Skip to content

Commit e8541e7

Browse files
committed
Add project files.
1 parent c954e68 commit e8541e7

18 files changed

+822
-0
lines changed

MindustryInstaller.sln

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31515.178
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MindustryInstaller", "MindustryInstaller\MindustryInstaller.csproj", "{AD73FD7A-F762-463F-9E54-8A8B060DAC2E}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MindustryLauncher", "MindustryLauncher\MindustryLauncher.csproj", "{1F881E72-0A19-418B-8622-3B44F4E3D950}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{AD73FD7A-F762-463F-9E54-8A8B060DAC2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{AD73FD7A-F762-463F-9E54-8A8B060DAC2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{AD73FD7A-F762-463F-9E54-8A8B060DAC2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{AD73FD7A-F762-463F-9E54-8A8B060DAC2E}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{1F881E72-0A19-418B-8622-3B44F4E3D950}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{1F881E72-0A19-418B-8622-3B44F4E3D950}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{1F881E72-0A19-418B-8622-3B44F4E3D950}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{1F881E72-0A19-418B-8622-3B44F4E3D950}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {2A4F7F56-29C6-411C-AB63-D94A2DC81E1B}
30+
EndGlobalSection
31+
EndGlobal

MindustryInstaller/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
5+
</startup>
6+
</configuration>

MindustryInstaller/App.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="MindustryInstaller.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:MindustryInstaller"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>

MindustryInstaller/App.xaml.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
9+
namespace MindustryInstaller
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
}
17+
}

MindustryInstaller/MainWindow.xaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Window x:Class="MindustryInstaller.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:MindustryInstaller"
7+
mc:Ignorable="d"
8+
Title="MainWindow" Height="278.5" Width="422.5">
9+
<Grid>
10+
<CheckBox Name="DownloadJavaCheckbox" Content="Download JAVA" HorizontalAlignment="Center" Margin="46,55,28,0" VerticalAlignment="Top" Width="130" IsChecked="true"/>
11+
<CheckBox Name="UseStableVersionCheckbox" Content="Use stable version" HorizontalAlignment="Center" Margin="46,75,28,0" VerticalAlignment="Top" RenderTransformOrigin="0.343,-0.378" Width="130" Checked="UseStableVersionCheckbox_Checked" IsChecked="true" Unchecked="UseStableVersionCheckbox_Unchecked"/>
12+
<Label Name="VersionLabel" Content="Mindustry version: null" HorizontalAlignment="Center" Margin="37,95,15,0" VerticalAlignment="Top" Width="152"/>
13+
<Button Name="InstallButton" Content="Install" HorizontalAlignment="Center" Margin="63,126,66,0" VerticalAlignment="Top" Width="75" Click="InstallButton_Click"/>
14+
<ScrollViewer Name="logView" Margin="0,151,0,0">
15+
<TextBlock Name="LogTextBlock" HorizontalAlignment="Left" Margin="0,0,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" />
16+
</ScrollViewer>
17+
</Grid>
18+
</Window>
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
using System;
2+
using System.IO;
3+
using System.Net;
4+
using System.Windows;
5+
using System.IO.Compression;
6+
using System.Collections.Generic;
7+
8+
using Microsoft.Win32;
9+
10+
using Newtonsoft.Json;
11+
using System.Threading;
12+
using System.Threading.Tasks;
13+
14+
namespace MindustryInstaller
15+
{
16+
/// <summary>
17+
/// Interaction logic for MainWindow.xaml
18+
/// </summary>
19+
public partial class MainWindow : Window
20+
{
21+
public MainWindow()
22+
{
23+
InitializeComponent();
24+
Directory.CreateDirectory(InstallDir);
25+
Directory.CreateDirectory(TempDir);
26+
}
27+
bool DownloadJAVA = true;
28+
string InstallDir = @"C:\Program Files\Mindustry\";
29+
string TempDir = Path.GetTempPath() + "MindustryInstaller";
30+
bool DownloadStable = true;
31+
string version = null;
32+
int downloadstat = 0;
33+
int tick = 0;
34+
void PrintLog(string log)
35+
{
36+
Invoke(() => LogTextBlock.Text += log + '\n');
37+
Invoke(() => logView.ScrollToBottom());
38+
}
39+
40+
//Gets version of Mindustry
41+
void LoadVersion()
42+
{
43+
Invoke(() => InstallButton.IsEnabled = false);
44+
Invoke(() => UseStableVersionCheckbox.IsEnabled = false);
45+
using (var wc = new WebClient())
46+
{
47+
wc.Headers["User-Agent"] = "ua";
48+
if (DownloadStable)
49+
{
50+
PrintLog("Searching stable version");
51+
version = wc.DownloadString("https://api.github.com/repos/Anuken/Mindustry/releases/latest");
52+
version = JsonConvert.DeserializeObject<Dictionary<string, object>>(version)["tag_name"] as string;
53+
}
54+
else
55+
{
56+
PrintLog("Searching preview version");
57+
version = wc.DownloadString("https://api.github.com/repos/Anuken/Mindustry/releases");
58+
version = JsonConvert.DeserializeObject<List<Dictionary<string, dynamic>>>(version)[0]["tag_name"] as string;
59+
}
60+
PrintLog($"{version} found");
61+
Invoke(() => VersionLabel.Content = "Mindustry version: " + version);
62+
}
63+
Invoke(() => InstallButton.IsEnabled = true);
64+
Invoke(() => UseStableVersionCheckbox.IsEnabled = true);
65+
}
66+
void Invoke(Action a)
67+
=> Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (ThreadStart)delegate() { a(); });
68+
//Install Mindustry
69+
void Install()
70+
{
71+
Invoke(() => InstallButton.IsEnabled = false);
72+
Invoke(() => DownloadJAVA = DownloadJavaCheckbox.IsChecked.Value);
73+
PrintLog("Download Java: " + (DownloadJAVA ? "true" : "false"));
74+
PrintLog("Download version: " + version);
75+
try
76+
{
77+
Directory.CreateDirectory(InstallDir);
78+
using (var wc = new WebClient())
79+
{
80+
wc.DownloadProgressChanged += WC_DownloadProgressChanged;
81+
wc.DownloadFileCompleted += WC_DownloadFileCompleted;
82+
wc.Headers["User-Agent"] = "MindustryInstaller";
83+
PrintLog("Setup: WebClient");
84+
if (DownloadJAVA)
85+
{
86+
try
87+
{
88+
Directory.Delete(Path.GetTempPath() + @"java", true);
89+
}
90+
catch (DirectoryNotFoundException) { }
91+
downloadstat = 1;
92+
var sync = new object();
93+
lock (sync)
94+
{
95+
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");
96+
Monitor.Wait(sync);
97+
}
98+
PrintLog("Extrecting JAVA Java to " + InstallDir + "java");
99+
ZipFile.ExtractToDirectory(Path.GetTempPath() + "mindustry-java.zip", Path.GetTempPath() + "java");
100+
Directory.Move(Path.GetTempPath() + @"java\jdk-16.0.2", InstallDir + "java");
101+
}
102+
if (File.Exists(InstallDir + "Mindustry.jar"))
103+
File.Delete(InstallDir + "Mindustry.jar");
104+
downloadstat = 2;
105+
var sync2 = new object();
106+
lock (sync2)
107+
{
108+
wc.DownloadFile($"https://github.com/Anuken/Mindustry/releases/download/{version}/Mindustry.jar", InstallDir + "Mindustry.jar");
109+
Monitor.Wait(sync2);
110+
}
111+
}
112+
PrintLog("Cleaning files");
113+
try
114+
{
115+
Directory.Delete(Path.GetTempPath() + @"java", true);
116+
}
117+
catch (DirectoryNotFoundException) { }
118+
try
119+
{
120+
File.Delete(Path.GetTempPath() + "mindustry-java.zip");
121+
}
122+
catch (DirectoryNotFoundException) { }
123+
}
124+
catch (Exception e)
125+
{
126+
_ = MessageBox.Show(e.Message);
127+
}
128+
downloadstat = 0;
129+
Invoke(() => InstallButton.IsEnabled = true);
130+
}
131+
132+
private void WC_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
133+
{
134+
if (downloadstat == 1)
135+
PrintLog("Java Downloaded");
136+
else if (downloadstat == 2)
137+
PrintLog("Mindustry Downloaded");
138+
Monitor.Pulse(e.UserState);
139+
}
140+
141+
private void WC_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
142+
{
143+
if (tick++ % 100 == 0)
144+
{
145+
if (downloadstat == 1)
146+
PrintLog($"Downloading JAVA...{e.ProgressPercentage}% ({e.BytesReceived} / {e.TotalBytesToReceive})");
147+
else if (downloadstat == 2)
148+
PrintLog($"Downloading Mindustry...{e.ProgressPercentage}% ({e.BytesReceived} / {e.TotalBytesToReceive})");
149+
}
150+
}
151+
152+
private void InstallButton_Click(object sender, RoutedEventArgs e)
153+
=> new Thread(() => Install()).Start();
154+
155+
private void UseStableVersionCheckbox_Checked(object sender, RoutedEventArgs e)
156+
{
157+
DownloadStable = true;
158+
new Thread(() => LoadVersion()).Start();
159+
}
160+
161+
private void UseStableVersionCheckbox_Unchecked(object sender, RoutedEventArgs e)
162+
{
163+
DownloadStable = false;
164+
new Thread(() => LoadVersion()).Start();
165+
}
166+
}
167+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{AD73FD7A-F762-463F-9E54-8A8B060DAC2E}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>MindustryInstaller</RootNamespace>
10+
<AssemblyName>MindustryInstaller</AssemblyName>
11+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<WarningLevel>4</WarningLevel>
15+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
16+
<Deterministic>true</Deterministic>
17+
<TargetFrameworkProfile />
18+
</PropertyGroup>
19+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
20+
<PlatformTarget>AnyCPU</PlatformTarget>
21+
<DebugSymbols>true</DebugSymbols>
22+
<DebugType>full</DebugType>
23+
<Optimize>false</Optimize>
24+
<OutputPath>bin\Debug\</OutputPath>
25+
<DefineConstants>DEBUG;TRACE</DefineConstants>
26+
<ErrorReport>prompt</ErrorReport>
27+
<WarningLevel>4</WarningLevel>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
30+
<PlatformTarget>AnyCPU</PlatformTarget>
31+
<DebugType>pdbonly</DebugType>
32+
<Optimize>true</Optimize>
33+
<OutputPath>bin\Release\</OutputPath>
34+
<DefineConstants>TRACE</DefineConstants>
35+
<ErrorReport>prompt</ErrorReport>
36+
<WarningLevel>4</WarningLevel>
37+
</PropertyGroup>
38+
<PropertyGroup>
39+
<SignManifests>false</SignManifests>
40+
</PropertyGroup>
41+
<PropertyGroup>
42+
<TargetZone>LocalIntranet</TargetZone>
43+
</PropertyGroup>
44+
<PropertyGroup>
45+
<GenerateManifests>false</GenerateManifests>
46+
</PropertyGroup>
47+
<PropertyGroup>
48+
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
49+
</PropertyGroup>
50+
<ItemGroup>
51+
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
52+
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
53+
</Reference>
54+
<Reference Include="System" />
55+
<Reference Include="System.Data" />
56+
<Reference Include="System.IO.Compression.FileSystem" />
57+
<Reference Include="System.Xml" />
58+
<Reference Include="Microsoft.CSharp" />
59+
<Reference Include="System.Core" />
60+
<Reference Include="System.Xml.Linq" />
61+
<Reference Include="System.Data.DataSetExtensions" />
62+
<Reference Include="System.Net.Http" />
63+
<Reference Include="System.Xaml">
64+
<RequiredTargetFramework>4.0</RequiredTargetFramework>
65+
</Reference>
66+
<Reference Include="WindowsBase" />
67+
<Reference Include="PresentationCore" />
68+
<Reference Include="PresentationFramework" />
69+
</ItemGroup>
70+
<ItemGroup>
71+
<ApplicationDefinition Include="App.xaml">
72+
<Generator>MSBuild:Compile</Generator>
73+
<SubType>Designer</SubType>
74+
</ApplicationDefinition>
75+
<Page Include="MainWindow.xaml">
76+
<Generator>MSBuild:Compile</Generator>
77+
<SubType>Designer</SubType>
78+
</Page>
79+
<Compile Include="App.xaml.cs">
80+
<DependentUpon>App.xaml</DependentUpon>
81+
<SubType>Code</SubType>
82+
</Compile>
83+
<Compile Include="MainWindow.xaml.cs">
84+
<DependentUpon>MainWindow.xaml</DependentUpon>
85+
<SubType>Code</SubType>
86+
</Compile>
87+
</ItemGroup>
88+
<ItemGroup>
89+
<Compile Include="Properties\AssemblyInfo.cs">
90+
<SubType>Code</SubType>
91+
</Compile>
92+
<Compile Include="Properties\Resources.Designer.cs">
93+
<AutoGen>True</AutoGen>
94+
<DesignTime>True</DesignTime>
95+
<DependentUpon>Resources.resx</DependentUpon>
96+
</Compile>
97+
<Compile Include="Properties\Settings.Designer.cs">
98+
<AutoGen>True</AutoGen>
99+
<DependentUpon>Settings.settings</DependentUpon>
100+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
101+
</Compile>
102+
<EmbeddedResource Include="Properties\Resources.resx">
103+
<Generator>ResXFileCodeGenerator</Generator>
104+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
105+
</EmbeddedResource>
106+
<None Include="packages.config" />
107+
<None Include="Properties\app.manifest" />
108+
<None Include="Properties\Settings.settings">
109+
<Generator>SettingsSingleFileGenerator</Generator>
110+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
111+
</None>
112+
</ItemGroup>
113+
<ItemGroup>
114+
<None Include="App.config" />
115+
</ItemGroup>
116+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
117+
</Project>

0 commit comments

Comments
 (0)