Added reset button to the Data Directory Location.

This commit is contained in:
Brett Hewitson 2021-12-08 16:23:53 +10:00
parent cd801a2334
commit cd2dbe9628
20 changed files with 301 additions and 75 deletions

View file

@ -408,8 +408,7 @@ namespace ServerManagerTool
Config.Default.ConfigPath = Path.Combine(Config.Default.DataPath, Config.Default.ProfilesRelativePath);
System.IO.Directory.CreateDirectory(Config.Default.ConfigPath);
Config.Default.Save();
CommonConfig.Default.Save();
SaveConfigFiles();
if (restartRequired)
{
@ -508,13 +507,31 @@ namespace ServerManagerTool
MessageBox.Show(String.Format(_globalizer.GetResourceString("Application_Profile_SaveFailedLabel"), server.Profile.ProfileName, ex.Message, ex.StackTrace), _globalizer.GetResourceString("Application_Profile_SaveFailedTitle"), MessageBoxButton.OK, MessageBoxImage.Error);
}
}
Config.Default.Save();
CommonConfig.Default.Save();
App.SaveConfigFiles();
}
PluginHelper.Instance?.Dispose();
this.ApplicationStarted = false;
}
public static void SaveConfigFiles(bool includeBackup = true)
{
Config.Default.Save();
CommonConfig.Default.Save();
Config.Default.Reload();
CommonConfig.Default.Reload();
var installFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var backupFolder = includeBackup
? IOUtils.NormalizePath(string.IsNullOrWhiteSpace(Config.Default.BackupPath)
? Path.Combine(Config.Default.DataPath, Config.Default.BackupRelativePath)
: Path.Combine(Config.Default.BackupPath))
: null;
SettingsUtils.BackupUserConfigSettings(Config.Default, "userconfig.json", installFolder, backupFolder);
SettingsUtils.BackupUserConfigSettings(CommonConfig.Default, "commonconfig.json", installFolder, backupFolder);
}
}
}

View file

@ -835,6 +835,8 @@
<sys:String x:Key="GlobalSettings_DataDirectoryChange_ConfirmLabel">Changing the data directory will move any existing profiles to the new location, but it will not move any server installations. Do you still want to change this directory?</sys:String>
<sys:String x:Key="GlobalSettings_DataDirectoryChange_FailedTitle">Failed to change data directory</sys:String>
<sys:String x:Key="GlobalSettings_DataDirectoryChange_FailedLabel">There was an error changing the data directory: {0}\r\nPlease correct the error and try again, or contact technical support for assistance.</sys:String>
<sys:String x:Key="GlobalSettings_ResetDataDirectory_ConfirmTitle">Confirm Data Directory Reset</sys:String>
<sys:String x:Key="GlobalSettings_ResetDataDirectory_ConfirmLabel">Click 'Yes' to confirm you want to reset the location of the data directory. Once reset, the server manager will shutdown and you will need to restart.</sys:String>
<sys:String x:Key="GlobalSettings_DataDirectoryTitle">Select Backup Directory</sys:String>
<sys:String x:Key="GlobalSettings_CacheDirectoryTitle">Select Cache Directory</sys:String>

View file

@ -641,6 +641,11 @@
<Label Content="{DynamicResource GlobalSettings_SetLocationButtonLabel}" VerticalAlignment="Center" Margin="0,-2,0,-2"/>
</StackPanel>
</ContentControl>
<ContentControl x:Key="DataDirectoryResetButtonContent">
<StackPanel Orientation="Horizontal">
<Label Content="{DynamicResource GlobalSettings_ResetButtonLabel}" VerticalAlignment="Center" Margin="0,-2,0,-2"/>
</StackPanel>
</ContentControl>
<ContentControl x:Key="BackupDirectoryButtonContent">
<StackPanel Orientation="Horizontal">
<Label Content="{DynamicResource GlobalSettings_SetLocationButtonLabel}" VerticalAlignment="Center" Margin="0,-2,0,-2"/>

View file

@ -5,14 +5,14 @@
<title>Conan Server Manager Version Feed</title>
<subtitle>This is the Conan Server Manager release version feed.</subtitle>
<link href="http://servermanagers.freeforums.net/" />
<updated>2021-12-02T00:00:00Z</updated>
<updated>2021-12-08T00:00:00Z</updated>
<entry>
<id>urn:uuid:F8A08616-749B-48E7-87D5-D97E86AB3926</id>
<title>1.1.56 (1.1.56.1)</title>
<summary>1.1.56.1</summary>
<title>1.1.56 (1.1.56.2)</title>
<summary>1.1.56.2</summary>
<link href="" />
<updated>2021-12-06T00:00:00Z</updated>
<updated>2021-12-08T00:00:00Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
<p>
@ -21,13 +21,20 @@
<ul>
<li>
A new Discord Bot has been added to the server manager.<br/>
This new discord bot will allow you to send <font color="#0094FF">Start, Stop, Shutdown, Restart, Backup and Update</font> commands to the server manager from within your discord client.
To setup the new discord bot, open the global settings and scroll down to the Discord section.
This new discord bot will allow you to send <font color="#0094FF">Start, Stop, Shutdown, Restart, Backup and Update</font> commands to the server manager from within your discord client.<br/>
To setup the new discord bot, open the global settings and scroll down to the Discord section.<br/>
<font color="#e62919">
NOTE: This is long process to get the discord bot working, and I have created a forum post with detailed instructions how to do it.
</font>
</li>
</ul>
<u style="font-size: .9em;">CHANGE</u>
<br/>
<ul>
<li>
<li>Global Settings - Added reset button to the Data Directory Location.</li>
</li>
</ul>
</p>
</div>
</content>

View file

