Did some testing and fixed some bugs

Im not happy with one of the fixes so i will do it properly an upcoming commit
This commit is contained in:
Xpl0itR 2019-07-05 12:28:22 +01:00
commit 9518dc831c
No known key found for this signature in database
GPG key ID: 91798184109676AD
3 changed files with 45 additions and 44 deletions

View file

@ -685,7 +685,7 @@ namespace Ryujinx.HLE.HOS
// It's only safe to release resources once all threads // It's only safe to release resources once all threads
// have exited. // have exited.
ThreadCounter.Signal(); ThreadCounter.Signal();
ThreadCounter.Wait(); //ThreadCounter.Wait();
Scheduler.Dispose(); Scheduler.Dispose();

View file

@ -37,6 +37,7 @@ namespace Ryujinx
#pragma warning disable 649 #pragma warning disable 649
[GUI] Window MainWin; [GUI] Window MainWin;
[GUI] CheckMenuItem FullScreen; [GUI] CheckMenuItem FullScreen;
[GUI] MenuItem ReturnMain;
[GUI] MenuItem Nfc; [GUI] MenuItem Nfc;
[GUI] Box Box; [GUI] Box Box;
[GUI] ScrolledWindow GameTableWindow; [GUI] ScrolledWindow GameTableWindow;
@ -98,6 +99,7 @@ namespace Ryujinx
Box.Remove(GlScreen); Box.Remove(GlScreen);
Nfc.Sensitive = false; Nfc.Sensitive = false;
ReturnMain.Sensitive = false;
GameTable.AppendColumn("Icon" , new CellRendererPixbuf(), "pixbuf", 0); GameTable.AppendColumn("Icon" , new CellRendererPixbuf(), "pixbuf", 0);
GameTable.AppendColumn("Game" , new CellRendererText() , "text" , 1); GameTable.AppendColumn("Game" , new CellRendererText() , "text" , 1);
@ -153,7 +155,7 @@ namespace Ryujinx
StyleContext.AddProviderForScreen(Gdk.Screen.Default, cssProvider, 800); StyleContext.AddProviderForScreen(Gdk.Screen.Default, cssProvider, 800);
} }
private static void LoadApplication(string path) private void LoadApplication(string path)
{ {
if (_GameLoaded) if (_GameLoaded)
{ {
@ -185,10 +187,6 @@ namespace Ryujinx
Logger.PrintInfo(LogClass.Application, "Loading as cart WITHOUT RomFS."); Logger.PrintInfo(LogClass.Application, "Loading as cart WITHOUT RomFS.");
_device.LoadCart(path); _device.LoadCart(path);
} }
new Thread(new ThreadStart(CreateGameWindow)).Start();
_GameLoaded = true;
} }
else if (File.Exists(path)) else if (File.Exists(path))
@ -213,33 +211,36 @@ namespace Ryujinx
_device.LoadProgram(path); _device.LoadProgram(path);
break; break;
} }
new Thread(new ThreadStart(CreateGameWindow)).Start();
_GameLoaded = true;
} }
else else
{ {
Logger.PrintWarning(LogClass.Application, "Please specify a valid XCI/NCA/NSP/PFS0/NRO file"); Logger.PrintWarning(LogClass.Application, "Please specify a valid XCI/NCA/NSP/PFS0/NRO file");
End();
} }
new Thread(new ThreadStart(CreateGameWindow)).Start();
_GameLoaded = true;
ReturnMain.Sensitive = true;
if (DiscordIntegrationEnabled) if (DiscordIntegrationEnabled)
{ {
if (File.ReadAllLines(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "RPsupported.dat")).Contains(_device.System.TitleID)) if (File.ReadAllLines(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "RPsupported.dat")).Contains(_device.System.TitleID))
{ {
DiscordPresence.Assets.LargeImageKey = _device.System.TitleID; DiscordPresence.Assets.LargeImageKey = _device.System.TitleID;
} }
DiscordPresence.Details = $"Playing {_device.System.TitleName}"; DiscordPresence.Details = $"Playing {_device.System.TitleName}";
DiscordPresence.State = string.IsNullOrWhiteSpace(_device.System.TitleID) ? string.Empty : _device.System.TitleID.ToUpper(); DiscordPresence.State = string.IsNullOrWhiteSpace(_device.System.TitleID) ? string.Empty : _device.System.TitleID.ToUpper();
DiscordPresence.Assets.LargeImageText = _device.System.TitleName; DiscordPresence.Assets.LargeImageText = _device.System.TitleName;
DiscordPresence.Assets.SmallImageKey = "ryujinx"; DiscordPresence.Assets.SmallImageKey = "ryujinx";
DiscordPresence.Assets.SmallImageText = "Ryujinx is an emulator for the Nintendo Switch"; DiscordPresence.Assets.SmallImageText = "Ryujinx is an emulator for the Nintendo Switch";
DiscordPresence.Timestamps = new Timestamps(DateTime.UnixEpoch); DiscordPresence.Timestamps = new Timestamps(DateTime.UtcNow);
DiscordClient.SetPresence(DiscordPresence); DiscordClient.SetPresence(DiscordPresence);
} }
if (_device.System.TitleID != null)
{
string appdataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string appdataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string savePath = System.IO.Path.Combine(appdataPath, "RyuFs", "nand", "user", "save", "0000000000000000", "savecommon", _device.System.TitleID); string savePath = System.IO.Path.Combine(appdataPath, "RyuFs", "nand", "user", "save", "0000000000000000", "savecommon", _device.System.TitleID);
using (FileStream fs = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat"))) using (FileStream fs = File.OpenWrite(System.IO.Path.Combine(savePath, "LastPlayed.dat")))
@ -250,22 +251,19 @@ namespace Ryujinx
} }
} }
} }
}
private static void CreateGameWindow() private static void CreateGameWindow()
{ {
using (GlScreen screen = new GlScreen(_device, _renderer)) using (GlScreen screen = new GlScreen(_device, _renderer))
{ {
screen.MainLoop(); screen.MainLoop();
Profile.FinishProfiling();
_device.Dispose();
_audioOut.Dispose();
} }
} }
private static void End() private static void End()
{
if (_device.System.TitleID != null)
{ {
string appdataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string appdataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string savePath = System.IO.Path.Combine(appdataPath, "RyuFs", "nand", "user", "save", "0000000000000000", "savecommon", _device.System.TitleID); string savePath = System.IO.Path.Combine(appdataPath, "RyuFs", "nand", "user", "save", "0000000000000000", "savecommon", _device.System.TitleID);
@ -294,7 +292,10 @@ namespace Ryujinx
} }
} }
} }
}
Profile.FinishProfiling();
_device.Dispose();
_audioOut.Dispose(); _audioOut.Dispose();
DiscordClient.Dispose(); DiscordClient.Dispose();
Logger.Shutdown(); Logger.Shutdown();
@ -351,7 +352,7 @@ namespace Ryujinx
private void Exit_Pressed(object o, EventArgs args) { End(); } private void Exit_Pressed(object o, EventArgs args) { End(); }
private void Window_Close(object obj, DeleteEventArgs args) { End(); } private void Window_Close(object o, DeleteEventArgs args) { End(); }
private void ReturnMain_Pressed(object o, EventArgs args) private void ReturnMain_Pressed(object o, EventArgs args)
{ {