From 2bad5217a4fca1a9b851c8ec813521b7e5fa2469 Mon Sep 17 00:00:00 2001 From: Bucky21659 Date: Thu, 20 Dec 2018 12:00:50 -0700 Subject: [PATCH] Center mouse cursor on main menu+right clicking closes server info window --- codemp/cgame/cg_view.c | 12 ++++++------ codemp/ui/ui_main.c | 5 +++++ codemp/ui/ui_shared.c | 25 +++++++++++++++++-------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/codemp/cgame/cg_view.c b/codemp/cgame/cg_view.c index 9646f312e6..52f71f0b08 100644 --- a/codemp/cgame/cg_view.c +++ b/codemp/cgame/cg_view.c @@ -476,10 +476,10 @@ static void CG_ResetThirdPersonViewDamp(void) VectorCopy(trace.endpos, cameraCurLoc); } - if (cg_smoothCamera.integer != 1) - cameraLastFrame = cg.predictedPlayerState.commandTime; - else + if (cg_smoothCamera.integer != 2) cameraLastFrame = cg.time; + else + cameraLastFrame = cg.predictedPlayerState.commandTime; cameraLastYaw = cameraFocusAngles[YAW]; cameraStiffFactor = 0.0f; @@ -872,10 +872,10 @@ static void CG_OffsetThirdPersonView( void ) // ...and of course we should copy the new view location to the proper spot too. VectorCopy(cameraCurLoc, cg.refdef.vieworg); - if (cg_smoothCamera.integer != 1) - cameraLastFrame = cg.predictedPlayerState.commandTime; - else + if (cg_smoothCamera.integer != 2) cameraLastFrame = cg.time; + else + cameraLastFrame = cg.predictedPlayerState.commandTime; } void CG_GetVehicleCamPos( vec3_t camPos ) diff --git a/codemp/ui/ui_main.c b/codemp/ui/ui_main.c index 7313f5161f..af445eb246 100644 --- a/codemp/ui/ui_main.c +++ b/codemp/ui/ui_main.c @@ -11400,6 +11400,11 @@ void UI_Init( qboolean inGameLoad ) { trap->ext.AddCommand("strafehelper"); trap->ext.AddCommand("stylePlayer"); trap->ext.AddCommand("speedometer"); + + //Center cursor + uiInfo.uiDC.cursorx = SCREEN_WIDTH / 2; + uiInfo.uiDC.cursory = (SCREEN_HEIGHT / 2); + } #define UI_FPS_FRAMES 4 diff --git a/codemp/ui/ui_shared.c b/codemp/ui/ui_shared.c index 1230604668..bd2b1011c8 100644 --- a/codemp/ui/ui_shared.c +++ b/codemp/ui/ui_shared.c @@ -4352,21 +4352,19 @@ void Menu_HandleKey(menuDef_t *menu, int key, qboolean down) { case A_CURSOR_UP: Menu_SetPrevCursorItem(menu); break; - case A_ESCAPE: if (!g_waitingForKey && menu->onESC) { itemDef_t it; - it.parent = menu; - Item_RunScript(&it, menu->onESC); + it.parent = menu; + Item_RunScript(&it, menu->onESC); } - g_waitingForKey = qfalse; + g_waitingForKey = qfalse; break; case A_TAB: case A_KP_2: case A_CURSOR_DOWN: Menu_SetNextCursorItem(menu); break; - case A_MOUSE1: case A_MOUSE2: if (item) { @@ -4375,7 +4373,9 @@ void Menu_HandleKey(menuDef_t *menu, int key, qboolean down) { { Item_Action(item); } - } else if (item->type == ITEM_TYPE_EDITFIELD || item->type == ITEM_TYPE_NUMERICFIELD) { + break; + } + if (item->type == ITEM_TYPE_EDITFIELD || item->type == ITEM_TYPE_NUMERICFIELD) { if (Rect_ContainsPoint(&item->window.rect, DC->cursorx, DC->cursory)) { Item_Action(item); @@ -4384,6 +4384,7 @@ void Menu_HandleKey(menuDef_t *menu, int key, qboolean down) { g_editItem = item; //DC->setOverstrikeMode(qtrue); } + break; } //JLFACCEPT @@ -4396,7 +4397,7 @@ void Menu_HandleKey(menuDef_t *menu, int key, qboolean down) { */ //JLFACCEPT MPMOVED - else if ( item->type == ITEM_TYPE_MULTI || item->type == ITEM_TYPE_YESNO || item->type == ITEM_TYPE_SLIDER || item->type == ITEM_TYPE_INTSLIDER) + if ( item->type == ITEM_TYPE_MULTI || item->type == ITEM_TYPE_YESNO || item->type == ITEM_TYPE_SLIDER || item->type == ITEM_TYPE_INTSLIDER) { if (Item_HandleAccept(item)) { @@ -4409,14 +4410,22 @@ void Menu_HandleKey(menuDef_t *menu, int key, qboolean down) { it.parent = menu; Item_RunScript(&it, menu->onAccept); } + break; } //END JLFACCEPT + if (key == A_MOUSE2 && !g_waitingForKey && !item->action && menu->onESC) { + itemDef_t it; + it.parent = menu; + Item_RunScript(&it, menu->onESC); + g_waitingForKey = qfalse; + break; + } else { if (Rect_ContainsPoint(&item->window.rect, DC->cursorx, DC->cursory)) { - Item_Action(item); } + break; } } break;