mika76 / mamesaver

Mamesaver is a mame emulated screensaver - get all the good ol' games playing their demo modes while you procrastinate and enjoy!
https://mika76.github.io/mamesaver/
MIT License
36 stars 10 forks source link

Added dynamic game overlay #15

Closed nullpainter closed 5 years ago

nullpainter commented 5 years ago

As per #12, this commit:

  1. Removes the splash screen with Mame logo and game information
  2. Adds a dynamic Mame layout builder
  3. Adds a dynamic game information image to display in the footer of the dynamic layout
  4. Adds a test project

The layouts and images are stored in a temporary directory and deleted on Mamesaver exit. Layouts support both horizontal and vertical games, and the game is scaled down slightly to avoid overlap with the game and the information bar.

nullpainter commented 5 years ago

Hmm, Appveyor doesn't like the newer PackageReference style approach of NuGet packages. Let me downgrade to packages.config.

Edit: I've reverted to using the old style of NuGet package management, but it's not running the NuGet package restore. It's not the end of the world - currently - as the NuGet packages are only used for tests, but it would be good to get this sorted.

@mika76 this document suggests that nuget restore needs to be added to either the 'before build script' or in appveyor.yml. I'm assuming that both of these are at your side to configure?

mika76 commented 5 years ago

Strange - ok let me have a look at the appveyor config...

mika76 commented 5 years ago

Ok packages are getting installed now but there still seems to be some problem with the build...

nullpainter commented 5 years ago

Ok packages are getting installed now but there still seems to be some problem with the build...

Curious. The NuGet package restore looks perfect, but the build looks to be ignoring it. I'll have a look soon.

nullpainter commented 5 years ago

@mika76 I've taken the cheat's way out for now (namely, removing the test project). Will investigate later on when I have more time.

Edit: I've set up Appveyor on my fork and all problems go away when using an appveyor.yml file. I have a couple of failing tests (nothing critical) so will fix these in the morning.

mika76 commented 5 years ago

Feel free to add it here - The current settings are the basic-est of basic 😄

If I had to export the current build settings this would be the appveyor.yml file. I don't mind you sorting it out, just keep the artifacts...

version: 1.0.{build}
configuration: Release
platform: Any CPU
before_build:
- cmd: nuget restore
build:
  verbosity: minimal
artifacts:
- path: MamesaverDeploy\bin\Release\Mamesaver.msi
  name: Mamesaver.msi
- path: Mamesaver\bin\Release\Mamesaver.scr
  name: Mamesaver.scr
mika76 commented 5 years ago

I just tried it but I don't see any image or anything different really - except for the loader screen being removed...

mika76 commented 5 years ago

