MainWindow.cs 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778
  1. using ARMeilleure.Translation;
  2. using Gtk;
  3. using LibHac.Common;
  4. using LibHac.Common.Keys;
  5. using LibHac.Ncm;
  6. using LibHac.Ns;
  7. using LibHac.Tools.FsSystem;
  8. using LibHac.Tools.FsSystem.NcaUtils;
  9. using Ryujinx.Audio.Backends.Dummy;
  10. using Ryujinx.Audio.Backends.OpenAL;
  11. using Ryujinx.Audio.Backends.SDL2;
  12. using Ryujinx.Audio.Backends.SoundIo;
  13. using Ryujinx.Audio.Integration;
  14. using Ryujinx.Common;
  15. using Ryujinx.Common.Configuration;
  16. using Ryujinx.Common.Logging;
  17. using Ryujinx.Common.SystemInterop;
  18. using Ryujinx.Cpu;
  19. using Ryujinx.Graphics.GAL;
  20. using Ryujinx.Graphics.GAL.Multithreading;
  21. using Ryujinx.Graphics.OpenGL;
  22. using Ryujinx.Graphics.Vulkan;
  23. using Ryujinx.HLE.FileSystem;
  24. using Ryujinx.HLE.HOS;
  25. using Ryujinx.HLE.HOS.Services.Account.Acc;
  26. using Ryujinx.HLE.HOS.SystemState;
  27. using Ryujinx.Input.GTK3;
  28. using Ryujinx.Input.HLE;
  29. using Ryujinx.Input.SDL2;
  30. using Ryujinx.Modules;
  31. using Ryujinx.Ui.App.Common;
  32. using Ryujinx.Ui.Applet;
  33. using Ryujinx.Ui.Common;
  34. using Ryujinx.Ui.Common.Configuration;
  35. using Ryujinx.Ui.Common.Helper;
  36. using Ryujinx.Ui.Helper;
  37. using Ryujinx.Ui.Widgets;
  38. using Ryujinx.Ui.Windows;
  39. using Silk.NET.Vulkan;
  40. using SPB.Graphics.Vulkan;
  41. using System;
  42. using System.Diagnostics;
  43. using System.IO;
  44. using System.Reflection;
  45. using System.Threading;
  46. using System.Threading.Tasks;
  47. using GUI = Gtk.Builder.ObjectAttribute;
  48. using ShaderCacheLoadingState = Ryujinx.Graphics.Gpu.Shader.ShaderCacheState;
  49. namespace Ryujinx.Ui
  50. {
  51. public class MainWindow : Window
  52. {
  53. private readonly VirtualFileSystem _virtualFileSystem;
  54. private readonly ContentManager _contentManager;
  55. private readonly AccountManager _accountManager;
  56. private readonly LibHacHorizonManager _libHacHorizonManager;
  57. private UserChannelPersistence _userChannelPersistence;
  58. private HLE.Switch _emulationContext;
  59. private WindowsMultimediaTimerResolution _windowsMultimediaTimerResolution;
  60. private readonly ApplicationLibrary _applicationLibrary;
  61. private readonly GtkHostUiHandler _uiHandler;
  62. private readonly AutoResetEvent _deviceExitStatus;
  63. private readonly ListStore _tableStore;
  64. private bool _updatingGameTable;
  65. private bool _gameLoaded;
  66. private bool _ending;
  67. private string _currentEmulatedGamePath = null;
  68. private string _lastScannedAmiiboId = "";
  69. private bool _lastScannedAmiiboShowAll = false;
  70. public RendererWidgetBase RendererWidget;
  71. public InputManager InputManager;
  72. public bool IsFocused;
  73. #pragma warning disable CS0169, CS0649, IDE0044
  74. [GUI] public MenuItem ExitMenuItem;
  75. [GUI] public MenuItem UpdateMenuItem;
  76. [GUI] MenuBar _menuBar;
  77. [GUI] Box _footerBox;
  78. [GUI] Box _statusBar;
  79. [GUI] MenuItem _optionMenu;
  80. [GUI] MenuItem _manageUserProfiles;
  81. [GUI] MenuItem _fileMenu;
  82. [GUI] MenuItem _loadApplicationFile;
  83. [GUI] MenuItem _loadApplicationFolder;
  84. [GUI] MenuItem _appletMenu;
  85. [GUI] MenuItem _actionMenu;
  86. [GUI] MenuItem _pauseEmulation;
  87. [GUI] MenuItem _resumeEmulation;
  88. [GUI] MenuItem _stopEmulation;
  89. [GUI] MenuItem _simulateWakeUpMessage;
  90. [GUI] MenuItem _scanAmiibo;
  91. [GUI] MenuItem _takeScreenshot;
  92. [GUI] MenuItem _hideUi;
  93. [GUI] MenuItem _fullScreen;
  94. [GUI] CheckMenuItem _startFullScreen;
  95. [GUI] CheckMenuItem _showConsole;
  96. [GUI] CheckMenuItem _favToggle;
  97. [GUI] MenuItem _firmwareInstallDirectory;
  98. [GUI] MenuItem _firmwareInstallFile;
  99. [GUI] MenuItem _fileTypesSubMenu;
  100. [GUI] Label _fifoStatus;
  101. [GUI] CheckMenuItem _iconToggle;
  102. [GUI] CheckMenuItem _developerToggle;
  103. [GUI] CheckMenuItem _appToggle;
  104. [GUI] CheckMenuItem _timePlayedToggle;
  105. [GUI] CheckMenuItem _versionToggle;
  106. [GUI] CheckMenuItem _lastPlayedToggle;
  107. [GUI] CheckMenuItem _fileExtToggle;
  108. [GUI] CheckMenuItem _pathToggle;
  109. [GUI] CheckMenuItem _fileSizeToggle;
  110. [GUI] Label _gpuBackend;
  111. [GUI] Label _dockedMode;
  112. [GUI] Label _aspectRatio;
  113. [GUI] Label _gameStatus;
  114. [GUI] TreeView _gameTable;
  115. [GUI] TreeSelection _gameTableSelection;
  116. [GUI] ScrolledWindow _gameTableWindow;
  117. [GUI] Label _gpuName;
  118. [GUI] Label _progressLabel;
  119. [GUI] Label _firmwareVersionLabel;
  120. [GUI] Gtk.ProgressBar _progressBar;
  121. [GUI] Box _viewBox;
  122. [GUI] Label _vSyncStatus;
  123. [GUI] Label _volumeStatus;
  124. [GUI] Box _listStatusBox;
  125. [GUI] Label _loadingStatusLabel;
  126. [GUI] Gtk.ProgressBar _loadingStatusBar;
  127. #pragma warning restore CS0649, IDE0044, CS0169
  128. public MainWindow() : this(new Builder("Ryujinx.Ui.MainWindow.glade")) { }
  129. private MainWindow(Builder builder) : base(builder.GetRawOwnedObject("_mainWin"))
  130. {
  131. builder.Autoconnect(this);
  132. // Apply custom theme if needed.
  133. ThemeHelper.ApplyTheme();
  134. Gdk.Monitor monitor = Display.GetMonitor(0);
  135. // Sets overridden fields.
  136. int monitorWidth = monitor.Geometry.Width * monitor.ScaleFactor;
  137. int monitorHeight = monitor.Geometry.Height * monitor.ScaleFactor;
  138. DefaultWidth = monitorWidth < 1280 ? monitorWidth : 1280;
  139. DefaultHeight = monitorHeight < 760 ? monitorHeight : 760;
  140. Icon = new Gdk.Pixbuf(Assembly.GetAssembly(typeof(ConfigurationState)), "Ryujinx.Ui.Common.Resources.Logo_Ryujinx.png");
  141. Title = $"Ryujinx {Program.Version}";
  142. // Hide emulation context status bar.
  143. _statusBar.Hide();
  144. // Instantiate HLE objects.
  145. _virtualFileSystem = VirtualFileSystem.CreateInstance();
  146. _libHacHorizonManager = new LibHacHorizonManager();
  147. _libHacHorizonManager.InitializeFsServer(_virtualFileSystem);
  148. _libHacHorizonManager.InitializeArpServer();
  149. _libHacHorizonManager.InitializeBcatServer();
  150. _libHacHorizonManager.InitializeSystemClients();
  151. // Save data created before we supported extra data in directory save data will not work properly if
  152. // given empty extra data. Luckily some of that extra data can be created using the data from the
  153. // save data indexer, which should be enough to check access permissions for user saves.
  154. // Every single save data's extra data will be checked and fixed if needed each time the emulator is opened.
  155. // Consider removing this at some point in the future when we don't need to worry about old saves.
  156. VirtualFileSystem.FixExtraData(_libHacHorizonManager.RyujinxClient);
  157. _contentManager = new ContentManager(_virtualFileSystem);
  158. _accountManager = new AccountManager(_libHacHorizonManager.RyujinxClient, CommandLineState.Profile);
  159. _userChannelPersistence = new UserChannelPersistence();
  160. // Instantiate GUI objects.
  161. _applicationLibrary = new ApplicationLibrary(_virtualFileSystem);
  162. _uiHandler = new GtkHostUiHandler(this);
  163. _deviceExitStatus = new AutoResetEvent(false);
  164. WindowStateEvent += WindowStateEvent_Changed;
  165. DeleteEvent += Window_Close;
  166. FocusInEvent += MainWindow_FocusInEvent;
  167. FocusOutEvent += MainWindow_FocusOutEvent;
  168. _applicationLibrary.ApplicationAdded += Application_Added;
  169. _applicationLibrary.ApplicationCountUpdated += ApplicationCount_Updated;
  170. _fileMenu.StateChanged += FileMenu_StateChanged;
  171. _actionMenu.StateChanged += ActionMenu_StateChanged;
  172. _optionMenu.StateChanged += OptionMenu_StateChanged;
  173. _gameTable.ButtonReleaseEvent += Row_Clicked;
  174. _fullScreen.Activated += FullScreen_Toggled;
  175. RendererWidgetBase.StatusUpdatedEvent += Update_StatusBar;
  176. ConfigurationState.Instance.System.IgnoreMissingServices.Event += UpdateIgnoreMissingServicesState;
  177. ConfigurationState.Instance.Graphics.AspectRatio.Event += UpdateAspectRatioState;
  178. ConfigurationState.Instance.System.EnableDockedMode.Event += UpdateDockedModeState;
  179. ConfigurationState.Instance.System.AudioVolume.Event += UpdateAudioVolumeState;
  180. if (ConfigurationState.Instance.Ui.StartFullscreen)
  181. {
  182. _startFullScreen.Active = true;
  183. }
  184. _showConsole.Active = ConfigurationState.Instance.Ui.ShowConsole.Value;
  185. _showConsole.Visible = ConsoleHelper.SetConsoleWindowStateSupported;
  186. _actionMenu.Sensitive = false;
  187. _pauseEmulation.Sensitive = false;
  188. _resumeEmulation.Sensitive = false;
  189. _fileTypesSubMenu.Visible = FileAssociationHelper.IsTypeAssociationSupported;
  190. if (ConfigurationState.Instance.Ui.GuiColumns.FavColumn) _favToggle.Active = true;
  191. if (ConfigurationState.Instance.Ui.GuiColumns.IconColumn) _iconToggle.Active = true;
  192. if (ConfigurationState.Instance.Ui.GuiColumns.AppColumn) _appToggle.Active = true;
  193. if (ConfigurationState.Instance.Ui.GuiColumns.DevColumn) _developerToggle.Active = true;
  194. if (ConfigurationState.Instance.Ui.GuiColumns.VersionColumn) _versionToggle.Active = true;
  195. if (ConfigurationState.Instance.Ui.GuiColumns.TimePlayedColumn) _timePlayedToggle.Active = true;
  196. if (ConfigurationState.Instance.Ui.GuiColumns.LastPlayedColumn) _lastPlayedToggle.Active = true;
  197. if (ConfigurationState.Instance.Ui.GuiColumns.FileExtColumn) _fileExtToggle.Active = true;
  198. if (ConfigurationState.Instance.Ui.GuiColumns.FileSizeColumn) _fileSizeToggle.Active = true;
  199. if (ConfigurationState.Instance.Ui.GuiColumns.PathColumn) _pathToggle.Active = true;
  200. _favToggle.Toggled += Fav_Toggled;
  201. _iconToggle.Toggled += Icon_Toggled;
  202. _appToggle.Toggled += App_Toggled;
  203. _developerToggle.Toggled += Developer_Toggled;
  204. _versionToggle.Toggled += Version_Toggled;
  205. _timePlayedToggle.Toggled += TimePlayed_Toggled;
  206. _lastPlayedToggle.Toggled += LastPlayed_Toggled;
  207. _fileExtToggle.Toggled += FileExt_Toggled;
  208. _fileSizeToggle.Toggled += FileSize_Toggled;
  209. _pathToggle.Toggled += Path_Toggled;
  210. _gameTable.Model = _tableStore = new ListStore(
  211. typeof(bool),
  212. typeof(Gdk.Pixbuf),
  213. typeof(string),
  214. typeof(string),
  215. typeof(string),
  216. typeof(string),
  217. typeof(string),
  218. typeof(string),
  219. typeof(string),
  220. typeof(string),
  221. typeof(BlitStruct<ApplicationControlProperty>));
  222. _tableStore.SetSortFunc(5, SortHelper.TimePlayedSort);
  223. _tableStore.SetSortFunc(6, SortHelper.LastPlayedSort);
  224. _tableStore.SetSortFunc(8, SortHelper.FileSizeSort);
  225. int columnId = ConfigurationState.Instance.Ui.ColumnSort.SortColumnId;
  226. bool ascending = ConfigurationState.Instance.Ui.ColumnSort.SortAscending;
  227. _tableStore.SetSortColumnId(columnId, ascending ? SortType.Ascending : SortType.Descending);
  228. _gameTable.EnableSearch = true;
  229. _gameTable.SearchColumn = 2;
  230. _gameTable.SearchEqualFunc = (model, col, key, iter) => !((string)model.GetValue(iter, col)).Contains(key, StringComparison.InvariantCultureIgnoreCase);
  231. _hideUi.Label = _hideUi.Label.Replace("SHOWUIKEY", ConfigurationState.Instance.Hid.Hotkeys.Value.ShowUi.ToString());
  232. UpdateColumns();
  233. UpdateGameTable();
  234. ConfigurationState.Instance.Ui.GameDirs.Event += (sender, args) =>
  235. {
  236. if (args.OldValue != args.NewValue)
  237. {
  238. UpdateGameTable();
  239. }
  240. };
  241. Task.Run(RefreshFirmwareLabel);
  242. InputManager = new InputManager(new GTK3KeyboardDriver(this), new SDL2GamepadDriver());
  243. }
  244. private void UpdateIgnoreMissingServicesState(object sender, ReactiveEventArgs<bool> args)
  245. {
  246. if (_emulationContext != null)
  247. {
  248. _emulationContext.Configuration.IgnoreMissingServices = args.NewValue;
  249. }
  250. }
  251. private void UpdateAspectRatioState(object sender, ReactiveEventArgs<AspectRatio> args)
  252. {
  253. if (_emulationContext != null)
  254. {
  255. _emulationContext.Configuration.AspectRatio = args.NewValue;
  256. }
  257. }
  258. private void UpdateDockedModeState(object sender, ReactiveEventArgs<bool> e)
  259. {
  260. if (_emulationContext != null)
  261. {
  262. _emulationContext.System.ChangeDockedModeState(e.NewValue);
  263. }
  264. }
  265. private void UpdateAudioVolumeState(object sender, ReactiveEventArgs<float> e)
  266. {
  267. _emulationContext?.SetVolume(e.NewValue);
  268. }
  269. private void WindowStateEvent_Changed(object o, WindowStateEventArgs args)
  270. {
  271. _fullScreen.Label = args.Event.NewWindowState.HasFlag(Gdk.WindowState.Fullscreen) ? "Exit Fullscreen" : "Enter Fullscreen";
  272. }
  273. private void MainWindow_FocusOutEvent(object o, FocusOutEventArgs args)
  274. {
  275. IsFocused = false;
  276. }
  277. private void MainWindow_FocusInEvent(object o, FocusInEventArgs args)
  278. {
  279. IsFocused = true;
  280. }
  281. private void UpdateColumns()
  282. {
  283. foreach (TreeViewColumn column in _gameTable.Columns)
  284. {
  285. _gameTable.RemoveColumn(column);
  286. }
  287. CellRendererToggle favToggle = new CellRendererToggle();
  288. favToggle.Toggled += FavToggle_Toggled;
  289. if (ConfigurationState.Instance.Ui.GuiColumns.FavColumn) _gameTable.AppendColumn("Fav", favToggle, "active", 0);
  290. if (ConfigurationState.Instance.Ui.GuiColumns.IconColumn) _gameTable.AppendColumn("Icon", new CellRendererPixbuf(), "pixbuf", 1);
  291. if (ConfigurationState.Instance.Ui.GuiColumns.AppColumn) _gameTable.AppendColumn("Application", new CellRendererText(), "text", 2);
  292. if (ConfigurationState.Instance.Ui.GuiColumns.DevColumn) _gameTable.AppendColumn("Developer", new CellRendererText(), "text", 3);
  293. if (ConfigurationState.Instance.Ui.GuiColumns.VersionColumn) _gameTable.AppendColumn("Version", new CellRendererText(), "text", 4);
  294. if (ConfigurationState.Instance.Ui.GuiColumns.TimePlayedColumn) _gameTable.AppendColumn("Time Played", new CellRendererText(), "text", 5);
  295. if (ConfigurationState.Instance.Ui.GuiColumns.LastPlayedColumn) _gameTable.AppendColumn("Last Played", new CellRendererText(), "text", 6);
  296. if (ConfigurationState.Instance.Ui.GuiColumns.FileExtColumn) _gameTable.AppendColumn("File Ext", new CellRendererText(), "text", 7);
  297. if (ConfigurationState.Instance.Ui.GuiColumns.FileSizeColumn) _gameTable.AppendColumn("File Size", new CellRendererText(), "text", 8);
  298. if (ConfigurationState.Instance.Ui.GuiColumns.PathColumn) _gameTable.AppendColumn("Path", new CellRendererText(), "text", 9);
  299. foreach (TreeViewColumn column in _gameTable.Columns)
  300. {
  301. switch (column.Title)
  302. {
  303. case "Fav":
  304. column.SortColumnId = 0;
  305. column.Clicked += Column_Clicked;
  306. break;
  307. case "Application":
  308. column.SortColumnId = 2;
  309. column.Clicked += Column_Clicked;
  310. break;
  311. case "Developer":
  312. column.SortColumnId = 3;
  313. column.Clicked += Column_Clicked;
  314. break;
  315. case "Version":
  316. column.SortColumnId = 4;
  317. column.Clicked += Column_Clicked;
  318. break;
  319. case "Time Played":
  320. column.SortColumnId = 5;
  321. column.Clicked += Column_Clicked;
  322. break;
  323. case "Last Played":
  324. column.SortColumnId = 6;
  325. column.Clicked += Column_Clicked;
  326. break;
  327. case "File Ext":
  328. column.SortColumnId = 7;
  329. column.Clicked += Column_Clicked;
  330. break;
  331. case "File Size":
  332. column.SortColumnId = 8;
  333. column.Clicked += Column_Clicked;
  334. break;
  335. case "Path":
  336. column.SortColumnId = 9;
  337. column.Clicked += Column_Clicked;
  338. break;
  339. }
  340. }
  341. }
  342. protected override void OnDestroyed()
  343. {
  344. InputManager.Dispose();
  345. }
  346. private void InitializeSwitchInstance()
  347. {
  348. _virtualFileSystem.ReloadKeySet();
  349. IRenderer renderer;
  350. if (ConfigurationState.Instance.Graphics.GraphicsBackend == GraphicsBackend.Vulkan)
  351. {
  352. string preferredGpu = ConfigurationState.Instance.Graphics.PreferredGpu.Value;
  353. renderer = new VulkanRenderer(CreateVulkanSurface, VulkanHelper.GetRequiredInstanceExtensions, preferredGpu);
  354. }
  355. else
  356. {
  357. renderer = new OpenGLRenderer();
  358. }
  359. BackendThreading threadingMode = ConfigurationState.Instance.Graphics.BackendThreading;
  360. bool threadedGAL = threadingMode == BackendThreading.On || (threadingMode == BackendThreading.Auto && renderer.PreferThreading);
  361. if (threadedGAL)
  362. {
  363. renderer = new ThreadedRenderer(renderer);
  364. }
  365. Logger.Info?.PrintMsg(LogClass.Gpu, $"Backend Threading ({threadingMode}): {threadedGAL}");
  366. IHardwareDeviceDriver deviceDriver = new DummyHardwareDeviceDriver();
  367. if (ConfigurationState.Instance.System.AudioBackend.Value == AudioBackend.SDL2)
  368. {
  369. if (SDL2HardwareDeviceDriver.IsSupported)
  370. {
  371. deviceDriver = new SDL2HardwareDeviceDriver();
  372. }
  373. else
  374. {
  375. Logger.Warning?.Print(LogClass.Audio, "SDL2 is not supported, trying to fall back to OpenAL.");
  376. if (OpenALHardwareDeviceDriver.IsSupported)
  377. {
  378. Logger.Warning?.Print(LogClass.Audio, "Found OpenAL, changing configuration.");
  379. ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.OpenAl;
  380. SaveConfig();
  381. deviceDriver = new OpenALHardwareDeviceDriver();
  382. }
  383. else
  384. {
  385. Logger.Warning?.Print(LogClass.Audio, "OpenAL is not supported, trying to fall back to SoundIO.");
  386. if (SoundIoHardwareDeviceDriver.IsSupported)
  387. {
  388. Logger.Warning?.Print(LogClass.Audio, "Found SoundIO, changing configuration.");
  389. ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.SoundIo;
  390. SaveConfig();
  391. deviceDriver = new SoundIoHardwareDeviceDriver();
  392. }
  393. else
  394. {
  395. Logger.Warning?.Print(LogClass.Audio, "SoundIO is not supported, falling back to dummy audio out.");
  396. }
  397. }
  398. }
  399. }
  400. else if (ConfigurationState.Instance.System.AudioBackend.Value == AudioBackend.SoundIo)
  401. {
  402. if (SoundIoHardwareDeviceDriver.IsSupported)
  403. {
  404. deviceDriver = new SoundIoHardwareDeviceDriver();
  405. }
  406. else
  407. {
  408. Logger.Warning?.Print(LogClass.Audio, "SoundIO is not supported, trying to fall back to SDL2.");
  409. if (SDL2HardwareDeviceDriver.IsSupported)
  410. {
  411. Logger.Warning?.Print(LogClass.Audio, "Found SDL2, changing configuration.");
  412. ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.SDL2;
  413. SaveConfig();
  414. deviceDriver = new SDL2HardwareDeviceDriver();
  415. }
  416. else
  417. {
  418. Logger.Warning?.Print(LogClass.Audio, "SDL2 is not supported, trying to fall back to OpenAL.");
  419. if (OpenALHardwareDeviceDriver.IsSupported)
  420. {
  421. Logger.Warning?.Print(LogClass.Audio, "Found OpenAL, changing configuration.");
  422. ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.OpenAl;
  423. SaveConfig();
  424. deviceDriver = new OpenALHardwareDeviceDriver();
  425. }
  426. else
  427. {
  428. Logger.Warning?.Print(LogClass.Audio, "OpenAL is not supported, falling back to dummy audio out.");
  429. }
  430. }
  431. }
  432. }
  433. else if (ConfigurationState.Instance.System.AudioBackend.Value == AudioBackend.OpenAl)
  434. {
  435. if (OpenALHardwareDeviceDriver.IsSupported)
  436. {
  437. deviceDriver = new OpenALHardwareDeviceDriver();
  438. }
  439. else
  440. {
  441. Logger.Warning?.Print(LogClass.Audio, "OpenAL is not supported, trying to fall back to SDL2.");
  442. if (SDL2HardwareDeviceDriver.IsSupported)
  443. {
  444. Logger.Warning?.Print(LogClass.Audio, "Found SDL2, changing configuration.");
  445. ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.SDL2;
  446. SaveConfig();
  447. deviceDriver = new SDL2HardwareDeviceDriver();
  448. }
  449. else
  450. {
  451. Logger.Warning?.Print(LogClass.Audio, "SDL2 is not supported, trying to fall back to SoundIO.");
  452. if (SoundIoHardwareDeviceDriver.IsSupported)
  453. {
  454. Logger.Warning?.Print(LogClass.Audio, "Found SoundIO, changing configuration.");
  455. ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.SoundIo;
  456. SaveConfig();
  457. deviceDriver = new SoundIoHardwareDeviceDriver();
  458. }
  459. else
  460. {
  461. Logger.Warning?.Print(LogClass.Audio, "SoundIO is not supported, falling back to dummy audio out.");
  462. }
  463. }
  464. }
  465. }
  466. var memoryConfiguration = ConfigurationState.Instance.System.ExpandRam.Value
  467. ? HLE.MemoryConfiguration.MemoryConfiguration6GiB
  468. : HLE.MemoryConfiguration.MemoryConfiguration4GiB;
  469. IntegrityCheckLevel fsIntegrityCheckLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None;
  470. HLE.HLEConfiguration configuration = new HLE.HLEConfiguration(_virtualFileSystem,
  471. _libHacHorizonManager,
  472. _contentManager,
  473. _accountManager,
  474. _userChannelPersistence,
  475. renderer,
  476. deviceDriver,
  477. memoryConfiguration,
  478. _uiHandler,
  479. (SystemLanguage)ConfigurationState.Instance.System.Language.Value,
  480. (RegionCode)ConfigurationState.Instance.System.Region.Value,
  481. ConfigurationState.Instance.Graphics.EnableVsync,
  482. ConfigurationState.Instance.System.EnableDockedMode,
  483. ConfigurationState.Instance.System.EnablePtc,
  484. ConfigurationState.Instance.System.EnableInternetAccess,
  485. fsIntegrityCheckLevel,
  486. ConfigurationState.Instance.System.FsGlobalAccessLogMode,
  487. ConfigurationState.Instance.System.SystemTimeOffset,
  488. ConfigurationState.Instance.System.TimeZone,
  489. ConfigurationState.Instance.System.MemoryManagerMode,
  490. ConfigurationState.Instance.System.IgnoreMissingServices,
  491. ConfigurationState.Instance.Graphics.AspectRatio,
  492. ConfigurationState.Instance.System.AudioVolume,
  493. ConfigurationState.Instance.System.UseHypervisor);
  494. _emulationContext = new HLE.Switch(configuration);
  495. }
  496. private SurfaceKHR CreateVulkanSurface(Instance instance, Vk vk)
  497. {
  498. return new SurfaceKHR((ulong)((VKRenderer)RendererWidget).CreateWindowSurface(instance.Handle));
  499. }
  500. private void SetupProgressUiHandlers()
  501. {
  502. if (_emulationContext.Application.DiskCacheLoadState != null)
  503. {
  504. _emulationContext.Application.DiskCacheLoadState.StateChanged -= ProgressHandler;
  505. _emulationContext.Application.DiskCacheLoadState.StateChanged += ProgressHandler;
  506. }
  507. _emulationContext.Gpu.ShaderCacheStateChanged -= ProgressHandler;
  508. _emulationContext.Gpu.ShaderCacheStateChanged += ProgressHandler;
  509. }
  510. private void ProgressHandler<T>(T state, int current, int total) where T : Enum
  511. {
  512. bool visible;
  513. string label;
  514. switch (state)
  515. {
  516. case LoadState ptcState:
  517. visible = ptcState != LoadState.Loaded;
  518. label = $"PTC : {current}/{total}";
  519. break;
  520. case ShaderCacheLoadingState shaderCacheState:
  521. visible = shaderCacheState != ShaderCacheLoadingState.Loaded;
  522. label = $"Shaders : {current}/{total}";
  523. break;
  524. default:
  525. throw new ArgumentException($"Unknown Progress Handler type {typeof(T)}");
  526. }
  527. Application.Invoke(delegate
  528. {
  529. _loadingStatusLabel.Text = label;
  530. _loadingStatusBar.Fraction = total > 0 ? (double)current / total : 0;
  531. _loadingStatusBar.Visible = visible;
  532. _loadingStatusLabel.Visible = visible;
  533. });
  534. }
  535. public void UpdateGameTable()
  536. {
  537. if (_updatingGameTable || _gameLoaded)
  538. {
  539. return;
  540. }
  541. _updatingGameTable = true;
  542. _tableStore.Clear();
  543. Thread applicationLibraryThread = new Thread(() =>
  544. {
  545. _applicationLibrary.LoadApplications(ConfigurationState.Instance.Ui.GameDirs, ConfigurationState.Instance.System.Language);
  546. _updatingGameTable = false;
  547. });
  548. applicationLibraryThread.Name = "GUI.ApplicationLibraryThread";
  549. applicationLibraryThread.IsBackground = true;
  550. applicationLibraryThread.Start();
  551. }
  552. [Conditional("RELEASE")]
  553. public void PerformanceCheck()
  554. {
  555. if (ConfigurationState.Instance.Logger.EnableTrace.Value)
  556. {
  557. MessageDialog debugWarningDialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo, null)
  558. {
  559. Title = "Ryujinx - Warning",
  560. Text = "You have trace logging enabled, which is designed to be used by developers only.",
  561. SecondaryText = "For optimal performance, it's recommended to disable trace logging. Would you like to disable trace logging now?"
  562. };
  563. if (debugWarningDialog.Run() == (int)ResponseType.Yes)
  564. {
  565. ConfigurationState.Instance.Logger.EnableTrace.Value = false;
  566. SaveConfig();
  567. }
  568. debugWarningDialog.Dispose();
  569. }
  570. if (!string.IsNullOrWhiteSpace(ConfigurationState.Instance.Graphics.ShadersDumpPath.Value))
  571. {
  572. MessageDialog shadersDumpWarningDialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo, null)
  573. {
  574. Title = "Ryujinx - Warning",
  575. Text = "You have shader dumping enabled, which is designed to be used by developers only.",
  576. SecondaryText = "For optimal performance, it's recommended to disable shader dumping. Would you like to disable shader dumping now?"
  577. };
  578. if (shadersDumpWarningDialog.Run() == (int)ResponseType.Yes)
  579. {
  580. ConfigurationState.Instance.Graphics.ShadersDumpPath.Value = "";
  581. SaveConfig();
  582. }
  583. shadersDumpWarningDialog.Dispose();
  584. }
  585. }
  586. public void LoadApplication(string path, bool startFullscreen = false)
  587. {
  588. if (_gameLoaded)
  589. {
  590. GtkDialog.CreateInfoDialog("A game has already been loaded", "Please stop emulation or close the emulator before launching another game.");
  591. }
  592. else
  593. {
  594. PerformanceCheck();
  595. Logger.RestartTime();
  596. RendererWidget = CreateRendererWidget();
  597. SwitchToRenderWidget(startFullscreen);
  598. InitializeSwitchInstance();
  599. UpdateGraphicsConfig();
  600. SystemVersion firmwareVersion = _contentManager.GetCurrentFirmwareVersion();
  601. bool isDirectory = Directory.Exists(path);
  602. bool isFirmwareTitle = false;
  603. if (path.StartsWith("@SystemContent"))
  604. {
  605. path = _virtualFileSystem.SwitchPathToSystemPath(path);
  606. isFirmwareTitle = true;
  607. }
  608. if (!SetupValidator.CanStartApplication(_contentManager, path, out UserError userError))
  609. {
  610. if (SetupValidator.CanFixStartApplication(_contentManager, path, userError, out firmwareVersion))
  611. {
  612. if (userError == UserError.NoFirmware)
  613. {
  614. string message = $"Would you like to install the firmware embedded in this game? (Firmware {firmwareVersion.VersionString})";
  615. ResponseType responseDialog = (ResponseType)GtkDialog.CreateConfirmationDialog("No Firmware Installed", message).Run();
  616. if (responseDialog != ResponseType.Yes)
  617. {
  618. UserErrorDialog.CreateUserErrorDialog(userError);
  619. _emulationContext.Dispose();
  620. SwitchToGameTable();
  621. return;
  622. }
  623. }
  624. if (!SetupValidator.TryFixStartApplication(_contentManager, path, userError, out _))
  625. {
  626. UserErrorDialog.CreateUserErrorDialog(userError);
  627. _emulationContext.Dispose();
  628. SwitchToGameTable();
  629. return;
  630. }
  631. // Tell the user that we installed a firmware for them.
  632. if (userError == UserError.NoFirmware)
  633. {
  634. firmwareVersion = _contentManager.GetCurrentFirmwareVersion();
  635. RefreshFirmwareLabel();
  636. string message = $"No installed firmware was found but Ryujinx was able to install firmware {firmwareVersion.VersionString} from the provided game.\nThe emulator will now start.";
  637. GtkDialog.CreateInfoDialog($"Firmware {firmwareVersion.VersionString} was installed", message);
  638. }
  639. }
  640. else
  641. {
  642. UserErrorDialog.CreateUserErrorDialog(userError);
  643. _emulationContext.Dispose();
  644. SwitchToGameTable();
  645. return;
  646. }
  647. }
  648. Logger.Notice.Print(LogClass.Application, $"Using Firmware Version: {firmwareVersion?.VersionString}");
  649. if (isFirmwareTitle)
  650. {
  651. Logger.Info?.Print(LogClass.Application, "Loading as Firmware Title (NCA).");
  652. _emulationContext.LoadNca(path);
  653. }
  654. else if (Directory.Exists(path))
  655. {
  656. string[] romFsFiles = Directory.GetFiles(path, "*.istorage");
  657. if (romFsFiles.Length == 0)
  658. {
  659. romFsFiles = Directory.GetFiles(path, "*.romfs");
  660. }
  661. if (romFsFiles.Length > 0)
  662. {
  663. Logger.Info?.Print(LogClass.Application, "Loading as cart with RomFS.");
  664. _emulationContext.LoadCart(path, romFsFiles[0]);
  665. }
  666. else
  667. {
  668. Logger.Info?.Print(LogClass.Application, "Loading as cart WITHOUT RomFS.");
  669. _emulationContext.LoadCart(path);
  670. }
  671. }
  672. else if (File.Exists(path))
  673. {
  674. switch (System.IO.Path.GetExtension(path).ToLowerInvariant())
  675. {
  676. case ".xci":
  677. Logger.Info?.Print(LogClass.Application, "Loading as XCI.");
  678. _emulationContext.LoadXci(path);
  679. break;
  680. case ".nca":
  681. Logger.Info?.Print(LogClass.Application, "Loading as NCA.");
  682. _emulationContext.LoadNca(path);
  683. break;
  684. case ".nsp":
  685. case ".pfs0":
  686. Logger.Info?.Print(LogClass.Application, "Loading as NSP.");
  687. _emulationContext.LoadNsp(path);
  688. break;
  689. default:
  690. Logger.Info?.Print(LogClass.Application, "Loading as Homebrew.");
  691. try
  692. {
  693. _emulationContext.LoadProgram(path);
  694. }
  695. catch (ArgumentOutOfRangeException)
  696. {
  697. Logger.Error?.Print(LogClass.Application, "The specified file is not supported by Ryujinx.");
  698. }
  699. break;
  700. }
  701. }
  702. else
  703. {
  704. Logger.Warning?.Print(LogClass.Application, "Please specify a valid XCI/NCA/NSP/PFS0/NRO file.");
  705. _emulationContext.Dispose();
  706. RendererWidget.Dispose();
  707. return;
  708. }
  709. SetupProgressUiHandlers();
  710. _currentEmulatedGamePath = path;
  711. _deviceExitStatus.Reset();
  712. Translator.IsReadyForTranslation.Reset();
  713. Thread windowThread = new Thread(() =>
  714. {
  715. CreateGameWindow();
  716. })
  717. {
  718. Name = "GUI.WindowThread"
  719. };
  720. windowThread.Start();
  721. _gameLoaded = true;
  722. _actionMenu.Sensitive = true;
  723. UpdateMenuItem.Sensitive = false;
  724. _lastScannedAmiiboId = "";
  725. _firmwareInstallFile.Sensitive = false;
  726. _firmwareInstallDirectory.Sensitive = false;
  727. DiscordIntegrationModule.SwitchToPlayingState(_emulationContext.Application.TitleIdText, _emulationContext.Application.TitleName);
  728. _applicationLibrary.LoadAndSaveMetaData(_emulationContext.Application.TitleIdText, appMetadata =>
  729. {
  730. appMetadata.LastPlayed = DateTime.UtcNow.ToString();
  731. });
  732. }
  733. }
  734. private RendererWidgetBase CreateRendererWidget()
  735. {
  736. if (ConfigurationState.Instance.Graphics.GraphicsBackend == GraphicsBackend.Vulkan)
  737. {
  738. return new VKRenderer(InputManager, ConfigurationState.Instance.Logger.GraphicsDebugLevel);
  739. }
  740. else
  741. {
  742. return new GlRenderer(InputManager, ConfigurationState.Instance.Logger.GraphicsDebugLevel);
  743. }
  744. }
  745. private void SwitchToRenderWidget(bool startFullscreen = false)
  746. {
  747. _viewBox.Remove(_gameTableWindow);
  748. RendererWidget.Expand = true;
  749. _viewBox.Child = RendererWidget;
  750. RendererWidget.ShowAll();
  751. EditFooterForGameRenderer();
  752. if (Window.State.HasFlag(Gdk.WindowState.Fullscreen))
  753. {
  754. ToggleExtraWidgets(false);
  755. }
  756. else if (startFullscreen || ConfigurationState.Instance.Ui.StartFullscreen.Value)
  757. {
  758. FullScreen_Toggled(null, null);
  759. }
  760. }
  761. private void SwitchToGameTable()
  762. {
  763. if (Window.State.HasFlag(Gdk.WindowState.Fullscreen))
  764. {
  765. ToggleExtraWidgets(true);
  766. }
  767. RendererWidget.Exit();
  768. if (RendererWidget.Window != Window && RendererWidget.Window != null)
  769. {
  770. RendererWidget.Window.Dispose();
  771. }
  772. RendererWidget.Dispose();
  773. if (OperatingSystem.IsWindows())
  774. {
  775. _windowsMultimediaTimerResolution?.Dispose();
  776. _windowsMultimediaTimerResolution = null;
  777. }
  778. DisplaySleep.Restore();
  779. _viewBox.Remove(RendererWidget);
  780. _viewBox.Add(_gameTableWindow);
  781. _gameTableWindow.Expand = true;
  782. Window.Title = $"Ryujinx {Program.Version}";
  783. _emulationContext = null;
  784. _gameLoaded = false;
  785. RendererWidget = null;
  786. DiscordIntegrationModule.SwitchToMainMenu();
  787. RecreateFooterForMenu();
  788. UpdateColumns();
  789. UpdateGameTable();
  790. RefreshFirmwareLabel();
  791. HandleRelaunch();
  792. }
  793. private void CreateGameWindow()
  794. {
  795. if (OperatingSystem.IsWindows())
  796. {
  797. _windowsMultimediaTimerResolution = new WindowsMultimediaTimerResolution(1);
  798. }
  799. DisplaySleep.Prevent();
  800. RendererWidget.Initialize(_emulationContext);
  801. RendererWidget.WaitEvent.WaitOne();
  802. RendererWidget.Start();
  803. _emulationContext.Dispose();
  804. _deviceExitStatus.Set();
  805. // NOTE: Everything that is here will not be executed when you close the UI.
  806. Application.Invoke(delegate
  807. {
  808. SwitchToGameTable();
  809. });
  810. }
  811. private void RecreateFooterForMenu()
  812. {
  813. _listStatusBox.Show();
  814. _statusBar.Hide();
  815. }
  816. private void EditFooterForGameRenderer()
  817. {
  818. _listStatusBox.Hide();
  819. _statusBar.Show();
  820. }
  821. public void ToggleExtraWidgets(bool show)
  822. {
  823. if (RendererWidget != null)
  824. {
  825. if (show)
  826. {
  827. _menuBar.ShowAll();
  828. _footerBox.Show();
  829. _statusBar.Show();
  830. }
  831. else
  832. {
  833. _menuBar.Hide();
  834. _footerBox.Hide();
  835. }
  836. }
  837. }
  838. private void UpdateGameMetadata(string titleId)
  839. {
  840. if (_gameLoaded)
  841. {
  842. _applicationLibrary.LoadAndSaveMetaData(titleId, appMetadata =>
  843. {
  844. DateTime lastPlayedDateTime = DateTime.Parse(appMetadata.LastPlayed);
  845. double sessionTimePlayed = DateTime.UtcNow.Subtract(lastPlayedDateTime).TotalSeconds;
  846. appMetadata.TimePlayed += Math.Round(sessionTimePlayed, MidpointRounding.AwayFromZero);
  847. });
  848. }
  849. }
  850. public void UpdateGraphicsConfig()
  851. {
  852. int resScale = ConfigurationState.Instance.Graphics.ResScale;
  853. float resScaleCustom = ConfigurationState.Instance.Graphics.ResScaleCustom;
  854. Graphics.Gpu.GraphicsConfig.ResScale = (resScale == -1) ? resScaleCustom : resScale;
  855. Graphics.Gpu.GraphicsConfig.MaxAnisotropy = ConfigurationState.Instance.Graphics.MaxAnisotropy;
  856. Graphics.Gpu.GraphicsConfig.ShadersDumpPath = ConfigurationState.Instance.Graphics.ShadersDumpPath;
  857. Graphics.Gpu.GraphicsConfig.EnableShaderCache = ConfigurationState.Instance.Graphics.EnableShaderCache;
  858. Graphics.Gpu.GraphicsConfig.EnableTextureRecompression = ConfigurationState.Instance.Graphics.EnableTextureRecompression;
  859. Graphics.Gpu.GraphicsConfig.EnableMacroHLE = ConfigurationState.Instance.Graphics.EnableMacroHLE;
  860. }
  861. public void SaveConfig()
  862. {
  863. ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
  864. }
  865. private void End()
  866. {
  867. if (_ending)
  868. {
  869. return;
  870. }
  871. _ending = true;
  872. if (_emulationContext != null)
  873. {
  874. UpdateGameMetadata(_emulationContext.Application.TitleIdText);
  875. if (RendererWidget != null)
  876. {
  877. // We tell the widget that we are exiting.
  878. RendererWidget.Exit();
  879. // Wait for the other thread to dispose the HLE context before exiting.
  880. _deviceExitStatus.WaitOne();
  881. RendererWidget.Dispose();
  882. }
  883. }
  884. Dispose();
  885. Program.Exit();
  886. Application.Quit();
  887. }
  888. //
  889. // Events
  890. //
  891. private void Application_Added(object sender, ApplicationAddedEventArgs args)
  892. {
  893. Application.Invoke(delegate
  894. {
  895. _tableStore.AppendValues(
  896. args.AppData.Favorite,
  897. new Gdk.Pixbuf(args.AppData.Icon, 75, 75),
  898. $"{args.AppData.TitleName}\n{args.AppData.TitleId.ToUpper()}",
  899. args.AppData.Developer,
  900. args.AppData.Version,
  901. args.AppData.TimePlayed,
  902. args.AppData.LastPlayed,
  903. args.AppData.FileExtension,
  904. args.AppData.FileSize,
  905. args.AppData.Path,
  906. args.AppData.ControlHolder);
  907. });
  908. }
  909. private void ApplicationCount_Updated(object sender, ApplicationCountUpdatedEventArgs args)
  910. {
  911. Application.Invoke(delegate
  912. {
  913. _progressLabel.Text = $"{args.NumAppsLoaded}/{args.NumAppsFound} Games Loaded";
  914. float barValue = 0;
  915. if (args.NumAppsFound != 0)
  916. {
  917. barValue = (float)args.NumAppsLoaded / args.NumAppsFound;
  918. }
  919. _progressBar.Fraction = barValue;
  920. // Reset the vertical scrollbar to the top when titles finish loading
  921. if (args.NumAppsLoaded == args.NumAppsFound)
  922. {
  923. _gameTableWindow.Vadjustment.Value = 0;
  924. }
  925. });
  926. }
  927. private void Update_StatusBar(object sender, StatusUpdatedEventArgs args)
  928. {
  929. Application.Invoke(delegate
  930. {
  931. _gameStatus.Text = args.GameStatus;
  932. _fifoStatus.Text = args.FifoStatus;
  933. _gpuName.Text = args.GpuName;
  934. _dockedMode.Text = args.DockedMode;
  935. _aspectRatio.Text = args.AspectRatio;
  936. _gpuBackend.Text = args.GpuBackend;
  937. _volumeStatus.Text = GetVolumeLabelText(args.Volume);
  938. if (args.VSyncEnabled)
  939. {
  940. _vSyncStatus.Attributes = new Pango.AttrList();
  941. _vSyncStatus.Attributes.Insert(new Pango.AttrForeground(11822, 60138, 51657));
  942. }
  943. else
  944. {
  945. _vSyncStatus.Attributes = new Pango.AttrList();
  946. _vSyncStatus.Attributes.Insert(new Pango.AttrForeground(ushort.MaxValue, 17733, 21588));
  947. }
  948. });
  949. }
  950. private void FavToggle_Toggled(object sender, ToggledArgs args)
  951. {
  952. _tableStore.GetIter(out TreeIter treeIter, new TreePath(args.Path));
  953. string titleId = _tableStore.GetValue(treeIter, 2).ToString().Split("\n")[1].ToLower();
  954. bool newToggleValue = !(bool)_tableStore.GetValue(treeIter, 0);
  955. _tableStore.SetValue(treeIter, 0, newToggleValue);
  956. _applicationLibrary.LoadAndSaveMetaData(titleId, appMetadata =>
  957. {
  958. appMetadata.Favorite = newToggleValue;
  959. });
  960. }
  961. private void Column_Clicked(object sender, EventArgs args)
  962. {
  963. TreeViewColumn column = (TreeViewColumn)sender;
  964. ConfigurationState.Instance.Ui.ColumnSort.SortColumnId.Value = column.SortColumnId;
  965. ConfigurationState.Instance.Ui.ColumnSort.SortAscending.Value = column.SortOrder == SortType.Ascending;
  966. SaveConfig();
  967. }
  968. private void Row_Activated(object sender, RowActivatedArgs args)
  969. {
  970. _gameTableSelection.GetSelected(out TreeIter treeIter);
  971. string path = (string)_tableStore.GetValue(treeIter, 9);
  972. LoadApplication(path);
  973. }
  974. private void VSyncStatus_Clicked(object sender, ButtonReleaseEventArgs args)
  975. {
  976. _emulationContext.EnableDeviceVsync = !_emulationContext.EnableDeviceVsync;
  977. Logger.Info?.Print(LogClass.Application, $"VSync toggled to: {_emulationContext.EnableDeviceVsync}");
  978. }
  979. private void DockedMode_Clicked(object sender, ButtonReleaseEventArgs args)
  980. {
  981. ConfigurationState.Instance.System.EnableDockedMode.Value = !ConfigurationState.Instance.System.EnableDockedMode.Value;
  982. }
  983. private string GetVolumeLabelText(float volume)
  984. {
  985. string icon = volume == 0 ? "🔇" : "🔊";
  986. return $"{icon} {(int)(volume * 100)}%";
  987. }
  988. private void VolumeStatus_Clicked(object sender, ButtonReleaseEventArgs args)
  989. {
  990. if (_emulationContext != null)
  991. {
  992. if (_emulationContext.IsAudioMuted())
  993. {
  994. _emulationContext.SetVolume(ConfigurationState.Instance.System.AudioVolume);
  995. }
  996. else
  997. {
  998. _emulationContext.SetVolume(0);
  999. }
  1000. }
  1001. }
  1002. private void AspectRatio_Clicked(object sender, ButtonReleaseEventArgs args)
  1003. {
  1004. AspectRatio aspectRatio = ConfigurationState.Instance.Graphics.AspectRatio.Value;
  1005. ConfigurationState.Instance.Graphics.AspectRatio.Value = ((int)aspectRatio + 1) > Enum.GetNames<AspectRatio>().Length - 1 ? AspectRatio.Fixed4x3 : aspectRatio + 1;
  1006. }
  1007. private void Row_Clicked(object sender, ButtonReleaseEventArgs args)
  1008. {
  1009. if (args.Event.Button != 3 /* Right Click */)
  1010. {
  1011. return;
  1012. }
  1013. _gameTableSelection.GetSelected(out TreeIter treeIter);
  1014. if (treeIter.UserData == IntPtr.Zero)
  1015. {
  1016. return;
  1017. }
  1018. string titleFilePath = _tableStore.GetValue(treeIter, 9).ToString();
  1019. string titleName = _tableStore.GetValue(treeIter, 2).ToString().Split("\n")[0];
  1020. string titleId = _tableStore.GetValue(treeIter, 2).ToString().Split("\n")[1].ToLower();
  1021. BlitStruct<ApplicationControlProperty> controlData = (BlitStruct<ApplicationControlProperty>)_tableStore.GetValue(treeIter, 10);
  1022. _ = new GameTableContextMenu(this, _virtualFileSystem, _accountManager, _libHacHorizonManager.RyujinxClient, titleFilePath, titleName, titleId, controlData);
  1023. }
  1024. private void Load_Application_File(object sender, EventArgs args)
  1025. {
  1026. using (FileChooserNative fileChooser = new FileChooserNative("Choose the file to open", this, FileChooserAction.Open, "Open", "Cancel"))
  1027. {
  1028. FileFilter filter = new FileFilter()
  1029. {
  1030. Name = "Switch Executables"
  1031. };
  1032. filter.AddPattern("*.xci");
  1033. filter.AddPattern("*.nsp");
  1034. filter.AddPattern("*.pfs0");
  1035. filter.AddPattern("*.nca");
  1036. filter.AddPattern("*.nro");
  1037. filter.AddPattern("*.nso");
  1038. fileChooser.AddFilter(filter);
  1039. if (fileChooser.Run() == (int)ResponseType.Accept)
  1040. {
  1041. LoadApplication(fileChooser.Filename);
  1042. }
  1043. }
  1044. }
  1045. private void Load_Application_Folder(object sender, EventArgs args)
  1046. {
  1047. using (FileChooserNative fileChooser = new FileChooserNative("Choose the folder to open", this, FileChooserAction.SelectFolder, "Open", "Cancel"))
  1048. {
  1049. if (fileChooser.Run() == (int)ResponseType.Accept)
  1050. {
  1051. LoadApplication(fileChooser.Filename);
  1052. }
  1053. }
  1054. }
  1055. private void FileMenu_StateChanged(object o, StateChangedArgs args)
  1056. {
  1057. _appletMenu.Sensitive = _emulationContext == null && _contentManager.GetCurrentFirmwareVersion() != null && _contentManager.GetCurrentFirmwareVersion().Major > 3;
  1058. _loadApplicationFile.Sensitive = _emulationContext == null;
  1059. _loadApplicationFolder.Sensitive = _emulationContext == null;
  1060. }
  1061. private void Load_Mii_Edit_Applet(object sender, EventArgs args)
  1062. {
  1063. string contentPath = _contentManager.GetInstalledContentPath(0x0100000000001009, StorageId.BuiltInSystem, NcaContentType.Program);
  1064. LoadApplication(contentPath);
  1065. }
  1066. private void Open_Ryu_Folder(object sender, EventArgs args)
  1067. {
  1068. OpenHelper.OpenFolder(AppDataManager.BaseDirPath);
  1069. }
  1070. private void OpenLogsFolder_Pressed(object sender, EventArgs args)
  1071. {
  1072. string logPath = System.IO.Path.Combine(ReleaseInformation.GetBaseApplicationDirectory(), "Logs");
  1073. new DirectoryInfo(logPath).Create();
  1074. OpenHelper.OpenFolder(logPath);
  1075. }
  1076. private void Exit_Pressed(object sender, EventArgs args)
  1077. {
  1078. if (!_gameLoaded || !ConfigurationState.Instance.ShowConfirmExit || GtkDialog.CreateExitDialog())
  1079. {
  1080. End();
  1081. }
  1082. }
  1083. private void Window_Close(object sender, DeleteEventArgs args)
  1084. {
  1085. if (!_gameLoaded || !ConfigurationState.Instance.ShowConfirmExit || GtkDialog.CreateExitDialog())
  1086. {
  1087. End();
  1088. }
  1089. else
  1090. {
  1091. args.RetVal = true;
  1092. }
  1093. }
  1094. private void StopEmulation_Pressed(object sender, EventArgs args)
  1095. {
  1096. if (_emulationContext != null)
  1097. {
  1098. UpdateGameMetadata(_emulationContext.Application.TitleIdText);
  1099. }
  1100. _pauseEmulation.Sensitive = false;
  1101. _resumeEmulation.Sensitive = false;
  1102. UpdateMenuItem.Sensitive = true;
  1103. RendererWidget?.Exit();
  1104. }
  1105. private void PauseEmulation_Pressed(object sender, EventArgs args)
  1106. {
  1107. _pauseEmulation.Sensitive = false;
  1108. _resumeEmulation.Sensitive = true;
  1109. _emulationContext.System.TogglePauseEmulation(true);
  1110. }
  1111. private void ResumeEmulation_Pressed(object sender, EventArgs args)
  1112. {
  1113. _pauseEmulation.Sensitive = true;
  1114. _resumeEmulation.Sensitive = false;
  1115. _emulationContext.System.TogglePauseEmulation(false);
  1116. }
  1117. public void ActivatePauseMenu()
  1118. {
  1119. _pauseEmulation.Sensitive = true;
  1120. _resumeEmulation.Sensitive = false;
  1121. }
  1122. public void TogglePause()
  1123. {
  1124. _pauseEmulation.Sensitive ^= true;
  1125. _resumeEmulation.Sensitive ^= true;
  1126. _emulationContext.System.TogglePauseEmulation(_resumeEmulation.Sensitive);
  1127. }
  1128. private void Installer_File_Pressed(object o, EventArgs args)
  1129. {
  1130. FileChooserNative fileChooser = new FileChooserNative("Choose the firmware file to open", this, FileChooserAction.Open, "Open", "Cancel");
  1131. FileFilter filter = new FileFilter
  1132. {
  1133. Name = "Switch Firmware Files"
  1134. };
  1135. filter.AddPattern("*.zip");
  1136. filter.AddPattern("*.xci");
  1137. fileChooser.AddFilter(filter);
  1138. HandleInstallerDialog(fileChooser);
  1139. }
  1140. private void Installer_Directory_Pressed(object o, EventArgs args)
  1141. {
  1142. FileChooserNative directoryChooser = new FileChooserNative("Choose the firmware directory to open", this, FileChooserAction.SelectFolder, "Open", "Cancel");
  1143. HandleInstallerDialog(directoryChooser);
  1144. }
  1145. private void HandleInstallerDialog(FileChooserNative fileChooser)
  1146. {
  1147. if (fileChooser.Run() == (int)ResponseType.Accept)
  1148. {
  1149. try
  1150. {
  1151. string filename = fileChooser.Filename;
  1152. fileChooser.Dispose();
  1153. SystemVersion firmwareVersion = _contentManager.VerifyFirmwarePackage(filename);
  1154. if (firmwareVersion is null)
  1155. {
  1156. GtkDialog.CreateErrorDialog($"A valid system firmware was not found in {filename}.");
  1157. return;
  1158. }
  1159. string dialogTitle = $"Install Firmware {firmwareVersion.VersionString}";
  1160. SystemVersion currentVersion = _contentManager.GetCurrentFirmwareVersion();
  1161. string dialogMessage = $"System version {firmwareVersion.VersionString} will be installed.";
  1162. if (currentVersion != null)
  1163. {
  1164. dialogMessage += $"\n\nThis will replace the current system version {currentVersion.VersionString}. ";
  1165. }
  1166. dialogMessage += "\n\nDo you want to continue?";
  1167. ResponseType responseInstallDialog = (ResponseType)GtkDialog.CreateConfirmationDialog(dialogTitle, dialogMessage).Run();
  1168. MessageDialog waitingDialog = GtkDialog.CreateWaitingDialog(dialogTitle, "Installing firmware...");
  1169. if (responseInstallDialog == ResponseType.Yes)
  1170. {
  1171. Logger.Info?.Print(LogClass.Application, $"Installing firmware {firmwareVersion.VersionString}");
  1172. Thread thread = new Thread(() =>
  1173. {
  1174. Application.Invoke(delegate
  1175. {
  1176. waitingDialog.Run();
  1177. });
  1178. try
  1179. {
  1180. _contentManager.InstallFirmware(filename);
  1181. Application.Invoke(delegate
  1182. {
  1183. waitingDialog.Dispose();
  1184. string message = $"System version {firmwareVersion.VersionString} successfully installed.";
  1185. GtkDialog.CreateInfoDialog(dialogTitle, message);
  1186. Logger.Info?.Print(LogClass.Application, message);
  1187. // Purge Applet Cache.
  1188. DirectoryInfo miiEditorCacheFolder = new DirectoryInfo(System.IO.Path.Combine(AppDataManager.GamesDirPath, "0100000000001009", "cache"));
  1189. if (miiEditorCacheFolder.Exists)
  1190. {
  1191. miiEditorCacheFolder.Delete(true);
  1192. }
  1193. });
  1194. }
  1195. catch (Exception ex)
  1196. {
  1197. Application.Invoke(delegate
  1198. {
  1199. waitingDialog.Dispose();
  1200. GtkDialog.CreateErrorDialog(ex.Message);
  1201. });
  1202. }
  1203. finally
  1204. {
  1205. RefreshFirmwareLabel();
  1206. }
  1207. });
  1208. thread.Name = "GUI.FirmwareInstallerThread";
  1209. thread.Start();
  1210. }
  1211. }
  1212. catch (MissingKeyException ex)
  1213. {
  1214. Logger.Error?.Print(LogClass.Application, ex.ToString());
  1215. UserErrorDialog.CreateUserErrorDialog(UserError.FirmwareParsingFailed);
  1216. }
  1217. catch (Exception ex)
  1218. {
  1219. GtkDialog.CreateErrorDialog(ex.Message);
  1220. }
  1221. }
  1222. else
  1223. {
  1224. fileChooser.Dispose();
  1225. }
  1226. }
  1227. private void RefreshFirmwareLabel()
  1228. {
  1229. SystemVersion currentFirmware = _contentManager.GetCurrentFirmwareVersion();
  1230. Application.Invoke(delegate
  1231. {
  1232. _firmwareVersionLabel.Text = currentFirmware != null ? currentFirmware.VersionString : "0.0.0";
  1233. });
  1234. }
  1235. private void InstallFileTypes_Pressed(object sender, EventArgs e)
  1236. {
  1237. if (FileAssociationHelper.Install())
  1238. {
  1239. GtkDialog.CreateInfoDialog("Install file types", "File types successfully installed!");
  1240. }
  1241. else
  1242. {
  1243. GtkDialog.CreateErrorDialog("Failed to install file types.");
  1244. }
  1245. }
  1246. private void UninstallFileTypes_Pressed(object sender, EventArgs e)
  1247. {
  1248. if (FileAssociationHelper.Uninstall())
  1249. {
  1250. GtkDialog.CreateInfoDialog("Uninstall file types", "File types successfully uninstalled!");
  1251. }
  1252. else
  1253. {
  1254. GtkDialog.CreateErrorDialog("Failed to uninstall file types.");
  1255. }
  1256. }
  1257. private void HandleRelaunch()
  1258. {
  1259. if (_userChannelPersistence.PreviousIndex != -1 && _userChannelPersistence.ShouldRestart)
  1260. {
  1261. _userChannelPersistence.ShouldRestart = false;
  1262. LoadApplication(_currentEmulatedGamePath);
  1263. }
  1264. else
  1265. {
  1266. // otherwise, clear state.
  1267. _userChannelPersistence = new UserChannelPersistence();
  1268. _currentEmulatedGamePath = null;
  1269. _actionMenu.Sensitive = false;
  1270. _firmwareInstallFile.Sensitive = true;
  1271. _firmwareInstallDirectory.Sensitive = true;
  1272. }
  1273. }
  1274. private void FullScreen_Toggled(object sender, EventArgs args)
  1275. {
  1276. if (!Window.State.HasFlag(Gdk.WindowState.Fullscreen))
  1277. {
  1278. Fullscreen();
  1279. ToggleExtraWidgets(false);
  1280. }
  1281. else
  1282. {
  1283. Unfullscreen();
  1284. ToggleExtraWidgets(true);
  1285. }
  1286. }
  1287. private void StartFullScreen_Toggled(object sender, EventArgs args)
  1288. {
  1289. ConfigurationState.Instance.Ui.StartFullscreen.Value = _startFullScreen.Active;
  1290. SaveConfig();
  1291. }
  1292. private void ShowConsole_Toggled(object sender, EventArgs args)
  1293. {
  1294. ConfigurationState.Instance.Ui.ShowConsole.Value = _showConsole.Active;
  1295. SaveConfig();
  1296. }
  1297. private void OptionMenu_StateChanged(object o, StateChangedArgs args)
  1298. {
  1299. _manageUserProfiles.Sensitive = _emulationContext == null;
  1300. }
  1301. private void Settings_Pressed(object sender, EventArgs args)
  1302. {
  1303. SettingsWindow settingsWindow = new SettingsWindow(this, _virtualFileSystem, _contentManager);
  1304. settingsWindow.SetSizeRequest((int)(settingsWindow.DefaultWidth * Program.WindowScaleFactor), (int)(settingsWindow.DefaultHeight * Program.WindowScaleFactor));
  1305. settingsWindow.Show();
  1306. }
  1307. private void HideUi_Pressed(object sender, EventArgs args)
  1308. {
  1309. ToggleExtraWidgets(false);
  1310. }
  1311. private void ManageCheats_Pressed(object sender, EventArgs args)
  1312. {
  1313. var window = new CheatWindow(_virtualFileSystem, _emulationContext.Application.TitleId, _emulationContext.Application.TitleName);
  1314. window.Destroyed += CheatWindow_Destroyed;
  1315. window.Show();
  1316. }
  1317. private void CheatWindow_Destroyed(object sender, EventArgs e)
  1318. {
  1319. _emulationContext.EnableCheats();
  1320. (sender as CheatWindow).Destroyed -= CheatWindow_Destroyed;
  1321. }
  1322. private void ManageUserProfiles_Pressed(object sender, EventArgs args)
  1323. {
  1324. UserProfilesManagerWindow userProfilesManagerWindow = new UserProfilesManagerWindow(_accountManager, _contentManager, _virtualFileSystem);
  1325. userProfilesManagerWindow.SetSizeRequest((int)(userProfilesManagerWindow.DefaultWidth * Program.WindowScaleFactor), (int)(userProfilesManagerWindow.DefaultHeight * Program.WindowScaleFactor));
  1326. userProfilesManagerWindow.Show();
  1327. }
  1328. private void Simulate_WakeUp_Message_Pressed(object sender, EventArgs args)
  1329. {
  1330. if (_emulationContext != null)
  1331. {
  1332. _emulationContext.System.SimulateWakeUpMessage();
  1333. }
  1334. }
  1335. private void ActionMenu_StateChanged(object o, StateChangedArgs args)
  1336. {
  1337. _scanAmiibo.Sensitive = _emulationContext != null && _emulationContext.System.SearchingForAmiibo(out int _);
  1338. _takeScreenshot.Sensitive = _emulationContext != null;
  1339. }
  1340. private void Scan_Amiibo(object sender, EventArgs args)
  1341. {
  1342. if (_emulationContext.System.SearchingForAmiibo(out int deviceId))
  1343. {
  1344. AmiiboWindow amiiboWindow = new AmiiboWindow
  1345. {
  1346. LastScannedAmiiboShowAll = _lastScannedAmiiboShowAll,
  1347. LastScannedAmiiboId = _lastScannedAmiiboId,
  1348. DeviceId = deviceId,
  1349. TitleId = _emulationContext.Application.TitleIdText.ToUpper()
  1350. };
  1351. amiiboWindow.DeleteEvent += AmiiboWindow_DeleteEvent;
  1352. amiiboWindow.Show();
  1353. }
  1354. else
  1355. {
  1356. GtkDialog.CreateInfoDialog($"Amiibo", "The game is currently not ready to receive Amiibo scan data. Ensure that you have an Amiibo-compatible game open and ready to receive Amiibo scan data.");
  1357. }
  1358. }
  1359. private void Take_Screenshot(object sender, EventArgs args)
  1360. {
  1361. if (_emulationContext != null && RendererWidget != null)
  1362. {
  1363. RendererWidget.ScreenshotRequested = true;
  1364. }
  1365. }
  1366. private void AmiiboWindow_DeleteEvent(object sender, DeleteEventArgs args)
  1367. {
  1368. if (((AmiiboWindow)sender).AmiiboId != "" && ((AmiiboWindow)sender).Response == ResponseType.Ok)
  1369. {
  1370. _lastScannedAmiiboId = ((AmiiboWindow)sender).AmiiboId;
  1371. _lastScannedAmiiboShowAll = ((AmiiboWindow)sender).LastScannedAmiiboShowAll;
  1372. _emulationContext.System.ScanAmiibo(((AmiiboWindow)sender).DeviceId, ((AmiiboWindow)sender).AmiiboId, ((AmiiboWindow)sender).UseRandomUuid);
  1373. }
  1374. }
  1375. private void Update_Pressed(object sender, EventArgs args)
  1376. {
  1377. if (Updater.CanUpdate(true))
  1378. {
  1379. Updater.BeginParse(this, true).ContinueWith(task =>
  1380. {
  1381. Logger.Error?.Print(LogClass.Application, $"Updater error: {task.Exception}");
  1382. }, TaskContinuationOptions.OnlyOnFaulted);
  1383. }
  1384. }
  1385. private void About_Pressed(object sender, EventArgs args)
  1386. {
  1387. AboutWindow aboutWindow = new AboutWindow();
  1388. aboutWindow.SetSizeRequest((int)(aboutWindow.DefaultWidth * Program.WindowScaleFactor), (int)(aboutWindow.DefaultHeight * Program.WindowScaleFactor));
  1389. aboutWindow.Show();
  1390. }
  1391. private void Fav_Toggled(object sender, EventArgs args)
  1392. {
  1393. ConfigurationState.Instance.Ui.GuiColumns.FavColumn.Value = _favToggle.Active;
  1394. SaveConfig();
  1395. UpdateColumns();
  1396. }
  1397. private void Icon_Toggled(object sender, EventArgs args)
  1398. {
  1399. ConfigurationState.Instance.Ui.GuiColumns.IconColumn.Value = _iconToggle.Active;
  1400. SaveConfig();
  1401. UpdateColumns();
  1402. }
  1403. private void App_Toggled(object sender, EventArgs args)
  1404. {
  1405. ConfigurationState.Instance.Ui.GuiColumns.AppColumn.Value = _appToggle.Active;
  1406. SaveConfig();
  1407. UpdateColumns();
  1408. }
  1409. private void Developer_Toggled(object sender, EventArgs args)
  1410. {
  1411. ConfigurationState.Instance.Ui.GuiColumns.DevColumn.Value = _developerToggle.Active;
  1412. SaveConfig();
  1413. UpdateColumns();
  1414. }
  1415. private void Version_Toggled(object sender, EventArgs args)
  1416. {
  1417. ConfigurationState.Instance.Ui.GuiColumns.VersionColumn.Value = _versionToggle.Active;
  1418. SaveConfig();
  1419. UpdateColumns();
  1420. }
  1421. private void TimePlayed_Toggled(object sender, EventArgs args)
  1422. {
  1423. ConfigurationState.Instance.Ui.GuiColumns.TimePlayedColumn.Value = _timePlayedToggle.Active;
  1424. SaveConfig();
  1425. UpdateColumns();
  1426. }
  1427. private void LastPlayed_Toggled(object sender, EventArgs args)
  1428. {
  1429. ConfigurationState.Instance.Ui.GuiColumns.LastPlayedColumn.Value = _lastPlayedToggle.Active;
  1430. SaveConfig();
  1431. UpdateColumns();
  1432. }
  1433. private void FileExt_Toggled(object sender, EventArgs args)
  1434. {
  1435. ConfigurationState.Instance.Ui.GuiColumns.FileExtColumn.Value = _fileExtToggle.Active;
  1436. SaveConfig();
  1437. UpdateColumns();
  1438. }
  1439. private void FileSize_Toggled(object sender, EventArgs args)
  1440. {
  1441. ConfigurationState.Instance.Ui.GuiColumns.FileSizeColumn.Value = _fileSizeToggle.Active;
  1442. SaveConfig();
  1443. UpdateColumns();
  1444. }
  1445. private void Path_Toggled(object sender, EventArgs args)
  1446. {
  1447. ConfigurationState.Instance.Ui.GuiColumns.PathColumn.Value = _pathToggle.Active;
  1448. SaveConfig();
  1449. UpdateColumns();
  1450. }
  1451. private void RefreshList_Pressed(object sender, ButtonReleaseEventArgs args)
  1452. {
  1453. UpdateGameTable();
  1454. }
  1455. }
  1456. }