Fix custom key bindings not being loaded, sprites are now rotated diagonally.

This commit is contained in:
UnknownShadow200 2015-09-27 08:48:51 +10:00
parent 067f87ce37
commit a12ffa3730
8 changed files with 52 additions and 51 deletions

View File

@ -128,7 +128,7 @@
<Compile Include="Map\MapCw.Exporter.cs" />
<Compile Include="Map\MapCw.Importer.cs" />
<Compile Include="Map\MapDat.Importer.cs" />
<Compile Include="Map\MapFcm3.Exporter.cs" />
<Compile Include="Map\MapFcm3.Importer.cs" />
<Compile Include="Model\BlockModel.cs" />
<Compile Include="Model\ChickenModel.cs" />
<Compile Include="Model\CreeperModel.cs" />

View File

@ -192,7 +192,7 @@ namespace ClassicalSharp {
!(Inventory.CanPlace[block] && Inventory.CanDelete[block])));
}
public KeyMap Keys = new KeyMap();
public KeyMap Keys;
}
public enum KeyMapping {
@ -279,11 +279,6 @@ namespace ClassicalSharp {
for( int i = 0; i < names.Length; i++ ) {
Options.Set( "key-" + names[i], Keys[i].ToString() );
}
try {
Options.Save();
} catch( IOException ) {
Utils.LogWarning( "Unable to sace options.txt" );
}
}
}
}

View File

