Initial implementation of classic options menu.

This commit is contained in:
UnknownShadow200 2016-01-24 00:14:56 +11:00
parent 70a45f3290
commit 3794876119
7 changed files with 62 additions and 17 deletions

View File

@ -32,6 +32,12 @@ namespace ClassicalSharp {
Options.Set( OptionsKey.UseClassicTabList, v == "yes" );
} ),
Make( -140, 50, "Classic options menu", OnWidgetClick,
g => g.UseClassicOptions ? "yes" : "no",
(g, v) => { g.UseClassicOptions = v == "yes";
Options.Set( OptionsKey.UseClassicOptions, v == "yes" );
} ),
// Column 2
Make( 140, -100, "Allow custom blocks", OnWidgetClick,
g => g.AllowCustomBlocks ? "yes" : "no",

View File

@ -19,6 +19,15 @@ namespace ClassicalSharp {
public override void Init() {
base.Init();
game.Events.HackPermissionsChanged += CheckHacksAllowed;
if( game.UseClassicOptions )
MakeClassic();
else
MakeNormal();
CheckHacksAllowed( null, null );
}
void MakeNormal() {
widgets = new ButtonWidget[] {
// Column 1
Make( -140, -150, "Misc options", Anchor.Centre,
@ -55,7 +64,29 @@ namespace ClassicalSharp {
MakeBack( true, titleFont,
(g, w) => g.SetNewScreen( null ) ),
};
CheckHacksAllowed( null, null );
}
void MakeClassic() {
widgets = new ButtonWidget[] {
MakeClassic( 0, -150, "Options", Anchor.Centre,
(g, w) => g.SetNewScreen( new MiscOptionsScreen( g ) ) ),
MakeClassic( 0, -100, "Key bindings", Anchor.Centre,
(g, w) => g.SetNewScreen( new NormalKeyBindingsScreen( g ) ) ),
MakeClassic( 0, -50, "Save level", Anchor.Centre,
(g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ),
!game.Network.IsSinglePlayer ? null :
MakeClassic( 0, 0, "Load level", Anchor.Centre,
(g, w) => g.SetNewScreen( new LoadLevelScreen( g ) ) ),
!game.Network.IsSinglePlayer ? null :
MakeClassic( 0, 50, "Generate level", Anchor.Centre,
(g, w) => g.SetNewScreen( new GenLevelScreen( g ) ) ),
MakeClassic( 0, 100, "Nostalgia options", Anchor.Centre,
(g, w) => g.SetNewScreen( new NostalgiaScreen( g ) ) ),
MakeBack( true, titleFont,
(g, w) => g.SetNewScreen( null ) ),
};
}
void CheckHacksAllowed( object sender, EventArgs e ) {
@ -74,6 +105,11 @@ namespace ClassicalSharp {
Anchor.Centre, vDocking, titleFont, LeftOnly( onClick ) );
}
ButtonWidget MakeClassic( int x, int y, string text, Anchor vDocking, Action<Game, Widget> onClick ) {
return ButtonWidget.Create( game, x, y, 400, 40, text,
Anchor.Centre, vDocking, 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 ) );

View File

@ -206,6 +206,7 @@ namespace ClassicalSharp {
/// <summary> Parses hack flags specified in the motd and/or name of the server. </summary>
/// <remarks> Recognises +/-hax, +/-fly, +/-noclip, +/-speed, +/-respawn, +/-ophax </remarks>
public void ParseHackFlags( string name, string motd ) {
return;
string joined = name + motd;
SetAllHacks( true );
// By default (this is also the case with WoM), we can use hacks.

View File

@ -128,7 +128,7 @@ namespace ClassicalSharp {
public bool TabAutocomplete;
public bool UseClassicGui, UseClassicTabList;
public bool UseClassicGui, UseClassicTabList, UseClassicOptions;
public bool AllowCustomBlocks, UseCPE, AllowServerTextures;

View File

@ -68,6 +68,7 @@ namespace ClassicalSharp {
UseClassicGui = Options.GetBool( OptionsKey.UseClassicGui, true );
UseClassicTabList = Options.GetBool( OptionsKey.UseClassicTabList, false );
UseClassicOptions = Options.GetBool( OptionsKey.UseClassicOptions, false );
AllowCustomBlocks = Options.GetBool( OptionsKey.AllowCustomBlocks, true );
UseCPE = Options.GetBool( OptionsKey.UseCPE, true );
AllowServerTextures = Options.GetBool( OptionsKey.AllowServerTextures, true );

View File

@ -45,9 +45,9 @@ namespace ClassicalSharp {
public const string UseClassicGui = "nostalgia-classicgui";
public const string SimpleArmsAnim = "nostalgia-simplearms";
public const string UseClassicTabList = "nostalgia-classictablist";
public const string UseClassicOptions = "nostalgia-classicoptions";
}
// TODO: implement this
public enum FpsLimitMethod {
LimitVSync,
Limit30FPS,

View File

@ -94,6 +94,7 @@ namespace Launcher2 {
Options.Set( "nostalgia-usecpe", !game.ClassicMode );
Options.Set( "nostalgia-servertextures", !game.ClassicMode );
Options.Set( "nostalgia-classictablist", game.ClassicMode );
Options.Set( "nostalgia-classicoptions", game.ClassicMode );
Options.Set( "hacksenabled", !game.ClassicMode );
Options.Set( "doublejump", false );
Options.Save();