예제 #1
0
        protected void OnInputClick(Game game, Widget widget)
        {
            ButtonWidget button = (ButtonWidget)widget;

            activeI = IndexWidget(button);
            DisposeExtendedHelp();

            DisposeInput();
            MenuInputValidator validator = validators[activeI];

            input = MenuInputWidget.Create(game, 400, 30, button.GetValue(game), textFont, validator)
                    .SetLocation(Anchor.Centre, Anchor.Centre, 0, 110);
            input.ShowCaret = true;

            widgets[widgets.Length - 1] = input;
            widgets[widgets.Length - 2] = ButtonWidget.Create(game, 40, "OK", titleFont, OKButtonClick)
                                          .SetLocation(Anchor.Centre, Anchor.Centre, 240, 110);
            widgets[widgets.Length - 3] = ButtonWidget.Create(game, 200, "Default value", titleFont, DefaultButtonClick)
                                          .SetLocation(Anchor.Centre, Anchor.Centre, 0, 150);
        }
예제 #2
0
        protected void OnButtonClick(Game game, Widget widget)
        {
            ButtonWidget button = widget as ButtonWidget;

            if (button == null)
            {
                return;
            }
            DisposeExtendedHelp();

            int index = IndexOfWidget(button);
            MenuInputValidator validator = validators[index];

            if (validator is BooleanValidator)
            {
                string value = button.GetValue(game);
                SetButtonValue(button, value == "ON" ? "OFF" : "ON");
                UpdateDescription(button);
                return;
            }
            else if (validator is EnumValidator)
            {
                Type type = ((EnumValidator)validator).EnumType;
                HandleEnumOption(button, type);
                return;
            }

            activeButton = button;
            InputClosed();

            input = MenuInputWidget.Create(game, 400, 30, button.GetValue(game), textFont, validator)
                    .SetLocation(Anchor.Centre, Anchor.Centre, 0, 110);
            input.ShowCaret = true;

            widgets[widgets.Length - 2] = input;
            widgets[widgets.Length - 1] = ButtonWidget.Create(game, 40, "OK", titleFont, OnOKButtonClick)
                                          .SetLocation(Anchor.Centre, Anchor.Centre, 240, 110);

            InputOpened();
            UpdateDescription(activeButton);
        }