diff --git a/MindustryInstaller.sln b/MindustryInstaller.sln
new file mode 100644
index 0000000..7418fb6
--- /dev/null
+++ b/MindustryInstaller.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31515.178
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MindustryInstaller", "MindustryInstaller\MindustryInstaller.csproj", "{AD73FD7A-F762-463F-9E54-8A8B060DAC2E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MindustryLauncher", "MindustryLauncher\MindustryLauncher.csproj", "{1F881E72-0A19-418B-8622-3B44F4E3D950}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {AD73FD7A-F762-463F-9E54-8A8B060DAC2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AD73FD7A-F762-463F-9E54-8A8B060DAC2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AD73FD7A-F762-463F-9E54-8A8B060DAC2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AD73FD7A-F762-463F-9E54-8A8B060DAC2E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1F881E72-0A19-418B-8622-3B44F4E3D950}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1F881E72-0A19-418B-8622-3B44F4E3D950}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1F881E72-0A19-418B-8622-3B44F4E3D950}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1F881E72-0A19-418B-8622-3B44F4E3D950}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {2A4F7F56-29C6-411C-AB63-D94A2DC81E1B}
+ EndGlobalSection
+EndGlobal
diff --git a/MindustryInstaller/App.config b/MindustryInstaller/App.config
new file mode 100644
index 0000000..4bfa005
--- /dev/null
+++ b/MindustryInstaller/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/MindustryInstaller/App.xaml b/MindustryInstaller/App.xaml
new file mode 100644
index 0000000..524dda0
--- /dev/null
+++ b/MindustryInstaller/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/MindustryInstaller/App.xaml.cs b/MindustryInstaller/App.xaml.cs
new file mode 100644
index 0000000..425153f
--- /dev/null
+++ b/MindustryInstaller/App.xaml.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace MindustryInstaller
+{
+ ///
+ /// Interaction logic for App.xaml
+ ///
+ public partial class App : Application
+ {
+ }
+}
diff --git a/MindustryInstaller/MainWindow.xaml b/MindustryInstaller/MainWindow.xaml
new file mode 100644
index 0000000..cf67f6a
--- /dev/null
+++ b/MindustryInstaller/MainWindow.xaml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/MindustryInstaller/MainWindow.xaml.cs b/MindustryInstaller/MainWindow.xaml.cs
new file mode 100644
index 0000000..11469ed
--- /dev/null
+++ b/MindustryInstaller/MainWindow.xaml.cs
@@ -0,0 +1,167 @@
+using System;
+using System.IO;
+using System.Net;
+using System.Windows;
+using System.IO.Compression;
+using System.Collections.Generic;
+
+using Microsoft.Win32;
+
+using Newtonsoft.Json;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace MindustryInstaller
+{
+ ///
+ /// Interaction logic for MainWindow.xaml
+ ///
+ public partial class MainWindow : Window
+ {
+ public MainWindow()
+ {
+ InitializeComponent();
+ Directory.CreateDirectory(InstallDir);
+ Directory.CreateDirectory(TempDir);
+ }
+ bool DownloadJAVA = true;
+ string InstallDir = @"C:\Program Files\Mindustry\";
+ string TempDir = Path.GetTempPath() + "MindustryInstaller";
+ bool DownloadStable = true;
+ string version = null;
+ int downloadstat = 0;
+ int tick = 0;
+ void PrintLog(string log)
+ {
+ Invoke(() => LogTextBlock.Text += log + '\n');
+ Invoke(() => logView.ScrollToBottom());
+ }
+
+ //Gets version of Mindustry
+ void LoadVersion()
+ {
+ Invoke(() => InstallButton.IsEnabled = false);
+ Invoke(() => UseStableVersionCheckbox.IsEnabled = false);
+ using (var wc = new WebClient())
+ {
+ wc.Headers["User-Agent"] = "ua";
+ if (DownloadStable)
+ {
+ PrintLog("Searching stable version");
+ version = wc.DownloadString("https://api.github.com/repos/Anuken/Mindustry/releases/latest");
+ version = JsonConvert.DeserializeObject>(version)["tag_name"] as string;
+ }
+ else
+ {
+ PrintLog("Searching preview version");
+ version = wc.DownloadString("https://api.github.com/repos/Anuken/Mindustry/releases");
+ version = JsonConvert.DeserializeObject>>(version)[0]["tag_name"] as string;
+ }
+ PrintLog($"{version} found");
+ Invoke(() => VersionLabel.Content = "Mindustry version: " + version);
+ }
+ Invoke(() => InstallButton.IsEnabled = true);
+ Invoke(() => UseStableVersionCheckbox.IsEnabled = true);
+ }
+ void Invoke(Action a)
+ => Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (ThreadStart)delegate() { a(); });
+ //Install Mindustry
+ void Install()
+ {
+ Invoke(() => InstallButton.IsEnabled = false);
+ Invoke(() => DownloadJAVA = DownloadJavaCheckbox.IsChecked.Value);
+ PrintLog("Download Java: " + (DownloadJAVA ? "true" : "false"));
+ PrintLog("Download version: " + version);
+ try
+ {
+ Directory.CreateDirectory(InstallDir);
+ using (var wc = new WebClient())
+ {
+ wc.DownloadProgressChanged += WC_DownloadProgressChanged;
+ wc.DownloadFileCompleted += WC_DownloadFileCompleted;
+ wc.Headers["User-Agent"] = "MindustryInstaller";
+ PrintLog("Setup: WebClient");
+ if (DownloadJAVA)
+ {
+ try
+ {
+ Directory.Delete(Path.GetTempPath() + @"java", true);
+ }
+ catch (DirectoryNotFoundException) { }
+ downloadstat = 1;
+ var sync = new object();
+ lock (sync)
+ {
+ wc.DownloadFileAsync(new Uri("https://download.java.net/java/GA/jdk16.0.2/d4a915d82b4c4fbb9bde534da945d746/7/GPL/openjdk-16.0.2_windows-x64_bin.zip"), Path.GetTempPath() + "mindustry-java.zip");
+ Monitor.Wait(sync);
+ }
+ PrintLog("Extrecting JAVA Java to " + InstallDir + "java");
+ ZipFile.ExtractToDirectory(Path.GetTempPath() + "mindustry-java.zip", Path.GetTempPath() + "java");
+ Directory.Move(Path.GetTempPath() + @"java\jdk-16.0.2", InstallDir + "java");
+ }
+ if (File.Exists(InstallDir + "Mindustry.jar"))
+ File.Delete(InstallDir + "Mindustry.jar");
+ downloadstat = 2;
+ var sync2 = new object();
+ lock (sync2)
+ {
+ wc.DownloadFile($"https://github.com/Anuken/Mindustry/releases/download/{version}/Mindustry.jar", InstallDir + "Mindustry.jar");
+ Monitor.Wait(sync2);
+ }
+ }
+ PrintLog("Cleaning files");
+ try
+ {
+ Directory.Delete(Path.GetTempPath() + @"java", true);
+ }
+ catch (DirectoryNotFoundException) { }
+ try
+ {
+ File.Delete(Path.GetTempPath() + "mindustry-java.zip");
+ }
+ catch (DirectoryNotFoundException) { }
+ }
+ catch (Exception e)
+ {
+ _ = MessageBox.Show(e.Message);
+ }
+ downloadstat = 0;
+ Invoke(() => InstallButton.IsEnabled = true);
+ }
+
+ private void WC_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
+ {
+ if (downloadstat == 1)
+ PrintLog("Java Downloaded");
+ else if (downloadstat == 2)
+ PrintLog("Mindustry Downloaded");
+ Monitor.Pulse(e.UserState);
+ }
+
+ private void WC_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
+ {
+ if (tick++ % 100 == 0)
+ {
+ if (downloadstat == 1)
+ PrintLog($"Downloading JAVA...{e.ProgressPercentage}% ({e.BytesReceived} / {e.TotalBytesToReceive})");
+ else if (downloadstat == 2)
+ PrintLog($"Downloading Mindustry...{e.ProgressPercentage}% ({e.BytesReceived} / {e.TotalBytesToReceive})");
+ }
+ }
+
+ private void InstallButton_Click(object sender, RoutedEventArgs e)
+ => new Thread(() => Install()).Start();
+
+ private void UseStableVersionCheckbox_Checked(object sender, RoutedEventArgs e)
+ {
+ DownloadStable = true;
+ new Thread(() => LoadVersion()).Start();
+ }
+
+ private void UseStableVersionCheckbox_Unchecked(object sender, RoutedEventArgs e)
+ {
+ DownloadStable = false;
+ new Thread(() => LoadVersion()).Start();
+ }
+ }
+}
diff --git a/MindustryInstaller/MindustryInstaller.csproj b/MindustryInstaller/MindustryInstaller.csproj
new file mode 100644
index 0000000..f09732c
--- /dev/null
+++ b/MindustryInstaller/MindustryInstaller.csproj
@@ -0,0 +1,117 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {AD73FD7A-F762-463F-9E54-8A8B060DAC2E}
+ WinExe
+ MindustryInstaller
+ MindustryInstaller
+ v4.8
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ true
+ true
+
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ false
+
+
+ LocalIntranet
+
+
+ false
+
+
+ Properties\app.manifest
+
+
+
+ ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll
+
+
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+ MainWindow.xaml
+ Code
+
+
+
+
+ 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/MindustryInstaller/Properties/AssemblyInfo.cs b/MindustryInstaller/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..57e89da
--- /dev/null
+++ b/MindustryInstaller/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+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("MindustryInstaller")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("MindustryInstaller")]
+[assembly: AssemblyCopyright("Copyright © 2021")]
+[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
+//CultureYouAreCodingWith in your .csproj file
+//inside a . For example, if you are using US english
+//in your source files, set the 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")]
diff --git a/MindustryInstaller/Properties/Resources.Designer.cs b/MindustryInstaller/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..0935789
--- /dev/null
+++ b/MindustryInstaller/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// 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.
+//
+//------------------------------------------------------------------------------
+
+namespace MindustryInstaller.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // 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", "16.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() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [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("MindustryInstaller.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/MindustryInstaller/Properties/Resources.resx b/MindustryInstaller/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/MindustryInstaller/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/MindustryInstaller/Properties/Settings.Designer.cs b/MindustryInstaller/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..9557d99
--- /dev/null
+++ b/MindustryInstaller/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+//
+// 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.
+//
+//------------------------------------------------------------------------------
+
+namespace MindustryInstaller.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.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;
+ }
+ }
+ }
+}
diff --git a/MindustryInstaller/Properties/Settings.settings b/MindustryInstaller/Properties/Settings.settings
new file mode 100644
index 0000000..033d7a5
--- /dev/null
+++ b/MindustryInstaller/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MindustryInstaller/Properties/app.manifest b/MindustryInstaller/Properties/app.manifest
new file mode 100644
index 0000000..ba0af7d
--- /dev/null
+++ b/MindustryInstaller/Properties/app.manifest
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MindustryInstaller/packages.config b/MindustryInstaller/packages.config
new file mode 100644
index 0000000..bc2a97e
--- /dev/null
+++ b/MindustryInstaller/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/MindustryLauncher/App.config b/MindustryLauncher/App.config
new file mode 100644
index 0000000..193aecc
--- /dev/null
+++ b/MindustryLauncher/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MindustryLauncher/MindustryLauncher.csproj b/MindustryLauncher/MindustryLauncher.csproj
new file mode 100644
index 0000000..28c8688
--- /dev/null
+++ b/MindustryLauncher/MindustryLauncher.csproj
@@ -0,0 +1,53 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {1F881E72-0A19-418B-8622-3B44F4E3D950}
+ Exe
+ MindustryLauncher
+ MindustryLauncher
+ v4.8
+ 512
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MindustryLauncher/Program.cs b/MindustryLauncher/Program.cs
new file mode 100644
index 0000000..9bc65e5
--- /dev/null
+++ b/MindustryLauncher/Program.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MindustryLauncher
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Process.Start(@"\java\bin\java -jar Mindustry.jar");
+ }
+ }
+}
diff --git a/MindustryLauncher/Properties/AssemblyInfo.cs b/MindustryLauncher/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..db2d739
--- /dev/null
+++ b/MindustryLauncher/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 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("MindustryLauncher")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("MindustryLauncher")]
+[assembly: AssemblyCopyright("Copyright © 2021")]
+[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)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("1f881e72-0a19-418b-8622-3b44f4e3d950")]
+
+// 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")]