mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-19 12:35:52 -04:00
Create some descriptions for various options (not drawn yet), also reduce some code duplication.
This commit is contained in:
parent
c39b58bbd0
commit
1278b8276b
@ -87,15 +87,6 @@ namespace ClassicalSharp {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonWidget Make( int x, int y, string text,Action<Game, Widget> onClick,
|
|
||||||
Func<Game, string> getter, Action<Game, string> setter ) {
|
|
||||||
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre,
|
|
||||||
Anchor.Centre, titleFont, onClick );
|
|
||||||
widget.GetValue = getter;
|
|
||||||
widget.SetValue = setter;
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void InputClosed() {
|
protected override void InputClosed() {
|
||||||
if( buttons[defaultIndex] != null )
|
if( buttons[defaultIndex] != null )
|
||||||
buttons[defaultIndex].Dispose();
|
buttons[defaultIndex].Dispose();
|
||||||
|
@ -71,30 +71,11 @@ namespace ClassicalSharp {
|
|||||||
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
|
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
|
||||||
null,
|
null,
|
||||||
};
|
};
|
||||||
validators = new MenuInputValidator[] {
|
|
||||||
new BooleanValidator(),
|
|
||||||
new BooleanValidator(),
|
|
||||||
new RealValidator( 0.25f, 5f ),
|
|
||||||
new RealValidator( 0.25f, 5f ),
|
|
||||||
|
|
||||||
new BooleanValidator(),
|
MakeValidators();
|
||||||
new BooleanValidator(),
|
|
||||||
new RealValidator( 0.25f, 5f ),
|
|
||||||
new IntegerValidator( 1, 30 ),
|
|
||||||
new BooleanValidator(),
|
|
||||||
};
|
|
||||||
okayIndex = buttons.Length - 1;
|
okayIndex = buttons.Length - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonWidget Make( int x, int y, string text, Action<Game, Widget> onClick,
|
|
||||||
Func<Game, string> getter, Action<Game, string> setter ) {
|
|
||||||
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre,
|
|
||||||
Anchor.Centre, titleFont, onClick );
|
|
||||||
widget.GetValue = getter;
|
|
||||||
widget.SetValue = setter;
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandleArialChatFont( Game g, string v ) {
|
void HandleArialChatFont( Game g, string v ) {
|
||||||
g.Drawer2D.UseBitmappedChat = v == "no";
|
g.Drawer2D.UseBitmappedChat = v == "no";
|
||||||
Options.Set( OptionsKey.ArialChatFont, v == "yes" );
|
Options.Set( OptionsKey.ArialChatFont, v == "yes" );
|
||||||
@ -110,5 +91,20 @@ namespace ClassicalSharp {
|
|||||||
g.RefreshHud();
|
g.RefreshHud();
|
||||||
Recreate();
|
Recreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MakeValidators() {
|
||||||
|
validators = new MenuInputValidator[] {
|
||||||
|
new BooleanValidator(),
|
||||||
|
new BooleanValidator(),
|
||||||
|
new RealValidator( 0.25f, 5f ),
|
||||||
|
new RealValidator( 0.25f, 5f ),
|
||||||
|
|
||||||
|
new BooleanValidator(),
|
||||||
|
new BooleanValidator(),
|
||||||
|
new RealValidator( 0.25f, 5f ),
|
||||||
|
new IntegerValidator( 1, 30 ),
|
||||||
|
new BooleanValidator(),
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -68,6 +68,32 @@ namespace ClassicalSharp {
|
|||||||
null,
|
null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MakeValidators();
|
||||||
|
MakeDescriptions();
|
||||||
|
okayIndex = buttons.Length - 1;
|
||||||
|
game.Events.HackPermissionsChanged += CheckHacksAllowed;
|
||||||
|
CheckHacksAllowed( null, null );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckHacksAllowed( object sender, EventArgs e ) {
|
||||||
|
for( int i = 0; i < buttons.Length; i++ ) {
|
||||||
|
if( buttons[i] == null ) continue;
|
||||||
|
buttons[i].Disabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalPlayer p = game.LocalPlayer;
|
||||||
|
bool noGlobalHacks = !p.CanAnyHacks || !p.HacksEnabled;
|
||||||
|
buttons[3].Disabled = noGlobalHacks || !p.CanSpeed;
|
||||||
|
buttons[4].Disabled = noGlobalHacks || !p.CanSpeed;
|
||||||
|
buttons[6].Disabled = noGlobalHacks || !p.CanPushbackBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Dispose() {
|
||||||
|
base.Dispose();
|
||||||
|
game.Events.HackPermissionsChanged -= CheckHacksAllowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MakeValidators() {
|
||||||
validators = new MenuInputValidator[] {
|
validators = new MenuInputValidator[] {
|
||||||
new BooleanValidator(),
|
new BooleanValidator(),
|
||||||
new RealValidator( 0.1f, 50 ),
|
new RealValidator( 0.1f, 50 ),
|
||||||
@ -80,35 +106,20 @@ namespace ClassicalSharp {
|
|||||||
new BooleanValidator(),
|
new BooleanValidator(),
|
||||||
new IntegerValidator( 1, 150 ),
|
new IntegerValidator( 1, 150 ),
|
||||||
};
|
};
|
||||||
okayIndex = buttons.Length - 1;
|
|
||||||
game.Events.HackPermissionsChanged += CheckHacksAllowed;
|
|
||||||
CheckHacksAllowed( null, null );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckHacksAllowed( object sender, EventArgs e ) {
|
void MakeDescriptions() {
|
||||||
for( int i = 0; i < buttons.Length; i++ ) {
|
descriptions = new string[buttons.Length][];
|
||||||
if( buttons[i] == null ) continue;
|
descriptions[5] = new [] {
|
||||||
buttons[i].Disabled = false;
|
"&fIf breaking liquids is set to true, then water/lava",
|
||||||
}
|
"&fcan be deleted the same way as any regular block.",
|
||||||
LocalPlayer p = game.LocalPlayer;
|
};
|
||||||
bool noGlobalHacks = !p.CanAnyHacks || !p.HacksEnabled;
|
descriptions[6] = new [] {
|
||||||
buttons[3].Disabled = noGlobalHacks || !p.CanSpeed;
|
"&aDetermines whether pushback placing mode is active or not.",
|
||||||
buttons[4].Disabled = noGlobalHacks || !p.CanSpeed;
|
"&fWhen this is active, placing blocks that intersect your own position",
|
||||||
buttons[6].Disabled = noGlobalHacks || !p.CanPushbackBlocks;
|
"&f cause the block to be placed, and you to be moved out of the way.",
|
||||||
}
|
"&fThis is mainly useful for quick pillaring/towering.",
|
||||||
|
};
|
||||||
ButtonWidget Make( int x, int y, string text, Action<Game, Widget> onClick,
|
|
||||||
Func<Game, string> getter, Action<Game, string> setter ) {
|
|
||||||
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre,
|
|
||||||
Anchor.Centre, titleFont, onClick );
|
|
||||||
widget.GetValue = getter;
|
|
||||||
widget.SetValue = setter;
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Dispose() {
|
|
||||||
base.Dispose();
|
|
||||||
game.Events.HackPermissionsChanged -= CheckHacksAllowed;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,6 +13,7 @@ namespace ClassicalSharp {
|
|||||||
protected MenuInputValidator[] validators;
|
protected MenuInputValidator[] validators;
|
||||||
protected TextWidget descWidget;
|
protected TextWidget descWidget;
|
||||||
protected int okayIndex;
|
protected int okayIndex;
|
||||||
|
protected string[][] descriptions;
|
||||||
|
|
||||||
public override void Render( double delta ) {
|
public override void Render( double delta ) {
|
||||||
RenderMenuBounds();
|
RenderMenuBounds();
|
||||||
@ -149,5 +150,14 @@ namespace ClassicalSharp {
|
|||||||
protected virtual void InputOpened() { }
|
protected virtual void InputOpened() { }
|
||||||
|
|
||||||
protected virtual void InputClosed() { }
|
protected virtual void InputClosed() { }
|
||||||
|
|
||||||
|
protected virtual ButtonWidget Make( int x, int y, string text, Action<Game, Widget> onClick,
|
||||||
|
Func<Game, string> getter, Action<Game, string> setter ) {
|
||||||
|
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre,
|
||||||
|
Anchor.Centre, titleFont, onClick );
|
||||||
|
widget.GetValue = getter;
|
||||||
|
widget.SetValue = setter;
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,9 +4,9 @@ using ClassicalSharp.Singleplayer;
|
|||||||
|
|
||||||
namespace ClassicalSharp {
|
namespace ClassicalSharp {
|
||||||
|
|
||||||
public class OptionsScreen : MenuInputScreen {
|
public class MiscOptionsScreen : MenuInputScreen {
|
||||||
|
|
||||||
public OptionsScreen( Game game ) : base( game ) {
|
public MiscOptionsScreen( Game game ) : base( game ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
@ -82,7 +82,13 @@ namespace ClassicalSharp {
|
|||||||
};
|
};
|
||||||
buttons[2].Metadata = typeof(NameMode);
|
buttons[2].Metadata = typeof(NameMode);
|
||||||
buttons[3].Metadata = typeof(FpsLimitMethod);
|
buttons[3].Metadata = typeof(FpsLimitMethod);
|
||||||
|
MakeValidators();
|
||||||
|
MakeDescriptions();
|
||||||
|
okayIndex = buttons.Length - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MakeValidators() {
|
||||||
|
INetworkProcessor network = game.Network;
|
||||||
validators = new MenuInputValidator[] {
|
validators = new MenuInputValidator[] {
|
||||||
network.IsSinglePlayer ? new RealValidator( 1, 1024 ) : null,
|
network.IsSinglePlayer ? new RealValidator( 1, 1024 ) : null,
|
||||||
new BooleanValidator(),
|
new BooleanValidator(),
|
||||||
@ -97,16 +103,29 @@ namespace ClassicalSharp {
|
|||||||
new BooleanValidator(),
|
new BooleanValidator(),
|
||||||
new IntegerValidator( 1, 100 ),
|
new IntegerValidator( 1, 100 ),
|
||||||
};
|
};
|
||||||
okayIndex = buttons.Length - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonWidget Make( int x, int y, string text, Action<Game, Widget> onClick,
|
void MakeDescriptions() {
|
||||||
Func<Game, string> getter, Action<Game, string> setter ) {
|
descriptions = new string[buttons.Length][];
|
||||||
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre,
|
descriptions[0] = new[] {
|
||||||
Anchor.Centre, titleFont, onClick );
|
"&aControls how far away you can place/delete blocks.",
|
||||||
widget.GetValue = getter;
|
"&eThe default click distance is 5 blocks.",
|
||||||
widget.SetValue = setter;
|
};
|
||||||
return widget;
|
descriptions[2] = new[] {
|
||||||
|
"&aDetermines how the names of other players/entities are drawn.",
|
||||||
|
"&eNoNames: &fNo player names are drawn.",
|
||||||
|
"&eHoveredOnly: &fThe name of the player you are looking at is drawn without depth testing.",
|
||||||
|
"&eAllNames: &fAll names are drawn without depth testing.",
|
||||||
|
"&eAllNamesAndHovered: &fThe name of the player you are looking at is drawn without depth testing,",
|
||||||
|
"&f all other player names are drawn with depth testing.",
|
||||||
|
};
|
||||||
|
descriptions[3] = new[] {
|
||||||
|
"&aDetermines the method used to limit the number of frames rendered each second.",
|
||||||
|
"&eVSync: &fNumber of frames rendered is equal to the refresh rate of the monitor.",
|
||||||
|
"&e30/60/120 FPS: &f30/60/120 frames are rendered at most each second.",
|
||||||
|
"&eNoLimit: &Renders as many frames as the GPU can handle each second.",
|
||||||
|
"&cUsing NoLimit mode is strongly discouraged for general usage.",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -81,14 +81,5 @@ namespace ClassicalSharp {
|
|||||||
base.Dispose();
|
base.Dispose();
|
||||||
infoWidget.Dispose();
|
infoWidget.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonWidget Make( int x, int y, string text, Action<Game, Widget> onClick,
|
|
||||||
Func<Game, string> getter, Action<Game, string> setter ) {
|
|
||||||
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre,
|
|
||||||
Anchor.Centre, titleFont, onClick );
|
|
||||||
widget.GetValue = getter;
|
|
||||||
widget.SetValue = setter;
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,7 +22,7 @@ namespace ClassicalSharp {
|
|||||||
buttons = new ButtonWidget[] {
|
buttons = new ButtonWidget[] {
|
||||||
// Column 1
|
// Column 1
|
||||||
Make( -140, -150, "Misc options", Anchor.Centre,
|
Make( -140, -150, "Misc options", Anchor.Centre,
|
||||||
(g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ),
|
(g, w) => g.SetNewScreen( new MiscOptionsScreen( g ) ) ),
|
||||||
Make( -140, -100, "Gui options", Anchor.Centre,
|
Make( -140, -100, "Gui options", Anchor.Centre,
|
||||||
(g, w) => g.SetNewScreen( new GuiOptionsScreen( g ) ) ),
|
(g, w) => g.SetNewScreen( new GuiOptionsScreen( g ) ) ),
|
||||||
Make( -140, -50, "Hacks settings", Anchor.Centre,
|
Make( -140, -50, "Hacks settings", Anchor.Centre,
|
||||||
|
@ -31,8 +31,6 @@ namespace ClassicalSharp {
|
|||||||
int defaultHeight;
|
int defaultHeight;
|
||||||
readonly Font font;
|
readonly Font font;
|
||||||
|
|
||||||
public string[] Description;
|
|
||||||
|
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
DrawTextArgs args = new DrawTextArgs( "I", font, true );
|
DrawTextArgs args = new DrawTextArgs( "I", font, true );
|
||||||
defaultHeight = game.Drawer2D.MeasureSize( ref args ).Height;
|
defaultHeight = game.Drawer2D.MeasureSize( ref args ).Height;
|
||||||
|
@ -105,7 +105,7 @@
|
|||||||
<Compile Include="2D\Screens\Menu\MenuScreen.cs" />
|
<Compile Include="2D\Screens\Menu\MenuScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\NostalgiaScreen.cs" />
|
<Compile Include="2D\Screens\Menu\NostalgiaScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\PauseScreen.cs" />
|
<Compile Include="2D\Screens\Menu\PauseScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\OptionsScreen.cs" />
|
<Compile Include="2D\Screens\Menu\MiscOptionsScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\SaveLevelScreen.cs" />
|
<Compile Include="2D\Screens\Menu\SaveLevelScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\TexturePackScreen.cs" />
|
<Compile Include="2D\Screens\Menu\TexturePackScreen.cs" />
|
||||||
<Compile Include="2D\Screens\HudScreen.cs" />
|
<Compile Include="2D\Screens\HudScreen.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user