Skip to content

Commit

Permalink
Don't let the cursor flicker.
Browse files Browse the repository at this point in the history
Hard to reproduce, probably depends on hardware and/or vsync.

Fixes ticket:4450.
  • Loading branch information
Cyp committed Jul 21, 2016
1 parent 31d9772 commit ec3eb89
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 34 deletions.
61 changes: 32 additions & 29 deletions src/display.cpp
Expand Up @@ -698,13 +698,15 @@ UDWORD getTargetType(void)
}

//don't want to do any of these whilst in the Intelligence Screen
void processMouseClickInput(void)
CURSOR processMouseClickInput()
{
UDWORD i;
SELECTION_TYPE selection;
MOUSE_TARGET item = MT_NOTARGET;
bool OverRadar = OverRadarAndNotDragging();

CURSOR cursor = CURSOR_DEFAULT;

ignoreOrder = CheckFinishedFindPosition();

CheckStartWallDrag();
Expand All @@ -726,7 +728,7 @@ void processMouseClickInput(void)
{
// Never, *ever* let user control the transport in SP games--it breaks the scripts!
ASSERT(game.type == CAMPAIGN, "Game type was set incorrectly!");
return;
return cursor;
}
else
{
Expand Down Expand Up @@ -802,17 +804,17 @@ void processMouseClickInput(void)

if (gamePaused())
{
wzSetCursor(CURSOR_DEFAULT);
cursor = CURSOR_DEFAULT;
}
if (buildState == BUILD3D_VALID)
{
// special casing for building
wzSetCursor(CURSOR_BUILD);
cursor = CURSOR_BUILD;
}
else if (buildState == BUILD3D_POS)
{
// special casing for building - can't build here
wzSetCursor(CURSOR_NOTPOSSIBLE);
cursor = CURSOR_NOTPOSSIBLE;
}
else if (selection != SC_INVALID)
{
Expand Down Expand Up @@ -976,29 +978,29 @@ void processMouseClickInput(void)
arnMPointers[item][selection] == CURSOR_MOVE && bMultiPlayer)
{
// Alt+move = disembark transporter
wzSetCursor(CURSOR_DISEMBARK);
cursor = CURSOR_DISEMBARK;
}
else if (specialOrderKeyDown() && selection == SC_DROID_DIRECT &&
arnMPointers[item][selection] == CURSOR_MOVE)
{
// Alt+move = scout
wzSetCursor(CURSOR_SCOUT);
cursor = CURSOR_SCOUT;
}
else if (arnMPointers[item][selection] == CURSOR_NOTPOSSIBLE &&
ObjUnderMouse && (ObjUnderMouse->player == selectedPlayer) &&
ObjUnderMouse->type == OBJ_STRUCTURE && ((STRUCTURE *)ObjUnderMouse)->asWeaps[0].nStat &&
(asWeaponStats[((STRUCTURE *)ObjUnderMouse)->asWeaps[0].nStat].weaponSubClass == WSC_LAS_SAT))
{
wzSetCursor(CURSOR_SELECT); // Special casing for LasSat
cursor = CURSOR_SELECT; // Special casing for LasSat
}
else
{
wzSetCursor(arnMPointers[item][selection]);
cursor = arnMPointers[item][selection];
}
}
else
{
wzSetCursor(CURSOR_DEFAULT);
cursor = CURSOR_DEFAULT;
}
}
else
Expand All @@ -1013,54 +1015,55 @@ void processMouseClickInput(void)
if (item == MT_ENEMYDROID || item == MT_ENEMYSTR || item == MT_DAMFEATURE)
{
//display attack cursor
wzSetCursor(CURSOR_ATTACK);
cursor = CURSOR_ATTACK;
}
else if (ObjUnderMouse && ObjUnderMouse->player == selectedPlayer && (ObjUnderMouse->type == OBJ_DROID ||
(ObjUnderMouse->type == OBJ_STRUCTURE && lasSatStructSelected((STRUCTURE *)ObjUnderMouse))))
{
// Special casing for selectables
wzSetCursor(CURSOR_SELECT);
cursor = CURSOR_SELECT;
}
else if (ObjUnderMouse && ObjUnderMouse->player == selectedPlayer && ObjUnderMouse->type == OBJ_STRUCTURE)
{
wzSetCursor(CURSOR_DEFAULT);
cursor = CURSOR_DEFAULT;
}
else
{
//display block cursor
wzSetCursor(CURSOR_NOTPOSSIBLE);
cursor = CURSOR_NOTPOSSIBLE;
}
}
else if (ObjUnderMouse && (ObjUnderMouse->player == selectedPlayer) &&
((ObjUnderMouse->type == OBJ_STRUCTURE && ((STRUCTURE *)ObjUnderMouse)->asWeaps[0].nStat
&& (asWeaponStats[((STRUCTURE *)ObjUnderMouse)->asWeaps[0].nStat].weaponSubClass == WSC_LAS_SAT))
|| ObjUnderMouse->type == OBJ_DROID))
{
wzSetCursor(CURSOR_SELECT); // Special casing for LasSat or own unit
cursor = CURSOR_SELECT; // Special casing for LasSat or own unit
}
else
{
// when one of the arrow key gets pressed, set cursor appropriately
if (keyDown(KEY_UPARROW))
{
wzSetCursor(CURSOR_UARROW);
cursor = CURSOR_UARROW;
}
else if (keyDown(KEY_DOWNARROW))
{
wzSetCursor(CURSOR_DARROW);
cursor = CURSOR_DARROW;
}
else if (keyDown(KEY_LEFTARROW))
{
wzSetCursor(CURSOR_LARROW);
cursor = CURSOR_LARROW;
}
else if (keyDown(KEY_RIGHTARROW))
{
wzSetCursor(CURSOR_RARROW);
cursor = CURSOR_RARROW;
}
}
}

