ClassiCube/ClassicalSharp/2D/Screens/Menu/EnvSettingsScreen.cs
UnknownShadow200 a13d3147bc Use gui.png.
2015-11-30 14:16:48 +11:00

81 lines
2.9 KiB
C#

using System;
using System.Drawing;
using ClassicalSharp.Renderers;
namespace ClassicalSharp {
public class EnvSettingsScreen : MenuInputScreen {
public EnvSettingsScreen( Game game ) : base( game ) {
}
public override void Init() {
base.Init();
buttons = new ButtonWidget[] {
Make( -140, -150, "Clouds colour", Anchor.Centre, OnWidgetClick,
g => g.Map.CloudsCol.ToRGBHexString(),
(g, v) => g.Map.SetCloudsColour( FastColour.Parse( v ) ) ),
Make( -140, -100, "Sky colour", Anchor.Centre, OnWidgetClick,
g => g.Map.SkyCol.ToRGBHexString(),
(g, v) => g.Map.SetSkyColour( FastColour.Parse( v ) ) ),
Make( -140, -50, "Fog colour", Anchor.Centre, OnWidgetClick,
g => g.Map.FogCol.ToRGBHexString(),
(g, v) => g.Map.SetFogColour( FastColour.Parse( v ) ) ),
Make( -140, 0, "Clouds speed", Anchor.Centre, OnWidgetClick,
g => g.Map.CloudsSpeed.ToString(),
(g, v) => g.Map.SetCloudsSpeed( Single.Parse( v ) ) ),
Make( -140, 50, "Clouds height", Anchor.Centre, OnWidgetClick,
g => g.Map.CloudHeight.ToString(),
(g, v) => g.Map.SetCloudsLevel( Int32.Parse( v ) ) ),
Make( 140, -150, "Sunlight colour", Anchor.Centre, OnWidgetClick,
g => g.Map.Sunlight.ToRGBHexString(),
(g, v) => g.Map.SetSunlight( FastColour.Parse( v ) ) ),
Make( 140, -100, "Shadow colour", Anchor.Centre, OnWidgetClick,
g => g.Map.Shadowlight.ToRGBHexString(),
(g, v) => g.Map.SetShadowlight( FastColour.Parse( v ) ) ),
Make( 140, -50, "Weather", Anchor.Centre, OnWidgetClick,
g => g.Map.Weather.ToString(),
(g, v) => g.Map.SetWeather( (Weather)Enum.Parse( typeof(Weather), v ) ) ),
Make( 140, 0, "Water level", Anchor.Centre, OnWidgetClick,
g => g.Map.EdgeHeight.ToString(),
(g, v) => g.Map.SetEdgeLevel( Int32.Parse( v ) ) ),
MakeBack( false, titleFont,
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
null,
};
buttons[7].Metadata = typeof(Weather);
validators = new MenuInputValidator[] {
new HexColourValidator(),
new HexColourValidator(),
new HexColourValidator(),
new RealValidator( 0, 1000 ),
new IntegerValidator( -10000, 10000 ),
new HexColourValidator(),
new HexColourValidator(),
new EnumValidator(),
new IntegerValidator( -2048, 2048 ),
};
okayIndex = buttons.Length - 1;
}
ButtonWidget Make( int x, int y, string text, Anchor vDocking, Action<Game, Widget> onClick,
Func<Game, string> getter, Action<Game, string> setter ) {
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text,
Anchor.Centre, vDocking, titleFont, onClick );
widget.GetValue = getter;
widget.SetValue = setter;
return widget;
}
}
}