MainWindow.cs 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306
  1. using ARMeilleure.Translation.PTC;
  2. using Gtk;
  3. using LibHac.Common;
  4. using LibHac.Ns;
  5. using Ryujinx.Audio;
  6. using Ryujinx.Common.Logging;
  7. using Ryujinx.Configuration;
  8. using Ryujinx.Debugger.Profiler;
  9. using Ryujinx.Graphics.GAL;
  10. using Ryujinx.Graphics.OpenGL;
  11. using Ryujinx.HLE.FileSystem;
  12. using Ryujinx.HLE.FileSystem.Content;
  13. using Ryujinx.HLE.HOS.Services.Hid;
  14. using System;
  15. using System.Diagnostics;
  16. using System.IO;
  17. using System.Linq;
  18. using System.Reflection;
  19. using System.Threading;
  20. using System.Threading.Tasks;
  21. using GUI = Gtk.Builder.ObjectAttribute;
  22. namespace Ryujinx.Ui
  23. {
  24. public class MainWindow : Window
  25. {
  26. private static VirtualFileSystem _virtualFileSystem;
  27. private static ContentManager _contentManager;
  28. private static HLE.Switch _emulationContext;
  29. private static GlRenderer _glWidget;
  30. private static AutoResetEvent _deviceExitStatus = new AutoResetEvent(false);
  31. private static ListStore _tableStore;
  32. private static bool _updatingGameTable;
  33. private static bool _gameLoaded;
  34. private static bool _ending;
  35. #pragma warning disable CS0169
  36. private static bool _debuggerOpened;
  37. private static Debugger.Debugger _debugger;
  38. #pragma warning restore CS0169
  39. #pragma warning disable CS0169, CS0649, IDE0044
  40. [GUI] MenuBar _menuBar;
  41. [GUI] Box _footerBox;
  42. [GUI] Box _statusBar;
  43. [GUI] MenuItem _stopEmulation;
  44. [GUI] MenuItem _fullScreen;
  45. [GUI] CheckMenuItem _favToggle;
  46. [GUI] MenuItem _firmwareInstallDirectory;
  47. [GUI] MenuItem _firmwareInstallFile;
  48. [GUI] Label _hostStatus;
  49. [GUI] MenuItem _openDebugger;
  50. [GUI] CheckMenuItem _iconToggle;
  51. [GUI] CheckMenuItem _developerToggle;
  52. [GUI] CheckMenuItem _appToggle;
  53. [GUI] CheckMenuItem _timePlayedToggle;
  54. [GUI] CheckMenuItem _versionToggle;
  55. [GUI] CheckMenuItem _lastPlayedToggle;
  56. [GUI] CheckMenuItem _fileExtToggle;
  57. [GUI] CheckMenuItem _pathToggle;
  58. [GUI] CheckMenuItem _fileSizeToggle;
  59. [GUI] Label _dockedMode;
  60. [GUI] Label _gameStatus;
  61. [GUI] TreeView _gameTable;
  62. [GUI] TreeSelection _gameTableSelection;
  63. [GUI] ScrolledWindow _gameTableWindow;
  64. [GUI] Label _gpuName;
  65. [GUI] Label _progressLabel;
  66. [GUI] Label _firmwareVersionLabel;
  67. [GUI] LevelBar _progressBar;
  68. [GUI] Box _viewBox;
  69. [GUI] Label _vSyncStatus;
  70. [GUI] Box _listStatusBox;
  71. #pragma warning restore CS0649, IDE0044, CS0169
  72. public MainWindow() : this(new Builder("Ryujinx.Ui.MainWindow.glade")) { }
  73. private MainWindow(Builder builder) : base(builder.GetObject("_mainWin").Handle)
  74. {
  75. builder.Autoconnect(this);
  76. int monitorWidth = Display.PrimaryMonitor.Geometry.Width * Display.PrimaryMonitor.ScaleFactor;
  77. int monitorHeight = Display.PrimaryMonitor.Geometry.Height * Display.PrimaryMonitor.ScaleFactor;
  78. this.DefaultWidth = monitorWidth < 1280 ? monitorWidth : 1280;
  79. this.DefaultHeight = monitorHeight < 760 ? monitorHeight : 760;
  80. this.DeleteEvent += Window_Close;
  81. _fullScreen.Activated += FullScreen_Toggled;
  82. this.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.Icon.png");
  83. this.Title = $"Ryujinx {Program.Version}";
  84. ApplicationLibrary.ApplicationAdded += Application_Added;
  85. ApplicationLibrary.ApplicationCountUpdated += ApplicationCount_Updated;
  86. GlRenderer.StatusUpdatedEvent += Update_StatusBar;
  87. _gameTable.ButtonReleaseEvent += Row_Clicked;
  88. // First we check that a migration isn't needed. (because VirtualFileSystem will create the new directory otherwise)
  89. bool continueWithStartup = Migration.PromptIfMigrationNeededForStartup(this, out bool migrationNeeded);
  90. if (!continueWithStartup)
  91. {
  92. End(null);
  93. }
  94. _virtualFileSystem = VirtualFileSystem.CreateInstance();
  95. _contentManager = new ContentManager(_virtualFileSystem);
  96. if (migrationNeeded)
  97. {
  98. bool migrationSuccessful = Migration.DoMigrationForStartup(this, _virtualFileSystem);
  99. if (!migrationSuccessful)
  100. {
  101. End(null);
  102. }
  103. }
  104. // Make sure that everything is loaded.
  105. _virtualFileSystem.Reload();
  106. ApplyTheme();
  107. _stopEmulation.Sensitive = false;
  108. if (ConfigurationState.Instance.Ui.GuiColumns.FavColumn) _favToggle.Active = true;
  109. if (ConfigurationState.Instance.Ui.GuiColumns.IconColumn) _iconToggle.Active = true;
  110. if (ConfigurationState.Instance.Ui.GuiColumns.AppColumn) _appToggle.Active = true;
  111. if (ConfigurationState.Instance.Ui.GuiColumns.DevColumn) _developerToggle.Active = true;
  112. if (ConfigurationState.Instance.Ui.GuiColumns.VersionColumn) _versionToggle.Active = true;
  113. if (ConfigurationState.Instance.Ui.GuiColumns.TimePlayedColumn) _timePlayedToggle.Active = true;
  114. if (ConfigurationState.Instance.Ui.GuiColumns.LastPlayedColumn) _lastPlayedToggle.Active = true;
  115. if (ConfigurationState.Instance.Ui.GuiColumns.FileExtColumn) _fileExtToggle.Active = true;
  116. if (ConfigurationState.Instance.Ui.GuiColumns.FileSizeColumn) _fileSizeToggle.Active = true;
  117. if (ConfigurationState.Instance.Ui.GuiColumns.PathColumn) _pathToggle.Active = true;
  118. #if USE_DEBUGGING
  119. _debugger = new Debugger.Debugger();
  120. _openDebugger.Activated += _openDebugger_Opened;
  121. #else
  122. _openDebugger.Hide();
  123. #endif
  124. _gameTable.Model = _tableStore = new ListStore(
  125. typeof(bool),
  126. typeof(Gdk.Pixbuf),
  127. typeof(string),
  128. typeof(string),
  129. typeof(string),
  130. typeof(string),
  131. typeof(string),
  132. typeof(string),
  133. typeof(string),
  134. typeof(string),
  135. typeof(BlitStruct<ApplicationControlProperty>));
  136. _tableStore.SetSortFunc(5, TimePlayedSort);
  137. _tableStore.SetSortFunc(6, LastPlayedSort);
  138. _tableStore.SetSortFunc(8, FileSizeSort);
  139. int columnId = ConfigurationState.Instance.Ui.ColumnSort.SortColumnId;
  140. bool ascending = ConfigurationState.Instance.Ui.ColumnSort.SortAscending;
  141. _tableStore.SetSortColumnId(columnId, ascending ? SortType.Ascending : SortType.Descending);
  142. _gameTable.EnableSearch = true;
  143. _gameTable.SearchColumn = 2;
  144. UpdateColumns();
  145. UpdateGameTable();
  146. ConfigurationState.Instance.Ui.GameDirs.Event += (sender, args) =>
  147. {
  148. if (args.OldValue != args.NewValue)
  149. {
  150. UpdateGameTable();
  151. }
  152. };
  153. Task.Run(RefreshFirmwareLabel);
  154. _statusBar.Hide();
  155. }
  156. #if USE_DEBUGGING
  157. private void _openDebugger_Opened(object sender, EventArgs e)
  158. {
  159. if (_debuggerOpened)
  160. {
  161. return;
  162. }
  163. Window debugWindow = new Window("Debugger");
  164. debugWindow.SetSizeRequest(1280, 640);
  165. debugWindow.Child = _debugger.Widget;
  166. debugWindow.DeleteEvent += DebugWindow_DeleteEvent;
  167. debugWindow.ShowAll();
  168. _debugger.Enable();
  169. _debuggerOpened = true;
  170. }
  171. private void DebugWindow_DeleteEvent(object o, DeleteEventArgs args)
  172. {
  173. _debuggerOpened = false;
  174. _debugger.Disable();
  175. (_debugger.Widget.Parent as Window)?.Remove(_debugger.Widget);
  176. }
  177. #endif
  178. internal static void ApplyTheme()
  179. {
  180. if (!ConfigurationState.Instance.Ui.EnableCustomTheme)
  181. {
  182. return;
  183. }
  184. if (File.Exists(ConfigurationState.Instance.Ui.CustomThemePath) && (System.IO.Path.GetExtension(ConfigurationState.Instance.Ui.CustomThemePath) == ".css"))
  185. {
  186. CssProvider cssProvider = new CssProvider();
  187. cssProvider.LoadFromPath(ConfigurationState.Instance.Ui.CustomThemePath);
  188. StyleContext.AddProviderForScreen(Gdk.Screen.Default, cssProvider, 800);
  189. }
  190. else
  191. {
  192. Logger.PrintWarning(LogClass.Application, $"The \"custom_theme_path\" section in \"Config.json\" contains an invalid path: \"{ConfigurationState.Instance.Ui.CustomThemePath}\".");
  193. }
  194. }
  195. private void UpdateColumns()
  196. {
  197. foreach (TreeViewColumn column in _gameTable.Columns)
  198. {
  199. _gameTable.RemoveColumn(column);
  200. }
  201. CellRendererToggle favToggle = new CellRendererToggle();
  202. favToggle.Toggled += FavToggle_Toggled;
  203. if (ConfigurationState.Instance.Ui.GuiColumns.FavColumn) _gameTable.AppendColumn("Fav", favToggle, "active", 0);
  204. if (ConfigurationState.Instance.Ui.GuiColumns.IconColumn) _gameTable.AppendColumn("Icon", new CellRendererPixbuf(), "pixbuf", 1);
  205. if (ConfigurationState.Instance.Ui.GuiColumns.AppColumn) _gameTable.AppendColumn("Application", new CellRendererText(), "text", 2);
  206. if (ConfigurationState.Instance.Ui.GuiColumns.DevColumn) _gameTable.AppendColumn("Developer", new CellRendererText(), "text", 3);
  207. if (ConfigurationState.Instance.Ui.GuiColumns.VersionColumn) _gameTable.AppendColumn("Version", new CellRendererText(), "text", 4);
  208. if (ConfigurationState.Instance.Ui.GuiColumns.TimePlayedColumn) _gameTable.AppendColumn("Time Played", new CellRendererText(), "text", 5);
  209. if (ConfigurationState.Instance.Ui.GuiColumns.LastPlayedColumn) _gameTable.AppendColumn("Last Played", new CellRendererText(), "text", 6);
  210. if (ConfigurationState.Instance.Ui.GuiColumns.FileExtColumn) _gameTable.AppendColumn("File Ext", new CellRendererText(), "text", 7);
  211. if (ConfigurationState.Instance.Ui.GuiColumns.FileSizeColumn) _gameTable.AppendColumn("File Size", new CellRendererText(), "text", 8);
  212. if (ConfigurationState.Instance.Ui.GuiColumns.PathColumn) _gameTable.AppendColumn("Path", new CellRendererText(), "text", 9);
  213. foreach (TreeViewColumn column in _gameTable.Columns)
  214. {
  215. switch (column.Title)
  216. {
  217. case "Fav":
  218. column.SortColumnId = 0;
  219. column.Clicked += Column_Clicked;
  220. break;
  221. case "Application":
  222. column.SortColumnId = 2;
  223. column.Clicked += Column_Clicked;
  224. break;
  225. case "Developer":
  226. column.SortColumnId = 3;
  227. column.Clicked += Column_Clicked;
  228. break;
  229. case "Version":
  230. column.SortColumnId = 4;
  231. column.Clicked += Column_Clicked;
  232. break;
  233. case "Time Played":
  234. column.SortColumnId = 5;
  235. column.Clicked += Column_Clicked;
  236. break;
  237. case "Last Played":
  238. column.SortColumnId = 6;
  239. column.Clicked += Column_Clicked;
  240. break;
  241. case "File Ext":
  242. column.SortColumnId = 7;
  243. column.Clicked += Column_Clicked;
  244. break;
  245. case "File Size":
  246. column.SortColumnId = 8;
  247. column.Clicked += Column_Clicked;
  248. break;
  249. case "Path":
  250. column.SortColumnId = 9;
  251. column.Clicked += Column_Clicked;
  252. break;
  253. }
  254. }
  255. }
  256. private HLE.Switch InitializeSwitchInstance()
  257. {
  258. _virtualFileSystem.Reload();
  259. HLE.Switch instance = new HLE.Switch(_virtualFileSystem, _contentManager, InitializeRenderer(), InitializeAudioEngine());
  260. instance.Initialize();
  261. return instance;
  262. }
  263. internal static void UpdateGameTable()
  264. {
  265. if (_updatingGameTable || _gameLoaded)
  266. {
  267. return;
  268. }
  269. _updatingGameTable = true;
  270. _tableStore.Clear();
  271. Thread applicationLibraryThread = new Thread(() =>
  272. {
  273. ApplicationLibrary.LoadApplications(ConfigurationState.Instance.Ui.GameDirs,
  274. _virtualFileSystem, ConfigurationState.Instance.System.Language);
  275. _updatingGameTable = false;
  276. });
  277. applicationLibraryThread.Name = "GUI.ApplicationLibraryThread";
  278. applicationLibraryThread.IsBackground = true;
  279. applicationLibraryThread.Start();
  280. }
  281. internal void LoadApplication(string path)
  282. {
  283. if (_gameLoaded)
  284. {
  285. GtkDialog.CreateInfoDialog("Ryujinx", "A game has already been loaded", "Please close it first and try again.");
  286. }
  287. else
  288. {
  289. if (ConfigurationState.Instance.Logger.EnableDebug.Value)
  290. {
  291. MessageDialog debugWarningDialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo, null)
  292. {
  293. Title = "Ryujinx - Warning",
  294. Text = "You have debug logging enabled, which is designed to be used by developers only.",
  295. SecondaryText = "For optimal performance, it's recommended to disable debug logging. Would you like to disable debug logging now?"
  296. };
  297. if (debugWarningDialog.Run() == (int)ResponseType.Yes)
  298. {
  299. ConfigurationState.Instance.Logger.EnableDebug.Value = false;
  300. SaveConfig();
  301. }
  302. debugWarningDialog.Dispose();
  303. }
  304. if (!string.IsNullOrWhiteSpace(ConfigurationState.Instance.Graphics.ShadersDumpPath.Value))
  305. {
  306. MessageDialog shadersDumpWarningDialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo, null)
  307. {
  308. Title = "Ryujinx - Warning",
  309. Text = "You have shader dumping enabled, which is designed to be used by developers only.",
  310. SecondaryText = "For optimal performance, it's recommended to disable shader dumping. Would you like to disable shader dumping now?"
  311. };
  312. if (shadersDumpWarningDialog.Run() == (int)ResponseType.Yes)
  313. {
  314. ConfigurationState.Instance.Graphics.ShadersDumpPath.Value = "";
  315. SaveConfig();
  316. }
  317. shadersDumpWarningDialog.Dispose();
  318. }
  319. Logger.RestartTime();
  320. HLE.Switch device = InitializeSwitchInstance();
  321. UpdateGraphicsConfig();
  322. Logger.PrintInfo(LogClass.Application, $"Using Firmware Version: {_contentManager.GetCurrentFirmwareVersion()?.VersionString}");
  323. if (Directory.Exists(path))
  324. {
  325. string[] romFsFiles = Directory.GetFiles(path, "*.istorage");
  326. if (romFsFiles.Length == 0)
  327. {
  328. romFsFiles = Directory.GetFiles(path, "*.romfs");
  329. }
  330. if (romFsFiles.Length > 0)
  331. {
  332. Logger.PrintInfo(LogClass.Application, "Loading as cart with RomFS.");
  333. device.LoadCart(path, romFsFiles[0]);
  334. }
  335. else
  336. {
  337. Logger.PrintInfo(LogClass.Application, "Loading as cart WITHOUT RomFS.");
  338. device.LoadCart(path);
  339. }
  340. }
  341. else if (File.Exists(path))
  342. {
  343. switch (System.IO.Path.GetExtension(path).ToLowerInvariant())
  344. {
  345. case ".xci":
  346. Logger.PrintInfo(LogClass.Application, "Loading as XCI.");
  347. device.LoadXci(path);
  348. break;
  349. case ".nca":
  350. Logger.PrintInfo(LogClass.Application, "Loading as NCA.");
  351. device.LoadNca(path);
  352. break;
  353. case ".nsp":
  354. case ".pfs0":
  355. Logger.PrintInfo(LogClass.Application, "Loading as NSP.");
  356. device.LoadNsp(path);
  357. break;
  358. default:
  359. Logger.PrintInfo(LogClass.Application, "Loading as homebrew.");
  360. try
  361. {
  362. device.LoadProgram(path);
  363. }
  364. catch (ArgumentOutOfRangeException)
  365. {
  366. Logger.PrintError(LogClass.Application, "The file which you have specified is unsupported by Ryujinx.");
  367. }
  368. break;
  369. }
  370. }
  371. else
  372. {
  373. Logger.PrintWarning(LogClass.Application, "Please specify a valid XCI/NCA/NSP/PFS0/NRO file.");
  374. device.Dispose();
  375. return;
  376. }
  377. _emulationContext = device;
  378. _deviceExitStatus.Reset();
  379. #if MACOS_BUILD
  380. CreateGameWindow(device);
  381. #else
  382. Thread windowThread = new Thread(() =>
  383. {
  384. CreateGameWindow(device);
  385. })
  386. {
  387. Name = "GUI.WindowThread"
  388. };
  389. windowThread.Start();
  390. #endif
  391. _gameLoaded = true;
  392. _stopEmulation.Sensitive = true;
  393. _firmwareInstallFile.Sensitive = false;
  394. _firmwareInstallDirectory.Sensitive = false;
  395. DiscordIntegrationModule.SwitchToPlayingState(device.Application.TitleIdText, device.Application.TitleName);
  396. ApplicationLibrary.LoadAndSaveMetaData(device.Application.TitleIdText, appMetadata =>
  397. {
  398. appMetadata.LastPlayed = DateTime.UtcNow.ToString();
  399. });
  400. }
  401. }
  402. private void CreateGameWindow(HLE.Switch device)
  403. {
  404. device.Hid.Npads.AddControllers(ConfigurationState.Instance.Hid.InputConfig.Value.Select(inputConfig =>
  405. new HLE.HOS.Services.Hid.ControllerConfig
  406. {
  407. Player = (PlayerIndex)inputConfig.PlayerIndex,
  408. Type = (ControllerType)inputConfig.ControllerType
  409. }
  410. ).ToArray());
  411. _glWidget = new GlRenderer(_emulationContext);
  412. Application.Invoke(delegate
  413. {
  414. _viewBox.Remove(_gameTableWindow);
  415. _glWidget.Expand = true;
  416. _viewBox.Child = _glWidget;
  417. _glWidget.ShowAll();
  418. EditFooterForGameRender();
  419. });
  420. _glWidget.WaitEvent.WaitOne();
  421. _glWidget.Start();
  422. Ptc.Close();
  423. PtcProfiler.Stop();
  424. device.Dispose();
  425. _deviceExitStatus.Set();
  426. // NOTE: Everything that is here will not be executed when you close the UI.
  427. Application.Invoke(delegate
  428. {
  429. _viewBox.Remove(_glWidget);
  430. _glWidget.Exit();
  431. if(_glWidget.Window != this.Window && _glWidget.Window != null)
  432. {
  433. _glWidget.Window.Dispose();
  434. }
  435. _glWidget.Dispose();
  436. _viewBox.Add(_gameTableWindow);
  437. _gameTableWindow.Expand = true;
  438. this.Window.Title = $"Ryujinx {Program.Version}";
  439. _emulationContext = null;
  440. _gameLoaded = false;
  441. _glWidget = null;
  442. DiscordIntegrationModule.SwitchToMainMenu();
  443. RecreateFooterForMenu();
  444. UpdateColumns();
  445. UpdateGameTable();
  446. Task.Run(RefreshFirmwareLabel);
  447. _stopEmulation.Sensitive = false;
  448. _firmwareInstallFile.Sensitive = true;
  449. _firmwareInstallDirectory.Sensitive = true;
  450. });
  451. }
  452. private void RecreateFooterForMenu()
  453. {
  454. _listStatusBox.Show();
  455. _statusBar.Hide();
  456. }
  457. private void EditFooterForGameRender()
  458. {
  459. _listStatusBox.Hide();
  460. _statusBar.Show();
  461. }
  462. public void ToggleExtraWidgets(bool show)
  463. {
  464. if (_glWidget != null)
  465. {
  466. if (show)
  467. {
  468. _menuBar.ShowAll();
  469. _footerBox.Show();
  470. _statusBar.Show();
  471. }
  472. else
  473. {
  474. _menuBar.Hide();
  475. _footerBox.Hide();
  476. }
  477. }
  478. bool fullScreenToggled = this.Window.State.HasFlag(Gdk.WindowState.Fullscreen);
  479. _fullScreen.Label = fullScreenToggled ? "Exit Fullscreen" : "Enter Fullscreen";
  480. }
  481. private static void UpdateGameMetadata(string titleId)
  482. {
  483. if (_gameLoaded)
  484. {
  485. ApplicationLibrary.LoadAndSaveMetaData(titleId, appMetadata =>
  486. {
  487. DateTime lastPlayedDateTime = DateTime.Parse(appMetadata.LastPlayed);
  488. double sessionTimePlayed = DateTime.UtcNow.Subtract(lastPlayedDateTime).TotalSeconds;
  489. appMetadata.TimePlayed += Math.Round(sessionTimePlayed, MidpointRounding.AwayFromZero);
  490. });
  491. }
  492. }
  493. public static void UpdateGraphicsConfig()
  494. {
  495. int resScale = ConfigurationState.Instance.Graphics.ResScale;
  496. float resScaleCustom = ConfigurationState.Instance.Graphics.ResScaleCustom;
  497. Graphics.Gpu.GraphicsConfig.ResScale = (resScale == -1) ? resScaleCustom : resScale;
  498. Graphics.Gpu.GraphicsConfig.MaxAnisotropy = ConfigurationState.Instance.Graphics.MaxAnisotropy;
  499. Graphics.Gpu.GraphicsConfig.ShadersDumpPath = ConfigurationState.Instance.Graphics.ShadersDumpPath;
  500. }
  501. public static void SaveConfig()
  502. {
  503. ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
  504. }
  505. private void End(HLE.Switch device)
  506. {
  507. #if USE_DEBUGGING
  508. _debugger.Dispose();
  509. #endif
  510. if (_ending)
  511. {
  512. return;
  513. }
  514. _ending = true;
  515. if (device != null)
  516. {
  517. UpdateGameMetadata(device.Application.TitleIdText);
  518. if (_glWidget != null)
  519. {
  520. // We tell the widget that we are exiting
  521. _glWidget.Exit();
  522. // Wait for the other thread to dispose the HLE context before exiting.
  523. _deviceExitStatus.WaitOne();
  524. }
  525. }
  526. Dispose();
  527. Profile.FinishProfiling();
  528. DiscordIntegrationModule.Exit();
  529. Logger.Shutdown();
  530. Ptc.Dispose();
  531. PtcProfiler.Dispose();
  532. Application.Quit();
  533. }
  534. private static IRenderer InitializeRenderer()
  535. {
  536. return new Renderer();
  537. }
  538. private static IAalOutput InitializeAudioEngine()
  539. {
  540. if (ConfigurationState.Instance.System.AudioBackend.Value == AudioBackend.SoundIo)
  541. {
  542. if (SoundIoAudioOut.IsSupported)
  543. {
  544. return new SoundIoAudioOut();
  545. }
  546. else
  547. {
  548. Logger.PrintWarning(LogClass.Audio, "SoundIO is not supported, falling back to dummy audio out.");
  549. }
  550. }
  551. else if (ConfigurationState.Instance.System.AudioBackend.Value == AudioBackend.OpenAl)
  552. {
  553. if (OpenALAudioOut.IsSupported)
  554. {
  555. return new OpenALAudioOut();
  556. }
  557. else
  558. {
  559. Logger.PrintWarning(LogClass.Audio, "OpenAL is not supported, trying to fall back to SoundIO.");
  560. if (SoundIoAudioOut.IsSupported)
  561. {
  562. Logger.PrintWarning(LogClass.Audio, "Found SoundIO, changing configuration.");
  563. ConfigurationState.Instance.System.AudioBackend.Value = AudioBackend.SoundIo;
  564. SaveConfig();
  565. return new SoundIoAudioOut();
  566. }
  567. else
  568. {
  569. Logger.PrintWarning(LogClass.Audio, "SoundIO is not supported, falling back to dummy audio out.");
  570. }
  571. }
  572. }
  573. return new DummyAudioOut();
  574. }
  575. //Events
  576. private void Application_Added(object sender, ApplicationAddedEventArgs args)
  577. {
  578. Application.Invoke(delegate
  579. {
  580. _tableStore.AppendValues(
  581. args.AppData.Favorite,
  582. new Gdk.Pixbuf(args.AppData.Icon, 75, 75),
  583. $"{args.AppData.TitleName}\n{args.AppData.TitleId.ToUpper()}",
  584. args.AppData.Developer,
  585. args.AppData.Version,
  586. args.AppData.TimePlayed,
  587. args.AppData.LastPlayed,
  588. args.AppData.FileExtension,
  589. args.AppData.FileSize,
  590. args.AppData.Path,
  591. args.AppData.ControlHolder);
  592. });
  593. }
  594. private void ApplicationCount_Updated(object sender, ApplicationCountUpdatedEventArgs args)
  595. {
  596. Application.Invoke(delegate
  597. {
  598. _progressLabel.Text = $"{args.NumAppsLoaded}/{args.NumAppsFound} Games Loaded";
  599. float barValue = 0;
  600. if (args.NumAppsFound != 0)
  601. {
  602. barValue = (float)args.NumAppsLoaded / args.NumAppsFound;
  603. }
  604. _progressBar.Value = barValue;
  605. if (args.NumAppsLoaded == args.NumAppsFound) // Reset the vertical scrollbar to the top when titles finish loading
  606. {
  607. _gameTableWindow.Vadjustment.Value = 0;
  608. }
  609. });
  610. }
  611. private void Update_StatusBar(object sender, StatusUpdatedEventArgs args)
  612. {
  613. Application.Invoke(delegate
  614. {
  615. _hostStatus.Text = args.HostStatus;
  616. _gameStatus.Text = args.GameStatus;
  617. _gpuName.Text = args.GpuName;
  618. _dockedMode.Text = args.DockedMode;
  619. if (args.VSyncEnabled)
  620. {
  621. _vSyncStatus.Attributes = new Pango.AttrList();
  622. _vSyncStatus.Attributes.Insert(new Pango.AttrForeground(11822, 60138, 51657));
  623. }
  624. else
  625. {
  626. _vSyncStatus.Attributes = new Pango.AttrList();
  627. _vSyncStatus.Attributes.Insert(new Pango.AttrForeground(ushort.MaxValue, 17733, 21588));
  628. }
  629. });
  630. }
  631. private void FavToggle_Toggled(object sender, ToggledArgs args)
  632. {
  633. _tableStore.GetIter(out TreeIter treeIter, new TreePath(args.Path));
  634. string titleId = _tableStore.GetValue(treeIter, 2).ToString().Split("\n")[1].ToLower();
  635. bool newToggleValue = !(bool)_tableStore.GetValue(treeIter, 0);
  636. _tableStore.SetValue(treeIter, 0, newToggleValue);
  637. ApplicationLibrary.LoadAndSaveMetaData(titleId, appMetadata =>
  638. {
  639. appMetadata.Favorite = newToggleValue;
  640. });
  641. }
  642. private void Column_Clicked(object sender, EventArgs args)
  643. {
  644. TreeViewColumn column = (TreeViewColumn)sender;
  645. ConfigurationState.Instance.Ui.ColumnSort.SortColumnId.Value = column.SortColumnId;
  646. ConfigurationState.Instance.Ui.ColumnSort.SortAscending.Value = column.SortOrder == SortType.Ascending;
  647. SaveConfig();
  648. }
  649. private void Row_Activated(object sender, RowActivatedArgs args)
  650. {
  651. _gameTableSelection.GetSelected(out TreeIter treeIter);
  652. string path = (string)_tableStore.GetValue(treeIter, 9);
  653. LoadApplication(path);
  654. }
  655. private void Row_Clicked(object sender, ButtonReleaseEventArgs args)
  656. {
  657. if (args.Event.Button != 3) return;
  658. _gameTableSelection.GetSelected(out TreeIter treeIter);
  659. if (treeIter.UserData == IntPtr.Zero) return;
  660. BlitStruct<ApplicationControlProperty> controlData = (BlitStruct<ApplicationControlProperty>)_tableStore.GetValue(treeIter, 10);
  661. GameTableContextMenu contextMenu = new GameTableContextMenu(_tableStore, controlData, treeIter, _virtualFileSystem);
  662. contextMenu.ShowAll();
  663. contextMenu.PopupAtPointer(null);
  664. }
  665. private void Load_Application_File(object sender, EventArgs args)
  666. {
  667. FileChooserDialog fileChooser = new FileChooserDialog("Choose the file to open", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
  668. fileChooser.Filter = new FileFilter();
  669. fileChooser.Filter.AddPattern("*.nsp" );
  670. fileChooser.Filter.AddPattern("*.pfs0");
  671. fileChooser.Filter.AddPattern("*.xci" );
  672. fileChooser.Filter.AddPattern("*.nca" );
  673. fileChooser.Filter.AddPattern("*.nro" );
  674. fileChooser.Filter.AddPattern("*.nso" );
  675. if (fileChooser.Run() == (int)ResponseType.Accept)
  676. {
  677. LoadApplication(fileChooser.Filename);
  678. }
  679. fileChooser.Dispose();
  680. }
  681. private void Load_Application_Folder(object sender, EventArgs args)
  682. {
  683. FileChooserDialog fileChooser = new FileChooserDialog("Choose the folder to open", this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
  684. if (fileChooser.Run() == (int)ResponseType.Accept)
  685. {
  686. LoadApplication(fileChooser.Filename);
  687. }
  688. fileChooser.Dispose();
  689. }
  690. private void Open_Ryu_Folder(object sender, EventArgs args)
  691. {
  692. Process.Start(new ProcessStartInfo()
  693. {
  694. FileName = _virtualFileSystem.GetBasePath(),
  695. UseShellExecute = true,
  696. Verb = "open"
  697. });
  698. }
  699. private void Exit_Pressed(object sender, EventArgs args)
  700. {
  701. End(_emulationContext);
  702. }
  703. private void Window_Close(object sender, DeleteEventArgs args)
  704. {
  705. End(_emulationContext);
  706. }
  707. private void StopEmulation_Pressed(object sender, EventArgs args)
  708. {
  709. _glWidget?.Exit();
  710. }
  711. private void Installer_File_Pressed(object o, EventArgs args)
  712. {
  713. FileChooserDialog fileChooser = new FileChooserDialog("Choose the firmware file to open",
  714. this,
  715. FileChooserAction.Open,
  716. "Cancel",
  717. ResponseType.Cancel,
  718. "Open",
  719. ResponseType.Accept);
  720. fileChooser.Filter = new FileFilter();
  721. fileChooser.Filter.AddPattern("*.zip");
  722. fileChooser.Filter.AddPattern("*.xci");
  723. HandleInstallerDialog(fileChooser);
  724. }
  725. private void Installer_Directory_Pressed(object o, EventArgs args)
  726. {
  727. FileChooserDialog directoryChooser = new FileChooserDialog("Choose the firmware directory to open",
  728. this,
  729. FileChooserAction.SelectFolder,
  730. "Cancel",
  731. ResponseType.Cancel,
  732. "Open",
  733. ResponseType.Accept);
  734. HandleInstallerDialog(directoryChooser);
  735. }
  736. private void RefreshFirmwareLabel()
  737. {
  738. SystemVersion currentFirmware = _contentManager.GetCurrentFirmwareVersion();
  739. GLib.Idle.Add(new GLib.IdleHandler(() =>
  740. {
  741. _firmwareVersionLabel.Text = currentFirmware != null ? currentFirmware.VersionString : "0.0.0";
  742. return false;
  743. }));
  744. }
  745. private void HandleInstallerDialog(FileChooserDialog fileChooser)
  746. {
  747. if (fileChooser.Run() == (int)ResponseType.Accept)
  748. {
  749. MessageDialog dialog = null;
  750. try
  751. {
  752. string filename = fileChooser.Filename;
  753. fileChooser.Dispose();
  754. SystemVersion firmwareVersion = _contentManager.VerifyFirmwarePackage(filename);
  755. if (firmwareVersion == null)
  756. {
  757. dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, false, "");
  758. dialog.Text = "Firmware not found.";
  759. dialog.SecondaryText = $"A valid system firmware was not found in {filename}.";
  760. Logger.PrintError(LogClass.Application, $"A valid system firmware was not found in {filename}.");
  761. dialog.Run();
  762. dialog.Hide();
  763. dialog.Dispose();
  764. return;
  765. }
  766. SystemVersion currentVersion = _contentManager.GetCurrentFirmwareVersion();
  767. string dialogMessage = $"System version {firmwareVersion.VersionString} will be installed.";
  768. if (currentVersion != null)
  769. {
  770. dialogMessage += $"This will replace the current system version {currentVersion.VersionString}. ";
  771. }
  772. dialogMessage += "Do you want to continue?";
  773. dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, false, "");
  774. dialog.Text = $"Install Firmware {firmwareVersion.VersionString}";
  775. dialog.SecondaryText = dialogMessage;
  776. int response = dialog.Run();
  777. dialog.Dispose();
  778. dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Info, ButtonsType.None, false, "");
  779. dialog.Text = $"Install Firmware {firmwareVersion.VersionString}";
  780. dialog.SecondaryText = "Installing firmware...";
  781. if (response == (int)ResponseType.Yes)
  782. {
  783. Logger.PrintInfo(LogClass.Application, $"Installing firmware {firmwareVersion.VersionString}");
  784. Thread thread = new Thread(() =>
  785. {
  786. GLib.Idle.Add(new GLib.IdleHandler(() =>
  787. {
  788. dialog.Run();
  789. return false;
  790. }));
  791. try
  792. {
  793. _contentManager.InstallFirmware(filename);
  794. GLib.Idle.Add(new GLib.IdleHandler(() =>
  795. {
  796. dialog.Dispose();
  797. dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, false, "");
  798. dialog.Text = $"Install Firmware {firmwareVersion.VersionString}";
  799. dialog.SecondaryText = $"System version {firmwareVersion.VersionString} successfully installed.";
  800. Logger.PrintInfo(LogClass.Application, $"System version {firmwareVersion.VersionString} successfully installed.");
  801. dialog.Run();
  802. dialog.Dispose();
  803. return false;
  804. }));
  805. }
  806. catch (Exception ex)
  807. {
  808. GLib.Idle.Add(new GLib.IdleHandler(() =>
  809. {
  810. dialog.Dispose();
  811. dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, false, "");
  812. dialog.Text = $"Install Firmware {firmwareVersion.VersionString} Failed.";
  813. dialog.SecondaryText = $"An error occured while installing system version {firmwareVersion.VersionString}." +
  814. " Please check logs for more info.";
  815. Logger.PrintError(LogClass.Application, ex.Message);
  816. dialog.Run();
  817. dialog.Dispose();
  818. return false;
  819. }));
  820. }
  821. finally
  822. {
  823. RefreshFirmwareLabel();
  824. }
  825. });
  826. thread.Name = "GUI.FirmwareInstallerThread";
  827. thread.Start();
  828. }
  829. else
  830. {
  831. dialog.Dispose();
  832. }
  833. }
  834. catch (Exception ex)
  835. {
  836. if (dialog != null)
  837. {
  838. dialog.Dispose();
  839. }
  840. dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, false, "");
  841. dialog.Text = "Parsing Firmware Failed.";
  842. dialog.SecondaryText = "An error occured while parsing firmware. Please check the logs for more info.";
  843. Logger.PrintError(LogClass.Application, ex.Message);
  844. dialog.Run();
  845. dialog.Dispose();
  846. }
  847. }
  848. else
  849. {
  850. fileChooser.Dispose();
  851. }
  852. }
  853. private void FullScreen_Toggled(object o, EventArgs args)
  854. {
  855. bool fullScreenToggled = this.Window.State.HasFlag(Gdk.WindowState.Fullscreen);
  856. if (!fullScreenToggled)
  857. {
  858. Fullscreen();
  859. ToggleExtraWidgets(false);
  860. }
  861. else
  862. {
  863. Unfullscreen();
  864. ToggleExtraWidgets(true);
  865. }
  866. }
  867. private void Settings_Pressed(object sender, EventArgs args)
  868. {
  869. SettingsWindow settingsWin = new SettingsWindow(_virtualFileSystem, _contentManager);
  870. settingsWin.Show();
  871. }
  872. private void Update_Pressed(object sender, EventArgs args)
  873. {
  874. string ryuUpdater = System.IO.Path.Combine(_virtualFileSystem.GetBasePath(), "RyuUpdater.exe");
  875. try
  876. {
  877. Process.Start(new ProcessStartInfo(ryuUpdater, "/U") { UseShellExecute = true });
  878. }
  879. catch(System.ComponentModel.Win32Exception)
  880. {
  881. GtkDialog.CreateErrorDialog("Update canceled by user or updater was not found");
  882. }
  883. }
  884. private void About_Pressed(object sender, EventArgs args)
  885. {
  886. AboutWindow aboutWin = new AboutWindow();
  887. aboutWin.Show();
  888. }
  889. private void Fav_Toggled(object sender, EventArgs args)
  890. {
  891. ConfigurationState.Instance.Ui.GuiColumns.FavColumn.Value = _favToggle.Active;
  892. SaveConfig();
  893. UpdateColumns();
  894. }
  895. private void Icon_Toggled(object sender, EventArgs args)
  896. {
  897. ConfigurationState.Instance.Ui.GuiColumns.IconColumn.Value = _iconToggle.Active;
  898. SaveConfig();
  899. UpdateColumns();
  900. }
  901. private void Title_Toggled(object sender, EventArgs args)
  902. {
  903. ConfigurationState.Instance.Ui.GuiColumns.AppColumn.Value = _appToggle.Active;
  904. SaveConfig();
  905. UpdateColumns();
  906. }
  907. private void Developer_Toggled(object sender, EventArgs args)
  908. {
  909. ConfigurationState.Instance.Ui.GuiColumns.DevColumn.Value = _developerToggle.Active;
  910. SaveConfig();
  911. UpdateColumns();
  912. }
  913. private void Version_Toggled(object sender, EventArgs args)
  914. {
  915. ConfigurationState.Instance.Ui.GuiColumns.VersionColumn.Value = _versionToggle.Active;
  916. SaveConfig();
  917. UpdateColumns();
  918. }
  919. private void TimePlayed_Toggled(object sender, EventArgs args)
  920. {
  921. ConfigurationState.Instance.Ui.GuiColumns.TimePlayedColumn.Value = _timePlayedToggle.Active;
  922. SaveConfig();
  923. UpdateColumns();
  924. }
  925. private void LastPlayed_Toggled(object sender, EventArgs args)
  926. {
  927. ConfigurationState.Instance.Ui.GuiColumns.LastPlayedColumn.Value = _lastPlayedToggle.Active;
  928. SaveConfig();
  929. UpdateColumns();
  930. }
  931. private void FileExt_Toggled(object sender, EventArgs args)
  932. {
  933. ConfigurationState.Instance.Ui.GuiColumns.FileExtColumn.Value = _fileExtToggle.Active;
  934. SaveConfig();
  935. UpdateColumns();
  936. }
  937. private void FileSize_Toggled(object sender, EventArgs args)
  938. {
  939. ConfigurationState.Instance.Ui.GuiColumns.FileSizeColumn.Value = _fileSizeToggle.Active;
  940. SaveConfig();
  941. UpdateColumns();
  942. }
  943. private void Path_Toggled(object sender, EventArgs args)
  944. {
  945. ConfigurationState.Instance.Ui.GuiColumns.PathColumn.Value = _pathToggle.Active;
  946. SaveConfig();
  947. UpdateColumns();
  948. }
  949. private void RefreshList_Pressed(object sender, ButtonReleaseEventArgs args)
  950. {
  951. UpdateGameTable();
  952. }
  953. private static int TimePlayedSort(ITreeModel model, TreeIter a, TreeIter b)
  954. {
  955. string aValue = model.GetValue(a, 5).ToString();
  956. string bValue = model.GetValue(b, 5).ToString();
  957. if (aValue.Length > 4 && aValue.Substring(aValue.Length - 4) == "mins")
  958. {
  959. aValue = (float.Parse(aValue.Substring(0, aValue.Length - 5)) * 60).ToString();
  960. }
  961. else if (aValue.Length > 3 && aValue.Substring(aValue.Length - 3) == "hrs")
  962. {
  963. aValue = (float.Parse(aValue.Substring(0, aValue.Length - 4)) * 3600).ToString();
  964. }
  965. else if (aValue.Length > 4 && aValue.Substring(aValue.Length - 4) == "days")
  966. {
  967. aValue = (float.Parse(aValue.Substring(0, aValue.Length - 5)) * 86400).ToString();
  968. }
  969. else
  970. {
  971. aValue = aValue.Substring(0, aValue.Length - 1);
  972. }
  973. if (bValue.Length > 4 && bValue.Substring(bValue.Length - 4) == "mins")
  974. {
  975. bValue = (float.Parse(bValue.Substring(0, bValue.Length - 5)) * 60).ToString();
  976. }
  977. else if (bValue.Length > 3 && bValue.Substring(bValue.Length - 3) == "hrs")
  978. {
  979. bValue = (float.Parse(bValue.Substring(0, bValue.Length - 4)) * 3600).ToString();
  980. }
  981. else if (bValue.Length > 4 && bValue.Substring(bValue.Length - 4) == "days")
  982. {
  983. bValue = (float.Parse(bValue.Substring(0, bValue.Length - 5)) * 86400).ToString();
  984. }
  985. else
  986. {
  987. bValue = bValue.Substring(0, bValue.Length - 1);
  988. }
  989. if (float.Parse(aValue) > float.Parse(bValue))
  990. {
  991. return -1;
  992. }
  993. else if (float.Parse(bValue) > float.Parse(aValue))
  994. {
  995. return 1;
  996. }
  997. else
  998. {
  999. return 0;
  1000. }
  1001. }
  1002. private static int LastPlayedSort(ITreeModel model, TreeIter a, TreeIter b)
  1003. {
  1004. string aValue = model.GetValue(a, 6).ToString();
  1005. string bValue = model.GetValue(b, 6).ToString();
  1006. if (aValue == "Never")
  1007. {
  1008. aValue = DateTime.UnixEpoch.ToString();
  1009. }
  1010. if (bValue == "Never")
  1011. {
  1012. bValue = DateTime.UnixEpoch.ToString();
  1013. }
  1014. return DateTime.Compare(DateTime.Parse(bValue), DateTime.Parse(aValue));
  1015. }
  1016. private static int FileSizeSort(ITreeModel model, TreeIter a, TreeIter b)
  1017. {
  1018. string aValue = model.GetValue(a, 8).ToString();
  1019. string bValue = model.GetValue(b, 8).ToString();
  1020. if (aValue.Substring(aValue.Length - 2) == "GB")
  1021. {
  1022. aValue = (float.Parse(aValue[0..^2]) * 1024).ToString();
  1023. }
  1024. else
  1025. {
  1026. aValue = aValue[0..^2];
  1027. }
  1028. if (bValue.Substring(bValue.Length - 2) == "GB")
  1029. {
  1030. bValue = (float.Parse(bValue[0..^2]) * 1024).ToString();
  1031. }
  1032. else
  1033. {
  1034. bValue = bValue[0..^2];
  1035. }
  1036. if (float.Parse(aValue) > float.Parse(bValue))
  1037. {
  1038. return -1;
  1039. }
  1040. else if (float.Parse(bValue) > float.Parse(aValue))
  1041. {
  1042. return 1;
  1043. }
  1044. else
  1045. {
  1046. return 0;
  1047. }
  1048. }
  1049. }
  1050. }