Add resources list class for launcher.

This commit is contained in:
UnknownShadow200 2016-05-15 19:31:37 +10:00
parent 664fb536c5
commit babf253b59
5 changed files with 62 additions and 41 deletions

View file

@ -29,7 +29,7 @@ namespace ClassicalSharp.Renderers {
short[] heightmap;
float vOffset;
const int extent = 4;
VertexP3fT2fC4b[] vertices = new VertexP3fT2fC4b[8 * (extent * 2 + 1) * (extent * 2 + 1) * 2];
VertexP3fT2fC4b[] vertices = new VertexP3fT2fC4b[8 * (extent * 2 + 1) * (extent * 2 + 1)];
double rainAcc;
Vector3I lastPos = new Vector3I( Int32.MinValue );
@ -97,24 +97,13 @@ namespace ClassicalSharp.Renderers {
vertices[index++] = new VertexP3fT2fC4b( x, y, z, 0, v1, col );
vertices[index++] = new VertexP3fT2fC4b( x, y + height, z, 0, v2, col );
vertices[index++] = new VertexP3fT2fC4b( x + 1, y + height, z + 1, 2, v2, col );
vertices[index++] = new VertexP3fT2fC4b( x + 1, y, z + 1, 2, v1, col );
vertices[index++] = new VertexP3fT2fC4b( x + 1, y + height, z + 1, 1, v2, col );
vertices[index++] = new VertexP3fT2fC4b( x + 1, y, z + 1, 1, v1, col );
vertices[index++] = new VertexP3fT2fC4b( x + 1, y, z, 2, v1, col );
vertices[index++] = new VertexP3fT2fC4b( x + 1, y + height, z, 2, v2, col );
vertices[index++] = new VertexP3fT2fC4b( x + 1, y, z, 1, v1, col );
vertices[index++] = new VertexP3fT2fC4b( x + 1, y + height, z, 1, v2, col );
vertices[index++] = new VertexP3fT2fC4b( x, y + height, z + 1, 0, v2, col );
vertices[index++] = new VertexP3fT2fC4b( x, y, z + 1, 0, v1, col );
// Draw mirrored
vertices[index++] = new VertexP3fT2fC4b( x + 1, y, z + 1, 0, v1, col );
vertices[index++] = new VertexP3fT2fC4b( x + 1, y + height, z + 1, 0, v2, col );
vertices[index++] = new VertexP3fT2fC4b( x, y + height, z, 2, v2, col );
vertices[index++] = new VertexP3fT2fC4b( x, y, z, 2, v1, col );
vertices[index++] = new VertexP3fT2fC4b( x, y, z + 1, 2, v1, col );
vertices[index++] = new VertexP3fT2fC4b( x, y + height, z + 1, 2, v2, col );
vertices[index++] = new VertexP3fT2fC4b( x + 1, y + height, z, 0, v2, col );
vertices[index++] = new VertexP3fT2fC4b( x + 1, y, z, 0, v1, col );
}
int length, width, maxY, oneY;

View file

@ -94,6 +94,7 @@
<Compile Include="Patcher\ResourceChecker.cs" />
<Compile Include="Patcher\ResourceFetcher.cs" />
<Compile Include="Patcher\ResourcePatcher.cs" />
<Compile Include="Patcher\ResourcesList.cs" />
<Compile Include="Patcher\SoundPatcher.cs" />
<Compile Include="Patcher\ZipWriter.cs" />
<Compile Include="Program.cs" />

View file

@ -27,8 +27,9 @@ namespace Launcher {
AllResourcesExist = false;
}
for( int i = 0; i < musicFiles.Length; i++ ) {
string file = Path.Combine( audioPath, musicFiles[i] + ".ogg" );
string[] files = ResourceList.MusicFiles;
for( int i = 0; i < files.Length; i++ ) {
string file = Path.Combine( audioPath, files[i] + ".ogg" );
musicExists[i] = File.Exists( file );
if( !musicExists[i] ) {
DownloadSize += musicSizes[i] / 1024f;
@ -38,11 +39,11 @@ namespace Launcher {
}
if( !DigSoundsExist ) {
ResourcesCount += digSounds.Length;
ResourcesCount += ResourceList.DigSounds.Length;
DownloadSize += 173 / 1024f;
}
if( !StepSoundsExist ) {
ResourcesCount += stepSounds.Length;
ResourcesCount += ResourceList.StepSounds.Length;
DownloadSize += 244 / 1024f;
}
}
@ -73,34 +74,24 @@ namespace Launcher {
void ProcessZipEntry( string filename, byte[] data, ZipEntry entry ) { }
bool CheckDigSoundsExist() {
string[] files = ResourceList.DigSounds;
string path = Path.Combine( Program.AppDirectory, "audio" );
for( int i = 0; i < digSounds.Length; i++ ) {
string file = "dig_" + digSounds[i].Substring( 1 ) + ".wav";
for( int i = 0; i < files.Length; i++ ) {
string file = "dig_" + files[i].Substring( 1 ) + ".wav";
if( !File.Exists( Path.Combine( path, file ) ) ) return false;
}
return true;
}
bool CheckStepSoundsExist() {
string[] files = ResourceList.StepSounds;
string path = Path.Combine( Program.AppDirectory, "audio" );
for( int i = 0; i < stepSounds.Length; i++ ) {
string file = "step_" + stepSounds[i].Substring( 1 ) + ".wav";
for( int i = 0; i < files.Length; i++ ) {
string file = "step_" + files[i].Substring( 1 ) + ".wav";
if( !File.Exists( Path.Combine( path, file ) ) ) return false;
}
return true;
}
internal static string[] digSounds = new [] { "Acloth1", "Acloth2", "Acloth3", "Acloth4", "Bglass1",
"Bglass2", "Bglass3", "Agrass1", "Agrass2", "Agrass3", "Agrass4", "Agravel1", "Agravel2",
"Agravel3", "Agravel4", "Asand1", "Asand2", "Asand3", "Asand4", "Asnow1", "Asnow2", "Asnow3",
"Asnow4", "Astone1", "Astone2", "Astone3", "Astone4", "Awood1", "Awood2", "Awood3", "Awood4" };
internal static string[] stepSounds = new [] { "Acloth1", "Acloth2", "Acloth3", "Acloth4", "Bgrass1",
"Bgrass2", "Bgrass3", "Bgrass4", "Agravel1", "Agravel2", "Agravel3", "Agravel4", "Asand1",
"Asand2", "Asand3", "Asand4", "Asnow1", "Asnow2", "Asnow3", "Asnow4", "Astone1", "Astone2",
"Astone3", "Astone4", "Awood1", "Awood2", "Awood3", "Awood4" };
internal static string[] musicFiles = new [] { "calm1", "calm2", "calm3", "hal1", "hal2", "hal3", "hal4" };
static int[] musicSizes = new [] { 2472, 1931, 2181, 1926, 1714, 1879, 2499 };
}
}

View file

@ -26,9 +26,9 @@ namespace Launcher {
public void DownloadItems( AsyncDownloader downloader, Action<string> setStatus ) {
this.downloader = downloader;
DownloadMusicFiles();
digPatcher = new SoundPatcher( ResourceChecker.digSounds, "dig_", "step_cloth1" );
digPatcher = new SoundPatcher( ResourceList.DigSounds, "dig_", "step_cloth1" );
digPatcher.FetchFiles( digSoundsUri, altDigSoundsUri, this, DigSoundsExist );
stepPatcher = new SoundPatcher( ResourceChecker.stepSounds, "step_", "classic jar" );
stepPatcher = new SoundPatcher( ResourceList.StepSounds, "step_", "classic jar" );
stepPatcher.FetchFiles( stepSoundsUri, altStepSoundsUri, this, StepSoundsExist );
if( !defaultZipExists ) {
@ -41,7 +41,7 @@ namespace Launcher {
}
void DownloadMusicFiles() {
string[] files = ResourceChecker.musicFiles;
string[] files = ResourceList.MusicFiles;
for( int i = 0; i < files.Length; i++ ) {
if( musicExists[i] ) continue;
string baseUri = i < 3 ? musicUri : newMusicUri;
@ -53,7 +53,7 @@ namespace Launcher {
void SetFirstStatus( Action<string> setStatus ) {
for( int i = 0; i < musicExists.Length; i++ ) {
if( musicExists[i] ) continue;
setStatus( MakeNext( ResourceChecker.musicFiles[i] ) );
setStatus( MakeNext( ResourceList.MusicFiles[i] ) );
return;
}
@ -124,7 +124,7 @@ namespace Launcher {
}
bool CheckMusicFiles( Action<string> setStatus ) {
string[] files = ResourceChecker.musicFiles;
string[] files = ResourceList.MusicFiles;
for( int i = 0; i < files.Length; i++ ) {
string next = i < files.Length - 1 ? files[i + 1] : "dig_cloth1";
string name = files[i];

View file

@ -0,0 +1,40 @@
// ClassicalSharp copyright 2014-2016 UnknownShadow200 | Licensed under MIT
using System;
using System.Collections.Generic;
using System.IO;
using ClassicalSharp.TexturePack;
namespace Launcher {
public sealed class ResourceList {
// Nibbles: Classic jar, 1.6.2 jar, gui patch, terrain patch
public static Dictionary<string, ushort> Files = new Dictionary<string, ushort>() {
// classic jar files
{ "char.png", 0x1000 }, { "clouds.png", 0x1000 },
{ "default.png", 0x1000 }, { "particles.png", 0x1000 },
{ "rain.png", 0x1000 }, { "terrain.png", 0x1001 },
{ "gui.png", 0x1000 }, { "icons.png", 0x1000 },
{ "arrows.png", 0x1000 }, { "sign.png", 0x1000 },
{ "creeper.png", 0x1000 }, { "pig.png", 0x1000 },
{ "sheep.png", 0x1000 }, { "sheep_fur.png", 0x1000 },
{ "skeleton.png", 0x1000 }, { "spider.png", 0x1000 },
{ "zombie.png", 0x1000 },
// Other files
{ "snow.png", 0x0100 }, { "chicken.png", 0x0100 },
{ "animations.png", 0x0100 }, { "gui_classic.png", 0x0010 },
};
public static string[] DigSounds = new [] { "Acloth1", "Acloth2", "Acloth3", "Acloth4", "Bglass1",
"Bglass2", "Bglass3", "Agrass1", "Agrass2", "Agrass3", "Agrass4", "Agravel1", "Agravel2",
"Agravel3", "Agravel4", "Asand1", "Asand2", "Asand3", "Asand4", "Asnow1", "Asnow2", "Asnow3",
"Asnow4", "Astone1", "Astone2", "Astone3", "Astone4", "Awood1", "Awood2", "Awood3", "Awood4" };
public static string[] StepSounds = new [] { "Acloth1", "Acloth2", "Acloth3", "Acloth4", "Bgrass1",
"Bgrass2", "Bgrass3", "Bgrass4", "Agravel1", "Agravel2", "Agravel3", "Agravel4", "Asand1",
"Asand2", "Asand3", "Asand4", "Asnow1", "Asnow2", "Asnow3", "Asnow4", "Astone1", "Astone2",
"Astone3", "Astone4", "Awood1", "Awood2", "Awood3", "Awood4" };
public static string[] MusicFiles = new [] { "calm1", "calm2", "calm3", "hal1", "hal2", "hal3", "hal4" };
}
}