mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-20 18:37:48 -04:00
menu mouse cursor improvements
* Restore mouse mode after interacting with setup menu items * Move mouse cursor to lower right corner after releasing mouse after grabbing
This commit is contained in:
parent
39fc6ccec3
commit
fb984ea390
@ -200,33 +200,20 @@ static void UpdateGrab(void)
|
||||
|
||||
if (!grab && currently_grabbed)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
SetShowCursor(true);
|
||||
|
||||
SDL_GetWindowSize(screen, &w, &h);
|
||||
SDL_WarpMouseInWindow(screen, 3 * w / 4, 4 * h / 5);
|
||||
}
|
||||
|
||||
currently_grabbed = grab;
|
||||
}
|
||||
|
||||
void I_ShowMouseCursor(boolean on)
|
||||
void I_ShowMouseCursor(boolean toggle)
|
||||
{
|
||||
static boolean state = true;
|
||||
|
||||
if (state == on)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
state = on;
|
||||
}
|
||||
|
||||
if (on)
|
||||
{
|
||||
int w, h;
|
||||
SDL_GetWindowSize(screen, &w, &h);
|
||||
SDL_WarpMouseInWindow(screen, w / 2, h / 2);
|
||||
}
|
||||
|
||||
SDL_ShowCursor(on);
|
||||
SDL_ShowCursor(toggle);
|
||||
}
|
||||
|
||||
void I_ResetRelativeMouseState(void)
|
||||
|
@ -109,7 +109,7 @@ void *I_GetSDLRenderer(void);
|
||||
|
||||
void I_InitWindowIcon(void);
|
||||
|
||||
void I_ShowMouseCursor(boolean on);
|
||||
void I_ShowMouseCursor(boolean toggle);
|
||||
void I_ResetRelativeMouseState(void);
|
||||
|
||||
#endif
|
||||
|
@ -2327,7 +2327,7 @@ static boolean ShortcutResponder(const event_t *ev)
|
||||
return false;
|
||||
}
|
||||
|
||||
menu_input_mode_t menu_input;
|
||||
menu_input_mode_t menu_input, old_menu_input;
|
||||
|
||||
static int mouse_state_x, mouse_state_y;
|
||||
|
||||
@ -2442,6 +2442,23 @@ static boolean SaveLoadResponder(menu_action_t action, int ch)
|
||||
return false;
|
||||
}
|
||||
|
||||
void MN_ResetMouseCursor(void)
|
||||
{
|
||||
static boolean state;
|
||||
|
||||
if (menu_input == mouse_mode && !state)
|
||||
{
|
||||
state = true;
|
||||
I_ShowMouseCursor(true);
|
||||
}
|
||||
else if (menu_input != mouse_mode && state)
|
||||
{
|
||||
state = false;
|
||||
ClearHighlightedItems();
|
||||
I_ShowMouseCursor(false);
|
||||
}
|
||||
}
|
||||
|
||||
static boolean MouseResponder(void)
|
||||
{
|
||||
if (!menuactive || messageToPrint)
|
||||
@ -2449,7 +2466,7 @@ static boolean MouseResponder(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
I_ShowMouseCursor(true);
|
||||
MN_ResetMouseCursor();
|
||||
|
||||
if (setup_active)
|
||||
{
|
||||
@ -2533,6 +2550,8 @@ boolean M_Responder(event_t *ev)
|
||||
static menu_action_t repeat = MENU_NULL;
|
||||
menu_action_t action = MENU_NULL;
|
||||
|
||||
old_menu_input = menu_input;
|
||||
|
||||
ch = 0; // will be changed to a legit char if we're going to use it here
|
||||
|
||||
switch (ev->type)
|
||||
@ -2581,10 +2600,6 @@ boolean M_Responder(event_t *ev)
|
||||
return false;
|
||||
|
||||
case ev_keydown:
|
||||
if (menu_input == mouse_mode && M_InputActivated(input_menu_escape))
|
||||
{
|
||||
break;
|
||||
}
|
||||
menu_input = key_mode;
|
||||
ch = ev->data1;
|
||||
break;
|
||||
@ -2619,19 +2634,6 @@ boolean M_Responder(event_t *ev)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (menuactive)
|
||||
{
|
||||
if (menu_input == mouse_mode)
|
||||
{
|
||||
I_ShowMouseCursor(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearHighlightedItems();
|
||||
I_ShowMouseCursor(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (M_InputActivated(input_menu_up))
|
||||
{
|
||||
action = MENU_UP;
|
||||
@ -2791,6 +2793,11 @@ boolean M_Responder(event_t *ev)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (menuactive)
|
||||
{
|
||||
MN_ResetMouseCursor();
|
||||
}
|
||||
|
||||
// From here on, these navigation keys are used on the BIG FONT menus
|
||||
// like the Main Menu.
|
||||
|
||||
@ -2885,6 +2892,8 @@ boolean M_Responder(event_t *ev)
|
||||
}
|
||||
MN_ClearMenus();
|
||||
M_StartSound(sfx_swtchx);
|
||||
menu_input = old_menu_input;
|
||||
MN_ResetMouseCursor();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2925,6 +2934,8 @@ boolean M_Responder(event_t *ev)
|
||||
MN_ClearMenus();
|
||||
M_StartSound(sfx_swtchx);
|
||||
}
|
||||
menu_input = old_menu_input;
|
||||
MN_ResetMouseCursor();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3058,6 +3058,8 @@ static boolean ChangeEntry(menu_action_t action, int ch)
|
||||
|
||||
SelectDone(current_item); // phares 4/17/98
|
||||
setup_gather = false; // finished gathering keys, if any
|
||||
menu_input = old_menu_input;
|
||||
MN_ResetMouseCursor();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3090,6 +3092,9 @@ static boolean ChangeEntry(menu_action_t action, int ch)
|
||||
// allow backspace, and return to original value if bad
|
||||
// value is entered).
|
||||
|
||||
menu_input = old_menu_input;
|
||||
MN_ResetMouseCursor();
|
||||
|
||||
if (action == MENU_ENTER)
|
||||
{
|
||||
if (gather_count) // Any input?
|
||||
@ -3162,6 +3167,9 @@ static boolean BindInput(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
menu_input = old_menu_input;
|
||||
MN_ResetMouseCursor();
|
||||
|
||||
setup_menu_t *current_item = current_menu + set_item_on;
|
||||
|
||||
int input_id =
|
||||
@ -3281,7 +3289,8 @@ boolean MN_SetupResponder(menu_action_t action, int ch)
|
||||
current_menu[highlight_item].m_flags &= ~S_HILITE;
|
||||
}
|
||||
|
||||
setup_menu_t *current_item = current_menu + set_item_on;
|
||||
int index = (old_menu_input == mouse_mode ? highlight_item : set_item_on);
|
||||
setup_menu_t *current_item = current_menu + index;
|
||||
|
||||
// phares 4/19/98:
|
||||
// Catch the response to the 'reset to default?' verification
|
||||
@ -3354,6 +3363,8 @@ boolean MN_SetupResponder(menu_action_t action, int ch)
|
||||
}
|
||||
|
||||
SelectDone(current_item); // phares 4/17/98
|
||||
menu_input = old_menu_input;
|
||||
MN_ResetMouseCursor();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,9 @@ typedef enum
|
||||
key_mode
|
||||
} menu_input_mode_t;
|
||||
|
||||
extern menu_input_mode_t menu_input;
|
||||
extern menu_input_mode_t menu_input, old_menu_input;
|
||||
void MN_ResetMouseCursor(void);
|
||||
|
||||
extern boolean setup_active;
|
||||
extern short whichSkull; // which skull to draw (he blinks)
|
||||
extern int saved_screenblocks;
|
||||
|
Loading…
x
Reference in New Issue
Block a user