MainWindow.cs 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777
  1. using ARMeilleure.Translation;
  2. using Gtk;
  3. using LibHac.Common;
  4. using LibHac.Common.Keys;
  5. using LibHac.FsSystem;
  6. using LibHac.Ncm;
  7. using LibHac.Ns;
  8. using LibHac.Tools.FsSystem;
  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. _emulationContext = new HLE.Switch(configuration);
  494. }
  495. private SurfaceKHR CreateVulkanSurface(Instance instance, Vk vk)
  496. {
  497. return new SurfaceKHR((ulong)((VKRenderer)RendererWidget).CreateWindowSurface(instance.Handle));
  498. }
  499. private void SetupProgressUiHandlers()
  500. {
  501. if (_emulationContext.Application.DiskCacheLoadState != null)
  502. {
  503. _emulationContext.Application.DiskCacheLoadState.StateChanged -= ProgressHandler;
  504. _emulationContext.Application.DiskCacheLoadState.StateChanged += ProgressHandler;
  505. }
  506. _emulationContext.Gpu.ShaderCacheStateChanged -= ProgressHandler;
  507. _emulationContext.Gpu.ShaderCacheStateChanged += ProgressHandler;
  508. }
  509. private void ProgressHandler<T>(T state, int current, int total) where T : Enum
  510. {
  511. bool visible;
  512. string label;
  513. switch (state)
  514. {
  515. case LoadState ptcState:
  516. visible = ptcState != LoadState.Loaded;
  517. label = $"PTC : {current}/{total}";
  518. break;
  519. case ShaderCacheLoadingState shaderCacheState:
  520. visible = shaderCacheState != ShaderCacheLoadingState.Loaded;
  521. label = $"Shaders : {current}/{total}";
  522. break;
  523. default:
  524. throw new ArgumentException($"Unknown Progress Handler type {typeof(T)}");
  525. }
  526. Application.Invoke(delegate
  527. {
  528. _loadingStatusLabel.Text = label;
  529. _loadingStatusBar.Fraction = total > 0 ? (double)current / total : 0;
  530. _loadingStatusBar.Visible = visible;
  531. _loadingStatusLabel.Visible = visible;
  532. });
  533. }
  534. public void UpdateGameTable()
  535. {
  536. if (_updatingGameTable || _gameLoaded)
  537. {
  538. return;
  539. }
  540. _updatingGameTable = true;
  541. _tableStore.Clear();
  542. Thread applicationLibraryThread = new Thread(() =>
  543. {
  544. _applicationLibrary.LoadApplications(ConfigurationState.Instance.Ui.GameDirs, ConfigurationState.Instance.System.Language);
  545. _updatingGameTable = false;
  546. });
  547. applicationLibraryThread.Name = "GUI.ApplicationLibraryThread";
  548. applicationLibraryThread.IsBackground = true;
  549. applicationLibraryThread.Start();
  550. }
  551. [Conditional("RELEASE")]
  552. public void PerformanceCheck()
  553. {
  554. if (ConfigurationState.Instance.Logger.EnableTrace.Value)
  555. {
  556. MessageDialog debugWarningDialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo, null)
  557. {
  558. Title = "Ryujinx - Warning",
  559. Text = "You have trace logging enabled, which is designed to be used by developers only.",
  560. SecondaryText = "For optimal performance, it's recommended to disable trace logging. Would you like to disable trace logging now?"
  561. };
  562. if (debugWarningDialog.Run() == (int)ResponseType.Yes)
  563. {
  564. ConfigurationState.Instance.Logger.EnableTrace.Value = false;
  565. SaveConfig();
  566. }
  567. debugWarningDialog.Dispose();
  568. }
  569. if (!string.IsNullOrWhiteSpace(ConfigurationState.Instance.Graphics.ShadersDumpPath.Value))
  570. {
  571. MessageDialog shadersDumpWarningDialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo, null)
  572. {
  573. Title = "Ryujinx - Warning",
  574. Text = "You have shader dumping enabled, which is designed to be used by developers only.",
  575. SecondaryText = "For optimal performance, it's recommended to disable shader dumping. Would you like to disable shader dumping now?"
  576. };
  577. if (shadersDumpWarningDialog.Run() == (int)ResponseType.Yes)
  578. {
  579. ConfigurationState.Instance.Graphics.ShadersDumpPath.Value = "";
  580. SaveConfig();
  581. }
  582. shadersDumpWarningDialog.Dispose();
  583. }
  584. }
  585. public void LoadApplication(string path, bool startFullscreen = false)
  586. {
  587. if (_gameLoaded)
  588. {
  589. GtkDialog.CreateInfoDialog("A game has already been loaded", "Please stop emulation or close the emulator before launching another game.");
  590. }
  591. else
  592. {
  593. PerformanceCheck();
  594. Logger.RestartTime();
  595. RendererWidget = CreateRendererWidget();
  596. SwitchToRenderWidget(startFullscreen);
  597. InitializeSwitchInstance();
  598. UpdateGraphicsConfig();
  599. SystemVersion firmwareVersion = _contentManager.GetCurrentFirmwareVersion();
  600. bool isDirectory = Directory.Exists(path);
  601. bool isFirmwareTitle = false;
  602. if (path.StartsWith("@SystemContent"))
  603. {
  604. path = _virtualFileSystem.SwitchPathToSystemPath(path);
  605. isFirmwareTitle = true;
  606. }
  607. if (!SetupValidator.CanStartApplication(_contentManager, path, out UserError userError))
  608. {
  609. if (SetupValidator.CanFixStartApplication(_contentManager, path, userError, out firmwareVersion))
  610. {
  611. if (userError == UserError.NoFirmware)
  612. {
  613. string message = $"Would you like to install the firmware embedded in this game? (Firmware {firmwareVersion.VersionString})";
  614. ResponseType responseDialog = (ResponseType)GtkDialog.CreateConfirmationDialog("No Firmware Installed", message).Run();
  615. if (responseDialog != ResponseType.Yes)
  616. {
  617. UserErrorDialog.CreateUserErrorDialog(userError);
  618. _emulationContext.Dispose();
  619. SwitchToGameTable();
  620. return;
  621. }
  622. }
  623. if (!SetupValidator.TryFixStartApplication(_contentManager, path, userError, out _))
  624. {
  625. UserErrorDialog.CreateUserErrorDialog(userError);
  626. _emulationContext.Dispose();
  627. SwitchToGameTable();
  628. return;
  629. }
  630. // Tell the user that we installed a firmware for them.
  631. if (userError == UserError.NoFirmware)
  632. {
  633. firmwareVersion = _contentManager.GetCurrentFirmwareVersion();
  634. RefreshFirmwareLabel();
  635. 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.";
  636. GtkDialog.CreateInfoDialog($"Firmware {firmwareVersion.VersionString} was installed", message);
  637. }
  638. }
  639. else
  640. {
  641. UserErrorDialog.CreateUserErrorDialog(userError);
  642. _emulationContext.Dispose();
  643. SwitchToGameTable();
  644. return;
  645. }
  646. }
  647. Logger.Notice.Print(LogClass.Application, $"Using Firmware Version: {firmwareVersion?.VersionString}");
  648. if (isFirmwareTitle)
  649. {
  650. Logger.Info?.Print(LogClass.Application, "Loading as Firmware Title (NCA).");
  651. _emulationContext.LoadNca(path);
  652. }
  653. else if (Directory.Exists(path))
  654. {
  655. string[] romFsFiles = Directory.GetFiles(path, "*.istorage");
  656. if (romFsFiles.Length == 0)
  657. {
  658. romFsFiles = Directory.GetFiles(path, "*.romfs");
  659. }
  660. if (romFsFiles.Length > 0)
  661. {
  662. Logger.Info?.Print(LogClass.Application, "Loading as cart with RomFS.");
  663. _emulationContext.LoadCart(path, romFsFiles[0]);
  664. }
  665. else
  666. {
  667. Logger.Info?.Print(LogClass.Application, "Loading as cart WITHOUT RomFS.");
  668. _emulationContext.LoadCart(path);
  669. }
  670. }
  671. else if (File.Exists(path))
  672. {
  673. switch (System.IO.Path.GetExtension(path).ToLowerInvariant())
  674. {
  675. case ".xci":
  676. Logger.Info?.Print(LogClass.Application, "Loading as XCI.");
  677. _emulationContext.LoadXci(path);
  678. break;
  679. case ".nca":
  680. Logger.Info?.Print(LogClass.Application, "Loading as NCA.");
  681. _emulationContext.LoadNca(path);
  682. break;
  683. case ".nsp":
  684. case ".pfs0":
  685. Logger.Info?.Print(LogClass.Application, "Loading as NSP.");
  686. _emulationContext.LoadNsp(path);
  687. break;
  688. default:
  689. Logger.Info?.Print(LogClass.Application, "Loading as Homebrew.");
  690. try
  691. {
  692. _emulationContext.LoadProgram(path);
  693. }
  694. catch (ArgumentOutOfRangeException)
  695. {
  696. Logger.Error?.Print(LogClass.Application, "The specified file is not supported by Ryujinx.");
  697. }
  698. break;
  699. }
  700. }
  701. else
  702. {
  703. Logger.Warning?.Print(LogClass.Application, "Please specify a valid XCI/NCA/NSP/PFS0/NRO file.");
  704. _emulationContext.Dispose();
  705. RendererWidget.Dispose();
  706. return;
  707. }
  708. SetupProgressUiHandlers();
  709. _currentEmulatedGamePath = path;
  710. _deviceExitStatus.Reset();
  711. Translator.IsReadyForTranslation.Reset();
  712. Thread windowThread = new Thread(() =>
  713. {
  714. CreateGameWindow();
  715. })
  716. {
  717. Name = "GUI.WindowThread"
  718. };
  719. windowThread.Start();
  720. _gameLoaded = true;
  721. _actionMenu.Sensitive = true;
  722. UpdateMenuItem.Sensitive = false;
  723. _lastScannedAmiiboId = "";
  724. _firmwareInstallFile.Sensitive = false;
  725. _firmwareInstallDirectory.Sensitive = false;
  726. DiscordIntegrationModule.SwitchToPlayingState(_emulationContext.Application.TitleIdText, _emulationContext.Application.TitleName);
  727. _applicationLibrary.LoadAndSaveMetaData(_emulationContext.Application.TitleIdText, appMetadata =>
  728. {
  729. appMetadata.LastPlayed = DateTime.UtcNow.ToString();
  730. });
  731. }
  732. }
  733. private RendererWidgetBase CreateRendererWidget()
  734. {
  735. if (ConfigurationState.Instance.Graphics.GraphicsBackend == GraphicsBackend.Vulkan)
  736. {
  737. return new VKRenderer(InputManager, ConfigurationState.Instance.Logger.GraphicsDebugLevel);
  738. }
  739. else
  740. {
  741. return new GlRenderer(InputManager, ConfigurationState.Instance.Logger.GraphicsDebugLevel);
  742. }
  743. }
  744. private void SwitchToRenderWidget(bool startFullscreen = false)
  745. {
  746. _viewBox.Remove(_gameTableWindow);
  747. RendererWidget.Expand = true;
  748. _viewBox.Child = RendererWidget;
  749. RendererWidget.ShowAll();
  750. EditFooterForGameRenderer();
  751. if (Window.State.HasFlag(Gdk.WindowState.Fullscreen))
  752. {
  753. ToggleExtraWidgets(false);
  754. }
  755. else if (startFullscreen || ConfigurationState.Instance.Ui.StartFullscreen.Value)
  756. {
  757. FullScreen_Toggled(null, null);
  758. }
  759. }
  760. private void SwitchToGameTable()
  761. {
  762. if (Window.State.HasFlag(Gdk.WindowState.Fullscreen))
  763. {
  764. ToggleExtraWidgets(true);
  765. }
  766. RendererWidget.Exit();
  767. if (RendererWidget.Window != Window && RendererWidget.Window != null)
  768. {
  769. RendererWidget.Window.Dispose();
  770. }
  771. RendererWidget.Dispose();
  772. if (OperatingSystem.IsWindows())
  773. {
  774. _windowsMultimediaTimerResolution?.Dispose();
  775. _windowsMultimediaTimerResolution = null;
  776. }
  777. DisplaySleep.Restore();
  778. _viewBox.Remove(RendererWidget);
  779. _viewBox.Add(_gameTableWindow);
  780. _gameTableWindow.Expand = true;
  781. Window.Title = $"Ryujinx {Program.Version}";
  782. _emulationContext = null;
  783. _gameLoaded = false;
  784. RendererWidget = null;
  785. DiscordIntegrationModule.SwitchToMainMenu();
  786. RecreateFooterForMenu();
  787. UpdateColumns();
  788. UpdateGameTable();
  789. RefreshFirmwareLabel();
  790. HandleRelaunch();
  791. }
  792. private void CreateGameWindow()
  793. {
  794. if (OperatingSystem.IsWindows())
  795. {
  796. _windowsMultimediaTimerResolution = new WindowsMultimediaTimerResolution(1);
  797. }
  798. DisplaySleep.Prevent();
  799. RendererWidget.Initialize(_emulationContext);
  800. RendererWidget.WaitEvent.WaitOne();
  801. RendererWidget.Start();
  802. _emulationContext.Dispose();
  803. _deviceExitStatus.Set();
  804. // NOTE: Everything that is here will not be executed when you close the UI.
  805. Application.Invoke(delegate
  806. {
  807. SwitchToGameTable();
  808. });
  809. }
  810. private void RecreateFooterForMenu()
  811. {
  812. _listStatusBox.Show();
  813. _statusBar.Hide();
  814. }
  815. private void EditFooterForGameRenderer()
  816. {
  817. _listStatusBox.Hide();
  818. _statusBar.Show();
  819. }
  820. public void ToggleExtraWidgets(bool show)
  821. {
  822. if (RendererWidget != null)
  823. {
  824. if (show)
  825. {
  826. _menuBar.ShowAll();
  827. _footerBox.Show();
  828. _statusBar.Show();
  829. }
  830. else
  831. {
  832. _menuBar.Hide();
  833. _footerBox.Hide();
  834. }
  835. }
  836. }
  837. private void UpdateGameMetadata(string titleId)
  838. {
  839. if (_gameLoaded)
  840. {
  841. _applicationLibrary.LoadAndSaveMetaData(titleId, appMetadata =>
  842. {
  843. DateTime lastPlayedDateTime = DateTime.Parse(appMetadata.LastPlayed);
  844. double sessionTimePlayed = DateTime.UtcNow.Subtract(lastPlayedDateTime).TotalSeconds;
  845. appMetadata.TimePlayed += Math.Round(sessionTimePlayed, MidpointRounding.AwayFromZero);
  846. });
  847. }
  848. }
  849. public void UpdateGraphicsConfig()
  850. {
  851. int resScale = ConfigurationState.Instance.Graphics.ResScale;
  852. float resScaleCustom = ConfigurationState.Instance.Graphics.ResScaleCustom;
  853. Graphics.Gpu.GraphicsConfig.ResScale = (resScale == -1) ? resScaleCustom : resScale;
  854. Graphics.Gpu.GraphicsConfig.MaxAnisotropy = ConfigurationState.Instance.Graphics.MaxAnisotropy;
  855. Graphics.Gpu.GraphicsConfig.ShadersDumpPath = ConfigurationState.Instance.Graphics.ShadersDumpPath;
  856. Graphics.Gpu.GraphicsConfig.EnableShaderCache = ConfigurationState.Instance.Graphics.EnableShaderCache;
  857. Graphics.Gpu.GraphicsConfig.EnableTextureRecompression = ConfigurationState.Instance.Graphics.EnableTextureRecompression;
  858. Graphics.Gpu.GraphicsConfig.EnableMacroHLE = ConfigurationState.Instance.Graphics.EnableMacroHLE;
  859. }
  860. public void SaveConfig()
  861. {
  862. ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
  863. }
  864. private void End()
  865. {
  866. if (_ending)
  867. {
  868. return;
  869. }
  870. _ending = true;
  871. if (_emulationContext != null)
  872. {
  873. UpdateGameMetadata(_emulationContext.Application.TitleIdText);
  874. if (RendererWidget != null)
  875. {
  876. // We tell the widget that we are exiting.
  877. RendererWidget.Exit();
  878. // Wait for the other thread to dispose the HLE context before exiting.
  879. _deviceExitStatus.WaitOne();
  880. RendererWidget.Dispose();
  881. }
  882. }
  883. Dispose();
  884. Program.Exit();
  885. Application.Quit();
  886. }
  887. //
  888. // Events
  889. //
  890. private void Application_Added(object sender, ApplicationAddedEventArgs args)
  891. {
  892. Application.Invoke(delegate
  893. {
  894. _tableStore.AppendValues(
  895. args.AppData.Favorite,
  896. new Gdk.Pixbuf(args.AppData.Icon, 75, 75),
  897. $"{args.AppData.TitleName}\n{args.AppData.TitleId.ToUpper()}",
  898. args.AppData.Developer,
  899. args.AppData.Version,
  900. args.AppData.TimePlayed,
  901. args.AppData.LastPlayed,
  902. args.AppData.FileExtension,
  903. args.AppData.FileSize,
  904. args.AppData.Path,
  905. args.AppData.ControlHolder);
  906. });
  907. }
  908. private void ApplicationCount_Updated(object sender, ApplicationCountUpdatedEventArgs args)
  909. {
  910. Application.Invoke(delegate
  911. {
  912. _progressLabel.Text = $"{args.NumAppsLoaded}/{args.NumAppsFound} Games Loaded";
  913. float barValue = 0;
  914. if (args.NumAppsFound != 0)
  915. {
  916. barValue = (float)args.NumAppsLoaded / args.NumAppsFound;
  917. }
  918. _progressBar.Fraction = barValue;
  919. // Reset the vertical scrollbar to the top when titles finish loading
  920. if (args.NumAppsLoaded == args.NumAppsFound)
  921. {
  922. _gameTableWindow.Vadjustment.Value = 0;
  923. }
  924. });
  925. }
  926. private void Update_StatusBar(object sender, StatusUpdatedEventArgs args)
  927. {
  928. Application.Invoke(delegate
  929. {
  930. _gameStatus.Text = args.GameStatus;
  931. _fifoStatus.Text = args.FifoStatus;
  932. _gpuName.Text = args.GpuName;
  933. _dockedMode.Text = args.DockedMode;
  934. _aspectRatio.Text = args.AspectRatio;
  935. _gpuBackend.Text = args.GpuBackend;
  936. _volumeStatus.Text = GetVolumeLabelText(args.Volume);
  937. if (args.VSyncEnabled)
  938. {
  939. _vSyncStatus.Attributes = new Pango.AttrList();
  940. _vSyncStatus.Attributes.Insert(new Pango.AttrForeground(11822, 60138, 51657));
  941. }
  942. else
  943. {
  944. _vSyncStatus.Attributes = new Pango.AttrList();
  945. _vSyncStatus.Attributes.Insert(new Pango.AttrForeground(ushort.MaxValue, 17733, 21588));
  946. }
  947. });
  948. }
  949. private void FavToggle_Toggled(object sender, ToggledArgs args)
  950. {
  951. _tableStore.GetIter(out TreeIter treeIter, new TreePath(args.Path));
  952. string titleId = _tableStore.GetValue(treeIter, 2).ToString().Split("\n")[1].ToLower();
  953. bool newToggleValue = !(bool)_tableStore.GetValue(treeIter, 0);
  954. _tableStore.SetValue(treeIter, 0, newToggleValue);
  955. _applicationLibrary.LoadAndSaveMetaData(titleId, appMetadata =>
  956. {
  957. appMetadata.Favorite = newToggleValue;
  958. });
  959. }
  960. private void Column_Clicked(object sender, EventArgs args)
  961. {
  962. TreeViewColumn column = (TreeViewColumn)sender;
  963. ConfigurationState.Instance.Ui.ColumnSort.SortColumnId.Value = column.SortColumnId;
  964. ConfigurationState.Instance.Ui.ColumnSort.SortAscending.Value = column.SortOrder == SortType.Ascending;
  965. SaveConfig();
  966. }
  967. private void Row_Activated(object sender, RowActivatedArgs args)
  968. {
  969. _gameTableSelection.GetSelected(out TreeIter treeIter);
  970. string path = (string)_tableStore.GetValue(treeIter, 9);
  971. LoadApplication(path);
  972. }
  973. private void VSyncStatus_Clicked(object sender, ButtonReleaseEventArgs args)
  974. {
  975. _emulationContext.EnableDeviceVsync = !_emulationContext.EnableDeviceVsync;
  976. Logger.Info?.Print(LogClass.Application, $"VSync toggled to: {_emulationContext.EnableDeviceVsync}");
  977. }
  978. private void DockedMode_Clicked(object sender, ButtonReleaseEventArgs args)
  979. {
  980. ConfigurationState.Instance.System.EnableDockedMode.Value = !ConfigurationState.Instance.System.EnableDockedMode.Value;
  981. }
  982. private string GetVolumeLabelText(float volume)
  983. {
  984. string icon = volume == 0 ? "🔇" : "🔊";
  985. return $"{icon} {(int)(volume * 100)}%";
  986. }
  987. private void VolumeStatus_Clicked(object sender, ButtonReleaseEventArgs args)
  988. {
  989. if (_emulationContext != null)
  990. {
  991. if (_emulationContext.IsAudioMuted())
  992. {
  993. _emulationContext.SetVolume(ConfigurationState.Instance.System.AudioVolume);
  994. }
  995. else
  996. {
  997. _emulationContext.SetVolume(0);
  998. }
  999. }
  1000. }
  1001. private void AspectRatio_Clicked(object sender, ButtonReleaseEventArgs args)
  1002. {
  1003. AspectRatio aspectRatio = ConfigurationState.Instance.Graphics.AspectRatio.Value;
  1004. ConfigurationState.Instance.Graphics.AspectRatio.Value = ((int)aspectRatio + 1) > Enum.GetNames<AspectRatio>().Length - 1 ? AspectRatio.Fixed4x3 : aspectRatio + 1;
  1005. }
  1006. private void Row_Clicked(object sender, ButtonReleaseEventArgs args)
  1007. {
  1008. if (args.Event.Button != 3 /* Right Click */)
  1009. {
  1010. return;
  1011. }
  1012. _gameTableSelection.GetSelected(out TreeIter treeIter);
  1013. if (treeIter.UserData == IntPtr.Zero)
  1014. {
  1015. return;
  1016. }
  1017. string titleFilePath = _tableStore.GetValue(treeIter, 9).ToString();
  1018. string titleName = _tableStore.GetValue(treeIter, 2).ToString().Split("\n")[0];
  1019. string titleId = _tableStore.GetValue(treeIter, 2).ToString().Split("\n")[1].ToLower();
  1020. BlitStruct<ApplicationControlProperty> controlData = (BlitStruct<ApplicationControlProperty>)_tableStore.GetValue(treeIter, 10);
  1021. _ = new GameTableContextMenu(this, _virtualFileSystem, _accountManager, _libHacHorizonManager.RyujinxClient, titleFilePath, titleName, titleId, controlData);
  1022. }
  1023. private void Load_Application_File(object sender, EventArgs args)
  1024. {
  1025. using (FileChooserNative fileChooser = new FileChooserNative("Choose the file to open", this, FileChooserAction.Open, "Open", "Cancel"))
  1026. {
  1027. FileFilter filter = new FileFilter()
  1028. {
  1029. Name = "Switch Executables"
  1030. };
  1031. filter.AddPattern("*.xci");
  1032. filter.AddPattern("*.nsp");
  1033. filter.AddPattern("*.pfs0");
  1034. filter.AddPattern("*.nca");
  1035. filter.AddPattern("*.nro");
  1036. filter.AddPattern("*.nso");
  1037. fileChooser.AddFilter(filter);
  1038. if (fileChooser.Run() == (int)ResponseType.Accept)
  1039. {
  1040. LoadApplication(fileChooser.Filename);
  1041. }
  1042. }
  1043. }
  1044. private void Load_Application_Folder(object sender, EventArgs args)
  1045. {
  1046. using (FileChooserNative fileChooser = new FileChooserNative("Choose the folder to open", this, FileChooserAction.SelectFolder, "Open", "Cancel"))
  1047. {
  1048. if (fileChooser.Run() == (int)ResponseType.Accept)
  1049. {
  1050. LoadApplication(fileChooser.Filename);
  1051. }
  1052. }
  1053. }
  1054. private void FileMenu_StateChanged(object o, StateChangedArgs args)
  1055. {
  1056. _appletMenu.Sensitive = _emulationContext == null && _contentManager.GetCurrentFirmwareVersion() != null && _contentManager.GetCurrentFirmwareVersion().Major > 3;
  1057. _loadApplicationFile.Sensitive = _emulationContext == null;
  1058. _loadApplicationFolder.Sensitive = _emulationContext == null;
  1059. }
  1060. private void Load_Mii_Edit_Applet(object sender, EventArgs args)
  1061. {
  1062. string contentPath = _contentManager.GetInstalledContentPath(0x0100000000001009, StorageId.BuiltInSystem, NcaContentType.Program);
  1063. LoadApplication(contentPath);
  1064. }
  1065. private void Open_Ryu_Folder(object sender, EventArgs args)
  1066. {
  1067. OpenHelper.OpenFolder(AppDataManager.BaseDirPath);
  1068. }
  1069. private void OpenLogsFolder_Pressed(object sender, EventArgs args)
  1070. {
  1071. string logPath = System.IO.Path.Combine(ReleaseInformation.GetBaseApplicationDirectory(), "Logs");
  1072. new DirectoryInfo(logPath).Create();
  1073. OpenHelper.OpenFolder(logPath);
  1074. }
  1075. private void Exit_Pressed(object sender, EventArgs args)
  1076. {
  1077. if (!_gameLoaded || !ConfigurationState.Instance.ShowConfirmExit || GtkDialog.CreateExitDialog())
  1078. {
  1079. End();
  1080. }
  1081. }
  1082. private void Window_Close(object sender, DeleteEventArgs args)
  1083. {
  1084. if (!_gameLoaded || !ConfigurationState.Instance.ShowConfirmExit || GtkDialog.CreateExitDialog())
  1085. {
  1086. End();
  1087. }
  1088. else
  1089. {
  1090. args.RetVal = true;
  1091. }
  1092. }
  1093. private void StopEmulation_Pressed(object sender, EventArgs args)
  1094. {
  1095. if (_emulationContext != null)
  1096. {
  1097. UpdateGameMetadata(_emulationContext.Application.TitleIdText);
  1098. }
  1099. _pauseEmulation.Sensitive = false;
  1100. _resumeEmulation.Sensitive = false;
  1101. UpdateMenuItem.Sensitive = true;
  1102. RendererWidget?.Exit();
  1103. }
  1104. private void PauseEmulation_Pressed(object sender, EventArgs args)
  1105. {
  1106. _pauseEmulation.Sensitive = false;
  1107. _resumeEmulation.Sensitive = true;
  1108. _emulationContext.System.TogglePauseEmulation(true);
  1109. }
  1110. private void ResumeEmulation_Pressed(object sender, EventArgs args)
  1111. {
  1112. _pauseEmulation.Sensitive = true;
  1113. _resumeEmulation.Sensitive = false;
  1114. _emulationContext.System.TogglePauseEmulation(false);
  1115. }
  1116. public void ActivatePauseMenu()
  1117. {
  1118. _pauseEmulation.Sensitive = true;
  1119. _resumeEmulation.Sensitive = false;
  1120. }
  1121. public void TogglePause()
  1122. {
  1123. _pauseEmulation.Sensitive ^= true;
  1124. _resumeEmulation.Sensitive ^= true;
  1125. _emulationContext.System.TogglePauseEmulation(_resumeEmulation.Sensitive);
  1126. }
  1127. private void Installer_File_Pressed(object o, EventArgs args)
  1128. {
  1129. FileChooserNative fileChooser = new FileChooserNative("Choose the firmware file to open", this, FileChooserAction.Open, "Open", "Cancel");
  1130. FileFilter filter = new FileFilter
  1131. {
  1132. Name = "Switch Firmware Files"
  1133. };
  1134. filter.AddPattern("*.zip");
  1135. filter.AddPattern("*.xci");
  1136. fileChooser.AddFilter(filter);
  1137. HandleInstallerDialog(fileChooser);
  1138. }
  1139. private void Installer_Directory_Pressed(object o, EventArgs args)
  1140. {
  1141. FileChooserNative directoryChooser = new FileChooserNative("Choose the firmware directory to open", this, FileChooserAction.SelectFolder, "Open", "Cancel");
  1142. HandleInstallerDialog(directoryChooser);
  1143. }
  1144. private void HandleInstallerDialog(FileChooserNative fileChooser)
  1145. {
  1146. if (fileChooser.Run() == (int)ResponseType.Accept)
  1147. {
  1148. try
  1149. {
  1150. string filename = fileChooser.Filename;
  1151. fileChooser.Dispose();
  1152. SystemVersion firmwareVersion = _contentManager.VerifyFirmwarePackage(filename);
  1153. if (firmwareVersion is null)
  1154. {
  1155. GtkDialog.CreateErrorDialog($"A valid system firmware was not found in {filename}.");
  1156. return;
  1157. }
  1158. string dialogTitle = $"Install Firmware {firmwareVersion.VersionString}";
  1159. SystemVersion currentVersion = _contentManager.GetCurrentFirmwareVersion();
  1160. string dialogMessage = $"System version {firmwareVersion.VersionString} will be installed.";
  1161. if (currentVersion != null)
  1162. {
  1163. dialogMessage += $"\n\nThis will replace the current system version {currentVersion.VersionString}. ";
  1164. }
  1165. dialogMessage += "\n\nDo you want to continue?";
  1166. ResponseType responseInstallDialog = (ResponseType)GtkDialog.CreateConfirmationDialog(dialogTitle, dialogMessage).Run();
  1167. MessageDialog waitingDialog = GtkDialog.CreateWaitingDialog(dialogTitle, "Installing firmware...");
  1168. if (responseInstallDialog == ResponseType.Yes)
  1169. {
  1170. Logger.Info?.Print(LogClass.Application, $"Installing firmware {firmwareVersion.VersionString}");
  1171. Thread thread = new Thread(() =>
  1172. {
  1173. Application.Invoke(delegate
  1174. {
  1175. waitingDialog.Run();
  1176. });
  1177. try
  1178. {
  1179. _contentManager.InstallFirmware(filename);
  1180. Application.Invoke(delegate
  1181. {
  1182. waitingDialog.Dispose();
  1183. string message = $"System version {firmwareVersion.VersionString} successfully installed.";
  1184. GtkDialog.CreateInfoDialog(dialogTitle, message);
  1185. Logger.Info?.Print(LogClass.Application, message);
  1186. // Purge Applet Cache.
  1187. DirectoryInfo miiEditorCacheFolder = new DirectoryInfo(System.IO.Path.Combine(AppDataManager.GamesDirPath, "0100000000001009", "cache"));
  1188. if (miiEditorCacheFolder.Exists)
  1189. {
  1190. miiEditorCacheFolder.Delete(true);
  1191. }
  1192. });
  1193. }
  1194. catch (Exception ex)
  1195. {
  1196. Application.Invoke(delegate
  1197. {
  1198. waitingDialog.Dispose();
  1199. GtkDialog.CreateErrorDialog(ex.Message);
  1200. });
  1201. }
  1202. finally
  1203. {
  1204. RefreshFirmwareLabel();
  1205. }
  1206. });
  1207. thread.Name = "GUI.FirmwareInstallerThread";
  1208. thread.Start();
  1209. }
  1210. }
  1211. catch (MissingKeyException ex)
  1212. {
  1213. Logger.Error?.Print(LogClass.Application, ex.ToString());
  1214. UserErrorDialog.CreateUserErrorDialog(UserError.FirmwareParsingFailed);
  1215. }
  1216. catch (Exception ex)
  1217. {
  1218. GtkDialog.CreateErrorDialog(ex.Message);
  1219. }
  1220. }
  1221. else
  1222. {
  1223. fileChooser.Dispose();
  1224. }
  1225. }
  1226. private void RefreshFirmwareLabel()
  1227. {
  1228. SystemVersion currentFirmware = _contentManager.GetCurrentFirmwareVersion();
  1229. Application.Invoke(delegate
  1230. {
  1231. _firmwareVersionLabel.Text = currentFirmware != null ? currentFirmware.VersionString : "0.0.0";
  1232. });
  1233. }
  1234. private void InstallFileTypes_Pressed(object sender, EventArgs e)
  1235. {
  1236. if (FileAssociationHelper.Install())
  1237. {
  1238. GtkDialog.CreateInfoDialog("Install file types", "File types successfully installed!");
  1239. }
  1240. else
  1241. {
  1242. GtkDialog.CreateErrorDialog("Failed to install file types.");
  1243. }
  1244. }
  1245. private void UninstallFileTypes_Pressed(object sender, EventArgs e)
  1246. {
  1247. if (FileAssociationHelper.Uninstall())
  1248. {
  1249. GtkDialog.CreateInfoDialog("Uninstall file types", "File types successfully uninstalled!");
  1250. }
  1251. else
  1252. {
  1253. GtkDialog.CreateErrorDialog("Failed to uninstall file types.");
  1254. }
  1255. }
  1256. private void HandleRelaunch()
  1257. {
  1258. if (_userChannelPersistence.PreviousIndex != -1 && _userChannelPersistence.ShouldRestart)
  1259. {
  1260. _userChannelPersistence.ShouldRestart = false;
  1261. LoadApplication(_currentEmulatedGamePath);
  1262. }
  1263. else
  1264. {
  1265. // otherwise, clear state.
  1266. _userChannelPersistence = new UserChannelPersistence();
  1267. _currentEmulatedGamePath = null;
  1268. _actionMenu.Sensitive = false;
  1269. _firmwareInstallFile.Sensitive = true;
  1270. _firmwareInstallDirectory.Sensitive = true;
  1271. }
  1272. }
  1273. private void FullScreen_Toggled(object sender, EventArgs args)
  1274. {
  1275. if (!Window.State.HasFlag(Gdk.WindowState.Fullscreen))
  1276. {
  1277. Fullscreen();
  1278. ToggleExtraWidgets(false);
  1279. }
  1280. else
  1281. {
  1282. Unfullscreen();
  1283. ToggleExtraWidgets(true);
  1284. }
  1285. }
  1286. private void StartFullScreen_Toggled(object sender, EventArgs args)
  1287. {
  1288. ConfigurationState.Instance.Ui.StartFullscreen.Value = _startFullScreen.Active;
  1289. SaveConfig();
  1290. }
  1291. private void ShowConsole_Toggled(object sender, EventArgs args)
  1292. {
  1293. ConfigurationState.Instance.Ui.ShowConsole.Value = _showConsole.Active;
  1294. SaveConfig();
  1295. }
  1296. private void OptionMenu_StateChanged(object o, StateChangedArgs args)
  1297. {
  1298. _manageUserProfiles.Sensitive = _emulationContext == null;
  1299. }
  1300. private void Settings_Pressed(object sender, EventArgs args)
  1301. {
  1302. SettingsWindow settingsWindow = new SettingsWindow(this, _virtualFileSystem, _contentManager);
  1303. settingsWindow.SetSizeRequest((int)(settingsWindow.DefaultWidth * Program.WindowScaleFactor), (int)(settingsWindow.DefaultHeight * Program.WindowScaleFactor));
  1304. settingsWindow.Show();
  1305. }
  1306. private void HideUi_Pressed(object sender, EventArgs args)
  1307. {
  1308. ToggleExtraWidgets(false);
  1309. }
  1310. private void ManageCheats_Pressed(object sender, EventArgs args)
  1311. {
  1312. var window = new CheatWindow(_virtualFileSystem, _emulationContext.Application.TitleId, _emulationContext.Application.TitleName);
  1313. window.Destroyed += CheatWindow_Destroyed;
  1314. window.Show();
  1315. }
  1316. private void CheatWindow_Destroyed(object sender, EventArgs e)
  1317. {
  1318. _emulationContext.EnableCheats();
  1319. (sender as CheatWindow).Destroyed -= CheatWindow_Destroyed;
  1320. }
  1321. private void ManageUserProfiles_Pressed(object sender, EventArgs args)
  1322. {
  1323. UserProfilesManagerWindow userProfilesManagerWindow = new UserProfilesManagerWindow(_accountManager, _contentManager, _virtualFileSystem);
  1324. userProfilesManagerWindow.SetSizeRequest((int)(userProfilesManagerWindow.DefaultWidth * Program.WindowScaleFactor), (int)(userProfilesManagerWindow.DefaultHeight * Program.WindowScaleFactor));
  1325. userProfilesManagerWindow.Show();
  1326. }
  1327. private void Simulate_WakeUp_Message_Pressed(object sender, EventArgs args)
  1328. {
  1329. if (_emulationContext != null)
  1330. {
  1331. _emulationContext.System.SimulateWakeUpMessage();
  1332. }
  1333. }
  1334. private void ActionMenu_StateChanged(object o, StateChangedArgs args)
  1335. {
  1336. _scanAmiibo.Sensitive = _emulationContext != null && _emulationContext.System.SearchingForAmiibo(out int _);
  1337. _takeScreenshot.Sensitive = _emulationContext != null;
  1338. }
  1339. private void Scan_Amiibo(object sender, EventArgs args)
  1340. {
  1341. if (_emulationContext.System.SearchingForAmiibo(out int deviceId))
  1342. {
  1343. AmiiboWindow amiiboWindow = new AmiiboWindow
  1344. {
  1345. LastScannedAmiiboShowAll = _lastScannedAmiiboShowAll,
  1346. LastScannedAmiiboId = _lastScannedAmiiboId,
  1347. DeviceId = deviceId,
  1348. TitleId = _emulationContext.Application.TitleIdText.ToUpper()
  1349. };
  1350. amiiboWindow.DeleteEvent += AmiiboWindow_DeleteEvent;
  1351. amiiboWindow.Show();
  1352. }
  1353. else
  1354. {
  1355. 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.");
  1356. }
  1357. }
  1358. private void Take_Screenshot(object sender, EventArgs args)
  1359. {
  1360. if (_emulationContext != null && RendererWidget != null)
  1361. {
  1362. RendererWidget.ScreenshotRequested = true;
  1363. }
  1364. }
  1365. private void AmiiboWindow_DeleteEvent(object sender, DeleteEventArgs args)
  1366. {
  1367. if (((AmiiboWindow)sender).AmiiboId != "" && ((AmiiboWindow)sender).Response == ResponseType.Ok)
  1368. {
  1369. _lastScannedAmiiboId = ((AmiiboWindow)sender).AmiiboId;
  1370. _lastScannedAmiiboShowAll = ((AmiiboWindow)sender).LastScannedAmiiboShowAll;
  1371. _emulationContext.System.ScanAmiibo(((AmiiboWindow)sender).DeviceId, ((AmiiboWindow)sender).AmiiboId, ((AmiiboWindow)sender).UseRandomUuid);
  1372. }
  1373. }
  1374. private void Update_Pressed(object sender, EventArgs args)
  1375. {
  1376. if (Updater.CanUpdate(true))
  1377. {
  1378. Updater.BeginParse(this, true).ContinueWith(task =>
  1379. {
  1380. Logger.Error?.Print(LogClass.Application, $"Updater error: {task.Exception}");
  1381. }, TaskContinuationOptions.OnlyOnFaulted);
  1382. }
  1383. }
  1384. private void About_Pressed(object sender, EventArgs args)
  1385. {
  1386. AboutWindow aboutWindow = new AboutWindow();
  1387. aboutWindow.SetSizeRequest((int)(aboutWindow.DefaultWidth * Program.WindowScaleFactor), (int)(aboutWindow.DefaultHeight * Program.WindowScaleFactor));
  1388. aboutWindow.Show();
  1389. }
  1390. private void Fav_Toggled(object sender, EventArgs args)
  1391. {
  1392. ConfigurationState.Instance.Ui.GuiColumns.FavColumn.Value = _favToggle.Active;
  1393. SaveConfig();
  1394. UpdateColumns();
  1395. }
  1396. private void Icon_Toggled(object sender, EventArgs args)
  1397. {
  1398. ConfigurationState.Instance.Ui.GuiColumns.IconColumn.Value = _iconToggle.Active;
  1399. SaveConfig();
  1400. UpdateColumns();
  1401. }
  1402. private void App_Toggled(object sender, EventArgs args)
  1403. {
  1404. ConfigurationState.Instance.Ui.GuiColumns.AppColumn.Value = _appToggle.Active;
  1405. SaveConfig();
  1406. UpdateColumns();
  1407. }
  1408. private void Developer_Toggled(object sender, EventArgs args)
  1409. {
  1410. ConfigurationState.Instance.Ui.GuiColumns.DevColumn.Value = _developerToggle.Active;
  1411. SaveConfig();
  1412. UpdateColumns();
  1413. }
  1414. private void Version_Toggled(object sender, EventArgs args)
  1415. {
  1416. ConfigurationState.Instance.Ui.GuiColumns.VersionColumn.Value = _versionToggle.Active;
  1417. SaveConfig();
  1418. UpdateColumns();
  1419. }
  1420. private void TimePlayed_Toggled(object sender, EventArgs args)
  1421. {
  1422. ConfigurationState.Instance.Ui.GuiColumns.TimePlayedColumn.Value = _timePlayedToggle.Active;
  1423. SaveConfig();
  1424. UpdateColumns();
  1425. }
  1426. private void LastPlayed_Toggled(object sender, EventArgs args)
  1427. {
  1428. ConfigurationState.Instance.Ui.GuiColumns.LastPlayedColumn.Value = _lastPlayedToggle.Active;
  1429. SaveConfig();
  1430. UpdateColumns();
  1431. }
  1432. private void FileExt_Toggled(object sender, EventArgs args)
  1433. {
  1434. ConfigurationState.Instance.Ui.GuiColumns.FileExtColumn.Value = _fileExtToggle.Active;
  1435. SaveConfig();
  1436. UpdateColumns();
  1437. }
  1438. private void FileSize_Toggled(object sender, EventArgs args)
  1439. {
  1440. ConfigurationState.Instance.Ui.GuiColumns.FileSizeColumn.Value = _fileSizeToggle.Active;
  1441. SaveConfig();
  1442. UpdateColumns();
  1443. }
  1444. private void Path_Toggled(object sender, EventArgs args)
  1445. {
  1446. ConfigurationState.Instance.Ui.GuiColumns.PathColumn.Value = _pathToggle.Active;
  1447. SaveConfig();
  1448. UpdateColumns();
  1449. }
  1450. private void RefreshList_Pressed(object sender, ButtonReleaseEventArgs args)
  1451. {
  1452. UpdateGameTable();
  1453. }
  1454. }
  1455. }