mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-23 17:43:08 -05:00
Make normal and classic mode buttons consistent.
This commit is contained in:
parent
db7e75a6ad
commit
9f933ac1d6
12 changed files with 58 additions and 91 deletions
|
@ -46,7 +46,7 @@ namespace ClassicalSharp.Gui {
|
|||
widgets = new Widget[] {
|
||||
ChatTextWidget.Create( game, 0, -30, title, Anchor.Centre, Anchor.Centre, titleFont ),
|
||||
ChatTextWidget.Create( game, 0, 10, message, Anchor.Centre, Anchor.Centre, messageFont ),
|
||||
ButtonWidget.Create( game, 0, 80, 280, 35, "Try to reconnect.. " + delay,
|
||||
ButtonWidget.Create( game, 0, 80, 301, 40, "Try to reconnect.. " + delay,
|
||||
Anchor.Centre, Anchor.Centre, titleFont, ReconnectClick ),
|
||||
};
|
||||
initTime = DateTime.UtcNow;
|
||||
|
|
|
@ -16,41 +16,41 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
widgets = new Widget[] {
|
||||
// Column 1
|
||||
MakeClassicBool( -1, -150, "Music", OptionsKey.UseMusic,
|
||||
MakeBool( -1, -150, "Music", OptionsKey.UseMusic,
|
||||
OnWidgetClick, g => g.UseMusic,
|
||||
(g, v) => { g.UseMusic = v; g.AudioPlayer.SetMusic( g.UseMusic ); }),
|
||||
|
||||
MakeClassicBool( -1, -100, "Invert mouse", OptionsKey.InvertMouse,
|
||||
MakeBool( -1, -100, "Invert mouse", OptionsKey.InvertMouse,
|
||||
OnWidgetClick, g => g.InvertMouse, (g, v) => g.InvertMouse = v ),
|
||||
|
||||
MakeClassic2( -1, -50, "View distance", OnWidgetClick,
|
||||
Make2( -1, -50, "View distance", OnWidgetClick,
|
||||
g => g.ViewDistance.ToString(),
|
||||
(g, v) => g.SetViewDistance( Int32.Parse( v ), true ) ),
|
||||
|
||||
!network.IsSinglePlayer ? null :
|
||||
MakeClassicBool( -1, 0, "Block physics", OptionsKey.SingleplayerPhysics, OnWidgetClick,
|
||||
MakeBool( -1, 0, "Block physics", OptionsKey.SingleplayerPhysics, OnWidgetClick,
|
||||
g => ((SinglePlayerServer)network).physics.Enabled,
|
||||
(g, v) => ((SinglePlayerServer)network).physics.Enabled = v),
|
||||
|
||||
// Column 2
|
||||
MakeClassicBool( 1, -150, "Sound", OptionsKey.UseSound,
|
||||
MakeBool( 1, -150, "Sound", OptionsKey.UseSound,
|
||||
OnWidgetClick, g => g.UseSound,
|
||||
(g, v) => { g.UseSound = v; g.AudioPlayer.SetSound( g.UseSound ); }),
|
||||
|
||||
MakeClassicBool( 1, -100, "Show FPS", OptionsKey.ShowFPS,
|
||||
MakeBool( 1, -100, "Show FPS", OptionsKey.ShowFPS,
|
||||
OnWidgetClick, g => g.ShowFPS, (g, v) => g.ShowFPS = v ),
|
||||
|
||||
MakeClassicBool( 1, -50, "View bobbing", OptionsKey.ViewBobbing,
|
||||
MakeBool( 1, -50, "View bobbing", OptionsKey.ViewBobbing,
|
||||
OnWidgetClick, g => g.ViewBobbing, (g, v) => g.ViewBobbing = v ),
|
||||
|
||||
MakeClassic2( 1, 0, "FPS mode", OnWidgetClick,
|
||||
Make2( 1, 0, "FPS mode", OnWidgetClick,
|
||||
g => g.FpsLimit.ToString(),
|
||||
(g, v) => { object raw = Enum.Parse( typeof(FpsLimitMethod), v );
|
||||
g.SetFpsLimitMethod( (FpsLimitMethod)raw );
|
||||
Options.Set( OptionsKey.FpsLimit, v ); } ),
|
||||
|
||||
!game.ClassicHacks ? null :
|
||||
MakeClassicBool( 0, 60, "Hacks enabled", OptionsKey.HacksEnabled,
|
||||
MakeBool( 0, 60, "Hacks enabled", OptionsKey.HacksEnabled,
|
||||
OnWidgetClick, g => g.LocalPlayer.Hacks.Enabled,
|
||||
(g, v) => { g.LocalPlayer.Hacks.Enabled = v;
|
||||
g.LocalPlayer.CheckHacksConsistency(); } ),
|
||||
|
@ -65,9 +65,9 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
Widget MakeControlsWidget() {
|
||||
if( !game.ClassicHacks )
|
||||
return MakeClassic( 0, 110, "Controls", LeftOnly(
|
||||
return Make( 0, 110, "Controls", LeftOnly(
|
||||
(g, w) => g.SetNewScreen( new ClassicKeyBindingsScreen( g ) ) ), null, null );
|
||||
return MakeClassic( 0, 110, "Controls", LeftOnly(
|
||||
return Make( 0, 110, "Controls", LeftOnly(
|
||||
(g, w) => g.SetNewScreen( new ClassicHacksKeyBindingsScreen( g ) ) ), null, null );
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
protected override void InputOpened() {
|
||||
widgets[defaultIndex] = ButtonWidget.Create(
|
||||
game, 0, 160, 180, 35, "Default value", Anchor.Centre,
|
||||
game, 0, 150, 201, 40, "Default value", Anchor.Centre,
|
||||
Anchor.Centre, titleFont, DefaultButtonClick );
|
||||
}
|
||||
|
||||
|
|
|
@ -14,26 +14,27 @@ namespace ClassicalSharp.Gui {
|
|||
public override void Init() {
|
||||
base.Init();
|
||||
INetworkProcessor network = game.Network;
|
||||
extHelpY = 50;
|
||||
|
||||
widgets = new Widget[] {
|
||||
widgets = new Widget[] {
|
||||
|
||||
Make2( -1, 0, "FPS mode", OnWidgetClick,
|
||||
Make2( -1, -50, "FPS mode", OnWidgetClick,
|
||||
g => g.FpsLimit.ToString(),
|
||||
(g, v) => { object raw = Enum.Parse( typeof(FpsLimitMethod), v );
|
||||
g.SetFpsLimitMethod( (FpsLimitMethod)raw );
|
||||
Options.Set( OptionsKey.FpsLimit, v ); } ),
|
||||
|
||||
Make2( -1, 50, "View distance", OnWidgetClick,
|
||||
Make2( -1, 0, "View distance", OnWidgetClick,
|
||||
g => g.ViewDistance.ToString(),
|
||||
(g, v) => g.SetViewDistance( Int32.Parse( v ), true ) ),
|
||||
|
||||
Make2( 1, 0, "Names", OnWidgetClick,
|
||||
Make2( 1, -50, "Names", OnWidgetClick,
|
||||
g => g.Players.NamesMode.ToString(),
|
||||
(g, v) => { object raw = Enum.Parse( typeof(NameMode), v );
|
||||
g.Players.NamesMode = (NameMode)raw;
|
||||
Options.Set( OptionsKey.NamesMode, v ); } ),
|
||||
|
||||
Make2( 1, 50, "Shadows", OnWidgetClick,
|
||||
Make2( 1, 0, "Shadows", OnWidgetClick,
|
||||
g => g.Players.ShadowMode.ToString(),
|
||||
(g, v) => { object raw = Enum.Parse( typeof(EntityShadow), v );
|
||||
g.Players.ShadowMode = (EntityShadow)raw;
|
||||
|
|
|
@ -68,10 +68,7 @@ namespace ClassicalSharp.Gui {
|
|||
return inputWidget.HandlesKeyUp( key );
|
||||
}
|
||||
|
||||
public override void OnResize( int oldWidth, int oldHeight, int width, int height ) {
|
||||
if( inputWidget != null )
|
||||
inputWidget.OnResize( oldWidth, oldHeight, width, height );
|
||||
|
||||
public override void OnResize( int oldWidth, int oldHeight, int width, int height ) {
|
||||
base.OnResize( oldWidth, oldHeight, width, height );
|
||||
if( extendedHelp == null ) return;
|
||||
extendedHelp.OnResize( oldWidth, oldHeight, width, height );
|
||||
|
@ -108,44 +105,17 @@ namespace ClassicalSharp.Gui {
|
|||
protected virtual void InputClosed() { }
|
||||
|
||||
protected ButtonWidget Make( int dir, int y, string text, ClickHandler onClick,
|
||||
Func<Game, string> getter, Action<Game, string> setter ) {
|
||||
ButtonWidget widget = ButtonWidget.Create( game, 160 * dir, y, 280, 35, text, Anchor.Centre,
|
||||
Func<Game, string> getter, Action<Game, string> setter ) {
|
||||
ButtonWidget widget = ButtonWidget.Create( game, 160 * dir, y, 301, 41, text, Anchor.Centre,
|
||||
Anchor.Centre, titleFont, onClick );
|
||||
widget.GetValue = getter; widget.SetValue = setter;
|
||||
return widget;
|
||||
}
|
||||
|
||||
protected ButtonWidget Make2( int dir, int y, string text, ClickHandler onClick,
|
||||
Func<Game, string> getter, Action<Game, string> setter ) {
|
||||
return Make2Impl( 160 * dir, y, 280, 35, text, onClick, getter, setter );
|
||||
}
|
||||
|
||||
protected ButtonWidget MakeBool( int dir, int y, string optName, string optKey,
|
||||
ClickHandler onClick, Func<Game, bool> getter, Action<Game, bool> setter ) {
|
||||
return MakeBoolImpl( 160 * dir, y, 280, 35, optName, optKey, onClick, getter, setter );
|
||||
}
|
||||
|
||||
protected ButtonWidget MakeClassic( int dir, int y, string text, ClickHandler onClick,
|
||||
Func<Game, string> getter, Action<Game, string> setter ) {
|
||||
ButtonWidget widget = ButtonWidget.Create( game, 165 * dir, y, 301, 41, text, Anchor.Centre,
|
||||
Anchor.Centre, titleFont, onClick );
|
||||
widget.GetValue = getter; widget.SetValue = setter;
|
||||
return widget;
|
||||
}
|
||||
|
||||
protected ButtonWidget MakeClassic2( int dir, int y, string text, ClickHandler onClick,
|
||||
Func<Game, string> getter, Action<Game, string> setter ) {
|
||||
return Make2Impl( 165 * dir, y, 301, 41, text, onClick, getter, setter );
|
||||
}
|
||||
|
||||
protected ButtonWidget MakeClassicBool( int dir, int y, string text, string optKey,
|
||||
ClickHandler onClick, Func<Game, bool> getter, Action<Game, bool> setter ) {
|
||||
return MakeBoolImpl( 165 * dir, y, 301, 41, text, optKey, onClick, getter, setter );
|
||||
}
|
||||
|
||||
ButtonWidget Make2Impl( int x, int y, int width, int height, string text,
|
||||
ClickHandler onClick, Func<Game, string> getter, Action<Game, string> setter ) {
|
||||
ButtonWidget widget = ButtonWidget.Create( game, x, y, width, height, text + ": " + getter( game ),
|
||||
ButtonWidget widget = ButtonWidget.Create( game, 160 * dir, y, 301, 41,
|
||||
text + ": " + getter( game ),
|
||||
Anchor.Centre, Anchor.Centre, titleFont, onClick );
|
||||
widget.Metadata = text;
|
||||
widget.GetValue = getter;
|
||||
|
@ -156,11 +126,11 @@ namespace ClassicalSharp.Gui {
|
|||
return widget;
|
||||
}
|
||||
|
||||
ButtonWidget MakeBoolImpl( int x, int y, int width, int height, string text, string optKey,
|
||||
ClickHandler onClick, Func<Game, bool> getter, Action<Game, bool> setter ) {
|
||||
protected ButtonWidget MakeBool( int dir, int y, string text, string optKey,
|
||||
ClickHandler onClick, Func<Game, bool> getter, Action<Game, bool> setter ) {
|
||||
string optName = text;
|
||||
text = text + ": " + (getter( game ) ? "ON" : "OFF");
|
||||
ButtonWidget widget = ButtonWidget.Create( game, x, y, width, height, text, Anchor.Centre,
|
||||
ButtonWidget widget = ButtonWidget.Create( game, 160 * dir, y, 301, 41, text, Anchor.Centre,
|
||||
Anchor.Centre, titleFont, onClick );
|
||||
widget.Metadata = optName;
|
||||
widget.GetValue = g => getter( g ) ? "yes" : "no";
|
||||
|
@ -185,7 +155,7 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
static FastColour tableCol = new FastColour( 20, 20, 20, 200 );
|
||||
int tableWidth, tableHeight;
|
||||
const int extHelpY = 100;
|
||||
protected int extHelpY = 100;
|
||||
void MakeExtendedHelp( string[] desc ) {
|
||||
extendedHelp = new TextGroupWidget( game, desc.Length, extendedHelpFont, null,
|
||||
Anchor.Centre, Anchor.Centre );
|
||||
|
|
|
@ -32,19 +32,19 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
void MakeNormal() {
|
||||
widgets = new Widget[] {
|
||||
Make( -140, -100, "Misc options",
|
||||
Make( -1, -100, "Misc options",
|
||||
(g, w) => g.SetNewScreen( new MiscOptionsScreen( g ) ) ),
|
||||
Make( -140, -50, "Gui options",
|
||||
Make( -1, -50, "Gui options",
|
||||
(g, w) => g.SetNewScreen( new GuiOptionsScreen( g ) ) ),
|
||||
Make( -140, 0, "Graphics options",
|
||||
Make( -1, 0, "Graphics options",
|
||||
(g, w) => g.SetNewScreen( new GraphicsOptionsScreen( g ) ) ),
|
||||
Make( -140, 50, "Key bindings",
|
||||
Make( -1, 50, "Key bindings",
|
||||
(g, w) => g.SetNewScreen( new NormalKeyBindingsScreen( g ) ) ),
|
||||
Make( 140, -50, "Hacks settings",
|
||||
Make( 1, -50, "Hacks settings",
|
||||
(g, w) => g.SetNewScreen( new HacksSettingsScreen( g ) ) ),
|
||||
Make( 140, 0, "Env settings",
|
||||
Make( 1, 0, "Env settings",
|
||||
(g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ),
|
||||
Make( 140, 50, "Nostalgia options",
|
||||
Make( 1, 50, "Nostalgia options",
|
||||
(g, w) => g.SetNewScreen( new NostalgiaScreen( g ) ) ),
|
||||
|
||||
MakeBack( false, titleFont,
|
||||
|
@ -70,13 +70,13 @@ namespace ClassicalSharp.Gui {
|
|||
descWidget = ChatTextWidget.Create( game, 0, 100, text, Anchor.Centre, Anchor.Centre, regularFont );
|
||||
}
|
||||
|
||||
ButtonWidget Make( int x, int y, string text, Action<Game, Widget> onClick ) {
|
||||
return ButtonWidget.Create( game, x, y, 240, 35, text,
|
||||
ButtonWidget Make( int dir, int y, string text, Action<Game, Widget> onClick ) {
|
||||
return ButtonWidget.Create( game, dir * 160, y, 301, 40, text,
|
||||
Anchor.Centre, Anchor.Centre, titleFont, LeftOnly( onClick ) );
|
||||
}
|
||||
|
||||
ButtonWidget MakeOther( int x, int y, int width, string text, Anchor hAnchor, Action<Game, Widget> onClick ) {
|
||||
return ButtonWidget.Create( game, x, y, width, 35, text,
|
||||
return ButtonWidget.Create( game, x, y, width, 40, text,
|
||||
hAnchor, Anchor.BottomOrRight, titleFont, LeftOnly( onClick ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -33,22 +33,23 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
void MakeNormal() {
|
||||
widgets = new Widget[] {
|
||||
Make( -140, -50, "Options",
|
||||
Make( -1, -50, "Options",
|
||||
(g, w) => g.SetNewScreen( new OptionsGroupScreen( g ) ) ),
|
||||
Make( 140, -50, "Generate level",
|
||||
Make( 1, -50, "Generate level",
|
||||
(g, w) => g.SetNewScreen( new GenLevelScreen( g ) ) ),
|
||||
Make( 140, 0, "Load level",
|
||||
Make( 1, 0, "Load level",
|
||||
(g, w) => g.SetNewScreen( new LoadLevelScreen( g ) ) ),
|
||||
Make( 140, 50, "Save level",
|
||||
Make( 1, 50, "Save level",
|
||||
(g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ),
|
||||
Make( -140, 0, "Select texture pack",
|
||||
Make( -1, 0, "Select texture pack",
|
||||
(g, w) => g.SetNewScreen( new TexturePackScreen( g ) ) ),
|
||||
Make( -140, 50, "Hotkeys",
|
||||
Make( -1, 50, "Hotkeys",
|
||||
(g, w) => g.SetNewScreen( new HotkeyScreen( g ) ) ),
|
||||
|
||||
// Other
|
||||
MakeOther( 10, 5, 120, "Quit game", Anchor.BottomOrRight,
|
||||
(g, w) => g.Exit() ),
|
||||
ButtonWidget.Create( game, 5, 5, 120, 40, "Quit game",
|
||||
Anchor.BottomOrRight, Anchor.BottomOrRight,
|
||||
titleFont, LeftOnly( (g, w) => g.Exit() ) ),
|
||||
MakeBack( true, titleFont, (g, w) => g.SetNewScreen( null ) ),
|
||||
};
|
||||
}
|
||||
|
@ -77,21 +78,16 @@ namespace ClassicalSharp.Gui {
|
|||
widgets[4].Disabled = !game.LocalPlayer.Hacks.CanAnyHacks; // select texture pack
|
||||
}
|
||||
|
||||
ButtonWidget Make( int x, int y, string text, Action<Game, Widget> onClick ) {
|
||||
return ButtonWidget.Create( game, x, y, 240, 35, text,
|
||||
ButtonWidget Make( int dir, int y, string text, Action<Game, Widget> onClick ) {
|
||||
return ButtonWidget.Create( game, dir * 160, y, 301, 40, text,
|
||||
Anchor.Centre, Anchor.Centre, titleFont, LeftOnly( onClick ) );
|
||||
}
|
||||
|
||||
ButtonWidget MakeClassic( int x, int y, string text, Action<Game, Widget> onClick ) {
|
||||
return ButtonWidget.Create( game, x, y, 401, 41, text,
|
||||
return ButtonWidget.Create( game, x, y, 401, 40, text,
|
||||
Anchor.Centre, Anchor.Centre, titleFont, LeftOnly( onClick ) );
|
||||
}
|
||||
|
||||
ButtonWidget MakeOther( int x, int y, int width, string text, Anchor hAnchor, Action<Game, Widget> onClick ) {
|
||||
return ButtonWidget.Create( game, x, y, width, 35, text,
|
||||
hAnchor, Anchor.BottomOrRight, titleFont, LeftOnly( onClick ) );
|
||||
}
|
||||
|
||||
public override bool HandlesKeyDown( Key key ) {
|
||||
if( key == Key.Escape )
|
||||
game.SetNewScreen( null );
|
||||
|
|
|
@ -139,7 +139,7 @@ namespace ClassicalSharp.Commands {
|
|||
}
|
||||
|
||||
void SetNewRenderType( bool legacy, bool minimal ) {
|
||||
game.MapBordersRenderer.SetUseLegacyMode( legacy );
|
||||
game.MapBordersRenderer.UseLegacyMode( legacy );
|
||||
if( minimal ) {
|
||||
game.EnvRenderer.Dispose();
|
||||
game.EnvRenderer = new MinimalEnvRenderer( game );
|
||||
|
@ -150,7 +150,7 @@ namespace ClassicalSharp.Commands {
|
|||
game.EnvRenderer = new StandardEnvRenderer( game );
|
||||
game.EnvRenderer.Init();
|
||||
}
|
||||
((StandardEnvRenderer)game.EnvRenderer).SetUseLegacyMode( legacy );
|
||||
((StandardEnvRenderer)game.EnvRenderer).UseLegacyMode( legacy );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,8 +154,8 @@ namespace ClassicalSharp {
|
|||
LoadIcon();
|
||||
string connectString = "Connecting to " + IPAddress + ":" + Port + "..";
|
||||
if( Graphics.WarnIfNecessary( Chat ) ) {
|
||||
MapBordersRenderer.SetUseLegacyMode( true );
|
||||
((StandardEnvRenderer)EnvRenderer).SetUseLegacyMode( true );
|
||||
MapBordersRenderer.UseLegacyMode( true );
|
||||
((StandardEnvRenderer)EnvRenderer).UseLegacyMode( true );
|
||||
}
|
||||
SetNewScreen( new LoadingMapScreen( this, connectString, "Waiting for handshake" ) );
|
||||
Network.Connect( IPAddress, Port );
|
||||
|
|
|
@ -52,10 +52,10 @@ namespace ClassicalSharp {
|
|||
width = 640; height = 480;
|
||||
|
||||
if( device.Width >= 1024 && device.Height >= 768 ) {
|
||||
width = 800; height = 600;
|
||||
//width = 800; height = 600;
|
||||
}
|
||||
if( device.Width >= 1920 && device.Height >= 1080 ) {
|
||||
width = 1600; height = 900;
|
||||
//width = 1600; height = 900;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace ClassicalSharp.Renderers {
|
|||
int sidesVertices, edgesVertices;
|
||||
bool legacy, fullColSides, fullColEdge;
|
||||
|
||||
public void SetUseLegacyMode( bool legacy ) {
|
||||
public void UseLegacyMode( bool legacy ) {
|
||||
this.legacy = legacy;
|
||||
ResetSidesAndEdges( null, null );
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace ClassicalSharp.Renderers {
|
|||
int cloudsVb = -1, cloudVertices, skyVb = -1, skyVertices;
|
||||
bool legacy;
|
||||
|
||||
public void SetUseLegacyMode( bool legacy ) {
|
||||
public void UseLegacyMode( bool legacy ) {
|
||||
this.legacy = legacy;
|
||||
ResetSky();
|
||||
ResetClouds();
|
||||
|
|
Loading…
Add table
Reference in a new issue