Assorted bug fixes, remove dead Torch.Launcher project
This commit is contained in:
@@ -8,11 +8,34 @@ namespace Torch.API
|
||||
[Flags]
|
||||
public enum ConnectionState
|
||||
{
|
||||
/// <summary>
|
||||
/// Unknown state.
|
||||
/// </summary>
|
||||
Unknown,
|
||||
|
||||
/// <summary>
|
||||
/// Connected to game.
|
||||
/// </summary>
|
||||
Connected = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Left the game.
|
||||
/// </summary>
|
||||
Left = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Disconnected from the game.
|
||||
/// </summary>
|
||||
Disconnected = 4,
|
||||
|
||||
/// <summary>
|
||||
/// Kicked from the game.
|
||||
/// </summary>
|
||||
Kicked = 8,
|
||||
|
||||
/// <summary>
|
||||
/// Banned from the game.
|
||||
/// </summary>
|
||||
Banned = 16,
|
||||
}
|
||||
}
|
@@ -8,9 +8,24 @@ namespace Torch.API
|
||||
{
|
||||
public interface IChatMessage
|
||||
{
|
||||
/// <summary>
|
||||
/// The time the message was created.
|
||||
/// </summary>
|
||||
DateTime Timestamp { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The SteamID of the message author.
|
||||
/// </summary>
|
||||
ulong SteamId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the message author.
|
||||
/// </summary>
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The content of the message.
|
||||
/// </summary>
|
||||
string Message { get; }
|
||||
}
|
||||
}
|
||||
|
@@ -7,10 +7,24 @@ using VRage.Game.ModAPI;
|
||||
|
||||
namespace Torch.API
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a player on the server.
|
||||
/// </summary>
|
||||
public interface IPlayer
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the player.
|
||||
/// </summary>
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The SteamID of the player.
|
||||
/// </summary>
|
||||
ulong SteamId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The player's current connection state.
|
||||
/// </summary>
|
||||
ConnectionState State { get; }
|
||||
}
|
||||
}
|
||||
|
20
Torch.API/ModAPI/TorchAPI.cs
Normal file
20
Torch.API/ModAPI/TorchAPI.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Entry point for mods to access Torch.
|
||||
/// </summary>
|
||||
public static class TorchAPI
|
||||
{
|
||||
internal static ITorchBase Instance;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}*/
|
||||
}
|
@@ -30,6 +30,7 @@
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<DocumentationFile>bin\x64\Release\Torch.API.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="HavokWrapper, Version=1.0.6278.22649, Culture=neutral, processorArchitecture=AMD64">
|
||||
@@ -168,10 +169,10 @@
|
||||
<Compile Include="ITorchBase.cs" />
|
||||
<Compile Include="Plugins\IWpfPlugin.cs" />
|
||||
<Compile Include="ModAPI\Ingame\GridExtensions.cs" />
|
||||
<Compile Include="ModAPI\TorchAPIGateway.cs" />
|
||||
<Compile Include="Plugins\PluginAttribute.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ServerState.cs" />
|
||||
<Compile Include="ModAPI\TorchAPI.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
@@ -35,6 +35,7 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<DocumentationFile>bin\x64\Release\Torch.Client.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>torchicon.ico</ApplicationIcon>
|
||||
|
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
|
||||
</startup>
|
||||
</configuration>
|
@@ -1,9 +0,0 @@
|
||||
<Application x:Class="Torch.Launcher.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Torch.Launcher"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
<Window x:Class="Torch.Launcher.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Torch.Launcher"
|
||||
mc:Ignorable="d"
|
||||
Title="Piston Launcher" ResizeMode="NoResize" Height="220" Width="400">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Label FontSize="50" Content="Piston Launcher" HorizontalAlignment="Center"/>
|
||||
<Button x:Name="LaunchBtn" FontSize="15" Height="25" Content="Launch" Margin="5,5,5,5" Click="LaunchBtn_Click"/>
|
||||
<Button x:Name="UpdateBtn" FontSize="15" Height="25" Content="Install/Update" Margin="5,5,5,5" Click="UpdateBtn_Click"/>
|
||||
<Label x:Name="InfoLabel" Margin="5,5,5,5" HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Window>
|
@@ -1,115 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
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.Navigation;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Torch.Launcher
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private Config _config;
|
||||
private TorchFileManager _fileManager;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
_config = Config.Load();
|
||||
Title += $" v{_config.Version}";
|
||||
_fileManager = new TorchFileManager(_config.RemoteFilePath);
|
||||
|
||||
CheckSpaceDirectory();
|
||||
CheckSEBranch();
|
||||
UpdatePistonFiles();
|
||||
}
|
||||
|
||||
protected override void OnClosing(CancelEventArgs e)
|
||||
{
|
||||
_config.Save();
|
||||
base.OnClosing(e);
|
||||
}
|
||||
|
||||
private bool CheckSpaceDirectory()
|
||||
{
|
||||
if (Directory.Exists(_config.SpaceDirectory) && Directory.GetFiles(_config.SpaceDirectory).Any(i => i.Contains("SpaceEngineers.exe")))
|
||||
return true;
|
||||
|
||||
var dialog = new SpaceDirPrompt();
|
||||
dialog.ShowDialog();
|
||||
|
||||
if (dialog.Success)
|
||||
{
|
||||
_config.SpaceDirectory = dialog.SelectedDir;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void CheckSEBranch()
|
||||
{
|
||||
try
|
||||
{
|
||||
var seAsm = Assembly.LoadFrom(Path.Combine(_config.SpaceDirectory, "VRage.Game.dll"));
|
||||
MessageBox.Show("found SE assembly");
|
||||
var gameType = seAsm.ExportedTypes.First(x => x.Name == "MyFinalBuildConstants");
|
||||
MessageBox.Show("found build constant class");
|
||||
var stable = (bool)gameType.GetField("IS_STABLE", BindingFlags.Public | BindingFlags.Static).GetValue(null);
|
||||
this.Title += $"SE Branch: {(stable ? "Stable" : "Develop")}";
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("Unable to check SE branch.\n\n" + e.Message + "\n\n" + e.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePistonFiles()
|
||||
{
|
||||
var i = 0;
|
||||
var files = _fileManager.GetDirectoryList();
|
||||
foreach (var file in files)
|
||||
{
|
||||
if (_fileManager.UpdateIfNew(file, _config.SpaceDirectory))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
InfoLabel.Content = $"Updated {i} files";
|
||||
}
|
||||
|
||||
private void LaunchBtn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!CheckSpaceDirectory())
|
||||
return;
|
||||
|
||||
Directory.SetCurrentDirectory(_config.SpaceDirectory);
|
||||
Process.Start(Path.Combine(_config.SpaceDirectory, "PistonClient.exe"));
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
private void UpdateBtn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var btn = (Button)sender;
|
||||
|
||||
btn.Content = "Up to date!";
|
||||
btn.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,55 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Piston.Launcher")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Piston.Launcher")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
//the line below to match the UICulture setting in the project file.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
63
Torch.Launcher/Properties/Resources.Designer.cs
generated
63
Torch.Launcher/Properties/Resources.Designer.cs
generated
@@ -1,63 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Torch.Launcher.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Torch.Launcher.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,117 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
26
Torch.Launcher/Properties/Settings.Designer.cs
generated
26
Torch.Launcher/Properties/Settings.Designer.cs
generated
@@ -1,26 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Torch.Launcher.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
@@ -1,14 +0,0 @@
|
||||
<Window x:Class="Torch.Launcher.SpaceDirPrompt"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Torch.Launcher"
|
||||
mc:Ignorable="d"
|
||||
Title="Select SE Directory" Height="120" Width="500">
|
||||
<StackPanel>
|
||||
<Label Content="SE not found in the default location. Please input the path of your game's Bin64 directory." HorizontalAlignment="Center"/>
|
||||
<TextBox x:Name="PathBox" Margin="5,5,5,5"/>
|
||||
<Button x:Name="OkButton" Content="OK" Margin="5,5,5,5" Click="OkButton_Click"></Button>
|
||||
</StackPanel>
|
||||
</Window>
|
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SpaceDirPrompt.xaml
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,117 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{19292801-5B9C-4EE0-961F-0FA37B3A6C3D}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Torch.Launcher</RootNamespace>
|
||||
<AssemblyName>Torch.Launcher</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="SpaceDirPrompt.xaml.cs">
|
||||
<DependentUpon>SpaceDirPrompt.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Config.cs" />
|
||||
<Compile Include="TorchFileManager.cs" />
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Page Include="SpaceDirPrompt.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
@@ -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<string> GetDirectoryList()
|
||||
{
|
||||
var fileList = new List<string>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,7 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<DocumentationFile>bin\x64\Release\Torch.Server.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>Torch.Server.Program</StartupObject>
|
||||
@@ -218,6 +219,7 @@
|
||||
<Compile Include="Views\AddWorkshopItemsDialog.xaml.cs">
|
||||
<DependentUpon>AddWorkshopItemsDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\Converters\InverseBooleanConverter.cs" />
|
||||
<Compile Include="Views\Converters\Vector3DConverter.cs" />
|
||||
<Compile Include="Views\Entities\Blocks\BlockView.xaml.cs">
|
||||
<DependentUpon>BlockView.xaml</DependentUpon>
|
||||
|
@@ -19,7 +19,6 @@ namespace Torch.Server
|
||||
public TorchService()
|
||||
{
|
||||
ServiceName = Name;
|
||||
EventLog.Log = "Application";
|
||||
|
||||
CanHandlePowerEvent = true;
|
||||
CanHandleSessionChangeEvent = false;
|
||||
|
@@ -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
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@@ -42,6 +43,6 @@ namespace Torch.Server.ViewModels
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler CanExecuteChanged;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
@@ -57,9 +57,12 @@ namespace Torch.Server.ViewModels
|
||||
public SessionSettingsViewModel SessionSettings { get; }
|
||||
|
||||
public ObservableCollection<string> WorldPaths { get; } = new ObservableCollection<string>();
|
||||
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
|
||||
{
|
||||
|
@@ -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<GridViewModel> AttachedGrids { get; } = new MTObservableCollection<GridViewModel>();
|
||||
|
||||
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<MyEntity>();
|
||||
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);
|
||||
|
@@ -10,15 +10,24 @@ using VRage.Library.Utils;
|
||||
|
||||
namespace Torch.Server.ViewModels
|
||||
{
|
||||
/// <summary>
|
||||
/// View model for <see cref="MyObjectBuilder_SessionSettings"/>
|
||||
/// </summary>
|
||||
public class SessionSettingsViewModel : ViewModel
|
||||
{
|
||||
private MyObjectBuilder_SessionSettings _settings;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new view model with a new <see cref="MyObjectBuilder_SessionSettings"/> object.
|
||||
/// </summary>
|
||||
public SessionSettingsViewModel() : this(new MyObjectBuilder_SessionSettings())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a view model using an existing <see cref="MyObjectBuilder_SessionSettings"/> object.
|
||||
/// </summary>
|
||||
public SessionSettingsViewModel(MyObjectBuilder_SessionSettings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
@@ -29,31 +38,38 @@ namespace Torch.Server.ViewModels
|
||||
public MTObservableCollection<BlockLimitViewModel> BlockLimits { get; } = new MTObservableCollection<BlockLimitViewModel>();
|
||||
|
||||
#region Multipliers
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.InventorySizeMultiplier"/>
|
||||
public float InventorySizeMultiplier
|
||||
{
|
||||
get => _settings.InventorySizeMultiplier; set { _settings.InventorySizeMultiplier = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.RefinerySpeedMultiplier"/>
|
||||
public float RefinerySpeedMultiplier
|
||||
{
|
||||
get => _settings.RefinerySpeedMultiplier; set { _settings.RefinerySpeedMultiplier = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.AssemblerEfficiencyMultiplier"/>
|
||||
public float AssemblerEfficiencyMultiplier
|
||||
{
|
||||
get => _settings.AssemblerEfficiencyMultiplier; set { _settings.AssemblerEfficiencyMultiplier = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.AssemblerSpeedMultiplier"/>
|
||||
public float AssemblerSpeedMultiplier
|
||||
{
|
||||
get => _settings.AssemblerSpeedMultiplier; set { _settings.AssemblerSpeedMultiplier = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.GrinderSpeedMultiplier"/>
|
||||
public float GrinderSpeedMultiplier
|
||||
{
|
||||
get => _settings.GrinderSpeedMultiplier; set { _settings.GrinderSpeedMultiplier = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.HackSpeedMultiplier"/>
|
||||
public float HackSpeedMultiplier
|
||||
{
|
||||
get => _settings.HackSpeedMultiplier; set { _settings.HackSpeedMultiplier = value; OnPropertyChanged(); }
|
||||
@@ -61,26 +77,32 @@ namespace Torch.Server.ViewModels
|
||||
#endregion
|
||||
|
||||
#region NPCs
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.EnableDrones"/>
|
||||
public bool EnableDrones
|
||||
{
|
||||
get => _settings.EnableDrones; set { _settings.EnableDrones = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.EnableEncounters"/>
|
||||
public bool EnableEncounters
|
||||
{
|
||||
get => _settings.EnableEncounters; set { _settings.EnableEncounters = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.EnableSpiders"/>
|
||||
public bool EnableSpiders
|
||||
{
|
||||
get => _settings.EnableSpiders; set { _settings.EnableSpiders = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.EnableWolfs"/>
|
||||
public bool EnableWolves
|
||||
{
|
||||
get => _settings.EnableWolfs; set { _settings.EnableWolfs = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.CargoShipsEnabled"/>
|
||||
public bool EnableCargoShips
|
||||
{
|
||||
get => _settings.CargoShipsEnabled; set { _settings.CargoShipsEnabled = value; OnPropertyChanged(); }
|
||||
@@ -88,206 +110,253 @@ namespace Torch.Server.ViewModels
|
||||
#endregion
|
||||
|
||||
#region Environment
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.EnableSunRotation"/>
|
||||
public bool EnableSunRotation
|
||||
{
|
||||
get => _settings.EnableSunRotation; set { _settings.EnableSunRotation = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.EnableOxygenPressurization"/>
|
||||
public bool EnableAirtightness
|
||||
{
|
||||
get => _settings.EnableOxygenPressurization; set { _settings.EnableOxygenPressurization = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.EnableOxygen"/>
|
||||
public bool EnableOxygen
|
||||
{
|
||||
get => _settings.EnableOxygen; set { _settings.EnableOxygen = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.DestructibleBlocks"/>
|
||||
public bool EnableDestructibleBlocks
|
||||
{
|
||||
get => _settings.DestructibleBlocks; set { _settings.DestructibleBlocks = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.EnableToolShake"/>
|
||||
public bool EnableToolShake
|
||||
{
|
||||
get => _settings.EnableToolShake; set { _settings.EnableToolShake = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.EnableVoxelDestruction"/>
|
||||
public bool EnableVoxelDestruction
|
||||
{
|
||||
get => _settings.EnableVoxelDestruction; set { _settings.EnableVoxelDestruction = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
public List<string> EnvironmentHostilityValues => Enum.GetNames(typeof(MyEnvironmentHostilityEnum)).ToList();
|
||||
/// <summary>
|
||||
/// List used to populate the environment hostility combo box.
|
||||
/// </summary>
|
||||
public List<string> EnvironmentHostilityValues { get; } = Enum.GetNames(typeof(MyEnvironmentHostilityEnum)).ToList();
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.EnvironmentHostility"/>
|
||||
public string EnvironmentHostility
|
||||
{
|
||||
get => _settings.EnvironmentHostility.ToString(); set { Enum.TryParse(value, true, out _settings.EnvironmentHostility); OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.EnableFlora"/>
|
||||
public bool EnableFlora
|
||||
{
|
||||
get => _settings.EnableFlora; set { _settings.EnableFlora = value; OnPropertyChanged(); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
public List<string> GameModeValues => Enum.GetNames(typeof(MyGameModeEnum)).ToList();
|
||||
/// <summary>
|
||||
/// List used to populate the game mode combobox.
|
||||
/// </summary>
|
||||
public List<string> GameModeValues { get; } = Enum.GetNames(typeof(MyGameModeEnum)).ToList();
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.GameMode"/>
|
||||
public string GameMode
|
||||
{
|
||||
get => _settings.GameMode.ToString(); set { Enum.TryParse(value, true, out _settings.GameMode); OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.AutoHealing"/>
|
||||
public bool EnableAutoHealing
|
||||
{
|
||||
get => _settings.AutoHealing; set { _settings.AutoHealing = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.EnableCopyPaste"/>
|
||||
public bool EnableCopyPaste
|
||||
{
|
||||
get => _settings.EnableCopyPaste; set { _settings.EnableCopyPaste = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.ShowPlayerNamesOnHud"/>
|
||||
public bool ShowPlayerNamesOnHud
|
||||
{
|
||||
get => _settings.ShowPlayerNamesOnHud; set { _settings.ShowPlayerNamesOnHud = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.Enable3rdPersonView"/>
|
||||
public bool EnableThirdPerson
|
||||
{
|
||||
get => _settings.Enable3rdPersonView; set { _settings.Enable3rdPersonView = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.EnableSpectator"/>
|
||||
public bool EnableSpectator
|
||||
{
|
||||
get => _settings.EnableSpectator; set { _settings.EnableSpectator = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.SpawnWithTools"/>
|
||||
public bool SpawnWithTools
|
||||
{
|
||||
get => _settings.SpawnWithTools; set { _settings.SpawnWithTools = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.EnableConvertToStation"/>
|
||||
public bool EnableConvertToStation
|
||||
{
|
||||
get => _settings.EnableConvertToStation; set { _settings.EnableConvertToStation = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.EnableJetpack"/>
|
||||
public bool EnableJetpack
|
||||
{
|
||||
get => _settings.EnableJetpack; set { _settings.EnableJetpack = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.EnableRemoteBlockRemoval"/>
|
||||
public bool EnableRemoteOwnerRemoval
|
||||
{
|
||||
get => _settings.EnableRemoteBlockRemoval; set { _settings.EnableRemoteBlockRemoval = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.EnableRespawnShips"/>
|
||||
public bool EnableRespawnShips
|
||||
{
|
||||
get => _settings.EnableRespawnShips; set { _settings.EnableRespawnShips = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.EnableScripterRole"/>
|
||||
public bool EnableScripterRole
|
||||
{
|
||||
get => _settings.EnableScripterRole; set { _settings.EnableScripterRole = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.RealisticSound"/>
|
||||
public bool EnableRealisticSound
|
||||
{
|
||||
get => _settings.RealisticSound; set { _settings.RealisticSound = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.ResetOwnership"/>
|
||||
public bool ResetOwnership
|
||||
{
|
||||
get => _settings.ResetOwnership; set { _settings.ResetOwnership = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.RespawnShipDelete"/>
|
||||
public bool DeleteRespawnShips
|
||||
{
|
||||
get => _settings.RespawnShipDelete; set { _settings.RespawnShipDelete = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.ThrusterDamage"/>
|
||||
public bool EnableThrusterDamage
|
||||
{
|
||||
get => _settings.ThrusterDamage; set { _settings.ThrusterDamage = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.WeaponsEnabled"/>
|
||||
public bool EnableWeapons
|
||||
{
|
||||
get => _settings.WeaponsEnabled; set { _settings.WeaponsEnabled = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.EnableIngameScripts"/>
|
||||
public bool EnableIngameScripts
|
||||
{
|
||||
get => _settings.EnableIngameScripts; set { _settings.EnableIngameScripts = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.AutoSaveInMinutes"/>
|
||||
public uint AutosaveInterval
|
||||
{
|
||||
get => _settings.AutoSaveInMinutes; set { _settings.AutoSaveInMinutes = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.FloraDensity"/>
|
||||
public int FloraDensity
|
||||
{
|
||||
get => _settings.FloraDensity; set { _settings.FloraDensity = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.FloraDensityMultiplier"/>
|
||||
public float FloraDensityMultiplier
|
||||
{
|
||||
get => _settings.FloraDensityMultiplier; set { _settings.FloraDensityMultiplier = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.MaxBackupSaves"/>
|
||||
public short MaxBackupSaves
|
||||
{
|
||||
get => _settings.MaxBackupSaves; set { _settings.MaxBackupSaves = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.MaxBlocksPerPlayer"/>
|
||||
public int MaxBlocksPerPlayer
|
||||
{
|
||||
get => _settings.MaxBlocksPerPlayer; set { _settings.MaxBlocksPerPlayer = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.MaxFloatingObjects"/>
|
||||
public short MaxFloatingObjects
|
||||
{
|
||||
get => _settings.MaxFloatingObjects; set { _settings.MaxFloatingObjects = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.MaxGridSize"/>
|
||||
public int MaxGridSize
|
||||
{
|
||||
get => _settings.MaxGridSize; set { _settings.MaxGridSize = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.MaxPlayers"/>
|
||||
public short MaxPlayers
|
||||
{
|
||||
get => _settings.MaxPlayers; set { _settings.MaxPlayers = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.PhysicsIterations"/>
|
||||
public int PhysicsIterations
|
||||
{
|
||||
get => _settings.PhysicsIterations; set { _settings.PhysicsIterations = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.SpawnShipTimeMultiplier"/>
|
||||
public float SpawnTimeMultiplier
|
||||
{
|
||||
get => _settings.SpawnShipTimeMultiplier; set { _settings.SpawnShipTimeMultiplier = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.SunRotationIntervalMinutes"/>
|
||||
public float SunRotationInterval
|
||||
{
|
||||
get => _settings.SunRotationIntervalMinutes; set { _settings.SunRotationIntervalMinutes = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.ViewDistance"/>
|
||||
public int ViewDistance
|
||||
{
|
||||
get => _settings.ViewDistance; set { _settings.ViewDistance = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MyObjectBuilder_SessionSettings.WorldSizeKm"/>
|
||||
public int WorldSize
|
||||
{
|
||||
get => _settings.WorldSizeKm; set { _settings.WorldSizeKm = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary />
|
||||
public static implicit operator MyObjectBuilder_SessionSettings(SessionSettingsViewModel viewModel)
|
||||
{
|
||||
viewModel._settings.BlockTypeLimits.Dictionary.Clear();
|
||||
|
@@ -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))
|
||||
|
@@ -14,7 +14,7 @@
|
||||
<DockPanel DockPanel.Dock="Top">
|
||||
<Label Content="World:" DockPanel.Dock="Left" />
|
||||
<Button Content="New World" Margin="3" DockPanel.Dock="Right" Click="NewWorld_OnClick"/>
|
||||
<ComboBox Text="{Binding LoadWorld}" ItemsSource="{Binding WorldPaths}" IsEditable="True" Margin="3" />
|
||||
<ComboBox Text="{Binding LoadWorld}" ItemsSource="{Binding WorldPaths}" IsEditable="True" Margin="3" SelectionChanged="Selector_OnSelectionChanged"/>
|
||||
</DockPanel>
|
||||
<DockPanel DockPanel.Dock="Bottom">
|
||||
<StackPanel DockPanel.Dock="Left">
|
||||
|
@@ -40,6 +40,7 @@ namespace Torch.Server.Views
|
||||
public MyConfigDedicated<MyObjectBuilder_SessionSettings> Config { get; set; }
|
||||
private ConfigDedicatedViewModel _viewModel;
|
||||
private string _configPath;
|
||||
private TorchConfig _torchConfig;
|
||||
|
||||
public ConfigControl()
|
||||
{
|
||||
@@ -76,6 +77,8 @@ namespace Torch.Server.Views
|
||||
|
||||
public void LoadDedicatedConfig(TorchConfig torchConfig)
|
||||
{
|
||||
_torchConfig = torchConfig;
|
||||
DataContext = null;
|
||||
MySandboxGame.Config = new MyConfig(MyPerServerSettings.GameNameSafe + ".cfg");
|
||||
var path = Path.Combine(torchConfig.InstancePath, "SpaceEngineers-Dedicated.cfg");
|
||||
|
||||
@@ -90,45 +93,38 @@ namespace Torch.Server.Views
|
||||
Config.Load(path);
|
||||
_configPath = path;
|
||||
|
||||
var checkpoint = MyLocalCache.LoadCheckpoint(Config.LoadWorld, out ulong _);
|
||||
if (checkpoint == null)
|
||||
{
|
||||
Log.Error("Failed to load checkpoint when loading DS config.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Config.Mods.Clear();
|
||||
foreach (var mod in checkpoint.Mods)
|
||||
Config.Mods.Add(mod.PublishedFileId);
|
||||
}
|
||||
|
||||
_viewModel = new ConfigDedicatedViewModel(Config);
|
||||
var worldFolders = Directory.EnumerateDirectories(Path.Combine(torchConfig.InstancePath, "Saves"));
|
||||
|
||||
foreach (var f in worldFolders)
|
||||
_viewModel.WorldPaths.Add(f);
|
||||
|
||||
LoadWorldMods();
|
||||
DataContext = _viewModel;
|
||||
}
|
||||
|
||||
/*
|
||||
private void Banned_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
private void LoadWorldMods()
|
||||
{
|
||||
var editor = new CollectionEditor {Owner = Window.GetWindow(this)};
|
||||
editor.Edit(_viewModel.Banned, "Banned Players");
|
||||
}
|
||||
var sandboxPath = Path.Combine(Config.LoadWorld, "Sandbox.sbc");
|
||||
|
||||
private void Administrators_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var editor = new CollectionEditor { Owner = Window.GetWindow(this) };
|
||||
editor.Edit(_viewModel.Administrators, "Administrators");
|
||||
}
|
||||
if (!File.Exists(sandboxPath))
|
||||
return;
|
||||
|
||||
private void Mods_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var editor = new CollectionEditor { Owner = Window.GetWindow(this) };
|
||||
editor.Edit(_viewModel.Mods, "Mods");
|
||||
}*/
|
||||
MyObjectBuilderSerializer.DeserializeXML(sandboxPath, out MyObjectBuilder_Checkpoint checkpoint, out ulong sizeInBytes);
|
||||
if (checkpoint == null)
|
||||
{
|
||||
Log.Error($"Failed to load {Config.LoadWorld}, checkpoint null ({sizeInBytes} bytes, instance {TorchBase.Instance.Config.InstancePath})");
|
||||
return;
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
foreach (var mod in checkpoint.Mods)
|
||||
sb.AppendLine(mod.PublishedFileId.ToString());
|
||||
|
||||
_viewModel.Mods = sb.ToString();
|
||||
|
||||
Log.Info("Loaded mod list from world");
|
||||
}
|
||||
|
||||
private void Save_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
@@ -150,5 +146,15 @@ namespace Torch.Server.Views
|
||||
{
|
||||
MessageBox.Show("Feature coming soon :)");
|
||||
}
|
||||
|
||||
private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
//The control doesn't update the binding before firing the event.
|
||||
if (e.AddedItems.Count > 0)
|
||||
{
|
||||
Config.LoadWorld = (string)e.AddedItems[0];
|
||||
LoadWorldMods();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
32
Torch.Server/Views/Converters/InverseBooleanConverter.cs
Normal file
32
Torch.Server/Views/Converters/InverseBooleanConverter.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Torch.Server.Views.Converters
|
||||
{
|
||||
[ValueConversion(typeof(bool), typeof(bool))]
|
||||
public class InverseBooleanConverter : IValueConverter
|
||||
{
|
||||
#region IValueConverter Members
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter,
|
||||
System.Globalization.CultureInfo culture)
|
||||
{
|
||||
if (targetType != typeof(bool))
|
||||
throw new InvalidOperationException("The target must be a boolean");
|
||||
|
||||
return !(bool)value;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter,
|
||||
System.Globalization.CultureInfo culture)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -29,7 +29,7 @@ namespace Torch.Server.Views.Entities
|
||||
|
||||
private void VoxelMapView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
((VoxelMapViewModel)e.NewValue).UpdateAttachedGrids();
|
||||
Task.Run(() => ((VoxelMapViewModel)e.NewValue).UpdateAttachedGrids()).Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -68,8 +68,8 @@ namespace Torch.Server.Views
|
||||
|
||||
private void TreeViewItem_OnExpanded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
LogManager.GetLogger("EntitiesControl").Debug(nameof(TreeViewItem_OnExpanded));
|
||||
var item = (TreeViewItem)e.Source;
|
||||
//Exact item that was expanded.
|
||||
var item = (TreeViewItem)e.OriginalSource;
|
||||
if (item.DataContext is ILazyLoad l)
|
||||
l.Load();
|
||||
}
|
||||
|
@@ -11,8 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Torch.Client", "Torch.Clien
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Torch.Server", "Torch.Server\Torch.Server.csproj", "{CA50886B-7B22-4CD8-93A0-C06F38D4F77D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Torch.Launcher", "Torch.Launcher\Torch.Launcher.csproj", "{19292801-5B9C-4EE0-961F-0FA37B3A6C3D}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7AD02A71-1D4C-48F9-A8C1-789A5512424F}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
NLog.config = NLog.config
|
||||
@@ -40,10 +38,6 @@ Global
|
||||
{CA50886B-7B22-4CD8-93A0-C06F38D4F77D}.Debug|x64.Build.0 = Debug|x64
|
||||
{CA50886B-7B22-4CD8-93A0-C06F38D4F77D}.Release|x64.ActiveCfg = Release|x64
|
||||
{CA50886B-7B22-4CD8-93A0-C06F38D4F77D}.Release|x64.Build.0 = Release|x64
|
||||
{19292801-5B9C-4EE0-961F-0FA37B3A6C3D}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{19292801-5B9C-4EE0-961F-0FA37B3A6C3D}.Debug|x64.Build.0 = Debug|x64
|
||||
{19292801-5B9C-4EE0-961F-0FA37B3A6C3D}.Release|x64.ActiveCfg = Release|x64
|
||||
{19292801-5B9C-4EE0-961F-0FA37B3A6C3D}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@@ -83,11 +83,13 @@ namespace Torch.Managers
|
||||
|
||||
public IMyPlayer GetPlayerByName(string name)
|
||||
{
|
||||
ValidateOnlinePlayersList();
|
||||
return _onlinePlayers.FirstOrDefault(x => x.Value.DisplayName == name).Value;
|
||||
}
|
||||
|
||||
public IMyPlayer GetPlayerBySteamId(ulong steamId)
|
||||
{
|
||||
ValidateOnlinePlayersList();
|
||||
_onlinePlayers.TryGetValue(new MyPlayer.PlayerId(steamId), out MyPlayer p);
|
||||
return p;
|
||||
}
|
||||
@@ -116,12 +118,18 @@ namespace Torch.Managers
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateOnlinePlayersList()
|
||||
{
|
||||
if (_onlinePlayers == null)
|
||||
_onlinePlayers = MySession.Static.Players.GetPrivateField<Dictionary<MyPlayer.PlayerId, MyPlayer>>("m_players");
|
||||
}
|
||||
|
||||
private void OnSessionLoaded()
|
||||
{
|
||||
MyMultiplayer.Static.ClientKicked += OnClientKicked;
|
||||
MyMultiplayer.Static.ClientLeft += OnClientLeft;
|
||||
|
||||
_onlinePlayers = MySession.Static.Players.GetPrivateField<Dictionary<MyPlayer.PlayerId, MyPlayer>>("m_players");
|
||||
ValidateOnlinePlayersList();
|
||||
|
||||
//TODO: Move these with the methods?
|
||||
RemoveHandlers();
|
||||
|
@@ -27,6 +27,7 @@ namespace Torch.Managers
|
||||
/// <param name="site"></param>
|
||||
/// <param name="stream"></param>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="packet"></param>
|
||||
/// <returns></returns>
|
||||
public abstract bool Handle(ulong remoteUserId, CallSite site, BitStream stream, object obj, MyPacket packet);
|
||||
|
||||
|
@@ -5,13 +5,14 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Sandbox.ModAPI;
|
||||
using Torch.API;
|
||||
using Torch.API.Managers;
|
||||
using Torch.API.ModAPI;
|
||||
using Torch.API.ModAPI.Ingame;
|
||||
using VRage.Scripting;
|
||||
|
||||
namespace Torch.Managers
|
||||
{
|
||||
public class ScriptingManager
|
||||
public class ScriptingManager : IManager
|
||||
{
|
||||
private MyScriptWhitelist _whitelist;
|
||||
|
||||
@@ -24,7 +25,7 @@ namespace Torch.Managers
|
||||
|
||||
using (var whitelist = _whitelist.OpenBatch())
|
||||
{
|
||||
//whitelist.AllowNamespaceOfTypes(MyWhitelistTarget.ModApi, typeof(TorchAPIGateway));
|
||||
whitelist.AllowNamespaceOfTypes(MyWhitelistTarget.ModApi, typeof(TorchAPI));
|
||||
whitelist.AllowNamespaceOfTypes(MyWhitelistTarget.Both, typeof(GridExtensions));
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ namespace Torch.Managers
|
||||
/// <summary>
|
||||
/// Handles updating of the DS and Torch plugins.
|
||||
/// </summary>
|
||||
public class UpdateManager
|
||||
public class UpdateManager : IDisposable
|
||||
{
|
||||
private Timer _updatePollTimer;
|
||||
|
||||
@@ -24,5 +24,11 @@ namespace Torch.Managers
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
_updatePollTimer?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -9,10 +9,10 @@ using Newtonsoft.Json;
|
||||
namespace Torch
|
||||
{
|
||||
/// <summary>
|
||||
/// Simple class that manages saving <see cref="T"/> to disk using JSON serialization.
|
||||
/// Simple class that manages saving <see cref="Persistent{T}.Data"/> to disk using JSON serialization.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Data class</typeparam>
|
||||
public class Persistent<T> : IDisposable where T : new()
|
||||
/// <typeparam name="T">Data class type</typeparam>
|
||||
public sealed class Persistent<T> : IDisposable where T : new()
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public T Data { get; private set; }
|
||||
|
@@ -30,6 +30,7 @@
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<DocumentationFile>bin\x64\Release\Torch.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="HavokWrapper, Version=1.0.6278.22649, Culture=neutral, processorArchitecture=AMD64">
|
||||
|
@@ -18,6 +18,7 @@ using Sandbox.ModAPI;
|
||||
using SpaceEngineers.Game;
|
||||
using Torch.API;
|
||||
using Torch.API.Managers;
|
||||
using Torch.API.ModAPI;
|
||||
using Torch.Commands;
|
||||
using Torch.Managers;
|
||||
using VRage.Collections;
|
||||
@@ -30,6 +31,9 @@ using VRage.Utils;
|
||||
|
||||
namespace Torch
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for code shared between the Torch client and server.
|
||||
/// </summary>
|
||||
public abstract class TorchBase : ViewModel, ITorchBase, IPlugin
|
||||
{
|
||||
/// <summary>
|
||||
@@ -51,10 +55,14 @@ namespace Torch
|
||||
public event Action SessionLoaded;
|
||||
public event Action SessionUnloading;
|
||||
public event Action SessionUnloaded;
|
||||
private HashSet<IManager> _managers;
|
||||
private readonly List<IManager> _managers;
|
||||
|
||||
private bool _init;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if a TorchBase instance already exists.</exception>
|
||||
protected TorchBase()
|
||||
{
|
||||
if (Instance != null)
|
||||
@@ -71,19 +79,15 @@ namespace Torch
|
||||
Network = new NetworkManager(this);
|
||||
Commands = new CommandManager(this);
|
||||
|
||||
_managers = new HashSet<IManager>
|
||||
{
|
||||
Plugins,
|
||||
Multiplayer,
|
||||
Entities,
|
||||
Network,
|
||||
Commands
|
||||
};
|
||||
_managers = new List<IManager> {Network, Commands, Plugins, Multiplayer, Entities, new ChatManager(this)};
|
||||
|
||||
|
||||
TorchAPI.Instance = this;
|
||||
}
|
||||
|
||||
public HashSetReader<IManager> GetManagers()
|
||||
public ListReader<IManager> GetManagers()
|
||||
{
|
||||
return new HashSetReader<IManager>(_managers);
|
||||
return new ListReader<IManager>(_managers);
|
||||
}
|
||||
|
||||
public T GetManager<T>() where T : class, IManager
|
||||
@@ -120,11 +124,11 @@ namespace Torch
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
if (!e.WaitOne(60000))
|
||||
{
|
||||
Log.Error("Save failed!");
|
||||
Multiplayer.SendMessage("Save timed out!", "Error");
|
||||
}
|
||||
if (e.WaitOne(60000))
|
||||
return;
|
||||
|
||||
Log.Error("Save failed!");
|
||||
Multiplayer.SendMessage("Save timed out!", "Error");
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -251,7 +255,7 @@ namespace Torch
|
||||
|
||||
public virtual void Start()
|
||||
{
|
||||
Plugins.Init();
|
||||
|
||||
}
|
||||
|
||||
public virtual void Stop() { }
|
||||
|
Reference in New Issue
Block a user