mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
GameData Changes
- when changing the gamedata files (add, delete, reload) it will reload all the gamedata files and repopulate the server managers. - updated the viewmodels to check for valid class names.
This commit is contained in:
parent
1bf04ed33e
commit
479e4a64dc
33 changed files with 427 additions and 305 deletions
|
|
@ -212,6 +212,8 @@
|
|||
<Compile Include="Lib\ServerRcon.cs" />
|
||||
<Compile Include="Lib\ViewConverters\EnumDescriptionTypeConverter.cs" />
|
||||
<Compile Include="Lib\ViewConverters\MapNameValueConverter.cs" />
|
||||
<Compile Include="Lib\ViewModel\GameDataFile.cs" />
|
||||
<Compile Include="Lib\ViewModel\GameDataFileList.cs" />
|
||||
<Compile Include="Lib\ViewModel\PlayerInfo.cs" />
|
||||
<Compile Include="Utils\DiscordBotHelper.cs" />
|
||||
<Compile Include="Utils\DiscordPluginHelper.cs" />
|
||||
|
|
|
|||
|
|
@ -12,12 +12,20 @@ namespace ServerManagerTool.Lib
|
|||
{
|
||||
public const string RCONINPUTMODE_COMMAND = "Command";
|
||||
|
||||
public static event EventHandler GameDataLoaded;
|
||||
|
||||
public static string MainDataFolder = Path.Combine(Environment.CurrentDirectory, Config.Default.GameDataRelativePath);
|
||||
public static string UserDataFolder = Path.Combine(Config.Default.DataPath, Config.Default.GameDataRelativePath);
|
||||
|
||||
private static MainGameData gameData = null;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
Load();
|
||||
OnGameDataLoaded();
|
||||
}
|
||||
|
||||
private static void Load()
|
||||
{
|
||||
// read static game data
|
||||
GameDataUtils.ReadAllData(out gameData, MainDataFolder, Config.Default.GameDataExtension, Config.Default.GameDataApplication);
|
||||
|
|
@ -74,6 +82,19 @@ namespace ServerManagerTool.Lib
|
|||
}
|
||||
}
|
||||
|
||||
private static void OnGameDataLoaded()
|
||||
{
|
||||
GameDataLoaded?.Invoke(null, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public static void Reload()
|
||||
{
|
||||
gameData = null;
|
||||
|
||||
Load();
|
||||
OnGameDataLoaded();
|
||||
}
|
||||
|
||||
public static string FriendlyNameForClass(string className, bool returnNullIfNotFound = false) => string.IsNullOrWhiteSpace(className) ? (returnNullIfNotFound ? null : string.Empty) : GlobalizedApplication.Instance.GetResourceString(className) ?? (returnNullIfNotFound ? null : className);
|
||||
|
||||
#region Game Maps
|
||||
|
|
|
|||
51
src/ConanServerManager/Lib/ViewModel/GameDataFile.cs
Normal file
51
src/ConanServerManager/Lib/ViewModel/GameDataFile.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class GameDataFile : DependencyObject
|
||||
{
|
||||
public static readonly DependencyProperty CreatedDateProperty = DependencyProperty.Register(nameof(CreatedDate), typeof(DateTime), typeof(GameDataFile), new PropertyMetadata(DateTime.MinValue));
|
||||
public static readonly DependencyProperty FileProperty = DependencyProperty.Register(nameof(File), typeof(string), typeof(GameDataFile), new PropertyMetadata(string.Empty));
|
||||
public static readonly DependencyProperty FileNameProperty = DependencyProperty.Register(nameof(FileName), typeof(string), typeof(GameDataFile), new PropertyMetadata(string.Empty));
|
||||
public static readonly DependencyProperty IsUserDataProperty = DependencyProperty.Register(nameof(IsUserData), typeof(bool), typeof(GameDataFile), new PropertyMetadata(true));
|
||||
public static readonly DependencyProperty VersionProperty = DependencyProperty.Register(nameof(Version), typeof(string), typeof(GameDataFile), new PropertyMetadata(string.Empty));
|
||||
public static readonly DependencyProperty HasErrorProperty = DependencyProperty.Register(nameof(HasError), typeof(bool), typeof(GameDataFile), new PropertyMetadata(false));
|
||||
|
||||
public DateTime CreatedDate
|
||||
{
|
||||
get { return (DateTime)GetValue(CreatedDateProperty); }
|
||||
set { SetValue(CreatedDateProperty, value); }
|
||||
}
|
||||
|
||||
public string File
|
||||
{
|
||||
get { return (string)GetValue(FileProperty); }
|
||||
set { SetValue(FileProperty, value); }
|
||||
}
|
||||
|
||||
public string FileName
|
||||
{
|
||||
get { return (string)GetValue(FileNameProperty); }
|
||||
set { SetValue(FileNameProperty, value); }
|
||||
}
|
||||
|
||||
public bool IsUserData
|
||||
{
|
||||
get { return (bool)GetValue(IsUserDataProperty); }
|
||||
set { SetValue(IsUserDataProperty, value); }
|
||||
}
|
||||
|
||||
public string Version
|
||||
{
|
||||
get { return (string)GetValue(VersionProperty); }
|
||||
set { SetValue(VersionProperty, value); }
|
||||
}
|
||||
|
||||
public bool HasError
|
||||
{
|
||||
get { return (bool)GetValue(HasErrorProperty); }
|
||||
set { SetValue(HasErrorProperty, value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
12
src/ConanServerManager/Lib/ViewModel/GameDataFileList.cs
Normal file
12
src/ConanServerManager/Lib/ViewModel/GameDataFileList.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
using ServerManagerTool.Common.Model;
|
||||
|
||||
namespace ServerManagerTool.Lib.ViewModel
|
||||
{
|
||||
public class GameDataFileList : SortableObservableCollection<GameDataFile>
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{nameof(GameDataFile)} - {Count}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -63,6 +63,8 @@ namespace ServerManagerTool
|
|||
}
|
||||
|
||||
this.DataContext = this;
|
||||
|
||||
GameData.GameDataLoaded += GameData_GameDataLoaded;
|
||||
}
|
||||
|
||||
public App AppInstance
|
||||
|
|
@ -398,14 +400,19 @@ namespace ServerManagerTool
|
|||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void GameData_GameDataLoaded(object sender, EventArgs e)
|
||||
{
|
||||
PopulateRconMessageModesComboBox();
|
||||
}
|
||||
|
||||
private void LanguageSelectionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
Config.CultureName = AvailableLanguages.Instance.SelectedLanguage;
|
||||
|
||||
PopulateWindowsStatesMainWindowComboBox();
|
||||
PopulateWindowsStatesServerMonitorWindowComboBox();
|
||||
PopulateRconMessageModesComboBox();
|
||||
PopulateTaskPrioritiesComboBox();
|
||||
GameData_GameDataLoaded(sender, e);
|
||||
|
||||
App.Instance.OnResourceDictionaryChanged(Config.CultureName);
|
||||
}
|
||||
|
|
@ -492,6 +499,11 @@ namespace ServerManagerTool
|
|||
}
|
||||
}
|
||||
|
||||
public void CloseControl()
|
||||
{
|
||||
GameData.GameDataLoaded -= GameData_GameDataLoaded;
|
||||
}
|
||||
|
||||
private void PopulateWindowsStatesMainWindowComboBox()
|
||||
{
|
||||
var selectedValue = this.WindowStateMainWindowComboBox?.SelectedValue ?? Config.MainWindow_WindowState;
|
||||
|
|
|
|||
|
|
@ -153,9 +153,18 @@ namespace ServerManagerTool
|
|||
|
||||
// hook into the language change event
|
||||
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent += ResourceDictionaryChangedEvent;
|
||||
GameData.GameDataLoaded += GameData_GameDataLoaded;
|
||||
}
|
||||
|
||||
#region Event Methods
|
||||
private void GameData_GameDataLoaded(object sender, EventArgs e)
|
||||
{
|
||||
this.RefreshBaseGameMapsList();
|
||||
this.RefreshBaseBranchesList();
|
||||
this.RefreshProcessPrioritiesList();
|
||||
this.RefreshServerRegionsList();
|
||||
}
|
||||
|
||||
private static void ServerPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var ssc = (ServerSettingsControl)d;
|
||||
|
|
@ -184,11 +193,8 @@ namespace ServerManagerTool
|
|||
{
|
||||
this.CurrentCulture = Thread.CurrentThread.CurrentCulture;
|
||||
|
||||
this.RefreshBaseGameMapsList();
|
||||
this.RefreshBaseBranchesList();
|
||||
this.RefreshProcessPrioritiesList();
|
||||
this.RefreshServerRegionsList();
|
||||
this.UpdateLastStartedDetails(false);
|
||||
GameData_GameDataLoaded(source, e);
|
||||
|
||||
Runtime.UpdateServerStatusString();
|
||||
}
|
||||
|
|
@ -1248,6 +1254,12 @@ namespace ServerManagerTool
|
|||
#endregion
|
||||
|
||||
#region Methods
|
||||
public void CloseControl()
|
||||
{
|
||||
GameData.GameDataLoaded -= GameData_GameDataLoaded;
|
||||
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent -= ResourceDictionaryChangedEvent;
|
||||
}
|
||||
|
||||
public void RefreshBaseGameMapsList()
|
||||
{
|
||||
var newList = new ComboBoxItemList();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,30 @@
|
|||
<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>2022-06-13T00:00:00Z</updated>
|
||||
<updated>2022-06-17T00:00:00Z</updated>
|
||||
|
||||
<entry>
|
||||
<id>urn:uuid:15FEC514-38B7-4367-BE79-1E00983E7EBB</id>
|
||||
<title>1.1.76 (1.1.76.1)</title>
|
||||
<summary>1.1.76.1</summary>
|
||||
<link href="" />
|
||||
<updated>2022-06-17T00: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>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>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
</content>
|
||||
<author>
|
||||
<name>bletch</name>
|
||||
<email>bletch1971@hotmail.com</email>
|
||||
</author>
|
||||
</entry>
|
||||
|
||||
<entry>
|
||||
<id>urn:uuid:4E189446-9861-4B64-9B27-0E3E655CD1CA</id>
|
||||
|
|
|
|||
|
|
@ -5,44 +5,21 @@
|
|||
<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>2022-06-16T00:00:00Z</updated>
|
||||
<updated>2022-06-17T00:00:00Z</updated>
|
||||
|
||||
<entry>
|
||||
<id>urn:uuid:4E189446-9861-4B64-9B27-0E3E655CD1CA</id>
|
||||
<title>1.1.75 (1.1.75.2)</title>
|
||||
<summary>1.1.75.2</summary>
|
||||
<id>urn:uuid:15FEC514-38B7-4367-BE79-1E00983E7EBB</id>
|
||||
<title>1.1.76 (1.1.76.1)</title>
|
||||
<summary>1.1.76.1</summary>
|
||||
<link href="" />
|
||||
<updated>2022-06-16T00:00:00Z</updated>
|
||||
<updated>2022-06-17T00: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>Server Monitor - added shutdown reason.</li>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
</content>
|
||||
<author>
|
||||
<name>bletch</name>
|
||||
<email>bletch1971@hotmail.com</email>
|
||||
</author>
|
||||
</entry>
|
||||
|
||||
<entry>
|
||||
<id>urn:uuid:4E189446-9861-4B64-9B27-0E3E655CD1CA</id>
|
||||
<title>1.1.75 (1.1.75.1)</title>
|
||||
<summary>1.1.75.1</summary>
|
||||
<link href="" />
|
||||
<updated>2022-06-16T00: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;">NEW</u>
|
||||
<br/>
|
||||
<ul>
|
||||
<li>Reset Server - added new button to reset your server. This will delete all server files and reset your server back to new.</li>
|
||||
<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>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||
using ServerManagerTool.Common.Model;
|
||||
using ServerManagerTool.Common.Utils;
|
||||
using ServerManagerTool.Lib;
|
||||
using ServerManagerTool.Lib.ViewModel;
|
||||
using ServerManagerTool.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -19,60 +19,6 @@ namespace ServerManagerTool
|
|||
/// </summary>
|
||||
public partial class GameDataWindow : Window
|
||||
{
|
||||
public class GameDataFileList : SortableObservableCollection<GameDataFile>
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{nameof(GameDataFile)} - {Count}";
|
||||
}
|
||||
}
|
||||
|
||||
public class GameDataFile : DependencyObject
|
||||
{
|
||||
public static readonly DependencyProperty CreatedDateProperty = DependencyProperty.Register(nameof(CreatedDate), typeof(DateTime), typeof(GameDataFile), new PropertyMetadata(DateTime.MinValue));
|
||||
public static readonly DependencyProperty FileProperty = DependencyProperty.Register(nameof(File), typeof(string), typeof(GameDataFile), new PropertyMetadata(string.Empty));
|
||||
public static readonly DependencyProperty FileNameProperty = DependencyProperty.Register(nameof(FileName), typeof(string), typeof(GameDataFile), new PropertyMetadata(string.Empty));
|
||||
public static readonly DependencyProperty IsUserDataProperty = DependencyProperty.Register(nameof(IsUserData), typeof(bool), typeof(GameDataFile), new PropertyMetadata(true));
|
||||
public static readonly DependencyProperty VersionProperty = DependencyProperty.Register(nameof(Version), typeof(string), typeof(GameDataFile), new PropertyMetadata(string.Empty));
|
||||
public static readonly DependencyProperty HasErrorProperty = DependencyProperty.Register(nameof(HasError), typeof(bool), typeof(GameDataFile), new PropertyMetadata(false));
|
||||
|
||||
public DateTime CreatedDate
|
||||
{
|
||||
get { return (DateTime)GetValue(CreatedDateProperty); }
|
||||
set { SetValue(CreatedDateProperty, value); }
|
||||
}
|
||||
|
||||
public string File
|
||||
{
|
||||
get { return (string)GetValue(FileProperty); }
|
||||
set { SetValue(FileProperty, value); }
|
||||
}
|
||||
|
||||
public string FileName
|
||||
{
|
||||
get { return (string)GetValue(FileNameProperty); }
|
||||
set { SetValue(FileNameProperty, value); }
|
||||
}
|
||||
|
||||
public bool IsUserData
|
||||
{
|
||||
get { return (bool)GetValue(IsUserDataProperty); }
|
||||
set { SetValue(IsUserDataProperty, value); }
|
||||
}
|
||||
|
||||
public string Version
|
||||
{
|
||||
get { return (string)GetValue(VersionProperty); }
|
||||
set { SetValue(VersionProperty, value); }
|
||||
}
|
||||
|
||||
public bool HasError
|
||||
{
|
||||
get { return (bool)GetValue(HasErrorProperty); }
|
||||
set { SetValue(HasErrorProperty, value); }
|
||||
}
|
||||
}
|
||||
|
||||
private readonly GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
|
||||
|
||||
public static readonly DependencyProperty GameDataFilesProperty = DependencyProperty.Register(nameof(GameDataFiles), typeof(GameDataFileList), typeof(GameDataWindow), new PropertyMetadata(null));
|
||||
|
|
@ -117,6 +63,7 @@ namespace ServerManagerTool
|
|||
try
|
||||
{
|
||||
AddGameDataFile(GameData.UserDataFolder, dialog.FileName);
|
||||
GameData.Reload();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -135,6 +82,7 @@ namespace ServerManagerTool
|
|||
{
|
||||
DeleteAllGameDataFiles(GameData.UserDataFolder);
|
||||
}
|
||||
GameData.Reload();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -166,6 +114,7 @@ namespace ServerManagerTool
|
|||
try
|
||||
{
|
||||
ReloadGameDataFiles();
|
||||
GameData.Reload();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -182,6 +131,7 @@ namespace ServerManagerTool
|
|||
{
|
||||
var gameDataItem = ((GameDataFile)((Button)e.Source).DataContext);
|
||||
DeleteGameDataFile(gameDataItem.File, true);
|
||||
GameData.Reload();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -246,6 +246,13 @@ namespace ServerManagerTool
|
|||
this.Activate();
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent -= ResourceDictionaryChangedEvent;
|
||||
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
if (DiscordBotHelper.HasRunningCommands)
|
||||
|
|
|
|||
|
|
@ -238,6 +238,7 @@ namespace ServerManagerTool
|
|||
|
||||
// hook into the language change event
|
||||
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent += ResourceDictionaryChangedEvent;
|
||||
GameData.GameDataLoaded += GameData_GameDataLoaded;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
|
@ -554,13 +555,19 @@ namespace ServerManagerTool
|
|||
return window;
|
||||
}
|
||||
|
||||
private void ResourceDictionaryChangedEvent(object source, ResourceDictionaryChangedEventArgs e)
|
||||
private void GameData_GameDataLoaded(object sender, EventArgs e)
|
||||
{
|
||||
PopulateRconInputModesComboBox();
|
||||
}
|
||||
|
||||
private void ResourceDictionaryChangedEvent(object source, ResourceDictionaryChangedEventArgs e)
|
||||
{
|
||||
GameData_GameDataLoaded(source, e);
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
GameData.GameDataLoaded -= GameData_GameDataLoaded;
|
||||
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent -= ResourceDictionaryChangedEvent;
|
||||
|
||||
if (this.RconParameters?.Server?.Runtime != null)
|
||||
|
|
|
|||
|
|
@ -13,24 +13,14 @@ namespace ServerManagerTool
|
|||
/// </summary>
|
||||
public partial class SettingsWindow : Window
|
||||
{
|
||||
public static readonly DependencyProperty AppInstanceProperty = DependencyProperty.Register(nameof(AppInstance), typeof(App), typeof(SettingsWindow), new PropertyMetadata(null));
|
||||
|
||||
private readonly GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
|
||||
|
||||
public SettingsWindow()
|
||||
{
|
||||
this.AppInstance = App.Instance;
|
||||
|
||||
InitializeComponent();
|
||||
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
|
||||
}
|
||||
|
||||
public App AppInstance
|
||||
{
|
||||
get { return GetValue(AppInstanceProperty) as App; }
|
||||
set { SetValue(AppInstanceProperty, value); }
|
||||
}
|
||||
|
||||
private void SettingsWindow_Closing(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (!globalSettingsControl.IsEnabled)
|
||||
|
|
@ -39,6 +29,7 @@ namespace ServerManagerTool
|
|||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
globalSettingsControl.CloseControl();
|
||||
globalSettingsControl.ApplyChangesToConfig();
|
||||
|
||||
if (SecurityUtils.IsAdministrator())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue