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:
Brett Hewitson 2022-06-17 18:41:05 +10:00
parent 1bf04ed33e
commit 479e4a64dc
33 changed files with 427 additions and 305 deletions

View file

@ -252,6 +252,8 @@
<Compile Include="Lib\ViewConverters\MapNameValueConverter.cs" /> <Compile Include="Lib\ViewConverters\MapNameValueConverter.cs" />
<Compile Include="Lib\ViewModel\Engram.cs" /> <Compile Include="Lib\ViewModel\Engram.cs" />
<Compile Include="Lib\ViewModel\EngramSettings.cs" /> <Compile Include="Lib\ViewModel\EngramSettings.cs" />
<Compile Include="Lib\ViewModel\GameDataFile.cs" />
<Compile Include="Lib\ViewModel\GameDataFileList.cs" />
<Compile Include="Utils\DiscordBotHelper.cs" /> <Compile Include="Utils\DiscordBotHelper.cs" />
<Compile Include="Utils\DiscordPluginHelper.cs" /> <Compile Include="Utils\DiscordPluginHelper.cs" />
<Compile Include="Utils\ModUtils.cs" /> <Compile Include="Utils\ModUtils.cs" />

View file

@ -17,6 +17,8 @@ namespace ServerManagerTool.Lib
public const string RCONINPUTMODE_COMMAND = "Command"; public const string RCONINPUTMODE_COMMAND = "Command";
public static event EventHandler GameDataLoaded;
public static string MainDataFolder = Path.Combine(Environment.CurrentDirectory, Config.Default.GameDataDir); public static string MainDataFolder = Path.Combine(Environment.CurrentDirectory, Config.Default.GameDataDir);
public static string UserDataFolder = Path.Combine(Config.Default.DataDir, Config.Default.GameDataDir); public static string UserDataFolder = Path.Combine(Config.Default.DataDir, Config.Default.GameDataDir);
@ -26,6 +28,12 @@ namespace ServerManagerTool.Lib
private static MainGameData gameData = null; private static MainGameData gameData = null;
public static void Initialize() public static void Initialize()
{
Load();
OnGameDataLoaded();
}
private static void Load()
{ {
// read static game data // read static game data
GameDataUtils.ReadAllData(out gameData, MainDataFolder, Config.Default.GameDataExtension, Config.Default.GameDataApplication); GameDataUtils.ReadAllData(out gameData, MainDataFolder, Config.Default.GameDataExtension, Config.Default.GameDataApplication);
@ -174,6 +182,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); public static string FriendlyNameForClass(string className, bool returnNullIfNotFound = false) => string.IsNullOrWhiteSpace(className) ? (returnNullIfNotFound ? null : string.Empty) : GlobalizedApplication.Instance.GetResourceString(className) ?? (returnNullIfNotFound ? null : className);
#region Creatures #region Creatures

View file

@ -26,10 +26,6 @@ namespace ServerManagerTool.Lib
{ {
} }
public void UpdateForLocalization()
{
}
public void Update(bool recursive = true) public void Update(bool recursive = true)
{ {
IsEnabled = this.Count > 0; IsEnabled = this.Count > 0;
@ -118,7 +114,15 @@ namespace ServerManagerTool.Lib
resource.Update(); resource.Update();
} }
ValidStatus = IsValid ? (BaseCraftingResourceRequirements.Any(i => i.ValidStatus == "N") ? "N" : (BaseCraftingResourceRequirements.Any(i => i.ValidStatus == "W") ? "W" : "Y")) : "N"; ValidStatus = IsValid
? (BaseCraftingResourceRequirements.Any(i => i.ValidStatus == "N")
? "N"
: (BaseCraftingResourceRequirements.Any(i => i.ValidStatus == "W")
? "W"
: (GameData.HasItemForClass(ItemClassString)
? "Y"
: "W")))
: "N";
} }
} }
@ -186,7 +190,11 @@ namespace ServerManagerTool.Lib
public void Update() public void Update()
{ {
ValidStatus = IsValid ? (GameData.HasItemForClass(ResourceItemTypeString) ? "Y" : "W") : "N"; ValidStatus = IsValid
? (GameData.HasItemForClass(ResourceItemTypeString)
? "Y"
: "W")
: "N";
} }
} }
} }

View file

@ -25,10 +25,6 @@ namespace ServerManagerTool.Lib
{ {
} }
public void UpdateForLocalization()
{
}
public void Update() public void Update()
{ {
IsEnabled = this.Count > 0; IsEnabled = this.Count > 0;
@ -98,7 +94,11 @@ namespace ServerManagerTool.Lib
public void Update() public void Update()
{ {
ValidStatus = IsValid ? (GameData.HasCreatureForClass(DinoClassString) ? "Y" : "W") : "N"; ValidStatus = IsValid
? (GameData.HasCreatureForClass(DinoClassString)
? "Y"
: "W")
: "N";
} }
} }
} }

