diff --git a/Piston.Launcher/MainWindow.xaml b/Piston.Launcher/MainWindow.xaml
index 7d42326..02a3754 100644
--- a/Piston.Launcher/MainWindow.xaml
+++ b/Piston.Launcher/MainWindow.xaml
@@ -8,8 +8,8 @@
Title="Piston Launcher" ResizeMode="NoResize" Height="220" Width="400">
-
-
+
+
diff --git a/Piston.Launcher/MainWindow.xaml.cs b/Piston.Launcher/MainWindow.xaml.cs
index a7a6811..24fad6c 100644
--- a/Piston.Launcher/MainWindow.xaml.cs
+++ b/Piston.Launcher/MainWindow.xaml.cs
@@ -14,6 +14,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.IO;
+using System.Reflection;
using Microsoft.Win32;
namespace Piston.Launcher
@@ -25,6 +26,7 @@ namespace Piston.Launcher
{
private Config _config;
private PistonFileManager _fileManager;
+
public MainWindow()
{
InitializeComponent();
@@ -33,6 +35,7 @@ namespace Piston.Launcher
_fileManager = new PistonFileManager(_config.RemoteFilePath);
CheckSpaceDirectory();
+ CheckSEBranch();
UpdatePistonFiles();
}
@@ -59,6 +62,23 @@ namespace Piston.Launcher
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;
@@ -79,7 +99,7 @@ namespace Piston.Launcher
if (!CheckSpaceDirectory())
return;
- Directory.SetCurrentDirectory(_config.SpaceDirectory);
+ Directory.SetCurrentDirectory(_config.SpaceDirectory);
Process.Start(Path.Combine(_config.SpaceDirectory, "PistonClient.exe"));
Environment.Exit(0);
}
diff --git a/Piston.Launcher/Piston.Launcher.csproj b/Piston.Launcher/Piston.Launcher.csproj
index 23d118c..b4f03d0 100644
--- a/Piston.Launcher/Piston.Launcher.csproj
+++ b/Piston.Launcher/Piston.Launcher.csproj
@@ -16,25 +16,6 @@
true
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
true
bin\x64\Debug\
diff --git a/Piston.sln b/Piston.sln
index a14ebaa..a045d92 100644
--- a/Piston.sln
+++ b/Piston.sln
@@ -17,60 +17,34 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Piston.Launcher", "Piston.L
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
- Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {7E01635C-3B67-472E-BCD6-C5539564F214}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7E01635C-3B67-472E-BCD6-C5539564F214}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7E01635C-3B67-472E-BCD6-C5539564F214}.Debug|x64.ActiveCfg = Debug|x64
{7E01635C-3B67-472E-BCD6-C5539564F214}.Debug|x64.Build.0 = Debug|x64
- {7E01635C-3B67-472E-BCD6-C5539564F214}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7E01635C-3B67-472E-BCD6-C5539564F214}.Release|Any CPU.Build.0 = Release|Any CPU
{7E01635C-3B67-472E-BCD6-C5539564F214}.Release|x64.ActiveCfg = Release|x64
{7E01635C-3B67-472E-BCD6-C5539564F214}.Release|x64.Build.0 = Release|x64
- {FBA5D932-6254-4A1E-BAF4-E229FA94E3C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {FBA5D932-6254-4A1E-BAF4-E229FA94E3C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FBA5D932-6254-4A1E-BAF4-E229FA94E3C2}.Debug|x64.ActiveCfg = Debug|x64
{FBA5D932-6254-4A1E-BAF4-E229FA94E3C2}.Debug|x64.Build.0 = Debug|x64
- {FBA5D932-6254-4A1E-BAF4-E229FA94E3C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {FBA5D932-6254-4A1E-BAF4-E229FA94E3C2}.Release|Any CPU.Build.0 = Release|Any CPU
{FBA5D932-6254-4A1E-BAF4-E229FA94E3C2}.Release|x64.ActiveCfg = Release|x64
{FBA5D932-6254-4A1E-BAF4-E229FA94E3C2}.Release|x64.Build.0 = Release|x64
- {E36DF745-260B-4956-A2E8-09F08B2E7161}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E36DF745-260B-4956-A2E8-09F08B2E7161}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E36DF745-260B-4956-A2E8-09F08B2E7161}.Debug|x64.ActiveCfg = Debug|x64
{E36DF745-260B-4956-A2E8-09F08B2E7161}.Debug|x64.Build.0 = Debug|x64
- {E36DF745-260B-4956-A2E8-09F08B2E7161}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E36DF745-260B-4956-A2E8-09F08B2E7161}.Release|Any CPU.Build.0 = Release|Any CPU
{E36DF745-260B-4956-A2E8-09F08B2E7161}.Release|x64.ActiveCfg = Release|x64
{E36DF745-260B-4956-A2E8-09F08B2E7161}.Release|x64.Build.0 = Release|x64
- {CA50886B-7B22-4CD8-93A0-C06F38D4F77D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {CA50886B-7B22-4CD8-93A0-C06F38D4F77D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CA50886B-7B22-4CD8-93A0-C06F38D4F77D}.Debug|x64.ActiveCfg = Debug|x64
{CA50886B-7B22-4CD8-93A0-C06F38D4F77D}.Debug|x64.Build.0 = Debug|x64
- {CA50886B-7B22-4CD8-93A0-C06F38D4F77D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {CA50886B-7B22-4CD8-93A0-C06F38D4F77D}.Release|Any CPU.Build.0 = Release|Any CPU
{CA50886B-7B22-4CD8-93A0-C06F38D4F77D}.Release|x64.ActiveCfg = Release|x64
{CA50886B-7B22-4CD8-93A0-C06F38D4F77D}.Release|x64.Build.0 = Release|x64
- {BF0D9941-B488-4880-B378-A9BF942D140D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {BF0D9941-B488-4880-B378-A9BF942D140D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BF0D9941-B488-4880-B378-A9BF942D140D}.Debug|x64.ActiveCfg = Debug|x64
{BF0D9941-B488-4880-B378-A9BF942D140D}.Debug|x64.Build.0 = Debug|x64
- {BF0D9941-B488-4880-B378-A9BF942D140D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {BF0D9941-B488-4880-B378-A9BF942D140D}.Release|Any CPU.Build.0 = Release|Any CPU
{BF0D9941-B488-4880-B378-A9BF942D140D}.Release|x64.ActiveCfg = Release|x64
{BF0D9941-B488-4880-B378-A9BF942D140D}.Release|x64.Build.0 = Release|x64
- {19292801-5B9C-4EE0-961F-0FA37B3A6C3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {19292801-5B9C-4EE0-961F-0FA37B3A6C3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{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|Any CPU.ActiveCfg = Release|Any CPU
- {19292801-5B9C-4EE0-961F-0FA37B3A6C3D}.Release|Any CPU.Build.0 = Release|Any CPU
- {19292801-5B9C-4EE0-961F-0FA37B3A6C3D}.Release|x64.ActiveCfg = Release|Any CPU
- {19292801-5B9C-4EE0-961F-0FA37B3A6C3D}.Release|x64.Build.0 = Release|Any CPU
+ {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
diff --git a/Piston/Piston.csproj b/Piston/Piston.csproj
index 4cee744..231e886 100644
--- a/Piston/Piston.csproj
+++ b/Piston/Piston.csproj
@@ -13,23 +13,6 @@
512
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
true
bin\x64\Debug\
diff --git a/PistonAPI/Piston.API.csproj b/PistonAPI/Piston.API.csproj
index d465695..612c220 100644
--- a/PistonAPI/Piston.API.csproj
+++ b/PistonAPI/Piston.API.csproj
@@ -13,23 +13,6 @@
512
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
true
bin\x64\Debug\
diff --git a/PistonClient/Piston.Client.csproj b/PistonClient/Piston.Client.csproj
index b7f2ee5..a8594e0 100644
--- a/PistonClient/Piston.Client.csproj
+++ b/PistonClient/Piston.Client.csproj
@@ -16,25 +16,6 @@
true
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
true
bin\x64\Debug\
@@ -101,6 +82,7 @@
+
Code
diff --git a/PistonClient/PistonSettingsScreen.cs b/PistonClient/PistonSettingsScreen.cs
new file mode 100644
index 0000000..6df3ec7
--- /dev/null
+++ b/PistonClient/PistonSettingsScreen.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Sandbox.Graphics.GUI;
+using VRage.Utils;
+using VRageMath;
+
+namespace Piston.Client
+{
+ public class PistonSettingsScreen : MyGuiScreenBase
+ {
+ public override string GetFriendlyName() => "Piston Settings";
+
+ public PistonSettingsScreen() : base(new Vector2(0.5f), null, new Vector2(0.5f), true, null, 0f, 0f)
+ {
+ this.BackgroundColor = new Vector4(0);
+ RecreateControls(true);
+ }
+
+ ///
+ public override void RecreateControls(bool constructor)
+ {
+ base.RecreateControls(constructor);
+ AddCaption(MyStringId.GetOrCompute("Piston Settings"));
+ }
+ }
+}
diff --git a/PistonClient/Program.cs b/PistonClient/Program.cs
index 8ca862d..d2335a5 100644
--- a/PistonClient/Program.cs
+++ b/PistonClient/Program.cs
@@ -1,19 +1,24 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Windows;
using Sandbox;
-using Sandbox.Engine.Platform;
using Sandbox.Game;
using SpaceEngineers.Game;
using VRage.FileSystem;
using VRageRender;
using Piston;
using Sandbox.Game.Gui;
+using Sandbox.Graphics;
using Sandbox.Graphics.GUI;
using Sandbox.Gui;
+using VRage.Game;
+using VRage.Utils;
using VRageMath;
+using Game = Sandbox.Engine.Platform.Game;
+using MessageBoxResult = System.Windows.MessageBoxResult;
namespace Piston.Client
{
@@ -29,6 +34,7 @@ namespace Piston.Client
private static void Main(string[] args)
{
+ AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
if (!File.Exists("steam_appid.txt"))
{
Directory.SetCurrentDirectory(Path.GetDirectoryName(typeof(VRage.FastResourceLock).Assembly.Location) + "\\..");
@@ -58,6 +64,7 @@ namespace Piston.Client
{
_renderer = null;
SpaceEngineersGame.SetupPerGameSettings();
+
SpaceEngineersGame.SetupRender();
try
{
@@ -85,13 +92,27 @@ namespace Piston.Client
MyInitializer.InvokeAfterRun();
}
+ private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
+ {
+ var ex = (Exception)e.ExceptionObject;
+ MessageBox.Show($"PistonClient crashed. Go bug Jimmacle and send him a screenshot of this box!\n\n{ex.Message}\n{ex.StackTrace}", "Unhandled Exception");
+ }
+
private static void GuiControlCreated(object o)
{
var menu = o as MyGuiScreenMainMenu;
if (menu != null)
{
- Logger.Write("Adding button to main menu");
- menu.Controls.Add(new MyGuiControlImageButton("PistonButton", text: new StringBuilder("Piston"), size: new Vector2(20), position: new Vector2(0)));
+ var pistonBtn = new MyGuiControlButton(MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER), MyGuiControlButtonStyleEnum.Default, null, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM, null, new StringBuilder("Piston"), 1f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_ACTIVE, null, GuiSounds.MouseClick, 1f, null, false);
+ pistonBtn.Visible = true;
+ //menu.Controls.Add(pistonBtn);
+
+ var scr = new PistonSettingsScreen();
+ scr.Controls.Add(pistonBtn);
+
+ MyScreenManager.AddScreen(scr);
+ //menu.Controls.Add(new MyGuiControlLabel(new Vector2(0.5f), new Vector2(0.5f), "Piston Enabled"));
+ //menu.RecreateControls(false);
}
}
@@ -106,32 +127,40 @@ namespace Piston.Client
private static void InitializeRender()
{
- if (Game.IsDedicated)
+ try
{
- _renderer = new MyNullRender();
- }
- else
- {
- var graphicsRenderer = MySandboxGame.Config.GraphicsRenderer;
- if (graphicsRenderer == MySandboxGame.DirectX11RendererKey)
+ if (Game.IsDedicated)
{
- _renderer = new MyDX11Render();
- if (!_renderer.IsSupported)
- {
- MySandboxGame.Log.WriteLine("DirectX 11 renderer not supported. No renderer to revert back to.");
- _renderer = null;
- }
+ _renderer = new MyNullRender();
}
- if (_renderer == null)
- throw new MyRenderException("The current version of the game requires a Dx11 card. \\n For more information please see : http://blog.marekrosa.org/2016/02/space-engineers-news-full-source-code_26.html", MyRenderExceptionEnum.GpuNotSupported);
+ else
+ {
+ var graphicsRenderer = MySandboxGame.Config.GraphicsRenderer;
+ if (graphicsRenderer == MySandboxGame.DirectX11RendererKey)
+ {
+ _renderer = new MyDX11Render();
+ if (!_renderer.IsSupported)
+ {
+ MySandboxGame.Log.WriteLine("DirectX 11 renderer not supported. No renderer to revert back to.");
+ _renderer = null;
+ }
+ }
+ if (_renderer == null)
+ throw new MyRenderException("The current version of the game requires a Dx11 card. \\n For more information please see : http://blog.marekrosa.org/2016/02/space-engineers-news-full-source-code_26.html", MyRenderExceptionEnum.GpuNotSupported);
- MySandboxGame.Config.GraphicsRenderer = graphicsRenderer;
+ MySandboxGame.Config.GraphicsRenderer = graphicsRenderer;
+ }
+
+ MyRenderProxy.Initialize(_renderer);
+ MyRenderProxy.IS_OFFICIAL = true;
+ MyRenderProxy.GetRenderProfiler().SetAutocommit(false);
+ MyRenderProxy.GetRenderProfiler().InitMemoryHack("MainEntryPoint");
+ }
+ catch (TypeLoadException)
+ {
+ MessageBox.Show("This version of Piston does not run on the Stable branch.", "Initialization Error");
+ Environment.Exit(-1);
}
-
- MyRenderProxy.Initialize(_renderer);
- MyRenderProxy.IS_OFFICIAL = true;
- MyRenderProxy.GetRenderProfiler().SetAutocommit(false);
- MyRenderProxy.GetRenderProfiler().InitMemoryHack("MainEntryPoint");
}
}
}
\ No newline at end of file
diff --git a/PistonServer/Piston.Server.csproj b/PistonServer/Piston.Server.csproj
index e04c48c..91edf16 100644
--- a/PistonServer/Piston.Server.csproj
+++ b/PistonServer/Piston.Server.csproj
@@ -16,25 +16,6 @@
true
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
true
bin\x64\Debug\
diff --git a/TestPlugin/TestPlugin.csproj b/TestPlugin/TestPlugin.csproj
index ee042ff..c3326bc 100644
--- a/TestPlugin/TestPlugin.csproj
+++ b/TestPlugin/TestPlugin.csproj
@@ -13,23 +13,6 @@
512
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
true
bin\x64\Debug\