Files
rookie/SettingsForm.cs
Harry Fn Potter 6d3885dc48 -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

RSL 2.4.3

= Moved nouns.txt library to a more suitable location.

HFP
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEKjgtlwMyrpVu4TGfx/Rql1VoczcFAmD4T5kACgkQx/Rql1Vo
czd9Ew/+LvPnoSuNl3ynFRAjTs8Yo1r2FCY82UfWLLddYTc4waH4s2HZQkUyFBGo
emkvZUa/TZuYGzNLAB4JpPDYYONyF2LmOx8z0Pwtp1+RoEJbGe7WsZa3oF+PQ2AU
+1+hE0u8RW546uaGdzyToX3N5JnPAA2MctG0+3X5J+k8C+CHWgMJyoDnoz62b2Qb
gER2HZMBlrebJwSJto+tKeLRDk2FI4UmQDu2CQpvlwkQMwa98ORRrulaO4LOEH3I
z5S6WyxlcF0Cy4dwD5PVsx4YTHn7Rjy9HHniMYe+vv7LQOz6w+DZZQv6x1BZ2xSF
ZqS76T3x5XAVpcH2JX7gce7dTFVpft/P/C/vOVAa8E2pUp3stuUFoIyVoeWPwgvJ
3wkJFeoG4umlLQZY934Mb6Hb2tu38xlcQd/xsO3aZRPUOZBuYMcbpf8V7qv7f+p+
YDSXwI92ostB3RNkXlUy2onSWrXoLQF70lq3zaNcUeyQt6HILc80h1pXC6VWnITz
RRH9ojt6CWLyzIXKgqdKWKVJJQ5GIR0YITk4kMyGqM/CP3pUPCUKPAVbWK4ajoGA
1A2JBniQwYmCj+vkfQDpwkacK3zmYy/JRpTYdyj7BuOXjGnPpberjdd+jpgGBRCH
IeOpD/kmWaKm5lH1KmEOPGe86bhpQstOba7EsiBM4/x6QpoqVOU=
=yWnO
-----END PGP SIGNATURE-----
2021-07-21 12:49:13 -04:00

199 lines
8.0 KiB
C#