@ -5,7 +5,32 @@
<title>Conan Server Manager Version Feed</title>
<subtitle>This is the Conan Server Manager beta version feed.</subtitle>
<link href="http://servermanagers.freeforums.net/" />
<updated>2021-12-06T00:00:00Z</updated>
<updated>2021-12-08T00:00:00Z</updated>
<entry>
<id>urn:uuid:F8A08616-749B-48E7-87D5-D97E86AB3926</id>
<title>1.1.56 (1.1.56.2)</title>
<summary>1.1.56.2</summary>
<link href="" />
<updated>2021-12-08T00:00:00Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
<p>
<u style="font-size: .9em;">CHANGE</u>
<br/>
<ul>
<li>
<li>Global Settings - Added reset button to the Data Directory Location.</li>
</li>
</ul>
</p>
</div>
</content>
<author>
<name>bletch</name>
<email>bletch1971@hotmail.com</email>
</author>
</entry>
<entry>
<id>urn:uuid:F8A08616-749B-48E7-87D5-D97E86AB3926</id>
@ -21,8 +46,8 @@
<ul>
<li>
A new Discord Bot has been added to the server manager.<br/>
This new discord bot will allow you to send <font color="#0094FF">Start, Stop, Shutdown, Restart, Backup and Update</font> commands to the server manager from within your discord client.
To setup the new discord bot, open the global settings and scroll down to the Discord section.
This new discord bot will allow you to send <font color="#0094FF">Start, Stop, Shutdown, Restart, Backup and Update</font> commands to the server manager from within your discord client.<br/>
To setup the new discord bot, open the global settings and scroll down to the Discord section.<br/>
<font color="#e62919">
NOTE: This is long process to get the discord bot working, and I have created a forum post with detailed instructions how to do it.
</font>

View file

@ -76,6 +76,7 @@
<Label Grid.Row="4" Grid.Column="0" Margin="1" Content="{DynamicResource GlobalSettings_DataDirectoryLabel}" VerticalAlignment="Center"/>
<TextBox Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" Margin="1" Text="{Binding Config.DataPath, Mode=TwoWay}" IsReadOnly="True" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" />
<Button Grid.Row="4" Grid.Column="3" Grid.ColumnSpan="2" Margin="5,1,0,1" VerticalAlignment="Center" HorizontalAlignment="Left" Content="{DynamicResource DataDirectoryButtonContent}" Click="SetDataDir_Click" Visibility="Hidden"/>
<Button Grid.Row="4" Grid.Column="3" Grid.ColumnSpan="2" Margin="5,1,0,1" VerticalAlignment="Center" HorizontalAlignment="Right" Content="{DynamicResource DataDirectoryResetButtonContent}" Click="ResetDataDir_Click" />
<Label Grid.Row="5" Grid.Column="0" Margin="1" Content="{DynamicResource GlobalSettings_BackupDirectoryLabel}" VerticalAlignment="Center"/>
<TextBox Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="2" Margin="1" Text="{Binding Config.BackupPath, Mode=TwoWay}" IsReadOnly="True" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" />

View file

@ -213,6 +213,21 @@ namespace ServerManagerTool
}
}
private void ResetDataDir_Click(object sender, RoutedEventArgs e)
{
// Confirm the reset with the user.
if (MessageBox.Show(_globalizer.GetResourceString("GlobalSettings_ResetDataDirectory_ConfirmLabel"), _globalizer.GetResourceString("GlobalSettings_ResetDataDirectory_ConfirmTitle"), MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
return;
// Update the config
Config.Default.DataPath = string.Empty;
Config.Default.ConfigPath = string.Empty;
App.SaveConfigFiles(false);
Environment.Exit(0);
}
private void SetBackupDir_Click(object sender, RoutedEventArgs e)
{
var dialog = new CommonOpenFileDialog();
@ -393,13 +408,11 @@ namespace ServerManagerTool
{
Config.Default.Reset();
Config.Default.UpgradeConfig = false;
Config.Default.Save();
Config.Default.Reload();
CommonConfig.Default.Reset();
CommonConfig.Default.UpgradeConfig = false;
CommonConfig.Default.Save();
CommonConfig.Default.Reload();
App.SaveConfigFiles(false);
}
catch (Exception ex)
{
@ -409,7 +422,7 @@ namespace ServerManagerTool
}
finally
{
App.Current.Shutdown(exitCode);
Environment.Exit(0);
}
}

View file

@ -244,13 +244,6 @@ namespace ServerManagerTool
PlayerListWindow.CloseAllWindows();
ServerMonitorWindow.CloseAllWindows();
this.versionChecker.DisposeAsync().DoNotWait();
var installFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var backupFolder = IOUtils.NormalizePath(string.IsNullOrWhiteSpace(Config.Default.BackupPath)
? Path.Combine(Config.Default.DataPath, Config.Default.BackupRelativePath)
: Path.Combine(Config.Default.BackupPath));
SettingsUtils.BackupUserConfigSettings(Config.Default, "userconfig.json", installFolder, backupFolder);
SettingsUtils.BackupUserConfigSettings(CommonConfig.Default, "commonconfig.json", installFolder, backupFolder);
}
private void ResourceDictionaryChangedEvent(object source, ResourceDictionaryChangedEventArgs e)

View file

@ -1,5 +1,4 @@
using ServerManagerTool.Common;
using ServerManagerTool.Common.Utils;
using ServerManagerTool.Common.Utils;
using System;
using System.ComponentModel;
using System.IO;
@ -101,11 +100,7 @@ namespace ServerManagerTool
Config.Default.SteamCmd_UseAnonymousCredentials = true;
}
Config.Default.Save();
CommonConfig.Default.Save();
Config.Default.Reload();
CommonConfig.Default.Reload();
App.SaveConfigFiles(false);
base.OnClosed(e);
}