mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-14 08:31:23 +00:00
Merge branch 'master' of https://github.com/rheit/zdoom
This commit is contained in:
commit
f57e08102c
7 changed files with 76 additions and 38 deletions
|
@ -18,8 +18,6 @@
|
||||||
#include "templates.h"
|
#include "templates.h"
|
||||||
#include "s_sound.h"
|
#include "s_sound.h"
|
||||||
|
|
||||||
void ScaleWithAspect (int &w, int &h, int Width, int Height);
|
|
||||||
|
|
||||||
static void I_CheckGUICapture ();
|
static void I_CheckGUICapture ();
|
||||||
static void I_CheckNativeMouse ();
|
static void I_CheckNativeMouse ();
|
||||||
|
|
||||||
|
@ -320,35 +318,11 @@ void MessagePump (const SDL_Event &sev)
|
||||||
int x, y;
|
int x, y;
|
||||||
SDL_GetMouseState (&x, &y);
|
SDL_GetMouseState (&x, &y);
|
||||||
|
|
||||||
// Detect if we're doing scaling in the Window and adjust the mouse
|
|
||||||
// coordinates accordingly. This could be more efficent, but I
|
|
||||||
// don't think performance is an issue in the menus.
|
|
||||||
SDL_Window *focus;
|
|
||||||
if (screen->IsFullscreen() && (focus = SDL_GetMouseFocus ()))
|
|
||||||
{
|
|
||||||
int w, h;
|
|
||||||
SDL_GetWindowSize (focus, &w, &h);
|
|
||||||
int realw = w, realh = h;
|
|
||||||
ScaleWithAspect (realw, realh, SCREENWIDTH, SCREENHEIGHT);
|
|
||||||
if (realw != SCREENWIDTH || realh != SCREENHEIGHT)
|
|
||||||
{
|
|
||||||
double xratio = (double)SCREENWIDTH/realw;
|
|
||||||
double yratio = (double)SCREENHEIGHT/realh;
|
|
||||||
if (realw < w)
|
|
||||||
{
|
|
||||||
x = (x - (w - realw)/2)*xratio;
|
|
||||||
y *= yratio;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
y = (y - (h - realh)/2)*yratio;
|
|
||||||
x *= xratio;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
event.data1 = x;
|
event.data1 = x;
|
||||||
event.data2 = y;
|
event.data2 = y;
|
||||||
|
|
||||||
|
screen->ScaleCoordsFromWindow(event.data1, event.data2);
|
||||||
|
|
||||||
event.type = EV_GUI_Event;
|
event.type = EV_GUI_Event;
|
||||||
if(sev.type == SDL_MOUSEMOTION)
|
if(sev.type == SDL_MOUSEMOTION)
|
||||||
event.subtype = EV_GUI_MouseMove;
|
event.subtype = EV_GUI_MouseMove;
|
||||||
|
|
|
@ -50,6 +50,7 @@ public:
|
||||||
friend class SDLVideo;
|
friend class SDLVideo;
|
||||||
|
|
||||||
virtual void SetVSync (bool vsync);
|
virtual void SetVSync (bool vsync);
|
||||||
|
virtual void ScaleCoordsFromWindow(SWORD &x, SWORD &y);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PalEntry SourcePalette[256];
|
PalEntry SourcePalette[256];
|
||||||
|
@ -723,6 +724,35 @@ void SDLFB::SetVSync (bool vsync)
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDLFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y)
|
||||||
|
{
|
||||||
|
// Detect if we're doing scaling in the Window and adjust the mouse
|
||||||
|
// coordinates accordingly. This could be more efficent, but I
|
||||||
|
// don't think performance is an issue in the menus.
|
||||||
|
if(IsFullscreen())
|
||||||
|
{
|
||||||
|
int w, h;
|
||||||
|
SDL_GetWindowSize (Screen, &w, &h);
|
||||||
|
int realw = w, realh = h;
|
||||||
|
ScaleWithAspect (realw, realh, SCREENWIDTH, SCREENHEIGHT);
|
||||||
|
if (realw != SCREENWIDTH || realh != SCREENHEIGHT)
|
||||||
|
{
|
||||||
|
double xratio = (double)SCREENWIDTH/realw;
|
||||||
|
double yratio = (double)SCREENHEIGHT/realh;
|
||||||
|
if (realw < w)
|
||||||
|
{
|
||||||
|
x = (x - (w - realw)/2)*xratio;
|
||||||
|
y *= yratio;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
y = (y - (h - realh)/2)*yratio;
|
||||||
|
x *= xratio;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ADD_STAT (blit)
|
ADD_STAT (blit)
|
||||||
{
|
{
|
||||||
FString out;
|
FString out;
|
||||||
|
|
|
@ -398,8 +398,8 @@ public:
|
||||||
virtual void WipeEndScreen();
|
virtual void WipeEndScreen();
|
||||||
virtual bool WipeDo(int ticks);
|
virtual bool WipeDo(int ticks);
|
||||||
virtual void WipeCleanup();
|
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; }
|
uint32 GetLastFPS() const { return LastCount; }
|
||||||
|
|
||||||
|
|
|
@ -1028,6 +1028,28 @@ 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
|
||||||
|
|
|
@ -806,6 +806,19 @@ 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;
|
||||||
|
|
|
@ -323,11 +323,11 @@ bool GUIWndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESU
|
||||||
if (BlockMouseMove > 0) return true;
|
if (BlockMouseMove > 0) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ev.data1 = LOWORD(lParam);
|
||||||
|
ev.data2 = HIWORD(lParam);
|
||||||
|
if (screen != NULL)
|
||||||
{
|
{
|
||||||
int shift = screen? screen->GetPixelDoubling() : 0;
|
screen->ScaleCoordsFromWindow(ev.data1, ev.data2);
|
||||||
ev.data1 = LOWORD(lParam) >> shift;
|
|
||||||
ev.data2 = HIWORD(lParam) >> shift;
|
|
||||||
if (screen) ev.data2 -= (screen->GetTrueHeight() - screen->GetHeight())/2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wParam & MK_SHIFT) ev.data3 |= GKM_SHIFT;
|
if (wParam & MK_SHIFT) ev.data3 |= GKM_SHIFT;
|
||||||
|
|
|
@ -164,8 +164,8 @@ public:
|
||||||
void SetVSync (bool vsync);
|
void SetVSync (bool vsync);
|
||||||
void NewRefreshRate();
|
void NewRefreshRate();
|
||||||
HRESULT GetHR ();
|
HRESULT GetHR ();
|
||||||
virtual int GetTrueHeight() { return TrueHeight; }
|
|
||||||
bool Is8BitMode();
|
bool Is8BitMode();
|
||||||
|
void ScaleCoordsFromWindow(SWORD &x, SWORD &y);
|
||||||
|
|
||||||
void Blank ();
|
void Blank ();
|
||||||
bool PaintToWindow ();
|
bool PaintToWindow ();
|
||||||
|
@ -269,8 +269,8 @@ public:
|
||||||
bool WipeDo(int ticks);
|
bool WipeDo(int ticks);
|
||||||
void WipeCleanup();
|
void WipeCleanup();
|
||||||
HRESULT GetHR ();
|
HRESULT GetHR ();
|
||||||
virtual int GetTrueHeight() { return TrueHeight; }
|
|
||||||
bool Is8BitMode() { return false; }
|
bool Is8BitMode() { return false; }
|
||||||
|
void ScaleCoordsFromWindow(SWORD &x, SWORD &y);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class D3DTex;
|
friend class D3DTex;
|
||||||
|
@ -380,7 +380,6 @@ private:
|
||||||
void EndLineBatch();
|
void EndLineBatch();
|
||||||
void EndBatch();
|
void EndBatch();
|
||||||
void CopyNextFrontBuffer();
|
void CopyNextFrontBuffer();
|
||||||
int GetPixelDoubling() const { return PixelDoubling; }
|
|
||||||
|
|
||||||
D3DCAPS9 DeviceCaps;
|
D3DCAPS9 DeviceCaps;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue