general settings menu is now fully functional. also fixed the bug where ryujinx crashes when it trys to load an invalid gamedir

This commit is contained in:
Xpl0itR 2019-06-09 01:36:12 +01:00
commit 38155b747a
No known key found for this signature in database
GPG key ID: 91798184109676AD
11 changed files with 52 additions and 31 deletions

View file

@ -26,10 +26,7 @@ namespace Ryujinx
public static void Init() public static void Init()
{ {
using (Stream iconstream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Ryujinx.ryujinxROMIcon.png")) RyujinxROMIcon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.GUI.assets.ryujinxROMIcon.png", 75, 75);
{
RyujinxROMIcon = new Gdk.Pixbuf(iconstream, 75, 75);
}
string dat = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "GameDirs.dat"); string dat = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "GameDirs.dat");
if (File.Exists(dat) == false) { File.Create(dat).Close(); } if (File.Exists(dat) == false) { File.Create(dat).Close(); }
@ -38,7 +35,7 @@ namespace Ryujinx
foreach (string GameDir in GameDirs) foreach (string GameDir in GameDirs)
{ {
if (Directory.Exists(GameDir) == false) { Logger.PrintError(LogClass.Application, "There is an invalid game directory in \"GameDirs.dat\""); } if (Directory.Exists(GameDir) == false) { Logger.PrintError(LogClass.Application, $"\"GameDirs.dat\" contains an invalid directory: \"{GameDir}\""); continue; }
DirectoryInfo GameDirInfo = new DirectoryInfo(GameDir); DirectoryInfo GameDirInfo = new DirectoryInfo(GameDir);
foreach (var Game in GameDirInfo.GetFiles()) foreach (var Game in GameDirInfo.GetFiles())
@ -73,7 +70,13 @@ namespace Ryujinx
{ {
BinaryReader Reader = new BinaryReader(Input); BinaryReader Reader = new BinaryReader(Input);
if (Path.GetExtension(filePath) == ".nro") if ((Path.GetExtension(filePath) == ".nsp") || (Path.GetExtension(filePath) == ".pfs0")) { return RyujinxROMIcon; }
else if (Path.GetExtension(filePath) == ".xci") { return RyujinxROMIcon; }
else if (Path.GetExtension(filePath) == ".nca") { return RyujinxROMIcon; }
else if (Path.GetExtension(filePath) == ".nro")
{ {
Input.Seek(24, SeekOrigin.Begin); Input.Seek(24, SeekOrigin.Begin);
int AssetOffset = Reader.ReadInt32(); int AssetOffset = Reader.ReadInt32();
@ -97,10 +100,8 @@ namespace Ryujinx
} }
else { return RyujinxROMIcon; } else { return RyujinxROMIcon; }
} }
else
{ else { return RyujinxROMIcon; }
return RyujinxROMIcon; //temp
}
} }
} }
} }

View file

@ -10,9 +10,11 @@ using Ryujinx.HLE.Input;
using Ryujinx.UI.Input; using Ryujinx.UI.Input;
using System; using System;
using System.IO; using System.IO;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Utf8Json; using Utf8Json;
using Utf8Json.Resolvers; using Utf8Json.Resolvers;
using JsonPrettyPrinterPlus;
namespace Ryujinx namespace Ryujinx
{ {
@ -182,6 +184,21 @@ namespace Ryujinx
} }
} }
/// <summary>
/// Save a configuration file to disk
/// </summary>
/// <param name="path">The path to the JSON configuration file</param>
public static void SaveConfig(Configuration config, string path)
{
var resolver = CompositeResolver.Create(
new[] { new ConfigurationEnumFormatter<Key>() },
new[] { StandardResolver.AllowPrivateSnakeCase }
);
var data = JsonSerializer.Serialize(config, resolver);
File.WriteAllText(path, Encoding.UTF8.GetString(data, 0, data.Length).PrettyPrintJson());
}
/// <summary> /// <summary>
/// Configures a <see cref="Switch"/> instance /// Configures a <see cref="Switch"/> instance
/// </summary> /// </summary>

View file

