From c220f899a34cbf334eb8c02cdc53f65c8f788e99 Mon Sep 17 00:00:00 2001 From: John Gross Date: Thu, 29 Jun 2017 12:02:36 -0700 Subject: [PATCH] Assorted bug fixes, remove dead Torch.Launcher project --- Torch.API/ConnectionState.cs | 23 ++++ Torch.API/IChatMessage.cs | 15 +++ Torch.API/IPlayer.cs | 14 +++ Torch.API/ModAPI/TorchAPI.cs | 20 +++ Torch.API/ModAPI/TorchAPIGateway.cs | 18 --- Torch.API/Torch.API.csproj | 3 +- Torch.Client/Torch.Client.csproj | 1 + Torch.Launcher/App.config | 6 - Torch.Launcher/App.xaml | 9 -- Torch.Launcher/App.xaml.cs | 17 --- Torch.Launcher/Config.cs | 57 --------- Torch.Launcher/MainWindow.xaml | 15 --- Torch.Launcher/MainWindow.xaml.cs | 115 ----------------- Torch.Launcher/Properties/AssemblyInfo.cs | 55 -------- .../Properties/Resources.Designer.cs | 63 ---------- Torch.Launcher/Properties/Resources.resx | 117 ------------------ .../Properties/Settings.Designer.cs | 26 ---- Torch.Launcher/Properties/Settings.settings | 7 -- Torch.Launcher/SpaceDirPrompt.xaml | 14 --- Torch.Launcher/SpaceDirPrompt.xaml.cs | 49 -------- Torch.Launcher/Torch.Launcher.csproj | 117 ------------------ Torch.Launcher/TorchFileManager.cs | 100 --------------- Torch.Server/Program.cs | 20 +-- Torch.Server/Torch.Server.csproj | 2 + Torch.Server/TorchService.cs | 1 - .../ViewModels/BlockLimitViewModel.cs | 5 +- .../ViewModels/ConfigDedicatedViewModel.cs | 9 +- .../ViewModels/Entities/VoxelMapViewModel.cs | 7 +- .../ViewModels/SessionSettingsViewModel.cs | 73 ++++++++++- Torch.Server/Views/ChatControl.xaml.cs | 3 + Torch.Server/Views/ConfigControl.xaml | 2 +- Torch.Server/Views/ConfigControl.xaml.cs | 60 +++++---- .../Converters/InverseBooleanConverter.cs | 32 +++++ .../Views/Entities/VoxelMapView.xaml.cs | 2 +- Torch.Server/Views/EntitiesControl.xaml.cs | 4 +- Torch.sln | 6 - Torch/Managers/MultiplayerManager.cs | 10 +- .../NetworkManager/NetworkHandlerBase.cs | 1 + Torch/Managers/ScriptingManager.cs | 5 +- Torch/Managers/UpdateManager.cs | 8 +- Torch/Persistent.cs | 6 +- Torch/Torch.csproj | 1 + Torch/TorchBase.cs | 38 +++--- 43 files changed, 289 insertions(+), 867 deletions(-) create mode 100644 Torch.API/ModAPI/TorchAPI.cs delete mode 100644 Torch.API/ModAPI/TorchAPIGateway.cs delete mode 100644 Torch.Launcher/App.config delete mode 100644 Torch.Launcher/App.xaml delete mode 100644 Torch.Launcher/App.xaml.cs delete mode 100644 Torch.Launcher/Config.cs delete mode 100644 Torch.Launcher/MainWindow.xaml delete mode 100644 Torch.Launcher/MainWindow.xaml.cs delete mode 100644 Torch.Launcher/Properties/AssemblyInfo.cs delete mode 100644 Torch.Launcher/Properties/Resources.Designer.cs delete mode 100644 Torch.Launcher/Properties/Resources.resx delete mode 100644 Torch.Launcher/Properties/Settings.Designer.cs delete mode 100644 Torch.Launcher/Properties/Settings.settings delete mode 100644 Torch.Launcher/SpaceDirPrompt.xaml delete mode 100644 Torch.Launcher/SpaceDirPrompt.xaml.cs delete mode 100644 Torch.Launcher/Torch.Launcher.csproj delete mode 100644 Torch.Launcher/TorchFileManager.cs create mode 100644 Torch.Server/Views/Converters/InverseBooleanConverter.cs diff --git a/Torch.API/ConnectionState.cs b/Torch.API/ConnectionState.cs index 5565c6c..aa48ead 100644 --- a/Torch.API/ConnectionState.cs +++ b/Torch.API/ConnectionState.cs @@ -8,11 +8,34 @@ namespace Torch.API [Flags] public enum ConnectionState { + /// + /// Unknown state. + /// Unknown, + + /// + /// Connected to game. + /// Connected = 1, + + /// + /// Left the game. + /// Left = 2, + + /// + /// Disconnected from the game. + /// Disconnected = 4, + + /// + /// Kicked from the game. + /// Kicked = 8, + + /// + /// Banned from the game. + /// Banned = 16, } } \ No newline at end of file diff --git a/Torch.API/IChatMessage.cs b/Torch.API/IChatMessage.cs index 30356dd..e9dbc11 100644 --- a/Torch.API/IChatMessage.cs +++ b/Torch.API/IChatMessage.cs @@ -8,9 +8,24 @@ namespace Torch.API { public interface IChatMessage { + /// + /// The time the message was created. + /// DateTime Timestamp { get; } + + /// + /// The SteamID of the message author. + /// ulong SteamId { get; } + + /// + /// The name of the message author. + /// string Name { get; } + + /// + /// The content of the message. + /// string Message { get; } } } diff --git a/Torch.API/IPlayer.cs b/Torch.API/IPlayer.cs index db4d09e..e2357a4 100644 --- a/Torch.API/IPlayer.cs +++ b/Torch.API/IPlayer.cs @@ -7,10 +7,24 @@ using VRage.Game.ModAPI; namespace Torch.API { + /// + /// Represents a player on the server. + /// public interface IPlayer { + /// + /// The name of the player. + /// string Name { get; } + + /// + /// The SteamID of the player. + /// ulong SteamId { get; } + + /// + /// The player's current connection state. + /// ConnectionState State { get; } } } diff --git a/Torch.API/ModAPI/TorchAPI.cs b/Torch.API/ModAPI/TorchAPI.cs new file mode 100644 index 0000000..60560c8 --- /dev/null +++ b/Torch.API/ModAPI/TorchAPI.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices.WindowsRuntime; +using System.Text; +using System.Threading.Tasks; + +//Needed so Torch can set the instance here without exposing anything bad to mods or creating a circular dependency. +[assembly: InternalsVisibleTo("Torch")] +namespace Torch.API.ModAPI +{ + /// + /// Entry point for mods to access Torch. + /// + public static class TorchAPI + { + internal static ITorchBase Instance; + } +} diff --git a/Torch.API/ModAPI/TorchAPIGateway.cs b/Torch.API/ModAPI/TorchAPIGateway.cs deleted file mode 100644 index b74114a..0000000 --- a/Torch.API/ModAPI/TorchAPIGateway.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Torch.API.ModAPI -{ - /* TODO: this without causing a circular dependency - public static class TorchAPIGateway - { - public static Version Version => TorchBase.Instance.TorchVersion; - - public static IMultiplayer Multiplayer => TorchBase.Instance.Multiplayer; - - public static IPluginManager Plugins => TorchBase.Instance.Plugins; - }*/ -} diff --git a/Torch.API/Torch.API.csproj b/Torch.API/Torch.API.csproj index 3a737c3..60f537f 100644 --- a/Torch.API/Torch.API.csproj +++ b/Torch.API/Torch.API.csproj @@ -30,6 +30,7 @@ x64 prompt MinimumRecommendedRules.ruleset + bin\x64\Release\Torch.API.xml @@ -168,10 +169,10 @@ - + diff --git a/Torch.Client/Torch.Client.csproj b/Torch.Client/Torch.Client.csproj index 947d5e8..b56672d 100644 --- a/Torch.Client/Torch.Client.csproj +++ b/Torch.Client/Torch.Client.csproj @@ -35,6 +35,7 @@ prompt MinimumRecommendedRules.ruleset true + bin\x64\Release\Torch.Client.xml torchicon.ico diff --git a/Torch.Launcher/App.config b/Torch.Launcher/App.config deleted file mode 100644 index bae5d6d..0000000 --- a/Torch.Launcher/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/Torch.Launcher/App.xaml b/Torch.Launcher/App.xaml deleted file mode 100644 index 09b2f9a..0000000 --- a/Torch.Launcher/App.xaml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/Torch.Launcher/App.xaml.cs b/Torch.Launcher/App.xaml.cs deleted file mode 100644 index f7e54a7..0000000 --- a/Torch.Launcher/App.xaml.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Threading.Tasks; -using System.Windows; - -namespace Torch.Launcher -{ - /// - /// Interaction logic for App.xaml - /// - public partial class App : Application - { - } -} diff --git a/Torch.Launcher/Config.cs b/Torch.Launcher/Config.cs deleted file mode 100644 index b8a8637..0000000 --- a/Torch.Launcher/Config.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Serialization; - -namespace Torch.Launcher -{ - public class Config - { - public int Version { get; set; } - public string RemoteFilePath { get; set; } - public string SpaceDirectory { get; set; } - - private Config() - { - Version = 0; - RemoteFilePath = "ftp://athena.jimmacle.com/"; - SpaceDirectory = @"C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64"; - } - - public static string GetConfigPath() - { - var appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); - var pistonFolder = Path.Combine(appdata, "Piston"); - if (!Directory.Exists(pistonFolder)) - Directory.CreateDirectory(pistonFolder); - return Path.Combine(appdata, "Piston\\config.xml"); - } - - public static Config Load() - { - if (!File.Exists(GetConfigPath())) - return new Config(); - - XmlSerializer ser = new XmlSerializer(typeof(Config)); - using (var f = File.OpenRead(GetConfigPath())) - { - using (var sr = new StreamReader(f)) - { - return (Config)ser.Deserialize(sr); - } - } - } - - public void Save() - { - XmlSerializer ser = new XmlSerializer(typeof(Config)); - using (var sw = new StreamWriter(GetConfigPath())) - { - ser.Serialize(sw, this); - } - } - } -} diff --git a/Torch.Launcher/MainWindow.xaml b/Torch.Launcher/MainWindow.xaml deleted file mode 100644 index 108a75d..0000000 --- a/Torch.Launcher/MainWindow.xaml +++ /dev/null @@ -1,15 +0,0 @@ - - - - diff --git a/Torch.Launcher/SpaceDirPrompt.xaml.cs b/Torch.Launcher/SpaceDirPrompt.xaml.cs deleted file mode 100644 index c74b1fc..0000000 --- a/Torch.Launcher/SpaceDirPrompt.xaml.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; - -namespace Torch.Launcher -{ - /// - /// Interaction logic for SpaceDirPrompt.xaml - /// - public partial class SpaceDirPrompt : Window - { - public string SelectedDir { get; private set; } - public bool Success { get; private set; } - public SpaceDirPrompt() - { - InitializeComponent(); - } - - private void OkButton_Click(object sender, RoutedEventArgs e) - { - if (!Directory.Exists(PathBox.Text)) - { - MessageBox.Show(this, "That's not a valid directory."); - return; - } - - if (!Directory.GetFiles(PathBox.Text).Any(i => i.Contains("SpaceEngineers.exe"))) - { - MessageBox.Show(this, "SE was not found in the given directory."); - return; - } - - Success = true; - SelectedDir = PathBox.Text; - Close(); - } - } -} diff --git a/Torch.Launcher/Torch.Launcher.csproj b/Torch.Launcher/Torch.Launcher.csproj deleted file mode 100644 index b4509d9..0000000 --- a/Torch.Launcher/Torch.Launcher.csproj +++ /dev/null @@ -1,117 +0,0 @@ - - - - - Debug - AnyCPU - {19292801-5B9C-4EE0-961F-0FA37B3A6C3D} - WinExe - Properties - Torch.Launcher - Torch.Launcher - v4.6.1 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - x64 - prompt - MinimumRecommendedRules.ruleset - true - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - prompt - MinimumRecommendedRules.ruleset - true - - - - - - - - - - - - 4.0 - - - - - - - - MSBuild:Compile - Designer - - - SpaceDirPrompt.xaml - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - - - MainWindow.xaml - Code - - - Designer - MSBuild:Compile - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - - - - \ No newline at end of file diff --git a/Torch.Launcher/TorchFileManager.cs b/Torch.Launcher/TorchFileManager.cs deleted file mode 100644 index 1ad94bb..0000000 --- a/Torch.Launcher/TorchFileManager.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Windows; - -namespace Torch.Launcher -{ - public class TorchFileManager - { - private readonly string _baseUri; - - public TorchFileManager(string baseUri) - { - _baseUri = baseUri; - } - - public List GetDirectoryList() - { - var fileList = new List(); - - var response = RequestFtp("", WebRequestMethods.Ftp.ListDirectory); - using (var tr = (TextReader)new StreamReader(response.GetResponseStream())) - { - string line; - while ((line = tr.ReadLine()) != null) - fileList.Add(line); - } - - response.Close(); - return fileList; - } - - public bool UpdateIfNew(string fileName, string targetDir) - { - var info = GetFileInfo(fileName); - var localPath = Path.Combine(targetDir, fileName); - if (File.Exists(localPath)) - { - var localTime = File.GetLastWriteTime(localPath); - if (info.LastModified < localTime) - return false; - } - - File.WriteAllBytes(localPath, DownloadFile(fileName)); - return true; - } - - public byte[] DownloadFile(string fileName) - { - byte[] file; - var response = RequestFtp(fileName, WebRequestMethods.Ftp.DownloadFile); - using (var s = response.GetResponseStream()) - { - file = new byte[response.ContentLength]; - s.Read(file, 0, (int)response.ContentLength); - } - response.Close(); - return file; - } - - public FileInfo GetFileInfo(string fileName) - { - var response = RequestFtp(fileName, WebRequestMethods.Ftp.GetDateTimestamp); - return new FileInfo - { - Name = fileName, - LastModified = response.LastModified, - SizeInBytes = response.ContentLength - }; - } - - private FtpWebResponse RequestFtp(string resource, string method) - { - var request = (FtpWebRequest)WebRequest.Create(_baseUri + resource); - request.Credentials = new NetworkCredential("pistonftp", "piston"); - request.Method = method; - - try { return (FtpWebResponse)request.GetResponse(); } - catch (WebException e) - { - MessageBox.Show($"{e.Message}\r\n{e.StackTrace}"); - throw; - } - } - - public struct FileInfo - { - public string Name; - public DateTime LastModified; - public long SizeInBytes; - } - } -} diff --git a/Torch.Server/Program.cs b/Torch.Server/Program.cs index 0d357cd..b555ee7 100644 --- a/Torch.Server/Program.cs +++ b/Torch.Server/Program.cs @@ -25,10 +25,11 @@ using System.IO.Compression; using System.Net; using Torch.Server.Managers; using VRage.FileSystem; +using VRageRender; namespace Torch.Server { - public static class Program + internal static class Program { private static ITorchServer _server; private static Logger _log = LogManager.GetLogger("Torch"); @@ -45,7 +46,7 @@ namespace Torch.Server //Ensures that all the files are downloaded in the Torch directory. Directory.SetCurrentDirectory(new FileInfo(typeof(Program).Assembly.Location).Directory.ToString()); - IsManualInstall = Directory.GetCurrentDirectory().Contains("DedicatedServer64"); + IsManualInstall = File.Exists("SpaceEngineersDedicated.exe"); if (!IsManualInstall) AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; @@ -75,7 +76,7 @@ namespace Torch.Server if (!IsManualInstall) { - new ConfigManager().CreateInstance("Instance"); + //new ConfigManager().CreateInstance("Instance"); options.InstancePath = Path.GetFullPath("Instance"); _log.Warn("Would you like to enable automatic updates? (Y/n):"); @@ -256,17 +257,17 @@ quit"; _server = new TorchServer(options); _server.Init(); + if (cli.NoGui || cli.Autostart) + { + new Thread(() => _server.Start()).Start(); + } + if (!cli.NoGui) { var ui = new TorchUI((TorchServer)_server); ui.LoadConfig(options); ui.ShowDialog(); } - - if (cli.NoGui || cli.Autostart) - { - _server.Start(); - } } private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) @@ -304,7 +305,8 @@ quit"; _cli.WaitForPID = Process.GetCurrentProcess().Id.ToString(); Process.Start(exe, _cli.ToString()); } - Environment.Exit(-1); + //1627 = Function failed during execution. + Environment.Exit(1627); } } } diff --git a/Torch.Server/Torch.Server.csproj b/Torch.Server/Torch.Server.csproj index 2ea886a..5fd97a7 100644 --- a/Torch.Server/Torch.Server.csproj +++ b/Torch.Server/Torch.Server.csproj @@ -35,6 +35,7 @@ prompt MinimumRecommendedRules.ruleset true + bin\x64\Release\Torch.Server.xml Torch.Server.Program @@ -218,6 +219,7 @@ AddWorkshopItemsDialog.xaml + BlockView.xaml diff --git a/Torch.Server/TorchService.cs b/Torch.Server/TorchService.cs index c78c0b4..2c108ff 100644 --- a/Torch.Server/TorchService.cs +++ b/Torch.Server/TorchService.cs @@ -19,7 +19,6 @@ namespace Torch.Server public TorchService() { ServiceName = Name; - EventLog.Log = "Application"; CanHandlePowerEvent = true; CanHandleSessionChangeEvent = false; diff --git a/Torch.Server/ViewModels/BlockLimitViewModel.cs b/Torch.Server/ViewModels/BlockLimitViewModel.cs index e026cde..7b0667c 100644 --- a/Torch.Server/ViewModels/BlockLimitViewModel.cs +++ b/Torch.Server/ViewModels/BlockLimitViewModel.cs @@ -17,7 +17,7 @@ namespace Torch.Server.ViewModels public string BlockType { get => _blockType; set { _blockType = value; OnPropertyChanged(); } } public short Limit { get => _limit; set { _limit = value; OnPropertyChanged(); } } - public CommandBinding Delete { get; } = new CommandBinding(new DeleteCommand()); + //public CommandBinding Delete { get; } = new CommandBinding(new DeleteCommand()); public BlockLimitViewModel(SessionSettingsViewModel sessionSettings, string blockType, short limit) { @@ -26,6 +26,7 @@ namespace Torch.Server.ViewModels _limit = limit; } + /* TODO: figure out how WPF commands work public class DeleteCommand : ICommand { /// @@ -42,6 +43,6 @@ namespace Torch.Server.ViewModels /// public event EventHandler CanExecuteChanged; - } + }*/ } } diff --git a/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs b/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs index 0414e3b..e62862d 100644 --- a/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs +++ b/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs @@ -57,9 +57,12 @@ namespace Torch.Server.ViewModels public SessionSettingsViewModel SessionSettings { get; } public ObservableCollection WorldPaths { get; } = new ObservableCollection(); - public string Administrators { get; set; } - public string Banned { get; set; } - public string Mods { get; set; } + private string _administrators; + public string Administrators { get => _administrators; set { _administrators = value; OnPropertyChanged(); } } + private string _banned; + public string Banned { get => _banned; set { _banned = value; OnPropertyChanged(); } } + private string _mods; + public string Mods { get => _mods; set { _mods = value; OnPropertyChanged(); } } public int AsteroidAmount { diff --git a/Torch.Server/ViewModels/Entities/VoxelMapViewModel.cs b/Torch.Server/ViewModels/Entities/VoxelMapViewModel.cs index e1f5384..e19179a 100644 --- a/Torch.Server/ViewModels/Entities/VoxelMapViewModel.cs +++ b/Torch.Server/ViewModels/Entities/VoxelMapViewModel.cs @@ -3,6 +3,7 @@ using System.Linq; using Sandbox.Game.Entities; using VRage.Game.Entity; using VRage.Game.ModAPI; +using System.Threading.Tasks; namespace Torch.Server.ViewModels.Entities { @@ -10,13 +11,13 @@ namespace Torch.Server.ViewModels.Entities { private MyVoxelBase Voxel => (MyVoxelBase)Entity; - public override string Name => string.IsNullOrEmpty(Voxel.StorageName) ? "Unnamed" : Voxel.StorageName; + public override string Name => string.IsNullOrEmpty(Voxel.StorageName) ? "UnnamedProcedural" : Voxel.StorageName; public override bool CanStop => false; public MTObservableCollection AttachedGrids { get; } = new MTObservableCollection(); - public void UpdateAttachedGrids() + public async Task UpdateAttachedGrids() { //TODO: fix return; @@ -24,7 +25,7 @@ namespace Torch.Server.ViewModels.Entities AttachedGrids.Clear(); var box = Entity.WorldAABB; var entities = new List(); - MyGamePruningStructure.GetTopMostEntitiesInBox(ref box, entities, MyEntityQueryType.Static); + await TorchBase.Instance.InvokeAsync(() => MyEntities.GetTopMostEntitiesInBox(ref box, entities)).ConfigureAwait(false); foreach (var entity in entities.Where(e => e is IMyCubeGrid)) { var gridModel = Tree.Grids.FirstOrDefault(g => g.Entity.EntityId == entity.EntityId); diff --git a/Torch.Server/ViewModels/SessionSettingsViewModel.cs b/Torch.Server/ViewModels/SessionSettingsViewModel.cs index f8d380a..9dc583b 100644 --- a/Torch.Server/ViewModels/SessionSettingsViewModel.cs +++ b/Torch.Server/ViewModels/SessionSettingsViewModel.cs @@ -10,15 +10,24 @@ using VRage.Library.Utils; namespace Torch.Server.ViewModels { + /// + /// View model for + /// public class SessionSettingsViewModel : ViewModel { private MyObjectBuilder_SessionSettings _settings; + /// + /// Creates a new view model with a new object. + /// public SessionSettingsViewModel() : this(new MyObjectBuilder_SessionSettings()) { } + /// + /// Creates a view model using an existing object. + /// public SessionSettingsViewModel(MyObjectBuilder_SessionSettings settings) { _settings = settings; @@ -29,31 +38,38 @@ namespace Torch.Server.ViewModels public MTObservableCollection BlockLimits { get; } = new MTObservableCollection(); #region Multipliers + + /// public float InventorySizeMultiplier { get => _settings.InventorySizeMultiplier; set { _settings.InventorySizeMultiplier = value; OnPropertyChanged(); } } + /// public float RefinerySpeedMultiplier { get => _settings.RefinerySpeedMultiplier; set { _settings.RefinerySpeedMultiplier = value; OnPropertyChanged(); } } + /// public float AssemblerEfficiencyMultiplier { get => _settings.AssemblerEfficiencyMultiplier; set { _settings.AssemblerEfficiencyMultiplier = value; OnPropertyChanged(); } } + /// public float AssemblerSpeedMultiplier { get => _settings.AssemblerSpeedMultiplier; set { _settings.AssemblerSpeedMultiplier = value; OnPropertyChanged(); } } + /// public float GrinderSpeedMultiplier { get => _settings.GrinderSpeedMultiplier; set { _settings.GrinderSpeedMultiplier = value; OnPropertyChanged(); } } + /// public float HackSpeedMultiplier { get => _settings.HackSpeedMultiplier; set { _settings.HackSpeedMultiplier = value; OnPropertyChanged(); } @@ -61,26 +77,32 @@ namespace Torch.Server.ViewModels #endregion #region NPCs + + /// public bool EnableDrones { get => _settings.EnableDrones; set { _settings.EnableDrones = value; OnPropertyChanged(); } } + /// public bool EnableEncounters { get => _settings.EnableEncounters; set { _settings.EnableEncounters = value; OnPropertyChanged(); } } + /// public bool EnableSpiders { get => _settings.EnableSpiders; set { _settings.EnableSpiders = value; OnPropertyChanged(); } } + /// public bool EnableWolves { get => _settings.EnableWolfs; set { _settings.EnableWolfs = value; OnPropertyChanged(); } } + /// public bool EnableCargoShips { get => _settings.CargoShipsEnabled; set { _settings.CargoShipsEnabled = value; OnPropertyChanged(); } @@ -88,206 +110,253 @@ namespace Torch.Server.ViewModels #endregion #region Environment + + /// public bool EnableSunRotation { get => _settings.EnableSunRotation; set { _settings.EnableSunRotation = value; OnPropertyChanged(); } } + /// public bool EnableAirtightness { get => _settings.EnableOxygenPressurization; set { _settings.EnableOxygenPressurization = value; OnPropertyChanged(); } } + /// public bool EnableOxygen { get => _settings.EnableOxygen; set { _settings.EnableOxygen = value; OnPropertyChanged(); } } + /// public bool EnableDestructibleBlocks { get => _settings.DestructibleBlocks; set { _settings.DestructibleBlocks = value; OnPropertyChanged(); } } + /// public bool EnableToolShake { get => _settings.EnableToolShake; set { _settings.EnableToolShake = value; OnPropertyChanged(); } } + /// public bool EnableVoxelDestruction { get => _settings.EnableVoxelDestruction; set { _settings.EnableVoxelDestruction = value; OnPropertyChanged(); } } - public List EnvironmentHostilityValues => Enum.GetNames(typeof(MyEnvironmentHostilityEnum)).ToList(); + /// + /// List used to populate the environment hostility combo box. + /// + public List EnvironmentHostilityValues { get; } = Enum.GetNames(typeof(MyEnvironmentHostilityEnum)).ToList(); + /// public string EnvironmentHostility { get => _settings.EnvironmentHostility.ToString(); set { Enum.TryParse(value, true, out _settings.EnvironmentHostility); OnPropertyChanged(); } } + /// public bool EnableFlora { get => _settings.EnableFlora; set { _settings.EnableFlora = value; OnPropertyChanged(); } } #endregion - public List GameModeValues => Enum.GetNames(typeof(MyGameModeEnum)).ToList(); + /// + /// List used to populate the game mode combobox. + /// + public List GameModeValues { get; } = Enum.GetNames(typeof(MyGameModeEnum)).ToList(); + /// public string GameMode { get => _settings.GameMode.ToString(); set { Enum.TryParse(value, true, out _settings.GameMode); OnPropertyChanged(); } } + /// public bool EnableAutoHealing { get => _settings.AutoHealing; set { _settings.AutoHealing = value; OnPropertyChanged(); } } + /// public bool EnableCopyPaste { get => _settings.EnableCopyPaste; set { _settings.EnableCopyPaste = value; OnPropertyChanged(); } } + /// public bool ShowPlayerNamesOnHud { get => _settings.ShowPlayerNamesOnHud; set { _settings.ShowPlayerNamesOnHud = value; OnPropertyChanged(); } } + /// public bool EnableThirdPerson { get => _settings.Enable3rdPersonView; set { _settings.Enable3rdPersonView = value; OnPropertyChanged(); } } + /// public bool EnableSpectator { get => _settings.EnableSpectator; set { _settings.EnableSpectator = value; OnPropertyChanged(); } } + /// public bool SpawnWithTools { get => _settings.SpawnWithTools; set { _settings.SpawnWithTools = value; OnPropertyChanged(); } } + /// public bool EnableConvertToStation { get => _settings.EnableConvertToStation; set { _settings.EnableConvertToStation = value; OnPropertyChanged(); } } + /// public bool EnableJetpack { get => _settings.EnableJetpack; set { _settings.EnableJetpack = value; OnPropertyChanged(); } } + /// public bool EnableRemoteOwnerRemoval { get => _settings.EnableRemoteBlockRemoval; set { _settings.EnableRemoteBlockRemoval = value; OnPropertyChanged(); } } + /// public bool EnableRespawnShips { get => _settings.EnableRespawnShips; set { _settings.EnableRespawnShips = value; OnPropertyChanged(); } } + /// public bool EnableScripterRole { get => _settings.EnableScripterRole; set { _settings.EnableScripterRole = value; OnPropertyChanged(); } } + /// public bool EnableRealisticSound { get => _settings.RealisticSound; set { _settings.RealisticSound = value; OnPropertyChanged(); } } + /// public bool ResetOwnership { get => _settings.ResetOwnership; set { _settings.ResetOwnership = value; OnPropertyChanged(); } } + /// public bool DeleteRespawnShips { get => _settings.RespawnShipDelete; set { _settings.RespawnShipDelete = value; OnPropertyChanged(); } } + /// public bool EnableThrusterDamage { get => _settings.ThrusterDamage; set { _settings.ThrusterDamage = value; OnPropertyChanged(); } } + /// public bool EnableWeapons { get => _settings.WeaponsEnabled; set { _settings.WeaponsEnabled = value; OnPropertyChanged(); } } + /// public bool EnableIngameScripts { get => _settings.EnableIngameScripts; set { _settings.EnableIngameScripts = value; OnPropertyChanged(); } } + /// public uint AutosaveInterval { get => _settings.AutoSaveInMinutes; set { _settings.AutoSaveInMinutes = value; OnPropertyChanged(); } } + /// public int FloraDensity { get => _settings.FloraDensity; set { _settings.FloraDensity = value; OnPropertyChanged(); } } + /// public float FloraDensityMultiplier { get => _settings.FloraDensityMultiplier; set { _settings.FloraDensityMultiplier = value; OnPropertyChanged(); } } + /// public short MaxBackupSaves { get => _settings.MaxBackupSaves; set { _settings.MaxBackupSaves = value; OnPropertyChanged(); } } + /// public int MaxBlocksPerPlayer { get => _settings.MaxBlocksPerPlayer; set { _settings.MaxBlocksPerPlayer = value; OnPropertyChanged(); } } + /// public short MaxFloatingObjects { get => _settings.MaxFloatingObjects; set { _settings.MaxFloatingObjects = value; OnPropertyChanged(); } } + /// public int MaxGridSize { get => _settings.MaxGridSize; set { _settings.MaxGridSize = value; OnPropertyChanged(); } } + /// public short MaxPlayers { get => _settings.MaxPlayers; set { _settings.MaxPlayers = value; OnPropertyChanged(); } } + /// public int PhysicsIterations { get => _settings.PhysicsIterations; set { _settings.PhysicsIterations = value; OnPropertyChanged(); } } + /// public float SpawnTimeMultiplier { get => _settings.SpawnShipTimeMultiplier; set { _settings.SpawnShipTimeMultiplier = value; OnPropertyChanged(); } } + /// public float SunRotationInterval { get => _settings.SunRotationIntervalMinutes; set { _settings.SunRotationIntervalMinutes = value; OnPropertyChanged(); } } + /// public int ViewDistance { get => _settings.ViewDistance; set { _settings.ViewDistance = value; OnPropertyChanged(); } } + /// public int WorldSize { get => _settings.WorldSizeKm; set { _settings.WorldSizeKm = value; OnPropertyChanged(); } } + /// public static implicit operator MyObjectBuilder_SessionSettings(SessionSettingsViewModel viewModel) { viewModel._settings.BlockTypeLimits.Dictionary.Clear(); diff --git a/Torch.Server/Views/ChatControl.xaml.cs b/Torch.Server/Views/ChatControl.xaml.cs index 32c6755..5e9ab16 100644 --- a/Torch.Server/Views/ChatControl.xaml.cs +++ b/Torch.Server/Views/ChatControl.xaml.cs @@ -58,6 +58,9 @@ namespace Torch.Server { //Can't use Message.Text directly because of object ownership in WPF. var text = Message.Text; + if (string.IsNullOrEmpty(text)) + return; + var commands = _server.Commands; string response = null; if (commands.IsCommand(text)) diff --git a/Torch.Server/Views/ConfigControl.xaml b/Torch.Server/Views/ConfigControl.xaml index 0ad09d1..f399687 100644 --- a/Torch.Server/Views/ConfigControl.xaml +++ b/Torch.Server/Views/ConfigControl.xaml @@ -14,7 +14,7 @@