This commit is contained in:
Christoph Oelckers 2015-04-17 21:39:35 +02:00
commit 887014c322
4 changed files with 27 additions and 37 deletions

View File

@ -1028,28 +1028,6 @@ bool D3DFB::IsFullscreen ()
return !Windowed; 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 // D3DFB :: Lock

View File

@ -806,19 +806,6 @@ bool DDrawFB::Is8BitMode()
return vid_displaybits == 8; 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 () bool DDrawFB::IsValid ()
{ {
return PrimarySurf != NULL; return PrimarySurf != NULL;

View File

@ -127,10 +127,12 @@ public:
virtual void Blank () = 0; virtual void Blank () = 0;
virtual bool PaintToWindow () = 0; virtual bool PaintToWindow () = 0;
virtual HRESULT GetHR () = 0; virtual HRESULT GetHR () = 0;
virtual void ScaleCoordsFromWindow(SWORD &x, SWORD &y);
protected: protected:
virtual bool CreateResources () = 0; virtual bool CreateResources () = 0;
virtual void ReleaseResources () = 0; virtual void ReleaseResources () = 0;
virtual int GetTrueHeight() { return GetHeight(); }
bool Windowed; bool Windowed;
@ -165,7 +167,7 @@ public:
void NewRefreshRate(); void NewRefreshRate();
HRESULT GetHR (); HRESULT GetHR ();
bool Is8BitMode(); bool Is8BitMode();
void ScaleCoordsFromWindow(SWORD &x, SWORD &y); virtual int GetTrueHeight() { return TrueHeight; }
void Blank (); void Blank ();
bool PaintToWindow (); bool PaintToWindow ();
@ -270,7 +272,7 @@ public:
void WipeCleanup(); void WipeCleanup();
HRESULT GetHR (); HRESULT GetHR ();
bool Is8BitMode() { return false; } bool Is8BitMode() { return false; }
void ScaleCoordsFromWindow(SWORD &x, SWORD &y); virtual int GetTrueHeight() { return TrueHeight; }
private: private:
friend class D3DTex; friend class D3DTex;

View File

@ -736,6 +736,29 @@ void Win32Video::SetWindowedScale (float scale)
// FIXME // FIXME
} }
//==========================================================================
//
// BaseWinFB :: ScaleCoordsFromWindow
//
// Given coordinates in window space, return coordinates in what the game
// thinks screen space is.
//
//==========================================================================
void BaseWinFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y)
{
RECT rect;
int TrueHeight = GetTrueHeight();
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;
}
//========================================================================== //==========================================================================
// //
// SetFPSLimit // SetFPSLimit