mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
Fix crash when clicking on graphics options button twice in very quick succession, then clicking on 'ok'.
This commit is contained in:
parent
5860746eda
commit
132d83b9aa
@ -119,7 +119,7 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
|
||||
void DefaultButtonClick(Game game, Widget widget, MouseButton btn, int x, int y) {
|
||||
if (btn != MouseButton.Left) return;
|
||||
int index = IndexOfWidget(targetWidget);
|
||||
int index = IndexOfWidget(activeButton);
|
||||
string defValue = defaultValues[index];
|
||||
|
||||
input.Clear();
|
||||
|
@ -85,7 +85,7 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
}
|
||||
|
||||
void HandleFontChange() {
|
||||
int selIndex = IndexOfWidget(selectedWidget);
|
||||
int selIndex = IndexOfWidget(selectedButton);
|
||||
game.Events.RaiseChatFontChanged();
|
||||
base.Dispose();
|
||||
base.Init();
|
||||
@ -102,7 +102,7 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
}
|
||||
|
||||
if (selIndex >= 0)
|
||||
selectedWidget = (ButtonWidget)widgets[selIndex];
|
||||
selectedButton = (ButtonWidget)widgets[selIndex];
|
||||
}
|
||||
|
||||
void MakeValidators() {
|
||||
|
@ -185,7 +185,7 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
|
||||
void DefaultButtonClick(Game game, Widget widget, MouseButton btn, int x, int y) {
|
||||
if (btn != MouseButton.Left) return;
|
||||
int index = IndexOfWidget(targetWidget);
|
||||
int index = IndexOfWidget(activeButton);
|
||||
string defValue = defaultValues[index];
|
||||
|
||||
input.Clear();
|
||||
|
@ -86,15 +86,15 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
protected ButtonWidget selectedWidget, targetWidget;
|
||||
protected ButtonWidget selectedButton, activeButton;
|
||||
protected override void WidgetSelected(Widget widget) {
|
||||
ButtonWidget button = widget as ButtonWidget;
|
||||
if (selectedWidget == button || button == null ||
|
||||
if (selectedButton == button || button == null ||
|
||||
button == widgets[widgets.Length - 2]) return;
|
||||
|
||||
selectedWidget = button;
|
||||
if (targetWidget != null) return;
|
||||
UpdateDescription(selectedWidget);
|
||||
selectedButton = button;
|
||||
if (activeButton != null) return;
|
||||
UpdateDescription(selectedButton);
|
||||
}
|
||||
|
||||
protected void UpdateDescription(ButtonWidget widget) {
|
||||
@ -133,10 +133,10 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
}
|
||||
|
||||
void ShowExtendedHelp() {
|
||||
bool canShow = input == null && selectedWidget != null && descriptions != null;
|
||||
bool canShow = input == null && selectedButton != null && descriptions != null;
|
||||
if (!canShow) return;
|
||||
|
||||
int index = IndexOfWidget(selectedWidget);
|
||||
int index = IndexOfWidget(selectedButton);
|
||||
if (index < 0 || index >= descriptions.Length) return;
|
||||
string[] desc = descriptions[index];
|
||||
if (desc == null) return;
|
||||
@ -186,7 +186,7 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
return;
|
||||
}
|
||||
|
||||
targetWidget = selectedWidget;
|
||||
activeButton = button;
|
||||
InputClosed();
|
||||
|
||||
input = MenuInputWidget.Create(game, 400, 30,
|
||||
@ -200,7 +200,7 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
.SetLocation(Anchor.Centre, Anchor.Centre, 240, 110);
|
||||
|
||||
InputOpened();
|
||||
UpdateDescription(targetWidget);
|
||||
UpdateDescription(activeButton);
|
||||
}
|
||||
|
||||
void InputClick(Game game, Widget widget, MouseButton btn, int x, int y) {
|
||||
@ -222,11 +222,11 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
void ChangeSetting() {
|
||||
string text = input.Text.ToString();
|
||||
if (((MenuInputWidget)input).Validator.IsValidValue(text)) {
|
||||
SetButtonValue(targetWidget, text);
|
||||
SetButtonValue(activeButton, text);
|
||||
}
|
||||
|
||||
UpdateDescription(targetWidget);
|
||||
targetWidget = null;
|
||||
UpdateDescription(activeButton);
|
||||
activeButton = null;
|
||||
InputClosed();
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,9 @@ typedef struct HotkeyData_ {
|
||||
#define HOTKEYS_MAX_COUNT 256
|
||||
HotkeyData HotkeysList[HOTKEYS_MAX_COUNT];
|
||||
StringsBuffer HotkeysText;
|
||||
#define HOTKEYS_FLAG_CTRL 1
|
||||
#define HOTKEYS_FLAG_SHIFT 2
|
||||
#define HOTKEYS_FLAT_ALT 4
|
||||
|
||||
void Hotkeys_Add(Key baseKey, UInt8 flags, STRING_PURE String* text, bool more);
|
||||
bool Hotkeys_Remove(Key baseKey, UInt8 flags);
|
||||
|
Loading…
x
Reference in New Issue
Block a user