-
Notifications
You must be signed in to change notification settings - Fork 51
/
SettingsForm.cs
250 lines (218 loc) · 10.3 KB
/
SettingsForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
using JR.Utils.GUI.Forms;
using System;
using System.Diagnostics;
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)
{
CenterToParent();
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;
nodevicemodeBox.Checked = Properties.Settings.Default.nodevicemode;
bmbfBox.Checked = Properties.Settings.Default.BMBFchecked;
AutoReinstBox.Checked = Properties.Settings.Default.AutoReinstall;
trailersOn.Checked = Properties.Settings.Default.TrailersOn;
singleThread.Checked = Properties.Settings.Default.singleThreadMode;
virtualFilesystemCompatibilityCheckbox.Checked = Properties.Settings.Default.virtualFilesystemCompatibility;
if (nodevicemodeBox.Checked)
{
deleteAfterInstallCheckBox.Checked = false;
deleteAfterInstallCheckBox.Enabled = false;
}
}
private void intToolTips()
{
ToolTip checkForUpdatesToolTip = new ToolTip();
checkForUpdatesToolTip.SetToolTip(checkForUpdatesCheckBox, "If this is checked, the software will check for available updates");
ToolTip enableMessageBoxesToolTip = new ToolTip();
enableMessageBoxesToolTip.SetToolTip(enableMessageBoxesCheckBox, "If this is checked, the software will display message boxes after every completed task");
ToolTip deleteAfterInstallToolTip = new ToolTip();
deleteAfterInstallToolTip.SetToolTip(deleteAfterInstallCheckBox, "If this is checked, the software will delete all game files after downloading and installing a game from a remote server");
}
public void btnUploadDebug_click(object sender, EventArgs e)
{
if (File.Exists($"{Properties.Settings.Default.CurrentLogPath}"))
{
string UUID = SideloaderUtilities.UUID();
string debugLogPath = $"{Environment.CurrentDirectory}\\{UUID}.log";
System.IO.File.Copy("debuglog.txt", debugLogPath);
Clipboard.SetText(UUID);
_ = RCLONE.runRcloneCommand_UploadConfig($"copy \"{debugLogPath}\" RSL-gameuploads:DebugLogs");
_ = MessageBox.Show($"Your debug log has been copied to the server. ID: {UUID}");
}
}
public void btnResetDebug_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");
}
}
//Apply settings
private void applyButton_Click(object sender, EventArgs e)
{
Properties.Settings.Default.Save();
_ = FlexibleMessageBox.Show(this, "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();
Properties.Settings.Default.customDownloadDir = false;
Properties.Settings.Default.customBackupDir = false;
MainForm.backupFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), $"Rookie Backups");
Properties.Settings.Default.downloadDir = Environment.CurrentDirectory.ToString();
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)
{
Close();
}
}
private void SettingsForm_Leave(object sender, EventArgs e)
{
Close();
}
private void Form_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
Close();
}
}
protected override bool ProcessDialogKey(Keys keyData)
{
if (Form.ModifierKeys == Keys.None && keyData == Keys.Escape)
{
Close();
return true;
}
return base.ProcessDialogKey(keyData);
}
private void nodevicemodeBox_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.nodevicemode = nodevicemodeBox.Checked;
if (!nodevicemodeBox.Checked)
{
deleteAfterInstallCheckBox.Checked = true;
Properties.Settings.Default.deleteAllAfterInstall = true;
deleteAfterInstallCheckBox.Enabled = true;
}
else
{
deleteAfterInstallCheckBox.Checked = false;
Properties.Settings.Default.deleteAllAfterInstall = false;
deleteAfterInstallCheckBox.Enabled = false;
}
Properties.Settings.Default.Save();
}
private void bmbfBox_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.BMBFchecked = bmbfBox.Checked;
Properties.Settings.Default.Save();
}
private void AutoReinstBox_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.AutoReinstall = AutoReinstBox.Checked;
Properties.Settings.Default.Save();
}
private void trailersOn_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.TrailersOn = trailersOn.Checked;
Properties.Settings.Default.Save();
}
private void AutoReinstBox_Click(object sender, EventArgs e)
{
if (AutoReinstBox.Checked)
{
DialogResult dialogResult = FlexibleMessageBox.Show(this, "WARNING: This box enables automatic reinstall when installs fail,\ndue to some games not allowing " +
"access to their save data (less than 5%) this\noption can lead to losing your progress." +
" However with this option\nchecked when installs fail you won't have to agree to a prompt to perform\nthe reinstall. " +
"(ideal when installing from a queue).\n\nNOTE: If your usb/wireless adb connection is extremely slow this option can\ncause larger" +
"apk file installations to fail. Enable anyway?", "WARNING", MessageBoxButtons.OKCancel);
if (dialogResult == DialogResult.Cancel)
{
AutoReinstBox.Checked = false;
}
}
}
private void btnOpenDebug_Click(object sender, EventArgs e)
{
if (File.Exists($"{Environment.CurrentDirectory}\\debuglog.txt"))
{
_ = Process.Start($"{Environment.CurrentDirectory}\\debuglog.txt");
}
}
private void setDownloadDirectory_Click(object sender, EventArgs e)
{
if (downloadDirectorySetter.ShowDialog() == DialogResult.OK)
{
Properties.Settings.Default.customDownloadDir = true;
Properties.Settings.Default.downloadDir = downloadDirectorySetter.SelectedPath;
Properties.Settings.Default.Save();
}
}
private void setBackupDirectory_Click(object sender, EventArgs e)
{
if (backupDirectorySetter.ShowDialog() == DialogResult.OK)
{
Properties.Settings.Default.customBackupDir = true;
Properties.Settings.Default.backupDir = backupDirectorySetter.SelectedPath;
MainForm.backupFolder = Properties.Settings.Default.backupDir;
Properties.Settings.Default.Save();
}
}
private void singleThread_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.singleThreadMode = singleThread.Checked;
Properties.Settings.Default.Save();
}
private void virtualFilesystemCompatibilityCheckbox_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.virtualFilesystemCompatibility = virtualFilesystemCompatibilityCheckbox.Checked;
Properties.Settings.Default.Save();
}
}
}