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