mirror of
https://github.com/Tribufu/ServerManagers
synced 2026-08-08 20:21:06 +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
|
|
@ -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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue