Techblox Mod Manager / Launcher
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.1KB

  1. using GCMM.Properties;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Text.RegularExpressions;
  11. using System.Threading.Tasks;
  12. using System.Windows.Forms;
  13. namespace GCMM
  14. {
  15. public partial class SettingsForm : Form
  16. {
  17. private MainForm mainForm;
  18. #if USING_STEAM
  19. private bool autopatchingEnabled;
  20. #endif
  21. public SettingsForm()
  22. {
  23. InitializeComponent();
  24. }
  25. private void Form1_Load(object sender, EventArgs e)
  26. {
  27. gamelocation.Text = Settings.Default.GamePath;
  28. useProxy.Checked = Settings.Default.UseProxy;
  29. mainForm = Owner as MainForm;
  30. #if USING_STEAM
  31. autopatchingEnabled = Settings.Default.SteamUserID != 0 && mainForm.UpdateOrGetSteamConfigToAutoStart(null);
  32. autopatching.Checked = autopatchingEnabled;
  33. #endif
  34. }
  35. private void browsebtn_Click(object sender, EventArgs e)
  36. {
  37. gamelocation.Text = mainForm.SelectGameFolder() ?? gamelocation.Text;
  38. }
  39. private void savebtn_Click(object sender, EventArgs e)
  40. {
  41. Settings.Default.GamePath = gamelocation.Text;
  42. Settings.Default.UseProxy = useProxy.Checked;
  43. #if USING_STEAM
  44. if (autopatching.Checked != autopatchingEnabled)
  45. {
  46. if (autopatching.Checked && Settings.Default.SteamUserID == 0)
  47. {
  48. var (steamPath, user) = mainForm.GetSteamLocationAndUser();
  49. if (user != 0)
  50. mainForm.DetectConfigLocationAndAutoStart(steamPath, ref user);
  51. Settings.Default.SteamUserID = user; //If it's 0 then it's no change
  52. }
  53. else
  54. mainForm.UpdateOrGetSteamConfigToAutoStart(autopatching.Checked);
  55. }
  56. #endif
  57. Settings.Default.Save();
  58. Close();
  59. }
  60. private void cancelbtn_Click(object sender, EventArgs e)
  61. {
  62. Close();
  63. }
  64. }
  65. }