mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-24 01:52:24 -05:00
get rid of keypress from widgets (only inputwidget used and needs it), fix edithotkey screen not showing
This commit is contained in:
parent
6c90fdd884
commit
02deabc0da
4 changed files with 27 additions and 38 deletions
|
@ -66,7 +66,6 @@ struct WidgetVTABLE {
|
||||||
void (*Free)(void* elem);
|
void (*Free)(void* elem);
|
||||||
bool (*HandlesKeyDown)(void* elem, Key key);
|
bool (*HandlesKeyDown)(void* elem, Key key);
|
||||||
bool (*HandlesKeyUp)(void* elem, Key key);
|
bool (*HandlesKeyUp)(void* elem, Key key);
|
||||||
bool (*HandlesKeyPress)(void* elem, char keyChar);
|
|
||||||
bool (*HandlesMouseDown)(void* elem, int x, int y, MouseButton btn);
|
bool (*HandlesMouseDown)(void* elem, int x, int y, MouseButton btn);
|
||||||
bool (*HandlesMouseUp)(void* elem, int x, int y, MouseButton btn);
|
bool (*HandlesMouseUp)(void* elem, int x, int y, MouseButton btn);
|
||||||
bool (*HandlesMouseMove)(void* elem, int x, int y);
|
bool (*HandlesMouseMove)(void* elem, int x, int y);
|
||||||
|
|
35
src/Menus.c
35
src/Menus.c
|
@ -374,7 +374,7 @@ static void ListScreen_Select(struct ListScreen* s, const String* str) {
|
||||||
|
|
||||||
static bool ListScreen_KeyDown(void* screen, Key key) {
|
static bool ListScreen_KeyDown(void* screen, Key key) {
|
||||||
struct ListScreen* s = (struct ListScreen*)screen;
|
struct ListScreen* s = (struct ListScreen*)screen;
|
||||||
if (key == KEY_LEFT || key == KEY_PAGEUP) {
|
if (key == KEY_LEFT || key == KEY_PAGEUP) {
|
||||||
ListScreen_PageClick(s, false);
|
ListScreen_PageClick(s, false);
|
||||||
} else if (key == KEY_RIGHT || key == KEY_PAGEDOWN) {
|
} else if (key == KEY_RIGHT || key == KEY_PAGEDOWN) {
|
||||||
ListScreen_PageClick(s, true);
|
ListScreen_PageClick(s, true);
|
||||||
|
@ -753,21 +753,17 @@ static void EditHotkeyScreen_MakeLeaveOpen(struct EditHotkeyScreen* s, Widget_Le
|
||||||
}
|
}
|
||||||
|
|
||||||
static void EditHotkeyScreen_BaseKey(void* screen, void* b) {
|
static void EditHotkeyScreen_BaseKey(void* screen, void* b) {
|
||||||
static const String msg = String_FromConst("Key: press a key..");
|
|
||||||
struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen;
|
struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen;
|
||||||
|
|
||||||
s->selectedI = 0;
|
s->selectedI = 0;
|
||||||
s->supressNextPress = true;
|
s->supressNextPress = true;
|
||||||
ButtonWidget_Set(&s->buttons[0], &msg, &s->titleFont);
|
ButtonWidget_SetConst(&s->buttons[0], "Key: press a key..", &s->titleFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void EditHotkeyScreen_Modifiers(void* screen, void* b) {
|
static void EditHotkeyScreen_Modifiers(void* screen, void* b) {
|
||||||
static const String msg = String_FromConst("Modifiers: press a key..");
|
|
||||||
struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen;
|
struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen;
|
||||||
|
|
||||||
s->selectedI = 1;
|
s->selectedI = 1;
|
||||||
s->supressNextPress = true;
|
s->supressNextPress = true;
|
||||||
ButtonWidget_Set(&s->buttons[1], &msg, &s->titleFont);
|
ButtonWidget_SetConst(&s->buttons[1], "Modifiers: press a key..", &s->titleFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void EditHotkeyScreen_LeaveOpen(void* screen, void* b) {
|
static void EditHotkeyScreen_LeaveOpen(void* screen, void* b) {
|
||||||
|
@ -839,9 +835,10 @@ static bool EditHotkeyScreen_KeyPress(void* screen, char keyChar) {
|
||||||
struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen;
|
struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen;
|
||||||
if (s->supressNextPress) {
|
if (s->supressNextPress) {
|
||||||
s->supressNextPress = false;
|
s->supressNextPress = false;
|
||||||
return true;
|
} else {
|
||||||
|
InputWidget_Append(&s->input.base, keyChar);
|
||||||
}
|
}
|
||||||
return Elem_HandlesKeyPress(&s->input.base, keyChar);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool EditHotkeyScreen_KeyDown(void* screen, Key key) {
|
static bool EditHotkeyScreen_KeyDown(void* screen, Key key) {
|
||||||
|
@ -907,7 +904,7 @@ static struct ScreenVTABLE EditHotkeyScreen_VTABLE = {
|
||||||
Menu_MouseDown, Menu_MouseUp, Menu_MouseMove, MenuScreen_MouseScroll,
|
Menu_MouseDown, Menu_MouseUp, Menu_MouseMove, MenuScreen_MouseScroll,
|
||||||
Menu_OnResize, Menu_ContextLost, EditHotkeyScreen_ContextRecreated
|
Menu_OnResize, Menu_ContextLost, EditHotkeyScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
struct Screen* EditHotkeyScreen_MakeInstance(struct HotkeyData original) {
|
void EditHotkeyScreen_Show(struct HotkeyData original) {
|
||||||
static struct Widget* widgets[7];
|
static struct Widget* widgets[7];
|
||||||
struct EditHotkeyScreen* s = &EditHotkeyScreen_Instance;
|
struct EditHotkeyScreen* s = &EditHotkeyScreen_Instance;
|
||||||
|
|
||||||
|
@ -920,7 +917,7 @@ struct Screen* EditHotkeyScreen_MakeInstance(struct HotkeyData original) {
|
||||||
s->selectedI = -1;
|
s->selectedI = -1;
|
||||||
s->origHotkey = original;
|
s->origHotkey = original;
|
||||||
s->curHotkey = original;
|
s->curHotkey = original;
|
||||||
return (struct Screen*)s;
|
Gui_Replace((struct Screen*)s, GUI_PRIORITY_MENU);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1039,7 +1036,8 @@ static bool GenLevelScreen_KeyUp(void* screen, Key key) {
|
||||||
|
|
||||||
static bool GenLevelScreen_KeyPress(void* screen, char keyChar) {
|
static bool GenLevelScreen_KeyPress(void* screen, char keyChar) {
|
||||||
struct GenLevelScreen* s = (struct GenLevelScreen*)screen;
|
struct GenLevelScreen* s = (struct GenLevelScreen*)screen;
|
||||||
return !s->selected || Elem_HandlesKeyPress(&s->selected->base, keyChar);
|
if (s->selected) InputWidget_Append(&s->selected->base, keyChar);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GenLevelScreen_ContextRecreated(void* screen) {
|
static void GenLevelScreen_ContextRecreated(void* screen) {
|
||||||
|
@ -1244,7 +1242,8 @@ static void SaveLevelScreen_Render(void* screen, double delta) {
|
||||||
static bool SaveLevelScreen_KeyPress(void* screen, char keyChar) {
|
static bool SaveLevelScreen_KeyPress(void* screen, char keyChar) {
|
||||||
struct SaveLevelScreen* s = (struct SaveLevelScreen*)screen;
|
struct SaveLevelScreen* s = (struct SaveLevelScreen*)screen;
|
||||||
SaveLevelScreen_RemoveOverwrites(s);
|
SaveLevelScreen_RemoveOverwrites(s);
|
||||||
return Elem_HandlesKeyPress(&s->input.base, keyChar);
|
InputWidget_Append(&s->input.base, keyChar);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool SaveLevelScreen_KeyDown(void* screen, Key key) {
|
static bool SaveLevelScreen_KeyDown(void* screen, Key key) {
|
||||||
|
@ -1412,8 +1411,7 @@ static void HotkeyListScreen_EntryClick(void* screen, void* widget) {
|
||||||
|
|
||||||
text = ListScreen_UNSAFE_GetCur(s, widget);
|
text = ListScreen_UNSAFE_GetCur(s, widget);
|
||||||
if (String_CaselessEqualsConst(&text, LIST_SCREEN_EMPTY)) {
|
if (String_CaselessEqualsConst(&text, LIST_SCREEN_EMPTY)) {
|
||||||
Gui_FreeActive();
|
EditHotkeyScreen_Show(original);
|
||||||
Gui_SetActive(EditHotkeyScreen_MakeInstance(original));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1428,8 +1426,7 @@ static void HotkeyListScreen_EntryClick(void* screen, void* widget) {
|
||||||
if (h.Trigger == trigger && h.Flags == flags) { original = h; break; }
|
if (h.Trigger == trigger && h.Flags == flags) { original = h; break; }
|
||||||
}
|
}
|
||||||
|
|
||||||
Gui_FreeActive();
|
EditHotkeyScreen_Show(original);
|
||||||
Gui_SetActive(EditHotkeyScreen_MakeInstance(original));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HotkeyListScreen_MakeFlags(int flags, String* str) {
|
static void HotkeyListScreen_MakeFlags(int flags, String* str) {
|
||||||
|
@ -1940,8 +1937,8 @@ static void MenuOptionsScreen_ContextLost(void* screen) {
|
||||||
|
|
||||||
static bool MenuOptionsScreen_KeyPress(void* screen, char keyChar) {
|
static bool MenuOptionsScreen_KeyPress(void* screen, char keyChar) {
|
||||||
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
|
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
|
||||||
if (s->activeI == -1) return true;
|
if (s->activeI >= 0) InputWidget_Append(&s->input.base, keyChar);
|
||||||
return Elem_HandlesKeyPress(&s->input.base, keyChar);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool MenuOptionsScreen_KeyDown(void* screen, Key key) {
|
static bool MenuOptionsScreen_KeyDown(void* screen, Key key) {
|
||||||
|
|
|
@ -1024,7 +1024,7 @@ static bool HUDScreen_KeyPress(void* screen, char keyChar) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Elem_HandlesKeyPress(&s->input.base, keyChar);
|
InputWidget_Append(&s->input.base, keyChar);
|
||||||
HUDScreen_UpdateAltTextY(s);
|
HUDScreen_UpdateAltTextY(s);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ static Size2D Size2D_Empty;
|
||||||
|
|
||||||
static bool Widget_Mouse(void* elem, int x, int y, MouseButton btn) { return false; }
|
static bool Widget_Mouse(void* elem, int x, int y, MouseButton btn) { return false; }
|
||||||
static bool Widget_Key(void* elem, Key key) { return false; }
|
static bool Widget_Key(void* elem, Key key) { return false; }
|
||||||
static bool Widget_KeyPress(void* elem, char keyChar) { return false; }
|
|
||||||
static bool Widget_MouseMove(void* elem, int x, int y) { return false; }
|
static bool Widget_MouseMove(void* elem, int x, int y) { return false; }
|
||||||
static bool Widget_MouseScroll(void* elem, float delta) { return false; }
|
static bool Widget_MouseScroll(void* elem, float delta) { return false; }
|
||||||
|
|
||||||
|
@ -50,7 +49,7 @@ static void TextWidget_Reposition(void* widget) {
|
||||||
|
|
||||||
static struct WidgetVTABLE TextWidget_VTABLE = {
|
static struct WidgetVTABLE TextWidget_VTABLE = {
|
||||||
Widget_NullFunc, TextWidget_Render, TextWidget_Free,
|
Widget_NullFunc, TextWidget_Render, TextWidget_Free,
|
||||||
Widget_Key, Widget_Key, Widget_KeyPress,
|
Widget_Key, Widget_Key,
|
||||||
Widget_Mouse, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
Widget_Mouse, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
||||||
TextWidget_Reposition
|
TextWidget_Reposition
|
||||||
};
|
};
|
||||||
|
@ -153,7 +152,7 @@ static void ButtonWidget_Render(void* widget, double delta) {
|
||||||
|
|
||||||
static struct WidgetVTABLE ButtonWidget_VTABLE = {
|
static struct WidgetVTABLE ButtonWidget_VTABLE = {
|
||||||
Widget_NullFunc, ButtonWidget_Render, ButtonWidget_Free,
|
Widget_NullFunc, ButtonWidget_Render, ButtonWidget_Free,
|
||||||
Widget_Key, Widget_Key, Widget_KeyPress,
|
Widget_Key, Widget_Key,
|
||||||
Widget_Mouse, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
Widget_Mouse, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
||||||
ButtonWidget_Reposition
|
ButtonWidget_Reposition
|
||||||
};
|
};
|
||||||
|
@ -299,7 +298,7 @@ static bool ScrollbarWidget_MouseMove(void* widget, int x, int y) {
|
||||||
|
|
||||||
static struct WidgetVTABLE ScrollbarWidget_VTABLE = {
|
static struct WidgetVTABLE ScrollbarWidget_VTABLE = {
|
||||||
Widget_NullFunc, ScrollbarWidget_Render, Widget_NullFunc,
|
Widget_NullFunc, ScrollbarWidget_Render, Widget_NullFunc,
|
||||||
Widget_Key, Widget_Key, Widget_KeyPress,
|
Widget_Key, Widget_Key,
|
||||||
ScrollbarWidget_MouseDown, ScrollbarWidget_MouseUp, ScrollbarWidget_MouseMove, ScrollbarWidget_MouseScroll,
|
ScrollbarWidget_MouseDown, ScrollbarWidget_MouseUp, ScrollbarWidget_MouseMove, ScrollbarWidget_MouseScroll,
|
||||||
Widget_CalcPosition
|
Widget_CalcPosition
|
||||||
};
|
};
|
||||||
|
@ -488,7 +487,7 @@ static bool HotbarWidget_MouseScroll(void* widget, float delta) {
|
||||||
|
|
||||||
static struct WidgetVTABLE HotbarWidget_VTABLE = {
|
static struct WidgetVTABLE HotbarWidget_VTABLE = {
|
||||||
HotbarWidget_Init, HotbarWidget_Render, Widget_NullFunc,
|
HotbarWidget_Init, HotbarWidget_Render, Widget_NullFunc,
|
||||||
HotbarWidget_KeyDown, HotbarWidget_KeyUp, Widget_KeyPress,
|
HotbarWidget_KeyDown, HotbarWidget_KeyUp,
|
||||||
HotbarWidget_MouseDown, Widget_Mouse, Widget_MouseMove, HotbarWidget_MouseScroll,
|
HotbarWidget_MouseDown, Widget_Mouse, Widget_MouseMove, HotbarWidget_MouseScroll,
|
||||||
HotbarWidget_Reposition
|
HotbarWidget_Reposition
|
||||||
};
|
};
|
||||||
|
@ -820,7 +819,7 @@ static bool TableWidget_KeyDown(void* widget, Key key) {
|
||||||
|
|
||||||
static struct WidgetVTABLE TableWidget_VTABLE = {
|
static struct WidgetVTABLE TableWidget_VTABLE = {
|
||||||
TableWidget_Init, TableWidget_Render, TableWidget_Free,
|
TableWidget_Init, TableWidget_Render, TableWidget_Free,
|
||||||
TableWidget_KeyDown, Widget_Key, Widget_KeyPress,
|
TableWidget_KeyDown, Widget_Key,
|
||||||
TableWidget_MouseDown, TableWidget_MouseUp, TableWidget_MouseMove, TableWidget_MouseScroll,
|
TableWidget_MouseDown, TableWidget_MouseUp, TableWidget_MouseMove, TableWidget_MouseScroll,
|
||||||
TableWidget_Reposition
|
TableWidget_Reposition
|
||||||
};
|
};
|
||||||
|
@ -1212,12 +1211,6 @@ static bool InputWidget_KeyDown(void* widget, Key key) {
|
||||||
|
|
||||||
static bool InputWidget_KeyUp(void* widget, Key key) { return true; }
|
static bool InputWidget_KeyUp(void* widget, Key key) { return true; }
|
||||||
|
|
||||||
static bool InputWidget_KeyPress(void* widget, char keyChar) {
|
|
||||||
struct InputWidget* w = (struct InputWidget*)widget;
|
|
||||||
InputWidget_Append(w, keyChar);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool InputWidget_MouseDown(void* widget, int x, int y, MouseButton button) {
|
static bool InputWidget_MouseDown(void* widget, int x, int y, MouseButton button) {
|
||||||
String line; char lineBuffer[STRING_SIZE];
|
String line; char lineBuffer[STRING_SIZE];
|
||||||
struct InputWidget* w = (struct InputWidget*)widget;
|
struct InputWidget* w = (struct InputWidget*)widget;
|
||||||
|
@ -1492,7 +1485,7 @@ static bool MenuInputWidget_AllowedChar(void* widget, char c) {
|
||||||
static int MenuInputWidget_GetMaxLines(void) { return 1; }
|
static int MenuInputWidget_GetMaxLines(void) { return 1; }
|
||||||
static struct WidgetVTABLE MenuInputWidget_VTABLE = {
|
static struct WidgetVTABLE MenuInputWidget_VTABLE = {
|
||||||
InputWidget_Init, MenuInputWidget_Render, InputWidget_Free,
|
InputWidget_Init, MenuInputWidget_Render, InputWidget_Free,
|
||||||
InputWidget_KeyDown, InputWidget_KeyUp, InputWidget_KeyPress,
|
InputWidget_KeyDown, InputWidget_KeyUp,
|
||||||
InputWidget_MouseDown, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
InputWidget_MouseDown, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
||||||
InputWidget_Reposition
|
InputWidget_Reposition
|
||||||
};
|
};
|
||||||
|
@ -1745,7 +1738,7 @@ static int ChatInputWidget_GetMaxLines(void) {
|
||||||
|
|
||||||
static struct WidgetVTABLE ChatInputWidget_VTABLE = {
|
static struct WidgetVTABLE ChatInputWidget_VTABLE = {
|
||||||
InputWidget_Init, ChatInputWidget_Render, InputWidget_Free,
|
InputWidget_Init, ChatInputWidget_Render, InputWidget_Free,
|
||||||
ChatInputWidget_KeyDown, InputWidget_KeyUp, InputWidget_KeyPress,
|
ChatInputWidget_KeyDown, InputWidget_KeyUp,
|
||||||
InputWidget_MouseDown, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
InputWidget_MouseDown, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
||||||
InputWidget_Reposition
|
InputWidget_Reposition
|
||||||
};
|
};
|
||||||
|
@ -2142,7 +2135,7 @@ static void PlayerListWidget_Free(void* widget) {
|
||||||
|
|
||||||
static struct WidgetVTABLE PlayerListWidget_VTABLE = {
|
static struct WidgetVTABLE PlayerListWidget_VTABLE = {
|
||||||
PlayerListWidget_Init, PlayerListWidget_Render, PlayerListWidget_Free,
|
PlayerListWidget_Init, PlayerListWidget_Render, PlayerListWidget_Free,
|
||||||
Widget_Key, Widget_Key, Widget_KeyPress,
|
Widget_Key, Widget_Key,
|
||||||
Widget_Mouse, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
Widget_Mouse, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
||||||
PlayerListWidget_Reposition
|
PlayerListWidget_Reposition
|
||||||
};
|
};
|
||||||
|
@ -2574,7 +2567,7 @@ static void TextGroupWidget_Free(void* widget) {
|
||||||
|
|
||||||
static struct WidgetVTABLE TextGroupWidget_VTABLE = {
|
static struct WidgetVTABLE TextGroupWidget_VTABLE = {
|
||||||
TextGroupWidget_Init, TextGroupWidget_Render, TextGroupWidget_Free,
|
TextGroupWidget_Init, TextGroupWidget_Render, TextGroupWidget_Free,
|
||||||
Widget_Key, Widget_Key, Widget_KeyPress,
|
Widget_Key, Widget_Key,
|
||||||
Widget_Mouse, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
Widget_Mouse, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
||||||
TextGroupWidget_Reposition
|
TextGroupWidget_Reposition
|
||||||
};
|
};
|
||||||
|
@ -2827,7 +2820,7 @@ void SpecialInputWidget_SetActive(struct SpecialInputWidget* w, bool active) {
|
||||||
|
|
||||||
static struct WidgetVTABLE SpecialInputWidget_VTABLE = {
|
static struct WidgetVTABLE SpecialInputWidget_VTABLE = {
|
||||||
SpecialInputWidget_Init, SpecialInputWidget_Render, SpecialInputWidget_Free,
|
SpecialInputWidget_Init, SpecialInputWidget_Render, SpecialInputWidget_Free,
|
||||||
Widget_Key, Widget_Key, Widget_KeyPress,
|
Widget_Key, Widget_Key,
|
||||||
SpecialInputWidget_MouseDown, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
SpecialInputWidget_MouseDown, Widget_Mouse, Widget_MouseMove, Widget_MouseScroll,
|
||||||
Widget_CalcPosition
|
Widget_CalcPosition
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue