MainWindow.cs 69 KB

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