mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Added reset button to the Data Directory Location.
This commit is contained in:
parent
cd801a2334
commit
cd2dbe9628
20 changed files with 301 additions and 75 deletions
|
|
@ -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" />
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue