Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions DOFConnect.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CategorySource": "Emulator"
}
78 changes: 53 additions & 25 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,26 @@ 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)
{
// Event types : https://pluginapi.launchbox-app.com/html/3e3603e5-bab6-e510-689c-ee35c0f5f694.htm
switch (eventType)
{
case SystemEventTypes.PluginInitialized:
// Do nothing
// Load the configuration
LoadConfig();
break;
case SystemEventTypes.LaunchBoxStartupCompleted:
// Play cabinet's marquee, per the configuration
Expand All @@ -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<DOFConnectConfig>(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()
{
Expand All @@ -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);
}
}
}
}

Expand Down