From 2ba192d411f77526870977c350b2e27e392d2f4c Mon Sep 17 00:00:00 2001 From: fgsfds Date: Tue, 14 May 2024 22:53:02 +0200 Subject: [PATCH] port: make menu mouse flag global --- src/game/menu.c | 17 +++++++---------- src/game/menuitem.c | 2 +- src/include/data.h | 2 ++ src/include/types.h | 3 --- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/game/menu.c b/src/game/menu.c index f660a8bbf..e91aa5687 100644 --- a/src/game/menu.c +++ b/src/game/menu.c @@ -139,6 +139,7 @@ s32 g_MpPlayerNum = 0; #ifndef PLATFORM_N64 s32 g_MenuMouseControl = true; +s32 g_MenuUsingMouse = false; #endif void menuPlaySound(s32 menusound) @@ -1362,7 +1363,7 @@ bool dialogChangeItemFocusWithMouse(struct menudialog *dialog, s32 mx, s32 my) s32 colwidth = 0; // only allow mouse control of player 1 menus; ignore mouse if navigating with keyboard - if (menu->playernum != 0 || !dialog->usingmouse) { + if (menu->playernum != 0 || !g_MenuUsingMouse) { return false; } @@ -1501,10 +1502,6 @@ void menuOpenDialog(struct menudialogdef *dialogdef, struct menudialog *dialog, dialog->y = dialog->dsty; dialog->width = dialog->dstwidth; dialog->height = dialog->dstheight; - -#ifndef PLATFORM_N64 - dialog->usingmouse = false; -#endif } void menuPushDialog(struct menudialogdef *dialogdef) @@ -4511,7 +4508,7 @@ void dialogTick(struct menudialog *dialog, struct menuinputs *inputs, u32 tickfl if ((dialog->focuseditem->flags & MENUITEMFLAG_00010000) == 0) { #ifndef PLATFORM_N64 - if (dialog->usingmouse) { + if (g_MenuUsingMouse) { dstscroll = dialog->dstscroll - inputs->mousescroll * LINEHEIGHT; } else #endif @@ -4683,7 +4680,7 @@ void menuProcessInput(void) inputs.mousex = (f32)(SCREEN_WIDTH_LO / 2) + cx; } if (dialog && inputs.mousemoved) { - dialog->usingmouse = true; + g_MenuUsingMouse = true; } } #endif @@ -4750,7 +4747,7 @@ void menuProcessInput(void) } // don't back out on weapon back when using mouse because it's likely bound to wheel - if (!dialog->usingmouse && (buttonsnow & BUTTON_WPNBACK)) { + if (!g_MenuUsingMouse && (buttonsnow & BUTTON_WPNBACK)) { inputs.back = 1; } #endif @@ -5096,10 +5093,10 @@ void menuProcessInput(void) #ifndef PLATFORM_N64 // if we haven't been using the mouse but we have been keyboard scrolling disable the mouse if (!inputs.mousemoved && (inputs.leftright || inputs.updown || inputs.leftrightheld || inputs.updownheld)) { - dialog->usingmouse = false; + g_MenuUsingMouse = false; } // otherwise rotate left/right by clicking on the side of the menu - if (dialog->usingmouse && inputs.select && !inputs.leftright && !inputs.leftrightheld) { + if (g_MenuUsingMouse && inputs.select && !inputs.leftright && !inputs.leftrightheld) { if (inputs.mousey > dialog->y && inputs.mousey < dialog->y + dialog->height) { if (inputs.mousex < dialog->x) { inputs.leftright = -1; diff --git a/src/game/menuitem.c b/src/game/menuitem.c index 6f585b75b..d64706f15 100644 --- a/src/game/menuitem.c +++ b/src/game/menuitem.c @@ -1369,7 +1369,7 @@ bool menuitemKeyboardTick(struct menuitem *item, struct menuinputs *inputs, u32 #ifndef PLATFORM_N64 // handle mouse struct menudialog *dialog = g_Menus[g_MpPlayerNum].curdialog; - if (dialog && dialog->usingmouse && !inputs->leftright && !inputs->updown) { + 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; diff --git a/src/include/data.h b/src/include/data.h index 853dbd622..24c106292 100644 --- a/src/include/data.h +++ b/src/include/data.h @@ -537,6 +537,8 @@ extern struct weathercfg g_WeatherConfig[WEATHERCFG_MAX_STAGES]; extern const struct weathercfg g_DefaultWeatherConfig; extern const struct weathercfg *g_CurWeatherConfig; +extern s32 g_MenuUsingMouse; + extern f32 g_ViShakeIntensityMult; extern u32 g_TexFilter2D; extern s32 g_HudCenter; diff --git a/src/include/types.h b/src/include/types.h index 57f018b7a..496d002c4 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -3739,9 +3739,6 @@ struct menudialog { /*0x6c*/ u8 unk6c; /*0x6d*/ s8 swipedir; /*0x6e*/ u8 unk6e; -#ifndef PLATFORM_N64 - /*0x6f*/ u8 usingmouse; -#endif }; struct menudfc {