CurrentItemUnderMouse = item;
return cursor;
}

static void calcScroll(float *y, float *dydt, float accel, float decel, float targetVelocity, float dt)
Expand Down Expand Up @@ -1097,7 +1100,7 @@ static void calcScroll(float *y, float *dydt, float accel, float decel, float ta
*y += *dydt * dt;
}

void scroll(void)
CURSOR scroll()
{
SDWORD xDif, yDif;
uint32_t timeDiff;
Expand All @@ -1108,9 +1111,11 @@ void scroll(void)

static float xDiffFrac = 0, yDiffFrac = 0;

CURSOR cursor = CURSOR_DEFAULT;

if (InGameOpUp || bDisplayMultiJoiningStatus || isInGamePopupUp) // cant scroll when menu up. or when over radar
{
return;
return cursor;
}

if (mouseScroll && wzMouseInWindow())
Expand All @@ -1123,23 +1128,19 @@ void scroll(void)
// when mouse cursor goes to an edge, set cursor appropriately
if (scrollDirUpDown > 0)
{
wzSetCursor(CURSOR_UARROW);
cursor = CURSOR_UARROW;
}
else if (scrollDirUpDown < 0)
{
wzSetCursor(CURSOR_DARROW);
cursor = CURSOR_DARROW;
}
else if (scrollDirLeftRight < 0)
{
wzSetCursor(CURSOR_LARROW);
cursor = CURSOR_LARROW;
}
else if (scrollDirLeftRight > 0)
{
wzSetCursor(CURSOR_RARROW);
}
else
{
wzSetCursor(CURSOR_DEFAULT);
cursor = CURSOR_RARROW;
}
}
if (!keyDown(KEY_LCTRL) && !keyDown(KEY_RCTRL))
Expand Down Expand Up @@ -1187,6 +1188,8 @@ void scroll(void)
player.p.z += yDif;

CheckScrollLimits();

return cursor;
}

/*
Expand Down
4 changes: 2 additions & 2 deletions src/display.h
Expand Up @@ -37,9 +37,9 @@ void ProcessRadarInput();

extern void processInput(void);
/*don't want to do any of these whilst in the Intelligence Screen*/
extern void processMouseClickInput(void);
CURSOR processMouseClickInput();

extern void scroll(void);
CURSOR scroll();
extern void resetScroll(void);
extern void setMouseScroll(bool);

Expand Down
10 changes: 7 additions & 3 deletions src/loop.cpp
Expand Up @@ -149,6 +149,7 @@ static GAMECODE renderLoop()
wzShowMouse(true);

INT_RETVAL intRetVal = INT_NONE;
CURSOR cursor = CURSOR_DEFAULT;
if (!paused)
{
/* Run the in game interface and see if it grabbed any mouse clicks */
Expand Down Expand Up @@ -206,7 +207,7 @@ static GAMECODE renderLoop()
}
if (!scrollPaused() && dragBox3D.status != DRAG_DRAGGING && intMode != INT_INGAMEOP)
{
scroll();
cursor = scroll();
zoom();
}
}
Expand All @@ -217,7 +218,7 @@ static GAMECODE renderLoop()

if (dragBox3D.status != DRAG_DRAGGING)
{
scroll();
cursor = scroll();
zoom();
}

Expand Down Expand Up @@ -318,7 +319,8 @@ static GAMECODE renderLoop()
//no key clicks or in Intelligence Screen
if (!isMouseOverRadar() && intRetVal == INT_NONE && !InGameOpUp && !isInGamePopupUp)
{
processMouseClickInput();
CURSOR cursor2 = processMouseClickInput();
cursor = cursor2 == CURSOR_DEFAULT? cursor : cursor2;
}
displayWorld();
}
Expand All @@ -342,6 +344,8 @@ static GAMECODE renderLoop()
wzPerfEnd(PERF_GUI);
}

wzSetCursor(cursor);

pie_GetResetCounts(&loopPieCount, &loopPolyCount, &loopStateChanges);

if ((fogStatus & FOG_BACKGROUND) && (loopMissionState == LMS_SAVECONTINUE))
Expand Down

0 comments on commit ec3eb89

Please sign in to comment.