SwitchSettings.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. using Gtk;
  2. using Ryujinx.Configuration;
  3. using Ryujinx.Configuration.Hid;
  4. using Ryujinx.Configuration.System;
  5. using Ryujinx.HLE.HOS.Services.Time.TimeZone;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Diagnostics;
  9. using System.IO;
  10. using System.Linq;
  11. using System.Reflection;
  12. using GUI = Gtk.Builder.ObjectAttribute;
  13. namespace Ryujinx.Ui
  14. {
  15. public class SwitchSettings : Window
  16. {
  17. private static ListStore _gameDirsBoxStore;
  18. private static bool _listeningForKeypress;
  19. private long _systemTimeOffset;
  20. #pragma warning disable CS0649
  21. #pragma warning disable IDE0044
  22. [GUI] Window _settingsWin;
  23. [GUI] CheckButton _errorLogToggle;
  24. [GUI] CheckButton _warningLogToggle;
  25. [GUI] CheckButton _infoLogToggle;
  26. [GUI] CheckButton _stubLogToggle;
  27. [GUI] CheckButton _debugLogToggle;
  28. [GUI] CheckButton _fileLogToggle;
  29. [GUI] CheckButton _guestLogToggle;
  30. [GUI] CheckButton _fsAccessLogToggle;
  31. [GUI] Adjustment _fsLogSpinAdjustment;
  32. [GUI] CheckButton _dockedModeToggle;
  33. [GUI] CheckButton _discordToggle;
  34. [GUI] CheckButton _vSyncToggle;
  35. [GUI] CheckButton _multiSchedToggle;
  36. [GUI] CheckButton _fsicToggle;
  37. [GUI] CheckButton _ignoreToggle;
  38. [GUI] CheckButton _directKeyboardAccess;
  39. [GUI] ComboBoxText _systemLanguageSelect;
  40. [GUI] ComboBoxText _systemRegionSelect;
  41. [GUI] ComboBoxText _systemTimeZoneSelect;
  42. [GUI] SpinButton _systemTimeYearSpin;
  43. [GUI] SpinButton _systemTimeMonthSpin;
  44. [GUI] SpinButton _systemTimeDaySpin;
  45. [GUI] SpinButton _systemTimeHourSpin;
  46. [GUI] SpinButton _systemTimeMinuteSpin;
  47. [GUI] Adjustment _systemTimeYearSpinAdjustment;
  48. [GUI] Adjustment _systemTimeMonthSpinAdjustment;
  49. [GUI] Adjustment _systemTimeDaySpinAdjustment;
  50. [GUI] Adjustment _systemTimeHourSpinAdjustment;
  51. [GUI] Adjustment _systemTimeMinuteSpinAdjustment;
  52. [GUI] CheckButton _custThemeToggle;
  53. [GUI] Entry _custThemePath;
  54. [GUI] ToggleButton _browseThemePath;
  55. [GUI] Label _custThemePathLabel;
  56. [GUI] TreeView _gameDirsBox;
  57. [GUI] Entry _addGameDirBox;
  58. [GUI] ToggleButton _addDir;
  59. [GUI] ToggleButton _browseDir;
  60. [GUI] ToggleButton _removeDir;
  61. [GUI] Entry _graphicsShadersDumpPath;
  62. [GUI] ComboBoxText _anisotropy;
  63. [GUI] Image _controller1Image;
  64. [GUI] ComboBoxText _controller1Type;
  65. [GUI] ToggleButton _lStickUp1;
  66. [GUI] ToggleButton _lStickDown1;
  67. [GUI] ToggleButton _lStickLeft1;
  68. [GUI] ToggleButton _lStickRight1;
  69. [GUI] ToggleButton _lStickButton1;
  70. [GUI] ToggleButton _dpadUp1;
  71. [GUI] ToggleButton _dpadDown1;
  72. [GUI] ToggleButton _dpadLeft1;
  73. [GUI] ToggleButton _dpadRight1;
  74. [GUI] ToggleButton _minus1;
  75. [GUI] ToggleButton _l1;
  76. [GUI] ToggleButton _zL1;
  77. [GUI] ToggleButton _rStickUp1;
  78. [GUI] ToggleButton _rStickDown1;
  79. [GUI] ToggleButton _rStickLeft1;
  80. [GUI] ToggleButton _rStickRight1;
  81. [GUI] ToggleButton _rStickButton1;
  82. [GUI] ToggleButton _a1;
  83. [GUI] ToggleButton _b1;
  84. [GUI] ToggleButton _x1;
  85. [GUI] ToggleButton _y1;
  86. [GUI] ToggleButton _plus1;
  87. [GUI] ToggleButton _r1;
  88. [GUI] ToggleButton _zR1;
  89. #pragma warning restore CS0649
  90. #pragma warning restore IDE0044
  91. public SwitchSettings(HLE.FileSystem.VirtualFileSystem virtualFileSystem, HLE.FileSystem.Content.ContentManager contentManager) : this(new Builder("Ryujinx.Ui.SwitchSettings.glade"), virtualFileSystem, contentManager) { }
  92. private SwitchSettings(Builder builder, HLE.FileSystem.VirtualFileSystem virtualFileSystem, HLE.FileSystem.Content.ContentManager contentManager) : base(builder.GetObject("_settingsWin").Handle)
  93. {
  94. builder.Autoconnect(this);
  95. _settingsWin.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.Icon.png");
  96. _controller1Image.Pixbuf = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.JoyCon.png", 500, 500);
  97. //Bind Events
  98. _lStickUp1.Clicked += (sender, args) => Button_Pressed(sender, args, _lStickUp1);
  99. _lStickDown1.Clicked += (sender, args) => Button_Pressed(sender, args, _lStickDown1);
  100. _lStickLeft1.Clicked += (sender, args) => Button_Pressed(sender, args, _lStickLeft1);
  101. _lStickRight1.Clicked += (sender, args) => Button_Pressed(sender, args, _lStickRight1);
  102. _lStickButton1.Clicked += (sender, args) => Button_Pressed(sender, args, _lStickButton1);
  103. _dpadUp1.Clicked += (sender, args) => Button_Pressed(sender, args, _dpadUp1);
  104. _dpadDown1.Clicked += (sender, args) => Button_Pressed(sender, args, _dpadDown1);
  105. _dpadLeft1.Clicked += (sender, args) => Button_Pressed(sender, args, _dpadLeft1);
  106. _dpadRight1.Clicked += (sender, args) => Button_Pressed(sender, args, _dpadRight1);
  107. _minus1.Clicked += (sender, args) => Button_Pressed(sender, args, _minus1);
  108. _l1.Clicked += (sender, args) => Button_Pressed(sender, args, _l1);
  109. _zL1.Clicked += (sender, args) => Button_Pressed(sender, args, _zL1);
  110. _rStickUp1.Clicked += (sender, args) => Button_Pressed(sender, args, _rStickUp1);
  111. _rStickDown1.Clicked += (sender, args) => Button_Pressed(sender, args, _rStickDown1);
  112. _rStickLeft1.Clicked += (sender, args) => Button_Pressed(sender, args, _rStickLeft1);
  113. _rStickRight1.Clicked += (sender, args) => Button_Pressed(sender, args, _rStickRight1);
  114. _rStickButton1.Clicked += (sender, args) => Button_Pressed(sender, args, _rStickButton1);
  115. _a1.Clicked += (sender, args) => Button_Pressed(sender, args, _a1);
  116. _b1.Clicked += (sender, args) => Button_Pressed(sender, args, _b1);
  117. _x1.Clicked += (sender, args) => Button_Pressed(sender, args, _x1);
  118. _y1.Clicked += (sender, args) => Button_Pressed(sender, args, _y1);
  119. _plus1.Clicked += (sender, args) => Button_Pressed(sender, args, _plus1);
  120. _r1.Clicked += (sender, args) => Button_Pressed(sender, args, _r1);
  121. _zR1.Clicked += (sender, args) => Button_Pressed(sender, args, _zR1);
  122. _controller1Type.Changed += (sender, args) => Controller_Changed(sender, args, _controller1Type.ActiveId, _controller1Image);
  123. //Setup Currents
  124. if (ConfigurationState.Instance.Logger.EnableFileLog)
  125. {
  126. _fileLogToggle.Click();
  127. }
  128. if (ConfigurationState.Instance.Logger.EnableError)
  129. {
  130. _errorLogToggle.Click();
  131. }
  132. if (ConfigurationState.Instance.Logger.EnableWarn)
  133. {
  134. _warningLogToggle.Click();
  135. }
  136. if (ConfigurationState.Instance.Logger.EnableInfo)
  137. {
  138. _infoLogToggle.Click();
  139. }
  140. if (ConfigurationState.Instance.Logger.EnableStub)
  141. {
  142. _stubLogToggle.Click();
  143. }
  144. if (ConfigurationState.Instance.Logger.EnableDebug)
  145. {
  146. _debugLogToggle.Click();
  147. }
  148. if (ConfigurationState.Instance.Logger.EnableGuest)
  149. {
  150. _guestLogToggle.Click();
  151. }
  152. if (ConfigurationState.Instance.Logger.EnableFsAccessLog)
  153. {
  154. _fsAccessLogToggle.Click();
  155. }
  156. if (ConfigurationState.Instance.System.EnableDockedMode)
  157. {
  158. _dockedModeToggle.Click();
  159. }
  160. if (ConfigurationState.Instance.EnableDiscordIntegration)
  161. {
  162. _discordToggle.Click();
  163. }
  164. if (ConfigurationState.Instance.Graphics.EnableVsync)
  165. {
  166. _vSyncToggle.Click();
  167. }
  168. if (ConfigurationState.Instance.System.EnableMulticoreScheduling)
  169. {
  170. _multiSchedToggle.Click();
  171. }
  172. if (ConfigurationState.Instance.System.EnableFsIntegrityChecks)
  173. {
  174. _fsicToggle.Click();
  175. }
  176. if (ConfigurationState.Instance.System.IgnoreMissingServices)
  177. {
  178. _ignoreToggle.Click();
  179. }
  180. if (ConfigurationState.Instance.Hid.EnableKeyboard)
  181. {
  182. _directKeyboardAccess.Click();
  183. }
  184. if (ConfigurationState.Instance.Ui.EnableCustomTheme)
  185. {
  186. _custThemeToggle.Click();
  187. }
  188. TimeZoneContentManager timeZoneContentManager = new TimeZoneContentManager();
  189. timeZoneContentManager.InitializeInstance(virtualFileSystem, contentManager, LibHac.FsSystem.IntegrityCheckLevel.None);
  190. List<string> locationNames = timeZoneContentManager.LocationNameCache.ToList();
  191. locationNames.Sort();
  192. foreach (string locationName in locationNames)
  193. {
  194. _systemTimeZoneSelect.Append(locationName, locationName);
  195. }
  196. _systemLanguageSelect.SetActiveId(ConfigurationState.Instance.System.Language.Value.ToString());
  197. _systemRegionSelect .SetActiveId(ConfigurationState.Instance.System.Region.Value.ToString());
  198. _systemTimeZoneSelect.SetActiveId(timeZoneContentManager.SanityCheckDeviceLocationName());
  199. _anisotropy .SetActiveId(ConfigurationState.Instance.Graphics.MaxAnisotropy.Value.ToString());
  200. _controller1Type .SetActiveId(ConfigurationState.Instance.Hid.ControllerType.Value.ToString());
  201. Controller_Changed(null, null, _controller1Type.ActiveId, _controller1Image);
  202. _lStickUp1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.StickUp.ToString();
  203. _lStickDown1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.StickDown.ToString();
  204. _lStickLeft1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.StickLeft.ToString();
  205. _lStickRight1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.StickRight.ToString();
  206. _lStickButton1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.StickButton.ToString();
  207. _dpadUp1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.DPadUp.ToString();
  208. _dpadDown1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.DPadDown.ToString();
  209. _dpadLeft1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.DPadLeft.ToString();
  210. _dpadRight1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.DPadRight.ToString();
  211. _minus1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.ButtonMinus.ToString();
  212. _l1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.ButtonL.ToString();
  213. _zL1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon.ButtonZl.ToString();
  214. _rStickUp1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.StickUp.ToString();
  215. _rStickDown1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.StickDown.ToString();
  216. _rStickLeft1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.StickLeft.ToString();
  217. _rStickRight1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.StickRight.ToString();
  218. _rStickButton1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.StickButton.ToString();
  219. _a1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.ButtonA.ToString();
  220. _b1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.ButtonB.ToString();
  221. _x1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.ButtonX.ToString();
  222. _y1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.ButtonY.ToString();
  223. _plus1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.ButtonPlus.ToString();
  224. _r1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.ButtonR.ToString();
  225. _zR1.Label = ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon.ButtonZr.ToString();
  226. _custThemePath.Buffer.Text = ConfigurationState.Instance.Ui.CustomThemePath;
  227. _graphicsShadersDumpPath.Buffer.Text = ConfigurationState.Instance.Graphics.ShadersDumpPath;
  228. _fsLogSpinAdjustment.Value = ConfigurationState.Instance.System.FsGlobalAccessLogMode;
  229. _systemTimeOffset = ConfigurationState.Instance.System.SystemTimeOffset;
  230. _gameDirsBox.AppendColumn("", new CellRendererText(), "text", 0);
  231. _gameDirsBoxStore = new ListStore(typeof(string));
  232. _gameDirsBox.Model = _gameDirsBoxStore;
  233. foreach (string gameDir in ConfigurationState.Instance.Ui.GameDirs.Value)
  234. {
  235. _gameDirsBoxStore.AppendValues(gameDir);
  236. }
  237. if (_custThemeToggle.Active == false)
  238. {
  239. _custThemePath.Sensitive = false;
  240. _custThemePathLabel.Sensitive = false;
  241. _browseThemePath.Sensitive = false;
  242. }
  243. _listeningForKeypress = false;
  244. //Setup system time spinners
  245. UpdateSystemTimeSpinners();
  246. }
  247. private void UpdateSystemTimeSpinners()
  248. {
  249. //Unbind system time spin events
  250. _systemTimeYearSpin.ValueChanged -= SystemTimeSpin_ValueChanged;
  251. _systemTimeMonthSpin.ValueChanged -= SystemTimeSpin_ValueChanged;
  252. _systemTimeDaySpin.ValueChanged -= SystemTimeSpin_ValueChanged;
  253. _systemTimeHourSpin.ValueChanged -= SystemTimeSpin_ValueChanged;
  254. _systemTimeMinuteSpin.ValueChanged -= SystemTimeSpin_ValueChanged;
  255. //Apply actual system time + SystemTimeOffset to system time spin buttons
  256. DateTime systemTime = DateTime.Now.AddSeconds(_systemTimeOffset);
  257. _systemTimeYearSpinAdjustment.Value = systemTime.Year;
  258. _systemTimeMonthSpinAdjustment.Value = systemTime.Month;
  259. _systemTimeDaySpinAdjustment.Value = systemTime.Day;
  260. _systemTimeHourSpinAdjustment.Value = systemTime.Hour;
  261. _systemTimeMinuteSpinAdjustment.Value = systemTime.Minute;
  262. //Format spin buttons text to include leading zeros
  263. _systemTimeYearSpin.Text = systemTime.Year.ToString("0000");
  264. _systemTimeMonthSpin.Text = systemTime.Month.ToString("00");
  265. _systemTimeDaySpin.Text = systemTime.Day.ToString("00");
  266. _systemTimeHourSpin.Text = systemTime.Hour.ToString("00");
  267. _systemTimeMinuteSpin.Text = systemTime.Minute.ToString("00");
  268. //Bind system time spin button events
  269. _systemTimeYearSpin.ValueChanged += SystemTimeSpin_ValueChanged;
  270. _systemTimeMonthSpin.ValueChanged += SystemTimeSpin_ValueChanged;
  271. _systemTimeDaySpin.ValueChanged += SystemTimeSpin_ValueChanged;
  272. _systemTimeHourSpin.ValueChanged += SystemTimeSpin_ValueChanged;
  273. _systemTimeMinuteSpin.ValueChanged += SystemTimeSpin_ValueChanged;
  274. }
  275. //Events
  276. private void SystemTimeSpin_ValueChanged(Object sender, EventArgs e)
  277. {
  278. int year = _systemTimeYearSpin.ValueAsInt;
  279. int month = _systemTimeMonthSpin.ValueAsInt;
  280. int day = _systemTimeDaySpin.ValueAsInt;
  281. int hour = _systemTimeHourSpin.ValueAsInt;
  282. int minute = _systemTimeMinuteSpin.ValueAsInt;
  283. if (!DateTime.TryParse(year + "-" + month + "-" + day + " " + hour + ":" + minute, out DateTime newTime))
  284. {
  285. UpdateSystemTimeSpinners();
  286. return;
  287. }
  288. newTime = newTime.AddSeconds(DateTime.Now.Second).AddMilliseconds(DateTime.Now.Millisecond);
  289. long systemTimeOffset = (long)Math.Ceiling((newTime - DateTime.Now).TotalMinutes) * 60L;
  290. if (_systemTimeOffset != systemTimeOffset)
  291. {
  292. _systemTimeOffset = systemTimeOffset;
  293. UpdateSystemTimeSpinners();
  294. }
  295. }
  296. private void Button_Pressed(object sender, EventArgs args, ToggleButton button)
  297. {
  298. if (_listeningForKeypress == false)
  299. {
  300. KeyPressEvent += On_KeyPress;
  301. _listeningForKeypress = true;
  302. void On_KeyPress(object o, KeyPressEventArgs keyPressed)
  303. {
  304. string key = keyPressed.Event.Key.ToString();
  305. string capKey = key.First().ToString().ToUpper() + key.Substring(1);
  306. if (Enum.IsDefined(typeof(Configuration.Hid.Key), capKey))
  307. {
  308. button.Label = capKey;
  309. }
  310. else if (GdkToOpenTkInput.ContainsKey(key))
  311. {
  312. button.Label = GdkToOpenTkInput[key];
  313. }
  314. else
  315. {
  316. button.Label = "Space";
  317. }
  318. button.SetStateFlags(0, true);
  319. KeyPressEvent -= On_KeyPress;
  320. _listeningForKeypress = false;
  321. }
  322. }
  323. else
  324. {
  325. button.SetStateFlags(0, true);
  326. }
  327. }
  328. private void Controller_Changed(object sender, EventArgs args, string controllerType, Image controllerImage)
  329. {
  330. switch (controllerType)
  331. {
  332. case "ProController":
  333. controllerImage.Pixbuf = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.ProCon.png", 500, 500);
  334. break;
  335. case "NpadLeft":
  336. controllerImage.Pixbuf = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.BlueCon.png", 500, 500);
  337. break;
  338. case "NpadRight":
  339. controllerImage.Pixbuf = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.RedCon.png", 500, 500);
  340. break;
  341. default:
  342. controllerImage.Pixbuf = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.JoyCon.png", 500, 500);
  343. break;
  344. }
  345. }
  346. private void AddDir_Pressed(object sender, EventArgs args)
  347. {
  348. if (Directory.Exists(_addGameDirBox.Buffer.Text))
  349. {
  350. _gameDirsBoxStore.AppendValues(_addGameDirBox.Buffer.Text);
  351. }
  352. _addDir.SetStateFlags(0, true);
  353. }
  354. private void BrowseDir_Pressed(object sender, EventArgs args)
  355. {
  356. FileChooserDialog fileChooser = new FileChooserDialog("Choose the game directory to add to the list", this, FileChooserAction.SelectFolder, "Cancel", ResponseType.Cancel, "Add", ResponseType.Accept);
  357. if (fileChooser.Run() == (int)ResponseType.Accept)
  358. {
  359. _gameDirsBoxStore.AppendValues(fileChooser.Filename);
  360. }
  361. fileChooser.Dispose();
  362. _browseDir.SetStateFlags(0, true);
  363. }
  364. private void RemoveDir_Pressed(object sender, EventArgs args)
  365. {
  366. TreeSelection selection = _gameDirsBox.Selection;
  367. selection.GetSelected(out TreeIter treeIter);
  368. _gameDirsBoxStore.Remove(ref treeIter);
  369. _removeDir.SetStateFlags(0, true);
  370. }
  371. private void CustThemeToggle_Activated(object sender, EventArgs args)
  372. {
  373. _custThemePath.Sensitive = _custThemeToggle.Active;
  374. _custThemePathLabel.Sensitive = _custThemeToggle.Active;
  375. _browseThemePath.Sensitive = _custThemeToggle.Active;
  376. }
  377. private void BrowseThemeDir_Pressed(object sender, EventArgs args)
  378. {
  379. FileChooserDialog fileChooser = new FileChooserDialog("Choose the theme to load", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Select", ResponseType.Accept);
  380. fileChooser.Filter = new FileFilter();
  381. fileChooser.Filter.AddPattern("*.css");
  382. if (fileChooser.Run() == (int)ResponseType.Accept)
  383. {
  384. _custThemePath.Buffer.Text = fileChooser.Filename;
  385. }
  386. fileChooser.Dispose();
  387. _browseThemePath.SetStateFlags(0, true);
  388. }
  389. private void OpenLogsFolder_Pressed(object sender, EventArgs args)
  390. {
  391. Process.Start(new ProcessStartInfo()
  392. {
  393. FileName = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs"),
  394. UseShellExecute = true,
  395. Verb = "open"
  396. });
  397. }
  398. private void SaveToggle_Activated(object sender, EventArgs args)
  399. {
  400. List<string> gameDirs = new List<string>();
  401. _gameDirsBoxStore.GetIterFirst(out TreeIter treeIter);
  402. for (int i = 0; i < _gameDirsBoxStore.IterNChildren(); i++)
  403. {
  404. _gameDirsBoxStore.GetValue(treeIter, i);
  405. gameDirs.Add((string)_gameDirsBoxStore.GetValue(treeIter, 0));
  406. _gameDirsBoxStore.IterNext(ref treeIter);
  407. }
  408. ConfigurationState.Instance.Logger.EnableError.Value = _errorLogToggle.Active;
  409. ConfigurationState.Instance.Logger.EnableWarn.Value = _warningLogToggle.Active;
  410. ConfigurationState.Instance.Logger.EnableInfo.Value = _infoLogToggle.Active;
  411. ConfigurationState.Instance.Logger.EnableStub.Value = _stubLogToggle.Active;
  412. ConfigurationState.Instance.Logger.EnableDebug.Value = _debugLogToggle.Active;
  413. ConfigurationState.Instance.Logger.EnableGuest.Value = _guestLogToggle.Active;
  414. ConfigurationState.Instance.Logger.EnableFsAccessLog.Value = _fsAccessLogToggle.Active;
  415. ConfigurationState.Instance.Logger.EnableFileLog.Value = _fileLogToggle.Active;
  416. ConfigurationState.Instance.System.EnableDockedMode.Value = _dockedModeToggle.Active;
  417. ConfigurationState.Instance.EnableDiscordIntegration.Value = _discordToggle.Active;
  418. ConfigurationState.Instance.Graphics.EnableVsync.Value = _vSyncToggle.Active;
  419. ConfigurationState.Instance.System.EnableMulticoreScheduling.Value = _multiSchedToggle.Active;
  420. ConfigurationState.Instance.System.EnableFsIntegrityChecks.Value = _fsicToggle.Active;
  421. ConfigurationState.Instance.System.IgnoreMissingServices.Value = _ignoreToggle.Active;
  422. ConfigurationState.Instance.Hid.EnableKeyboard.Value = _directKeyboardAccess.Active;
  423. ConfigurationState.Instance.Ui.EnableCustomTheme.Value = _custThemeToggle.Active;
  424. ConfigurationState.Instance.Hid.KeyboardControls.Value.LeftJoycon = new NpadKeyboardLeft()
  425. {
  426. StickUp = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickUp1.Label),
  427. StickDown = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickDown1.Label),
  428. StickLeft = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickLeft1.Label),
  429. StickRight = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickRight1.Label),
  430. StickButton = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _lStickButton1.Label),
  431. DPadUp = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _dpadUp1.Label),
  432. DPadDown = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _dpadDown1.Label),
  433. DPadLeft = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _dpadLeft1.Label),
  434. DPadRight = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _dpadRight1.Label),
  435. ButtonMinus = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _minus1.Label),
  436. ButtonL = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _l1.Label),
  437. ButtonZl = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _zL1.Label),
  438. };
  439. ConfigurationState.Instance.Hid.KeyboardControls.Value.RightJoycon = new NpadKeyboardRight()
  440. {
  441. StickUp = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickUp1.Label),
  442. StickDown = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickDown1.Label),
  443. StickLeft = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickLeft1.Label),
  444. StickRight = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickRight1.Label),
  445. StickButton = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _rStickButton1.Label),
  446. ButtonA = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _a1.Label),
  447. ButtonB = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _b1.Label),
  448. ButtonX = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _x1.Label),
  449. ButtonY = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _y1.Label),
  450. ButtonPlus = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _plus1.Label),
  451. ButtonR = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _r1.Label),
  452. ButtonZr = (Configuration.Hid.Key)Enum.Parse(typeof(Configuration.Hid.Key), _zR1.Label),
  453. };
  454. ConfigurationState.Instance.System.Language.Value = (Language)Enum.Parse(typeof(Language), _systemLanguageSelect.ActiveId);
  455. ConfigurationState.Instance.System.Region.Value = (Configuration.System.Region)Enum.Parse(typeof(Configuration.System.Region), _systemRegionSelect.ActiveId);
  456. ConfigurationState.Instance.Graphics.MaxAnisotropy.Value = float.Parse(_anisotropy.ActiveId);
  457. ConfigurationState.Instance.Hid.ControllerType.Value = (ControllerType)Enum.Parse(typeof(ControllerType), _controller1Type.ActiveId);
  458. ConfigurationState.Instance.Ui.CustomThemePath.Value = _custThemePath.Buffer.Text;
  459. ConfigurationState.Instance.Graphics.ShadersDumpPath.Value = _graphicsShadersDumpPath.Buffer.Text;
  460. ConfigurationState.Instance.Ui.GameDirs.Value = gameDirs;
  461. ConfigurationState.Instance.System.FsGlobalAccessLogMode.Value = (int)_fsLogSpinAdjustment.Value;
  462. ConfigurationState.Instance.System.TimeZone.Value = _systemTimeZoneSelect.ActiveId;
  463. ConfigurationState.Instance.System.SystemTimeOffset.Value = _systemTimeOffset;
  464. MainWindow.SaveConfig();
  465. MainWindow.ApplyTheme();
  466. MainWindow.UpdateGameTable();
  467. Dispose();
  468. }
  469. private void CloseToggle_Activated(object sender, EventArgs args)
  470. {
  471. Dispose();
  472. }
  473. public readonly Dictionary<string, string> GdkToOpenTkInput = new Dictionary<string, string>()
  474. {
  475. { "Key_0", "Number0" },
  476. { "Key_1", "Number1" },
  477. { "Key_2", "Number2" },
  478. { "Key_3", "Number3" },
  479. { "Key_4", "Number4" },
  480. { "Key_5", "Number5" },
  481. { "Key_6", "Number6" },
  482. { "Key_7", "Number7" },
  483. { "Key_8", "Number8" },
  484. { "Key_9", "Number9" },
  485. { "equal", "Plus" },
  486. { "uparrow", "Up" },
  487. { "downarrow", "Down" },
  488. { "leftarrow", "Left" },
  489. { "rightarrow", "Right" },
  490. { "Control_L", "ControlLeft" },
  491. { "Control_R", "ControlRight" },
  492. { "Shift_L", "ShiftLeft" },
  493. { "Shift_R", "ShiftRight" },
  494. { "Alt_L", "AltLeft" },
  495. { "Alt_R", "AltRight" },
  496. { "Page_Up", "PageUp" },
  497. { "Page_Down", "PageDown" },
  498. { "KP_Enter", "KeypadEnter" },
  499. { "KP_Up", "Up" },
  500. { "KP_Down", "Down" },
  501. { "KP_Left", "Left" },
  502. { "KP_Right", "Right" },
  503. { "KP_Divide", "KeypadDivide" },
  504. { "KP_Multiply", "KeypadMultiply" },
  505. { "KP_Subtract", "KeypadSubtract" },
  506. { "KP_Add", "KeypadAdd" },
  507. { "KP_Decimal", "KeypadDecimal" },
  508. { "KP_0", "Keypad0" },
  509. { "KP_1", "Keypad1" },
  510. { "KP_2", "Keypad2" },
  511. { "KP_3", "Keypad3" },
  512. { "KP_4", "Keypad4" },
  513. { "KP_5", "Keypad5" },
  514. { "KP_6", "Keypad6" },
  515. { "KP_7", "Keypad7" },
  516. { "KP_8", "Keypad8" },
  517. { "KP_9", "Keypad9" },
  518. };
  519. }
  520. }