Minor fixes

This commit is contained in:
Xpl0itR 2019-11-16 13:30:37 +00:00 committed by unknown
parent 3b45fcdcc6
commit 6f8ba4eec2
No known key found for this signature in database
GPG key ID: 91798184109676AD
3 changed files with 59 additions and 54 deletions

View file

@ -9,6 +9,7 @@
010034e005c9c000
01004f8006a78000
010051f00ac5e000
010056e00853a000
0100574009f9e000
0100628004bce000
0100633007d48000
@ -16,13 +17,16 @@
010068f00aa78000
01006a800016e000
010072800cbe8000
01007300020fa000
01007330027ee000
0100749009844000
01007a4008486000
01007ef00011e000
010080b00ad66000
010094e00b52e000
01009aa000faa000
01009b90006dc000
01009cc00c97c000
0100a4200a284000
0100a5c00d162000
0100ae000aebc000

View file

@ -154,10 +154,10 @@
</packing>
</child>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="license">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Unlicenced</property>
<property name="label" translatable="yes">MIT License</property>
<property name="justify">center</property>
</object>
<packing>
@ -168,7 +168,7 @@
</packing>
</child>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="disclaimer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Ryujinx is not affiliated with Nintendo,

View file

@ -49,8 +49,7 @@ namespace Ryujinx.UI
private static ListStore _tableStore;
private static Task _updateGameTableTask;
private static bool _updatingGameTable;
private static bool _gameLoaded;
private static bool _ending;
@ -163,6 +162,7 @@ namespace Ryujinx.UI
_tableStore.SetSortFunc(5, TimePlayedSort);
_tableStore.SetSortFunc(6, LastPlayedSort);
_tableStore.SetSortFunc(8, FileSizeSort);
_tableStore.SetSortColumnId(0, SortType.Descending);
UpdateColumns();
#pragma warning disable CS4014
@ -187,21 +187,20 @@ namespace Ryujinx.UI
internal static void ApplyTheme()
{
if (SwitchSettings.SwitchConfig.EnableCustomTheme)
if (!SwitchSettings.SwitchConfig.EnableCustomTheme) return;
if (File.Exists(SwitchSettings.SwitchConfig.CustomThemePath) && (System.IO.Path.GetExtension(SwitchSettings.SwitchConfig.CustomThemePath) == ".css"))
{
CssProvider cssProvider = new CssProvider();
if (File.Exists(SwitchSettings.SwitchConfig.CustomThemePath) && (System.IO.Path.GetExtension(SwitchSettings.SwitchConfig.CustomThemePath) == ".css"))
{
cssProvider.LoadFromPath(SwitchSettings.SwitchConfig.CustomThemePath);
}
else
{
Logger.PrintWarning(LogClass.Application, $"The \"custom_theme_path\" section in \"Config.json\" contains an invalid path: \"{SwitchSettings.SwitchConfig.CustomThemePath}\"");
}
cssProvider.LoadFromPath(SwitchSettings.SwitchConfig.CustomThemePath);
StyleContext.AddProviderForScreen(Gdk.Screen.Default, cssProvider, 800);
}
else
{
Logger.PrintWarning(LogClass.Application, $"The \"custom_theme_path\" section in \"Config.json\" contains an invalid path: \"{SwitchSettings.SwitchConfig.CustomThemePath}\"");
}
}
private void UpdateColumns()
@ -251,15 +250,16 @@ namespace Ryujinx.UI
internal static async Task UpdateGameTable()
{
if (_updateGameTableTask != null && !_updateGameTableTask.IsCompleted) return;
if (_updatingGameTable) return;
_tableStore.Clear();
_updatingGameTable = true;
_treeView.HeadersClickable = false;
_tableStore.Clear();
_updateGameTableTask = Task.Run(() => ApplicationLibrary.LoadApplications(SwitchSettings.SwitchConfig.GameDirs, _device.System.KeySet, _device.System.State.DesiredTitleLanguage));
await _updateGameTableTask;
await Task.Run(() => ApplicationLibrary.LoadApplications(SwitchSettings.SwitchConfig.GameDirs, _device.System.KeySet, _device.System.State.DesiredTitleLanguage));
_treeView.HeadersClickable = true;
_updatingGameTable = false;
}
internal void LoadApplication(string path)
@ -419,51 +419,50 @@ namespace Ryujinx.UI
private static void End()
{
if (!_ending)
if (_ending) return;
_ending = true;
if (_gameLoaded)
{
_ending = true;
string metadataFolder = System.IO.Path.Combine(new VirtualFileSystem().GetBasePath(), "games", _device.System.TitleId, "gui");
string metadataFile = System.IO.Path.Combine(metadataFolder, "metadata.json");
if (_gameLoaded)
IJsonFormatterResolver resolver = CompositeResolver.Create(new[] { StandardResolver.AllowPrivateSnakeCase });
ApplicationMetadata appMetadata;
if (!File.Exists(metadataFile))
{
string metadataFolder = System.IO.Path.Combine(new VirtualFileSystem().GetBasePath(), "games", _device.System.TitleId, "gui");
string metadataFile = System.IO.Path.Combine(metadataFolder, "metadata.json");
Directory.CreateDirectory(metadataFolder);
IJsonFormatterResolver resolver = CompositeResolver.Create(new[] { StandardResolver.AllowPrivateSnakeCase });
ApplicationMetadata appMetadata;
if (!File.Exists(metadataFile))
appMetadata = new ApplicationMetadata
{
Directory.CreateDirectory(metadataFolder);
Favorite = false,
TimePlayed = 0,
LastPlayed = "Never"
};
appMetadata = new ApplicationMetadata
{
Favorite = false,
TimePlayed = 0,
LastPlayed = "Never"
};
byte[] data = JsonSerializer.Serialize(appMetadata, resolver);
File.WriteAllText(metadataFile, Encoding.UTF8.GetString(data, 0, data.Length).PrettyPrintJson());
}
using (Stream stream = File.OpenRead(metadataFile))
{
appMetadata = JsonSerializer.Deserialize<ApplicationMetadata>(stream, resolver);
}
appMetadata.TimePlayed += Math.Round(DateTime.UtcNow.Subtract(DateTime.Parse(appMetadata.LastPlayed)).TotalSeconds, MidpointRounding.AwayFromZero);
byte[] saveData = JsonSerializer.Serialize(appMetadata, resolver);
File.WriteAllText(metadataFile, Encoding.UTF8.GetString(saveData, 0, saveData.Length).PrettyPrintJson());
byte[] data = JsonSerializer.Serialize(appMetadata, resolver);
File.WriteAllText(metadataFile, Encoding.UTF8.GetString(data, 0, data.Length).PrettyPrintJson());
}
Profile.FinishProfiling();
_device.Dispose();
_audioOut.Dispose();
DiscordClient?.Dispose();
Logger.Shutdown();
Environment.Exit(0);
using (Stream stream = File.OpenRead(metadataFile))
{
appMetadata = JsonSerializer.Deserialize<ApplicationMetadata>(stream, resolver);
}
appMetadata.TimePlayed += Math.Round(DateTime.UtcNow.Subtract(DateTime.Parse(appMetadata.LastPlayed)).TotalSeconds, MidpointRounding.AwayFromZero);
byte[] saveData = JsonSerializer.Serialize(appMetadata, resolver);
File.WriteAllText(metadataFile, Encoding.UTF8.GetString(saveData, 0, saveData.Length).PrettyPrintJson());
}
Profile.FinishProfiling();
_device.Dispose();
_audioOut.Dispose();
DiscordClient?.Dispose();
Logger.Shutdown();
Environment.Exit(0);
}
/// <summary>
@ -590,6 +589,8 @@ namespace Ryujinx.UI
private void StopEmulation_Pressed(object sender, EventArgs args)
{
// TODO: Write logic to kill running game
_gameLoaded = false;
}
private void FullScreen_Toggled(object sender, EventArgs args)