MainWindowViewModel.cs 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865
  1. using Avalonia;
  2. using Avalonia.Controls;
  3. using Avalonia.Controls.ApplicationLifetimes;
  4. using Avalonia.Input;
  5. using Avalonia.Media;
  6. using Avalonia.Media.Imaging;
  7. using Avalonia.Platform.Storage;
  8. using Avalonia.Threading;
  9. using CommunityToolkit.Mvvm.ComponentModel;
  10. using DynamicData;
  11. using DynamicData.Binding;
  12. using FluentAvalonia.UI.Controls;
  13. using Gommon;
  14. using LibHac.Common;
  15. using LibHac.Ns;
  16. using Ryujinx.Ava.Common;
  17. using Ryujinx.Ava.Common.Locale;
  18. using Ryujinx.Ava.Input;
  19. using Ryujinx.Ava.UI.Controls;
  20. using Ryujinx.Ava.UI.Helpers;
  21. using Ryujinx.Ava.UI.Models;
  22. using Ryujinx.Ava.UI.Models.Generic;
  23. using Ryujinx.Ava.UI.Renderer;
  24. using Ryujinx.Ava.UI.Windows;
  25. using Ryujinx.Ava.Utilities.AppLibrary;
  26. using Ryujinx.Ava.Utilities.Configuration;
  27. using Ryujinx.Common;
  28. using Ryujinx.Common.Configuration;
  29. using Ryujinx.Common.Helper;
  30. using Ryujinx.Common.Logging;
  31. using Ryujinx.Common.UI;
  32. using Ryujinx.Common.Utilities;
  33. using Ryujinx.Cpu;
  34. using Ryujinx.HLE;
  35. using Ryujinx.HLE.FileSystem;
  36. using Ryujinx.HLE.HOS;
  37. using Ryujinx.HLE.HOS.Services.Account.Acc;
  38. using Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption;
  39. using Ryujinx.HLE.UI;
  40. using Ryujinx.Input.HLE;
  41. using SkiaSharp;
  42. using System;
  43. using System.Collections.Generic;
  44. using System.Collections.ObjectModel;
  45. using System.Globalization;
  46. using System.IO;
  47. using System.Linq;
  48. using System.Reflection;
  49. using System.Threading;
  50. using System.Threading.Tasks;
  51. using Key = Ryujinx.Input.Key;
  52. using MissingKeyException = LibHac.Common.Keys.MissingKeyException;
  53. using ShaderCacheLoadingState = Ryujinx.Graphics.Gpu.Shader.ShaderCacheState;
  54. namespace Ryujinx.Ava.UI.ViewModels
  55. {
  56. public partial class MainWindowViewModel : BaseModel
  57. {
  58. private const int HotKeyPressDelayMs = 500;
  59. private delegate int LoadContentFromFolderDelegate(List<string> dirs, out int numRemoved);
  60. [ObservableProperty] private ObservableCollectionExtended<ApplicationData> _applications;
  61. [ObservableProperty] private string _aspectRatioStatusText;
  62. [ObservableProperty] private string _loadHeading;
  63. [ObservableProperty] private string _cacheLoadStatus;
  64. [ObservableProperty] private string _dockedStatusText;
  65. [ObservableProperty] private string _fifoStatusText;
  66. [ObservableProperty] private string _gameStatusText;
  67. [ObservableProperty] private string _volumeStatusText;
  68. [ObservableProperty] private string _gpuNameText;
  69. [ObservableProperty] private string _backendText;
  70. [ObservableProperty] private string _shaderCountText;
  71. [ObservableProperty] private bool _showShaderCompilationHint;
  72. [ObservableProperty] private bool _isFullScreen;
  73. [ObservableProperty] private int _progressMaximum;
  74. [ObservableProperty] private int _progressValue;
  75. [ObservableProperty] private bool _showMenuAndStatusBar = true;
  76. [ObservableProperty] private bool _showStatusSeparator;
  77. [ObservableProperty] private Brush _progressBarForegroundColor;
  78. [ObservableProperty] private Brush _progressBarBackgroundColor;
  79. [ObservableProperty] private Brush _vSyncModeColor;
  80. #nullable enable
  81. [ObservableProperty] private byte[]? _selectedIcon;
  82. #nullable disable
  83. [ObservableProperty] private int _statusBarProgressMaximum;
  84. [ObservableProperty] private int _statusBarProgressValue;
  85. [ObservableProperty] private string _statusBarProgressStatusText;
  86. [ObservableProperty] private bool _statusBarProgressStatusVisible;
  87. [ObservableProperty] private bool _isPaused;
  88. [ObservableProperty] private bool _isLoadingIndeterminate = true;
  89. [ObservableProperty] private bool _showAll;
  90. [ObservableProperty] private string _lastScannedAmiiboId;
  91. [ObservableProperty] private ReadOnlyObservableCollection<ApplicationData> _appsObservableList;
  92. [ObservableProperty] private long _lastFullscreenToggle = Environment.TickCount64;
  93. [ObservableProperty] private bool _showContent = true;
  94. [ObservableProperty] private float _volumeBeforeMute;
  95. [ObservableProperty] private bool _areMimeTypesRegistered = FileAssociationHelper.AreMimeTypesRegistered;
  96. [ObservableProperty] private Cursor _cursor;
  97. [ObservableProperty] private string _title;
  98. [ObservableProperty] private WindowState _windowState;
  99. [ObservableProperty] private double _windowWidth;
  100. [ObservableProperty] private double _windowHeight;
  101. [ObservableProperty] private bool _isActive;
  102. [ObservableProperty] private bool _isSubMenuOpen;
  103. [ObservableProperty] private ApplicationContextMenu _listAppContextMenu;
  104. [ObservableProperty] private ApplicationContextMenu _gridAppContextMenu;
  105. private bool _showLoadProgress;
  106. private bool _isGameRunning;
  107. private bool _isAmiiboRequested;
  108. private bool _isAmiiboBinRequested;
  109. private string _searchText;
  110. private Timer _searchTimer;
  111. private string _vSyncModeText;
  112. private string _showUiKey = "F4";
  113. private string _pauseKey = "F5";
  114. private string _screenshotKey = "F8";
  115. private float _volume;
  116. private bool _isAppletMenuActive;
  117. private bool _statusBarVisible;
  118. private bool _canUpdate = true;
  119. private ApplicationData _currentApplicationData;
  120. private readonly AutoResetEvent _rendererWaitEvent;
  121. private int _customVSyncInterval;
  122. private int _customVSyncIntervalPercentageProxy;
  123. private ApplicationData _listSelectedApplication;
  124. private ApplicationData _gridSelectedApplication;
  125. // Key is Title ID
  126. public SafeDictionary<string, LdnGameData.Array> LdnData = [];
  127. // The UI specifically uses a thicker bordered variant of the icon to avoid crunching out the border at lower resolutions.
  128. // For an example of this, download canary 1.2.95, then open the settings menu, and look at the icon in the top-left.
  129. // The border gets reduced to colored pixels in the 4 corners.
  130. public static readonly Bitmap IconBitmap =
  131. new(Assembly.GetAssembly(typeof(MainWindowViewModel))!.GetManifestResourceStream("Ryujinx.Assets.UIImages.Logo_Ryujinx_AntiAlias.png")!);
  132. public MainWindow Window { get; init; }
  133. internal AppHost AppHost { get; set; }
  134. public MainWindowViewModel()
  135. {
  136. Applications = [];
  137. Applications.ToObservableChangeSet()
  138. .Filter(Filter)
  139. .Sort(GetComparer())
  140. .OnItemAdded(_ => OnPropertyChanged(nameof(AppsObservableList)))
  141. .OnItemRemoved(_ => OnPropertyChanged(nameof(AppsObservableList)))
  142. #pragma warning disable MVVMTK0034 // Event to update is fired below
  143. .Bind(out _appsObservableList);
  144. #pragma warning restore MVVMTK0034
  145. _rendererWaitEvent = new AutoResetEvent(false);
  146. if (Program.PreviewerDetached)
  147. {
  148. LoadConfigurableHotKeys();
  149. Volume = ConfigurationState.Instance.System.AudioVolume;
  150. CustomVSyncInterval = ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value;
  151. }
  152. }
  153. public void Initialize(
  154. ContentManager contentManager,
  155. IStorageProvider storageProvider,
  156. ApplicationLibrary applicationLibrary,
  157. VirtualFileSystem virtualFileSystem,
  158. AccountManager accountManager,
  159. InputManager inputManager,
  160. UserChannelPersistence userChannelPersistence,
  161. LibHacHorizonManager libHacHorizonManager,
  162. IHostUIHandler uiHandler,
  163. Action<bool> showLoading,
  164. Action<bool> switchToGameControl,
  165. Action<Control> setMainContent,
  166. TopLevel topLevel)
  167. {
  168. ContentManager = contentManager;
  169. StorageProvider = storageProvider;
  170. ApplicationLibrary = applicationLibrary;
  171. VirtualFileSystem = virtualFileSystem;
  172. AccountManager = accountManager;
  173. InputManager = inputManager;
  174. UserChannelPersistence = userChannelPersistence;
  175. LibHacHorizonManager = libHacHorizonManager;
  176. UiHandler = uiHandler;
  177. ShowLoading = showLoading;
  178. SwitchToGameControl = switchToGameControl;
  179. SetMainContent = setMainContent;
  180. TopLevel = topLevel;
  181. #if DEBUG
  182. topLevel.AttachDevTools(new KeyGesture(Avalonia.Input.Key.F12, KeyModifiers.Control));
  183. #endif
  184. }
  185. #region Properties
  186. public string SearchText
  187. {
  188. get => _searchText;
  189. set
  190. {
  191. _searchText = value;
  192. _searchTimer?.Dispose();
  193. _searchTimer = new Timer(_ =>
  194. {
  195. RefreshView();
  196. _searchTimer.Dispose();
  197. _searchTimer = null;
  198. }, null, 1000, 0);
  199. }
  200. }
  201. public bool CanUpdate
  202. {
  203. get => _canUpdate && EnableNonGameRunningControls && Updater.CanUpdate();
  204. set
  205. {
  206. _canUpdate = value;
  207. OnPropertyChanged();
  208. }
  209. }
  210. public bool StatusBarVisible
  211. {
  212. get => _statusBarVisible && EnableNonGameRunningControls;
  213. set
  214. {
  215. _statusBarVisible = value;
  216. OnPropertyChanged();
  217. }
  218. }
  219. public bool EnableNonGameRunningControls => !IsGameRunning;
  220. public bool ShowFirmwareStatus => !ShowLoadProgress;
  221. public bool IsGameRunning
  222. {
  223. get => _isGameRunning;
  224. set
  225. {
  226. _isGameRunning = value;
  227. if (!value)
  228. {
  229. ShowMenuAndStatusBar = false;
  230. }
  231. OnPropertyChanged();
  232. OnPropertyChanged(nameof(EnableNonGameRunningControls));
  233. OnPropertyChanged(nameof(IsAppletMenuActive));
  234. OnPropertyChanged(nameof(StatusBarVisible));
  235. OnPropertyChanged(nameof(ShowFirmwareStatus));
  236. }
  237. }
  238. public bool IsAmiiboRequested
  239. {
  240. get => _isAmiiboRequested && _isGameRunning;
  241. set
  242. {
  243. _isAmiiboRequested = value;
  244. OnPropertyChanged();
  245. }
  246. }
  247. public bool IsAmiiboBinRequested
  248. {
  249. get => _isAmiiboBinRequested && _isGameRunning;
  250. set
  251. {
  252. _isAmiiboBinRequested = value;
  253. OnPropertyChanged();
  254. }
  255. }
  256. public bool CanScanAmiiboBinaries => AmiiboBinReader.HasAmiiboKeyFile;
  257. public bool ShowLoadProgress
  258. {
  259. get => _showLoadProgress;
  260. set
  261. {
  262. _showLoadProgress = value;
  263. OnPropertyChanged();
  264. OnPropertyChanged(nameof(ShowFirmwareStatus));
  265. }
  266. }
  267. public ApplicationData ListSelectedApplication
  268. {
  269. get => _listSelectedApplication;
  270. set
  271. {
  272. _listSelectedApplication = value;
  273. #pragma warning disable MVVMTK0034
  274. if (_listSelectedApplication != null && _listAppContextMenu == null)
  275. ListAppContextMenu = new ApplicationContextMenu();
  276. else if (_listSelectedApplication == null && _listAppContextMenu != null)
  277. ListAppContextMenu = null!;
  278. #pragma warning restore MVVMTK0034
  279. OnPropertyChanged();
  280. }
  281. }
  282. public ApplicationData GridSelectedApplication
  283. {
  284. get => _gridSelectedApplication;
  285. set
  286. {
  287. _gridSelectedApplication = value;
  288. #pragma warning disable MVVMTK0034
  289. if (_gridSelectedApplication != null && _gridAppContextMenu == null)
  290. GridAppContextMenu = new ApplicationContextMenu();
  291. else if (_gridSelectedApplication == null && _gridAppContextMenu != null)
  292. GridAppContextMenu = null!;
  293. #pragma warning restore MVVMTK0034
  294. OnPropertyChanged();
  295. }
  296. }
  297. public ApplicationData SelectedApplication
  298. {
  299. get
  300. {
  301. return Glyph switch
  302. {
  303. Glyph.List => ListSelectedApplication,
  304. Glyph.Grid => GridSelectedApplication,
  305. _ => null,
  306. };
  307. }
  308. }
  309. public bool OpenUserSaveDirectoryEnabled => SelectedApplication.HasControlHolder && SelectedApplication.ControlHolder.Value.UserAccountSaveDataSize > 0;
  310. public bool OpenDeviceSaveDirectoryEnabled => SelectedApplication.HasControlHolder && SelectedApplication.ControlHolder.Value.DeviceSaveDataSize > 0;
  311. public bool TrimXCIEnabled => XCIFileTrimmer.CanTrim(SelectedApplication.Path, new XCITrimmerLog.MainWindow(this));
  312. public bool OpenBcatSaveDirectoryEnabled => SelectedApplication.HasControlHolder && SelectedApplication.ControlHolder.Value.BcatDeliveryCacheStorageSize > 0;
  313. public bool ShowCustomVSyncIntervalPicker
  314. => _isGameRunning && AppHost.Device.VSyncMode == VSyncMode.Custom;
  315. public void UpdateVSyncIntervalPicker()
  316. {
  317. OnPropertyChanged(nameof(ShowCustomVSyncIntervalPicker));
  318. }
  319. public int CustomVSyncIntervalPercentageProxy
  320. {
  321. get => _customVSyncIntervalPercentageProxy;
  322. set
  323. {
  324. int newInterval = (int)((value / 100f) * 60);
  325. _customVSyncInterval = newInterval;
  326. _customVSyncIntervalPercentageProxy = value;
  327. if (_isGameRunning)
  328. {
  329. AppHost.Device.CustomVSyncInterval = newInterval;
  330. AppHost.Device.UpdateVSyncInterval();
  331. }
  332. OnPropertyChanged((nameof(CustomVSyncInterval)));
  333. OnPropertyChanged((nameof(CustomVSyncIntervalPercentageText)));
  334. }
  335. }
  336. public string CustomVSyncIntervalPercentageText
  337. {
  338. get
  339. {
  340. string text = CustomVSyncIntervalPercentageProxy.ToString() + "%";
  341. return text;
  342. }
  343. set
  344. {
  345. }
  346. }
  347. public int CustomVSyncInterval
  348. {
  349. get => _customVSyncInterval;
  350. set
  351. {
  352. _customVSyncInterval = value;
  353. int newPercent = (int)((value / 60f) * 100);
  354. _customVSyncIntervalPercentageProxy = newPercent;
  355. if (_isGameRunning)
  356. {
  357. AppHost.Device.CustomVSyncInterval = value;
  358. AppHost.Device.UpdateVSyncInterval();
  359. }
  360. OnPropertyChanged(nameof(CustomVSyncIntervalPercentageProxy));
  361. OnPropertyChanged(nameof(CustomVSyncIntervalPercentageText));
  362. OnPropertyChanged();
  363. }
  364. }
  365. public string VSyncModeText
  366. {
  367. get => _vSyncModeText;
  368. set
  369. {
  370. _vSyncModeText = value;
  371. OnPropertyChanged();
  372. OnPropertyChanged(nameof(ShowCustomVSyncIntervalPicker));
  373. }
  374. }
  375. public bool VolumeMuted => _volume == 0;
  376. public float Volume
  377. {
  378. get => _volume;
  379. set
  380. {
  381. _volume = value;
  382. if (_isGameRunning)
  383. {
  384. AppHost.Device.SetVolume(_volume);
  385. }
  386. OnPropertyChanged(nameof(VolumeStatusText));
  387. OnPropertyChanged(nameof(VolumeMuted));
  388. OnPropertyChanged();
  389. }
  390. }
  391. public bool IsAppletMenuActive
  392. {
  393. get => _isAppletMenuActive && EnableNonGameRunningControls;
  394. set
  395. {
  396. _isAppletMenuActive = value;
  397. OnPropertyChanged();
  398. }
  399. }
  400. public bool IsGrid => Glyph == Glyph.Grid;
  401. public bool IsList => Glyph == Glyph.List;
  402. internal void Sort(bool isAscending)
  403. {
  404. IsAscending = isAscending;
  405. RefreshView();
  406. }
  407. internal void Sort(ApplicationSort sort)
  408. {
  409. SortMode = sort;
  410. RefreshView();
  411. }
  412. public bool StartGamesInFullscreen
  413. {
  414. get => ConfigurationState.Instance.UI.StartFullscreen;
  415. set
  416. {
  417. ConfigurationState.Instance.UI.StartFullscreen.Value = value;
  418. ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
  419. OnPropertyChanged();
  420. }
  421. }
  422. public bool StartGamesWithoutUI
  423. {
  424. get => ConfigurationState.Instance.UI.StartNoUI;
  425. set
  426. {
  427. ConfigurationState.Instance.UI.StartNoUI.Value = value;
  428. ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
  429. OnPropertyChanged();
  430. }
  431. }
  432. public bool ShowConsole
  433. {
  434. get => ConfigurationState.Instance.UI.ShowConsole;
  435. set
  436. {
  437. ConfigurationState.Instance.UI.ShowConsole.Value = value;
  438. ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
  439. OnPropertyChanged();
  440. }
  441. }
  442. public bool ShowConsoleVisible
  443. {
  444. get => ConsoleHelper.SetConsoleWindowStateSupported;
  445. }
  446. public bool ManageFileTypesVisible
  447. {
  448. get => FileAssociationHelper.IsTypeAssociationSupported;
  449. }
  450. public Glyph Glyph
  451. {
  452. get => (Glyph)ConfigurationState.Instance.UI.GameListViewMode.Value;
  453. set
  454. {
  455. ConfigurationState.Instance.UI.GameListViewMode.Value = (int)value;
  456. OnPropertyChanged();
  457. OnPropertyChanged(nameof(IsGrid));
  458. OnPropertyChanged(nameof(IsList));
  459. ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
  460. }
  461. }
  462. public bool ShowNames
  463. {
  464. get => ConfigurationState.Instance.UI.ShowNames && ConfigurationState.Instance.UI.GridSize > 1;
  465. set
  466. {
  467. ConfigurationState.Instance.UI.ShowNames.Value = value;
  468. OnPropertyChanged();
  469. OnPropertyChanged(nameof(GridSizeScale));
  470. OnPropertyChanged(nameof(GridItemSelectorSize));
  471. ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
  472. }
  473. }
  474. internal ApplicationSort SortMode
  475. {
  476. get => (ApplicationSort)ConfigurationState.Instance.UI.ApplicationSort.Value;
  477. private set
  478. {
  479. ConfigurationState.Instance.UI.ApplicationSort.Value = (int)value;
  480. OnPropertyChanged();
  481. OnPropertyChanged(nameof(SortName));
  482. ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
  483. }
  484. }
  485. public int ListItemSelectorSize
  486. {
  487. get
  488. {
  489. return ConfigurationState.Instance.UI.GridSize.Value switch
  490. {
  491. 1 => 78,
  492. 2 => 100,
  493. 3 => 120,
  494. 4 => 140,
  495. _ => 16,
  496. };
  497. }
  498. }
  499. public int GridItemSelectorSize
  500. {
  501. get
  502. {
  503. return ConfigurationState.Instance.UI.GridSize.Value switch
  504. {
  505. 1 => 120,
  506. 2 => ShowNames ? 210 : 150,
  507. 3 => ShowNames ? 240 : 180,
  508. 4 => ShowNames ? 280 : 220,
  509. _ => 16,
  510. };
  511. }
  512. }
  513. public int GridSizeScale
  514. {
  515. get => ConfigurationState.Instance.UI.GridSize;
  516. set
  517. {
  518. ConfigurationState.Instance.UI.GridSize.Value = value;
  519. if (value < 2)
  520. {
  521. ShowNames = false;
  522. }
  523. OnPropertyChanged();
  524. OnPropertyChanged(nameof(IsGridSmall));
  525. OnPropertyChanged(nameof(IsGridMedium));
  526. OnPropertyChanged(nameof(IsGridLarge));
  527. OnPropertyChanged(nameof(IsGridHuge));
  528. OnPropertyChanged(nameof(ListItemSelectorSize));
  529. OnPropertyChanged(nameof(GridItemSelectorSize));
  530. OnPropertyChanged(nameof(ShowNames));
  531. ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
  532. }
  533. }
  534. public string SortName
  535. {
  536. get
  537. {
  538. return SortMode switch
  539. {
  540. ApplicationSort.Title => LocaleManager.Instance[LocaleKeys.GameListHeaderApplication],
  541. ApplicationSort.Developer => LocaleManager.Instance[LocaleKeys.GameListHeaderDeveloper],
  542. ApplicationSort.LastPlayed => LocaleManager.Instance[LocaleKeys.GameListHeaderLastPlayed],
  543. ApplicationSort.TotalTimePlayed => LocaleManager.Instance[LocaleKeys.GameListHeaderTimePlayed],
  544. ApplicationSort.FileType => LocaleManager.Instance[LocaleKeys.GameListHeaderFileExtension],
  545. ApplicationSort.FileSize => LocaleManager.Instance[LocaleKeys.GameListHeaderFileSize],
  546. ApplicationSort.Path => LocaleManager.Instance[LocaleKeys.GameListHeaderPath],
  547. ApplicationSort.Favorite => LocaleManager.Instance[LocaleKeys.CommonFavorite],
  548. ApplicationSort.TitleId => LocaleManager.Instance[LocaleKeys.DlcManagerTableHeadingTitleIdLabel],
  549. _ => string.Empty,
  550. };
  551. }
  552. }
  553. public bool IsAscending
  554. {
  555. get => ConfigurationState.Instance.UI.IsAscendingOrder;
  556. private set
  557. {
  558. ConfigurationState.Instance.UI.IsAscendingOrder.Value = value;
  559. OnPropertyChanged();
  560. OnPropertyChanged(nameof(SortMode));
  561. OnPropertyChanged(nameof(SortName));
  562. ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
  563. }
  564. }
  565. public KeyGesture ShowUiKey
  566. {
  567. get => KeyGesture.Parse(_showUiKey);
  568. set
  569. {
  570. _showUiKey = value.ToString();
  571. OnPropertyChanged();
  572. }
  573. }
  574. public KeyGesture ScreenshotKey
  575. {
  576. get => KeyGesture.Parse(_screenshotKey);
  577. set
  578. {
  579. _screenshotKey = value.ToString();
  580. OnPropertyChanged();
  581. }
  582. }
  583. public KeyGesture PauseKey
  584. {
  585. get => KeyGesture.Parse(_pauseKey);
  586. set
  587. {
  588. _pauseKey = value.ToString();
  589. OnPropertyChanged();
  590. }
  591. }
  592. public ContentManager ContentManager { get; private set; }
  593. public IStorageProvider StorageProvider { get; private set; }
  594. public ApplicationLibrary ApplicationLibrary { get; private set; }
  595. public VirtualFileSystem VirtualFileSystem { get; private set; }
  596. public AccountManager AccountManager { get; private set; }
  597. public InputManager InputManager { get; private set; }
  598. public UserChannelPersistence UserChannelPersistence { get; private set; }
  599. public Action<bool> ShowLoading { get; private set; }
  600. public Action<bool> SwitchToGameControl { get; private set; }
  601. public Action<Control> SetMainContent { get; private set; }
  602. public TopLevel TopLevel { get; private set; }
  603. public RendererHost RendererHostControl { get; private set; }
  604. public bool IsClosing { get; set; }
  605. public LibHacHorizonManager LibHacHorizonManager { get; internal set; }
  606. public IHostUIHandler UiHandler { get; internal set; }
  607. public bool IsSortedByFavorite => SortMode == ApplicationSort.Favorite;
  608. public bool IsSortedByTitle => SortMode == ApplicationSort.Title;
  609. public bool IsSortedByTitleId => SortMode == ApplicationSort.TitleId;
  610. public bool IsSortedByDeveloper => SortMode == ApplicationSort.Developer;
  611. public bool IsSortedByLastPlayed => SortMode == ApplicationSort.LastPlayed;
  612. public bool IsSortedByTimePlayed => SortMode == ApplicationSort.TotalTimePlayed;
  613. public bool IsSortedByType => SortMode == ApplicationSort.FileType;
  614. public bool IsSortedBySize => SortMode == ApplicationSort.FileSize;
  615. public bool IsSortedByPath => SortMode == ApplicationSort.Path;
  616. public bool IsGridSmall => ConfigurationState.Instance.UI.GridSize == 1;
  617. public bool IsGridMedium => ConfigurationState.Instance.UI.GridSize == 2;
  618. public bool IsGridLarge => ConfigurationState.Instance.UI.GridSize == 3;
  619. public bool IsGridHuge => ConfigurationState.Instance.UI.GridSize == 4;
  620. #endregion
  621. #region PrivateMethods
  622. private static IComparer<ApplicationData> CreateComparer(bool ascending, Func<ApplicationData, IComparable> selector) =>
  623. ascending
  624. ? SortExpressionComparer<ApplicationData>.Ascending(selector)
  625. : SortExpressionComparer<ApplicationData>.Descending(selector);
  626. private IComparer<ApplicationData> GetComparer()
  627. => SortMode switch
  628. {
  629. #pragma warning disable IDE0055 // Disable formatting
  630. ApplicationSort.Title => CreateComparer(IsAscending, app => app.Name),
  631. ApplicationSort.Developer => CreateComparer(IsAscending, app => app.Developer),
  632. ApplicationSort.LastPlayed => new LastPlayedSortComparer(IsAscending),
  633. ApplicationSort.TotalTimePlayed => new TimePlayedSortComparer(IsAscending),
  634. ApplicationSort.FileType => CreateComparer(IsAscending, app => app.FileExtension),
  635. ApplicationSort.FileSize => CreateComparer(IsAscending, app => app.FileSize),
  636. ApplicationSort.Path => CreateComparer(IsAscending, app => app.Path),
  637. ApplicationSort.Favorite => CreateComparer(IsAscending, app => new AppListFavoriteComparable(app)),
  638. ApplicationSort.TitleId => CreateComparer(IsAscending, app => app.Id),
  639. _ => null,
  640. #pragma warning restore IDE0055
  641. };
  642. public void RefreshView()
  643. {
  644. RefreshGrid();
  645. }
  646. private void RefreshGrid()
  647. {
  648. Applications.ToObservableChangeSet()
  649. .Filter(Filter)
  650. .Sort(GetComparer())
  651. #pragma warning disable MVVMTK0034
  652. .Bind(out _appsObservableList)
  653. #pragma warning restore MVVMTK0034
  654. .AsObservableList();
  655. OnPropertyChanged(nameof(AppsObservableList));
  656. }
  657. private bool Filter(object arg)
  658. {
  659. if (arg is ApplicationData app)
  660. {
  661. if (string.IsNullOrWhiteSpace(_searchText))
  662. {
  663. return true;
  664. }
  665. CompareInfo compareInfo = CultureInfo.CurrentCulture.CompareInfo;
  666. return compareInfo.IndexOf(app.Name, _searchText, CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace) >= 0;
  667. }
  668. return false;
  669. }
  670. private async Task HandleFirmwareInstallation(string filename)
  671. {
  672. try
  673. {
  674. SystemVersion firmwareVersion = ContentManager.VerifyFirmwarePackage(filename);
  675. if (firmwareVersion == null)
  676. {
  677. await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogFirmwareInstallerFirmwareNotFoundErrorMessage, filename));
  678. return;
  679. }
  680. string dialogTitle = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogFirmwareInstallerFirmwareInstallTitle, firmwareVersion.VersionString);
  681. string dialogMessage = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogFirmwareInstallerFirmwareInstallMessage, firmwareVersion.VersionString);
  682. SystemVersion currentVersion = ContentManager.GetCurrentFirmwareVersion();
  683. if (currentVersion != null)
  684. {
  685. dialogMessage += LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogFirmwareInstallerFirmwareInstallSubMessage, currentVersion.VersionString);
  686. }
  687. dialogMessage += LocaleManager.Instance[LocaleKeys.DialogFirmwareInstallerFirmwareInstallConfirmMessage];
  688. UserResult result = await ContentDialogHelper.CreateConfirmationDialog(
  689. dialogTitle,
  690. dialogMessage,
  691. LocaleManager.Instance[LocaleKeys.InputDialogYes],
  692. LocaleManager.Instance[LocaleKeys.InputDialogNo],
  693. LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
  694. UpdateWaitWindow waitingDialog = new(dialogTitle, LocaleManager.Instance[LocaleKeys.DialogFirmwareInstallerFirmwareInstallWaitMessage]);
  695. if (result == UserResult.Yes)
  696. {
  697. Logger.Info?.Print(LogClass.Application, $"Installing firmware {firmwareVersion.VersionString}");
  698. Thread thread = new(() =>
  699. {
  700. Dispatcher.UIThread.InvokeAsync(delegate
  701. {
  702. waitingDialog.Show();
  703. });
  704. try
  705. {
  706. ContentManager.InstallFirmware(filename);
  707. Dispatcher.UIThread.InvokeAsync(async delegate
  708. {
  709. waitingDialog.Close();
  710. string message = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogFirmwareInstallerFirmwareInstallSuccessMessage, firmwareVersion.VersionString);
  711. await ContentDialogHelper.CreateInfoDialog(
  712. dialogTitle,
  713. message,
  714. LocaleManager.Instance[LocaleKeys.InputDialogOk],
  715. string.Empty,
  716. LocaleManager.Instance[LocaleKeys.RyujinxInfo]);
  717. Logger.Info?.Print(LogClass.Application, message);
  718. // Purge Applet Cache.
  719. DirectoryInfo miiEditorCacheFolder = new(Path.Combine(AppDataManager.GamesDirPath, "0100000000001009", "cache"));
  720. if (miiEditorCacheFolder.Exists)
  721. {
  722. miiEditorCacheFolder.Delete(true);
  723. }
  724. });
  725. }
  726. catch (Exception ex)
  727. {
  728. Dispatcher.UIThread.InvokeAsync(async () =>
  729. {
  730. waitingDialog.Close();
  731. await ContentDialogHelper.CreateErrorDialog(ex.Message);
  732. });
  733. }
  734. finally
  735. {
  736. RefreshFirmwareStatus();
  737. }
  738. })
  739. {
  740. Name = "GUI.FirmwareInstallerThread",
  741. };
  742. thread.Start();
  743. }
  744. }
  745. catch (MissingKeyException ex)
  746. {
  747. if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime)
  748. {
  749. Logger.Error?.Print(LogClass.Application, ex.ToString());
  750. await UserErrorDialog.ShowUserErrorDialog(UserError.NoKeys);
  751. }
  752. }
  753. catch (Exception ex)
  754. {
  755. await ContentDialogHelper.CreateErrorDialog(ex.Message);
  756. }
  757. }
  758. private async Task HandleKeysInstallation(string filename)
  759. {
  760. try
  761. {
  762. string systemDirectory = AppDataManager.KeysDirPath;
  763. if (AppDataManager.Mode == AppDataManager.LaunchMode.UserProfile && Directory.Exists(AppDataManager.KeysDirPathUser))
  764. {
  765. systemDirectory = AppDataManager.KeysDirPathUser;
  766. }
  767. string dialogTitle = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogKeysInstallerKeysInstallTitle);
  768. string dialogMessage = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogKeysInstallerKeysInstallMessage);
  769. bool alreadyKesyInstalled = ContentManager.AreKeysAlredyPresent(systemDirectory);
  770. if (alreadyKesyInstalled)
  771. {
  772. dialogMessage += LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogKeysInstallerKeysInstallSubMessage);
  773. }
  774. dialogMessage += LocaleManager.Instance[LocaleKeys.DialogKeysInstallerKeysInstallConfirmMessage];
  775. UserResult result = await ContentDialogHelper.CreateConfirmationDialog(
  776. dialogTitle,
  777. dialogMessage,
  778. LocaleManager.Instance[LocaleKeys.InputDialogYes],
  779. LocaleManager.Instance[LocaleKeys.InputDialogNo],
  780. LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
  781. UpdateWaitWindow waitingDialog = new(dialogTitle, LocaleManager.Instance[LocaleKeys.DialogKeysInstallerKeysInstallWaitMessage]);
  782. if (result == UserResult.Yes)
  783. {
  784. Logger.Info?.Print(LogClass.Application, $"Installing Keys");
  785. Thread thread = new(() =>
  786. {
  787. Dispatcher.UIThread.InvokeAsync(delegate
  788. {
  789. waitingDialog.Show();
  790. });
  791. try
  792. {
  793. ContentManager.InstallKeys(filename, systemDirectory);
  794. Dispatcher.UIThread.InvokeAsync(async delegate
  795. {
  796. waitingDialog.Close();
  797. string message = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogKeysInstallerKeysInstallSuccessMessage);
  798. await ContentDialogHelper.CreateInfoDialog(
  799. dialogTitle,
  800. message,
  801. LocaleManager.Instance[LocaleKeys.InputDialogOk],
  802. string.Empty,
  803. LocaleManager.Instance[LocaleKeys.RyujinxInfo]);
  804. Logger.Info?.Print(LogClass.Application, message);
  805. });
  806. }
  807. catch (Exception ex)
  808. {
  809. Dispatcher.UIThread.InvokeAsync(async () =>
  810. {
  811. waitingDialog.Close();
  812. string message = ex.Message;
  813. if(ex is FormatException)
  814. {
  815. message = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogKeysInstallerKeysNotFoundErrorMessage, filename);
  816. }
  817. await ContentDialogHelper.CreateErrorDialog(message);
  818. });
  819. }
  820. finally
  821. {
  822. VirtualFileSystem.ReloadKeySet();
  823. }
  824. })
  825. {
  826. Name = "GUI.KeysInstallerThread",
  827. };
  828. thread.Start();
  829. }
  830. }
  831. catch (MissingKeyException ex)
  832. {
  833. if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime)
  834. {
  835. Logger.Error?.Print(LogClass.Application, ex.ToString());
  836. await UserErrorDialog.ShowUserErrorDialog(UserError.NoKeys);
  837. }
  838. }
  839. catch (Exception ex)
  840. {
  841. await ContentDialogHelper.CreateErrorDialog(ex.Message);
  842. }
  843. }
  844. private void ProgressHandler<T>(T state, int current, int total) where T : Enum
  845. {
  846. Dispatcher.UIThread.Post(() =>
  847. {
  848. ProgressMaximum = total;
  849. ProgressValue = current;
  850. switch (state)
  851. {
  852. case LoadState ptcState:
  853. CacheLoadStatus = $"{current} / {total}";
  854. switch (ptcState)
  855. {
  856. case LoadState.Unloaded:
  857. case LoadState.Loading:
  858. LoadHeading = LocaleManager.Instance[LocaleKeys.CompilingPPTC];
  859. IsLoadingIndeterminate = false;
  860. break;
  861. case LoadState.Loaded:
  862. LoadHeading = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.LoadingHeading, _currentApplicationData.Name);
  863. IsLoadingIndeterminate = true;
  864. CacheLoadStatus = string.Empty;
  865. break;
  866. }
  867. break;
  868. case ShaderCacheLoadingState shaderCacheState:
  869. CacheLoadStatus = $"{current} / {total}";
  870. switch (shaderCacheState)
  871. {
  872. case ShaderCacheLoadingState.Start:
  873. case ShaderCacheLoadingState.Loading:
  874. LoadHeading = LocaleManager.Instance[LocaleKeys.CompilingShaders];
  875. IsLoadingIndeterminate = false;
  876. break;
  877. case ShaderCacheLoadingState.Packaging:
  878. LoadHeading = LocaleManager.Instance[LocaleKeys.PackagingShaders];
  879. IsLoadingIndeterminate = false;
  880. break;
  881. case ShaderCacheLoadingState.Loaded:
  882. LoadHeading = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.LoadingHeading, _currentApplicationData.Name);
  883. IsLoadingIndeterminate = true;
  884. CacheLoadStatus = string.Empty;
  885. break;
  886. }
  887. break;
  888. default:
  889. throw new ArgumentException($"Unknown Progress Handler type {typeof(T)}");
  890. }
  891. });
  892. }
  893. private void PrepareLoadScreen()
  894. {
  895. using MemoryStream stream = new(SelectedIcon);
  896. using var gameIconBmp = SKBitmap.Decode(stream);
  897. var dominantColor = IconColorPicker.GetFilteredColor(gameIconBmp);
  898. const float ColorMultiple = 0.5f;
  899. Color progressFgColor = Color.FromRgb(dominantColor.Red, dominantColor.Green, dominantColor.Blue);
  900. Color progressBgColor = Color.FromRgb(
  901. (byte)(dominantColor.Red * ColorMultiple),
  902. (byte)(dominantColor.Green * ColorMultiple),
  903. (byte)(dominantColor.Blue * ColorMultiple));
  904. ProgressBarForegroundColor = new SolidColorBrush(progressFgColor);
  905. ProgressBarBackgroundColor = new SolidColorBrush(progressBgColor);
  906. }
  907. private void InitializeGame()
  908. {
  909. RendererHostControl.WindowCreated += RendererHost_Created;
  910. AppHost.StatusUpdatedEvent += Update_StatusBar;
  911. AppHost.AppExit += AppHost_AppExit;
  912. _rendererWaitEvent.WaitOne();
  913. AppHost?.Start();
  914. AppHost?.DisposeContext();
  915. }
  916. private async Task HandleRelaunch()
  917. {
  918. if (UserChannelPersistence.PreviousIndex != -1 && UserChannelPersistence.ShouldRestart)
  919. {
  920. UserChannelPersistence.ShouldRestart = false;
  921. await LoadApplication(_currentApplicationData);
  922. }
  923. else
  924. {
  925. // Otherwise, clear state.
  926. UserChannelPersistence = new UserChannelPersistence();
  927. _currentApplicationData = null;
  928. }
  929. }
  930. private void Update_StatusBar(object sender, StatusUpdatedEventArgs args)
  931. {
  932. if (ShowMenuAndStatusBar && !ShowLoadProgress)
  933. {
  934. Dispatcher.UIThread.InvokeAsync(() =>
  935. {
  936. Application.Current!.Styles.TryGetResource(args.VSyncMode,
  937. Application.Current.ActualThemeVariant,
  938. out object color);
  939. if (color is Color clr)
  940. {
  941. VSyncModeColor = new SolidColorBrush(clr);
  942. }
  943. VSyncModeText = args.VSyncMode == "Custom" ? "Custom" : "VSync";
  944. DockedStatusText = args.DockedMode;
  945. AspectRatioStatusText = args.AspectRatio;
  946. GameStatusText = args.GameStatus;
  947. VolumeStatusText = args.VolumeStatus;
  948. FifoStatusText = args.FifoStatus;
  949. ShaderCountText = (ShowShaderCompilationHint = args.ShaderCount > 0)
  950. ? $"{LocaleManager.Instance[LocaleKeys.CompilingShaders]}: {args.ShaderCount}"
  951. : string.Empty;
  952. ShowStatusSeparator = true;
  953. });
  954. }
  955. }
  956. private void RendererHost_Created(object sender, EventArgs e)
  957. {
  958. ShowLoading(false);
  959. _rendererWaitEvent.Set();
  960. }
  961. private async Task LoadContentFromFolder(LocaleKeys localeMessageAddedKey, LocaleKeys localeMessageRemovedKey, LoadContentFromFolderDelegate onDirsSelected)
  962. {
  963. var result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
  964. {
  965. Title = LocaleManager.Instance[LocaleKeys.OpenFolderDialogTitle],
  966. AllowMultiple = true,
  967. });
  968. if (result.Count > 0)
  969. {
  970. var dirs = result.Select(it => it.Path.LocalPath).ToList();
  971. var numAdded = onDirsSelected(dirs, out int numRemoved);
  972. var msg = String.Join("\r\n", new string[] {
  973. string.Format(LocaleManager.Instance[localeMessageRemovedKey], numRemoved),
  974. string.Format(LocaleManager.Instance[localeMessageAddedKey], numAdded)
  975. });
  976. await Dispatcher.UIThread.InvokeAsync(async () =>
  977. {
  978. await ContentDialogHelper.ShowTextDialog(
  979. LocaleManager.Instance[numAdded > 0 || numRemoved > 0 ? LocaleKeys.RyujinxConfirm : LocaleKeys.RyujinxInfo],
  980. msg,
  981. string.Empty,
  982. string.Empty,
  983. string.Empty,
  984. LocaleManager.Instance[LocaleKeys.InputDialogOk],
  985. (int)Symbol.Checkmark);
  986. });
  987. }
  988. }
  989. #endregion
  990. #region PublicMethods
  991. public void SetUiProgressHandlers(Switch emulationContext)
  992. {
  993. if (emulationContext.Processes.ActiveApplication.DiskCacheLoadState != null)
  994. {
  995. emulationContext.Processes.ActiveApplication.DiskCacheLoadState.StateChanged -= ProgressHandler;
  996. emulationContext.Processes.ActiveApplication.DiskCacheLoadState.StateChanged += ProgressHandler;
  997. }
  998. emulationContext.Gpu.ShaderCacheStateChanged -= ProgressHandler;
  999. emulationContext.Gpu.ShaderCacheStateChanged += ProgressHandler;
  1000. }
  1001. public void LoadConfigurableHotKeys()
  1002. {
  1003. if (AvaloniaKeyboardMappingHelper.TryGetAvaKey((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ShowUI, out var showUiKey))
  1004. {
  1005. ShowUiKey = new KeyGesture(showUiKey);
  1006. }
  1007. if (AvaloniaKeyboardMappingHelper.TryGetAvaKey((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.Screenshot, out var screenshotKey))
  1008. {
  1009. ScreenshotKey = new KeyGesture(screenshotKey);
  1010. }
  1011. if (AvaloniaKeyboardMappingHelper.TryGetAvaKey((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.Pause, out var pauseKey))
  1012. {
  1013. PauseKey = new KeyGesture(pauseKey);
  1014. }
  1015. }
  1016. public void TakeScreenshot()
  1017. {
  1018. AppHost.ScreenshotRequested = true;
  1019. }
  1020. public void HideUi()
  1021. {
  1022. ShowMenuAndStatusBar = false;
  1023. }
  1024. public void ToggleStartGamesInFullscreen()
  1025. {
  1026. StartGamesInFullscreen = !StartGamesInFullscreen;
  1027. }
  1028. public void ToggleStartGamesWithoutUI()
  1029. {
  1030. StartGamesWithoutUI = !StartGamesWithoutUI;
  1031. }
  1032. public void ToggleShowConsole()
  1033. {
  1034. ShowConsole = !ShowConsole;
  1035. }
  1036. public void SetListMode()
  1037. {
  1038. Glyph = Glyph.List;
  1039. }
  1040. public void SetGridMode()
  1041. {
  1042. Glyph = Glyph.Grid;
  1043. }
  1044. public void SetAspectRatio(AspectRatio aspectRatio)
  1045. {
  1046. ConfigurationState.Instance.Graphics.AspectRatio.Value = aspectRatio;
  1047. }
  1048. public async Task InstallFirmwareFromFile()
  1049. {
  1050. var result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
  1051. {
  1052. AllowMultiple = false,
  1053. FileTypeFilter = new List<FilePickerFileType>
  1054. {
  1055. new(LocaleManager.Instance[LocaleKeys.FileDialogAllTypes])
  1056. {
  1057. Patterns = new[] { "*.xci", "*.zip" },
  1058. AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xci", "public.zip-archive" },
  1059. MimeTypes = new[] { "application/x-nx-xci", "application/zip" },
  1060. },
  1061. new("XCI")
  1062. {
  1063. Patterns = new[] { "*.xci" },
  1064. AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xci" },
  1065. MimeTypes = new[] { "application/x-nx-xci" },
  1066. },
  1067. new("ZIP")
  1068. {
  1069. Patterns = new[] { "*.zip" },
  1070. AppleUniformTypeIdentifiers = new[] { "public.zip-archive" },
  1071. MimeTypes = new[] { "application/zip" },
  1072. },
  1073. },
  1074. });
  1075. if (result.Count > 0)
  1076. {
  1077. await HandleFirmwareInstallation(result[0].Path.LocalPath);
  1078. }
  1079. }
  1080. public async Task InstallFirmwareFromFolder()
  1081. {
  1082. var result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
  1083. {
  1084. AllowMultiple = false,
  1085. });
  1086. if (result.Count > 0)
  1087. {
  1088. await HandleFirmwareInstallation(result[0].Path.LocalPath);
  1089. }
  1090. }
  1091. public async Task InstallKeysFromFile()
  1092. {
  1093. var result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
  1094. {
  1095. AllowMultiple = false,
  1096. FileTypeFilter = new List<FilePickerFileType>
  1097. {
  1098. new(LocaleManager.Instance[LocaleKeys.FileDialogAllTypes])
  1099. {
  1100. Patterns = new[] { "*.keys", "*.zip" },
  1101. AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xci", "public.zip-archive" },
  1102. MimeTypes = new[] { "application/keys", "application/zip" },
  1103. },
  1104. new("KEYS")
  1105. {
  1106. Patterns = new[] { "*.keys" },
  1107. AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xci" },
  1108. MimeTypes = new[] { "application/keys" },
  1109. },
  1110. new("ZIP")
  1111. {
  1112. Patterns = new[] { "*.zip" },
  1113. AppleUniformTypeIdentifiers = new[] { "public.zip-archive" },
  1114. MimeTypes = new[] { "application/zip" },
  1115. },
  1116. },
  1117. });
  1118. if (result.Count > 0)
  1119. {
  1120. await HandleKeysInstallation(result[0].Path.LocalPath);
  1121. }
  1122. }
  1123. public async Task InstallKeysFromFolder()
  1124. {
  1125. var result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
  1126. {
  1127. AllowMultiple = false,
  1128. });
  1129. if (result.Count > 0)
  1130. {
  1131. await HandleKeysInstallation(result[0].Path.LocalPath);
  1132. }
  1133. }
  1134. public void OpenRyujinxFolder()
  1135. {
  1136. OpenHelper.OpenFolder(AppDataManager.BaseDirPath);
  1137. }
  1138. public void OpenLogsFolder()
  1139. {
  1140. string logPath = AppDataManager.GetOrCreateLogsDir();
  1141. if (!string.IsNullOrEmpty(logPath))
  1142. {
  1143. OpenHelper.OpenFolder(logPath);
  1144. }
  1145. }
  1146. public void ToggleDockMode()
  1147. {
  1148. if (IsGameRunning)
  1149. {
  1150. ConfigurationState.Instance.System.EnableDockedMode.Toggle();
  1151. }
  1152. }
  1153. public void ToggleVSyncMode()
  1154. {
  1155. AppHost.VSyncModeToggle();
  1156. OnPropertyChanged(nameof(ShowCustomVSyncIntervalPicker));
  1157. }
  1158. public void VSyncModeSettingChanged()
  1159. {
  1160. if (_isGameRunning)
  1161. {
  1162. AppHost.Device.CustomVSyncInterval = ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value;
  1163. AppHost.Device.UpdateVSyncInterval();
  1164. }
  1165. CustomVSyncInterval = ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value;
  1166. OnPropertyChanged(nameof(ShowCustomVSyncIntervalPicker));
  1167. OnPropertyChanged(nameof(CustomVSyncIntervalPercentageProxy));
  1168. OnPropertyChanged(nameof(CustomVSyncIntervalPercentageText));
  1169. OnPropertyChanged(nameof(CustomVSyncInterval));
  1170. }
  1171. public async Task ExitCurrentState()
  1172. {
  1173. if (WindowState is WindowState.FullScreen)
  1174. {
  1175. ToggleFullscreen();
  1176. }
  1177. else if (IsGameRunning)
  1178. {
  1179. await Task.Delay(100);
  1180. AppHost?.ShowExitPrompt();
  1181. }
  1182. }
  1183. public static void ChangeLanguage(object languageCode)
  1184. {
  1185. LocaleManager.Instance.LoadLanguage((string)languageCode);
  1186. if (Program.PreviewerDetached)
  1187. {
  1188. ConfigurationState.Instance.UI.LanguageCode.Value = (string)languageCode;
  1189. ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
  1190. }
  1191. }
  1192. public async Task ManageProfiles()
  1193. {
  1194. await NavigationDialogHost.Show(AccountManager, ContentManager, VirtualFileSystem, LibHacHorizonManager.RyujinxClient);
  1195. }
  1196. public void SimulateWakeUpMessage()
  1197. {
  1198. AppHost.Device.System.SimulateWakeUpMessage();
  1199. }
  1200. public async Task OpenFile()
  1201. {
  1202. var result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
  1203. {
  1204. Title = LocaleManager.Instance[LocaleKeys.OpenFileDialogTitle],
  1205. AllowMultiple = false,
  1206. FileTypeFilter = new List<FilePickerFileType>
  1207. {
  1208. new(LocaleManager.Instance[LocaleKeys.AllSupportedFormats])
  1209. {
  1210. Patterns = new[] { "*.nsp", "*.xci", "*.nca", "*.nro", "*.nso" },
  1211. AppleUniformTypeIdentifiers = new[]
  1212. {
  1213. "com.ryujinx.nsp",
  1214. "com.ryujinx.xci",
  1215. "com.ryujinx.nca",
  1216. "com.ryujinx.nro",
  1217. "com.ryujinx.nso",
  1218. },
  1219. MimeTypes = new[]
  1220. {
  1221. "application/x-nx-nsp",
  1222. "application/x-nx-xci",
  1223. "application/x-nx-nca",
  1224. "application/x-nx-nro",
  1225. "application/x-nx-nso",
  1226. },
  1227. },
  1228. new("NSP")
  1229. {
  1230. Patterns = new[] { "*.nsp" },
  1231. AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nsp" },
  1232. MimeTypes = new[] { "application/x-nx-nsp" },
  1233. },
  1234. new("XCI")
  1235. {
  1236. Patterns = new[] { "*.xci" },
  1237. AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xci" },
  1238. MimeTypes = new[] { "application/x-nx-xci" },
  1239. },
  1240. new("NCA")
  1241. {
  1242. Patterns = new[] { "*.nca" },
  1243. AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nca" },
  1244. MimeTypes = new[] { "application/x-nx-nca" },
  1245. },
  1246. new("NRO")
  1247. {
  1248. Patterns = new[] { "*.nro" },
  1249. AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nro" },
  1250. MimeTypes = new[] { "application/x-nx-nro" },
  1251. },
  1252. new("NSO")
  1253. {
  1254. Patterns = new[] { "*.nso" },
  1255. AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nso" },
  1256. MimeTypes = new[] { "application/x-nx-nso" },
  1257. },
  1258. },
  1259. });
  1260. if (result.Count > 0)
  1261. {
  1262. if (ApplicationLibrary.TryGetApplicationsFromFile(result[0].Path.LocalPath,
  1263. out List<ApplicationData> applications))
  1264. {
  1265. await LoadApplication(applications[0]);
  1266. }
  1267. else
  1268. {
  1269. await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.MenuBarFileOpenFromFileError]);
  1270. }
  1271. }
  1272. }
  1273. public async Task LoadDlcFromFolder()
  1274. {
  1275. await LoadContentFromFolder(
  1276. LocaleKeys.AutoloadDlcAddedMessage,
  1277. LocaleKeys.AutoloadDlcRemovedMessage,
  1278. ApplicationLibrary.AutoLoadDownloadableContents);
  1279. }
  1280. public async Task LoadTitleUpdatesFromFolder()
  1281. {
  1282. await LoadContentFromFolder(
  1283. LocaleKeys.AutoloadUpdateAddedMessage,
  1284. LocaleKeys.AutoloadUpdateRemovedMessage,
  1285. ApplicationLibrary.AutoLoadTitleUpdates);
  1286. }
  1287. public async Task OpenFolder()
  1288. {
  1289. var result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
  1290. {
  1291. Title = LocaleManager.Instance[LocaleKeys.OpenFolderDialogTitle],
  1292. AllowMultiple = false,
  1293. });
  1294. if (result.Count > 0)
  1295. {
  1296. ApplicationData applicationData = new()
  1297. {
  1298. Name = Path.GetFileNameWithoutExtension(result[0].Path.LocalPath),
  1299. Path = result[0].Path.LocalPath,
  1300. };
  1301. await LoadApplication(applicationData);
  1302. }
  1303. }
  1304. public async Task LoadApplication(ApplicationData application, bool startFullscreen = false, BlitStruct<ApplicationControlProperty>? customNacpData = null)
  1305. {
  1306. if (AppHost != null)
  1307. {
  1308. await ContentDialogHelper.CreateInfoDialog(
  1309. LocaleManager.Instance[LocaleKeys.DialogLoadAppGameAlreadyLoadedMessage],
  1310. LocaleManager.Instance[LocaleKeys.DialogLoadAppGameAlreadyLoadedSubMessage],
  1311. LocaleManager.Instance[LocaleKeys.InputDialogOk],
  1312. string.Empty,
  1313. LocaleManager.Instance[LocaleKeys.RyujinxInfo]);
  1314. return;
  1315. }
  1316. #if RELEASE
  1317. await PerformanceCheck();
  1318. #endif
  1319. Logger.RestartTime();
  1320. SelectedIcon ??= ApplicationLibrary.GetApplicationIcon(application.Path, ConfigurationState.Instance.System.Language, application.Id);
  1321. PrepareLoadScreen();
  1322. RendererHostControl = new RendererHost(application.Id.ToString("X16"));
  1323. AppHost = new AppHost(
  1324. RendererHostControl,
  1325. InputManager,
  1326. application.Path,
  1327. application.Id,
  1328. VirtualFileSystem,
  1329. ContentManager,
  1330. AccountManager,
  1331. UserChannelPersistence,
  1332. this,
  1333. TopLevel);
  1334. if (!await AppHost.LoadGuestApplication(customNacpData))
  1335. {
  1336. AppHost.DisposeContext();
  1337. AppHost = null;
  1338. return;
  1339. }
  1340. CanUpdate = false;
  1341. LoadHeading = application.Name;
  1342. if (string.IsNullOrWhiteSpace(application.Name))
  1343. {
  1344. LoadHeading = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.LoadingHeading, AppHost.Device.Processes.ActiveApplication.Name);
  1345. application.Name = AppHost.Device.Processes.ActiveApplication.Name;
  1346. }
  1347. SwitchToRenderer(startFullscreen);
  1348. _currentApplicationData = application;
  1349. Thread gameThread = new(InitializeGame) { Name = "GUI.WindowThread" };
  1350. gameThread.Start();
  1351. }
  1352. public void SwitchToRenderer(bool startFullscreen) =>
  1353. Dispatcher.UIThread.Post(() =>
  1354. {
  1355. SwitchToGameControl(startFullscreen);
  1356. SetMainContent(RendererHostControl);
  1357. RendererHostControl.Focus();
  1358. });
  1359. public static void UpdateGameMetadata(string titleId)
  1360. => ApplicationLibrary.LoadAndSaveMetaData(titleId, appMetadata => appMetadata.UpdatePostGame());
  1361. public void RefreshFirmwareStatus()
  1362. {
  1363. SystemVersion version = null;
  1364. try
  1365. {
  1366. version = ContentManager.GetCurrentFirmwareVersion();
  1367. }
  1368. catch (Exception)
  1369. {
  1370. // ignored
  1371. }
  1372. bool hasApplet = false;
  1373. if (version != null)
  1374. {
  1375. LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.StatusBarSystemVersion, version.VersionString);
  1376. hasApplet = version.Major > 3;
  1377. }
  1378. else
  1379. {
  1380. LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.StatusBarSystemVersion, "NaN");
  1381. }
  1382. IsAppletMenuActive = hasApplet;
  1383. }
  1384. public void AppHost_AppExit(object sender, EventArgs e)
  1385. {
  1386. if (IsClosing)
  1387. {
  1388. return;
  1389. }
  1390. IsGameRunning = false;
  1391. Dispatcher.UIThread.InvokeAsync(async () =>
  1392. {
  1393. ShowMenuAndStatusBar = true;
  1394. ShowContent = true;
  1395. ShowLoadProgress = false;
  1396. IsLoadingIndeterminate = false;
  1397. CanUpdate = true;
  1398. Cursor = Cursor.Default;
  1399. SetMainContent(null);
  1400. AppHost = null;
  1401. await HandleRelaunch();
  1402. });
  1403. RendererHostControl.WindowCreated -= RendererHost_Created;
  1404. RendererHostControl = null;
  1405. SelectedIcon = null;
  1406. Dispatcher.UIThread.InvokeAsync(() =>
  1407. {
  1408. Title = RyujinxApp.FormatTitle();
  1409. });
  1410. }
  1411. public async Task OpenAmiiboWindow()
  1412. {
  1413. if (AppHost.Device.System.SearchingForAmiibo(out int deviceId) && IsGameRunning)
  1414. {
  1415. string titleId = AppHost.Device.Processes.ActiveApplication.ProgramIdText.ToUpper();
  1416. AmiiboWindow window = new(ShowAll, LastScannedAmiiboId, titleId);
  1417. await window.ShowDialog(Window);
  1418. if (window.IsScanned)
  1419. {
  1420. ShowAll = window.ViewModel.ShowAllAmiibo;
  1421. LastScannedAmiiboId = window.ScannedAmiibo.GetId();
  1422. AppHost.Device.System.ScanAmiibo(deviceId, LastScannedAmiiboId, window.ViewModel.UseRandomUuid);
  1423. }
  1424. }
  1425. }
  1426. public async Task OpenBinFile()
  1427. {
  1428. if (AppHost.Device.System.SearchingForAmiibo(out _) && IsGameRunning)
  1429. {
  1430. var result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
  1431. {
  1432. Title = LocaleManager.Instance[LocaleKeys.OpenFileDialogTitle],
  1433. AllowMultiple = false,
  1434. FileTypeFilter = new List<FilePickerFileType>
  1435. {
  1436. new(LocaleManager.Instance[LocaleKeys.AllSupportedFormats])
  1437. {
  1438. Patterns = new[] { "*.bin" },
  1439. }
  1440. }
  1441. });
  1442. if (result.Count > 0)
  1443. {
  1444. AppHost.Device.System.ScanAmiiboFromBin(result[0].Path.LocalPath);
  1445. }
  1446. }
  1447. }
  1448. public void ToggleFullscreen()
  1449. {
  1450. if (Environment.TickCount64 - LastFullscreenToggle < HotKeyPressDelayMs)
  1451. {
  1452. return;
  1453. }
  1454. LastFullscreenToggle = Environment.TickCount64;
  1455. if (WindowState is not WindowState.Normal)
  1456. {
  1457. WindowState = WindowState.Normal;
  1458. Window.TitleBar.ExtendsContentIntoTitleBar = !ConfigurationState.Instance.ShowTitleBar;
  1459. if (IsGameRunning)
  1460. {
  1461. ShowMenuAndStatusBar = true;
  1462. }
  1463. }
  1464. else
  1465. {
  1466. WindowState = WindowState.FullScreen;
  1467. Window.TitleBar.ExtendsContentIntoTitleBar = true;
  1468. if (IsGameRunning)
  1469. {
  1470. ShowMenuAndStatusBar = false;
  1471. }
  1472. }
  1473. IsFullScreen = WindowState is WindowState.FullScreen;
  1474. }
  1475. public static void SaveConfig()
  1476. {
  1477. ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
  1478. }
  1479. public static async Task PerformanceCheck()
  1480. {
  1481. if (ConfigurationState.Instance.Logger.EnableTrace.Value)
  1482. {
  1483. string mainMessage = LocaleManager.Instance[LocaleKeys.DialogPerformanceCheckLoggingEnabledMessage];
  1484. string secondaryMessage = LocaleManager.Instance[LocaleKeys.DialogPerformanceCheckLoggingEnabledConfirmMessage];
  1485. UserResult result = await ContentDialogHelper.CreateLocalizedConfirmationDialog(mainMessage, secondaryMessage);
  1486. if (result == UserResult.Yes)
  1487. {
  1488. ConfigurationState.Instance.Logger.EnableTrace.Value = false;
  1489. SaveConfig();
  1490. }
  1491. }
  1492. if (!string.IsNullOrWhiteSpace(ConfigurationState.Instance.Graphics.ShadersDumpPath.Value))
  1493. {
  1494. string mainMessage = LocaleManager.Instance[LocaleKeys.DialogPerformanceCheckShaderDumpEnabledMessage];
  1495. string secondaryMessage = LocaleManager.Instance[LocaleKeys.DialogPerformanceCheckShaderDumpEnabledConfirmMessage];
  1496. UserResult result = await ContentDialogHelper.CreateLocalizedConfirmationDialog(mainMessage, secondaryMessage);
  1497. if (result == UserResult.Yes)
  1498. {
  1499. ConfigurationState.Instance.Graphics.ShadersDumpPath.Value = string.Empty;
  1500. SaveConfig();
  1501. }
  1502. }
  1503. }
  1504. public async void ProcessTrimResult(String filename, XCIFileTrimmer.OperationOutcome operationOutcome)
  1505. {
  1506. string notifyUser = operationOutcome.ToLocalisedText();
  1507. if (notifyUser != null)
  1508. {
  1509. await ContentDialogHelper.CreateWarningDialog(
  1510. LocaleManager.Instance[LocaleKeys.TrimXCIFileFailedPrimaryText],
  1511. notifyUser
  1512. );
  1513. }
  1514. else
  1515. {
  1516. switch (operationOutcome)
  1517. {
  1518. case XCIFileTrimmer.OperationOutcome.Successful:
  1519. RyujinxApp.MainWindow.LoadApplications();
  1520. break;
  1521. }
  1522. }
  1523. }
  1524. public async Task TrimXCIFile(string filename)
  1525. {
  1526. if (filename == null)
  1527. {
  1528. return;
  1529. }
  1530. var trimmer = new XCIFileTrimmer(filename, new XCITrimmerLog.MainWindow(this));
  1531. if (trimmer.CanBeTrimmed)
  1532. {
  1533. var savings = (double)trimmer.DiskSpaceSavingsB / 1024.0 / 1024.0;
  1534. var currentFileSize = (double)trimmer.FileSizeB / 1024.0 / 1024.0;
  1535. var cartDataSize = (double)trimmer.DataSizeB / 1024.0 / 1024.0;
  1536. string secondaryText = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.TrimXCIFileDialogSecondaryText, currentFileSize, cartDataSize, savings);
  1537. var result = await ContentDialogHelper.CreateConfirmationDialog(
  1538. LocaleManager.Instance[LocaleKeys.TrimXCIFileDialogPrimaryText],
  1539. secondaryText,
  1540. LocaleManager.Instance[LocaleKeys.Continue],
  1541. LocaleManager.Instance[LocaleKeys.Cancel],
  1542. LocaleManager.Instance[LocaleKeys.TrimXCIFileDialogTitle]
  1543. );
  1544. if (result == UserResult.Yes)
  1545. {
  1546. Thread XCIFileTrimThread = new(() =>
  1547. {
  1548. Dispatcher.UIThread.Post(() =>
  1549. {
  1550. StatusBarProgressStatusText = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.StatusBarXCIFileTrimming, Path.GetFileName(filename));
  1551. StatusBarProgressStatusVisible = true;
  1552. StatusBarProgressMaximum = 1;
  1553. StatusBarProgressValue = 0;
  1554. StatusBarVisible = true;
  1555. });
  1556. try
  1557. {
  1558. XCIFileTrimmer.OperationOutcome operationOutcome = trimmer.Trim();
  1559. Dispatcher.UIThread.Post(() =>
  1560. {
  1561. ProcessTrimResult(filename, operationOutcome);
  1562. });
  1563. }
  1564. finally
  1565. {
  1566. Dispatcher.UIThread.Post(() =>
  1567. {
  1568. StatusBarProgressStatusVisible = false;
  1569. StatusBarProgressStatusText = string.Empty;
  1570. StatusBarVisible = false;
  1571. });
  1572. }
  1573. })
  1574. {
  1575. Name = "GUI.XCIFileTrimmerThread",
  1576. IsBackground = true,
  1577. };
  1578. XCIFileTrimThread.Start();
  1579. }
  1580. }
  1581. }
  1582. #endregion
  1583. }
  1584. }