View file

@ -44,10 +44,6 @@ namespace ServerManagerTool.Lib
} }
} }
public void UpdateForLocalization()
{
}
public void Update() public void Update()
{ {
IsEnabled = this.Count > 0; IsEnabled = this.Count > 0;
@ -160,7 +156,11 @@ namespace ServerManagerTool.Lib
public void Update() public void Update()
{ {
ValidStatus = IsValid ? (GameData.HasItemForClass(ItemClassString) ? "Y" : "W") : "N"; ValidStatus = IsValid
? (GameData.HasItemForClass(ItemClassString)
? "Y"
: "W")
: "N";
} }
} }

View file

@ -72,10 +72,6 @@ namespace ServerManagerTool.Lib
} }
} }
public void UpdateForLocalization()
{
}
public void Update(bool recursive = true) public void Update(bool recursive = true)
{ {
IsEnabled = this.Count > 0; IsEnabled = this.Count > 0;
@ -226,7 +222,15 @@ namespace ServerManagerTool.Lib
itemSet.Update(recursive); itemSet.Update(recursive);
} }
ValidStatus = IsViewValid ? (ItemSets.Any(i => i.ValidStatus == "N") ? "N" : (ItemSets.Any(i => i.ValidStatus == "W") ? "W" : "Y")) : "N"; ValidStatus = IsViewValid
? (ItemSets.Any(i => i.ValidStatus == "N")
? "N"
: (ItemSets.Any(i => i.ValidStatus == "W")
? "W"
: (GameData.HasSupplyCrateForClass(SupplyCrateClassString)
? "Y"
: "W")))
: "N";
} }
} }
@ -340,7 +344,13 @@ namespace ServerManagerTool.Lib
itemEntry.Update(recursive); itemEntry.Update(recursive);
} }
ValidStatus = IsViewValid ? (ItemEntries.Any(i => i.ValidStatus == "N") ? "N" : (ItemEntries.Any(i => i.ValidStatus == "W") ? "W" : "Y")) : "N"; ValidStatus = IsViewValid
? (ItemEntries.Any(i => i.ValidStatus == "N")
? "N"
: (ItemEntries.Any(i => i.ValidStatus == "W")
? "W"
: "Y"))
: "N";
} }
} }
@ -495,7 +505,13 @@ namespace ServerManagerTool.Lib
item.Update(); item.Update();
} }
ValidStatus = IsViewValid ? (Items.Any(i => i.ValidStatus == "N") ? "N" : (Items.Any(i => i.ValidStatus == "W") ? "W" : "Y")) : "N"; ValidStatus = IsViewValid
? (Items.Any(i => i.ValidStatus == "N")
? "N"
: (Items.Any(i => i.ValidStatus == "W")
? "W"
: "Y"))
: "N";
} }
} }
} }

View file

@ -317,13 +317,5 @@ namespace ServerManagerTool.Lib.ViewModel
} }
} }
} }
public void UpdateForLocalization()
{
//foreach (var dinoSetting in this)
//{
// dinoSetting.FriendlyName = GameData.FriendlyNameForClass(dinoSetting.ClassName);
//}
}
} }
} }

View file

@ -174,10 +174,6 @@ namespace ServerManagerTool.Lib.ViewModel
} }
} }
public void UpdateForLocalization()
{
}
#region INotifyPropertyChanged #region INotifyPropertyChanged
private Dictionary<string, object> _properties = new Dictionary<string, object>(); private Dictionary<string, object> _properties = new Dictionary<string, object>();

View 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); }
}
}
}

View 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}";
}
}
}

View file

@ -195,10 +195,6 @@ namespace ServerManagerTool.Lib.ViewModel
} }
} }
public void UpdateForLocalization()
{
}
public void Update(bool recursive = true) public void Update(bool recursive = true)
{ {
foreach (var npcSpawn in this) foreach (var npcSpawn in this)
@ -307,7 +303,15 @@ namespace ServerManagerTool.Lib.ViewModel
itemSet.Update(); itemSet.Update();
} }
ValidStatus = IsViewValid ? (NPCSpawnEntrySettings.Any(i => i.ValidStatus == "N") ? "N" : (NPCSpawnEntrySettings.Any(i => i.ValidStatus == "W") ? "W" : "Y")) : "N"; ValidStatus = IsViewValid
? (NPCSpawnEntrySettings.Any(i => i.ValidStatus == "N")
? "N"
: (NPCSpawnEntrySettings.Any(i => i.ValidStatus == "W")
? "W"
: (GameData.HasMapSpawnerForClass(NPCSpawnEntriesContainerClassString)
? "Y"
: "W")))
: "N";
} }
} }
@ -354,7 +358,11 @@ namespace ServerManagerTool.Lib.ViewModel
public void Update() public void Update()
{ {
ValidStatus = IsValid ? (GameData.HasCreatureForClass(NPCClassString) ? "Y" : "W") : "N"; ValidStatus = IsValid
? (GameData.HasCreatureForClass(NPCClassString)
? "Y"
: "W")
: "N";
} }
} }
} }