@ -3,8 +3,7 @@ using GUI = Gtk.Builder.ObjectAttribute;
using Ryujinx.HLE.HOS.SystemState; using Ryujinx.HLE.HOS.SystemState;
using System; using System;
using System.IO; using System.IO;
using Utf8Json; using System.Reflection;
using Utf8Json.Resolvers;
namespace Ryujinx namespace Ryujinx
{ {
@ -15,6 +14,7 @@ namespace Ryujinx
internal static Configuration SwitchConfig { get; private set; } internal static Configuration SwitchConfig { get; private set; }
//UI Controls //UI Controls
[GUI] Window GSWin;
[GUI] CheckButton ErrorLogToggle; [GUI] CheckButton ErrorLogToggle;
[GUI] CheckButton WarningLogToggle; [GUI] CheckButton WarningLogToggle;
[GUI] CheckButton InfoLogToggle; [GUI] CheckButton InfoLogToggle;
@ -37,7 +37,7 @@ namespace Ryujinx
public static void ConfigureSettings(Configuration Instance) { SwitchConfig = Instance; } public static void ConfigureSettings(Configuration Instance) { SwitchConfig = Instance; }
public GeneralSettings(HLE.Switch _device) : this(new Builder("Ryujinx.GeneralSettings.glade"), _device) { } public GeneralSettings(HLE.Switch _device) : this(new Builder("Ryujinx.GUI.GeneralSettings.glade"), _device) { }
private GeneralSettings(Builder builder, HLE.Switch _device) : base(builder.GetObject("GSWin").Handle) private GeneralSettings(Builder builder, HLE.Switch _device) : base(builder.GetObject("GSWin").Handle)
{ {
@ -45,8 +45,8 @@ namespace Ryujinx
builder.Autoconnect(this); builder.Autoconnect(this);
SaveToggle.Toggled += SaveToggle_Activated; GSWin.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.GUI.assets.ryujinxIcon.png");
CloseToggle.Toggled += CloseToggle_Activated;
CustThemeToggle.Clicked += CustThemeToggle_Activated; CustThemeToggle.Clicked += CustThemeToggle_Activated;
if (SwitchConfig.LoggingEnableError) { ErrorLogToggle.Click(); } if (SwitchConfig.LoggingEnableError) { ErrorLogToggle.Click(); }
@ -102,6 +102,7 @@ namespace Ryujinx
SwitchConfig.SystemLanguage = (SystemLanguage)Enum.Parse(typeof(SystemLanguage), SystemLanguageSelect.ActiveId); SwitchConfig.SystemLanguage = (SystemLanguage)Enum.Parse(typeof(SystemLanguage), SystemLanguageSelect.ActiveId);
SwitchConfig.CustomThemePath = CustThemeDir.Buffer.Text; SwitchConfig.CustomThemePath = CustThemeDir.Buffer.Text;
Configuration.SaveConfig(SwitchConfig, System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.jsonc"));
File.WriteAllText("./GameDirs.dat", GameDirsBox.Buffer.Text); File.WriteAllText("./GameDirs.dat", GameDirsBox.Buffer.Text);
Configuration.Configure(device, SwitchConfig); Configuration.Configure(device, SwitchConfig);

View file

@ -6,7 +6,6 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="title" translatable="yes">Ryujinx - General Settings (Read-Only)</property> <property name="title" translatable="yes">Ryujinx - General Settings (Read-Only)</property>
<property name="default_height">500</property> <property name="default_height">500</property>
<property name="icon">ryujinxIcon.png</property>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
@ -409,6 +408,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
<signal name="toggled" handler="SaveToggle_Activated" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -422,6 +422,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
<signal name="toggled" handler="CloseToggle_Activated" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>

View file

@ -3,6 +3,7 @@ using GUI = Gtk.Builder.ObjectAttribute;
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using System; using System;
using System.IO; using System.IO;
using System.Reflection;
namespace Ryujinx namespace Ryujinx
{ {
@ -15,13 +16,14 @@ namespace Ryujinx
internal ListStore TableStore { get; private set; } internal ListStore TableStore { get; private set; }
//UI Controls //UI Controls
[GUI] Window MainWin;
[GUI] MenuItem NFC; [GUI] MenuItem NFC;
[GUI] MenuItem ControlSettingsMenu; [GUI] MenuItem ControlSettingsMenu;
[GUI] TreeView GameTable; [GUI] TreeView GameTable;
[GUI] ScrolledWindow GameTableWindow; [GUI] ScrolledWindow GameTableWindow;
[GUI] GLArea GLScreen; [GUI] GLArea GLScreen;
public MainMenu(HLE.Switch _device, Application _gtkapp) : this(new Builder("Ryujinx.MainMenu.glade"), _device, _gtkapp) { } public MainMenu(HLE.Switch _device, Application _gtkapp) : this(new Builder("Ryujinx.GUI.MainMenu.glade"), _device, _gtkapp) { }
private MainMenu(Builder builder, HLE.Switch _device, Application _gtkapp) : base(builder.GetObject("MainWin").Handle) private MainMenu(Builder builder, HLE.Switch _device, Application _gtkapp) : base(builder.GetObject("MainWin").Handle)
{ {
@ -38,6 +40,7 @@ namespace Ryujinx
} }
builder.Autoconnect(this); builder.Autoconnect(this);
MainWin.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.GUI.assets.ryujinxIcon.png");
GameTableWindow.Show(); GameTableWindow.Show();
GLScreen.Hide(); GLScreen.Hide();
@ -84,7 +87,7 @@ namespace Ryujinx
} }
else else
{ {
css_provider.LoadFromPath("Theme.css"); css_provider.LoadFromPath("./GUI/assets/Theme.css");
} }
StyleContext.AddProviderForScreen(Gdk.Screen.Default, css_provider, 800); StyleContext.AddProviderForScreen(Gdk.Screen.Default, css_provider, 800);
@ -237,7 +240,7 @@ namespace Ryujinx
AboutDialog about = new AboutDialog AboutDialog about = new AboutDialog
{ {
ProgramName = "Ryujinx", ProgramName = "Ryujinx",
Icon = new Gdk.Pixbuf("./ryujinxIcon.png"), Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.GUI.assets.ryujinxIcon.png"),
Version = "Version x.x.x", Version = "Version x.x.x",
Authors = new string[] { "gdkchan", "Ac_K", "LDj3SNuD", "emmauss", "MerryMage", "MS-DOS1999", "Thog", "jD", "BaronKiko", "Dr.Hacknik", "Lordmau5", "(and Xpl0itR did a bit of work too :D)" }, Authors = new string[] { "gdkchan", "Ac_K", "LDj3SNuD", "emmauss", "MerryMage", "MS-DOS1999", "Thog", "jD", "BaronKiko", "Dr.Hacknik", "Lordmau5", "(and Xpl0itR did a bit of work too :D)" },
Copyright = "Unlicense", Copyright = "Unlicense",

View file

@ -7,8 +7,7 @@
<property name="title" translatable="yes">Ryujinx</property> <property name="title" translatable="yes">Ryujinx</property>
<property name="window_position">center</property> <property name="window_position">center</property>
<property name="default_width">1280</property> <property name="default_width">1280</property>
<property name="default_height">745</property> <property name="default_height">750</property>
<property name="icon">ryujinxIcon.png</property>
<property name="gravity">center</property> <property name="gravity">center</property>
<child type="titlebar"> <child type="titlebar">
<placeholder/> <placeholder/>

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Before After
Before After

View file

@ -25,7 +25,7 @@ namespace Ryujinx
{ {
Console.Title = "Ryujinx Console"; Console.Title = "Ryujinx Console";
string parentDir = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory).Parent.ToString(); string parentDir = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory).ToString();
string systemPATH = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine); string systemPATH = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine);
Environment.SetEnvironmentVariable("Path", $"{Path.Combine(parentDir, "bin")};{systemPATH}"); Environment.SetEnvironmentVariable("Path", $"{Path.Combine(parentDir, "bin")};{systemPATH}");

View file

@ -19,14 +19,16 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="GeneralSettings.glade" /> <EmbeddedResource Include="GUI\assets\ryujinxIcon.png" />
<EmbeddedResource Include="MainMenu.glade" /> <EmbeddedResource Include="GUI\assets\ryujinxROMIcon.png" />
<EmbeddedResource Include="ryujinxROMIcon.png" /> <EmbeddedResource Include="GUI\GeneralSettings.glade" />
<EmbeddedResource Include="GUI\MainMenu.glade" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DiscordRichPresence" Version="1.0.108" /> <PackageReference Include="DiscordRichPresence" Version="1.0.108" />
<PackageReference Include="GtkSharp" Version="3.22.24.37" /> <PackageReference Include="GtkSharp" Version="3.22.24.37" />
<PackageReference Include="JsonPrettyPrinter" Version="1.0.1.1" />
<PackageReference Include="OpenTK.NetStandard" Version="1.0.4" /> <PackageReference Include="OpenTK.NetStandard" Version="1.0.4" />
</ItemGroup> </ItemGroup>
@ -43,15 +45,12 @@
<None Update="Config.jsonc"> <None Update="Config.jsonc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Update="GUI\assets\Theme.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="RPsupported.dat"> <None Update="RPsupported.dat">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Update="ryujinxIcon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Theme.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup> </ItemGroup>
</Project> </Project>