forked from Mirrors/openclonk
Fix game coordinates for keyboard controls that request a cursor pos
parent
e5c6ca990b
commit
159d0811d6
|
@ -1459,8 +1459,10 @@ bool C4PlayerControl::GetCurrentPlayerCursorPos(int32_t *x_out, int32_t *y_out,
|
|||
// prefer mouse position if this is a mouse control
|
||||
if (pControlSet && pControlSet->HasMouse())
|
||||
{
|
||||
if (MouseControl.GetLastGUIPos(x_out, y_out))
|
||||
if (MouseControl.GetLastCursorPos(x_out, y_out, game_x_out, game_y_out))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// if getting the mouse position failed, better fall back to cursor pos
|
||||
}
|
||||
// no mouse position known. Use cursor.
|
||||
|
|
|
@ -884,11 +884,12 @@ bool C4MouseControl::IsDragging()
|
|||
return Active && Drag == C4MC_Drag_Script;
|
||||
}
|
||||
|
||||
bool C4MouseControl::GetLastGUIPos(int32_t *x_out, int32_t *y_out) const
|
||||
bool C4MouseControl::GetLastCursorPos(int32_t *x_out_gui, int32_t *y_out_gui, int32_t *x_out_game, int32_t *y_out_game) const
|
||||
{
|
||||
// safety
|
||||
if (!Active || !fMouseOwned) return false;
|
||||
// OK; assign last known pos
|
||||
*x_out = GuiX; *y_out = GuiY;
|
||||
*x_out_gui = GuiX; *y_out_gui = GuiY;
|
||||
*x_out_game = GameX; *y_out_game = GameY;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ public:
|
|||
void SetOwnedMouse(bool fToVal) { fMouseOwned = fToVal; }
|
||||
bool IsMouseOwned() { return fMouseOwned; }
|
||||
bool IsActive() { return !!Active; }
|
||||
bool GetLastGUIPos(int32_t *x_out, int32_t *y_out) const;
|
||||
bool GetLastCursorPos(int32_t *x_out_gui, int32_t *y_out_gui, int32_t *x_out_game, int32_t *y_out_game) const;
|
||||
|
||||
const char *GetCaption();
|
||||
void SetTooltipText(const StdStrBuf &text);
|
||||
|
|
Loading…
Reference in New Issue