View file

@ -40,7 +40,11 @@ namespace ServerManagerTool.Lib.ViewModel
public void Update() public void Update()
{ {
ValidStatus = IsViewValid ? (GameData.HasItemForClass(ItemClassString) ? "Y" : "W") : "N"; ValidStatus = IsViewValid
? (GameData.HasItemForClass(ItemClassString)
? "Y"
: "W")
: "N";
} }
} }
} }

View file

@ -65,6 +65,8 @@ namespace ServerManagerTool
} }
this.DataContext = this; this.DataContext = this;
GameData.GameDataLoaded += GameData_GameDataLoaded;
} }
public App AppInstance public App AppInstance
@ -396,15 +398,21 @@ namespace ServerManagerTool
e.Handled = true; e.Handled = true;
} }
private void GameData_GameDataLoaded(object sender, EventArgs e)
{
PopulateRconMessageModesComboBox();
}
private void LanguageSelectionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) private void LanguageSelectionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
Config.CultureName = AvailableLanguages.Instance.SelectedLanguage; Config.CultureName = AvailableLanguages.Instance.SelectedLanguage;
PopulateWindowsStatesMainWindowComboBox(); PopulateWindowsStatesMainWindowComboBox();
PopulateWindowsStatesServerMonitorWindowComboBox(); PopulateWindowsStatesServerMonitorWindowComboBox();
PopulateRconMessageModesComboBox();
PopulateTaskPrioritiesComboBox(); PopulateTaskPrioritiesComboBox();
GameData_GameDataLoaded(sender, e);
App.Instance.OnResourceDictionaryChanged(Config.CultureName); App.Instance.OnResourceDictionaryChanged(Config.CultureName);
} }
@ -490,6 +498,11 @@ namespace ServerManagerTool
} }
} }
public void CloseControl()
{
GameData.GameDataLoaded -= GameData_GameDataLoaded;
}
private void PopulateWindowsStatesMainWindowComboBox() private void PopulateWindowsStatesMainWindowComboBox()
{ {
var selectedValue = this.WindowStateMainWindowComboBox?.SelectedValue ?? Config.MainWindow_WindowState; var selectedValue = this.WindowStateMainWindowComboBox?.SelectedValue ?? Config.MainWindow_WindowState;

View file

@ -342,9 +342,36 @@ namespace ServerManagerTool
// hook into the language change event // hook into the language change event
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent += ResourceDictionaryChangedEvent; GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent += ResourceDictionaryChangedEvent;
GameData.GameDataLoaded += GameData_GameDataLoaded;
} }
#region Event Methods #region Event Methods
private void GameData_GameDataLoaded(object sender, EventArgs e)
{
this.RefreshBaseDinoModList();
this.RefreshBaseEngramModList();
this.RefreshBaseResourceModList();
this.RefreshBaseDinoList();
this.RefreshBaseMapSpawnerList();
this.RefreshBasePrimalItemList();
this.RefreshBaseSupplyCrateList();
this.RefreshBaseGameMapsList();
this.RefreshBaseTotalConversionsList();
this.RefreshBaseBranchesList();
this.RefreshBaseEventsList();
this.RefreshProcessPrioritiesList();
this.RefreshCustomLevelProgressionsInformation();
this.HarvestResourceItemAmountClassMultipliersListBox.Items.Refresh();
this.Settings.ConfigOverrideItemCraftingCosts.Update();
this.Settings.ConfigOverrideItemMaxQuantity.Update();
this.Settings.ConfigOverrideSupplyCrateItems.Update();
this.Settings.NPCSpawnSettings.Update();
this.Settings.PreventTransferForClassNames.Update();
}
private static void ServerPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) private static void ServerPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ {
var ssc = (ServerSettingsControl)d; var ssc = (ServerSettingsControl)d;
@ -378,30 +405,8 @@ namespace ServerManagerTool
{ {
this.CurrentCulture = Thread.CurrentThread.CurrentCulture; this.CurrentCulture = Thread.CurrentThread.CurrentCulture;
this.Settings.DinoSettings.UpdateForLocalization();
this.Settings.EngramSettings.UpdateForLocalization();
this.Settings.NPCSpawnSettings.UpdateForLocalization();
this.Settings.ConfigOverrideSupplyCrateItems.UpdateForLocalization();
this.Settings.ConfigOverrideItemMaxQuantity.UpdateForLocalization();
this.RefreshBaseDinoModList();
this.RefreshBaseEngramModList();
this.RefreshBaseResourceModList();
this.RefreshBaseDinoList();
this.RefreshBaseMapSpawnerList();
this.RefreshBasePrimalItemList();
this.RefreshBaseSupplyCrateList();
this.RefreshBaseGameMapsList();
this.RefreshBaseTotalConversionsList();
this.RefreshBaseBranchesList();
this.RefreshBaseEventsList();
this.RefreshProcessPrioritiesList();
this.HarvestResourceItemAmountClassMultipliersListBox.Items.Refresh();
this.RefreshCustomLevelProgressionsInformation();
this.UpdateLastStartedDetails(false); this.UpdateLastStartedDetails(false);
GameData_GameDataLoaded(source, e);
Runtime.UpdateServerStatusString(); Runtime.UpdateServerStatusString();
} }
@ -3487,6 +3492,12 @@ namespace ServerManagerTool
#endregion #endregion
#region Methods #region Methods
public void CloseControl()
{
GameData.GameDataLoaded -= GameData_GameDataLoaded;
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent -= ResourceDictionaryChangedEvent;
}
public void RefreshBaseDinoModList() public void RefreshBaseDinoModList()
{ {
var selectedValue = SelectedModDino; var selectedValue = SelectedModDino;

View file

@ -5,7 +5,30 @@
<title>Ark Server Manager Version Feed</title> <title>Ark Server Manager Version Feed</title>
<subtitle>This is the Ark Server Manager release version feed.</subtitle> <subtitle>This is the Ark Server Manager release version feed.</subtitle>
<link href="http://arkservermanager.freeforums.net/" /> <link href="http://arkservermanager.freeforums.net/" />
<updated>2022-06-16T00:00:00Z</updated> <updated>2022-06-17T00:00:00Z</updated>
<entry>
<id>urn:uuid:1AE0925B-64EB-4177-B834-7A75FA46E807</id>
<title>1.1.433 (1.1.433.1)</title>
<summary>1.1.433.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> <entry>
<id>urn:uuid:93A04A12-C632-4C2B-AC76-42D9E476431C</id> <id>urn:uuid:93A04A12-C632-4C2B-AC76-42D9E476431C</id>

View file

@ -5,94 +5,21 @@
<title>Ark Server Manager Version Feed</title> <title>Ark Server Manager Version Feed</title>
<subtitle>This is the Ark Server Manager beta version feed.</subtitle> <subtitle>This is the Ark Server Manager beta version feed.</subtitle>
<link href="http://arkservermanager.freeforums.net/" /> <link href="http://arkservermanager.freeforums.net/" />
<updated>2022-06-16T00:00:00Z</updated> <updated>2022-06-17T00:00:00Z</updated>
<entry> <entry>
<id>urn:uuid:DB240E90-17B0-4DE1-B60B-0D5E4753810F</id> <id>urn:uuid:1AE0925B-64EB-4177-B834-7A75FA46E807</id>
<title>1.1.432 (1.1.432.4)</title> <title>1.1.433 (1.1.433.1)</title>
<summary>1.1.432.4</summary> <summary>1.1.433.1</summary>
<link href="" /> <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;">NEW</u>
<br/>
<ul>
<li>Profile Settings - Rules Section - Added UseFjordurTraversalBuff setting. Located in the Fjordur group at the bottom of the Rules section.</li>
</ul>
</p>
</div>
</content>
<author>
<name>bletch</name>
<email>bletch1971@hotmail.com</email>
</author>
</entry>
<entry>
<id>urn:uuid:EB7309A6-5E1F-4F97-A813-CDCFC51A9A7C</id>
<title>1.1.432 (1.1.432.3)</title>
<summary>1.1.432.3</summary>
<link href="" />
<updated>2022-06-16T00:00:00Z</updated>
<content type="xhtml"> <content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;"> <div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
<p> <p>
<u style="font-size: .9em;">CHANGE</u> <u style="font-size: .9em;">CHANGE</u>
<br/> <br/>
<ul> <ul>
<li>Crafting Override Grids - Added new icons to show Good (green), Warning (orange) or Bad (red). Warnings will show for items not familiar with (raw class names, not loaded via gamedata files), Errors will show for missing items.</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>
<li>Prevent Transfer Grids - Added new icons to show Good (green), Warning (orange) or Bad (red). Warnings will show for creatures not familiar with (raw class names, not loaded via gamedata files), Errors will show for missing creatures.</li>
<li>Map Spawner Grids - Added new icons to show Good (green), Warning (orange) or Bad (red). Warnings will show for spawners/creatures not familiar with (raw class names, not loaded via gamedata files), Errors will show for missing spawners/creatures.</li>
<li>Stack Size Grid - Added new icons to show Good (green), Warning (orange) or Bad (red). Warnings will show for items not familiar with (raw class names, not loaded via gamedata files), Errors will show for missing items.</li>
<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:93A04A12-C632-4C2B-AC76-42D9E476431C</id>
<title>1.1.432 (1.1.432.2)</title>
<summary>1.1.432.2</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;">CHANGE</u>
<br/>
<ul>
<li>Gamedata Files - changed the Fjordur official mod to the correct mod id.</li>
</ul>
</p>
</div>
</content>
<author>
<name>bletch</name>
<email>bletch1971@hotmail.com</email>
</author>
</entry>
<entry>
<id>urn:uuid:93A04A12-C632-4C2B-AC76-42D9E476431C</id>
<title>1.1.432 (1.1.432.1)</title>
<summary>1.1.432.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, player and tribe files and reset your server back to new.</li>
</ul> </ul>
</p> </p>
</div> </div>

View file

@ -1,7 +1,7 @@
using Microsoft.WindowsAPICodePack.Dialogs; using Microsoft.WindowsAPICodePack.Dialogs;
using ServerManagerTool.Common.Model;
using ServerManagerTool.Common.Utils; using ServerManagerTool.Common.Utils;
using ServerManagerTool.Lib; using ServerManagerTool.Lib;
using ServerManagerTool.Lib.ViewModel;
using ServerManagerTool.Utils; using ServerManagerTool.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -19,60 +19,6 @@ namespace ServerManagerTool
/// </summary> /// </summary>
public partial class GameDataWindow : Window 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; private readonly GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
public static readonly DependencyProperty GameDataFilesProperty = DependencyProperty.Register(nameof(GameDataFiles), typeof(GameDataFileList), typeof(GameDataWindow), new PropertyMetadata(null)); public static readonly DependencyProperty GameDataFilesProperty = DependencyProperty.Register(nameof(GameDataFiles), typeof(GameDataFileList), typeof(GameDataWindow), new PropertyMetadata(null));
@ -117,6 +63,7 @@ namespace ServerManagerTool
try try
{ {
AddGameDataFile(GameData.UserDataFolder, dialog.FileName); AddGameDataFile(GameData.UserDataFolder, dialog.FileName);
GameData.Reload();
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -135,6 +82,7 @@ namespace ServerManagerTool
{ {
DeleteAllGameDataFiles(GameData.UserDataFolder); DeleteAllGameDataFiles(GameData.UserDataFolder);
} }
GameData.Reload();
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -166,6 +114,7 @@ namespace ServerManagerTool
try try
{ {
ReloadGameDataFiles(); ReloadGameDataFiles();
GameData.Reload();
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -182,6 +131,7 @@ namespace ServerManagerTool
{ {
var gameDataItem = ((GameDataFile)((Button)e.Source).DataContext); var gameDataItem = ((GameDataFile)((Button)e.Source).DataContext);
DeleteGameDataFile(gameDataItem.File, true); DeleteGameDataFile(gameDataItem.File, true);
GameData.Reload();
} }
catch (Exception ex) catch (Exception ex)
{ {

View file

@ -246,6 +246,13 @@ namespace ServerManagerTool
this.Activate(); this.Activate();
} }
protected override void OnClosed(EventArgs e)
{
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent -= ResourceDictionaryChangedEvent;
base.OnClosed(e);
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e) protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{ {
if (DiscordBotHelper.HasRunningCommands) if (DiscordBotHelper.HasRunningCommands)

View file

@ -245,6 +245,7 @@ namespace ServerManagerTool
// hook into the language change event // hook into the language change event
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent += ResourceDictionaryChangedEvent; GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent += ResourceDictionaryChangedEvent;
GameData.GameDataLoaded += GameData_GameDataLoaded;
} }
#region Properties #region Properties
@ -684,13 +685,19 @@ namespace ServerManagerTool
return new RCONWindow(parameters); return new RCONWindow(parameters);
} }
private void ResourceDictionaryChangedEvent(object source, ResourceDictionaryChangedEventArgs e) private void GameData_GameDataLoaded(object sender, EventArgs e)
{ {
PopulateRconInputModesComboBox(); PopulateRconInputModesComboBox();
} }
private void ResourceDictionaryChangedEvent(object source, ResourceDictionaryChangedEventArgs e)
{
GameData_GameDataLoaded(source, e);
}
protected override void OnClosed(EventArgs e) protected override void OnClosed(EventArgs e)
{ {
GameData.GameDataLoaded -= GameData_GameDataLoaded;
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent -= ResourceDictionaryChangedEvent; GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent -= ResourceDictionaryChangedEvent;
if (this.RCONParameters?.Server?.Runtime != null) if (this.RCONParameters?.Server?.Runtime != null)

View file

@ -3,9 +3,10 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ServerManagerTool" xmlns:sm="clr-namespace:ServerManagerTool"
mc:Ignorable="d" mc:Ignorable="d"
MinWidth="800" MinHeight="600" Width="800" Height="700" ResizeMode="CanResizeWithGrip" WindowStyle="ToolWindow" WindowStartupLocation="CenterOwner" ShowInTaskbar="False" MinWidth="800" MinHeight="600" Width="800" Height="700" ResizeMode="CanResizeWithGrip" WindowStyle="ToolWindow" WindowStartupLocation="CenterOwner" ShowInTaskbar="False"
Closing="SettingsWindow_Closing"
Icon="../Art/favicon.ico" Title="{DynamicResource Settings_Title}" > Icon="../Art/favicon.ico" Title="{DynamicResource Settings_Title}" >
<Window.Resources> <Window.Resources>
<ResourceDictionary> <ResourceDictionary>
@ -16,6 +17,6 @@
</ResourceDictionary> </ResourceDictionary>
</Window.Resources> </Window.Resources>
<Grid> <Grid>
<local:GlobalSettingsControl x:Name="globalSettingsControl" HorizontalAlignment="Stretch" VerticalContentAlignment="Stretch" Background="{StaticResource BeigeGradient}"/> <sm:GlobalSettingsControl x:Name="globalSettingsControl" HorizontalAlignment="Stretch" VerticalContentAlignment="Stretch" Background="{StaticResource BeigeGradient}"/>
</Grid> </Grid>
</Window> </Window>

View file

@ -1,5 +1,6 @@
using ServerManagerTool.Common.Utils; using ServerManagerTool.Common.Utils;
using System; using System;
using System.ComponentModel;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Windows; using System.Windows;
@ -20,8 +21,15 @@ namespace ServerManagerTool
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile); WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
} }
private void SettingsWindow_Closing(object sender, CancelEventArgs e)
{
if (!globalSettingsControl.IsEnabled)
e.Cancel = true;
}
protected override void OnClosed(EventArgs e) protected override void OnClosed(EventArgs e)
{ {
globalSettingsControl.CloseControl();
globalSettingsControl.ApplyChangesToConfig(); globalSettingsControl.ApplyChangesToConfig();
if (SecurityUtils.IsAdministrator()) if (SecurityUtils.IsAdministrator())

View file

@ -212,6 +212,8 @@
<Compile Include="Lib\ServerRcon.cs" /> <Compile Include="Lib\ServerRcon.cs" />
<Compile Include="Lib\ViewConverters\EnumDescriptionTypeConverter.cs" /> <Compile Include="Lib\ViewConverters\EnumDescriptionTypeConverter.cs" />
<Compile Include="Lib\ViewConverters\MapNameValueConverter.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="Lib\ViewModel\PlayerInfo.cs" />
<Compile Include="Utils\DiscordBotHelper.cs" /> <Compile Include="Utils\DiscordBotHelper.cs" />
<Compile Include="Utils\DiscordPluginHelper.cs" /> <Compile Include="Utils\DiscordPluginHelper.cs" />

View file

@ -12,12 +12,20 @@ namespace ServerManagerTool.Lib
{ {
public const string RCONINPUTMODE_COMMAND = "Command"; 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 MainDataFolder = Path.Combine(Environment.CurrentDirectory, Config.Default.GameDataRelativePath);
public static string UserDataFolder = Path.Combine(Config.Default.DataPath, Config.Default.GameDataRelativePath); public static string UserDataFolder = Path.Combine(Config.Default.DataPath, Config.Default.GameDataRelativePath);
private static MainGameData gameData = null; private static MainGameData gameData = null;
public static void Initialize() public static void Initialize()
{
Load();
OnGameDataLoaded();
}
private static void Load()
{ {
// read static game data // read static game data
GameDataUtils.ReadAllData(out gameData, MainDataFolder, Config.Default.GameDataExtension, Config.Default.GameDataApplication); 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); 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 #region Game Maps

View 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); }
}
}
}

View 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}";
}
}
}

