Skip to content

Commit

Permalink
port: fix mouse controls in combat sim keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsfdsfgs committed May 31, 2024
1 parent 07e6fdc commit b523b1e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/game/menuitem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ bool menuitemKeyboardTick(struct menuitem *item, struct menuinputs *inputs, u32
if (dialog && g_MenuUsingMouse && !inputs->leftright && !inputs->updown) {
const s32 dleft = dialog->x + 4;
const s32 dright = dleft + 12 * 10;
const s32 dtop = dialog->y + 13 + 12;
const s32 dtop = menuitemGetTop(item, dialog) + 12;
const s32 dbottom = dtop + 11 * 5;
const s32 mx = inputs->mousex;
const s32 my = inputs->mousey;
Expand Down Expand Up @@ -4514,3 +4514,28 @@ Gfx *menuitemOverlay(Gfx *gdl, s16 x, s16 y, s16 x2, s16 y2, struct menuitem *it

return gdl;
}

#ifndef PLATFORM_N64

s32 menuitemGetTop(struct menuitem *item, struct menudialog *dialog)
{
struct menu *menu = &g_Menus[g_MpPlayerNum];
s32 dtop = dialog->y + LINEHEIGHT + 1;

for (s32 i = 0; i < dialog->numcols; ++i) {
const s32 colindex = i + dialog->colstart;

for (s32 j = 0; j < menu->cols[colindex].numrows; ++j) {
const s32 rowindex = j + menu->cols[colindex].rowstart;
struct menuitem *pitem = &dialog->definition->items[menu->rows[rowindex].itemindex];
if (pitem == item) {
return dtop;
}
dtop += menu->rows[rowindex].height;
}
}

return dtop;
}

#endif
4 changes: 4 additions & 0 deletions src/include/game/menuitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,8 @@ bool menuitemTick(struct menuitem *item, struct menudialog *dialog, struct menui
void menuitemInit(struct menuitem *item, union menuitemdata *data);
Gfx *menuitemOverlay(Gfx *gdl, s16 x, s16 y, s16 x2, s16 y2, struct menuitem *item, struct menudialog *dialog, union menuitemdata *data);

#ifndef PLATFORM_N64
s32 menuitemGetTop(struct menuitem *item, struct menudialog *dialog);
#endif

#endif

0 comments on commit b523b1e

Please sign in to comment.