mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 10:05:44 -04:00
Fix crashing when pressing button in OptionsScreen, save and load default view distance, other minor gui touchups.
This commit is contained in:
parent
e01f24bebb
commit
fe1d808025
@ -15,42 +15,45 @@ namespace ClassicalSharp {
|
|||||||
hintFont = new Font( "Arial", 14, FontStyle.Italic );
|
hintFont = new Font( "Arial", 14, FontStyle.Italic );
|
||||||
|
|
||||||
buttons = new ButtonWidget[] {
|
buttons = new ButtonWidget[] {
|
||||||
Make( -140, -100, "Clouds colour", Docking.Centre, OnWidgetClick,
|
Make( -140, -150, "Clouds colour", Docking.Centre, OnWidgetClick,
|
||||||
g => g.Map.CloudsCol.ToRGBHexString(),
|
g => g.Map.CloudsCol.ToRGBHexString(),
|
||||||
(g, v) => g.Map.SetCloudsColour( FastColour.Parse( v ) ) ),
|
(g, v) => g.Map.SetCloudsColour( FastColour.Parse( v ) ) ),
|
||||||
|
|
||||||
Make( -140, -50, "Sky colour", Docking.Centre, OnWidgetClick,
|
Make( -140, -100, "Sky colour", Docking.Centre, OnWidgetClick,
|
||||||
g => g.Map.SkyCol.ToRGBHexString(),
|
g => g.Map.SkyCol.ToRGBHexString(),
|
||||||
(g, v) => g.Map.SetSkyColour( FastColour.Parse( v ) ) ),
|
(g, v) => g.Map.SetSkyColour( FastColour.Parse( v ) ) ),
|
||||||
|
|
||||||
Make( -140, 0, "Fog colour", Docking.Centre, OnWidgetClick,
|
Make( -140, -50, "Fog colour", Docking.Centre, OnWidgetClick,
|
||||||
g => g.Map.FogCol.ToRGBHexString(),
|
g => g.Map.FogCol.ToRGBHexString(),
|
||||||
(g, v) => g.Map.SetFogColour( FastColour.Parse( v ) ) ),
|
(g, v) => g.Map.SetFogColour( FastColour.Parse( v ) ) ),
|
||||||
|
|
||||||
Make( -140, 50, "Clouds speed", Docking.Centre, OnWidgetClick,
|
Make( -140, 0, "Clouds speed", Docking.Centre, OnWidgetClick,
|
||||||
g => {
|
g => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer;
|
||||||
StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer;
|
return env == null ? "(not active)" : env.CloudsSpeed.ToString(); },
|
||||||
return env == null ? "(not active)" : env.CloudsSpeed.ToString();
|
(g, v) => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer;
|
||||||
},
|
|
||||||
(g, v) => {
|
|
||||||
StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer;
|
|
||||||
if( env != null )
|
if( env != null )
|
||||||
env.CloudsSpeed = Single.Parse( v );
|
env.CloudsSpeed = Single.Parse( v ); } ),
|
||||||
} ),
|
|
||||||
|
|
||||||
Make( 140, -100, "Sunlight colour", Docking.Centre, OnWidgetClick,
|
Make( -140, 50, "Clouds offset", Docking.Centre, OnWidgetClick,
|
||||||
|
g => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer;
|
||||||
|
return env == null ? "(not active)" : env.CloudsOffset.ToString(); },
|
||||||
|
(g, v) => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer;
|
||||||
|
if( env != null )
|
||||||
|
env.SetCloudsOffset( Int32.Parse( v ) ); } ),
|
||||||
|
|
||||||
|
Make( 140, -150, "Sunlight colour", Docking.Centre, OnWidgetClick,
|
||||||
g => g.Map.Sunlight.ToRGBHexString(),
|
g => g.Map.Sunlight.ToRGBHexString(),
|
||||||
(g, v) => g.Map.SetSunlight( FastColour.Parse( v ) ) ),
|
(g, v) => g.Map.SetSunlight( FastColour.Parse( v ) ) ),
|
||||||
|
|
||||||
Make( 140, -50, "Shadow colour", Docking.Centre, OnWidgetClick,
|
Make( 140, -100, "Shadow colour", Docking.Centre, OnWidgetClick,
|
||||||
g => g.Map.Shadowlight.ToRGBHexString(),
|
g => g.Map.Shadowlight.ToRGBHexString(),
|
||||||
(g, v) => g.Map.SetShadowlight( FastColour.Parse( v ) ) ),
|
(g, v) => g.Map.SetShadowlight( FastColour.Parse( v ) ) ),
|
||||||
|
|
||||||
Make( 140, 0, "Weather", Docking.Centre, OnWidgetClick,
|
Make( 140, -50, "Weather", Docking.Centre, OnWidgetClick,
|
||||||
g => ((int)g.Map.Weather).ToString(),
|
g => ((int)g.Map.Weather).ToString(),
|
||||||
(g, v) => g.Map.SetWeather( (Weather)Int32.Parse( v ) ) ),
|
(g, v) => g.Map.SetWeather( (Weather)Int32.Parse( v ) ) ),
|
||||||
|
|
||||||
Make( 140, 50, "Water level", Docking.Centre, OnWidgetClick,
|
Make( 140, 0, "Water level", Docking.Centre, OnWidgetClick,
|
||||||
g => g.Map.WaterHeight.ToString(),
|
g => g.Map.WaterHeight.ToString(),
|
||||||
(g, v) => g.Map.SetWaterLevel( Int32.Parse( v ) ) ),
|
(g, v) => g.Map.SetWaterLevel( Int32.Parse( v ) ) ),
|
||||||
|
|
||||||
@ -64,6 +67,7 @@ namespace ClassicalSharp {
|
|||||||
new HexColourValidator(),
|
new HexColourValidator(),
|
||||||
new HexColourValidator(),
|
new HexColourValidator(),
|
||||||
new RealValidator( 0, 1000 ),
|
new RealValidator( 0, 1000 ),
|
||||||
|
new IntegerValidator( -1000, 1000 ),
|
||||||
new HexColourValidator(),
|
new HexColourValidator(),
|
||||||
new HexColourValidator(),
|
new HexColourValidator(),
|
||||||
new IntegerValidator( 0, 2 ),
|
new IntegerValidator( 0, 2 ),
|
||||||
|
@ -27,14 +27,21 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandlesKeyPress( char key ) {
|
public override bool HandlesKeyPress( char key ) {
|
||||||
|
if( inputWidget == null ) return true;
|
||||||
return inputWidget.HandlesKeyPress( key );
|
return inputWidget.HandlesKeyPress( key );
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandlesKeyDown( Key key ) {
|
public override bool HandlesKeyDown( Key key ) {
|
||||||
|
if( key == Key.Escape ) {
|
||||||
|
game.SetNewScreen( new NormalScreen( game ) );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if( inputWidget == null ) return true;
|
||||||
return inputWidget.HandlesKeyDown( key );
|
return inputWidget.HandlesKeyDown( key );
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandlesKeyUp( Key key ) {
|
public override bool HandlesKeyUp( Key key ) {
|
||||||
|
if( inputWidget == null ) return true;
|
||||||
return inputWidget.HandlesKeyUp( key );
|
return inputWidget.HandlesKeyUp( key );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,14 +92,21 @@ namespace ClassicalSharp {
|
|||||||
buttons[okayIndex].Dispose();
|
buttons[okayIndex].Dispose();
|
||||||
buttons[okayIndex] = null;
|
buttons[okayIndex] = null;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int index = Array.IndexOf<ButtonWidget>( buttons, widget );
|
||||||
|
MenuInputValidator validator = validators[index];
|
||||||
|
if( validator is BooleanValidator ) {
|
||||||
|
string value = widget.GetValue( game );
|
||||||
|
widget.SetValue( game, value == "yes" ? "no" : "yes" );
|
||||||
|
UpdateDescription( widget );
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( inputWidget != null )
|
if( inputWidget != null )
|
||||||
inputWidget.Dispose();
|
inputWidget.Dispose();
|
||||||
targetWidget = selectedWidget;
|
|
||||||
|
|
||||||
int index = Array.IndexOf<ButtonWidget>( buttons, widget );
|
targetWidget = selectedWidget;
|
||||||
MenuInputValidator validator = validators[index];
|
|
||||||
inputWidget = MenuInputWidget.Create( game, 0, 150, 400, 25, widget.GetValue( game ),
|
inputWidget = MenuInputWidget.Create( game, 0, 150, 400, 25, widget.GetValue( game ),
|
||||||
Docking.Centre, Docking.Centre, regularFont, titleFont,
|
Docking.Centre, Docking.Centre, regularFont, titleFont,
|
||||||
hintFont, validator );
|
hintFont, validator );
|
||||||
|
@ -15,16 +15,16 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
buttons = new ButtonWidget[] {
|
buttons = new ButtonWidget[] {
|
||||||
Make( -140, -50, "Use animations", Docking.Centre, OnWidgetClick,
|
Make( -140, -50, "Use animations", Docking.Centre, OnWidgetClick,
|
||||||
g => g.Animations.Enabled ? "y" : "n",
|
g => g.Animations.Enabled ? "yes" : "no",
|
||||||
(g, v) => g.Animations.Enabled = v == "y" ),
|
(g, v) => g.Animations.Enabled = v == "yes" ),
|
||||||
|
|
||||||
Make( -140, 0, "View distance", Docking.Centre, OnWidgetClick,
|
Make( -140, 0, "View distance", Docking.Centre, OnWidgetClick,
|
||||||
g => g.ViewDistance.ToString(),
|
g => g.ViewDistance.ToString(),
|
||||||
(g, v) => g.SetViewDistance( Int32.Parse( v ) ) ),
|
(g, v) => g.SetViewDistance( Int32.Parse( v ) ) ),
|
||||||
|
|
||||||
Make( -140, 50, "VSync active", Docking.Centre, OnWidgetClick,
|
Make( -140, 50, "VSync active", Docking.Centre, OnWidgetClick,
|
||||||
g => g.VSync ? "y" : "n",
|
g => g.VSync ? "yes" : "no",
|
||||||
(g, v) => g.Graphics.SetVSync( g, v == "y" ) ),
|
(g, v) => g.Graphics.SetVSync( g, v == "yes" ) ),
|
||||||
Make( 140, -50, "Mouse sensitivity", Docking.Centre, OnWidgetClick,
|
Make( 140, -50, "Mouse sensitivity", Docking.Centre, OnWidgetClick,
|
||||||
g => g.MouseSensitivity.ToString(),
|
g => g.MouseSensitivity.ToString(),
|
||||||
(g, v) => g.MouseSensitivity = Int32.Parse( v ) ),
|
(g, v) => g.MouseSensitivity = Int32.Parse( v ) ),
|
||||||
|
@ -21,14 +21,20 @@ namespace ClassicalSharp {
|
|||||||
buttons = new ButtonWidget[] {
|
buttons = new ButtonWidget[] {
|
||||||
Make( 0, -50, "Options", Docking.Centre, (g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ),
|
Make( 0, -50, "Options", Docking.Centre, (g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ),
|
||||||
Make( 0, 0, "Environment settings", Docking.Centre, (g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ),
|
Make( 0, 0, "Environment settings", Docking.Centre, (g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ),
|
||||||
Make( 0, 50, "Key mappings", Docking.Centre, (g, w) => g.SetNewScreen( new KeyMappingsScreen( g ) ) ), // TODO: Temp fix
|
Make( 0, 50, "Key mappings", Docking.Centre, (g, w) => g.SetNewScreen( new KeyMappingsScreen( g ) ) ),
|
||||||
Make( 0, 55, "Back to game", Docking.BottomOrRight, (g, w) => g.SetNewScreen( new NormalScreen( g ) ) ),
|
Make( 0, 55, "Back to game", Docking.BottomOrRight, (g, w) => g.SetNewScreen( new NormalScreen( g ) ) ),
|
||||||
Make( 0, 5, "Exit", Docking.BottomOrRight, (g, w) => g.Exit() ),
|
Make( 0, 5, "Quit game", Docking.BottomOrRight, (g, w) => g.Exit() ),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonWidget Make( int x, int y, string text, Docking vDocking, Action<Game, ButtonWidget> onClick ) {
|
ButtonWidget Make( int x, int y, string text, Docking vDocking, Action<Game, ButtonWidget> onClick ) {
|
||||||
return ButtonWidget.Create( game, x, y, 240, 35, text, Docking.Centre, vDocking, titleFont, onClick );
|
return ButtonWidget.Create( game, x, y, 240, 35, text, Docking.Centre, vDocking, titleFont, onClick );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool HandlesKeyDown( Key key ) {
|
||||||
|
if( key == Key.Escape )
|
||||||
|
game.SetNewScreen( new NormalScreen( game ) );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -75,6 +75,7 @@ namespace ClassicalSharp {
|
|||||||
hotbar.Init();
|
hotbar.Init();
|
||||||
if( game.CursorVisible )
|
if( game.CursorVisible )
|
||||||
game.CursorVisible = false;
|
game.CursorVisible = false;
|
||||||
|
game.Camera.RegrabMouse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandlesAllInput {
|
public override bool HandlesAllInput {
|
||||||
|
@ -113,6 +113,7 @@ namespace ClassicalSharp {
|
|||||||
texture = Utils2D.Make2DTexture( graphicsApi, bmp, size, 0, 0 );
|
texture = Utils2D.Make2DTexture( graphicsApi, bmp, size, 0, 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsPath MakePath( float offset, float width, float height ) {
|
GraphicsPath MakePath( float offset, float width, float height ) {
|
||||||
GraphicsPath path = new GraphicsPath();
|
GraphicsPath path = new GraphicsPath();
|
||||||
float x1 = offset, y1 = offset;
|
float x1 = offset, y1 = offset;
|
||||||
|
@ -95,19 +95,19 @@ namespace ClassicalSharp {
|
|||||||
public sealed class BooleanValidator : MenuInputValidator {
|
public sealed class BooleanValidator : MenuInputValidator {
|
||||||
|
|
||||||
public BooleanValidator() {
|
public BooleanValidator() {
|
||||||
Range = "&7(y or n)";
|
Range = "&7(yes or no)";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsValidChar( char c ) {
|
public override bool IsValidChar( char c ) {
|
||||||
return c == 'y' || c == 'n';
|
return c >= 'a' && c <= 'z';
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsValidString( string s ) {
|
public override bool IsValidString( string s ) {
|
||||||
return s.Length <= 1;
|
return s.Length <= 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsValidValue( string s ) {
|
public override bool IsValidValue( string s ) {
|
||||||
return s == "y" || s == "n";
|
return s == "yes" || s == "no";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
if( now.Day != last.Day || now.Month != last.Month || now.Year != last.Year ) {
|
if( now.Day != last.Day || now.Month != last.Month || now.Year != last.Year ) {
|
||||||
if( writer != null ) {
|
if( writer != null ) {
|
||||||
writer.Close();
|
writer.Dispose();
|
||||||
writer = null;
|
writer = null;
|
||||||
}
|
}
|
||||||
OpenChatFile( now );
|
OpenChatFile( now );
|
||||||
|
@ -249,12 +249,6 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LoadKeyBindings() {
|
void LoadKeyBindings() {
|
||||||
try {
|
|
||||||
Options.Load();
|
|
||||||
} catch( IOException ) {
|
|
||||||
Utils.LogWarning( "Unable to load options.txt" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
string[] names = KeyMapping.GetNames( typeof( KeyMapping ) );
|
string[] names = KeyMapping.GetNames( typeof( KeyMapping ) );
|
||||||
for( int i = 0; i < names.Length; i++ ) {
|
for( int i = 0; i < names.Length; i++ ) {
|
||||||
string key = "key-" + names[i];
|
string key = "key-" + names[i];
|
||||||
|
@ -142,6 +142,12 @@ namespace ClassicalSharp {
|
|||||||
#else
|
#else
|
||||||
Graphics = new Direct3D9Api( this );
|
Graphics = new Direct3D9Api( this );
|
||||||
#endif
|
#endif
|
||||||
|
try {
|
||||||
|
Options.Load();
|
||||||
|
} catch( IOException ) {
|
||||||
|
Utils.LogWarning( "Unable to load options.txt" );
|
||||||
|
}
|
||||||
|
ViewDistance = Options.GetInt( "viewdist", 16, 8192, 512 );
|
||||||
defaultIb = Graphics.MakeDefaultIb();
|
defaultIb = Graphics.MakeDefaultIb();
|
||||||
ModelCache = new ModelCache( this );
|
ModelCache = new ModelCache( this );
|
||||||
ModelCache.InitCache();
|
ModelCache.InitCache();
|
||||||
@ -201,6 +207,8 @@ namespace ClassicalSharp {
|
|||||||
public void SetViewDistance( int distance ) {
|
public void SetViewDistance( int distance ) {
|
||||||
ViewDistance = distance;
|
ViewDistance = distance;
|
||||||
Utils.LogDebug( "setting view distance to: " + distance );
|
Utils.LogDebug( "setting view distance to: " + distance );
|
||||||
|
Options.Set( "viewdist", distance.ToString() );
|
||||||
|
Options.Save();
|
||||||
Raise( ViewDistanceChanged );
|
Raise( ViewDistanceChanged );
|
||||||
UpdateProjection();
|
UpdateProjection();
|
||||||
}
|
}
|
||||||
@ -332,10 +340,9 @@ namespace ClassicalSharp {
|
|||||||
if( activeScreen != null ) {
|
if( activeScreen != null ) {
|
||||||
activeScreen.Dispose();
|
activeScreen.Dispose();
|
||||||
}
|
}
|
||||||
if( activeScreen != null && activeScreen.HandlesAllInput ) {
|
if( activeScreen != null && activeScreen.HandlesAllInput )
|
||||||
Camera.RegrabMouse();
|
|
||||||
lastClick = DateTime.UtcNow;
|
lastClick = DateTime.UtcNow;
|
||||||
}
|
|
||||||
activeScreen = screen;
|
activeScreen = screen;
|
||||||
if( screen != null ) {
|
if( screen != null ) {
|
||||||
screen.game = this;
|
screen.game = this;
|
||||||
@ -381,7 +388,7 @@ namespace ClassicalSharp {
|
|||||||
Players.Dispose();
|
Players.Dispose();
|
||||||
AsyncDownloader.Dispose();
|
AsyncDownloader.Dispose();
|
||||||
if( writer != null ) {
|
if( writer != null ) {
|
||||||
writer.Close();
|
writer.Dispose();
|
||||||
}
|
}
|
||||||
if( activeScreen != null ) {
|
if( activeScreen != null ) {
|
||||||
activeScreen.Dispose();
|
activeScreen.Dispose();
|
||||||
|
@ -68,12 +68,6 @@ namespace ClassicalSharp {
|
|||||||
R = c.R; G = c.G; B = c.B; A = c.A;
|
R = c.R; G = c.G; B = c.B; A = c.A;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VertexPos3fTex2fCol4b( float x, float y, float z, float u, float v, Color c ) {
|
|
||||||
X = x; Y = y; Z = z;
|
|
||||||
U = u; V = v;
|
|
||||||
R = c.R; G = c.G; B = c.B; A = c.A;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VertexPos3fTex2fCol4b( float x, float y, float z, float u, float v, byte r, byte g, byte b, byte a ) {
|
public VertexPos3fTex2fCol4b( float x, float y, float z, float u, float v, byte r, byte g, byte b, byte a ) {
|
||||||
X = x; Y = y; Z = z;
|
X = x; Y = y; Z = z;
|
||||||
U = u; V = v;
|
U = u; V = v;
|
||||||
|
@ -12,11 +12,17 @@ namespace ClassicalSharp.Renderers {
|
|||||||
map = game.Map;
|
map = game.Map;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cloudsVb = -1, cloudsIndices;
|
int cloudsVb = -1, cloudsIndices, skyVb = -1, skyIndices;
|
||||||
int skyOffset = 10, skyVb = -1, skyIndices;
|
public float CloudsSpeed = 1;
|
||||||
public float CloudsSpeed = 1;
|
public int CloudsOffset = 2;
|
||||||
bool legacy;
|
bool legacy;
|
||||||
|
|
||||||
|
public void SetCloudsOffset( int offset ) {
|
||||||
|
CloudsOffset = offset;
|
||||||
|
ResetClouds();
|
||||||
|
ResetSky();
|
||||||
|
}
|
||||||
|
|
||||||
public void SetUseLegacyMode( bool legacy ) {
|
public void SetUseLegacyMode( bool legacy ) {
|
||||||
this.legacy = legacy;
|
this.legacy = legacy;
|
||||||
ResetSky();
|
ResetSky();
|
||||||
@ -27,7 +33,7 @@ namespace ClassicalSharp.Renderers {
|
|||||||
if( skyVb == -1 || cloudsVb == -1 ) return;
|
if( skyVb == -1 || cloudsVb == -1 ) return;
|
||||||
|
|
||||||
Vector3 pos = game.LocalPlayer.EyePosition;
|
Vector3 pos = game.LocalPlayer.EyePosition;
|
||||||
if( pos.Y < map.Height + skyOffset ) {
|
if( pos.Y < map.Height + CloudsOffset + 8 ) {
|
||||||
graphics.BeginVbBatch( VertexFormat.Pos3fCol4b );
|
graphics.BeginVbBatch( VertexFormat.Pos3fCol4b );
|
||||||
graphics.BindVb( skyVb );
|
graphics.BindVb( skyVb );
|
||||||
graphics.DrawIndexedVb( DrawMode.Triangles, skyIndices, 0 );
|
graphics.DrawIndexedVb( DrawMode.Triangles, skyIndices, 0 );
|
||||||
@ -35,11 +41,6 @@ namespace ClassicalSharp.Renderers {
|
|||||||
RenderClouds( deltaTime );
|
RenderClouds( deltaTime );
|
||||||
ResetFog();
|
ResetFog();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSkyOffset( int offset ) {
|
|
||||||
skyOffset = offset;
|
|
||||||
ResetSky();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void CloudsColourChanged() {
|
protected override void CloudsColourChanged() {
|
||||||
ResetClouds();
|
ResetClouds();
|
||||||
@ -159,7 +160,7 @@ namespace ClassicalSharp.Renderers {
|
|||||||
cloudsIndices = Utils.CountIndices( x2 - x1, z2 - z1, axisSize );
|
cloudsIndices = Utils.CountIndices( x2 - x1, z2 - z1, axisSize );
|
||||||
|
|
||||||
VertexPos3fTex2fCol4b* vertices = stackalloc VertexPos3fTex2fCol4b[cloudsIndices / 6 * 4];
|
VertexPos3fTex2fCol4b* vertices = stackalloc VertexPos3fTex2fCol4b[cloudsIndices / 6 * 4];
|
||||||
DrawCloudsY( x1, z1, x2, z2, map.Height + 2, axisSize, map.CloudsCol, vertices );
|
DrawCloudsY( x1, z1, x2, z2, map.Height + CloudsOffset, axisSize, map.CloudsCol, vertices );
|
||||||
cloudsVb = graphics.CreateVb( (IntPtr)vertices, VertexFormat.Pos3fTex2fCol4b, cloudsIndices / 6 * 4 );
|
cloudsVb = graphics.CreateVb( (IntPtr)vertices, VertexFormat.Pos3fTex2fCol4b, cloudsIndices / 6 * 4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +170,7 @@ namespace ClassicalSharp.Renderers {
|
|||||||
skyIndices = Utils.CountIndices( x2 - x1, z2 - z1, axisSize );
|
skyIndices = Utils.CountIndices( x2 - x1, z2 - z1, axisSize );
|
||||||
|
|
||||||
VertexPos3fCol4b* vertices = stackalloc VertexPos3fCol4b[skyIndices / 6 * 4];
|
VertexPos3fCol4b* vertices = stackalloc VertexPos3fCol4b[skyIndices / 6 * 4];
|
||||||
DrawSkyY( x1, z1, x2, z2, map.Height + skyOffset, axisSize, map.SkyCol, vertices );
|
DrawSkyY( x1, z1, x2, z2, map.Height + CloudsOffset + 8, axisSize, map.SkyCol, vertices );
|
||||||
skyVb = graphics.CreateVb( (IntPtr)vertices, VertexFormat.Pos3fCol4b, skyIndices / 6 * 4 );
|
skyVb = graphics.CreateVb( (IntPtr)vertices, VertexFormat.Pos3fCol4b, skyIndices / 6 * 4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,24 @@ namespace ClassicalSharp {
|
|||||||
return OptionsSet.TryGetValue( key, out value ) ? value : null;
|
return OptionsSet.TryGetValue( key, out value ) ? value : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool TryGetInt( string key, out int valueInt ) {
|
||||||
|
string value;
|
||||||
|
valueInt = 0;
|
||||||
|
OptionsSet.TryGetValue( key, out value );
|
||||||
|
|
||||||
|
if( String.IsNullOrEmpty( value ) ) return false;
|
||||||
|
return Int32.TryParse( value, out 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 void Set( string key, string value ) {
|
public static void Set( string key, string value ) {
|
||||||
OptionsSet[key] = value;
|
OptionsSet[key] = value;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user