Make 'Back to X' buttons same as classic. (Thanks FrostFox)

This commit is contained in:
UnknownShadow200 2016-06-24 20:21:33 +10:00
parent 123b452fbc
commit df986441f8
4 changed files with 30 additions and 25 deletions

View file

@ -50,12 +50,16 @@ namespace ClassicalSharp.Gui {
}
protected ButtonWidget MakeBack( bool toGame, Font font, Action<Game, Widget> onClick ) {
return MakeBack( toGame ? "Back to game" : "Back to menu", 25, font, onClick );
return MakeBack( 201, toGame ? "Back to game" : "Back to menu", 25, font, onClick );
}
protected ButtonWidget MakeBack( string text, int y, Font font, Action<Game, Widget> onClick ) {
return MakeBack( 201, text, y, font, onClick );
}
protected ButtonWidget MakeBack( int width, string text, int y, Font font, Action<Game, Widget> onClick ) {
return ButtonWidget.Create(
game, 0, y, 201, 40, text,
game, 0, y, width, 40, text,
Anchor.Centre, Anchor.BottomOrRight, font, LeftOnly( onClick ) );
}
}

View file

@ -17,48 +17,49 @@ namespace ClassicalSharp.Gui {
widgets = new Widget[] {
// Column 1
MakeBool( -1, -150, "Music", OptionsKey.UseMusic,
OnWidgetClick, g => g.UseMusic,
(g, v) => { g.UseMusic = v; g.AudioPlayer.SetMusic( g.UseMusic ); }),
OnWidgetClick, g => g.UseMusic,
(g, v) => { g.UseMusic = v; g.AudioPlayer.SetMusic( g.UseMusic ); }),
MakeBool( -1, -100, "Invert mouse", OptionsKey.InvertMouse,
OnWidgetClick, g => g.InvertMouse, (g, v) => g.InvertMouse = v ),
MakeOpt( -1, -50, "View distance", OnWidgetClick,
g => g.ViewDistance.ToString(),
(g, v) => g.SetViewDistance( Int32.Parse( v ), true ) ),
g => g.ViewDistance.ToString(),
(g, v) => g.SetViewDistance( Int32.Parse( v ), true ) ),
!network.IsSinglePlayer ? null :
MakeBool( -1, 0, "Block physics", OptionsKey.SingleplayerPhysics, OnWidgetClick,
g => ((SinglePlayerServer)network).physics.Enabled,
(g, v) => ((SinglePlayerServer)network).physics.Enabled = v),
g => ((SinglePlayerServer)network).physics.Enabled,
(g, v) => ((SinglePlayerServer)network).physics.Enabled = v),
// Column 2
MakeBool( 1, -150, "Sound", OptionsKey.UseSound,
OnWidgetClick, g => g.UseSound,
(g, v) => { g.UseSound = v; g.AudioPlayer.SetSound( g.UseSound ); }),
OnWidgetClick, g => g.UseSound,
(g, v) => { g.UseSound = v; g.AudioPlayer.SetSound( g.UseSound ); }),
MakeBool( 1, -100, "Show FPS", OptionsKey.ShowFPS,
OnWidgetClick, g => g.ShowFPS, (g, v) => g.ShowFPS = v ),
OnWidgetClick, g => g.ShowFPS, (g, v) => g.ShowFPS = v ),
MakeBool( 1, -50, "View bobbing", OptionsKey.ViewBobbing,
OnWidgetClick, g => g.ViewBobbing, (g, v) => g.ViewBobbing = v ),
OnWidgetClick, g => g.ViewBobbing, (g, v) => g.ViewBobbing = v ),
MakeOpt( 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 ); } ),
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 :
MakeBool( 0, 60, "Hacks enabled", OptionsKey.HacksEnabled,
OnWidgetClick, g => g.LocalPlayer.Hacks.Enabled,
(g, v) => { g.LocalPlayer.Hacks.Enabled = v;
g.LocalPlayer.CheckHacksConsistency(); } ),
OnWidgetClick, g => g.LocalPlayer.Hacks.Enabled,
(g, v) => { g.LocalPlayer.Hacks.Enabled = v;
g.LocalPlayer.CheckHacksConsistency(); } ),
MakeTitle( 0, 110, "Controls", LeftOnly(
(g, w) => g.SetNewScreen( new ClassicKeyBindingsScreen( g ) ) ) ),
ButtonWidget.Create( game, 0, 95, 401, 41, "Controls", Anchor.Centre,
Anchor.BottomOrRight, titleFont,
LeftOnly( (g, w) => g.SetNewScreen( new ClassicKeyBindingsScreen( g ) ) ) ),
MakeBack( "Done", 25, titleFont, (g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
MakeBack( 401, "Done", 22, titleFont, (g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
null, null,
};
MakeValidators();
@ -70,7 +71,7 @@ namespace ClassicalSharp.Gui {
new BooleanValidator(),
new BooleanValidator(),
new IntegerValidator( 16, 4096 ),
network.IsSinglePlayer ? new BooleanValidator() : null,
network.IsSinglePlayer ? new BooleanValidator() : null,
new BooleanValidator(),
new BooleanValidator(),

View file

@ -65,7 +65,7 @@ namespace ClassicalSharp.Gui {
MakeClassic( 0, 50, "Save level",
(g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ),
MakeBack( true, titleFont, (g, w) => g.SetNewScreen( null ) ),
MakeBack( 401, "Back to game", 22, titleFont, (g, w) => g.SetNewScreen( null ) ),
game.ClassicMode ? null :
MakeClassic( 0, 150, "Nostalgia options",

View file

@ -88,7 +88,7 @@ namespace ClassicalSharp {
Rectangle rec = new Rectangle( 0, 0, Bitmap.Width, Bitmap.Height );
data = Bitmap.LockBits( rec, ImageLockMode.ReadWrite, format );
Scan0 = data.Scan0;
scan0Byte = (byte*)Scan0;
scan0Byte = (byte*)Scan0;
Stride = data.Stride;
Width = data.Width;
Height = data.Height;