mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 22:11:43 +00:00
Scale mouse coordinates based on window size
- Fixed: If you enlarged the game window (in windowed mode) so that the window is bigger than the selected resolution, the menu would still take its inputs from the portion in the upper left that matched the resolution.
This commit is contained in:
parent
d166211ce0
commit
9b6756114b
5 changed files with 43 additions and 9 deletions
|
@ -398,8 +398,8 @@ public:
|
|||
virtual void WipeEndScreen();
|
||||
virtual bool WipeDo(int ticks);
|
||||
virtual void WipeCleanup();
|
||||
virtual int GetPixelDoubling() const { return 0; }
|
||||
virtual int GetTrueHeight() { return GetHeight(); }
|
||||
|
||||
virtual void ScaleCoordsFromWindow(SWORD &x, SWORD &y) {}
|
||||
|
||||
uint32 GetLastFPS() const { return LastCount; }
|
||||
|
||||
|
|
|
@ -1028,6 +1028,28 @@ bool D3DFB::IsFullscreen ()
|
|||
return !Windowed;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// D3DFB :: ScaleCoordsFromWindow
|
||||
//
|
||||
// Given coordinates in window space, return coordinates in what the game
|
||||
// thinks screen space is.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void D3DFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y)
|
||||
{
|
||||
RECT rect;
|
||||
|
||||
if (GetClientRect(Window, &rect))
|
||||
{
|
||||
x = SWORD(x * Width / (rect.right - rect.left));
|
||||
y = SWORD(y * TrueHeight / (rect.bottom - rect.top));
|
||||
}
|
||||
// Subtract letterboxing borders
|
||||
y -= (TrueHeight - Height) / 2;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// D3DFB :: Lock
|
||||
|
|
|
@ -806,6 +806,19 @@ bool DDrawFB::Is8BitMode()
|
|||
return vid_displaybits == 8;
|
||||
}
|
||||
|
||||
void DDrawFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y)
|
||||
{
|
||||
RECT rect;
|
||||
|
||||
if (GetClientRect(Window, &rect))
|
||||
{
|
||||
x = SWORD(x * Width / (rect.right - rect.left));
|
||||
y = SWORD(y * TrueHeight / (rect.bottom - rect.top));
|
||||
}
|
||||
// Subtract letterboxing borders
|
||||
y -= (TrueHeight - Height) / 2;
|
||||
}
|
||||
|
||||
bool DDrawFB::IsValid ()
|
||||
{
|
||||
return PrimarySurf != NULL;
|
||||
|
|
|
@ -323,11 +323,11 @@ bool GUIWndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESU
|
|||
if (BlockMouseMove > 0) return true;
|
||||
}
|
||||
|
||||
ev.data1 = LOWORD(lParam);
|
||||
ev.data2 = HIWORD(lParam);
|
||||
if (screen != NULL)
|
||||
{
|
||||
int shift = screen? screen->GetPixelDoubling() : 0;
|
||||
ev.data1 = LOWORD(lParam) >> shift;
|
||||
ev.data2 = HIWORD(lParam) >> shift;
|
||||
if (screen) ev.data2 -= (screen->GetTrueHeight() - screen->GetHeight())/2;
|
||||
screen->ScaleCoordsFromWindow(ev.data1, ev.data2);
|
||||
}
|
||||
|
||||
if (wParam & MK_SHIFT) ev.data3 |= GKM_SHIFT;
|
||||
|
|
|
@ -164,8 +164,8 @@ public:
|
|||
void SetVSync (bool vsync);
|
||||
void NewRefreshRate();
|
||||
HRESULT GetHR ();
|
||||
virtual int GetTrueHeight() { return TrueHeight; }
|
||||
bool Is8BitMode();
|
||||
void ScaleCoordsFromWindow(SWORD &x, SWORD &y);
|
||||
|
||||
void Blank ();
|
||||
bool PaintToWindow ();
|
||||
|
@ -269,8 +269,8 @@ public:
|
|||
bool WipeDo(int ticks);
|
||||
void WipeCleanup();
|
||||
HRESULT GetHR ();
|
||||
virtual int GetTrueHeight() { return TrueHeight; }
|
||||
bool Is8BitMode() { return false; }
|
||||
void ScaleCoordsFromWindow(SWORD &x, SWORD &y);
|
||||
|
||||
private:
|
||||
friend class D3DTex;
|
||||
|
@ -380,7 +380,6 @@ private:
|
|||
void EndLineBatch();
|
||||
void EndBatch();
|
||||
void CopyNextFrontBuffer();
|
||||
int GetPixelDoubling() const { return PixelDoubling; }
|
||||
|
||||
D3DCAPS9 DeviceCaps;
|
||||
|
||||
|
|
Loading…
Reference in a new issue