Exemplo n.º 1
0
        public override bool HandlesKeyDown( Key key )
        {
            if( key == Key.Escape ) {
                game.SetNewScreen( new NormalScreen( game ) );
            } else if( widget != null ) {
                int index = Array.IndexOf<ButtonWidget>( buttons, widget );
                KeyBinding mapping = (KeyBinding)index;
                KeyMap map = game.InputHandler.Keys;
                Key oldKey = map[mapping];
                string reason;

                if( !map.IsKeyOkay( oldKey, key, out reason ) ) {
                    const string format = "&eFailed to change mapping \"{0}\". &c({1})";
                    statusWidget.SetText( String.Format( format, descriptions[index], reason ) );
                } else {
                    const string format = "&eChanged mapping \"{0}\" from &7{1} &eto &7{2}&e.";
                    statusWidget.SetText( String.Format( format, descriptions[index], oldKey, key ) );
                    string text = descriptions[index] + " : " + keyNames[(int)key];

                    widget.SetText( text );
                    map[mapping] = key;
                }
                widget = null;
            }
            return true;
        }
Exemplo n.º 2
0
        public override void Init()
        {
            titleFont = new Font( "Arial", 16, FontStyle.Bold );
            buttons = new ButtonWidget[] {
                // Column 1
                Make( -140, -100, "Options", Anchor.Centre,
                     (g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ),
                Make( -140, -50, "Environment settings", Anchor.Centre,
                     (g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ),

                Make( -140, 0, "Hotkeys", Anchor.Centre,
                     (g, w) => g.SetNewScreen( new HotkeyScreen( g ) ) ),
                Make( -140, 50, "Key bindings", Anchor.Centre,
                     (g, w) => g.SetNewScreen( new KeyBindingsScreen( g ) ) ),
                // Column 2
                Make( 140, -100, "Save level", Anchor.Centre,
                     (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ),
                !game.Network.IsSinglePlayer ? null :
                    Make( 140, -50, "Load level", Anchor.Centre,
                         (g, w) => g.SetNewScreen( new LoadLevelScreen( g ) ) ),
                // TODO: singleplayer Generate level screen
                Make( 140, 50, "Select texture pack", Anchor.Centre,
                     (g, w) => g.SetNewScreen( new TexturePackScreen( g ) ) ),
                // Other
                Make( 0, 55, "Back to game", Anchor.BottomOrRight,
                     (g, w) => g.SetNewScreen( new NormalScreen( g ) ) ),
                Make( 0, 5, "Quit game", Anchor.BottomOrRight, (g, w) => g.Exit() ),
            };
        }
Exemplo n.º 3
0
 public override void Init()
 {
     titleFont = new Font( "Arial", 16, FontStyle.Bold );
     if( game.Network.IsSinglePlayer ) {
         buttons = new ButtonWidget[] {
             Make( -140, -50, "Options", Anchor.Centre, (g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ),
             Make( -140, 0, "Environment settings", Anchor.Centre, (g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ),
             Make( -140, 50, "Select texture pack", Anchor.Centre, (g, w) => g.SetNewScreen( new TexturePackScreen( g ) ) ),
             Make( 140, -50, "Save level", Anchor.Centre, (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ),
             Make( 140, 0, "Load level", Anchor.Centre, (g, w) => g.SetNewScreen( new LoadLevelScreen( g ) ) ),
             // TODO: singleplayer Make( 0, 50, "Load/Save/Gen level", Docking.Centre, (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ),
             Make( 0, 55, "Back to game", Anchor.BottomOrRight, (g, w) => g.SetNewScreen( new NormalScreen( g ) ) ),
             Make( 0, 5, "Quit game", Anchor.BottomOrRight, (g, w) => g.Exit() ),
         };
     } else {
         buttons = new ButtonWidget[] {
             Make( 0, -100, "Options", Anchor.Centre, (g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ),
             Make( 0, -50, "Environment settings", Anchor.Centre, (g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ),
             Make( 0, 0, "Select texture pack", Anchor.Centre, (g, w) => g.SetNewScreen( new TexturePackScreen( g ) ) ),
             Make( 0, 50, "Save level", Anchor.Centre, (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ),
             Make( 0, 55, "Back to game", Anchor.BottomOrRight, (g, w) => g.SetNewScreen( new NormalScreen( g ) ) ),
             Make( 0, 5, "Quit game", Anchor.BottomOrRight, (g, w) => g.Exit() ),
         };
     }
 }
        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 => ((int)g.Map.Weather).ToString(),
                     (g, v) => g.Map.SetWeather( (Weather)Int32.Parse( v ) ) ),

                Make( 140, 0, "Water level", Anchor.Centre, OnWidgetClick,
                     g => g.Map.EdgeHeight.ToString(),
                     (g, v) => g.Map.SetEdgeLevel( Int32.Parse( v ) ) ),

                Make( 0, 5, "Back to menu", Anchor.BottomOrRight,
                     (g, w) => g.SetNewScreen( new PauseScreen( g ) ), null, null ),
                null,
            };

            validators = new MenuInputValidator[] {
                new HexColourValidator(),
                new HexColourValidator(),
                new HexColourValidator(),
                new RealValidator( 0, 1000 ),
                new IntegerValidator( -10000, 10000 ),
                new HexColourValidator(),
                new HexColourValidator(),
                new IntegerValidator( 0, 2 ),
                new IntegerValidator( -2048, 2048 ),
            };
            okayIndex = buttons.Length - 1;
        }
Exemplo n.º 5
0
 protected override void TextButtonClick( Game game, ButtonWidget widget )
 {
     string path = widget.Text;
     if( File.Exists( path ) ) {
         TexturePackExtractor extractor = new TexturePackExtractor();
         extractor.Extract( path, game );
     }
 }
Exemplo n.º 6
0
 public static ButtonWidget Create( Game game, int x, int y, int width, int height, string text, Anchor horizontal,
     Anchor vertical, Font font, Action<Game, Widget> onClick)
 {
     ButtonWidget widget = new ButtonWidget( game, font );
     widget.Init();
     widget.HorizontalAnchor = horizontal;
     widget.VerticalAnchor = vertical;
     widget.XOffset = x; widget.YOffset = y;
     widget.DesiredMaxWidth = width; widget.DesiredMaxHeight = height;
     widget.SetText( text );
     widget.OnClick = onClick;
     return widget;
 }
Exemplo n.º 7
0
        public override void Init()
        {
            titleFont = new Font( "Arial", 16, FontStyle.Bold );
            regularFont = new Font( "Arial", 14, FontStyle.Regular );

            buttons = new ButtonWidget[] {
                ButtonWidget.Create( game, -60, 30, 60, 20, "Yes", Anchor.Centre,
                                    Anchor.Centre, titleFont, OnYesClick ),
                ButtonWidget.Create( game, 60, 30, 60, 20, "No", Anchor.Centre,
                                    Anchor.Centre, titleFont, OnNoClick ),
            };
            SetText( title, body );
        }
Exemplo n.º 8
0
 public override void Init()
 {
     titleFont = new Font( "Arial", 16, FontStyle.Bold );
     buttons = new ButtonWidget[] {
         Make( 0, -100, "Options", Docking.Centre, (g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ),
         Make( 0, -50, "Environment settings", Docking.Centre, (g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ),
         Make( 0, 0, "Key mappings", Docking.Centre, (g, w) => g.SetNewScreen( new KeyMappingsScreen( g ) ) ),
         Make( 0, 50, "Save level", Docking.Centre, (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ),
         // TODO: singleplayer Make( 0, 50, "Load/Save/Gen level", Docking.Centre, (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ),
         Make( 0, 55, "Back to game", Docking.BottomOrRight, (g, w) => g.SetNewScreen( new NormalScreen( g ) ) ),
         Make( 0, 5, "Quit game", Docking.BottomOrRight, (g, w) => g.Exit() ),
     };
 }
Exemplo n.º 9
0
        public override void Init()
        {
            if( keyNames == null )
                keyNames = Enum.GetNames( typeof( Key ) );
            keyFont = new Font( "Arial", 14, FontStyle.Bold );
            regularFont = new Font( "Arial", 14, FontStyle.Italic );
            titleFont = new Font( "Arial", 16, FontStyle.Bold );
            buttons = new ButtonWidget[descriptions.Length + 1];

            MakeKeys( 0, 11, -140 );
            MakeKeys( 11, 11, 140 );
            buttons[index] = Make( 0, 5, "Back to menu", Anchor.BottomOrRight, (g, w) => g.SetNewScreen( new OptionsScreen( g ) ) );
            statusWidget = TextWidget.Create( game, 0, 150, "", Anchor.Centre, Anchor.Centre, regularFont );
        }
Exemplo n.º 10
0
        public override void Init()
        {
            base.Init();
            INetworkProcessor network = game.Network;

            buttons = new ButtonWidget[] {
                Make( -140, -50, "Show FPS", Anchor.Centre, OnWidgetClick,
                     g => g.ShowFPS ? "yes" : "no",
                     (g, v) => g.ShowFPS = v == "yes" ),

                Make( -140, 0, "View distance", Anchor.Centre, OnWidgetClick,
                     g => g.ViewDistance.ToString(),
                     (g, v) => g.SetViewDistance( Int32.Parse( v ) ) ),

                Make( -140, 50, "VSync active", Anchor.Centre, OnWidgetClick,
                     g => g.VSync ? "yes" : "no",
                     (g, v) => g.Graphics.SetVSync( g, v == "yes" ) ),

                Make( 140, -50, "Mouse sensitivity", Anchor.Centre, OnWidgetClick,
                     g => g.MouseSensitivity.ToString(),
                     (g, v) => { g.MouseSensitivity = Int32.Parse( v );
                     		Options.Set( OptionsKey.Sensitivity, v ); } ),

                Make( 140, 0, "Chat font size", Anchor.Centre, OnWidgetClick,
                     g => g.Chat.FontSize.ToString(),
                     (g, v) => { g.Chat.FontSize = Int32.Parse( v );
                     	Options.Set( OptionsKey.FontSize, v ); } ),

                Make( 140, 50, "Key mappings", Anchor.Centre,
                     (g, w) => g.SetNewScreen( new KeyMappingsScreen( g ) ), null, null ),

                !network.IsSinglePlayer ? null :
                    Make( -140, -100, "Singleplayer physics", Anchor.Centre, OnWidgetClick,
                         g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no",
                         (g, v) => ((SinglePlayerServer)network).physics.Enabled = (v == "yes") ),

                Make( 0, 5, "Back to menu", Anchor.BottomOrRight,
                     (g, w) => g.SetNewScreen( new PauseScreen( g ) ), null, null ),
                null,
            };
            validators = new MenuInputValidator[] {
                new BooleanValidator(),
                new IntegerValidator( 16, 4096 ),
                new BooleanValidator(),
                new IntegerValidator( 1, 100 ),
                new IntegerValidator( 6, 30 ),
                network.IsSinglePlayer ? new BooleanValidator() : null,
            };
            okayIndex = buttons.Length - 1;
        }
Exemplo n.º 11
0
 ButtonWidget MakeText(int x, int y, string text)
 {
     return(ButtonWidget.Create(game, x, y, 240, 30, text,
                                Anchor.Centre, Anchor.Centre, textFont, TextButtonClick));
 }
Exemplo n.º 12
0
        void OnWidgetClick( Game game, ButtonWidget widget )
        {
            this.widget = widget;
            int index = Array.IndexOf<ButtonWidget>( buttons, widget );
            statusWidget.Dispose();

            string text = "Press new key binding for " + descriptions[index] + ":";
            statusWidget = TextWidget.Create( game, 0, 150, text, Anchor.Centre, Anchor.Centre, regularFont );
        }
Exemplo n.º 13
0
        protected void OnWidgetClick( Game game, ButtonWidget widget )
        {
            if( widget == buttons[okayIndex] ) {
                ChangeSetting();
                return;
            }

            int index = Array.IndexOf<ButtonWidget>( buttons, widget );
            MenuInputValidator validator = validators[index];
            if( validator is BooleanValidator ) {
                string value = widget.GetValue( game );
                widget.SetValue( game, value == "yes" ? "no" : "yes" );
                UpdateDescription( widget );
                return;
            }

            if( inputWidget != null )
                inputWidget.Dispose();

            targetWidget = selectedWidget;
            inputWidget = MenuInputWidget.Create( game, 0, 150, 400, 25, widget.GetValue( game ),
                                                 Anchor.Centre, Anchor.Centre, regularFont, titleFont,
                                                 hintFont, validator );
            buttons[okayIndex] = ButtonWidget.Create( game, 240, 150, 30, 30, "OK",
                                                     Anchor.Centre, Anchor.Centre, titleFont, OnWidgetClick );
            UpdateDescription( targetWidget );
        }
Exemplo n.º 14
0
        public override void Init()
        {
            base.Init();
            INetworkProcessor network = game.Network;

            buttons = new ButtonWidget[] {
                // Column 1
                !network.IsSinglePlayer ? null :
                Make(-140, -200, "Click distance", OnWidgetClick,
                     g => g.LocalPlayer.ReachDistance.ToString(),
                     (g, v) => g.LocalPlayer.ReachDistance = Single.Parse(v)),

                Make(-140, -150, "Use sound", OnWidgetClick,
                     g => g.UseSound ? "yes" : "no",
                     (g, v) => { g.UseSound = v == "yes";
                                 g.AudioPlayer.SetSound(g.UseSound);
                                 Options.Set(OptionsKey.UseSound, v == "yes"); }),

                Make(-140, -100, "Simple arms anim", OnWidgetClick,
                     g => g.SimpleArmsAnim? "yes" : "no",
                     (g, v) => { g.SimpleArmsAnim = v == "yes";
                                 Options.Set(OptionsKey.SimpleArmsAnim, v == "yes"); }),

                Make(-140, -50, "Names mode", 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); }),

                Make(-140, 0, "FPS limit", OnWidgetClick,
                     g => g.FpsLimit.ToString(),
                     (g, v) => { object raw = Enum.Parse(typeof(FpsLimitMethod), v);
                                 g.SetFpsLimitMethod((FpsLimitMethod)raw);
                                 Options.Set(OptionsKey.FpsLimit, v); }),

                Make(-140, 50, "View distance", OnWidgetClick,
                     g => g.ViewDistance.ToString(),
                     (g, v) => g.SetViewDistance(Int32.Parse(v), true)),

                // Column 2
                !network.IsSinglePlayer ? null :
                Make(140, -200, "Block physics", OnWidgetClick,
                     g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no",
                     (g, v) => {
                    ((SinglePlayerServer)network).physics.Enabled = v == "yes";
                    Options.Set(OptionsKey.SingleplayerPhysics, v == "yes");
                }),

                Make(140, -150, "Use music", OnWidgetClick,
                     g => g.UseMusic ? "yes" : "no",
                     (g, v) => { g.UseMusic = v == "yes";
                                 g.AudioPlayer.SetMusic(g.UseMusic);
                                 Options.Set(OptionsKey.UseMusic, v == "yes"); }),

                Make(140, -100, "View bobbing", OnWidgetClick,
                     g => g.ViewBobbing ? "yes" : "no",
                     (g, v) => { g.ViewBobbing = v == "yes";
                                 Options.Set(OptionsKey.ViewBobbing, v == "yes"); }),

                Make(140, -50, "Auto close launcher", OnWidgetClick,
                     g => Options.GetBool(OptionsKey.AutoCloseLauncher, false) ? "yes" : "no",
                     (g, v) => Options.Set(OptionsKey.AutoCloseLauncher, v == "yes")),

                Make(140, 0, "Invert mouse", OnWidgetClick,
                     g => g.InvertMouse ? "yes" : "no",
                     (g, v) => { g.InvertMouse = v == "yes";
                                 Options.Set(OptionsKey.InvertMouse, v == "yes"); }),

                Make(140, 50, "Mouse sensitivity", OnWidgetClick,
                     g => g.MouseSensitivity.ToString(),
                     (g, v) => { g.MouseSensitivity = Int32.Parse(v);
                                 Options.Set(OptionsKey.Sensitivity, v); }),

                MakeBack(false, titleFont,
                         (g, w) => g.SetNewScreen(new PauseScreen(g))),
                null,
            };
            buttons[3].Metadata = typeof(NameMode);
            buttons[4].Metadata = typeof(FpsLimitMethod);

            validators = new MenuInputValidator[] {
                network.IsSinglePlayer ? new RealValidator(1, 1024) : null,
                new BooleanValidator(),
                new BooleanValidator(),
                new EnumValidator(),
                new EnumValidator(),
                new IntegerValidator(16, 4096),

                network.IsSinglePlayer ? new BooleanValidator() : null,
                new BooleanValidator(),
                new BooleanValidator(),
                new BooleanValidator(),
                new BooleanValidator(),
                new IntegerValidator(1, 100),
            };
            okayIndex = buttons.Length - 1;
        }
Exemplo n.º 15
0
 ButtonWidget Make(int x, int y, string text, int width, int height,
                   Font font, Action <Game, Widget> onClick)
 {
     return(ButtonWidget.Create(game, x, y, width, height, text,
                                Anchor.Centre, Anchor.Centre, font, LeftOnly(onClick)));
 }
Exemplo n.º 16
0
 protected override void TextButtonClick( Game game, ButtonWidget widget )
 {
     string path = widget.Text;
     if( File.Exists( path ) )
         LoadMap( path );
 }
Exemplo n.º 17
0
        void LostFocus()
        {
            if( focusWidget == null ) return;

            if( focusWidget == buttons[8] ) {
                buttons[8].SetText( "Key: " + curHotkey.BaseKey );
            } else if( focusWidget == buttons[9] ) {
                buttons[9].SetText( "Modifiers: " + MakeFlagsString( curHotkey.Flags ) );
            }
            focusWidget = null;
            supressNextPress = false;
        }
Exemplo n.º 18
0
        void FocusKeyDown( Key key )
        {
            if( focusWidget == buttons[8] ) {
                curHotkey.BaseKey = key;
                buttons[8].SetText( "Key: " + curHotkey.BaseKey );
                supressNextPress = true;
            } else if( focusWidget == buttons[9] ) {
                if( key == Key.ControlLeft || key == Key.ControlRight ) curHotkey.Flags |= 1;
                else if( key == Key.ShiftLeft || key == Key.ShiftRight ) curHotkey.Flags |= 2;
                else if( key == Key.AltLeft || key == Key.AltRight ) curHotkey.Flags |= 4;
                else curHotkey.Flags = 0;

                buttons[9].SetText( "Modifiers: " + MakeFlagsString( curHotkey.Flags ) );
                supressNextPress = true;
            }
            focusWidget = null;
        }
Exemplo n.º 19
0
        void DisposeEditingWidgets()
        {
            if( currentAction != null ) {
                currentAction.Dispose();
                currentAction = null;
            }

            for( int i = 8; i < buttons.Length - 1; i++ ) {
                if( buttons[i] != null ) {
                    buttons[i].Dispose();
                    buttons[i] = null;
                }
            }
            focusWidget = null;
        }
Exemplo n.º 20
0
 void BaseKeyClick( Game game, Widget widget )
 {
     focusWidget = buttons[8];
     focusWidget.SetText( "Key: press a key.." );
     supressNextPress = true;
 }
Exemplo n.º 21
0
 ButtonWidget Make(int x, int y, string text, Action <Game, Widget> onClick)
 {
     return(ButtonWidget.Create(game, x, y, 40, 40, text,
                                Anchor.Centre, Anchor.Centre, arrowFont, onClick));
 }
Exemplo n.º 22
0
        public override void Init()
        {
            base.Init();
            INetworkProcessor network = game.Network;

            buttons = new ButtonWidget[] {
                // Column 1
                Make( -140, -100, "Speed multiplier", Anchor.Centre, OnWidgetClick,
                     g => g.LocalPlayer.SpeedMultiplier.ToString(),
                     (g, v) => { g.LocalPlayer.SpeedMultiplier = Int32.Parse( v );
                     	Options.Set( OptionsKey.Speed, v ); } ),

                Make( -140, -50, "Show FPS", Anchor.Centre, OnWidgetClick,
                     g => g.ShowFPS ? "yes" : "no",
                     (g, v) => g.ShowFPS = v == "yes" ),

                Make( -140, 0, "VSync active", Anchor.Centre, OnWidgetClick,
                     g => g.VSync ? "yes" : "no",
                     (g, v) => { g.Graphics.SetVSync( g, v == "yes" );
                     	Options.Set( OptionsKey.VSync, v == "yes" ); } ),

                Make( -140, 50, "View distance", Anchor.Centre, OnWidgetClick,
                     g => g.ViewDistance.ToString(),
                     (g, v) => g.SetViewDistance( Int32.Parse( v ) ) ),
                // Column 2
                Make( 140, -100, "Mouse sensitivity", Anchor.Centre, OnWidgetClick,
                     g => g.MouseSensitivity.ToString(),
                     (g, v) => { g.MouseSensitivity = Int32.Parse( v );
                     	Options.Set( OptionsKey.Sensitivity, v ); } ),

                Make( 140, -50, "Hud scale", Anchor.Centre, OnWidgetClick,
                     g => g.HudScale.ToString(),
                     (g, v) => { g.HudScale = Single.Parse( v );
                     	Options.Set( OptionsKey.HudScale, v );
                     	g.RefreshHud();
                     } ),

                Make( 140, 0, "Chat lines", Anchor.Centre, OnWidgetClick,
                     g => g.ChatLines.ToString(),
                     (g, v) => { g.ChatLines = Int32.Parse( v );
                     	Options.Set( OptionsKey.ChatLines, v );
                     	g.RefreshHud();
                     } ),

                Make( 140, 50, "Arial chat font", Anchor.Centre, OnWidgetClick,
                     g => g.Drawer2D.UseBitmappedChat ? "no" : "yes",
                     (g, v) => {
                     	g.Drawer2D.UseBitmappedChat = v == "no";
                     	Options.Set( OptionsKey.ArialChatFont, v == "yes" );
                     	game.Events.RaiseChatFontChanged();
                     	g.RefreshHud();
                     } ),

                // Extra stuff
                !network.IsSinglePlayer ? null :
                    Make( -140, -200, "Singleplayer physics", Anchor.Centre, OnWidgetClick,
                         g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no",
                         (g, v) => {
                         	((SinglePlayerServer)network).physics.Enabled = v == "yes";
                         	Options.Set( OptionsKey.SingleplayerPhysics, v == "yes" );
                         }),
                Make( 140, -150, "Pushback block placing", Anchor.Centre, OnWidgetClick,
                     g => g.LocalPlayer.PushbackBlockPlacing
                     && g.LocalPlayer.CanPushbackBlocks ? "yes" : "no",
                     (g, v) => {
                     	if( g.LocalPlayer.CanPushbackBlocks)
                     		g.LocalPlayer.PushbackBlockPlacing = v == "yes";
                     }),

                Make( -140, -150, "Show hover names", Anchor.Centre, OnWidgetClick,
                     g => g.Players.ShowHoveredNames ? "yes" : "no",
                     (g, v) => {
                     	g.Players.ShowHoveredNames = v == "yes";
                     	Options.Set( OptionsKey.ShowHoveredNames, v == "yes" );
                     }),

                Make( 0, 5, "Back to menu", Anchor.BottomOrRight,
                     (g, w) => g.SetNewScreen( new PauseScreen( g ) ), null, null ),
                null,
            };
            validators = new MenuInputValidator[] {
                new IntegerValidator( 1, 50 ),
                new BooleanValidator(),
                new BooleanValidator(),
                new IntegerValidator( 16, 4096 ),

                new IntegerValidator( 1, 100 ),
                new RealValidator( 0.5f, 2f ),
                new IntegerValidator( 1, 30 ),
                new BooleanValidator(),

                network.IsSinglePlayer ? new BooleanValidator() : null,
                new BooleanValidator(),
                new BooleanValidator(),
            };
            okayIndex = buttons.Length - 1;
        }
Exemplo n.º 23
0
 protected virtual void WidgetSelected( ButtonWidget widget )
 {
 }
Exemplo n.º 24
0
 void ModifiersClick(Game game, Widget widget)
 {
     focusWidget = buttons[9];
     focusWidget.SetText("Modifiers: press a key..");
     supressNextPress = true;
 }
Exemplo n.º 25
0
 protected abstract void TextButtonClick( Game game, ButtonWidget widget );
Exemplo n.º 26
0
        protected override void WidgetSelected( ButtonWidget widget )
        {
            if( selectedWidget == widget || widget == null ||
               widget == buttons[buttons.Length - 2] ) return;

            selectedWidget = widget;
            if( targetWidget != null ) return;
            UpdateDescription( selectedWidget );
        }
Exemplo n.º 27
0
 void ModifiersClick( Game game, Widget widget )
 {
     focusWidget = buttons[9];
     focusWidget.SetText( "Modifiers: press a key.." );
     supressNextPress = true;
 }
Exemplo n.º 28
0
        public override void Init()
        {
            base.Init();
            INetworkProcessor network = game.Network;

            buttons = new ButtonWidget[] {
                // Column 1
                Make(-140, -100, "Hacks enabled", OnWidgetClick,
                     g => g.LocalPlayer.HacksEnabled ? "yes" : "no",
                     (g, v) => { g.LocalPlayer.HacksEnabled = v == "yes";
                                 Options.Set(OptionsKey.HacksEnabled, v == "yes");
                                 g.LocalPlayer.CheckHacksConsistency(); }),

                Make(-140, -50, "Speed multiplier", OnWidgetClick,
                     g => g.LocalPlayer.SpeedMultiplier.ToString(),
                     (g, v) => { g.LocalPlayer.SpeedMultiplier = Single.Parse(v);
                                 Options.Set(OptionsKey.Speed, v); }),

                Make(-140, 0, "Camera clipping", OnWidgetClick,
                     g => g.CameraClipping ? "yes" : "no",
                     (g, v) => { g.CameraClipping = v == "yes";
                                 Options.Set(OptionsKey.CameraClipping, v == "yes"); }),

                Make(-140, 50, "Jump height", OnWidgetClick,
                     g => g.LocalPlayer.JumpHeight.ToString(),
                     (g, v) => g.LocalPlayer.CalculateJumpVelocity(Single.Parse(v))),

                // Column 2
                Make(140, -100, "Liquids breakable", OnWidgetClick,
                     g => g.LiquidsBreakable ? "yes" : "no",
                     (g, v) => { g.LiquidsBreakable = v == "yes";
                                 Options.Set(OptionsKey.LiquidsBreakable, v == "yes"); }),

                Make(140, -50, "Pushback placing", OnWidgetClick,
                     g => g.LocalPlayer.PushbackPlacing ? "yes" : "no",
                     (g, v) => { g.LocalPlayer.PushbackPlacing = v == "yes";
                                 Options.Set(OptionsKey.PushbackPlacing, v == "yes"); }),

                Make(140, 0, "Noclip slide", OnWidgetClick,
                     g => g.LocalPlayer.NoclipSlide ? "yes" : "no",
                     (g, v) => { g.LocalPlayer.NoclipSlide = v == "yes";
                                 Options.Set(OptionsKey.NoclipSlide, v == "yes"); }),

                Make(140, 50, "Field of view", OnWidgetClick,
                     g => g.FieldOfView.ToString(),
                     (g, v) => { g.FieldOfView = Int32.Parse(v);
                                 Options.Set(OptionsKey.FieldOfView, v);
                                 g.UpdateProjection(); }),

                MakeBack(false, titleFont,
                         (g, w) => g.SetNewScreen(new PauseScreen(g))),
                null,
            };

            validators = new MenuInputValidator[] {
                new BooleanValidator(),
                new RealValidator(0.1f, 50),
                new BooleanValidator(),
                new RealValidator(0.1f, 1024f),

                new BooleanValidator(),
                new BooleanValidator(),
                new BooleanValidator(),
                new IntegerValidator(1, 150),
            };
            okayIndex = buttons.Length - 1;
            game.Events.HackPermissionsChanged += CheckHacksAllowed;
            CheckHacksAllowed(null, null);
        }
Exemplo n.º 29
0
        public override void Init()
        {
            base.Init();

            buttons = new ButtonWidget[] {
                Make( -140, -150, "Clouds colour", Docking.Centre, OnWidgetClick,
                     g => g.Map.CloudsCol.ToRGBHexString(),
                     (g, v) => g.Map.SetCloudsColour( FastColour.Parse( v ) ) ),

                Make( -140, -100, "Sky colour", Docking.Centre, OnWidgetClick,
                     g => g.Map.SkyCol.ToRGBHexString(),
                     (g, v) => g.Map.SetSkyColour( FastColour.Parse( v ) ) ),

                Make( -140, -50, "Fog colour", Docking.Centre, OnWidgetClick,
                     g => g.Map.FogCol.ToRGBHexString(),
                     (g, v) => g.Map.SetFogColour( FastColour.Parse( v ) ) ),

                Make( -140, 0, "Clouds speed", Docking.Centre, OnWidgetClick,
                     g => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer;
                     	return env == null ? "(not active)" : env.CloudsSpeed.ToString(); },
                     (g, v) => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer;
                     	if( env != null )
                     		env.CloudsSpeed = Single.Parse( v ); } ),

                Make( -140, 50, "Clouds offset", Docking.Centre, OnWidgetClick,
                     g => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer;
                     	return env == null ? "(not active)" : env.CloudsOffset.ToString(); },
                     (g, v) => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer;
                     	if( env != null )
                     		env.SetCloudsOffset( Int32.Parse( v ) ); } ),

                Make( 140, -150, "Sunlight colour", Docking.Centre, OnWidgetClick,
                     g => g.Map.Sunlight.ToRGBHexString(),
                     (g, v) => g.Map.SetSunlight( FastColour.Parse( v ) ) ),

                Make( 140, -100, "Shadow colour", Docking.Centre, OnWidgetClick,
                     g => g.Map.Shadowlight.ToRGBHexString(),
                     (g, v) => g.Map.SetShadowlight( FastColour.Parse( v ) ) ),

                Make( 140, -50, "Weather", Docking.Centre, OnWidgetClick,
                     g => ((int)g.Map.Weather).ToString(),
                     (g, v) => g.Map.SetWeather( (Weather)Int32.Parse( v ) ) ),

                Make( 140, 0, "Water level", Docking.Centre, OnWidgetClick,
                     g => g.Map.WaterHeight.ToString(),
                     (g, v) => g.Map.SetWaterLevel( Int32.Parse( v ) ) ),

                Make( 0, 5, "Back to menu", Docking.BottomOrRight,
                     (g, w) => g.SetNewScreen( new PauseScreen( g ) ), null, null ),
                null,
            };

            validators = new MenuInputValidator[] {
                new HexColourValidator(),
                new HexColourValidator(),
                new HexColourValidator(),
                new RealValidator( 0, 1000 ),
                new IntegerValidator( -1000, 1000 ),
                new HexColourValidator(),
                new HexColourValidator(),
                new IntegerValidator( 0, 2 ),
                new IntegerValidator( -2048, 2048 ),
            };
            okayIndex = buttons.Length - 1;
        }
Exemplo n.º 30
0
        protected void UpdateDescription( ButtonWidget widget )
        {
            if( descWidget != null )
                descWidget.Dispose();
            if( widget.GetValue == null ) return;

            string text = widget.Text + ": " + widget.GetValue( game );
            descWidget = TextWidget.Create( game, 0, 100, text, Anchor.Centre, Anchor.Centre, regularFont );
        }
Exemplo n.º 31
0
        void OkButtonClick( Game game, ButtonWidget widget )
        {
            string text = inputWidget.GetText();
            if( text.Length == 0 ) {
                MakeDescWidget( "Please enter a filename" );
                return;
            }
            text = Path.ChangeExtension( text, ".cw" );

            if( File.Exists( text ) ) {
                MakeDescWidget( "&eFilename already exists" );
            } else {
                // NOTE: We don't immediately save here, because otherwise the 'saving...'
                // will not be rendered in time because saving is done on the main thread.
                MakeDescWidget( "Saving.." );
                textPath = text;
            }
        }
Exemplo n.º 32
0
 void BaseKeyClick(Game game, Widget widget)
 {
     focusWidget = buttons[8];
     focusWidget.SetText("Key: press a key..");
     supressNextPress = true;
 }