Ok so it seems to be the layout file structure - firstly the element <MameLayout> should all be lowercase and also the element <View> should have a name="xxx" attribute... (as per http://wiki.mamedev.org/index.php/LAY_File_Basics_-_Part_I)

I changed it manually and it seemed to work. Maybe different mame versions? I'm using Mame64 0.200

nullpainter commented 5 years ago

I just tried it but I don't see any image or anything different really - except for the loader screen being removed...

I've only seen this for games where I had bezels turned off - can you see if that's it? Will try at work in a few hours.

nullpainter commented 5 years ago

Ok so it seems to be the layout file structure

Nice work! Yeah - I'm using 0.191. Would you like me to update the code? Feel free if you've already got the hood up.

nullpainter commented 5 years ago

I suspect it was just the missing name attribute. I was using an existing layout file and modifying it and it seemed that that was optional.

mika76 commented 5 years ago

Seems I can't push to your repo - but here's a patch file...

From 23b275f47956750471a19d9d5662fc636e2bae69 Mon Sep 17 00:00:00 2001
From: Mladen Mihajlovic <mmihajlovic@gmail.com>
Date: Mon, 20 Aug 2018 20:36:53 +0200
Subject: [PATCH] Fixes to layout file for later versions of Mame

---
 Mamesaver/Layout/LayoutFactory.cs     | 1 +
 Mamesaver/Layout/Models/MameLayout.cs | 2 +-
 Mamesaver/Layout/Models/View.cs       | 3 +++
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/Mamesaver/Layout/LayoutFactory.cs b/Mamesaver/Layout/LayoutFactory.cs
index 1af3b96..1070628 100644
--- a/Mamesaver/Layout/LayoutFactory.cs
+++ b/Mamesaver/Layout/LayoutFactory.cs
@@ -43,6 +43,7 @@ namespace Mamesaver.Layout
                 Element = new Element { Name = "bezel", Image = new Image { File = LayoutConstants.TitleImage } },
                 View = new View
                 {
+                    Name = "Mamesaver",
                     Screen = new Screen
                     {
                         Index = 0,
diff --git a/Mamesaver/Layout/Models/MameLayout.cs b/Mamesaver/Layout/Models/MameLayout.cs
index 6977795..90fb1d3 100644
--- a/Mamesaver/Layout/Models/MameLayout.cs
+++ b/Mamesaver/Layout/Models/MameLayout.cs
@@ -2,7 +2,7 @@

 namespace Mamesaver.Layout.Models
 {
-    [XmlRoot("MameLayout")]
+    [XmlRoot("mamelayout")]
     public class MameLayout
     {
         [XmlAttribute("version")]
diff --git a/Mamesaver/Layout/Models/View.cs b/Mamesaver/Layout/Models/View.cs
index 0fec277..12c73bc 100644
--- a/Mamesaver/Layout/Models/View.cs
+++ b/Mamesaver/Layout/Models/View.cs
@@ -9,5 +9,8 @@ namespace Mamesaver.Layout.Models

         [XmlElement("bezel")]
         public Bezel Bezel { get; set; }
+
+        [XmlAttribute("name")]
+        public string Name { get; set; }
     }
 }
-- 
2.17.1.windows.1
nullpainter commented 5 years ago

Cheers! Sorry about that - forgot that my custom mame executable was probably a bit old...

mika76 commented 5 years ago

No prob at all - keeping up with Mame versions is always a fun game.

Here's another for readding artifacts to the appveyor.yml file

From b4c71c1c50675a62aec0420858f72b1fec159c4f Mon Sep 17 00:00:00 2001
From: Mladen Mihajlovic <mmihajlovic@gmail.com>
Date: Mon, 20 Aug 2018 20:53:30 +0200
Subject: [PATCH] Added artifacts to appveyor.yml

---
 Appveyor.yml | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/Appveyor.yml b/Appveyor.yml
index c7fc18e..910176d 100644
--- a/Appveyor.yml
+++ b/Appveyor.yml
@@ -2,8 +2,15 @@ version: 1.0.{build}
 image: Visual Studio 2017
 environment:
   EnableNuGetPackageRestore: true
+configuration: Release
+platform: Any CPU
 before_build:
 - cmd: >-
     nuget restore
 build:
-  verbosity: minimal
\ No newline at end of file
+  verbosity: minimal
+artifacts:
+- path: MamesaverDeploy\bin\Release\Mamesaver.msi
+  name: Mamesaver.msi
+- path: Mamesaver\bin\Release\Mamesaver.scr
+  name: Mamesaver.scr
\ No newline at end of file
-- 
2.17.1.windows.1
nullpainter commented 5 years ago

@mika76 patch applied and verified with Mame 0.200.

nullpainter commented 5 years ago

@mika76 I've just made a small tweak to align the text horizontally to the game itself. Think it looks a bit more grounded, particularly with widescreen monitors. Have also decreased the text brightness ever so slightly.

Up to you whether you deem these improvements or not. No issues if you don't want to include them!

mika76 commented 5 years ago

You don't like the appveyor patch? I just added the configuration and artifacts (otherwise appveryor deletes the resulting binaries)

mika76 commented 5 years ago

just made a small tweak to align the text horizontally to the game itself. Think it looks a bit more grounded, particularly with widescreen monitors. Have also decreased the text brightness ever so slightly.

Centered is awesome and text color will always be a subjective choice 😄 so just keep it how you like it

nullpainter commented 5 years ago

You don't like the appveyor patch?

I haven't had a chance to look at it, sorry!

nullpainter commented 5 years ago

@mika76, I've merged in @andyvans's changes, fixed conflicts and re-integrated the dynamic layout builder. I will continue in this branch for the layout options updates in #16 and let you know when we're good to go.

mika76 commented 5 years ago

@nullpainter cool - do you want me to merge and then do another PR or just continue with this one?

nullpainter commented 5 years ago

There were a bunch of merge conflicts which needed fixing. Also, this PR has the splash screen code which I had previously removed, so I think it makes sense for me to continue on this one.

mika76 commented 5 years ago

Cool no prob

nullpainter commented 5 years ago

@mika76 - closing this PR in lieu of a new PR containing the in-game titles, layout options, reinstated splash screen, fixes, tidying, tests and more fixes. Need to do a bit more testing still; will be early next week. Stay tuned!

nullpainter commented 5 years ago

In lieu of the impending PR, are you able to update your Appveyor Build worker image (under 'Environment') to Visual Studio 2017, if it isn't already? It looks like the default is 2015.

I've got NuGet to play ball, so we don't need a git-managed Appveyor configuration file.

mika76 commented 5 years ago

Sure. Done. Although I think if you include a appveryor.yml file it takes over the settings...

[edit]I don't really know what is best practice - yml file in git or settings on appveryor - git might be a bit more powerful when doing PR's since you can change settings without affecting other branches - but the plain and simple settings have worked till now - either way you're welcome to add a git yml file if you'd like - just add in the artifacts if you do...[/edit]