mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-23 17:43:08 -05:00
Gui: Reduce code duplication in NostalgiaScreen
This commit is contained in:
parent
f9c0f75208
commit
603cb9fdce
2 changed files with 16 additions and 37 deletions
|
@ -30,7 +30,7 @@ namespace ClassicalSharp.Gui.Screens {
|
|||
api.Texturing = true;
|
||||
RenderMenuWidgets( delta );
|
||||
if( inputWidget != null )
|
||||
inputWidget.Render( delta );
|
||||
inputWidget.Render( delta );
|
||||
|
||||
if( extendedHelp != null && extEndY <= extClipY )
|
||||
extendedHelp.Render( delta );
|
||||
|
@ -68,14 +68,14 @@ namespace ClassicalSharp.Gui.Screens {
|
|||
return inputWidget.HandlesKeyUp( key );
|
||||
}
|
||||
|
||||
public override void OnResize( int width, int height ) {
|
||||
public override void OnResize( int width, int height ) {
|
||||
base.OnResize( width, height );
|
||||
if( extendedHelp == null ) return;
|
||||
extendedHelp.OnResize( width, height );
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
DisposeWidgets();
|
||||
DisposeWidgets();
|
||||
game.Keyboard.KeyRepeat = false;
|
||||
extendedHelpFont.Dispose();
|
||||
DisposeExtendedHelp();
|
||||
|
@ -111,8 +111,8 @@ namespace ClassicalSharp.Gui.Screens {
|
|||
}
|
||||
|
||||
protected ButtonWidget MakeOpt( int dir, int y, string text, ClickHandler onClick,
|
||||
Func<Game, string> getter, Action<Game, string> setter ) {
|
||||
ButtonWidget widget = ButtonWidget.Create( game, 160 * dir, y, 301, 41,
|
||||
Func<Game, string> getter, Action<Game, string> setter ) {
|
||||
ButtonWidget widget = ButtonWidget.Create( game, 160 * dir, y, 301, 41,
|
||||
text + ": " + getter( game ),
|
||||
Anchor.Centre, Anchor.Centre, titleFont, onClick );
|
||||
widget.Metadata = text;
|
||||
|
@ -125,7 +125,7 @@ namespace ClassicalSharp.Gui.Screens {
|
|||
}
|
||||
|
||||
protected ButtonWidget MakeBool( int dir, int y, string text, string optKey,
|
||||
ClickHandler onClick, Func<Game, bool> getter, Action<Game, bool> setter ) {
|
||||
ClickHandler onClick, Func<Game, bool> getter, Action<Game, bool> setter ) {
|
||||
string optName = text;
|
||||
text = text + ": " + (getter( game ) ? "ON" : "OFF");
|
||||
ButtonWidget widget = ButtonWidget.Create( game, 160 * dir, y, 301, 41, text, Anchor.Centre,
|
||||
|
|
|
@ -15,29 +15,27 @@ namespace ClassicalSharp.Gui.Screens {
|
|||
base.Init();
|
||||
|
||||
widgets = new Widget[] {
|
||||
// Column 1
|
||||
// Column 1
|
||||
MakeBool( -1, -100, "Simple arms anim", OptionsKey.SimpleArmsAnim,
|
||||
OnWidgetClick, g => g.SimpleArmsAnim, (g, v) => g.SimpleArmsAnim = v ),
|
||||
|
||||
OnWidgetClick, g => g.SimpleArmsAnim, (g, v) => g.SimpleArmsAnim = v ),
|
||||
MakeBool( -1, -50, "Classic gui textures", OptionsKey.UseClassicGui,
|
||||
OnWidgetClick, g => g.UseClassicGui, (g, v) => g.UseClassicGui = v ),
|
||||
|
||||
OnWidgetClick, g => g.UseClassicGui, (g, v) => g.UseClassicGui = v ),
|
||||
MakeBool( -1, 0, "Classic player list", OptionsKey.UseClassicTabList,
|
||||
OnWidgetClick, g => g.UseClassicTabList, (g, v) => g.UseClassicTabList = v ),
|
||||
|
||||
OnWidgetClick, g => g.UseClassicTabList, (g, v) => g.UseClassicTabList = v ),
|
||||
MakeBool( -1, 50, "Classic options", OptionsKey.UseClassicOptions,
|
||||
OnWidgetClick, g => g.UseClassicOptions, (g, v) => g.UseClassicOptions = v ),
|
||||
|
||||
// Column 2
|
||||
MakeBool( 1, -100, "Allow custom blocks", OptionsKey.AllowCustomBlocks,
|
||||
OnWidgetClick, g => g.AllowCustomBlocks, (g, v) => g.AllowCustomBlocks = v ),
|
||||
|
||||
OnWidgetClick, g => g.AllowCustomBlocks, (g, v) => g.AllowCustomBlocks = v ),
|
||||
MakeBool( 1, -50, "Use CPE", OptionsKey.UseCPE,
|
||||
OnWidgetClick, g => g.UseCPE, (g, v) => g.UseCPE = v ),
|
||||
|
||||
OnWidgetClick, g => g.UseCPE, (g, v) => g.UseCPE = v ),
|
||||
MakeBool( 1, 0, "Use server textures", OptionsKey.AllowServerTextures,
|
||||
OnWidgetClick, g => g.AllowServerTextures, (g, v) => g.AllowServerTextures = v ),
|
||||
|
||||
|
||||
ChatTextWidget.Create( game, 0, 100,
|
||||
"&eButtons on the right require a client restart",
|
||||
Anchor.Centre, Anchor.Centre, regularFont ),
|
||||
MakeBack( false, titleFont,
|
||||
(g, w) => g.Gui.SetNewScreen( PreviousScreen() ) ),
|
||||
null, null,
|
||||
|
@ -53,30 +51,11 @@ namespace ClassicalSharp.Gui.Screens {
|
|||
new BooleanValidator(),
|
||||
new BooleanValidator(),
|
||||
};
|
||||
infoWidget = ChatTextWidget.Create( game, 0, 100, "&eButtons on the right require a client restart",
|
||||
Anchor.Centre, Anchor.Centre, regularFont );
|
||||
}
|
||||
|
||||
Screen PreviousScreen() {
|
||||
if( game.UseClassicOptions ) return new PauseScreen( game );
|
||||
return new OptionsGroupScreen( game );
|
||||
}
|
||||
|
||||
public override void Render( double delta ) {
|
||||
base.Render( delta );
|
||||
api.Texturing = true;
|
||||
infoWidget.Render( delta );
|
||||
api.Texturing = false;
|
||||
}
|
||||
|
||||
public override void OnResize( int width, int height ) {
|
||||
base.OnResize( width, height );
|
||||
infoWidget.OnResize( width, height );
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
base.Dispose();
|
||||
infoWidget.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue