From e208b383395a46f914ca550bd18516a220bf43f0 Mon Sep 17 00:00:00 2001 From: DDH69 <74479241+DDH69@users.noreply.github.com> Date: Mon, 10 Mar 2025 10:57:27 +1030 Subject: [PATCH 1/2] Add ability to use either Platform or Emulator --- Program.cs | 78 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 25 deletions(-) diff --git a/Program.cs b/Program.cs index 802f77d..e3f41d4 100644 --- a/Program.cs +++ b/Program.cs @@ -4,14 +4,17 @@ namespace DOFConnect { using Unbroken.LaunchBox.Plugins; using Unbroken.LaunchBox.Plugins.Data; - using System.IO.Pipes; - - // Class to handle system events in LaunchBox/BigBox + using System.IO.Pipes; + using System.Text.Json; + using System.Reflection; + + // Class to handle system events in LaunchBox/BigBox public partial class SystemEvents : ISystemEventsPlugin { string gCurrentGame = ""; string gCurrentPlatform = "platforms"; - string gCurrentEmulator = ""; + string gCurrentCategory = ""; + Boolean UseEmulator = true; public void OnEventRaised(string eventType) { @@ -19,7 +22,8 @@ public void OnEventRaised(string eventType) switch (eventType) { case SystemEventTypes.PluginInitialized: - // Do nothing + // Load the configuration + LoadConfig(); break; case SystemEventTypes.LaunchBoxStartupCompleted: // Play cabinet's marquee, per the configuration @@ -45,6 +49,23 @@ public void OnEventRaised(string eventType) } } + public class DOFConnectConfig + { + public string CategorySource { get; set; } + } + + // Load up the configuration details + private void LoadConfig() + { + using (StreamReader r = new StreamReader(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)+"\\DOFConnect.json")) + { + string json = r.ReadToEnd(); + DOFConnectConfig config = JsonSerializer.Deserialize(json); + if (config.CategorySource == "Platform") UseEmulator = false; + sendMsg($"INFO=DOFConnect v3 category set to {config.CategorySource}"); + } + } + // Helper method to handle selection changes private void HandleSelectionChanged() { @@ -59,29 +80,36 @@ private void HandleSelectionChanged() if (gCurrentGame != CleanGameName(game.ApplicationPath)) { gCurrentGame = CleanGameName(game.ApplicationPath); - gCurrentEmulator = emulator.Title; - sendMenuRom(gCurrentEmulator, gCurrentGame); + if (UseEmulator) + { + gCurrentCategory = emulator.Title; + } + else + { + gCurrentCategory = game.Platform; + } + sendMenuRom(gCurrentCategory, gCurrentGame); } } else - { - if (selectedPlatform != null) - { - // If platform is not null, then we just selected a platform - // If we changed platform - if (gCurrentPlatform != selectedPlatform.Name) - { - gCurrentPlatform = selectedPlatform.Name; - if (selectedGames != null) - { - sendMenuRom(gCurrentPlatform, gCurrentGame); - } - else - { - // No game selected? Then display platform's marquee - sendMenuRom("platforms", gCurrentPlatform); - } - } + { + if (selectedPlatform != null) + { + // If platform is not null, then we just selected a platform + // If we changed platform + if (gCurrentPlatform != selectedPlatform.Name) + { + gCurrentPlatform = selectedPlatform.Name; + if (selectedGames != null) + { + sendMenuRom(gCurrentPlatform, gCurrentGame); + } + else + { + // No game selected? Then display platform's marquee + sendMenuRom("platforms", gCurrentPlatform); + } + } } } From 25ef2a5212298688088440ae6aa9181ffa81c837 Mon Sep 17 00:00:00 2001 From: DDH69 <74479241+DDH69@users.noreply.github.com> Date: Mon, 10 Mar 2025 10:58:41 +1030 Subject: [PATCH 2/2] Configuration file for DOFConnect --- DOFConnect.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 DOFConnect.json diff --git a/DOFConnect.json b/DOFConnect.json new file mode 100644 index 0000000..9c013d3 --- /dev/null +++ b/DOFConnect.json @@ -0,0 +1,3 @@ +{ + "CategorySource": "Emulator" +} \ No newline at end of file