protected void OnWidgetClick(Game game, Widget widget, MouseButton mouseBtn) { ButtonWidget button = widget as ButtonWidget; if (mouseBtn != MouseButton.Left) { return; } if (widget == widgets[widgets.Length - 1]) { ChangeSetting(); return; } if (button == null) { return; } DisposeExtendedHelp(); int index = Array.IndexOf <Widget>(widgets, button); MenuInputValidator validator = validators[index]; if (validator is BooleanValidator) { string value = button.GetValue(game); button.SetValue(game, value == "yes" ? "no" : "yes"); UpdateDescription(button); return; } else if (validator is EnumValidator) { Type type = ((EnumValidator)validator).EnumType; HandleEnumOption(button, type); return; } if (inputWidget != null) { inputWidget.Dispose(); } targetWidget = selectedWidget; inputWidget = MenuInputWidget.Create(game, 0, 110, 400, 30, button.GetValue(game), Anchor.Centre, Anchor.Centre, regularFont, titleFont, validator); widgets[widgets.Length - 2] = inputWidget; widgets[widgets.Length - 1] = ButtonWidget.Create(game, 240, 110, 40, 30, "OK", Anchor.Centre, Anchor.Centre, titleFont, OnWidgetClick); InputOpened(); UpdateDescription(targetWidget); }
public override void Dispose() { game.Keyboard.KeyRepeat = false; inputWidget.Dispose(); DisposeDescWidget(); base.Dispose(); }