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:
parent
6672b6c1de
commit
38155b747a
11 changed files with 52 additions and 31 deletions
|
@ -26,10 +26,7 @@ namespace Ryujinx
|
|||
|
||||
public static void Init()
|
||||
{
|
||||
using (Stream iconstream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Ryujinx.ryujinxROMIcon.png"))
|
||||
{
|
||||
RyujinxROMIcon = new Gdk.Pixbuf(iconstream, 75, 75);
|
||||
}
|
||||
RyujinxROMIcon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.GUI.assets.ryujinxROMIcon.png", 75, 75);
|
||||
|
||||
string dat = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "GameDirs.dat");
|
||||
if (File.Exists(dat) == false) { File.Create(dat).Close(); }
|
||||
|
@ -38,7 +35,7 @@ namespace Ryujinx
|
|||
|
||||
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);
|
||||
foreach (var Game in GameDirInfo.GetFiles())
|
||||
|
@ -73,7 +70,13 @@ namespace Ryujinx
|
|||
{
|
||||
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);
|
||||
int AssetOffset = Reader.ReadInt32();
|
||||
|
@ -97,10 +100,8 @@ namespace Ryujinx
|
|||
}
|
||||
else { return RyujinxROMIcon; }
|
||||
}
|
||||
else
|
||||
{
|
||||
return RyujinxROMIcon; //temp
|
||||
}
|
||||
|
||||
else { return RyujinxROMIcon; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,11 @@ using Ryujinx.HLE.Input;
|
|||
using Ryujinx.UI.Input;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Utf8Json;
|
||||
using Utf8Json.Resolvers;
|
||||
using JsonPrettyPrinterPlus;
|
||||
|
||||
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>
|
||||
/// Configures a <see cref="Switch"/> instance
|
||||
/// </summary>
|
||||
|
|
|
@ -3,8 +3,7 @@ using GUI = Gtk.Builder.ObjectAttribute;
|
|||
using Ryujinx.HLE.HOS.SystemState;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Utf8Json;
|
||||
using Utf8Json.Resolvers;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Ryujinx
|
||||
{
|
||||
|
@ -15,6 +14,7 @@ namespace Ryujinx
|
|||
internal static Configuration SwitchConfig { get; private set; }
|
||||
|
||||
//UI Controls
|
||||
[GUI] Window GSWin;
|
||||
[GUI] CheckButton ErrorLogToggle;
|
||||
[GUI] CheckButton WarningLogToggle;
|
||||
[GUI] CheckButton InfoLogToggle;
|
||||
|
@ -37,7 +37,7 @@ namespace Ryujinx
|
|||
|
||||
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)
|
||||
{
|
||||
|
@ -45,8 +45,8 @@ namespace Ryujinx
|
|||
|
||||
builder.Autoconnect(this);
|
||||
|
||||
SaveToggle.Toggled += SaveToggle_Activated;
|
||||
CloseToggle.Toggled += CloseToggle_Activated;
|
||||
GSWin.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.GUI.assets.ryujinxIcon.png");
|
||||
|
||||
CustThemeToggle.Clicked += CustThemeToggle_Activated;
|
||||
|
||||
if (SwitchConfig.LoggingEnableError) { ErrorLogToggle.Click(); }
|
||||
|
@ -102,6 +102,7 @@ namespace Ryujinx
|
|||
SwitchConfig.SystemLanguage = (SystemLanguage)Enum.Parse(typeof(SystemLanguage), SystemLanguageSelect.ActiveId);
|
||||
SwitchConfig.CustomThemePath = CustThemeDir.Buffer.Text;
|
||||
|
||||
Configuration.SaveConfig(SwitchConfig, System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.jsonc"));
|
||||
File.WriteAllText("./GameDirs.dat", GameDirsBox.Buffer.Text);
|
||||
|
||||
Configuration.Configure(device, SwitchConfig);
|
|
@ -6,7 +6,6 @@
|
|||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">Ryujinx - General Settings (Read-Only)</property>
|
||||
<property name="default_height">500</property>
|
||||
<property name="icon">ryujinxIcon.png</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
|
@ -409,6 +408,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="toggled" handler="SaveToggle_Activated" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -422,6 +422,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="toggled" handler="CloseToggle_Activated" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
|
@ -3,6 +3,7 @@ using GUI = Gtk.Builder.ObjectAttribute;
|
|||
using Ryujinx.Common.Logging;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Ryujinx
|
||||
{
|
||||
|
@ -15,13 +16,14 @@ namespace Ryujinx
|
|||
internal ListStore TableStore { get; private set; }
|
||||
|
||||
//UI Controls
|
||||
[GUI] Window MainWin;
|
||||
[GUI] MenuItem NFC;
|
||||
[GUI] MenuItem ControlSettingsMenu;
|
||||
[GUI] TreeView GameTable;
|
||||
[GUI] ScrolledWindow GameTableWindow;
|
||||
[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)
|
||||
{
|
||||
|
@ -38,6 +40,7 @@ namespace Ryujinx
|
|||
}
|
||||
|
||||
builder.Autoconnect(this);
|
||||
MainWin.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.GUI.assets.ryujinxIcon.png");
|
||||
GameTableWindow.Show();
|
||||
GLScreen.Hide();
|
||||
|
||||
|
@ -84,7 +87,7 @@ namespace Ryujinx
|
|||
}
|
||||
else
|
||||
{
|
||||
css_provider.LoadFromPath("Theme.css");
|
||||
css_provider.LoadFromPath("./GUI/assets/Theme.css");
|
||||
}
|
||||
|
||||
StyleContext.AddProviderForScreen(Gdk.Screen.Default, css_provider, 800);
|
||||
|
@ -237,7 +240,7 @@ namespace Ryujinx
|
|||
AboutDialog about = new AboutDialog
|
||||
{
|
||||
ProgramName = "Ryujinx",
|
||||
Icon = new Gdk.Pixbuf("./ryujinxIcon.png"),
|
||||
Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.GUI.assets.ryujinxIcon.png"),
|
||||
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)" },
|
||||
Copyright = "Unlicense",
|
|
@ -7,8 +7,7 @@
|
|||
<property name="title" translatable="yes">Ryujinx</property>
|
||||
<property name="window_position">center</property>
|
||||
<property name="default_width">1280</property>
|
||||
<property name="default_height">745</property>
|
||||
<property name="icon">ryujinxIcon.png</property>
|
||||
<property name="default_height">750</property>
|
||||
<property name="gravity">center</property>
|
||||
<child type="titlebar">
|
||||
<placeholder/>
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
@ -25,7 +25,7 @@ namespace Ryujinx
|
|||
{
|
||||
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);
|
||||
Environment.SetEnvironmentVariable("Path", $"{Path.Combine(parentDir, "bin")};{systemPATH}");
|
||||
|
||||
|
|
|
@ -19,14 +19,16 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="GeneralSettings.glade" />
|
||||
<EmbeddedResource Include="MainMenu.glade" />
|
||||
<EmbeddedResource Include="ryujinxROMIcon.png" />
|
||||
<EmbeddedResource Include="GUI\assets\ryujinxIcon.png" />
|
||||
<EmbeddedResource Include="GUI\assets\ryujinxROMIcon.png" />
|
||||
<EmbeddedResource Include="GUI\GeneralSettings.glade" />
|
||||
<EmbeddedResource Include="GUI\MainMenu.glade" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DiscordRichPresence" Version="1.0.108" />
|
||||
<PackageReference Include="GtkSharp" Version="3.22.24.37" />
|
||||
<PackageReference Include="JsonPrettyPrinter" Version="1.0.1.1" />
|
||||
<PackageReference Include="OpenTK.NetStandard" Version="1.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -43,15 +45,12 @@
|
|||
<None Update="Config.jsonc">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GUI\assets\Theme.css">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="RPsupported.dat">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ryujinxIcon.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Theme.css">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
Loading…
Add table
Reference in a new issue