Skip to content

Commit

Permalink
Merge pull request #42 from sn0rkle/Framework4.8Update
Browse files Browse the repository at this point in the history
Framework4.8 update
  • Loading branch information
Razzmatazzz authored Jul 7, 2022
2 parents 3184ac3 + de3f308 commit 321cefe
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 58 deletions.
20 changes: 10 additions & 10 deletions App.config
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ValheimSaveShield.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="ValheimSaveShield.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<userSettings>
<ValheimSaveShield.Properties.Settings>
Expand All @@ -17,7 +17,7 @@
<value>10</value>
</setting>
<setting name="BackupFolder" serializeAs="String">
<value />
<value/>
</setting>
<setting name="UpgradeRequired" serializeAs="String">
<value>True</value>
Expand All @@ -32,25 +32,25 @@
<value>10</value>
</setting>
<setting name="FtpIpAddress" serializeAs="String">
<value />
<value/>
</setting>
<setting name="FtpPort" serializeAs="String">
<value>21</value>
</setting>
<setting name="FtpUsername" serializeAs="String">
<value />
<value/>
</setting>
<setting name="FtpPassword" serializeAs="String">
<value />
<value/>
</setting>
<setting name="FtpFilePath" serializeAs="String">
<value />
<value/>
</setting>
<setting name="ShowMinimizeMessage" serializeAs="String">
<value>True</value>
</setting>
<setting name="FtpSaveDest" serializeAs="String">
<value />
<value/>
</setting>
<setting name="MainWindowWidth" serializeAs="String">
<value>800</value>
Expand Down
2 changes: 1 addition & 1 deletion MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
<CheckBox x:Name="chkAutoCheckUpdate" Content="Automatically check for update" HorizontalAlignment="Left" Margin="10,5" VerticalAlignment="Center" Grid.Row="1" Grid.Column="0" Checked="chkAutoCheckUpdate_Click"/>
<Button x:Name="btnAppUpdate" Content="Check Now" ToolTip="Check to see if there's a new version of this program available" HorizontalAlignment="Left" Margin="10,5,0,5" VerticalAlignment="Center" Click="btnAppUpdate_Click" Grid.Row="1" Grid.Column="1" />
</Grid>
<Button x:Name="btnExtraWorldFiles" Content="Extra world files" ToolTip="Back up additional files from your /worlds folder" HorizontalAlignment="Left" Margin="10,5" Grid.Row="4" Click="btnExtraWorldFiles_Click"/>
<Button x:Name="btnExtraWorldFiles" Content="Extra world files" ToolTip="Back up additional files from your /worlds_local folder" HorizontalAlignment="Left" Margin="10,5" Grid.Row="4" Click="btnExtraWorldFiles_Click"/>
</Grid>
</TabItem>
<TabItem x:Name="tabLog" Header="Log">
Expand Down
64 changes: 32 additions & 32 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ private bool IsBackupCurrent {
get {
foreach (var saveDirPath in Properties.Settings.Default.SaveFolders)
{
if (!Directory.Exists($@"{saveDirPath}\worlds"))
if (!Directory.Exists($@"{saveDirPath}\worlds_local"))
{
return false;
}
var worlds = Directory.GetFiles($@"{saveDirPath}\worlds", "*.db");
var worlds = Directory.GetFiles($@"{saveDirPath}\worlds_local", "*.db");
foreach (string world in worlds)
{
SaveFile save = new SaveFile(world);
Expand All @@ -60,7 +60,7 @@ private bool IsBackupCurrent {
return false;
}
}
var characters = Directory.GetFiles($@"{saveDirPath}\characters", "*.fch");
var characters = Directory.GetFiles($@"{saveDirPath}\characters_local", "*.fch");
foreach (string character in characters)
{
SaveFile save = new SaveFile(character);
Expand Down Expand Up @@ -340,29 +340,29 @@ private void loadBackups()
{
logMessage("Backups folder not found, creating...");
Directory.CreateDirectory(backupDirPath);
Directory.CreateDirectory($@"{backupDirPath}\worlds");
Directory.CreateDirectory($@"{backupDirPath}\characters");
Directory.CreateDirectory($@"{backupDirPath}\worlds_local");
Directory.CreateDirectory($@"{backupDirPath}\characters_local");
}
else
{
if (!Directory.Exists($@"{backupDirPath}\worlds"))
if (!Directory.Exists($@"{backupDirPath}\worlds_local"))
{
Directory.CreateDirectory($@"{backupDirPath}\worlds");
Directory.CreateDirectory($@"{backupDirPath}\worlds_local");
}
if (!Directory.Exists($@"{backupDirPath}\characters"))
if (!Directory.Exists($@"{backupDirPath}\characters_local"))
{
Directory.CreateDirectory($@"{backupDirPath}\characters");
Directory.CreateDirectory($@"{backupDirPath}\characters_local");
}
}

dataBackups.ItemsSource = null;
listBackups.Clear();
Dictionary<long, string> backupWorldNames = getBackupNames("World");
Dictionary<long, bool> backupWorldKeeps = getBackupKeeps("World");
string[] worldBackups = Directory.GetDirectories(backupDirPath + "\\worlds");
string[] worldBackups = Directory.GetDirectories(backupDirPath + "\\worlds_local");
foreach (string w in worldBackups)
{
//string name = w.Replace($@"{backupDirPath}\worlds", "");
//string name = w.Replace($@"{backupDirPath}\worlds_local", "");
string[] backupDirs = Directory.GetDirectories(w);
foreach (string backupDir in backupDirs)
{
Expand All @@ -387,10 +387,10 @@ private void loadBackups()

Dictionary<long, string> backupCharNames = getBackupNames("Character");
Dictionary<long, bool> backupCharKeeps = getBackupKeeps("Character");
string[] charBackups = Directory.GetDirectories($@"{backupDirPath}\characters");
string[] charBackups = Directory.GetDirectories($@"{backupDirPath}\characters_local");
foreach (string c in charBackups)
{
//string name = c.Replace($@"{backupDirPath}\characters", "");
//string name = c.Replace($@"{backupDirPath}\characters_local", "");
string[] backupDirs = Directory.GetDirectories(c);
foreach (string backupDir in backupDirs)
{
Expand Down Expand Up @@ -512,16 +512,16 @@ private void BtnBackup_Click(object sender, RoutedEventArgs e)
{
foreach (var saveDirPath in Properties.Settings.Default.SaveFolders)
{
string[] worlds = Directory.GetFiles($@"{saveDirPath}\worlds", "*.db");
string[] worlds = Directory.GetFiles($@"{saveDirPath}\worlds_local", "*.db");
foreach (string save in worlds)
{
doBackup(save);
}
if (!Directory.Exists($@"{saveDirPath}\characters"))
if (!Directory.Exists($@"{saveDirPath}\characters_local"))
{
Directory.CreateDirectory($@"{saveDirPath}\characters");
Directory.CreateDirectory($@"{saveDirPath}\characters_local");
}
string[] characters = Directory.GetFiles($@"{saveDirPath}\characters", "*.fch");
string[] characters = Directory.GetFiles($@"{saveDirPath}\characters_local", "*.fch");
foreach (string save in characters)
{
doBackup(save);
Expand Down Expand Up @@ -1080,13 +1080,13 @@ private void BtnBackupFolder_Click(object sender, RoutedEventArgs e)
}
txtBackupFolder.Text = folderName;
backupDirPath = folderName;
if (!Directory.Exists($@"{backupDirPath}\worlds"))
if (!Directory.Exists($@"{backupDirPath}\worlds_local"))
{
Directory.CreateDirectory($@"{backupDirPath}\worlds");
Directory.CreateDirectory($@"{backupDirPath}\worlds_local");
}
if (!Directory.Exists($@"{backupDirPath}\characters"))
if (!Directory.Exists($@"{backupDirPath}\characters_local"))
{
Directory.CreateDirectory($@"{backupDirPath}\characters");
Directory.CreateDirectory($@"{backupDirPath}\characters_local");
}
Properties.Settings.Default.BackupFolder = folderName;
Properties.Settings.Default.Save();
Expand Down Expand Up @@ -1203,7 +1203,7 @@ private void syncDirectoriesAsync()
Properties.Settings.Default.FtpIpAddress,
Properties.Settings.Default.FtpPort,
Properties.Settings.Default.FtpFilePath,
Properties.Settings.Default.FtpSaveDest + "\\worlds",
Properties.Settings.Default.FtpSaveDest + "\\worlds_local",
Properties.Settings.Default.FtpUsername,
Properties.Settings.Default.FtpPassword,
(WinSCP.FtpMode)Properties.Settings.Default.FtpMode
Expand Down Expand Up @@ -1361,14 +1361,14 @@ private void menuSavePathAdd_Click(object sender, RoutedEventArgs e)
return;
}
}
if (!Directory.Exists($@"{folderName}\worlds"))
if (!Directory.Exists($@"{folderName}\worlds_local"))
{
Directory.CreateDirectory($@"{folderName}\worlds");
logMessage($"{folderName} did not contain a \"worlds\" folder, so it may not be a valid save location.");
Directory.CreateDirectory($@"{folderName}\worlds_local");
logMessage($"{folderName} did not contain a \"worlds_local\" folder, so it may not be a valid save location.");
}
if (!Directory.Exists($@"{folderName}\characters"))
if (!Directory.Exists($@"{folderName}\characters_local"))
{
Directory.CreateDirectory($@"{folderName}\characters");
Directory.CreateDirectory($@"{folderName}\characters_local");
}
lstSaveFolders.Items.Add(folderName);
lblSaveFolders.Content = "Save Folders";
Expand Down Expand Up @@ -1403,14 +1403,14 @@ private void menuSavePathEdit_Click(object sender, RoutedEventArgs e)
return;
}
}
if (!Directory.Exists($@"{folderName}\worlds"))
if (!Directory.Exists($@"{folderName}\worlds_local"))
{
Directory.CreateDirectory($@"{folderName}\worlds");
logMessage($"{folderName} did not contain a \"worlds\" folder, so it may not be a valid save location.");
Directory.CreateDirectory($@"{folderName}\worlds_local");
logMessage($"{folderName} did not contain a \"worlds_local\" folder, so it may not be a valid save location.");
}
if (!Directory.Exists($@"{folderName}\characters"))
if (!Directory.Exists($@"{folderName}\characters_local"))
{
Directory.CreateDirectory($@"{folderName}\characters");
Directory.CreateDirectory($@"{folderName}\characters_local");
}
lstSaveFolders.Items[lstSaveFolders.SelectedIndex] = folderName;
foreach (var swatcher in saveWatchers)
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.4.11.0")]
[assembly: AssemblyFileVersion("0.4.11.0")]
[assembly: AssemblyVersion("0.4.13.0")]
[assembly: AssemblyFileVersion("0.4.13.0")]
2 changes: 1 addition & 1 deletion Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion SaveBackup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public string Type
{
get
{
if (new FileInfo(this.backupData.backupPath).Directory.FullName.StartsWith($@"{Properties.Settings.Default.BackupFolder}\worlds\"))
if (new FileInfo(this.backupData.backupPath).Directory.FullName.StartsWith($@"{Properties.Settings.Default.BackupFolder}\worlds_local\"))
{
return "World";
}
Expand Down
10 changes: 7 additions & 3 deletions SaveFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public string Type
{
get
{
if (new FileInfo(this.filePath).Directory.FullName.EndsWith("\\worlds"))
if (new FileInfo(this.filePath).Directory.FullName.EndsWith("\\worlds_local"))
{
return "World";
}
Expand Down Expand Up @@ -75,7 +75,7 @@ public string BackupsPath
{
get
{
return Properties.Settings.Default.BackupFolder + "\\" + this.Type.ToLower() + "s\\" + this.Name;
return Properties.Settings.Default.BackupFolder + "\\" + this.Type.ToLower() + "s_local\\" + this.Name;
}
}

Expand Down Expand Up @@ -120,6 +120,10 @@ public DateTime BackupDueTime
{
get
{
if (!Directory.Exists(this.BackupsPath))
{
Directory.CreateDirectory(this.BackupsPath);
}
string[] backups = Directory.GetDirectories(this.BackupsPath);
SaveBackup latestBackup = null;
foreach (string bdir in backups)
Expand All @@ -145,7 +149,7 @@ public SaveBackup PerformBackup()
int copyAttempts = 0;
try
{
string backupFolder = $@"{Properties.Settings.Default.BackupFolder}\{this.Type.ToLower()}s\{this.Name}\{File.GetLastWriteTime(this.FullPath).Ticks}";
string backupFolder = $@"{Properties.Settings.Default.BackupFolder}\{this.Type.ToLower()}s_local\{this.Name}\{File.GetLastWriteTime(this.FullPath).Ticks}";
if (!Directory.Exists(backupFolder))
{
Directory.CreateDirectory(backupFolder);
Expand Down
12 changes: 6 additions & 6 deletions SaveWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public SaveWatcher(string path, EventHandler<SaveWatcherLogMessageEventArgs> log
}
SavePath = path;
WorldWatcher = new FileSystemWatcher();
if (!Directory.Exists($@"{path}\worlds"))
if (!Directory.Exists($@"{path}\worlds_local"))
{
Directory.CreateDirectory($@"{path}\worlds");
Directory.CreateDirectory($@"{path}\worlds_local");
}
WorldWatcher.Path = $@"{path}\worlds";
WorldWatcher.Path = $@"{path}\worlds_local";

// Watch for changes in LastWrite times.
WorldWatcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.CreationTime | NotifyFilters.FileName;
Expand All @@ -36,11 +36,11 @@ public SaveWatcher(string path, EventHandler<SaveWatcherLogMessageEventArgs> log
WorldWatcher.Filter = "*.db";

CharacterWatcher = new FileSystemWatcher();
if (!Directory.Exists($@"{path}\characters"))
if (!Directory.Exists($@"{path}\characters_local"))
{
Directory.CreateDirectory($@"{path}\characters");
Directory.CreateDirectory($@"{path}\characters_local");
}
CharacterWatcher.Path = $@"{path}\characters";
CharacterWatcher.Path = $@"{path}\characters_local";

// Watch for changes in LastWrite and file creation times.
CharacterWatcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.CreationTime | NotifyFilters.FileName;
Expand Down
3 changes: 2 additions & 1 deletion ValheimSaveShield.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>WinExe</OutputType>
<RootNamespace>ValheimSaveShield</RootNamespace>
<AssemblyName>ValheimSaveShield</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
Expand All @@ -32,6 +32,7 @@
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down

0 comments on commit 321cefe

Please sign in to comment.