mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
Seed should not be restricted between 1-8192 in GenLevelScreen, do a general touchup of GenLevelScreen.
This commit is contained in:
parent
c4a2bd0517
commit
2f65ef3797
@ -15,6 +15,7 @@ namespace ClassicalSharp {
|
|||||||
TextWidget[] labels;
|
TextWidget[] labels;
|
||||||
MenuInputWidget[] inputs;
|
MenuInputWidget[] inputs;
|
||||||
MenuInputWidget selectedWidget;
|
MenuInputWidget selectedWidget;
|
||||||
|
Font labelFont;
|
||||||
|
|
||||||
public override void Render( double delta ) {
|
public override void Render( double delta ) {
|
||||||
RenderMenuBounds();
|
RenderMenuBounds();
|
||||||
@ -55,14 +56,19 @@ namespace ClassicalSharp {
|
|||||||
game.Keyboard.KeyRepeat = true;
|
game.Keyboard.KeyRepeat = true;
|
||||||
base.Init();
|
base.Init();
|
||||||
int size = game.Drawer2D.UseBitmappedChat ? 14 : 18;
|
int size = game.Drawer2D.UseBitmappedChat ? 14 : 18;
|
||||||
titleFont = new Font( game.FontName, size, FontStyle.Bold );
|
labelFont = new Font( game.FontName, size, FontStyle.Regular );
|
||||||
|
titleFont = new Font( game.FontName, size, FontStyle.Bold );
|
||||||
regularFont = new Font( game.FontName, 16, FontStyle.Regular );
|
regularFont = new Font( game.FontName, 16, FontStyle.Regular );
|
||||||
|
|
||||||
inputs = new [] { MakeInput( -100 ), MakeInput( -60 ),
|
inputs = new [] {
|
||||||
MakeInput( -20 ), MakeInput( 20 )
|
MakeInput( -100, false, game.Map.Width.ToString() ),
|
||||||
|
MakeInput( -60, false, game.Map.Height.ToString() ),
|
||||||
|
MakeInput( -20, false, game.Map.Length.ToString() ),
|
||||||
|
MakeInput( 20, true, "" )
|
||||||
};
|
};
|
||||||
labels = new [] { MakeLabel( -100, "Width:" ), MakeLabel( -60, "Height:" ),
|
labels = new [] {
|
||||||
MakeLabel( -20, "Length:" ), MakeLabel( 20, "Seed:" ),
|
MakeLabel( -150, -100, "Width:" ), MakeLabel( -150, -60, "Height:" ),
|
||||||
|
MakeLabel( -150, -20, "Length:" ), MakeLabel( -140, 20, "Seed:" ),
|
||||||
};
|
};
|
||||||
widgets = new [] {
|
widgets = new [] {
|
||||||
ButtonWidget.Create( game, 0, 80, 250, 35, "Generate flatgrass", Anchor.Centre,
|
ButtonWidget.Create( game, 0, 80, 250, 35, "Generate flatgrass", Anchor.Centre,
|
||||||
@ -74,18 +80,19 @@ namespace ClassicalSharp {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuInputWidget MakeInput( int y ) {
|
MenuInputWidget MakeInput( int y, bool seed, string value ) {
|
||||||
|
MenuInputValidator validator = seed ? new SeedValidator() : new IntegerValidator( 1, 8192 );
|
||||||
MenuInputWidget widget = MenuInputWidget.Create(
|
MenuInputWidget widget = MenuInputWidget.Create(
|
||||||
game, 0, y, 200, 25, "", Anchor.Centre, Anchor.Centre,
|
game, 0, y, 200, 25, value, Anchor.Centre, Anchor.Centre,
|
||||||
regularFont, titleFont, new IntegerValidator( 1, 8192 ) );
|
regularFont, titleFont, validator );
|
||||||
widget.Active = false;
|
widget.Active = false;
|
||||||
widget.OnClick = InputClick;
|
widget.OnClick = InputClick;
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWidget MakeLabel( int y, string text ) {
|
TextWidget MakeLabel( int x, int y, string text ) {
|
||||||
return TextWidget.Create( game, -140, y, text,
|
return TextWidget.Create( game, x, y, text,
|
||||||
Anchor.Centre, Anchor.Centre, titleFont );
|
Anchor.Centre, Anchor.Centre, labelFont );
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnResize( int oldWidth, int oldHeight, int width, int height ) {
|
public override void OnResize( int oldWidth, int oldHeight, int width, int height ) {
|
||||||
@ -102,6 +109,7 @@ namespace ClassicalSharp {
|
|||||||
inputs[i].Dispose();
|
inputs[i].Dispose();
|
||||||
for( int i = 0; i < labels.Length; i++ )
|
for( int i = 0; i < labels.Length; i++ )
|
||||||
labels[i].Dispose();
|
labels[i].Dispose();
|
||||||
|
labelFont.Dispose();
|
||||||
base.Dispose();
|
base.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,12 +40,16 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class IntegerValidator : MenuInputValidator {
|
public class IntegerValidator : MenuInputValidator {
|
||||||
|
|
||||||
int min, max;
|
int min, max;
|
||||||
public IntegerValidator( int min, int max ) {
|
public IntegerValidator( int min, int max ) {
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.max = max;
|
this.max = max;
|
||||||
|
SetRange();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void SetRange() {
|
||||||
MakeRange( min.ToString(), max.ToString() );
|
MakeRange( min.ToString(), max.ToString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,6 +70,15 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sealed class SeedValidator : IntegerValidator {
|
||||||
|
|
||||||
|
public SeedValidator() : base( 0, 0 ) { }
|
||||||
|
|
||||||
|
protected override void SetRange() {
|
||||||
|
Range = "&7(an integer)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public sealed class RealValidator : MenuInputValidator {
|
public sealed class RealValidator : MenuInputValidator {
|
||||||
|
|
||||||
float min, max;
|
float min, max;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user