diff --git a/3rdParty/3rdParty.csproj b/3rdParty/3rdParty.csproj new file mode 100644 index 0000000..8ac2d17 --- /dev/null +++ b/3rdParty/3rdParty.csproj @@ -0,0 +1,14 @@ + + + + net8.0 + _3rdParty + enable + enable + + + + + + + diff --git a/ScePSX/Core/DiscordRPC/RPCManager.cs b/3rdParty/DiscordRPC/RPCManager.cs similarity index 85% rename from ScePSX/Core/DiscordRPC/RPCManager.cs rename to 3rdParty/DiscordRPC/RPCManager.cs index a6b25c7..52f6ab7 100644 --- a/ScePSX/Core/DiscordRPC/RPCManager.cs +++ b/3rdParty/DiscordRPC/RPCManager.cs @@ -4,7 +4,7 @@ using DiscordRPC; using DiscordRPC.Logging; -namespace ScePSX.Core.DiscordRPC +namespace ScePSX.ThirdParty.DiscordRPC { public class RPCManager : IDisposable { @@ -21,7 +21,7 @@ public class RPCManager : IDisposable private Stopwatch _playTimeStopwatch; private string _platformName = ""; - private const string APP_ID = "1342671514892259388"; + private const string APP_ID = "1482446005763834111"; //test id, change in prod public void Initialize() { @@ -54,6 +54,7 @@ public void Initialize() _client.Initialize(); _playTimeStopwatch = new Stopwatch(); _initialized = true; + UpdatePresence(); Console.WriteLine("[DiscordRPC] Initialized successfully on {0}", _platformName); } catch (Exception ex) @@ -73,7 +74,7 @@ private string GetPlatformName() if (OperatingSystem.IsAndroid()) return "Android"; if (OperatingSystem.IsIOS()) - return "iOS"; + return "iOS"; //i dont think this will be ever the case but just in case return RuntimeInformation.OSDescription; } @@ -92,6 +93,7 @@ public void StartGame(string gameName, string diskId) public void SetPaused(bool paused) { + Console.WriteLine($"[DiscordRPC] SetPaused called: {paused}, initialized: {_initialized}, client: {_client != null}, diskId: '{_diskId}'"); if (!_initialized || _client == null || string.IsNullOrEmpty(_diskId)) return; _isPaused = paused; @@ -124,19 +126,26 @@ private void UpdatePresence() { if (_client == null) return; + bool isIdle = string.IsNullOrEmpty(_gameName); + bool isInGame = !isIdle && !_isPaused; + var presence = new RichPresence() { - Details = string.IsNullOrEmpty(_gameName) ? "ScePSX" : _gameName, - State = _isPaused ? $"Paused | {_platformName}" : $"{FormatPlayTime(_playTimeStopwatch.Elapsed)} | {_platformName}", - Timestamps = _isPaused ? new Timestamps() : new Timestamps(DateTime.UtcNow), - Assets = new Assets() + Details = isIdle ? "Menu" : _gameName, + State = _isPaused ? $"Paused | {_platformName}" : (isIdle ? $"Idle | {_platformName}" : $"{FormatPlayTime(_playTimeStopwatch.Elapsed)} | {_platformName}"), + Timestamps = isInGame ? new Timestamps(DateTime.UtcNow) : new Timestamps() + }; + + if (!isIdle) + { + presence.Assets = new Assets() { LargeImageKey = "logo", LargeImageText = "PlayStation 1 Emulator", SmallImageKey = _isPaused ? "paused" : "playing", SmallImageText = _isPaused ? "Paused" : "In Game" - } - }; + }; + } if (!string.IsNullOrEmpty(_diskId)) { diff --git a/AvaloniaUI/ScePSX.csproj b/AvaloniaUI/ScePSX.csproj index 252f5e8..39419e8 100644 --- a/AvaloniaUI/ScePSX.csproj +++ b/AvaloniaUI/ScePSX.csproj @@ -39,6 +39,16 @@ + + + + + PreserveNewest + + + PreserveNewest + + diff --git a/AvaloniaUI/UI/MainWindow.axaml.cs b/AvaloniaUI/UI/MainWindow.axaml.cs index 2ac8224..6f2ebf3 100644 --- a/AvaloniaUI/UI/MainWindow.axaml.cs +++ b/AvaloniaUI/UI/MainWindow.axaml.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Diagnostics; using System.IO; using System.Linq; @@ -11,7 +11,7 @@ using Avalonia.Interactivity; using Avalonia.Platform.Storage; using Avalonia.Threading; -using ScePSX.Core.DiscordRPC; +using ScePSX.ThirdParty.DiscordRPC; using ScePSX.Core.GPU; namespace ScePSX.UI; @@ -294,7 +294,8 @@ private void CleanCheckSet(MenuItem Menu, int CheckIdx) foreach (MenuItem child in Menu.Items.OfType()) child.IsChecked = false; - (Menu.Items[CheckIdx] as MenuItem).IsChecked = true; + if (CheckIdx >= 0 && CheckIdx < Menu.Items.Count) + (Menu.Items[CheckIdx] as MenuItem).IsChecked = true; } private void MainWindow_KeyUp(object? sender, KeyEventArgs e) diff --git a/AvaloniaUI/Utils/Translations.cs b/AvaloniaUI/Utils/Translations.cs index 25ab923..7a5b282 100644 --- a/AvaloniaUI/Utils/Translations.cs +++ b/AvaloniaUI/Utils/Translations.cs @@ -20,7 +20,7 @@ public class Translations private static SortedSet _AvailableLanguages; - public static string DefaultLanguage = ""; + public static string DefaultLanguage = "en"; public static Dictionary Languages = new Dictionary(); diff --git a/ScePSX.Avalonia.sln b/ScePSX.Avalonia.sln index c8da9bd..4999369 100644 --- a/ScePSX.Avalonia.sln +++ b/ScePSX.Avalonia.sln @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core", "ScePSX\Core.csproj" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScePSX", "AvaloniaUI\ScePSX.csproj", "{A284CBA8-2FF5-4A73-9374-84F0F836E811}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "3rdParty", "3rdParty\3rdParty.csproj", "{50665EE0-4C90-6705-A0AA-47709E31B14E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {A284CBA8-2FF5-4A73-9374-84F0F836E811}.Debug|Any CPU.Build.0 = Debug|Any CPU {A284CBA8-2FF5-4A73-9374-84F0F836E811}.Release|Any CPU.ActiveCfg = Release|Any CPU {A284CBA8-2FF5-4A73-9374-84F0F836E811}.Release|Any CPU.Build.0 = Release|Any CPU + {50665EE0-4C90-6705-A0AA-47709E31B14E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {50665EE0-4C90-6705-A0AA-47709E31B14E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {50665EE0-4C90-6705-A0AA-47709E31B14E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {50665EE0-4C90-6705-A0AA-47709E31B14E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ScePSX.Window.sln b/ScePSX.Window.sln index c1de7b0..f806319 100644 --- a/ScePSX.Window.sln +++ b/ScePSX.Window.sln @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScePSX.Win", "WindowUI\SceP EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core", "ScePSX\Core.csproj", "{D5B209D6-4B10-A5C9-1C7D-74897040277E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "3rdParty", "3rdParty\3rdParty.csproj", "{528F7AE4-C245-45D9-B893-995FD9AEF7C9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {D5B209D6-4B10-A5C9-1C7D-74897040277E}.Debug|Any CPU.Build.0 = Debug|Any CPU {D5B209D6-4B10-A5C9-1C7D-74897040277E}.Release|Any CPU.ActiveCfg = Release|Any CPU {D5B209D6-4B10-A5C9-1C7D-74897040277E}.Release|Any CPU.Build.0 = Release|Any CPU + {528F7AE4-C245-45D9-B893-995FD9AEF7C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {528F7AE4-C245-45D9-B893-995FD9AEF7C9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {528F7AE4-C245-45D9-B893-995FD9AEF7C9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {528F7AE4-C245-45D9-B893-995FD9AEF7C9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ScePSX/Core.csproj b/ScePSX/Core.csproj index 298726a..ee9d3e0 100644 --- a/ScePSX/Core.csproj +++ b/ScePSX/Core.csproj @@ -35,7 +35,21 @@ - + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + \ No newline at end of file diff --git a/WindowUI/Render/VulkanRender.resx b/WindowUI/Render/VulkanRender.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WindowUI/Render/VulkanRender.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WindowUI/ScePSX.Win.csproj b/WindowUI/ScePSX.Win.csproj index e4fffb6..d14663a 100644 --- a/WindowUI/ScePSX.Win.csproj +++ b/WindowUI/ScePSX.Win.csproj @@ -55,7 +55,20 @@ + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + \ No newline at end of file diff --git a/WindowUI/UI/Form_Main.cs b/WindowUI/UI/Form_Main.cs index 7fe3c36..52c20c8 100644 --- a/WindowUI/UI/Form_Main.cs +++ b/WindowUI/UI/Form_Main.cs @@ -1,5 +1,5 @@ using Microsoft.Win32; -using ScePSX.Core.DiscordRPC; +using ScePSX.ThirdParty.DiscordRPC; using ScePSX.Core.GPU; using ScePSX.Render; using ScePSX.Win.UI; @@ -809,11 +809,10 @@ private void MnuPause_Click(object sender, EventArgs e) { if (Core != null && Core.Running) { + bool wasPaused = Core.Pauseed; Core.Pause(); - if (Core.Pauseed) - RPCManager.Instance.SetPaused(true); - else - RPCManager.Instance.SetPaused(false); + while (Core.Pauseed == wasPaused) { } + RPCManager.Instance.SetPaused(Core.Pauseed); } } @@ -970,7 +969,10 @@ private void ButtonsDown(object sender, KeyEventArgs e) { if (Core.Pauseed) SimpleOSD.Close(); + bool wasPaused = Core.Pauseed; Core.Pause(); + while (Core.Pauseed == wasPaused) { } + RPCManager.Instance.SetPaused(Core.Pauseed); } return; } diff --git a/WindowUI/UI/Translations.cs b/WindowUI/UI/Translations.cs index 35fbacc..ce367e6 100644 --- a/WindowUI/UI/Translations.cs +++ b/WindowUI/UI/Translations.cs @@ -18,7 +18,7 @@ public class Translations private static SortedSet _AvailableLanguages; - public static string DefaultLanguage = null; + public static string DefaultLanguage = "en"; public static Dictionary Languages = new Dictionary(); @@ -246,15 +246,20 @@ public static string GetString(string CategoryId, string TextId, string LangId = } catch (Exception) { - //Console.Error.WriteLine("Can't find key '{0}.{1}.{2}'", CategoryId, TextId, LangId); - //Console.Error.WriteLine(value); try { - result = dictionary[Translations.DefaultLanguage]; + if (dictionary != null) + { + result = dictionary[Translations.DefaultLanguage]; + } + else + { + result = null; + } } catch { - result = null;//string.Format("{0}.{1}", CategoryId, TextId); + result = null; } } return result;