no name: Mii Editor applet support (#2419)

* no name: Mii Editor applet support

* addresses gdkchan feedback

* Fix comment

* Bypass MountCounter of MiiDatabaseManager

* Fix GetSettingsPlatformRegion

* Disable Applet Menu for unsupported firmwares
This commit is contained in:
Ac_K 2021-06-28 20:54:45 +02:00 committed by GitHub
parent fefd4619a5
commit a79b39b913
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 591 additions and 33 deletions

View file

@ -3,6 +3,7 @@ using ARMeilleure.Translation.PTC;
using Gtk;
using LibHac.Common;
using LibHac.FsSystem;
using LibHac.FsSystem.NcaUtils;
using LibHac.Ns;
using Ryujinx.Audio.Backends.Dummy;
using Ryujinx.Audio.Backends.OpenAL;
@ -87,6 +88,10 @@ namespace Ryujinx.Ui
[GUI] Box _statusBar;
[GUI] MenuItem _optionMenu;
[GUI] MenuItem _manageUserProfiles;
[GUI] MenuItem _fileMenu;
[GUI] MenuItem _loadApplicationFile;
[GUI] MenuItem _loadApplicationFolder;
[GUI] MenuItem _appletMenu;
[GUI] MenuItem _actionMenu;
[GUI] MenuItem _stopEmulation;
[GUI] MenuItem _simulateWakeUpMessage;
@ -165,6 +170,7 @@ namespace Ryujinx.Ui
_applicationLibrary.ApplicationAdded += Application_Added;
_applicationLibrary.ApplicationCountUpdated += ApplicationCount_Updated;
_fileMenu.StateChanged += FileMenu_StateChanged;
_actionMenu.StateChanged += ActionMenu_StateChanged;
_optionMenu.StateChanged += OptionMenu_StateChanged;
@ -575,7 +581,15 @@ namespace Ryujinx.Ui
SystemVersion firmwareVersion = _contentManager.GetCurrentFirmwareVersion();
bool isDirectory = Directory.Exists(path);
bool isDirectory = Directory.Exists(path);
bool isFirmwareTitle = false;
if (path.StartsWith("@SystemContent"))
{
path = _virtualFileSystem.SwitchPathToSystemPath(path);
isFirmwareTitle = true;
}
if (!SetupValidator.CanStartApplication(_contentManager, path, out UserError userError))
{
@ -636,7 +650,13 @@ namespace Ryujinx.Ui
Logger.Notice.Print(LogClass.Application, $"Using Firmware Version: {firmwareVersion?.VersionString}");
if (Directory.Exists(path))
if (isFirmwareTitle)
{
Logger.Info?.Print(LogClass.Application, "Loading as Firmware Title (NCA).");
_emulationContext.LoadNca(path);
}
else if (Directory.Exists(path))
{
string[] romFsFiles = Directory.GetFiles(path, "*.istorage");
@ -1100,6 +1120,20 @@ namespace Ryujinx.Ui
}
}
private void FileMenu_StateChanged(object o, StateChangedArgs args)
{
_appletMenu.Sensitive = _emulationContext == null && _contentManager.GetCurrentFirmwareVersion() != null && _contentManager.GetCurrentFirmwareVersion().Major > 3;
_loadApplicationFile.Sensitive = _emulationContext == null;
_loadApplicationFolder.Sensitive = _emulationContext == null;
}
private void Load_Mii_Edit_Applet(object sender, EventArgs args)
{
string contentPath = _contentManager.GetInstalledContentPath(0x0100000000001009, StorageId.NandSystem, NcaContentType.Program);
LoadApplication(contentPath);
}
private void Open_Ryu_Folder(object sender, EventArgs args)
{
OpenHelper.OpenFolder(AppDataManager.BaseDirPath);
@ -1217,6 +1251,15 @@ namespace Ryujinx.Ui
GtkDialog.CreateInfoDialog(dialogTitle, message);
Logger.Info?.Print(LogClass.Application, message);
// Purge Applet Cache.
DirectoryInfo miiEditorCacheFolder = new DirectoryInfo(System.IO.Path.Combine(AppDataManager.GamesDirPath, "0100000000001009", "cache"));
if (miiEditorCacheFolder.Exists)
{
miiEditorCacheFolder.Delete(true);
}
});
}
catch (Exception ex)

View file

@ -19,7 +19,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="FileMenu">
<object class="GtkMenuItem" id="_fileMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">File</property>
@ -29,7 +29,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="LoadApplicationFile">
<object class="GtkMenuItem" id="_loadApplicationFile">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Open a file chooser to chose a switch compatible file to load</property>
@ -39,7 +39,7 @@
</object>
</child>
<child>
<object class="GtkMenuItem" id="LoadApplicationFolder">
<object class="GtkMenuItem" id="_loadApplicationFolder">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Open a file chooser to chose a switch compatible, unpacked application to load</property>
@ -48,6 +48,30 @@
<signal name="activate" handler="Load_Application_Folder" swapped="no"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="_appletMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Load Applet</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="LoadMiiEditApplet">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Open Mii Editor Applet in Standalone mode</property>
<property name="label" translatable="yes">Mii Editor</property>
<property name="use_underline">True</property>
<signal name="activate" handler="Load_Mii_Edit_Applet" swapped="no"/>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem">
<property name="visible">True</property>