@ -49,7 +49,7 @@ namespace ClassicalSharp {
internal string skinServer, chatInInputBuffer, defaultTexPack;
internal int defaultIb;
public bool CanUseThirdPersonCamera = true;
FpsScreen fpsScreen;
FpsScreen fpsScreen;
public IPAddress IPAddress;
public string Username;
@ -97,6 +97,7 @@ namespace ClassicalSharp {
} catch( IOException ) {
Utils.LogWarning( "Unable to load options.txt" );
}
Keys = new KeyMap();
ViewDistance = Options.GetInt( "viewdist", 16, 8192, 512 );
defaultIb = Graphics.MakeDefaultIb();
ModelCache = new ModelCache( this );
@ -159,7 +160,6 @@ namespace ClassicalSharp {
ViewDistance = distance;
Utils.LogDebug( "setting view distance to: " + distance );
Options.Set( "viewdist", distance.ToString() );
Options.Save();
Raise( ViewDistanceChanged );
UpdateProjection();
}
@ -206,7 +206,7 @@ namespace ClassicalSharp {
MapRenderer.Render( e.Time );
if( SelectedPos.Valid )
Picking.Render( e.Time, SelectedPos );
WeatherRenderer.Render( e.Time );
WeatherRenderer.Render( e.Time );
SelectionManager.Render( e.Time );
bool left = IsMousePressed( MouseButton.Left );
bool right = IsMousePressed( MouseButton.Right );
@ -351,6 +351,14 @@ namespace ClassicalSharp {
Graphics.DeleteTexture( ref CloudsTextureId );
Graphics.DeleteTexture( ref RainTextureId );
Graphics.DeleteTexture( ref SnowTextureId );
if( Options.HasChanged ) {
try {
Options.Save();
} catch( IOException ) {
Utils.LogWarning( "Unable to save options.txt" );
}
}
base.Dispose();
}
}

View File

@ -172,9 +172,8 @@ namespace ClassicalSharp {
countIndex += TileSide.Top;
if( counts[countIndex] != 0 ) {
X = x; Y = y; Z = z;
int count = StretchX( xx, countIndex, x, y, z, chunkIndex, tile, TileSide.Top );
AddSpriteVertices( tile, count );
counts[countIndex] = (byte)count;
AddSpriteVertices( tile, 1 );
counts[countIndex] = 1;
}
} else {
X = x; Y = y; Z = z;

View File

@ -45,7 +45,7 @@ namespace ClassicalSharp {
if( vertices == null || vCount > vertices.Length ) {
vertices = new VertexPos3fTex2fCol4b[vCount];
}
}
vIndex.left = spriteCount / 6 * 4;
vIndex.right = vIndex.left + Count.left / 6 * 4;
vIndex.front = vIndex.right + Count.right / 6 * 4;
@ -167,7 +167,7 @@ namespace ClassicalSharp {
int texId = info.GetTextureLoc( tile, TileSide.Left );
int i;
TextureRectangle rec = atlas.GetTexRec( texId, count, out i );
FastColour col = emitsLight ? FastColour.White :
FastColour col = emitsLight ? FastColour.White :
X > 0 ? ( Y > map.heightmap[( Z * width ) + (X - 1)] ? map.SunlightXSide : map.ShadowlightXSide ) : map.SunlightXSide;
if( blockHeight != 1 ) {
rec.V2 = rec.V1 + blockHeight * invVerElementSize;
@ -184,7 +184,7 @@ namespace ClassicalSharp {
int texId = info.GetTextureLoc( tile, TileSide.Right );
int i;
TextureRectangle rec = atlas.GetTexRec( texId, count, out i );
FastColour col = emitsLight ? FastColour.White :
FastColour col = emitsLight ? FastColour.White :
X < maxX ? ( Y > map.heightmap[( Z * width ) + (X + 1)] ? map.SunlightXSide : map.ShadowlightXSide ) : map.SunlightXSide;
if( blockHeight != 1 ) {
rec.V2 = rec.V1 + blockHeight * invVerElementSize;
@ -201,7 +201,7 @@ namespace ClassicalSharp {
int texId = info.GetTextureLoc( tile, TileSide.Back );
int i;
TextureRectangle rec = atlas.GetTexRec( texId, count, out i );
FastColour col = emitsLight ? FastColour.White :
FastColour col = emitsLight ? FastColour.White :
Z < maxZ ? ( Y > map.heightmap[( (Z + 1) * width ) + X] ? map.SunlightZSide : map.ShadowlightZSide ) : map.SunlightZSide;
if( blockHeight != 1 ) {
rec.V2 = rec.V1 + blockHeight * invVerElementSize;
@ -218,7 +218,7 @@ namespace ClassicalSharp {
int texId = info.GetTextureLoc( tile, TileSide.Front );
int i;
TextureRectangle rec = atlas.GetTexRec( texId, count, out i );
FastColour col = emitsLight ? FastColour.White :
FastColour col = emitsLight ? FastColour.White :
Z > 0 ? ( Y > map.heightmap[( (Z - 1) * width ) + X] ? map.SunlightZSide : map.ShadowlightZSide ) : map.SunlightZSide;
if( blockHeight != 1 ) {
rec.V2 = rec.V1 + blockHeight * invVerElementSize;
@ -235,7 +235,7 @@ namespace ClassicalSharp {
int texId = info.GetTextureLoc( tile, TileSide.Bottom );
int i;
TextureRectangle rec = atlas.GetTexRec( texId, count, out i );
FastColour col = emitsLight ? FastColour.White :
FastColour col = emitsLight ? FastColour.White :
Y > 0 ? ( (Y - 1) > map.heightmap[( Z * width ) + X] ? map.SunlightYBottom : map.ShadowlightYBottom ) : map.SunlightYBottom;
DrawInfo part = isTranslucent ? drawInfoTranslucent[i] : drawInfoNormal[i];
@ -249,7 +249,7 @@ namespace ClassicalSharp {
int texId = info.GetTextureLoc( tile, TileSide.Top );
int i;
TextureRectangle rec = atlas.GetTexRec( texId, count, out i );
FastColour col = emitsLight ? FastColour.White :
FastColour col = emitsLight ? FastColour.White :
Y < maxY ? ( Y > map.heightmap[( Z * width ) + X] ? map.Sunlight : map.Shadowlight ) : map.Sunlight;
DrawInfo part = isTranslucent ? drawInfoTranslucent[i] : drawInfoNormal[i];
@ -262,29 +262,22 @@ namespace ClassicalSharp {
void DrawSprite( int count ) {
int texId = info.GetTextureLoc( tile, TileSide.Right );
int i;
TextureRectangle rec = atlas.GetTexRec( texId, count, out i );
FastColour col = Y < maxY ? ( emitsLight || Y > map.heightmap[( Z * width ) + X] ? map.Sunlight : map.Shadowlight )
TextureRectangle rec = atlas.GetTexRec( texId, 1, out i );
FastColour col = Y < maxY ? ( emitsLight || Y > map.heightmap[( Z * width ) + X] ? map.Sunlight : map.Shadowlight )
: map.Sunlight;
DrawInfo part = drawInfoNormal[i];
// Draw stretched Z axis
part.vertices[part.spriteIndex++] = new VertexPos3fTex2fCol4b( X, Y, Z + 0.5f, rec.U2, rec.V2, col );
part.vertices[part.spriteIndex++] = new VertexPos3fTex2fCol4b( X, Y + blockHeight, Z + 0.5f, rec.U2, rec.V1, col );
part.vertices[part.spriteIndex++] = new VertexPos3fTex2fCol4b( X + count, Y + blockHeight, Z + 0.5f, rec.U1, rec.V1, col );
part.vertices[part.spriteIndex++] = new VertexPos3fTex2fCol4b( X + count, Y, Z + 0.5f, rec.U1, rec.V2, col );
// Draw Z axis
part.vertices[part.spriteIndex++] = new VertexPos3fTex2fCol4b( X + 2.50f/16, Y, Z + 2.5f/16, rec.U2, rec.V2, col );
part.vertices[part.spriteIndex++] = new VertexPos3fTex2fCol4b( X + 2.50f/16, Y + blockHeight, Z + 2.5f/16, rec.U2, rec.V1, col );
part.vertices[part.spriteIndex++] = new VertexPos3fTex2fCol4b( X + 13.5f/16, Y + blockHeight, Z + 13.5f/16, rec.U1, rec.V1, col );
part.vertices[part.spriteIndex++] = new VertexPos3fTex2fCol4b( X + 13.5f/16, Y, Z + 13.5f/16, rec.U1, rec.V2, col );
// Draw X axis
rec.U2 = 1;
int startX = X;
for( int j = 0; j < count; j++ ) {
part.vertices[part.spriteIndex++] = new VertexPos3fTex2fCol4b( X + 0.5f, Y, Z, rec.U1, rec.V2, col );
part.vertices[part.spriteIndex++] = new VertexPos3fTex2fCol4b( X + 0.5f, Y + blockHeight, Z, rec.U1, rec.V1, col );
part.vertices[part.spriteIndex++] = new VertexPos3fTex2fCol4b( X + 0.5f, Y + blockHeight, Z + 1, rec.U2, rec.V1, col );
part.vertices[part.spriteIndex++] = new VertexPos3fTex2fCol4b( X + 0.5f, Y, Z + 1, rec.U2, rec.V2, col );
X++;
}
X = startX;
part.vertices[part.spriteIndex++] = new VertexPos3fTex2fCol4b( X + 2.50f/16, Y, Z + 13.5f/16, rec.U1, rec.V2, col );
part.vertices[part.spriteIndex++] = new VertexPos3fTex2fCol4b( X + 2.50f/16, Y + blockHeight, Z + 13.5f/16, rec.U1, rec.V1, col );
part.vertices[part.spriteIndex++] = new VertexPos3fTex2fCol4b( X + 13.5f/16, Y + blockHeight, Z + 2.5f/16, rec.U2, rec.V1, col );
part.vertices[part.spriteIndex++] = new VertexPos3fTex2fCol4b( X + 13.5f/16, Y, Z + 2.5f/16, rec.U2, rec.V2, col );
}
}
}

View File

@ -59,6 +59,8 @@ namespace ClassicalSharp {
return result;
}
public Color ToColor() {
return Color.FromArgb( A, R, G, B );
}

View File

@ -7,32 +7,36 @@ namespace ClassicalSharp {
public static class Options {
static Dictionary<string, string> OptionsSet = new Dictionary<string, string>();
public static bool HasChanged;
public static string Get( string key ) {
string value;
return OptionsSet.TryGetValue( key, out value ) ? value : null;
}
public static bool TryGetInt( string key, out int valueInt ) {
public static int GetInt( string key, int min, int max, int defValue ) {
string value;
valueInt = 0;
OptionsSet.TryGetValue( key, out value );
if( String.IsNullOrEmpty( value ) ) return false;
return Int32.TryParse( value, out valueInt );
int valueInt = 0;
if( !OptionsSet.TryGetValue( key, out value ) || String.IsNullOrEmpty( value )
|| !Int32.TryParse( value, out valueInt ) )
return defValue;
Utils.Clamp( ref valueInt, min, max );
return valueInt;
}
public static int GetInt( string key, int min, int max, int defValue ) {
int valueInt = 0;
if( TryGetInt( key, out valueInt ) ) {
Utils.Clamp( ref valueInt, min, max );
return valueInt;
}
return defValue;
public static bool GetBool( string key, bool defValue ) {
string value;
bool valueBool = false;
if( !OptionsSet.TryGetValue( key, out value ) || String.IsNullOrEmpty( value )
|| !Boolean.TryParse( value, out valueBool ) )
return defValue;
return valueBool;
}
public static void Set( string key, string value ) {
OptionsSet[key] = value;
HasChanged = true;
}
public const string OptionsFile = "options.txt";