mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 20:15:35 -04:00
Return touch type instead of true in screen pointer up's, return void for widget input/pointer up
This commit is contained in:
parent
1303119929
commit
53e3ab92e6
@ -453,7 +453,6 @@ static cc_result ApplySkin(struct Entity* e, struct Bitmap* bmp, struct Stream*
|
|||||||
|
|
||||||
static void LogInvalidSkin(cc_result res, const cc_string* url, const cc_uint8* data, int size) {
|
static void LogInvalidSkin(cc_result res, const cc_string* url, const cc_uint8* data, int size) {
|
||||||
cc_string msg; char msgBuffer[256];
|
cc_string msg; char msgBuffer[256];
|
||||||
int i;
|
|
||||||
String_InitArray(msg, msgBuffer);
|
String_InitArray(msg, msgBuffer);
|
||||||
|
|
||||||
Logger_FormatWarn2(&msg, res, "decoding", url, Platform_DescribeError);
|
Logger_FormatWarn2(&msg, res, "decoding", url, Platform_DescribeError);
|
||||||
|
12
src/Gui.h
12
src/Gui.h
@ -140,14 +140,14 @@ struct WidgetVTABLE {
|
|||||||
void (*Reposition)(void* elem);
|
void (*Reposition)(void* elem);
|
||||||
/* Returns non-zero if an input press is handled. */
|
/* Returns non-zero if an input press is handled. */
|
||||||
int (*HandlesKeyDown)(void* elem, int key);
|
int (*HandlesKeyDown)(void* elem, int key);
|
||||||
/* Returns non-zero if an input release is handled. */
|
/* Called when an input key or button is released. */
|
||||||
int (*HandlesKeyUp)(void* elem, int key);
|
void (*OnInputUp)(void* elem, int key);
|
||||||
/* Returns non-zero if a mouse wheel scroll is handled. */
|
/* Returns non-zero if a mouse wheel scroll is handled. */
|
||||||
int (*HandlesMouseScroll)(void* elem, float delta);
|
int (*HandlesMouseScroll)(void* elem, float delta);
|
||||||
/* Returns non-zero if a pointer press is handled. */
|
/* Returns non-zero if a pointer press is handled. */
|
||||||
int (*HandlesPointerDown)(void* elem, int id, int x, int y);
|
int (*HandlesPointerDown)(void* elem, int id, int x, int y);
|
||||||
/* Returns non-zero if a pointer release is handled. */
|
/* Called when a pointer is released. */
|
||||||
int (*HandlesPointerUp)(void* elem, int id, int x, int y);
|
void (*OnPointerUp)(void* elem, int id, int x, int y);
|
||||||
/* Returns non-zero if a pointer movement is handled. */
|
/* Returns non-zero if a pointer movement is handled. */
|
||||||
int (*HandlesPointerMove)(void* elem, int id, int x, int y);
|
int (*HandlesPointerMove)(void* elem, int id, int x, int y);
|
||||||
/* Builds the mesh of vertices for this widget. */
|
/* Builds the mesh of vertices for this widget. */
|
||||||
@ -248,11 +248,11 @@ void TextAtlas_AddInt(struct TextAtlas* atlas, int value, struct VertexTextured*
|
|||||||
#define Elem_Free(elem) (elem)->VTABLE->Free(elem)
|
#define Elem_Free(elem) (elem)->VTABLE->Free(elem)
|
||||||
#define Elem_HandlesKeyPress(elem, key) (elem)->VTABLE->HandlesKeyPress(elem, key)
|
#define Elem_HandlesKeyPress(elem, key) (elem)->VTABLE->HandlesKeyPress(elem, key)
|
||||||
#define Elem_HandlesKeyDown(elem, key) (elem)->VTABLE->HandlesKeyDown(elem, key)
|
#define Elem_HandlesKeyDown(elem, key) (elem)->VTABLE->HandlesKeyDown(elem, key)
|
||||||
#define Elem_HandlesKeyUp(elem, key) (elem)->VTABLE->HandlesKeyUp(elem, key)
|
#define Elem_OnInputUp(elem, key) (elem)->VTABLE->OnInputUp(elem, key)
|
||||||
|
|
||||||
#define Elem_HandlesMouseScroll(elem, delta) (elem)->VTABLE->HandlesMouseScroll(elem, delta)
|
#define Elem_HandlesMouseScroll(elem, delta) (elem)->VTABLE->HandlesMouseScroll(elem, delta)
|
||||||
#define Elem_HandlesPointerDown(elem, id, x, y) (elem)->VTABLE->HandlesPointerDown(elem, id, x, y)
|
#define Elem_HandlesPointerDown(elem, id, x, y) (elem)->VTABLE->HandlesPointerDown(elem, id, x, y)
|
||||||
#define Elem_HandlesPointerUp(elem, id, x, y) (elem)->VTABLE->HandlesPointerUp(elem, id, x, y)
|
#define Elem_OnPointerUp(elem, id, x, y) (elem)->VTABLE->OnPointerUp(elem, id, x, y)
|
||||||
#define Elem_HandlesPointerMove(elem, id, x, y) (elem)->VTABLE->HandlesPointerMove(elem, id, x, y)
|
#define Elem_HandlesPointerMove(elem, id, x, y) (elem)->VTABLE->HandlesPointerMove(elem, id, x, y)
|
||||||
|
|
||||||
#define Widget_BuildMesh(widget, vertices) (widget)->VTABLE->BuildMesh(widget, vertices)
|
#define Widget_BuildMesh(widget, vertices) (widget)->VTABLE->BuildMesh(widget, vertices)
|
||||||
|
@ -51,15 +51,6 @@ int Pointers_Count;
|
|||||||
cc_bool Input_TapPlace = true, Input_HoldPlace = false;
|
cc_bool Input_TapPlace = true, Input_HoldPlace = false;
|
||||||
cc_bool Input_TouchMode;
|
cc_bool Input_TouchMode;
|
||||||
|
|
||||||
/* Touch fingers are initially are all type, meaning they could */
|
|
||||||
/* trigger menu clicks, camera movement, or place/delete blocks */
|
|
||||||
/* But for example, after clicking on a menu button, you wouldn't */
|
|
||||||
/* want moving that finger anymore to move the camera */
|
|
||||||
#define TOUCH_TYPE_GUI 1
|
|
||||||
#define TOUCH_TYPE_CAMERA 2
|
|
||||||
#define TOUCH_TYPE_BLOCKS 4
|
|
||||||
#define TOUCH_TYPE_ALL (TOUCH_TYPE_GUI | TOUCH_TYPE_CAMERA | TOUCH_TYPE_BLOCKS)
|
|
||||||
|
|
||||||
static void DoDeleteBlock(void);
|
static void DoDeleteBlock(void);
|
||||||
static void DoPlaceBlock(void);
|
static void DoPlaceBlock(void);
|
||||||
static void MouseStatePress(int button);
|
static void MouseStatePress(int button);
|
||||||
|
@ -93,6 +93,15 @@ void Input_RemoveTouch(long id, int x, int y);
|
|||||||
#define Input_TouchMode false
|
#define Input_TouchMode false
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Touch fingers are initially are 'all' type, meaning they could */
|
||||||
|
/* trigger menu clicks, camera movement, or place/delete blocks */
|
||||||
|
/* But for example, after clicking on a menu button, you wouldn't */
|
||||||
|
/* want moving that finger anymore to move the camera */
|
||||||
|
#define TOUCH_TYPE_GUI 1
|
||||||
|
#define TOUCH_TYPE_CAMERA 2
|
||||||
|
#define TOUCH_TYPE_BLOCKS 4
|
||||||
|
#define TOUCH_TYPE_ALL (TOUCH_TYPE_GUI | TOUCH_TYPE_CAMERA | TOUCH_TYPE_BLOCKS)
|
||||||
|
|
||||||
/* Data for mouse and touch */
|
/* Data for mouse and touch */
|
||||||
extern struct Pointer { int x, y; } Pointers[INPUT_MAX_POINTERS];
|
extern struct Pointer { int x, y; } Pointers[INPUT_MAX_POINTERS];
|
||||||
/* Raises InputEvents.Wheel with the given wheel delta. */
|
/* Raises InputEvents.Wheel with the given wheel delta. */
|
||||||
|
@ -85,7 +85,7 @@ static void Menu_RenderBounds(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Menu_PointerDown(void* screen, int id, int x, int y) {
|
int Menu_PointerDown(void* screen, int id, int x, int y) {
|
||||||
Screen_DoPointerDown(screen, id, x, y); return true;
|
Screen_DoPointerDown(screen, id, x, y); return TOUCH_TYPE_GUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Menu_DoPointerMove(void* screen, int id, int x, int y) {
|
static int Menu_DoPointerMove(void* screen, int id, int x, int y) {
|
||||||
@ -1100,13 +1100,13 @@ static int GenLevelScreen_TextChanged(void* screen, const cc_string* str) {
|
|||||||
static int GenLevelScreen_PointerDown(void* screen, int id, int x, int y) {
|
static int GenLevelScreen_PointerDown(void* screen, int id, int x, int y) {
|
||||||
struct GenLevelScreen* s = (struct GenLevelScreen*)screen;
|
struct GenLevelScreen* s = (struct GenLevelScreen*)screen;
|
||||||
int i = Screen_DoPointerDown(screen, id, x, y);
|
int i = Screen_DoPointerDown(screen, id, x, y);
|
||||||
if (i == -1 || i >= 4) return true;
|
if (i == -1 || i >= 4) return TOUCH_TYPE_GUI;
|
||||||
|
|
||||||
if (s->selected) s->selected->base.showCaret = false;
|
if (s->selected) s->selected->base.showCaret = false;
|
||||||
s->selected = (struct TextInputWidget*)&s->inputs[i];
|
s->selected = (struct TextInputWidget*)&s->inputs[i];
|
||||||
s->selected->base.showCaret = true;
|
s->selected->base.showCaret = true;
|
||||||
Window_SetKeyboardText(&s->inputs[i].base.text);
|
Window_SetKeyboardText(&s->inputs[i].base.text);
|
||||||
return true;
|
return TOUCH_TYPE_GUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GenLevelScreen_ContextLost(void* screen) {
|
static void GenLevelScreen_ContextLost(void* screen) {
|
||||||
|
@ -236,10 +236,10 @@ static int HUDScreen_KeyDown(void* screen, int key) {
|
|||||||
return Elem_HandlesKeyDown(&s->hotbar, key);
|
return Elem_HandlesKeyDown(&s->hotbar, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HUDScreen_KeyUp(void* screen, int key) {
|
static void HUDScreen_InputUp(void* screen, int key) {
|
||||||
struct HUDScreen* s = (struct HUDScreen*)screen;
|
struct HUDScreen* s = (struct HUDScreen*)screen;
|
||||||
if (!InventoryScreen_IsHotbarActive()) return;
|
if (!InventoryScreen_IsHotbarActive()) return;
|
||||||
Elem_HandlesKeyUp(&s->hotbar, key);
|
Elem_OnInputUp(&s->hotbar, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int HUDscreen_PointerDown(void* screen, int id, int x, int y) {
|
static int HUDscreen_PointerDown(void* screen, int id, int x, int y) {
|
||||||
@ -300,7 +300,7 @@ static void HUDScreen_Free(void* screen) {
|
|||||||
static const struct ScreenVTABLE HUDScreen_VTABLE = {
|
static const struct ScreenVTABLE HUDScreen_VTABLE = {
|
||||||
HUDScreen_Init, HUDScreen_Update, HUDScreen_Free,
|
HUDScreen_Init, HUDScreen_Update, HUDScreen_Free,
|
||||||
HUDScreen_Render, HUDScreen_BuildMesh,
|
HUDScreen_Render, HUDScreen_BuildMesh,
|
||||||
HUDScreen_KeyDown, HUDScreen_KeyUp, Screen_FKeyPress, Screen_FText,
|
HUDScreen_KeyDown, HUDScreen_InputUp, Screen_FKeyPress, Screen_FText,
|
||||||
HUDscreen_PointerDown, Screen_PointerUp, Screen_FPointer, HUDscreen_MouseScroll,
|
HUDscreen_PointerDown, Screen_PointerUp, Screen_FPointer, HUDscreen_MouseScroll,
|
||||||
HUDScreen_Layout, HUDScreen_ContextLost, HUDScreen_ContextRecreated
|
HUDScreen_Layout, HUDScreen_ContextLost, HUDScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
@ -619,7 +619,7 @@ static int TabListOverlay_PointerDown(void* screen, int id, int x, int y) {
|
|||||||
player = TabList_UNSAFE_GetPlayer(s->ids[i]);
|
player = TabList_UNSAFE_GetPlayer(s->ids[i]);
|
||||||
String_Format1(&text, "%s ", &player);
|
String_Format1(&text, "%s ", &player);
|
||||||
ChatScreen_AppendInput(&text);
|
ChatScreen_AppendInput(&text);
|
||||||
return true;
|
return TOUCH_TYPE_GUI;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1188,15 +1188,15 @@ static int ChatScreen_PointerDown(void* screen, int id, int x, int y) {
|
|||||||
if (!Utils_IsUrlPrefix(&text)) return false;
|
if (!Utils_IsUrlPrefix(&text)) return false;
|
||||||
|
|
||||||
if (Chat_LogTime[s->chatIndex + i] + 10 < Game.Time) return false;
|
if (Chat_LogTime[s->chatIndex + i] + 10 < Game.Time) return false;
|
||||||
UrlWarningOverlay_Show(&text); return true;
|
UrlWarningOverlay_Show(&text); return TOUCH_TYPE_GUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CC_BUILD_TOUCH
|
#ifdef CC_BUILD_TOUCH
|
||||||
if (Widget_Contains(&s->send, x, y)) {
|
if (Widget_Contains(&s->send, x, y)) {
|
||||||
ChatScreen_EnterChatInput(s, false); return true;
|
ChatScreen_EnterChatInput(s, false); return TOUCH_TYPE_GUI;
|
||||||
}
|
}
|
||||||
if (Widget_Contains(&s->cancel, x, y)) {
|
if (Widget_Contains(&s->cancel, x, y)) {
|
||||||
ChatScreen_EnterChatInput(s, true); return true;
|
ChatScreen_EnterChatInput(s, true); return TOUCH_TYPE_GUI;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1204,10 +1204,10 @@ static int ChatScreen_PointerDown(void* screen, int id, int x, int y) {
|
|||||||
if (s->altText.active && Widget_Contains(&s->altText, x, y)) {
|
if (s->altText.active && Widget_Contains(&s->altText, x, y)) {
|
||||||
Elem_HandlesPointerDown(&s->altText, id, x, y);
|
Elem_HandlesPointerDown(&s->altText, id, x, y);
|
||||||
ChatScreen_UpdateChatYOffsets(s);
|
ChatScreen_UpdateChatYOffsets(s);
|
||||||
return true;
|
return TOUCH_TYPE_GUI;
|
||||||
}
|
}
|
||||||
Elem_HandlesPointerDown(&s->input.base, id, x, y);
|
Elem_HandlesPointerDown(&s->input.base, id, x, y);
|
||||||
return true;
|
return TOUCH_TYPE_GUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
height = TextGroupWidget_UsedHeight(&s->chat);
|
height = TextGroupWidget_UsedHeight(&s->chat);
|
||||||
@ -1223,7 +1223,7 @@ static int ChatScreen_PointerDown(void* screen, int id, int x, int y) {
|
|||||||
} else if (Gui.ClickableChat) {
|
} else if (Gui.ClickableChat) {
|
||||||
ChatScreen_AppendInput(&text);
|
ChatScreen_AppendInput(&text);
|
||||||
}
|
}
|
||||||
return true;
|
return TOUCH_TYPE_GUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ChatScreen_Init(void* screen) {
|
static void ChatScreen_Init(void* screen) {
|
||||||
@ -1438,20 +1438,20 @@ static int InventoryScreen_PointerDown(void* screen, int id, int x, int y) {
|
|||||||
struct TableWidget* table = &s->table;
|
struct TableWidget* table = &s->table;
|
||||||
cc_bool handled, hotbar;
|
cc_bool handled, hotbar;
|
||||||
|
|
||||||
if (table->scroll.draggingId == id) return true;
|
if (table->scroll.draggingId == id) return TOUCH_TYPE_GUI;
|
||||||
if (HUDscreen_PointerDown(Gui_HUD, id, x, y)) return true;
|
if (HUDscreen_PointerDown(Gui_HUD, id, x, y)) return TOUCH_TYPE_GUI;
|
||||||
handled = Elem_HandlesPointerDown(table, id, x, y);
|
handled = Elem_HandlesPointerDown(table, id, x, y);
|
||||||
|
|
||||||
if (!handled || table->pendingClose) {
|
if (!handled || table->pendingClose) {
|
||||||
hotbar = Key_IsControlPressed() || Key_IsShiftPressed();
|
hotbar = Key_IsControlPressed() || Key_IsShiftPressed();
|
||||||
if (!hotbar) Gui_Remove((struct Screen*)s);
|
if (!hotbar) Gui_Remove((struct Screen*)s);
|
||||||
}
|
}
|
||||||
return true;
|
return TOUCH_TYPE_GUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InventoryScreen_PointerUp(void* screen, int id, int x, int y) {
|
static void InventoryScreen_PointerUp(void* screen, int id, int x, int y) {
|
||||||
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
||||||
Elem_HandlesPointerUp(&s->table, id, x, y);
|
Elem_OnPointerUp(&s->table, id, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int InventoryScreen_PointerMove(void* screen, int id, int x, int y) {
|
static int InventoryScreen_PointerMove(void* screen, int id, int x, int y) {
|
||||||
|
@ -21,10 +21,12 @@
|
|||||||
|
|
||||||
#define Widget_UV(u1,v1, u2,v2) Tex_UV(u1/256.0f,v1/256.0f, u2/256.0f,v2/256.0f)
|
#define Widget_UV(u1,v1, u2,v2) Tex_UV(u1/256.0f,v1/256.0f, u2/256.0f,v2/256.0f)
|
||||||
static void Widget_NullFunc(void* widget) { }
|
static void Widget_NullFunc(void* widget) { }
|
||||||
static int Widget_Pointer(void* elem, int id, int x, int y) { return false; }
|
static int Widget_Pointer(void* elem, int id, int x, int y) { return false; }
|
||||||
static int Widget_Key(void* elem, int key) { return false; }
|
static void Widget_InputUp(void* elem, int key) { }
|
||||||
static int Widget_PointerMove(void* elem, int id, int x, int y) { return false; }
|
static int Widget_InputDown(void* elem, int key) { return false; }
|
||||||
static int Widget_MouseScroll(void* elem, float delta) { return false; }
|
static void Widget_PointerUp(void* elem, int id, int x, int y) { }
|
||||||
|
static int Widget_PointerMove(void* elem, int id, int x, int y) { return false; }
|
||||||
|
static int Widget_MouseScroll(void* elem, float delta) { return false; }
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-------------------------------------------------------TextWidget--------------------------------------------------------*
|
*-------------------------------------------------------TextWidget--------------------------------------------------------*
|
||||||
@ -60,9 +62,9 @@ static int TextWidget_Render2(void* widget, int offset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const struct WidgetVTABLE TextWidget_VTABLE = {
|
static const struct WidgetVTABLE TextWidget_VTABLE = {
|
||||||
TextWidget_Render, TextWidget_Free, TextWidget_Reposition,
|
TextWidget_Render, TextWidget_Free, TextWidget_Reposition,
|
||||||
Widget_Key, Widget_Key, Widget_MouseScroll,
|
Widget_InputDown, Widget_InputUp, Widget_MouseScroll,
|
||||||
Widget_Pointer, Widget_Pointer, Widget_PointerMove,
|
Widget_Pointer, Widget_PointerUp, Widget_PointerMove,
|
||||||
TextWidget_BuildMesh, TextWidget_Render2
|
TextWidget_BuildMesh, TextWidget_Render2
|
||||||
};
|
};
|
||||||
void TextWidget_Init(struct TextWidget* w) {
|
void TextWidget_Init(struct TextWidget* w) {
|
||||||
@ -209,8 +211,8 @@ static int ButtonWidget_Render2(void* widget, int offset) {
|
|||||||
|
|
||||||
static const struct WidgetVTABLE ButtonWidget_VTABLE = {
|
static const struct WidgetVTABLE ButtonWidget_VTABLE = {
|
||||||
ButtonWidget_Render, ButtonWidget_Free, ButtonWidget_Reposition,
|
ButtonWidget_Render, ButtonWidget_Free, ButtonWidget_Reposition,
|
||||||
Widget_Key, Widget_Key, Widget_MouseScroll,
|
Widget_InputDown, Widget_InputUp, Widget_MouseScroll,
|
||||||
Widget_Pointer, Widget_Pointer, Widget_PointerMove,
|
Widget_Pointer, Widget_PointerUp, Widget_PointerMove,
|
||||||
ButtonWidget_BuildMesh, ButtonWidget_Render2
|
ButtonWidget_BuildMesh, ButtonWidget_Render2
|
||||||
};
|
};
|
||||||
void ButtonWidget_Make(struct ButtonWidget* w, int minWidth, Widget_LeftClick onClick, cc_uint8 horAnchor, cc_uint8 verAnchor, int xOffset, int yOffset) {
|
void ButtonWidget_Make(struct ButtonWidget* w, int minWidth, Widget_LeftClick onClick, cc_uint8 horAnchor, cc_uint8 verAnchor, int xOffset, int yOffset) {
|
||||||
@ -303,7 +305,7 @@ static int ScrollbarWidget_PointerDown(void* widget, int id, int x, int y) {
|
|||||||
struct ScrollbarWidget* w = (struct ScrollbarWidget*)widget;
|
struct ScrollbarWidget* w = (struct ScrollbarWidget*)widget;
|
||||||
int posY, height;
|
int posY, height;
|
||||||
|
|
||||||
if (w->draggingId == id) return true;
|
if (w->draggingId == id) return TOUCH_TYPE_GUI;
|
||||||
if (x < w->x || x >= w->x + w->width + w->padding) return false;
|
if (x < w->x || x >= w->x + w->width + w->padding) return false;
|
||||||
/* only intercept pointer that's dragging scrollbar */
|
/* only intercept pointer that's dragging scrollbar */
|
||||||
if (w->draggingId) return false;
|
if (w->draggingId) return false;
|
||||||
@ -320,16 +322,14 @@ static int ScrollbarWidget_PointerDown(void* widget, int id, int x, int y) {
|
|||||||
w->dragOffset = y - posY;
|
w->dragOffset = y - posY;
|
||||||
}
|
}
|
||||||
ScrollbarWidget_ClampTopRow(w);
|
ScrollbarWidget_ClampTopRow(w);
|
||||||
return true;
|
return TOUCH_TYPE_GUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ScrollbarWidget_PointerUp(void* widget, int id, int x, int y) {
|
static void ScrollbarWidget_PointerUp(void* widget, int id, int x, int y) {
|
||||||
struct ScrollbarWidget* w = (struct ScrollbarWidget*)widget;
|
struct ScrollbarWidget* w = (struct ScrollbarWidget*)widget;
|
||||||
if (w->draggingId != id) return true;
|
if (w->draggingId != id) return;
|
||||||
|
|
||||||
w->draggingId = 0;
|
w->draggingId = 0;
|
||||||
w->dragOffset = 0;
|
w->dragOffset = 0;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ScrollbarWidget_MouseScroll(void* widget, float delta) {
|
static int ScrollbarWidget_MouseScroll(void* widget, float delta) {
|
||||||
@ -357,7 +357,7 @@ static int ScrollbarWidget_PointerMove(void* widget, int id, int x, int y) {
|
|||||||
|
|
||||||
static const struct WidgetVTABLE ScrollbarWidget_VTABLE = {
|
static const struct WidgetVTABLE ScrollbarWidget_VTABLE = {
|
||||||
ScrollbarWidget_Render, Widget_NullFunc, Widget_CalcPosition,
|
ScrollbarWidget_Render, Widget_NullFunc, Widget_CalcPosition,
|
||||||
Widget_Key, Widget_Key, ScrollbarWidget_MouseScroll,
|
Widget_InputDown, Widget_InputUp, ScrollbarWidget_MouseScroll,
|
||||||
ScrollbarWidget_PointerDown, ScrollbarWidget_PointerUp, ScrollbarWidget_PointerMove
|
ScrollbarWidget_PointerDown, ScrollbarWidget_PointerUp, ScrollbarWidget_PointerMove
|
||||||
};
|
};
|
||||||
void ScrollbarWidget_Create(struct ScrollbarWidget* w) {
|
void ScrollbarWidget_Create(struct ScrollbarWidget* w) {
|
||||||
@ -490,18 +490,17 @@ static int HotbarWidget_KeyDown(void* widget, int key) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int HotbarWidget_KeyUp(void* widget, int key) {
|
static void HotbarWidget_InputUp(void* widget, int key) {
|
||||||
struct HotbarWidget* w = (struct HotbarWidget*)widget;
|
struct HotbarWidget* w = (struct HotbarWidget*)widget;
|
||||||
/* Need to handle these cases:
|
/* Need to handle these cases:
|
||||||
a) user presses alt then number
|
a) user presses alt then number
|
||||||
b) user presses alt
|
b) user presses alt
|
||||||
We only do case b) if case a) did not happen */
|
We only do case b) if case a) did not happen */
|
||||||
if (key != KeyBinds[KEYBIND_HOTBAR_SWITCH]) return false;
|
if (key != KeyBinds[KEYBIND_HOTBAR_SWITCH]) return;
|
||||||
if (w->altHandled) { w->altHandled = false; return true; } /* handled already */
|
if (w->altHandled) { w->altHandled = false; return; } /* handled already */
|
||||||
|
|
||||||
/* Don't switch hotbar when alt+tabbing to another window */
|
/* Don't switch hotbar when alt+tabbing to another window */
|
||||||
if (WindowInfo.Focused) Inventory_SwitchHotbar();
|
if (WindowInfo.Focused) Inventory_SwitchHotbar();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int HotbarWidget_PointerDown(void* widget, int id, int x, int y) {
|
static int HotbarWidget_PointerDown(void* widget, int id, int x, int y) {
|
||||||
@ -520,11 +519,11 @@ static int HotbarWidget_PointerDown(void* widget, int id, int x, int y) {
|
|||||||
|
|
||||||
#ifdef CC_BUILD_TOUCH
|
#ifdef CC_BUILD_TOUCH
|
||||||
if (i == HOTBAR_MAX_INDEX && Input_TouchMode) {
|
if (i == HOTBAR_MAX_INDEX && Input_TouchMode) {
|
||||||
InventoryScreen_Show(); return true;
|
InventoryScreen_Show(); return TOUCH_TYPE_GUI;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Inventory_SetSelectedIndex(i);
|
Inventory_SetSelectedIndex(i);
|
||||||
return true;
|
return TOUCH_TYPE_GUI;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -555,9 +554,9 @@ static void HotbarWidget_Free(void* widget) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const struct WidgetVTABLE HotbarWidget_VTABLE = {
|
static const struct WidgetVTABLE HotbarWidget_VTABLE = {
|
||||||
HotbarWidget_Render, HotbarWidget_Free, HotbarWidget_Reposition,
|
HotbarWidget_Render, HotbarWidget_Free, HotbarWidget_Reposition,
|
||||||
HotbarWidget_KeyDown, HotbarWidget_KeyUp, HotbarWidget_MouseScroll,
|
HotbarWidget_KeyDown, HotbarWidget_InputUp, HotbarWidget_MouseScroll,
|
||||||
HotbarWidget_PointerDown, Widget_Pointer, Widget_PointerMove
|
HotbarWidget_PointerDown, Widget_PointerUp, Widget_PointerMove
|
||||||
};
|
};
|
||||||
void HotbarWidget_Create(struct HotbarWidget* w) {
|
void HotbarWidget_Create(struct HotbarWidget* w) {
|
||||||
Widget_Reset(w);
|
Widget_Reset(w);
|
||||||
@ -811,20 +810,20 @@ static int TableWidget_PointerDown(void* widget, int id, int x, int y) {
|
|||||||
w->pendingClose = false;
|
w->pendingClose = false;
|
||||||
|
|
||||||
if (Elem_HandlesPointerDown(&w->scroll, id, x, y)) {
|
if (Elem_HandlesPointerDown(&w->scroll, id, x, y)) {
|
||||||
return true;
|
return TOUCH_TYPE_GUI;
|
||||||
} else if (w->selectedIndex != -1 && w->blocks[w->selectedIndex] != BLOCK_AIR) {
|
} else if (w->selectedIndex != -1 && w->blocks[w->selectedIndex] != BLOCK_AIR) {
|
||||||
Inventory_SetSelectedBlock(w->blocks[w->selectedIndex]);
|
Inventory_SetSelectedBlock(w->blocks[w->selectedIndex]);
|
||||||
w->pendingClose = true;
|
w->pendingClose = true;
|
||||||
return true;
|
return TOUCH_TYPE_GUI;
|
||||||
} else if (Gui_Contains(Table_X(w), Table_Y(w), Table_Width(w), Table_Height(w), x, y)) {
|
} else if (Gui_Contains(Table_X(w), Table_Y(w), Table_Width(w), Table_Height(w), x, y)) {
|
||||||
return true;
|
return TOUCH_TYPE_GUI;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int TableWidget_PointerUp(void* widget, int id, int x, int y) {
|
static void TableWidget_PointerUp(void* widget, int id, int x, int y) {
|
||||||
struct TableWidget* w = (struct TableWidget*)widget;
|
struct TableWidget* w = (struct TableWidget*)widget;
|
||||||
return Elem_HandlesPointerUp(&w->scroll, id, x, y);
|
Elem_OnPointerUp(&w->scroll, id, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int TableWidget_MouseScroll(void* widget, float delta) {
|
static int TableWidget_MouseScroll(void* widget, float delta) {
|
||||||
@ -896,7 +895,7 @@ static int TableWidget_KeyDown(void* widget, int key) {
|
|||||||
|
|
||||||
static const struct WidgetVTABLE TableWidget_VTABLE = {
|
static const struct WidgetVTABLE TableWidget_VTABLE = {
|
||||||
TableWidget_Render, TableWidget_Free, TableWidget_Reposition,
|
TableWidget_Render, TableWidget_Free, TableWidget_Reposition,
|
||||||
TableWidget_KeyDown, Widget_Key, TableWidget_MouseScroll,
|
TableWidget_KeyDown, Widget_InputUp, TableWidget_MouseScroll,
|
||||||
TableWidget_PointerDown, TableWidget_PointerUp, TableWidget_PointerMove
|
TableWidget_PointerDown, TableWidget_PointerUp, TableWidget_PointerMove
|
||||||
};
|
};
|
||||||
void TableWidget_Create(struct TableWidget* w) {
|
void TableWidget_Create(struct TableWidget* w) {
|
||||||
@ -1321,7 +1320,7 @@ static int InputWidget_PointerDown(void* widget, int id, int x, int y) {
|
|||||||
if (Gui_Contains(charX, cy * charHeight, charWidth, charHeight, x, y)) {
|
if (Gui_Contains(charX, cy * charHeight, charWidth, charHeight, x, y)) {
|
||||||
w->caretPos = offset + cx;
|
w->caretPos = offset + cx;
|
||||||
InputWidget_UpdateCaret(w);
|
InputWidget_UpdateCaret(w);
|
||||||
return true;
|
return TOUCH_TYPE_GUI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
offset += line.length;
|
offset += line.length;
|
||||||
@ -1329,7 +1328,7 @@ static int InputWidget_PointerDown(void* widget, int id, int x, int y) {
|
|||||||
|
|
||||||
w->caretPos = -1;
|
w->caretPos = -1;
|
||||||
InputWidget_UpdateCaret(w);
|
InputWidget_UpdateCaret(w);
|
||||||
return true;
|
return TOUCH_TYPE_GUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1555,8 +1554,8 @@ static cc_bool TextInputWidget_AllowedChar(void* widget, char c) {
|
|||||||
static int TextInputWidget_GetMaxLines(void) { return 1; }
|
static int TextInputWidget_GetMaxLines(void) { return 1; }
|
||||||
static const struct WidgetVTABLE TextInputWidget_VTABLE = {
|
static const struct WidgetVTABLE TextInputWidget_VTABLE = {
|
||||||
TextInputWidget_Render, InputWidget_Free, InputWidget_Reposition,
|
TextInputWidget_Render, InputWidget_Free, InputWidget_Reposition,
|
||||||
InputWidget_KeyDown, Widget_Key, Widget_MouseScroll,
|
InputWidget_KeyDown, Widget_InputUp, Widget_MouseScroll,
|
||||||
InputWidget_PointerDown, Widget_Pointer, Widget_PointerMove,
|
InputWidget_PointerDown, Widget_PointerUp, Widget_PointerMove,
|
||||||
TextInputWidget_BuildMesh, TextInputWidget_Render2
|
TextInputWidget_BuildMesh, TextInputWidget_Render2
|
||||||
};
|
};
|
||||||
void TextInputWidget_Create(struct TextInputWidget* w, int width, const cc_string* text, struct MenuInputDesc* desc) {
|
void TextInputWidget_Create(struct TextInputWidget* w, int width, const cc_string* text, struct MenuInputDesc* desc) {
|
||||||
@ -1818,8 +1817,8 @@ static int ChatInputWidget_GetMaxLines(void) {
|
|||||||
|
|
||||||
static const struct WidgetVTABLE ChatInputWidget_VTABLE = {
|
static const struct WidgetVTABLE ChatInputWidget_VTABLE = {
|
||||||
ChatInputWidget_Render, InputWidget_Free, InputWidget_Reposition,
|
ChatInputWidget_Render, InputWidget_Free, InputWidget_Reposition,
|
||||||
ChatInputWidget_KeyDown, Widget_Key, Widget_MouseScroll,
|
ChatInputWidget_KeyDown, Widget_InputUp, Widget_MouseScroll,
|
||||||
InputWidget_PointerDown, Widget_Pointer, Widget_PointerMove
|
InputWidget_PointerDown, Widget_PointerUp, Widget_PointerMove
|
||||||
};
|
};
|
||||||
void ChatInputWidget_Create(struct ChatInputWidget* w) {
|
void ChatInputWidget_Create(struct ChatInputWidget* w) {
|
||||||
InputWidget_Reset(&w->base);
|
InputWidget_Reset(&w->base);
|
||||||
@ -2233,8 +2232,8 @@ static void TextGroupWidget_Free(void* widget) {
|
|||||||
|
|
||||||
static const struct WidgetVTABLE TextGroupWidget_VTABLE = {
|
static const struct WidgetVTABLE TextGroupWidget_VTABLE = {
|
||||||
TextGroupWidget_Render, TextGroupWidget_Free, TextGroupWidget_Reposition,
|
TextGroupWidget_Render, TextGroupWidget_Free, TextGroupWidget_Reposition,
|
||||||
Widget_Key, Widget_Key, Widget_MouseScroll,
|
Widget_InputDown, Widget_InputUp, Widget_MouseScroll,
|
||||||
Widget_Pointer, Widget_Pointer, Widget_PointerMove
|
Widget_Pointer, Widget_PointerUp, Widget_PointerMove
|
||||||
};
|
};
|
||||||
void TextGroupWidget_Create(struct TextGroupWidget* w, int lines, struct Texture* textures, TextGroupWidget_Get getLine) {
|
void TextGroupWidget_Create(struct TextGroupWidget* w, int lines, struct Texture* textures, TextGroupWidget_Get getLine) {
|
||||||
Widget_Reset(w);
|
Widget_Reset(w);
|
||||||
@ -2460,7 +2459,7 @@ static int SpecialInputWidget_PointerDown(void* widget, int id, int x, int y) {
|
|||||||
} else {
|
} else {
|
||||||
SpecialInputWidget_IntersectsBody(w, x, y);
|
SpecialInputWidget_IntersectsBody(w, x, y);
|
||||||
}
|
}
|
||||||
return true;
|
return TOUCH_TYPE_GUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpecialInputWidget_UpdateCols(struct SpecialInputWidget* w) {
|
void SpecialInputWidget_UpdateCols(struct SpecialInputWidget* w) {
|
||||||
@ -2481,8 +2480,8 @@ void SpecialInputWidget_SetActive(struct SpecialInputWidget* w, cc_bool active)
|
|||||||
|
|
||||||
static const struct WidgetVTABLE SpecialInputWidget_VTABLE = {
|
static const struct WidgetVTABLE SpecialInputWidget_VTABLE = {
|
||||||
SpecialInputWidget_Render, SpecialInputWidget_Free, SpecialInputWidget_Reposition,
|
SpecialInputWidget_Render, SpecialInputWidget_Free, SpecialInputWidget_Reposition,
|
||||||
Widget_Key, Widget_Key, Widget_MouseScroll,
|
Widget_InputDown, Widget_InputUp, Widget_MouseScroll,
|
||||||
SpecialInputWidget_PointerDown, Widget_Pointer, Widget_PointerMove
|
SpecialInputWidget_PointerDown, Widget_PointerUp, Widget_PointerMove
|
||||||
};
|
};
|
||||||
void SpecialInputWidget_Create(struct SpecialInputWidget* w, struct FontDesc* font, struct InputWidget* target) {
|
void SpecialInputWidget_Create(struct SpecialInputWidget* w, struct FontDesc* font, struct InputWidget* target) {
|
||||||
Widget_Reset(w);
|
Widget_Reset(w);
|
||||||
@ -2592,8 +2591,8 @@ static void ThumbstickWidget_Reposition(void* widget) {
|
|||||||
|
|
||||||
static const struct WidgetVTABLE ThumbstickWidget_VTABLE = {
|
static const struct WidgetVTABLE ThumbstickWidget_VTABLE = {
|
||||||
NULL, Screen_NullFunc, ThumbstickWidget_Reposition,
|
NULL, Screen_NullFunc, ThumbstickWidget_Reposition,
|
||||||
Widget_Key, Widget_Key, Widget_MouseScroll,
|
Widget_InputDown, Widget_InputUp, Widget_MouseScroll,
|
||||||
Widget_Pointer, Widget_Pointer, Widget_PointerMove,
|
Widget_Pointer, Widget_PointerUp, Widget_PointerMove,
|
||||||
ThumbstickWidget_BuildMesh, ThumbstickWidget_Render2
|
ThumbstickWidget_BuildMesh, ThumbstickWidget_Render2
|
||||||
};
|
};
|
||||||
void ThumbstickWidget_Init(struct ThumbstickWidget* w) {
|
void ThumbstickWidget_Init(struct ThumbstickWidget* w) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user