Skip to content

Commit

Permalink
Center mouse cursor on main menu+right clicking closes server info wi…
Browse files Browse the repository at this point in the history
…ndow
  • Loading branch information
Bucky21659 committed Dec 20, 2018
1 parent 0d8f644 commit 2bad521
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
12 changes: 6 additions & 6 deletions codemp/cgame/cg_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 )
Expand Down
5 changes: 5 additions & 0 deletions codemp/ui/ui_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 17 additions & 8 deletions codemp/ui/ui_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand All @@ -4384,6 +4384,7 @@ void Menu_HandleKey(menuDef_t *menu, int key, qboolean down) {
g_editItem = item;
//DC->setOverstrikeMode(qtrue);
}
break;
}

//JLFACCEPT
Expand All @@ -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))
{
Expand All @@ -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;
Expand Down

0 comments on commit 2bad521

Please sign in to comment.