Skip to content

Commit 2bad521

Browse files
committed
Center mouse cursor on main menu+right clicking closes server info window
1 parent 0d8f644 commit 2bad521

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

codemp/cgame/cg_view.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -476,10 +476,10 @@ static void CG_ResetThirdPersonViewDamp(void)
476476
VectorCopy(trace.endpos, cameraCurLoc);
477477
}
478478

479-
if (cg_smoothCamera.integer != 1)
480-
cameraLastFrame = cg.predictedPlayerState.commandTime;
481-
else
479+
if (cg_smoothCamera.integer != 2)
482480
cameraLastFrame = cg.time;
481+
else
482+
cameraLastFrame = cg.predictedPlayerState.commandTime;
483483

484484
cameraLastYaw = cameraFocusAngles[YAW];
485485
cameraStiffFactor = 0.0f;
@@ -872,10 +872,10 @@ static void CG_OffsetThirdPersonView( void )
872872
// ...and of course we should copy the new view location to the proper spot too.
873873
VectorCopy(cameraCurLoc, cg.refdef.vieworg);
874874

875-
if (cg_smoothCamera.integer != 1)
876-
cameraLastFrame = cg.predictedPlayerState.commandTime;
877-
else
875+
if (cg_smoothCamera.integer != 2)
878876
cameraLastFrame = cg.time;
877+
else
878+
cameraLastFrame = cg.predictedPlayerState.commandTime;
879879
}
880880

881881
void CG_GetVehicleCamPos( vec3_t camPos )

codemp/ui/ui_main.c

+5
Original file line numberDiff line numberDiff line change
@@ -11400,6 +11400,11 @@ void UI_Init( qboolean inGameLoad ) {
1140011400
trap->ext.AddCommand("strafehelper");
1140111401
trap->ext.AddCommand("stylePlayer");
1140211402
trap->ext.AddCommand("speedometer");
11403+
11404+
//Center cursor
11405+
uiInfo.uiDC.cursorx = SCREEN_WIDTH / 2;
11406+
uiInfo.uiDC.cursory = (SCREEN_HEIGHT / 2);
11407+
1140311408
}
1140411409

1140511410
#define UI_FPS_FRAMES 4

codemp/ui/ui_shared.c

+17-8
Original file line numberDiff line numberDiff line change
@@ -4352,21 +4352,19 @@ void Menu_HandleKey(menuDef_t *menu, int key, qboolean down) {
43524352
case A_CURSOR_UP:
43534353
Menu_SetPrevCursorItem(menu);
43544354
break;
4355-
43564355
case A_ESCAPE:
43574356
if (!g_waitingForKey && menu->onESC) {
43584357
itemDef_t it;
4359-
it.parent = menu;
4360-
Item_RunScript(&it, menu->onESC);
4358+
it.parent = menu;
4359+
Item_RunScript(&it, menu->onESC);
43614360
}
4362-
g_waitingForKey = qfalse;
4361+
g_waitingForKey = qfalse;
43634362
break;
43644363
case A_TAB:
43654364
case A_KP_2:
43664365
case A_CURSOR_DOWN:
43674366
Menu_SetNextCursorItem(menu);
43684367
break;
4369-
43704368
case A_MOUSE1:
43714369
case A_MOUSE2:
43724370
if (item) {
@@ -4375,7 +4373,9 @@ void Menu_HandleKey(menuDef_t *menu, int key, qboolean down) {
43754373
{
43764374
Item_Action(item);
43774375
}
4378-
} else if (item->type == ITEM_TYPE_EDITFIELD || item->type == ITEM_TYPE_NUMERICFIELD) {
4376+
break;
4377+
}
4378+
if (item->type == ITEM_TYPE_EDITFIELD || item->type == ITEM_TYPE_NUMERICFIELD) {
43794379
if (Rect_ContainsPoint(&item->window.rect, DC->cursorx, DC->cursory))
43804380
{
43814381
Item_Action(item);
@@ -4384,6 +4384,7 @@ void Menu_HandleKey(menuDef_t *menu, int key, qboolean down) {
43844384
g_editItem = item;
43854385
//DC->setOverstrikeMode(qtrue);
43864386
}
4387+
break;
43874388
}
43884389

43894390
//JLFACCEPT
@@ -4396,7 +4397,7 @@ void Menu_HandleKey(menuDef_t *menu, int key, qboolean down) {
43964397
*/
43974398

43984399
//JLFACCEPT MPMOVED
4399-
else if ( item->type == ITEM_TYPE_MULTI || item->type == ITEM_TYPE_YESNO || item->type == ITEM_TYPE_SLIDER || item->type == ITEM_TYPE_INTSLIDER)
4400+
if ( item->type == ITEM_TYPE_MULTI || item->type == ITEM_TYPE_YESNO || item->type == ITEM_TYPE_SLIDER || item->type == ITEM_TYPE_INTSLIDER)
44004401
{
44014402
if (Item_HandleAccept(item))
44024403
{
@@ -4409,14 +4410,22 @@ void Menu_HandleKey(menuDef_t *menu, int key, qboolean down) {
44094410
it.parent = menu;
44104411
Item_RunScript(&it, menu->onAccept);
44114412
}
4413+
break;
44124414
}
44134415
//END JLFACCEPT
4416+
if (key == A_MOUSE2 && !g_waitingForKey && !item->action && menu->onESC) {
4417+
itemDef_t it;
4418+
it.parent = menu;
4419+
Item_RunScript(&it, menu->onESC);
4420+
g_waitingForKey = qfalse;
4421+
break;
4422+
}
44144423
else {
44154424
if (Rect_ContainsPoint(&item->window.rect, DC->cursorx, DC->cursory))
44164425
{
4417-
44184426
Item_Action(item);
44194427
}
4428+
break;
44204429
}
44214430
}
44224431
break;

0 commit comments

Comments
 (0)