mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 17:47:12 -04:00
Fix custom key bindings not being loaded, sprites are now rotated diagonally.
This commit is contained in:
parent
067f87ce37
commit
a12ffa3730
@ -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" />
|
||||
|
@ -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" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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 );
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
@ -59,6 +59,8 @@ namespace ClassicalSharp {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Color ToColor() {
|
||||
return Color.FromArgb( A, R, G, B );
|
||||
}
|
||||
|
@ -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 );
|
||||
int valueInt = 0;
|
||||
if( !OptionsSet.TryGetValue( key, out value ) || String.IsNullOrEmpty( value )
|
||||
|| !Int32.TryParse( value, out valueInt ) )
|
||||
return defValue;
|
||||
|
||||
if( String.IsNullOrEmpty( value ) ) return false;
|
||||
return Int32.TryParse( value, out valueInt );
|
||||
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";
|
||||
|
Loading…
x
Reference in New Issue
Block a user