TBMM/GCMM/SettingsForm.cs

65 lines
2 KiB
C#
Raw Permalink Normal View History

2020-06-15 19:11:05 +00:00
using GCMM.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GCMM
{
public partial class SettingsForm : Form
{
private MainForm mainForm;
private bool autopatchingEnabled;
2020-06-15 19:11:05 +00:00
public SettingsForm()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
gamelocation.Text = Settings.Default.GamePath;
useProxy.Checked = Settings.Default.UseProxy;
2020-06-15 19:11:05 +00:00
mainForm = Owner as MainForm;
autopatchingEnabled = Settings.Default.SteamUserID != 0 && mainForm.UpdateOrGetSteamConfigToAutoStart(null);
autopatching.Checked = autopatchingEnabled;
2020-06-15 19:11:05 +00:00
}
private void browsebtn_Click(object sender, EventArgs e)
{
gamelocation.Text = mainForm.SelectGameFolder() ?? gamelocation.Text;
}
private void savebtn_Click(object sender, EventArgs e)
{
Settings.Default.GamePath = gamelocation.Text;
Settings.Default.UseProxy = useProxy.Checked;
if (autopatching.Checked != autopatchingEnabled)
{
if (autopatching.Checked && Settings.Default.SteamUserID == 0)
{
var (steamPath, user) = mainForm.GetSteamLocationAndUser();
if (user != 0)
mainForm.DetectConfigLocationAndAutoStart(steamPath, ref user);
Settings.Default.SteamUserID = user; //If it's 0 then it's no change
}
else
mainForm.UpdateOrGetSteamConfigToAutoStart(autopatching.Checked);
}
Settings.Default.Save();
2020-06-15 19:11:05 +00:00
Close();
}
private void cancelbtn_Click(object sender, EventArgs e)
{
Close();
}
}
}