Skip to content

Commit 9eb0e45

Browse files
1.1
added saved paths, user error validation and some information useful to the user
1 parent b86ad31 commit 9eb0e45

File tree

7 files changed

+2616
-37
lines changed

7 files changed

+2616
-37
lines changed

eldenringsavebackup/App.config

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<configuration>
3+
<configSections>
4+
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
5+
<section name="eldenringsavebackup.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
6+
</sectionGroup>
7+
</configSections>
38
<startup>
49
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
510
</startup>
11+
<userSettings>
12+
<eldenringsavebackup.Properties.Settings>
13+
<setting name="SaveLocation" serializeAs="String">
14+
<value />
15+
</setting>
16+
<setting name="BackupLocation" serializeAs="String">
17+
<value />
18+
</setting>
19+
</eldenringsavebackup.Properties.Settings>
20+
</userSettings>
621
</configuration>

eldenringsavebackup/Form1.Designer.cs

Lines changed: 52 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eldenringsavebackup/Form1.cs

Lines changed: 86 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ public ERSaveLoader()
2323

2424
private void btnBackup_Click(object sender, EventArgs e)
2525
{
26+
// Using user set path to set variables to correct file location
2627
string sourceFile1 = $"{userPath}\\ER0000.sl2";
2728
string sourceFile2 = $"{userPath}\\ER0000.sl2.bak";
2829
string sourceFile3 = $"{userPath}\\steam_autocloud.vdf";
2930
string destinationFile1 = $"{backupPath}\\ER0000.sl2";
3031
string destinationFile2 = $"{backupPath}\\ER0000.sl2.bak";
3132
string destinationFile3 = $"{backupPath}\\steam_autocloud.vdf";
33+
34+
// Try copying the files
3235
try
3336
{
3437
File.Copy(sourceFile1, destinationFile1, true);
@@ -43,12 +46,15 @@ private void btnBackup_Click(object sender, EventArgs e)
4346

4447
private void btnLoad_Click(object sender, EventArgs e)
4548
{
49+
// Using user set path to set variables to correct file location
4650
string sourceFile1 = $"{backupPath}\\ER0000.sl2";
4751
string sourceFile2 = $"{backupPath}\\ER0000.sl2.bak";
4852
string sourceFile3 = $"{backupPath}\\steam_autocloud.vdf";
4953
string destinationFile1 = $"{userPath}\\ER0000.sl2";
5054
string destinationFile2 = $"{userPath}\\ER0000.sl2.bak";
5155
string destinationFile3 = $"{userPath}\\steam_autocloud.vdf";
56+
57+
// Try copying the files
5258
try
5359
{
5460
File.Copy(sourceFile1, destinationFile1, true);
@@ -61,27 +67,98 @@ private void btnLoad_Click(object sender, EventArgs e)
6167
}
6268
}
6369

70+
private void btnSaveLocation_Click(object sender, EventArgs e)
71+
{
72+
// Set root folder as %appdata% & show the choose folder dialog
73+
fbdSave.RootFolder = Environment.SpecialFolder.ApplicationData;
74+
fbdSave.ShowDialog();
75+
76+
// Set global variable as user selected location
77+
userPath = fbdSave.SelectedPath;
78+
79+
// Set buttons to guide user to choose backup location
80+
btnBackupLocation.Enabled = true;
81+
btnSaveLocation.Enabled = false;
82+
83+
// Save user selected location, so they dont have to choose over and over
84+
Properties.Settings.Default.SaveLocation = userPath;
85+
Properties.Settings.Default.Save();
86+
87+
// Change label to user selected path
88+
lblSaveLocation.Text = userPath;
89+
}
90+
6491
private void btnBackupLocation_Click(object sender, EventArgs e)
6592
{
93+
// Set root folder as %appdata% & show the choose folder dialog
6694
fbdBackup.RootFolder = Environment.SpecialFolder.ApplicationData;
6795
fbdBackup.ShowDialog();
96+
97+
// If user has selected the same path for backup as save, first: let them know, second: stop them.
98+
if(fbdBackup.SelectedPath == fbdSave.SelectedPath)
99+
{
100+
MessageBox.Show("Please choose/create a folder for BACKUPS, you selected your save folder twice");
101+
return;
102+
}
103+
104+
// Set global variable as user selected location
68105
backupPath = fbdBackup.SelectedPath;
106+
107+
// Set all buttons to enabled to give user full functionality
69108
btnBackup.Enabled = true;
70109
btnLoad.Enabled = true;
71110
btnSaveLocation.Enabled = true;
72111

112+
// Save user selected location, so they dont have to choose over and over
113+
Properties.Settings.Default.BackupLocation = backupPath;
114+
Properties.Settings.Default.Save();
115+
116+
// Change label to user selected path
117+
lblBackupLocation.Text = backupPath;
118+
119+
// Change label to let user know information has been saved
120+
lblLocation.Text = "Save and backup location stored and ready for use";
121+
73122
}
74123

75-
private void btnSaveLocation_Click(object sender, EventArgs e)
124+
private void ERSaveLoader_Load(object sender, EventArgs e)
76125
{
77-
fbdSave.RootFolder = Environment.SpecialFolder.ApplicationData;
78-
fbdSave.ShowDialog();
79-
userPath = fbdSave.SelectedPath;
80-
btnBackupLocation.Enabled = true;
81-
btnSaveLocation.Enabled = false;
82-
btnBackup.Enabled = false;
83-
btnLoad.Enabled = false;
84-
}
126+
//Usefull for debugging
127+
//Properties.Settings.Default.Reset();
128+
129+
//Set lbl default txt
130+
lblLocation.Text = "Please choose your save and backup location!";
85131

132+
// Check if user settings are empty, if so return program to normal state, if not, set global variables as stored paths @Credits to Jacques
133+
if (Properties.Settings.Default.SaveLocation != "")
134+
{
135+
userPath = Properties.Settings.Default.SaveLocation;
136+
}
137+
else
138+
{
139+
return;
140+
}
141+
if (Properties.Settings.Default.BackupLocation != "")
142+
{
143+
backupPath = Properties.Settings.Default.BackupLocation;
144+
}
145+
else
146+
{
147+
return;
148+
}
149+
150+
//Change to text to show user saved paths
151+
lblBackupLocation.Text = backupPath;
152+
lblSaveLocation.Text = userPath;
153+
154+
// If user has stored paths, set all buttons to enabled to give user full functionality
155+
btnBackup.Enabled = true;
156+
btnLoad.Enabled = true;
157+
btnBackupLocation.Enabled=true;
158+
btnSaveLocation.Enabled=true;
159+
160+
// Set lbl to tell user saved are locations are ready for use
161+
lblLocation.Text = "Save and backup location stored and ready for use";
162+
}
86163
}
87164
}

0 commit comments

Comments
 (0)