mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 17:47:12 -04:00
Add option to fetch resources. (thanks Jonty800)
This commit is contained in:
parent
8ebaefc62b
commit
f920e05495
@ -1,117 +1,118 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ProjectGuid>{23B9BDA8-4330-46AB-9012-08D87430391A}</ProjectGuid>
|
<ProjectGuid>{23B9BDA8-4330-46AB-9012-08D87430391A}</ProjectGuid>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<RootNamespace>Launcher</RootNamespace>
|
<RootNamespace>Launcher</RootNamespace>
|
||||||
<AssemblyName>Launcher</AssemblyName>
|
<AssemblyName>Launcher</AssemblyName>
|
||||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<TargetFrameworkProfile>
|
<TargetFrameworkProfile>
|
||||||
</TargetFrameworkProfile>
|
</TargetFrameworkProfile>
|
||||||
<FileUpgradeFlags>
|
<FileUpgradeFlags>
|
||||||
</FileUpgradeFlags>
|
</FileUpgradeFlags>
|
||||||
<UpgradeBackupLocation>
|
<UpgradeBackupLocation>
|
||||||
</UpgradeBackupLocation>
|
</UpgradeBackupLocation>
|
||||||
<OldToolsVersion>3.5</OldToolsVersion>
|
<OldToolsVersion>3.5</OldToolsVersion>
|
||||||
<PublishUrl>publish\</PublishUrl>
|
<PublishUrl>publish\</PublishUrl>
|
||||||
<Install>true</Install>
|
<Install>true</Install>
|
||||||
<InstallFrom>Disk</InstallFrom>
|
<InstallFrom>Disk</InstallFrom>
|
||||||
<UpdateEnabled>false</UpdateEnabled>
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
<UpdateMode>Foreground</UpdateMode>
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
<UpdateInterval>7</UpdateInterval>
|
<UpdateInterval>7</UpdateInterval>
|
||||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
<UpdatePeriodically>false</UpdatePeriodically>
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
<UpdateRequired>false</UpdateRequired>
|
<UpdateRequired>false</UpdateRequired>
|
||||||
<MapFileExtensions>true</MapFileExtensions>
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
<ApplicationRevision>0</ApplicationRevision>
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
<SignAssembly>False</SignAssembly>
|
<SignAssembly>False</SignAssembly>
|
||||||
<DelaySign>False</DelaySign>
|
<DelaySign>False</DelaySign>
|
||||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
|
||||||
<NoStdLib>False</NoStdLib>
|
<NoStdLib>False</NoStdLib>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
|
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<RegisterForComInterop>False</RegisterForComInterop>
|
<RegisterForComInterop>False</RegisterForComInterop>
|
||||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
||||||
<BaseAddress>4194304</BaseAddress>
|
<BaseAddress>4194304</BaseAddress>
|
||||||
<FileAlignment>4096</FileAlignment>
|
<FileAlignment>4096</FileAlignment>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
<OutputPath>..\output\debug\</OutputPath>
|
<OutputPath>..\output\debug\</OutputPath>
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>Full</DebugType>
|
<DebugType>Full</DebugType>
|
||||||
<Optimize>False</Optimize>
|
<Optimize>False</Optimize>
|
||||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
<OutputPath>..\output\release\</OutputPath>
|
<OutputPath>..\output\release\</OutputPath>
|
||||||
<DebugSymbols>false</DebugSymbols>
|
<DebugSymbols>false</DebugSymbols>
|
||||||
<DebugType>None</DebugType>
|
<DebugType>None</DebugType>
|
||||||
<Optimize>True</Optimize>
|
<Optimize>True</Optimize>
|
||||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="ClassiCubeSession.cs" />
|
<Compile Include="ClassiCubeSession.cs" />
|
||||||
<Compile Include="Comparers.cs" />
|
<Compile Include="Comparers.cs" />
|
||||||
<Compile Include="GameSession.cs" />
|
<Compile Include="GameSession.cs" />
|
||||||
<Compile Include="GameStartData.cs" />
|
<Compile Include="GameStartData.cs" />
|
||||||
<Compile Include="MainForm.cs">
|
<Compile Include="MainForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="MainForm.Designer.cs">
|
<Compile Include="MainForm.Designer.cs">
|
||||||
<DependentUpon>MainForm.cs</DependentUpon>
|
<DependentUpon>MainForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="MinecraftSession.cs" />
|
<Compile Include="MinecraftSession.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="ServerListEntry.cs" />
|
<Compile Include="ResourceFetcher.cs" />
|
||||||
<Compile Include="WebUtility.cs" />
|
<Compile Include="ServerListEntry.cs" />
|
||||||
</ItemGroup>
|
<Compile Include="WebUtility.cs" />
|
||||||
<ItemGroup>
|
</ItemGroup>
|
||||||
<None Include="app.config" />
|
<ItemGroup>
|
||||||
</ItemGroup>
|
<None Include="app.config" />
|
||||||
<ItemGroup>
|
</ItemGroup>
|
||||||
<EmbeddedResource Include="MainForm.resx">
|
<ItemGroup>
|
||||||
<DependentUpon>MainForm.cs</DependentUpon>
|
<EmbeddedResource Include="MainForm.resx">
|
||||||
</EmbeddedResource>
|
<DependentUpon>MainForm.cs</DependentUpon>
|
||||||
</ItemGroup>
|
</EmbeddedResource>
|
||||||
<ItemGroup>
|
</ItemGroup>
|
||||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
|
<ItemGroup>
|
||||||
<Visible>False</Visible>
|
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
|
||||||
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
|
<Visible>False</Visible>
|
||||||
<Install>true</Install>
|
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
|
||||||
</BootstrapperPackage>
|
<Install>true</Install>
|
||||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
</BootstrapperPackage>
|
||||||
<Visible>False</Visible>
|
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
<Visible>False</Visible>
|
||||||
<Install>false</Install>
|
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||||
</BootstrapperPackage>
|
<Install>false</Install>
|
||||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
</BootstrapperPackage>
|
||||||
<Visible>False</Visible>
|
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
<Visible>False</Visible>
|
||||||
<Install>false</Install>
|
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||||
</BootstrapperPackage>
|
<Install>false</Install>
|
||||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
</BootstrapperPackage>
|
||||||
<Visible>False</Visible>
|
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||||
<ProductName>Windows Installer 3.1</ProductName>
|
<Visible>False</Visible>
|
||||||
<Install>true</Install>
|
<ProductName>Windows Installer 3.1</ProductName>
|
||||||
</BootstrapperPackage>
|
<Install>true</Install>
|
||||||
</ItemGroup>
|
</BootstrapperPackage>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
@ -24,6 +24,20 @@ namespace Launcher {
|
|||||||
tabMC.TabPages.Remove( tabMCServer );
|
tabMC.TabPages.Remove( tabMCServer );
|
||||||
tabCC.TabPages.Remove( tabCCServers );
|
tabCC.TabPages.Remove( tabCCServers );
|
||||||
tabCC.TabPages.Remove( tabCCServer );
|
tabCC.TabPages.Remove( tabCCServer );
|
||||||
|
Shown += DisplayResourcesDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayResourcesDialog( object sender, EventArgs e ) {
|
||||||
|
// TODO: async fetching
|
||||||
|
ResourceFetcher fetcher = new ResourceFetcher();
|
||||||
|
if( !fetcher.CheckAllResourcesExist() ) {
|
||||||
|
DialogResult result = MessageBox.Show(
|
||||||
|
"Some required resources weren't found. Would you like to download them now?", "Missing resources",
|
||||||
|
MessageBoxButtons.OKCancel );
|
||||||
|
if( result == DialogResult.OK ) {
|
||||||
|
fetcher.Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate void Action<T1, T2>( T1 arg1, T2 arg2 );
|
delegate void Action<T1, T2>( T1 arg1, T2 arg2 );
|
||||||
|
47
Launcher/ResourceFetcher.cs
Normal file
47
Launcher/ResourceFetcher.cs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Launcher {
|
||||||
|
|
||||||
|
public class ResourceFetcher {
|
||||||
|
|
||||||
|
const string terrainUri = "https://raw.githubusercontent.com/andrewphorn/ClassiCube-Client/master/src/main/resources/terrain.png";
|
||||||
|
const string cloudsUri = "https://raw.githubusercontent.com/andrewphorn/ClassiCube-Client/master/src/main/resources/clouds.png";
|
||||||
|
const string charUri = "https://raw.githubusercontent.com/andrewphorn/ClassiCube-Client/master/src/main/resources/char.png";
|
||||||
|
|
||||||
|
public void Run() {
|
||||||
|
using( WebClient client = new WebClient() ) {
|
||||||
|
client.Proxy = null;
|
||||||
|
if( !DownloadData( terrainUri, client, "terrain.png" ) ) return;
|
||||||
|
if( !DownloadData( cloudsUri, client, "clouds.png" ) ) return;
|
||||||
|
if( !DownloadData( charUri, client, "char.png" ) ) return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool DownloadData( string uri, WebClient client, string output ) {
|
||||||
|
if( File.Exists( output ) ) return true;
|
||||||
|
|
||||||
|
byte[] data = null;
|
||||||
|
try {
|
||||||
|
data = client.DownloadData( uri );
|
||||||
|
} catch( WebException ) {
|
||||||
|
MessageBox.Show( "Unable to download " + output, "Failed to download resource", MessageBoxButtons.OK, MessageBoxIcon.Error );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
File.WriteAllBytes( output, data );
|
||||||
|
} catch( IOException ) {
|
||||||
|
MessageBox.Show( "Unable to save " + output, "Failed to save resource", MessageBoxButtons.OK, MessageBoxIcon.Error );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CheckAllResourcesExist() {
|
||||||
|
return File.Exists( "terrain.png" ) && File.Exists( "clouds.png" ) && File.Exists( "char.png" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user