View file

@ -63,6 +63,8 @@ namespace ServerManagerTool
} }
this.DataContext = this; this.DataContext = this;
GameData.GameDataLoaded += GameData_GameDataLoaded;
} }
public App AppInstance public App AppInstance
@ -398,14 +400,19 @@ namespace ServerManagerTool
e.Handled = true; e.Handled = true;
} }
private void GameData_GameDataLoaded(object sender, EventArgs e)
{
PopulateRconMessageModesComboBox();
}
private void LanguageSelectionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) private void LanguageSelectionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
Config.CultureName = AvailableLanguages.Instance.SelectedLanguage; Config.CultureName = AvailableLanguages.Instance.SelectedLanguage;
PopulateWindowsStatesMainWindowComboBox(); PopulateWindowsStatesMainWindowComboBox();
PopulateWindowsStatesServerMonitorWindowComboBox(); PopulateWindowsStatesServerMonitorWindowComboBox();
PopulateRconMessageModesComboBox();
PopulateTaskPrioritiesComboBox(); PopulateTaskPrioritiesComboBox();
GameData_GameDataLoaded(sender, e);
App.Instance.OnResourceDictionaryChanged(Config.CultureName); App.Instance.OnResourceDictionaryChanged(Config.CultureName);
} }
@ -492,6 +499,11 @@ namespace ServerManagerTool
} }
} }
public void CloseControl()
{
GameData.GameDataLoaded -= GameData_GameDataLoaded;
}
private void PopulateWindowsStatesMainWindowComboBox() private void PopulateWindowsStatesMainWindowComboBox()
{ {
var selectedValue = this.WindowStateMainWindowComboBox?.SelectedValue ?? Config.MainWindow_WindowState; var selectedValue = this.WindowStateMainWindowComboBox?.SelectedValue ?? Config.MainWindow_WindowState;

View file

@ -153,9 +153,18 @@ namespace ServerManagerTool
// hook into the language change event // hook into the language change event
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent += ResourceDictionaryChangedEvent; GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent += ResourceDictionaryChangedEvent;
GameData.GameDataLoaded += GameData_GameDataLoaded;
} }
#region Event Methods #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) private static void ServerPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ {
var ssc = (ServerSettingsControl)d; var ssc = (ServerSettingsControl)d;
@ -184,11 +193,8 @@ namespace ServerManagerTool
{ {
this.CurrentCulture = Thread.CurrentThread.CurrentCulture; this.CurrentCulture = Thread.CurrentThread.CurrentCulture;
this.RefreshBaseGameMapsList();
this.RefreshBaseBranchesList();
this.RefreshProcessPrioritiesList();
this.RefreshServerRegionsList();
this.UpdateLastStartedDetails(false); this.UpdateLastStartedDetails(false);
GameData_GameDataLoaded(source, e);
Runtime.UpdateServerStatusString(); Runtime.UpdateServerStatusString();
} }
@ -1248,6 +1254,12 @@ namespace ServerManagerTool
#endregion #endregion
#region Methods #region Methods
public void CloseControl()
{
GameData.GameDataLoaded -= GameData_GameDataLoaded;
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent -= ResourceDictionaryChangedEvent;
}
public void RefreshBaseGameMapsList() public void RefreshBaseGameMapsList()
{ {
var newList = new ComboBoxItemList(); var newList = new ComboBoxItemList();

View file

@ -5,7 +5,30 @@
<title>Conan Server Manager Version Feed</title> <title>Conan Server Manager Version Feed</title>
<subtitle>This is the Conan Server Manager release version feed.</subtitle> <subtitle>This is the Conan Server Manager release version feed.</subtitle>
<link href="http://servermanagers.freeforums.net/" /> <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> <entry>
<id>urn:uuid:4E189446-9861-4B64-9B27-0E3E655CD1CA</id> <id>urn:uuid:4E189446-9861-4B64-9B27-0E3E655CD1CA</id>

View file

@ -5,44 +5,21 @@
<title>Conan Server Manager Version Feed</title> <title>Conan Server Manager Version Feed</title>
<subtitle>This is the Conan Server Manager beta version feed.</subtitle> <subtitle>This is the Conan Server Manager beta version feed.</subtitle>
<link href="http://servermanagers.freeforums.net/" /> <link href="http://servermanagers.freeforums.net/" />
<updated>2022-06-16T00:00:00Z</updated> <updated>2022-06-17T00:00:00Z</updated>
<entry> <entry>
<id>urn:uuid:4E189446-9861-4B64-9B27-0E3E655CD1CA</id> <id>urn:uuid:15FEC514-38B7-4367-BE79-1E00983E7EBB</id>
<title>1.1.75 (1.1.75.2)</title> <title>1.1.76 (1.1.76.1)</title>
<summary>1.1.75.2</summary> <summary>1.1.76.1</summary>
<link href="" /> <link href="" />
<updated>2022-06-16T00:00:00Z</updated> <updated>2022-06-17T00:00:00Z</updated>
<content type="xhtml"> <content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;"> <div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
<p> <p>
<u style="font-size: .9em;">CHANGE</u> <u style="font-size: .9em;">CHANGE</u>
<br/> <br/>
<ul> <ul>
<li>Server Monitor - added shutdown reason.</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>
</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>
</ul> </ul>
</p> </p>
</div> </div>

View file

@ -1,7 +1,7 @@
using Microsoft.WindowsAPICodePack.Dialogs; using Microsoft.WindowsAPICodePack.Dialogs;
using ServerManagerTool.Common.Model;
using ServerManagerTool.Common.Utils; using ServerManagerTool.Common.Utils;
using ServerManagerTool.Lib; using ServerManagerTool.Lib;
using ServerManagerTool.Lib.ViewModel;
using ServerManagerTool.Utils; using ServerManagerTool.Utils;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -19,60 +19,6 @@ namespace ServerManagerTool
/// </summary> /// </summary>
public partial class GameDataWindow : Window 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; private readonly GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
public static readonly DependencyProperty GameDataFilesProperty = DependencyProperty.Register(nameof(GameDataFiles), typeof(GameDataFileList), typeof(GameDataWindow), new PropertyMetadata(null)); public static readonly DependencyProperty GameDataFilesProperty = DependencyProperty.Register(nameof(GameDataFiles), typeof(GameDataFileList), typeof(GameDataWindow), new PropertyMetadata(null));
@ -117,6 +63,7 @@ namespace ServerManagerTool
try try
{ {
AddGameDataFile(GameData.UserDataFolder, dialog.FileName); AddGameDataFile(GameData.UserDataFolder, dialog.FileName);
GameData.Reload();
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -135,6 +82,7 @@ namespace ServerManagerTool
{ {
DeleteAllGameDataFiles(GameData.UserDataFolder); DeleteAllGameDataFiles(GameData.UserDataFolder);
} }
GameData.Reload();
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -166,6 +114,7 @@ namespace ServerManagerTool
try try
{ {
ReloadGameDataFiles(); ReloadGameDataFiles();
GameData.Reload();
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -182,6 +131,7 @@ namespace ServerManagerTool
{ {
var gameDataItem = ((GameDataFile)((Button)e.Source).DataContext); var gameDataItem = ((GameDataFile)((Button)e.Source).DataContext);
DeleteGameDataFile(gameDataItem.File, true); DeleteGameDataFile(gameDataItem.File, true);
GameData.Reload();
} }
catch (Exception ex) catch (Exception ex)
{ {

View file

@ -246,6 +246,13 @@ namespace ServerManagerTool
this.Activate(); this.Activate();
} }
protected override void OnClosed(EventArgs e)
{
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent -= ResourceDictionaryChangedEvent;
base.OnClosed(e);
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e) protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{ {
if (DiscordBotHelper.HasRunningCommands) if (DiscordBotHelper.HasRunningCommands)

View file

@ -238,6 +238,7 @@ namespace ServerManagerTool
// hook into the language change event // hook into the language change event
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent += ResourceDictionaryChangedEvent; GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent += ResourceDictionaryChangedEvent;
GameData.GameDataLoaded += GameData_GameDataLoaded;
} }
#region Properties #region Properties
@ -554,13 +555,19 @@ namespace ServerManagerTool
return window; return window;
} }
private void ResourceDictionaryChangedEvent(object source, ResourceDictionaryChangedEventArgs e) private void GameData_GameDataLoaded(object sender, EventArgs e)
{ {
PopulateRconInputModesComboBox(); PopulateRconInputModesComboBox();
} }
private void ResourceDictionaryChangedEvent(object source, ResourceDictionaryChangedEventArgs e)
{
GameData_GameDataLoaded(source, e);
}
protected override void OnClosed(EventArgs e) protected override void OnClosed(EventArgs e)
{ {
GameData.GameDataLoaded -= GameData_GameDataLoaded;
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent -= ResourceDictionaryChangedEvent; GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent -= ResourceDictionaryChangedEvent;
if (this.RconParameters?.Server?.Runtime != null) if (this.RconParameters?.Server?.Runtime != null)

View file

@ -13,24 +13,14 @@ namespace ServerManagerTool
/// </summary> /// </summary>
public partial class SettingsWindow : Window 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; private readonly GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
public SettingsWindow() public SettingsWindow()
{ {
this.AppInstance = App.Instance;
InitializeComponent(); InitializeComponent();
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile); 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) private void SettingsWindow_Closing(object sender, CancelEventArgs e)
{ {
if (!globalSettingsControl.IsEnabled) if (!globalSettingsControl.IsEnabled)
@ -39,6 +29,7 @@ namespace ServerManagerTool
protected override void OnClosed(EventArgs e) protected override void OnClosed(EventArgs e)
{ {
globalSettingsControl.CloseControl();
globalSettingsControl.ApplyChangesToConfig(); globalSettingsControl.ApplyChangesToConfig();
if (SecurityUtils.IsAdministrator()) if (SecurityUtils.IsAdministrator())