Fix incorrect autoUpdateLauncher state, create seperate class for checkbox

pull/35/head
Miepee 4 years ago
parent 52bbf0b408
commit 11e429ccdc

@ -0,0 +1,13 @@
using Eto.Forms;
namespace AM2RLauncher;
public class LauncherCheckbox : CheckBox
{
public LauncherCheckbox(string text, bool? checkedState = false)
{
Text = text;
Checked = checkedState;
TextColor = LauncherColors.Green;
}
}

@ -566,8 +566,8 @@ public partial class MainForm : Form
/// <summary>Gets called when <see cref="autoUpdateLauncherCheck"/> gets clicked and writes its new value to the config.</summary> /// <summary>Gets called when <see cref="autoUpdateLauncherCheck"/> gets clicked and writes its new value to the config.</summary>
private void AutoUpdateLauncherCheckChanged(object sender, EventArgs e) private void AutoUpdateLauncherCheckChanged(object sender, EventArgs e)
{ {
log.Info("Auto Update Launcher has been set to " + autoUpdateAM2RCheck.Checked + "."); log.Info("Auto Update Launcher has been set to " + autoUpdateLauncherCheck.Checked + ".");
WriteToConfig("AutoUpdateLauncher", autoUpdateAM2RCheck.Checked.Value); WriteToConfig("AutoUpdateLauncher", autoUpdateLauncherCheck.Checked.Value);
} }
/// <summary>Gets called when <see cref="hqMusicPCCheck"/> gets clicked and writes its new value to the config.</summary> /// <summary>Gets called when <see cref="hqMusicPCCheck"/> gets clicked and writes its new value to the config.</summary>

@ -475,52 +475,17 @@ public partial class MainForm : Form
languageDropDown.SelectedIndex = 0; languageDropDown.SelectedIndex = 0;
else else
languageDropDown.SelectedIndex = languageDropDown.Items.IndexOf(languageDropDown.Items.FirstOrDefault(x => x.Text.Equals(tmpLanguage))); languageDropDown.SelectedIndex = languageDropDown.Items.IndexOf(languageDropDown.Items.FirstOrDefault(x => x.Text.Equals(tmpLanguage)));
if (languageDropDown.SelectedIndex == -1) if (languageDropDown.SelectedIndex == -1)
{ {
log.Info($"User has tried to use {tmpLanguage} as a Language, but it was not found. Reverting to System Language"); log.Info($"User has tried to use {tmpLanguage} as a Language, but it was not found. Reverting to System Language");
languageDropDown.SelectedIndex = 0; languageDropDown.SelectedIndex = 0;
} }
// autoUpdateAM2R checkbox autoUpdateAM2RCheck = new LauncherCheckbox(Text.AutoUpdateAM2R, Boolean.Parse(ReadFromConfig("AutoUpdateAM2R")));
autoUpdateAM2RCheck = new CheckBox autoUpdateLauncherCheck = new LauncherCheckbox(Text.AutoUpdateLauncher, Boolean.Parse(ReadFromConfig("AutoUpdateLauncher")));
{ hqMusicPCCheck = new LauncherCheckbox(Text.HighQualityPC, Boolean.Parse(ReadFromConfig("MusicHQPC")));
Checked = Boolean.Parse(ReadFromConfig("AutoUpdateAM2R")), hqMusicAndroidCheck = new LauncherCheckbox(Text.HighQualityAndroid, Boolean.Parse(ReadFromConfig("MusicHQAndroid")));
Text = Text.AutoUpdateAM2R, profileDebugLogCheck = new LauncherCheckbox(Text.ProfileDebugCheckBox, Boolean.Parse(ReadFromConfig("ProfileDebugLog")));
TextColor = LauncherColors.Green
};
// autoUpdateLauncher checkbox
autoUpdateLauncherCheck = new CheckBox
{
Checked = Boolean.Parse(ReadFromConfig("AutoUpdateLauncher")),
Text = Text.AutoUpdateLauncher,
TextColor = LauncherColors.Green
};
// HQ music, PC
hqMusicPCCheck = new CheckBox
{
Checked = Boolean.Parse(ReadFromConfig("MusicHQPC")),
Text = Text.HighQualityPC,
TextColor = LauncherColors.Green
};
// HQ music, Android
hqMusicAndroidCheck = new CheckBox
{
Checked = Boolean.Parse(ReadFromConfig("MusicHQAndroid")),
Text = Text.HighQualityAndroid,
TextColor = LauncherColors.Green
};
// Create game debug logs
profileDebugLogCheck = new CheckBox
{
Checked = Boolean.Parse(ReadFromConfig("ProfileDebugLog")),
Text = Text.ProfileDebugCheckBox,
TextColor = LauncherColors.Green
};
// Mirror list // Mirror list
mirrorLabel = new Label mirrorLabel = new Label
@ -545,12 +510,7 @@ public partial class MainForm : Form
currentMirror = mirrorList[mirrorDropDown.SelectedIndex]; currentMirror = mirrorList[mirrorDropDown.SelectedIndex];
// Custom mirror // Custom mirror
customMirrorCheck = new CheckBox customMirrorCheck = new LauncherCheckbox(Text.CustomMirrorCheck, Boolean.Parse(ReadFromConfig("CustomMirrorEnabled")));
{
Checked = Boolean.Parse(ReadFromConfig("CustomMirrorEnabled")),
Text = Text.CustomMirrorCheck,
TextColor = LauncherColors.Green
};
customMirrorTextBox = new TextBox customMirrorTextBox = new TextBox
{ {
@ -660,13 +620,9 @@ public partial class MainForm : Form
Pages = Pages =
{ {
mainPage, mainPage,
changelogPage, changelogPage,
newsPage, newsPage,
settingsPage, settingsPage,
modSettingsPage modSettingsPage
} }
}; };

Loading…
Cancel
Save