mirror of
https://github.com/Tribufu/ServerManagers
synced 2026-08-08 12:11:05 +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);
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ namespace ServerManagerTool.Lib
|
|||
set { SetValue(QueryPortProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ServerMapProperty = DependencyProperty.Register(nameof(ServerMap), typeof(string), typeof(ServerProfile), new PropertyMetadata("ConanSandbox"));
|
||||
public static readonly DependencyProperty ServerMapProperty = DependencyProperty.Register(nameof(ServerMap), typeof(string), typeof(ServerProfile), new PropertyMetadata(String.Empty));
|
||||
[DataMember]
|
||||
public string ServerMap
|
||||
{
|
||||
|
|
@ -225,7 +225,7 @@ namespace ServerManagerTool.Lib
|
|||
}
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ServerMapSaveFileNameProperty = DependencyProperty.Register(nameof(ServerMapSaveFileName), typeof(string), typeof(ServerProfile), new PropertyMetadata("game.db"));
|
||||
public static readonly DependencyProperty ServerMapSaveFileNameProperty = DependencyProperty.Register(nameof(ServerMapSaveFileName), typeof(string), typeof(ServerProfile), new PropertyMetadata(String.Empty));
|
||||
[DataMember]
|
||||
public string ServerMapSaveFileName
|
||||
{
|
||||
|
|
@ -710,10 +710,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.ServerGameConfigFile);
|
||||
if (File.Exists(serverConfigFile))
|
||||
{
|
||||
LoadFromConfigFiles(serverConfigFile, this, exclusions: null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LoadServerFiles(true, true);
|
||||
SetupServerFilesWatcher();
|
||||
}
|
||||
|
|
@ -903,12 +916,12 @@ namespace ServerManagerTool.Lib
|
|||
return LoadFromProfileFile(file, profile);
|
||||
|
||||
var filePath = Path.GetDirectoryName(file);
|
||||
profile = LoadFromConfigFiles(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);
|
||||
}
|
||||
|
||||
return profile;
|
||||
|
|
@ -927,6 +940,13 @@ namespace ServerManagerTool.Lib
|
|||
profile = profile ?? new ServerProfile();
|
||||
iniFile.Deserialize(profile, exclusions);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(profile.ServerModIds) && iniPath.EndsWith(Config.Default.ServerConfigRelativePath))
|
||||
{
|
||||
var installDirectory = iniPath.Replace(Config.Default.ServerConfigRelativePath, string.Empty).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||
var modIds = ModUtils.ReadModListFile(installDirectory);
|
||||
profile.ServerModIds = string.Join(",", modIds);
|
||||
}
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue