mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Server Import/Set Location Changes
- when changing the location, the profile will be updated to use the new config files.
This commit is contained in:
parent
a2d5c92c00
commit
7015523837
12 changed files with 100 additions and 27 deletions
|
|
@ -70,7 +70,7 @@ namespace ServerManagerTool.Lib
|
|||
|
||||
public static Server FromPath(string path)
|
||||
{
|
||||
var loadedProfile = ServerProfile.LoadFrom(path);
|
||||
var loadedProfile = ServerProfile.LoadFrom(path, profile: null);
|
||||
if (loadedProfile == null)
|
||||
return null;
|
||||
return new Server(loadedProfile);
|
||||
|
|
|
|||
|
|
@ -3511,10 +3511,23 @@ namespace ServerManagerTool.Lib
|
|||
#region Methods
|
||||
|
||||
#region Common Methods
|
||||
public void ChangeInstallationFolder(string folder)
|
||||
public void ChangeInstallationFolder(string folder, bool reloadConfigFiles)
|
||||
{
|
||||
InstallDirectory = folder;
|
||||
|
||||
if (reloadConfigFiles)
|
||||
{
|
||||
var serverConfigPath = GetProfileServerConfigDir();
|
||||
if (Directory.Exists(serverConfigPath))
|
||||
{
|
||||
var serverConfigFile = Path.Combine(serverConfigPath, Config.Default.ServerGameUserSettingsConfigFile);
|
||||
if (File.Exists(serverConfigFile))
|
||||
{
|
||||
LoadFromConfigFiles(serverConfigFile, this, exclusions: null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LoadServerFiles(true, true, true);
|
||||
SetupServerFilesWatcher();
|
||||
}
|
||||
|
|
@ -4035,12 +4048,12 @@ namespace ServerManagerTool.Lib
|
|||
return LoadFromProfileFile(file, profile);
|
||||
|
||||
var filePath = Path.GetDirectoryName(file);
|
||||
profile = LoadFromINIFiles(file, profile);
|
||||
profile = LoadFromConfigFiles(file, profile, exclusions: null);
|
||||
|
||||
if (filePath.EndsWith(Config.Default.ServerConfigRelativePath))
|
||||
{
|
||||
var installDirectory = filePath.Replace(Config.Default.ServerConfigRelativePath, string.Empty).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||
profile.ChangeInstallationFolder(installDirectory);
|
||||
profile.ChangeInstallationFolder(installDirectory, reloadConfigFiles: false);
|
||||
}
|
||||
|
||||
if (profile.PlayerLevels.Count == 0)
|
||||
|
|
@ -4075,7 +4088,7 @@ namespace ServerManagerTool.Lib
|
|||
return profile;
|
||||
}
|
||||
|
||||
public static ServerProfile LoadFromINIFiles(string file, ServerProfile profile, IEnumerable<Enum> exclusions = null)
|
||||
public static ServerProfile LoadFromConfigFiles(string file, ServerProfile profile, IEnumerable<Enum> exclusions = null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(file) || !File.Exists(file))
|
||||
return null;
|
||||
|
|
@ -4186,10 +4199,10 @@ namespace ServerManagerTool.Lib
|
|||
return null;
|
||||
}
|
||||
|
||||
var configIniPath = Path.Combine(GetProfileServerConfigDir(profile), Config.Default.ServerGameUserSettingsConfigFile);
|
||||
if (File.Exists(configIniPath))
|
||||
var serverConfigFile = Path.Combine(GetProfileServerConfigDir(profile), Config.Default.ServerGameUserSettingsConfigFile);
|
||||
if (File.Exists(serverConfigFile))
|
||||
{
|
||||
profile = LoadFromINIFiles(configIniPath, profile);
|
||||
profile = LoadFromConfigFiles(serverConfigFile, profile, exclusions: null);
|
||||
}
|
||||
|
||||
profile._lastSaveLocation = file;
|
||||
|
|
@ -4460,10 +4473,10 @@ namespace ServerManagerTool.Lib
|
|||
//
|
||||
string configDir = GetProfileServerConfigDir();
|
||||
Directory.CreateDirectory(configDir);
|
||||
SaveINIFile(configDir);
|
||||
SaveConfigFile(configDir);
|
||||
}
|
||||
|
||||
public void SaveINIFile(string profileIniDir, IEnumerable<Enum> exclusions = null)
|
||||
public void SaveConfigFile(string profileIniDir, IEnumerable<Enum> exclusions = null)
|
||||
{
|
||||
if (exclusions == null)
|
||||
exclusions = GetExclusions();
|
||||
|
|
|
|||
|
|
@ -1036,10 +1036,12 @@ namespace ServerManagerTool
|
|||
|
||||
private void SelectInstallDirectory_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new CommonOpenFileDialog();
|
||||
dialog.IsFolderPicker = true;
|
||||
dialog.Title = _globalizer.GetResourceString("ServerSettings_InstallServer_Title");
|
||||
if (!String.IsNullOrWhiteSpace(Settings.InstallDirectory))
|
||||
var dialog = new CommonOpenFileDialog
|
||||
{
|
||||
IsFolderPicker = true,
|
||||
Title = _globalizer.GetResourceString("ServerSettings_InstallServer_Title")
|
||||
};
|
||||
if (!string.IsNullOrWhiteSpace(Settings.InstallDirectory))
|
||||
{
|
||||
dialog.InitialDirectory = Settings.InstallDirectory;
|
||||
}
|
||||
|
|
@ -1047,7 +1049,10 @@ namespace ServerManagerTool
|
|||
var result = dialog.ShowDialog(Window.GetWindow(this));
|
||||
if (result == CommonFileDialogResult.Ok)
|
||||
{
|
||||
Settings.ChangeInstallationFolder(dialog.FileName);
|
||||
Settings.ServerMap = string.Empty;
|
||||
Settings.TotalConversionModId = string.Empty;
|
||||
|
||||
Settings.ChangeInstallationFolder(dialog.FileName, reloadConfigFiles: true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2047,7 +2052,7 @@ namespace ServerManagerTool
|
|||
|
||||
var configIniFile = Path.Combine(ServerProfile.GetProfileServerConfigDir(Settings), Config.Default.ServerGameUserSettingsConfigFile);
|
||||
// load only this section, using the full exclusion list
|
||||
var tempServerProfile = ServerProfile.LoadFromINIFiles(configIniFile, null, exclusions);
|
||||
var tempServerProfile = ServerProfile.LoadFromConfigFiles(configIniFile, null, exclusions);
|
||||
// perform a profile sync
|
||||
Settings.SyncSettings(ServerProfileCategory.CustomGameUserSettings, tempServerProfile);
|
||||
}
|
||||
|
|
@ -2208,7 +2213,7 @@ namespace ServerManagerTool
|
|||
|
||||
var configIniFile = Path.Combine(ServerProfile.GetProfileServerConfigDir(Settings), Config.Default.ServerGameUserSettingsConfigFile);
|
||||
// load only this section, using the full exclusion list
|
||||
var tempServerProfile = ServerProfile.LoadFromINIFiles(configIniFile, null, exclusions);
|
||||
var tempServerProfile = ServerProfile.LoadFromConfigFiles(configIniFile, null, exclusions);
|
||||
// perform a profile sync
|
||||
Settings.SyncSettings(ServerProfileCategory.CustomGameSettings, tempServerProfile);
|
||||
}
|
||||
|
|
@ -2369,7 +2374,7 @@ namespace ServerManagerTool
|
|||
|
||||
var configIniFile = Path.Combine(ServerProfile.GetProfileServerConfigDir(Settings), Config.Default.ServerGameUserSettingsConfigFile);
|
||||
// load only this section, using the full exclusion list
|
||||
var tempServerProfile = ServerProfile.LoadFromINIFiles(configIniFile, null, exclusions);
|
||||
var tempServerProfile = ServerProfile.LoadFromConfigFiles(configIniFile, null, exclusions);
|
||||
// perform a profile sync
|
||||
Settings.SyncSettings(ServerProfileCategory.CustomEngineSettings, tempServerProfile);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
<br/>
|
||||
<ul>
|
||||
<li>Gamedata Files - when adding, deleteing or reloading the gamedata files via the gamedata window, the server manager will reload them and update the settings window.</li>
|
||||
<li>Main Window - when changing the location of the server, it will reload the profile with the config settings in the new location.</li>
|
||||
<li>Main Window - added discord server button.</li>
|
||||
<li>Main Window - re-organised the buttons.</li>
|
||||
<li>pt-BR Translation file updated.</li>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
<u style="font-size: .9em;">CHANGE</u>
|
||||
<br/>
|
||||
<ul>
|
||||
<li>Main Window - when changing the location of the server, it will reload the profile with the config settings in the new location.</li>
|
||||
<li>Main Window - added discord server button.</li>
|
||||
<li>Main Window - re-organised the buttons.</li>
|
||||
</ul>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue