diff --git a/src/Drawer2D.c b/src/Drawer2D.c index d6a8f0b1d..f353c242a 100644 --- a/src/Drawer2D.c +++ b/src/Drawer2D.c @@ -736,13 +736,13 @@ String Font_Lookup(const String* fontName, int style) { String str = String_FromConst("-----"); return str; } -ReturnCode Font_Make(FontDesc* desc, const String* fontName, int size, int style) { +ReturnCode Font_Make(struct FontDesc* desc, const String* fontName, int size, int style) { desc->size = size; desc->style = style; desc->height = 0; return 0; } -void Font_Free(FontDesc* desc) { +void Font_Free(struct FontDesc* desc) { desc->size = 0; desc->style = 0; } diff --git a/src/Gui.c b/src/Gui.c index b3c454c72..7a6fba852 100644 --- a/src/Gui.c +++ b/src/Gui.c @@ -70,6 +70,16 @@ bool Gui_Contains(int recX, int recY, int width, int height, int x, int y) { return x >= recX && y >= recY && x < (recX + width) && y < (recY + height); } +bool Gui_ContainsPointers(int x, int y, int width, int height) { + int i, px, py; + for (i = 0; i < Pointers_Count; i++) { + px = Pointers[i].x; py = Pointers[i].y; + + if (px >= x && py >= y && px < (x + width) && py < (y + height)) return true; + } + return false; +} + void Gui_ShowDefault(void) { StatusScreen_Show(); HUDScreen_Show(); diff --git a/src/Gui.h b/src/Gui.h index c3f1af4e2..62cdc1fd6 100644 --- a/src/Gui.h +++ b/src/Gui.h @@ -117,6 +117,8 @@ extern int Gui_ScreensCount; int Gui_CalcPos(cc_uint8 anchor, int offset, int size, int axisLen); /* Returns whether the given rectangle contains the given point. */ bool Gui_Contains(int recX, int recY, int width, int height, int x, int y); +/* Returns whether one or more pointers lie within the given rectangle. */ +bool Gui_ContainsPointers(int x, int y, int width, int height); /* Shows HUD and Status screens. */ void Gui_ShowDefault(void); diff --git a/src/Input.h b/src/Input.h index 37e7c37a0..676df0a42 100644 --- a/src/Input.h +++ b/src/Input.h @@ -78,9 +78,7 @@ extern float Mouse_Wheel; #define Pointers_Count 1 /* 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]; /* X and Y coordinates of the mouse. Use Mouse_SetPosition to change. */ extern int Mouse_X, Mouse_Y; diff --git a/src/Widgets.c b/src/Widgets.c index 887e47cea..3b22a2d21 100644 --- a/src/Widgets.c +++ b/src/Widgets.c @@ -226,7 +226,7 @@ static void ScrollbarWidget_Render(void* widget, double delta) { x += SCROLL_BORDER; y += w->y; width -= SCROLL_BORDER * 2; - hovered = Gui_Contains(x, y, width, height, Mouse_X, Mouse_Y); + hovered = Gui_ContainsPointers(x, y, width, height); barCol = hovered ? Scroll_HoverCol : Scroll_BarCol; Gfx_Draw2DFlat(x, y, width, height, barCol); @@ -729,8 +729,8 @@ static bool TableWidget_MouseScroll(void* widget, float delta) { struct TableWidget* w = (struct TableWidget*)widget; int origTopRow, index; - bool bounds = Gui_Contains(Table_X(w), Table_Y(w), - Table_Width(w) + w->scroll.width, Table_Height(w), Mouse_X, Mouse_Y); + bool bounds = Gui_ContainsPointers(Table_X(w), Table_Y(w), + Table_Width(w) + w->scroll.width, Table_Height(w)); if (!bounds) return false; origTopRow = w->scroll.topRow; @@ -805,7 +805,7 @@ void TableWidget_Create(struct TableWidget* w) { w->horAnchor = ANCHOR_CENTRE; w->verAnchor = ANCHOR_CENTRE; - w->lastX = Mouse_X; w->lastY = Mouse_Y; + w->lastX = -20; w->lastY = -20; } void TableWidget_SetBlockTo(struct TableWidget* w, BlockID block) { @@ -2063,7 +2063,7 @@ static void PlayerListWidget_Render(void* widget, double delta) { struct TextWidget* title = &w->title; struct Texture tex; int offset, height; - int i, selectedI; + int i; PackedCol topCol = PACKEDCOL_CONST( 0, 0, 0, 180); PackedCol bottomCol = PACKEDCOL_CONST(50, 50, 50, 205); @@ -2077,12 +2077,13 @@ static void PlayerListWidget_Render(void* widget, double delta) { Widget_Reposition(title); Elem_Render(title, delta); - selectedI = PlayerListWidget_HighlightedName(w, Mouse_X, Mouse_Y); for (i = 0; i < w->namesCount; i++) { if (!w->textures[i].ID) continue; - tex = w->textures[i]; - if (i == selectedI) tex.X += 4; + + if (w->ids[i] != GROUP_NAME_ID) { + if (Gui_ContainsPointers(tex.X, tex.Y, tex.Width, tex.Height)) tex.X += 4; + } Texture_Render(&tex); } } diff --git a/src/Window.c b/src/Window.c index 13d743c3d..3ea24cb8a 100644 --- a/src/Window.c +++ b/src/Window.c @@ -2731,7 +2731,7 @@ void Window_ProcessEvents(void) { } /* Not needed because browser provides relative mouse and touch events */ static void Cursor_GetRawPos(int* x, int* y) { *x = 0; *y = 0; } /* Not allowed to move cursor from javascript */ -void Cursor_SetPosition(int x, int y) { Mouse_X = x; Mouse_Y = y; } +void Cursor_SetPosition(int x, int y) { } void Cursor_SetVisible(bool visible) { if (visible) { @@ -3026,9 +3026,9 @@ void Window_ProcessEvents(void) { JavaCallVoid(env, "processEvents", "()V", NULL); } -/* No actual cursor, so just fake one */ +/* No actual mouse cursor */ static void Cursor_GetRawPos(int* x, int* y) { *x = 0; *y = 0; } -void Cursor_SetPosition(int x, int y) { Mouse_X = x; Mouse_Y = y; } +void Cursor_SetPosition(int x, int y) { } void Cursor_SetVisible(bool visible) { } void Window_ShowDialog(const char* title, const char* msg) {