mirror of
https://github.com/blupi-games/planetblupi
synced 2024-12-30 10:15:36 +01:00
Merge branch 'wip/fullscreen' into wip/landscape
This commit is contained in:
commit
c79961e803
@ -779,8 +779,16 @@ DoInit (int argc, char * argv[], bool & exit)
|
|||||||
info.max_texture_height);
|
info.max_texture_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the event manager.
|
||||||
|
g_pEvent = new CEvent;
|
||||||
|
if (g_pEvent == nullptr)
|
||||||
|
{
|
||||||
|
InitFail ("New event");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
// Create the main pixmap.
|
// Create the main pixmap.
|
||||||
g_pPixmap = new CPixmap;
|
g_pPixmap = new CPixmap (g_pEvent);
|
||||||
if (g_pPixmap == nullptr)
|
if (g_pPixmap == nullptr)
|
||||||
{
|
{
|
||||||
InitFail ("New pixmap");
|
InitFail ("New pixmap");
|
||||||
@ -994,27 +1002,18 @@ DoInit (int argc, char * argv[], bool & exit)
|
|||||||
g_pDecor->Create (g_pSound, g_pPixmap);
|
g_pDecor->Create (g_pSound, g_pPixmap);
|
||||||
g_pDecor->MapInitColors ();
|
g_pDecor->MapInitColors ();
|
||||||
|
|
||||||
// Create the event manager.
|
|
||||||
g_pEvent = new CEvent;
|
|
||||||
if (g_pEvent == nullptr)
|
|
||||||
{
|
|
||||||
InitFail ("New event");
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool zoom = g_zoom;
|
const bool zoom = g_zoom;
|
||||||
|
|
||||||
g_pEvent->Create (g_pPixmap, g_pDecor, g_pSound, g_pMovie);
|
g_pEvent->Create (g_pPixmap, g_pDecor, g_pSound, g_pMovie);
|
||||||
|
|
||||||
// Load all cursors
|
// Load all cursors
|
||||||
g_pPixmap->LoadCursors (g_zoom);
|
g_pPixmap->LoadCursors ();
|
||||||
g_pPixmap->ChangeSprite (SPRITE_WAIT);
|
g_pPixmap->ChangeSprite (SPRITE_WAIT);
|
||||||
|
|
||||||
g_updateThread = new std::thread (CheckForUpdates);
|
g_updateThread = new std::thread (CheckForUpdates);
|
||||||
if (g_bFullScreen)
|
if (zoom != g_zoom)
|
||||||
g_pEvent->SetFullScreen (true);
|
|
||||||
if (!g_bFullScreen && zoom != g_zoom)
|
|
||||||
g_pEvent->SetWindowSize (g_zoom);
|
g_pEvent->SetWindowSize (g_zoom);
|
||||||
|
g_pEvent->SetFullScreen (g_bFullScreen);
|
||||||
g_pEvent->ChangePhase (EV_PHASE_INTRO1);
|
g_pEvent->ChangePhase (EV_PHASE_INTRO1);
|
||||||
|
|
||||||
g_bTermInit = true;
|
g_bTermInit = true;
|
||||||
|
@ -25,7 +25,9 @@
|
|||||||
// clang-format off
|
// clang-format off
|
||||||
#define _INTRO true // true for init screen
|
#define _INTRO true // true for init screen
|
||||||
|
|
||||||
#define SCRFACTOR 16 / 9
|
#define SCRNUM 16
|
||||||
|
#define SCRDEN 9
|
||||||
|
#define SCRFACTOR SCRNUM / SCRDEN
|
||||||
#define LXLOGIC 640
|
#define LXLOGIC 640
|
||||||
#define LYLOGIC 480
|
#define LYLOGIC 480
|
||||||
#define LXIMAGE (LYLOGIC * SCRFACTOR + (LYLOGIC * SCRFACTOR) % 2) // window size
|
#define LXIMAGE (LYLOGIC * SCRFACTOR + (LYLOGIC * SCRFACTOR) % 2) // window size
|
||||||
|
@ -1697,6 +1697,12 @@ CEvent::~CEvent ()
|
|||||||
WriteInfo (); // lit le fichier "info.blp"
|
WriteInfo (); // lit le fichier "info.blp"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CEvent::IsDemoPlaying ()
|
||||||
|
{
|
||||||
|
return this->m_bDemoPlay;
|
||||||
|
}
|
||||||
|
|
||||||
// Retourne la position de la souris.
|
// Retourne la position de la souris.
|
||||||
|
|
||||||
Point
|
Point
|
||||||
@ -1717,14 +1723,6 @@ CEvent::GetMousePos ()
|
|||||||
void
|
void
|
||||||
CEvent::SetFullScreen (bool bFullScreen)
|
CEvent::SetFullScreen (bool bFullScreen)
|
||||||
{
|
{
|
||||||
int x, y;
|
|
||||||
SDL_GetMouseState (&x, &y);
|
|
||||||
x /= g_zoom;
|
|
||||||
y /= g_zoom;
|
|
||||||
|
|
||||||
g_zoom = 1;
|
|
||||||
SDL_SetWindowSize (g_window, LXIMAGE, LYIMAGE);
|
|
||||||
|
|
||||||
g_bFullScreen = bFullScreen;
|
g_bFullScreen = bFullScreen;
|
||||||
|
|
||||||
int displayIndex = 0;
|
int displayIndex = 0;
|
||||||
@ -1732,7 +1730,7 @@ CEvent::SetFullScreen (bool bFullScreen)
|
|||||||
displayIndex = SDL_GetWindowDisplayIndex (g_window);
|
displayIndex = SDL_GetWindowDisplayIndex (g_window);
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
if (g_bFullScreen)
|
if (g_bFullScreen && g_zoom == 2)
|
||||||
{
|
{
|
||||||
int displays = SDL_GetNumVideoDisplays ();
|
int displays = SDL_GetNumVideoDisplays ();
|
||||||
|
|
||||||
@ -1750,7 +1748,10 @@ CEvent::SetFullScreen (bool bFullScreen)
|
|||||||
g_window, displayBounds[displayIndex].x, displayBounds[displayIndex].y);
|
g_window, displayBounds[displayIndex].x, displayBounds[displayIndex].y);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SetWindowFullscreen (g_window, bFullScreen ? SDL_WINDOW_FULLSCREEN : 0);
|
SDL_SetWindowFullscreen (
|
||||||
|
g_window, bFullScreen ? (g_zoom == 1 ? SDL_WINDOW_FULLSCREEN_DESKTOP
|
||||||
|
: SDL_WINDOW_FULLSCREEN)
|
||||||
|
: 0);
|
||||||
SDL_SetWindowBordered (g_window, bFullScreen ? SDL_FALSE : SDL_TRUE);
|
SDL_SetWindowBordered (g_window, bFullScreen ? SDL_FALSE : SDL_TRUE);
|
||||||
SDL_SetWindowGrab (g_window, bFullScreen ? SDL_TRUE : SDL_FALSE);
|
SDL_SetWindowGrab (g_window, bFullScreen ? SDL_TRUE : SDL_FALSE);
|
||||||
|
|
||||||
@ -1759,17 +1760,14 @@ CEvent::SetFullScreen (bool bFullScreen)
|
|||||||
g_window, SDL_WINDOWPOS_CENTERED_DISPLAY (displayIndex),
|
g_window, SDL_WINDOWPOS_CENTERED_DISPLAY (displayIndex),
|
||||||
SDL_WINDOWPOS_CENTERED_DISPLAY (displayIndex));
|
SDL_WINDOWPOS_CENTERED_DISPLAY (displayIndex));
|
||||||
|
|
||||||
m_pPixmap->LoadCursors (g_zoom);
|
m_pPixmap->LoadCursors ();
|
||||||
|
|
||||||
/* Force this update before otherwise the coordinates retrieved with
|
if (g_bFullScreen)
|
||||||
* the Warp SDL function are corresponding to the previous size.
|
{
|
||||||
*/
|
Sint32 w, h;
|
||||||
CEvent::PushUserEvent (EV_UPDATE);
|
SDL_GetWindowSize (g_window, &w, &h);
|
||||||
|
SDL_WarpMouseGlobal (w / 2, h / 2);
|
||||||
auto coord = new SDL_Point; // Released by the event handler.
|
}
|
||||||
coord->x = x;
|
|
||||||
coord->y = y;
|
|
||||||
CEvent::PushUserEvent (EV_WARPMOUSE, coord);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1810,6 +1808,9 @@ CEvent::SetWindowSize (Uint8 prevScale, Uint8 newScale)
|
|||||||
int x, y;
|
int x, y;
|
||||||
SDL_GetMouseState (&x, &y);
|
SDL_GetMouseState (&x, &y);
|
||||||
|
|
||||||
|
if (g_bFullScreen && newScale == 2)
|
||||||
|
newScale = 1;
|
||||||
|
|
||||||
SDL_SetWindowSize (g_window, LXIMAGE * newScale, LYIMAGE * newScale);
|
SDL_SetWindowSize (g_window, LXIMAGE * newScale, LYIMAGE * newScale);
|
||||||
|
|
||||||
int displayIndex = SDL_GetWindowDisplayIndex (g_window);
|
int displayIndex = SDL_GetWindowDisplayIndex (g_window);
|
||||||
@ -1817,7 +1818,10 @@ CEvent::SetWindowSize (Uint8 prevScale, Uint8 newScale)
|
|||||||
g_window, SDL_WINDOWPOS_CENTERED_DISPLAY (displayIndex),
|
g_window, SDL_WINDOWPOS_CENTERED_DISPLAY (displayIndex),
|
||||||
SDL_WINDOWPOS_CENTERED_DISPLAY (displayIndex));
|
SDL_WINDOWPOS_CENTERED_DISPLAY (displayIndex));
|
||||||
|
|
||||||
m_pPixmap->LoadCursors (newScale);
|
m_pPixmap->LoadCursors ();
|
||||||
|
|
||||||
|
if (prevScale == newScale)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Force this update before otherwise the coordinates retrieved with
|
/* Force this update before otherwise the coordinates retrieved with
|
||||||
* the Warp SDL function are corresponding to the previous size.
|
* the Warp SDL function are corresponding to the previous size.
|
||||||
@ -2178,8 +2182,8 @@ CEvent::DrawButtons ()
|
|||||||
SetEnable (EV_BUTTON3, !g_bFullScreen);
|
SetEnable (EV_BUTTON3, !g_bFullScreen);
|
||||||
SetEnable (EV_BUTTON4, g_bFullScreen);
|
SetEnable (EV_BUTTON4, g_bFullScreen);
|
||||||
|
|
||||||
SetEnable (EV_BUTTON5, !g_bFullScreen && g_zoom > 1);
|
SetEnable (EV_BUTTON5, g_zoom > 1);
|
||||||
SetEnable (EV_BUTTON6, !g_bFullScreen && g_zoom < 2);
|
SetEnable (EV_BUTTON6, g_zoom < 2);
|
||||||
|
|
||||||
SetEnable (EV_BUTTON7, g_restoreMidi && mid && ogg);
|
SetEnable (EV_BUTTON7, g_restoreMidi && mid && ogg);
|
||||||
SetEnable (EV_BUTTON8, !g_restoreMidi && mid && ogg);
|
SetEnable (EV_BUTTON8, !g_restoreMidi && mid && ogg);
|
||||||
@ -4233,10 +4237,16 @@ CEvent::ChangeButtons (Sint32 message)
|
|||||||
SetLanguage ();
|
SetLanguage ();
|
||||||
break;
|
break;
|
||||||
case EV_BUTTON3:
|
case EV_BUTTON3:
|
||||||
|
{
|
||||||
|
auto zoom = g_zoom;
|
||||||
|
g_zoom = 1;
|
||||||
SetFullScreen (true);
|
SetFullScreen (true);
|
||||||
|
SetWindowSize (zoom, 1);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case EV_BUTTON4:
|
case EV_BUTTON4:
|
||||||
SetFullScreen (false);
|
SetFullScreen (false);
|
||||||
|
SetWindowSize (g_zoom, g_zoom);
|
||||||
break;
|
break;
|
||||||
case EV_BUTTON5:
|
case EV_BUTTON5:
|
||||||
{
|
{
|
||||||
@ -4244,6 +4254,7 @@ CEvent::ChangeButtons (Sint32 message)
|
|||||||
if (g_zoom > 1)
|
if (g_zoom > 1)
|
||||||
--g_zoom;
|
--g_zoom;
|
||||||
SetWindowSize (scale, g_zoom);
|
SetWindowSize (scale, g_zoom);
|
||||||
|
SetFullScreen (g_bFullScreen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EV_BUTTON6:
|
case EV_BUTTON6:
|
||||||
@ -4252,6 +4263,7 @@ CEvent::ChangeButtons (Sint32 message)
|
|||||||
if (g_zoom < 2)
|
if (g_zoom < 2)
|
||||||
++g_zoom;
|
++g_zoom;
|
||||||
SetWindowSize (scale, g_zoom);
|
SetWindowSize (scale, g_zoom);
|
||||||
|
SetFullScreen (g_bFullScreen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EV_BUTTON7:
|
case EV_BUTTON7:
|
||||||
@ -5282,7 +5294,8 @@ CEvent::DemoStep ()
|
|||||||
pos.y = event.motion.y;
|
pos.y = event.motion.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_WarpMouseInWindow (g_window, pos.x * g_zoom, pos.y * g_zoom);
|
this->m_pPixmap->FromGameToDisplay (pos.x, pos.y);
|
||||||
|
SDL_WarpMouseInWindow (g_window, pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_pDemoBuffer)
|
if (m_pDemoBuffer)
|
||||||
@ -5334,6 +5347,7 @@ CEvent::DemoRecEvent (const SDL_Event & event)
|
|||||||
demoEvent.button = event.button.button;
|
demoEvent.button = event.button.button;
|
||||||
demoEvent.x = event.button.x;
|
demoEvent.x = event.button.x;
|
||||||
demoEvent.y = event.button.y;
|
demoEvent.y = event.button.y;
|
||||||
|
this->m_pPixmap->FromDisplayToGame (demoEvent.x, demoEvent.y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
@ -5341,6 +5355,7 @@ CEvent::DemoRecEvent (const SDL_Event & event)
|
|||||||
demoEvent.time = m_demoTime;
|
demoEvent.time = m_demoTime;
|
||||||
demoEvent.x = event.motion.x;
|
demoEvent.x = event.motion.x;
|
||||||
demoEvent.y = event.motion.y;
|
demoEvent.y = event.motion.y;
|
||||||
|
this->m_pPixmap->FromDisplayToGame (demoEvent.x, demoEvent.y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -94,6 +94,7 @@ public:
|
|||||||
CEvent ();
|
CEvent ();
|
||||||
~CEvent ();
|
~CEvent ();
|
||||||
|
|
||||||
|
bool IsDemoPlaying ();
|
||||||
Point GetMousePos ();
|
Point GetMousePos ();
|
||||||
void
|
void
|
||||||
Create (CPixmap * pPixmap, CDecor * pDecor, CSound * pSound, CMovie * pMovie);
|
Create (CPixmap * pPixmap, CDecor * pDecor, CSound * pSound, CMovie * pMovie);
|
||||||
|
@ -185,7 +185,9 @@ CMenu::Create (
|
|||||||
pos = m_pos;
|
pos = m_pos;
|
||||||
pos.x += DIMBUTTONX / 2;
|
pos.x += DIMBUTTONX / 2;
|
||||||
pos.y += DIMBUTTONY / 2;
|
pos.y += DIMBUTTONY / 2;
|
||||||
SDL_WarpMouseInWindow (g_window, pos.x * g_zoom, pos.y * g_zoom);
|
|
||||||
|
this->m_pPixmap->FromGameToDisplay (pos.x, pos.y);
|
||||||
|
SDL_WarpMouseInWindow (g_window, pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_selRank = Detect (pos);
|
m_selRank = Detect (pos);
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include "blupi.h"
|
#include "blupi.h"
|
||||||
#include "def.h"
|
#include "def.h"
|
||||||
|
#include "event.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "pixmap.h"
|
#include "pixmap.h"
|
||||||
|
|
||||||
@ -40,7 +41,7 @@
|
|||||||
|
|
||||||
// Constructeur.
|
// Constructeur.
|
||||||
|
|
||||||
CPixmap::CPixmap ()
|
CPixmap::CPixmap (CEvent * event)
|
||||||
{
|
{
|
||||||
Sint32 i;
|
Sint32 i;
|
||||||
|
|
||||||
@ -56,6 +57,8 @@ CPixmap::CPixmap ()
|
|||||||
m_lpSDLCursors[i] = nullptr;
|
m_lpSDLCursors[i] = nullptr;
|
||||||
|
|
||||||
m_lpCurrentCursor = nullptr;
|
m_lpCurrentCursor = nullptr;
|
||||||
|
this->mainTexture = nullptr;
|
||||||
|
this->event = event;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructeur.
|
// Destructeur.
|
||||||
@ -83,6 +86,9 @@ CPixmap::~CPixmap ()
|
|||||||
|
|
||||||
if (m_lpSDLBlupi)
|
if (m_lpSDLBlupi)
|
||||||
SDL_FreeSurface (m_lpSDLBlupi);
|
SDL_FreeSurface (m_lpSDLBlupi);
|
||||||
|
|
||||||
|
if (this->mainTexture)
|
||||||
|
SDL_DestroyTexture (this->mainTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cr�e l'objet DirectDraw principal.
|
// Cr�e l'objet DirectDraw principal.
|
||||||
@ -118,8 +124,25 @@ CPixmap::BltFast (Sint32 dstCh, size_t srcCh, Rect dstR, Rect srcR)
|
|||||||
|
|
||||||
if (dstCh < 0)
|
if (dstCh < 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (!this->mainTexture && g_bFullScreen && g_zoom == 1)
|
||||||
|
{
|
||||||
|
SDL_SetHint (SDL_HINT_RENDER_SCALE_QUALITY, "best");
|
||||||
|
this->mainTexture = SDL_CreateTexture (
|
||||||
|
g_renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, LXIMAGE,
|
||||||
|
LYIMAGE);
|
||||||
|
SDL_SetHint (SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
|
||||||
|
}
|
||||||
|
else if (this->mainTexture && !(g_bFullScreen && g_zoom == 1))
|
||||||
|
{
|
||||||
|
SDL_DestroyTexture (this->mainTexture);
|
||||||
|
this->mainTexture = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SetRenderTarget (g_renderer, this->mainTexture);
|
||||||
res = SDL_RenderCopy (
|
res = SDL_RenderCopy (
|
||||||
g_renderer, m_SDLTextureInfo[srcCh].texture, &srcRect, &dstRect);
|
g_renderer, m_SDLTextureInfo[srcCh].texture, &srcRect, &dstRect);
|
||||||
|
SDL_SetRenderTarget (g_renderer, nullptr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -711,6 +734,10 @@ bool
|
|||||||
CPixmap::Display ()
|
CPixmap::Display ()
|
||||||
{
|
{
|
||||||
m_bBackDisplayed = true;
|
m_bBackDisplayed = true;
|
||||||
|
|
||||||
|
if (this->mainTexture)
|
||||||
|
SDL_RenderCopy (g_renderer, this->mainTexture, nullptr, nullptr);
|
||||||
|
|
||||||
SDL_RenderPresent (g_renderer);
|
SDL_RenderPresent (g_renderer);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -881,7 +908,7 @@ CPixmap::GetCursorRect (MouseSprites sprite)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CPixmap::LoadCursors (Uint8 scale)
|
CPixmap::LoadCursors ()
|
||||||
{
|
{
|
||||||
Uint32 rmask, gmask, bmask, amask;
|
Uint32 rmask, gmask, bmask, amask;
|
||||||
|
|
||||||
@ -899,6 +926,8 @@ on the endianness (byte order) of the machine */
|
|||||||
amask = 0xff000000;
|
amask = 0xff000000;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
auto scale = this->GetDisplayScale ();
|
||||||
|
|
||||||
for (int i = SPRITE_BEGIN; i <= SPRITE_END; ++i)
|
for (int i = SPRITE_BEGIN; i <= SPRITE_END; ++i)
|
||||||
{
|
{
|
||||||
MouseSprites sprite = static_cast<MouseSprites> (i);
|
MouseSprites sprite = static_cast<MouseSprites> (i);
|
||||||
@ -929,3 +958,58 @@ CPixmap::ChangeSprite (MouseSprites sprite)
|
|||||||
SDL_SetCursor (m_lpSDLCursors[sprite - 1]);
|
SDL_SetCursor (m_lpSDLCursors[sprite - 1]);
|
||||||
m_lpCurrentCursor = m_lpSDLCursors[sprite - 1];
|
m_lpCurrentCursor = m_lpSDLCursors[sprite - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
CPixmap::GetDisplayScale ()
|
||||||
|
{
|
||||||
|
// SDL_DisplayMode displayMode;
|
||||||
|
// SDL_GetWindowDisplayMode (g_window, &displayMode);
|
||||||
|
Sint32 w, h;
|
||||||
|
SDL_GetWindowSize (g_window, &w, &h);
|
||||||
|
return static_cast<double> (h / LYIMAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CPixmap::FromDisplayToGame (Sint32 & x, Sint32 & y)
|
||||||
|
{
|
||||||
|
if (this->event->IsDemoPlaying ())
|
||||||
|
return;
|
||||||
|
|
||||||
|
SDL_DisplayMode displayMode;
|
||||||
|
SDL_GetWindowDisplayMode (g_window, &displayMode);
|
||||||
|
|
||||||
|
if (
|
||||||
|
static_cast<double> (displayMode.w) / displayMode.h ==
|
||||||
|
static_cast<double> (SCRNUM) / SCRDEN)
|
||||||
|
return;
|
||||||
|
|
||||||
|
double w = displayMode.w, h = displayMode.h;
|
||||||
|
double ratio = w * SCRDEN / SCRNUM;
|
||||||
|
|
||||||
|
x = (x - (w - ratio) / 2) / (ratio / LXIMAGE);
|
||||||
|
y = y / (h / LYIMAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CPixmap::FromGameToDisplay (Sint32 & x, Sint32 & y)
|
||||||
|
{
|
||||||
|
Sint32 w, h;
|
||||||
|
SDL_GetWindowSize (g_window, &w, &h);
|
||||||
|
|
||||||
|
double factor = 1;
|
||||||
|
|
||||||
|
if (!g_bFullScreen)
|
||||||
|
factor = g_zoom;
|
||||||
|
|
||||||
|
x *= factor;
|
||||||
|
y *= factor;
|
||||||
|
|
||||||
|
if (static_cast<double> (w) / h == static_cast<double> (SCRNUM) / SCRDEN)
|
||||||
|
return;
|
||||||
|
|
||||||
|
double _w = w, _h = h;
|
||||||
|
double ratio = w * SCRDEN / SCRNUM;
|
||||||
|
|
||||||
|
x = x * ratio / LXIMAGE + (_w - ratio) / 2;
|
||||||
|
y = y * _h / LYIMAGE;
|
||||||
|
}
|
||||||
|
14
src/pixmap.h
14
src/pixmap.h
@ -47,6 +47,8 @@ struct TextureInfo {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CEvent;
|
||||||
|
|
||||||
class CPixmap
|
class CPixmap
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -55,7 +57,7 @@ public:
|
|||||||
EXPAND,
|
EXPAND,
|
||||||
};
|
};
|
||||||
|
|
||||||
CPixmap ();
|
CPixmap (CEvent * event);
|
||||||
~CPixmap ();
|
~CPixmap ();
|
||||||
|
|
||||||
bool Create (Point dim);
|
bool Create (Point dim);
|
||||||
@ -88,9 +90,14 @@ public:
|
|||||||
|
|
||||||
void SetMouseSprite (MouseSprites sprite);
|
void SetMouseSprite (MouseSprites sprite);
|
||||||
void MouseShow (bool bShow);
|
void MouseShow (bool bShow);
|
||||||
void LoadCursors (Uint8 scale);
|
void LoadCursors ();
|
||||||
void ChangeSprite (MouseSprites sprite);
|
void ChangeSprite (MouseSprites sprite);
|
||||||
|
|
||||||
|
public:
|
||||||
|
double GetDisplayScale ();
|
||||||
|
void FromDisplayToGame (Sint32 & x, Sint32 & y);
|
||||||
|
void FromGameToDisplay (Sint32 & x, Sint32 & y);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Sint32 BltFast (Sint32 dstCh, size_t srcCh, Rect dstR, Rect srcR);
|
Sint32 BltFast (Sint32 dstCh, size_t srcCh, Rect dstR, Rect srcR);
|
||||||
Sint32 BltFast (Sint32 chDst, size_t channel, Point dst, Rect rcRect);
|
Sint32 BltFast (Sint32 chDst, size_t channel, Point dst, Rect rcRect);
|
||||||
@ -111,8 +118,11 @@ protected:
|
|||||||
MouseSprites m_mouseSprite;
|
MouseSprites m_mouseSprite;
|
||||||
bool m_bBackDisplayed;
|
bool m_bBackDisplayed;
|
||||||
|
|
||||||
|
CEvent * event;
|
||||||
|
|
||||||
SDL_Cursor * m_lpCurrentCursor;
|
SDL_Cursor * m_lpCurrentCursor;
|
||||||
SDL_Cursor * m_lpSDLCursors[MAXCURSORS];
|
SDL_Cursor * m_lpSDLCursors[MAXCURSORS];
|
||||||
SDL_Surface * m_lpSDLBlupi;
|
SDL_Surface * m_lpSDLBlupi;
|
||||||
|
SDL_Texture * mainTexture;
|
||||||
std::unordered_map<size_t, TextureInfo> m_SDLTextureInfo;
|
std::unordered_map<size_t, TextureInfo> m_SDLTextureInfo;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user