using JR.Utils.GUI.Forms;
using System;
using System.IO;
using System.Windows.Forms;
namespace AndroidSideloader
{
public partial class SettingsForm : Form
{
public SettingsForm()
{
InitializeComponent();
}
private void SettingsForm_Load(object sender, EventArgs e)
{
this.CenterToParent();
if (!string.IsNullOrEmpty(Properties.Settings.Default.CurrentLogName))
textBox1.Text = Properties.Settings.Default.CurrentCrashName;
if (!string.IsNullOrEmpty(Properties.Settings.Default.CurrentLogPath))
DebugID.Text = Properties.Settings.Default.CurrentLogName;
debuglogID.Text = "This is your DebugLogID. Click on your DebugLogID to copy it to your clipboard.";
intSettings();
intToolTips();
}
//Init form objects with values from settings
private void intSettings()
{
checkForUpdatesCheckBox.Checked = Properties.Settings.Default.checkForUpdates;
enableMessageBoxesCheckBox.Checked = Properties.Settings.Default.enableMessageBoxes;
deleteAfterInstallCheckBox.Checked = Properties.Settings.Default.deleteAllAfterInstall;
updateConfigCheckBox.Checked = Properties.Settings.Default.autoUpdateConfig;
userJsonOnGameInstall.Checked = Properties.Settings.Default.userJsonOnGameInstall;
if (Properties.Settings.Default.BandwithLimit.Length > 1)
{
BandwithTextbox.Text = Properties.Settings.Default.BandwithLimit.Remove(Properties.Settings.Default.BandwithLimit.Length - 1);
BandwithComboBox.Text = Properties.Settings.Default.BandwithLimit[Properties.Settings.Default.BandwithLimit.Length - 1].ToString();
}
}
void intToolTips()
{
ToolTip checkForUpdatesToolTip = new ToolTip();
checkForUpdatesToolTip.SetToolTip(this.checkForUpdatesCheckBox, "If this is checked, the software will check for available updates");
ToolTip enableMessageBoxesToolTip = new ToolTip();
enableMessageBoxesToolTip.SetToolTip(this.enableMessageBoxesCheckBox, "If this is checked, the software will display message boxes after every completed task");
ToolTip deleteAfterInstallToolTip = new ToolTip();
deleteAfterInstallToolTip.SetToolTip(this.deleteAfterInstallCheckBox, "If this is checked, the software will delete all game files after downloading and installing a game from a remote server");
}
public void DebugLogCopy_click(object sender, EventArgs e)
{
if (File.Exists($"{Properties.Settings.Default.CurrentLogPath}"))
{
RCLONE.runRcloneCommand($"copy \"{Properties.Settings.Default.CurrentLogPath}\" RSL-debuglogs:DebugLogs/");
MessageBox.Show($"Your debug log has been copied to the server. Please mention your DebugLog ID ({Properties.Settings.Default.CurrentLogName}) to the Mods (it has been automatically copied to your clipboard).");
}
}
public void button1_click(object sender, EventArgs e)
{
if (File.Exists($"{Properties.Settings.Default.CurrentLogPath}"))
File.Delete($"{Properties.Settings.Default.CurrentLogPath}");
if (File.Exists($"{Environment.CurrentDirectory}\\debuglog.txt"))
File.Delete($"{Environment.CurrentDirectory}\\debuglog.txt");
if (File.Exists($"{Environment.CurrentDirectory}\\nouns\\nouns.txt"))
{
string[] lines = File.ReadAllLines($"{Environment.CurrentDirectory}\\nouns\\nouns.txt");
Random r = new Random();
int x = r.Next(6806);
int y = r.Next(6806);
string randomnoun = lines[new Random(x).Next(lines.Length)];
string randomnoun2 = lines[new Random(y).Next(lines.Length)];
string combined = randomnoun + "-" + randomnoun2;
Properties.Settings.Default.CurrentLogPath = Environment.CurrentDirectory + "\\" + combined + ".txt";
Properties.Settings.Default.CurrentLogName = combined;
Properties.Settings.Default.Save();
DebugID.Text = combined;
this.Close();
SettingsForm Form = new SettingsForm();
Form.Show();
}
}
//Apply settings
private void applyButton_Click(object sender, EventArgs e)
{
if (BandwithTextbox.Text.Length > 0 && BandwithTextbox.Text != "0")
if (BandwithComboBox.SelectedIndex == -1)
{
FlexibleMessageBox.Show("You need to select something from the combobox");
return;
}
else
{
Properties.Settings.Default.BandwithLimit = $"{BandwithTextbox.Text.Replace(" ", "")}{BandwithComboBox.Text}";
}
else
Properties.Settings.Default.BandwithLimit = "";
Properties.Settings.Default.Save();
FlexibleMessageBox.Show("Settings applied!");
}
private void checkForUpdatesCheckBox_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.checkForUpdates = checkForUpdatesCheckBox.Checked;
}
private void enableMessageBoxesCheckBox_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.enableMessageBoxes = enableMessageBoxesCheckBox.Checked;
}
private void resetSettingsButton_Click(object sender, EventArgs e)
{
Properties.Settings.Default.Reset();
intSettings();
}
private void deleteAfterInstallCheckBox_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.deleteAllAfterInstall = deleteAfterInstallCheckBox.Checked;
}
private void updateConfigCheckBox_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.autoUpdateConfig = updateConfigCheckBox.Checked;
}
private void userJsonOnGameInstall_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.userJsonOnGameInstall = userJsonOnGameInstall.Checked;
}
private void SettingsForm_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Escape)
{
this.Close();
}
}
private void SettingsForm_Leave(object sender, EventArgs e)
{
this.Close();
}
private void Form_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
this.Close();
}
}
protected override bool ProcessDialogKey(Keys keyData)
{
if (Form.ModifierKeys == Keys.None && keyData == Keys.Escape)
{
this.Close();
return true;
}
return base.ProcessDialogKey(keyData);
}
private void DebugID_Click(object sender, EventArgs e)
{
if (File.Exists(Environment.CurrentDirectory + "\\" + Properties.Settings.Default.CurrentLogName + ".txt"))
Clipboard.SetText(DebugID.Text);
MessageBox.Show("DebugLogID copied to clipboard! Paste it to a moderator/helper for assistance!");
}
private void textBox1_Click(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(Properties.Settings.Default.CurrentCrashName))
{
Clipboard.SetText(textBox1.Text);
MessageBox.Show("CrashLogID copied to clipboard! Paste it to a moderator/helper for assistance!");
}
}
}
}