mirror of
https://github.com/blupi-games/planetblupi
synced 2024-12-30 10:15:36 +01:00
Retrieve the right ratio accordingly to the current display
It's no longer forced to 16:9.
This commit is contained in:
parent
9a7ffb887f
commit
988962d74a
@ -202,8 +202,8 @@ UpdateFrame (void)
|
||||
|
||||
rcRect.left = 0;
|
||||
rcRect.top = 0;
|
||||
rcRect.right = LXIMAGE;
|
||||
rcRect.bottom = LYIMAGE;
|
||||
rcRect.right = LXIMAGE ();
|
||||
rcRect.bottom = LYIMAGE ();
|
||||
g_pPixmap->DrawImage (-1, CHBACK, rcRect); // draw the background
|
||||
|
||||
if (phase == EV_PHASE_INTRO1)
|
||||
@ -729,10 +729,12 @@ DoInit (int argc, char * argv[], bool & exit)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
Display::getDisplay ().readDisplaySize ();
|
||||
|
||||
// Create a window.
|
||||
g_window = SDL_CreateWindow (
|
||||
gettext ("Planet Blupi"), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||
LXIMAGE, LYIMAGE, 0);
|
||||
LXIMAGE (), LYIMAGE (), 0);
|
||||
|
||||
if (!g_window)
|
||||
{
|
||||
@ -755,7 +757,7 @@ DoInit (int argc, char * argv[], bool & exit)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
SDL_RenderSetLogicalSize (g_renderer, LXIMAGE, LYIMAGE);
|
||||
SDL_RenderSetLogicalSize (g_renderer, LXIMAGE (), LYIMAGE ());
|
||||
|
||||
const auto renders = SDL_GetNumRenderDrivers ();
|
||||
for (int i = 0; i < renders; ++i)
|
||||
@ -798,8 +800,8 @@ DoInit (int argc, char * argv[], bool & exit)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
totalDim.x = LXIMAGE;
|
||||
totalDim.y = LYIMAGE;
|
||||
totalDim.x = LXIMAGE ();
|
||||
totalDim.y = LYIMAGE ();
|
||||
if (!g_pPixmap->Create (totalDim))
|
||||
{
|
||||
InitFail ("Create pixmap");
|
||||
@ -807,8 +809,8 @@ DoInit (int argc, char * argv[], bool & exit)
|
||||
}
|
||||
|
||||
OutputDebug ("Image: init\n");
|
||||
totalDim.x = LXLOGIC;
|
||||
totalDim.y = LYLOGIC;
|
||||
totalDim.x = LXLOGIC ();
|
||||
totalDim.y = LYLOGIC ();
|
||||
iconDim.x = 0;
|
||||
iconDim.y = 0;
|
||||
#if _INTRO
|
||||
@ -819,28 +821,28 @@ DoInit (int argc, char * argv[], bool & exit)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
OutputDebug ("Image: init\n");
|
||||
totalDim.x = LXIMAGE;
|
||||
totalDim.y = LYIMAGE;
|
||||
totalDim.x = LXIMAGE ();
|
||||
totalDim.y = LYIMAGE ();
|
||||
if (!g_pPixmap->Cache (CHGROUND, totalDim))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
rcRect.left = 0;
|
||||
rcRect.top = 0;
|
||||
rcRect.right = LXLOGIC;
|
||||
rcRect.bottom = LYLOGIC;
|
||||
rcRect.right = LXLOGIC ();
|
||||
rcRect.bottom = LYLOGIC ();
|
||||
g_pPixmap->DrawImage (-1, CHBACK, rcRect); // dessine le fond
|
||||
g_pPixmap->Display ();
|
||||
|
||||
totalDim.x = LXLOGIC;
|
||||
totalDim.y = LYLOGIC;
|
||||
totalDim.x = LXLOGIC ();
|
||||
totalDim.y = LYLOGIC ();
|
||||
iconDim.x = 0;
|
||||
iconDim.y = 0;
|
||||
if (!g_pPixmap->Cache (
|
||||
CHBACKBUILD, "image/back-build.png", totalDim, iconDim))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
totalDim.x = LXLOGIC;
|
||||
totalDim.y = LYLOGIC;
|
||||
totalDim.x = LXLOGIC ();
|
||||
totalDim.y = LYLOGIC ();
|
||||
iconDim.x = 0;
|
||||
iconDim.y = 0;
|
||||
if (!g_pPixmap->Cache (CHBACKBOOK, "image/back-book.png", totalDim, iconDim))
|
||||
|
@ -2220,8 +2220,8 @@ CDecor::GoalStop (Sint32 rank, bool bError, bool bSound)
|
||||
{
|
||||
if (bError)
|
||||
{
|
||||
pos.x = LXIMAGE / 2;
|
||||
pos.y = LYIMAGE / 2;
|
||||
pos.x = LXIMAGE () / 2;
|
||||
pos.y = LYIMAGE () / 2;
|
||||
BlupiSound (
|
||||
rank, table_sound_boing[Random (0, countof (table_sound_boing) - 1)],
|
||||
pos, true);
|
||||
@ -4145,9 +4145,9 @@ CDecor::BlupiGoal (Point cel, Buttons button)
|
||||
}
|
||||
if (avg.x < 0)
|
||||
avg.x = 0;
|
||||
if (avg.x > LXIMAGE)
|
||||
avg.x = LXIMAGE;
|
||||
avg.y = LYIMAGE / 2;
|
||||
if (avg.x > LXIMAGE ())
|
||||
avg.x = LXIMAGE ();
|
||||
avg.y = LYIMAGE () / 2;
|
||||
|
||||
if (nb == 0 && nbHili > 0)
|
||||
{
|
||||
@ -4588,8 +4588,8 @@ CDecor::IsTerminated ()
|
||||
Sint32 nb, count, out;
|
||||
Point pos;
|
||||
|
||||
pos.x = LXIMAGE / 2;
|
||||
pos.y = LYIMAGE / 2;
|
||||
pos.x = LXIMAGE () / 2;
|
||||
pos.y = LYIMAGE () / 2;
|
||||
|
||||
count = m_winCount;
|
||||
m_winCount = 50;
|
||||
|
@ -3315,8 +3315,8 @@ CDecor::MemoPos (Sint32 rank, bool bRecord)
|
||||
{
|
||||
Point pos;
|
||||
|
||||
pos.x = LXIMAGE / 2;
|
||||
pos.y = LYIMAGE / 2;
|
||||
pos.x = LXIMAGE () / 2;
|
||||
pos.y = LYIMAGE () / 2;
|
||||
|
||||
if (rank < 0 || rank >= 4)
|
||||
return;
|
||||
|
@ -817,8 +817,8 @@ CDecor::StatisticDown (Point pos)
|
||||
if (m_statFirst < STATNB - 1)
|
||||
m_statFirst = 0;
|
||||
StatisticUpdate ();
|
||||
pos.x = LXIMAGE / 2;
|
||||
pos.y = LYIMAGE / 2;
|
||||
pos.x = LXIMAGE () / 2;
|
||||
pos.y = LYIMAGE () / 2;
|
||||
m_pSound->PlayImage (SOUND_OPEN, pos);
|
||||
return true;
|
||||
}
|
||||
@ -830,8 +830,8 @@ CDecor::StatisticDown (Point pos)
|
||||
else
|
||||
m_statFirst += STATNB - 2;
|
||||
StatisticUpdate ();
|
||||
pos.x = LXIMAGE / 2;
|
||||
pos.y = LYIMAGE / 2;
|
||||
pos.x = LXIMAGE () / 2;
|
||||
pos.y = LYIMAGE () / 2;
|
||||
m_pSound->PlayImage (SOUND_OPEN, pos);
|
||||
return true;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#define POSDRAWX 144 // draw surface
|
||||
#define POSDRAWY 15
|
||||
#define DIMDRAWX (LXIMAGE - (LXLOGIC - LYLOGIC))
|
||||
#define DIMDRAWX (LXIMAGE () - (LXLOGIC () - LYLOGIC ()))
|
||||
#define DIMDRAWY 450
|
||||
|
||||
#define POSMAPX 8 // map surface
|
||||
|
@ -4,52 +4,43 @@
|
||||
#include "blupi.h"
|
||||
#include "display.h"
|
||||
|
||||
#define SCRNUM 16
|
||||
#define SCRDEN 9
|
||||
#define SCRFACTOR SCRNUM / SCRDEN
|
||||
|
||||
Display::Display ()
|
||||
{
|
||||
this->width = 0;
|
||||
this->height = 0;
|
||||
this->width = this->getLogicWidth ();
|
||||
this->height = this->getLogicHeight ();
|
||||
}
|
||||
|
||||
Display &
|
||||
Display::getDisplay ()
|
||||
{
|
||||
static Display display;
|
||||
return display;
|
||||
}
|
||||
|
||||
void
|
||||
Display::readDisplaySize ()
|
||||
{
|
||||
SDL_DisplayMode displayMode;
|
||||
SDL_GetWindowDisplayMode (g_window, &displayMode);
|
||||
int res;
|
||||
|
||||
if (g_window)
|
||||
res = SDL_GetWindowDisplayMode (g_window, &displayMode);
|
||||
else
|
||||
res = SDL_GetCurrentDisplayMode (0, &displayMode);
|
||||
|
||||
if (res < 0)
|
||||
return;
|
||||
|
||||
this->width = displayMode.w;
|
||||
this->height = displayMode.h;
|
||||
}
|
||||
|
||||
Display &
|
||||
Display::getDisplay ()
|
||||
{
|
||||
static bool init = false;
|
||||
static Display display;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
display.readDisplaySize ();
|
||||
init = true;
|
||||
}
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
double
|
||||
Display::getRatio ()
|
||||
{
|
||||
return this->width / this->height;
|
||||
}
|
||||
|
||||
Sint32
|
||||
Display::getWidth ()
|
||||
{
|
||||
return (
|
||||
this->getLogicHeight () * SCRFACTOR +
|
||||
(this->getLogicHeight () * SCRFACTOR) % 2);
|
||||
this->getLogicHeight () * this->width / this->height +
|
||||
(this->getLogicHeight () * this->width / this->height) % 2);
|
||||
}
|
||||
|
||||
Sint32
|
||||
|
@ -12,20 +12,42 @@ private:
|
||||
private:
|
||||
Display ();
|
||||
|
||||
void readDisplaySize ();
|
||||
|
||||
public:
|
||||
static Display & getDisplay ();
|
||||
|
||||
double getRatio ();
|
||||
void readDisplaySize ();
|
||||
Sint32 getWidth ();
|
||||
Sint32 getHeight ();
|
||||
Sint32 getLogicWidth ();
|
||||
Sint32 getLogicHeight ();
|
||||
};
|
||||
|
||||
#define LXLOGIC (Display::getDisplay ().getLogicWidth ())
|
||||
#define LYLOGIC (Display::getDisplay ().getLogicHeight ())
|
||||
#define LXIMAGE (Display::getDisplay ().getWidth ())
|
||||
#define LYIMAGE (Display::getDisplay ().getHeight ())
|
||||
#define LXOFFSET ((LXIMAGE - LXLOGIC) / 2)
|
||||
inline Sint32
|
||||
LXLOGIC ()
|
||||
{
|
||||
return Display::getDisplay ().getLogicWidth ();
|
||||
}
|
||||
|
||||
inline Sint32
|
||||
LYLOGIC ()
|
||||
{
|
||||
return Display::getDisplay ().getLogicHeight ();
|
||||
}
|
||||
|
||||
inline Sint32
|
||||
LXIMAGE ()
|
||||
{
|
||||
return Display::getDisplay ().getWidth ();
|
||||
}
|
||||
|
||||
inline Sint32
|
||||
LYIMAGE ()
|
||||
{
|
||||
return Display::getDisplay ().getHeight ();
|
||||
}
|
||||
|
||||
inline Sint32
|
||||
LXOFFSET ()
|
||||
{
|
||||
return ((LXIMAGE () - LXLOGIC ()) / 2);
|
||||
}
|
||||
|
128
src/event.cxx
128
src/event.cxx
@ -1818,7 +1818,7 @@ CEvent::SetWindowSize (double prevScale, double newScale)
|
||||
if (g_bFullScreen && newScale == 2)
|
||||
newScale = 1;
|
||||
|
||||
SDL_SetWindowSize (g_window, LXIMAGE * newScale, LYIMAGE * newScale);
|
||||
SDL_SetWindowSize (g_window, LXIMAGE () * newScale, LYIMAGE () * newScale);
|
||||
SDL_RenderClear (g_renderer);
|
||||
SDL_RenderPresent (g_renderer);
|
||||
|
||||
@ -2001,18 +2001,18 @@ CEvent::CreateButtons (Sint32 phase)
|
||||
message = table[m_index].buttons[i].message;
|
||||
|
||||
if (phase != EV_PHASE_PLAY && phase != EV_PHASE_BUILD)
|
||||
pos.x += LXOFFSET;
|
||||
pos.x += LXOFFSET ();
|
||||
|
||||
if (m_bPrivate)
|
||||
{
|
||||
if (message == EV_PHASE_SKILL1)
|
||||
{
|
||||
pos.x = 117 + LXOFFSET;
|
||||
pos.x = 117 + LXOFFSET ();
|
||||
pos.y = 115;
|
||||
}
|
||||
if (message == EV_PHASE_SKILL2)
|
||||
{
|
||||
pos.x = 117 + LXOFFSET;
|
||||
pos.x = 117 + LXOFFSET ();
|
||||
pos.y = 115 + 42;
|
||||
}
|
||||
}
|
||||
@ -2112,13 +2112,13 @@ CEvent::DrawButtons ()
|
||||
snprintf (
|
||||
res, sizeof (res), "%s %u.%u.%u%s", gettext ("Version"), PB_VERSION_MAJOR,
|
||||
PB_VERSION_MINOR, PB_VERSION_PATCH, PB_VERSION_EXTRA);
|
||||
pos.x = LXIMAGE - GetTextWidth (res, FONTLITTLE) - 4;
|
||||
pos.x = LXIMAGE () - GetTextWidth (res, FONTLITTLE) - 4;
|
||||
pos.y = 465;
|
||||
DrawText (m_pPixmap, pos, res, FONTLITTLE);
|
||||
|
||||
if (!this->m_updateVersion.empty () && this->m_updateBlinking++ % 80 < 40)
|
||||
{
|
||||
pos.x = 70 + LXOFFSET;
|
||||
pos.x = 70 + LXOFFSET ();
|
||||
pos.y = 465;
|
||||
snprintf (
|
||||
res, sizeof (res),
|
||||
@ -2262,7 +2262,7 @@ CEvent::DrawButtons ()
|
||||
|
||||
// Dessine la vitesse.
|
||||
pos.x = 64;
|
||||
pos.y = LYIMAGE - 15;
|
||||
pos.y = LYIMAGE () - 15;
|
||||
rect.left = pos.x;
|
||||
rect.right = pos.x + 20;
|
||||
rect.top = pos.y;
|
||||
@ -2339,7 +2339,7 @@ CEvent::DrawButtons ()
|
||||
else
|
||||
snprintf (res, sizeof (res), "%s", gettext ("Save this game"));
|
||||
|
||||
pos.x = 420 + LXOFFSET;
|
||||
pos.x = 420 + LXOFFSET ();
|
||||
pos.y = 8;
|
||||
DrawText (m_pPixmap, pos, res);
|
||||
|
||||
@ -2350,11 +2350,11 @@ CEvent::DrawButtons ()
|
||||
|
||||
snprintf (text, sizeof (text), "%d", i + 1);
|
||||
lg = GetTextWidth (text);
|
||||
pos.x = (420 + 460) / 2 - lg / 2 + LXOFFSET;
|
||||
pos.x = (420 + 460) / 2 - lg / 2 + LXOFFSET ();
|
||||
pos.y = 30 + 12 + 42 * i;
|
||||
DrawText (m_pPixmap, pos, text, FONTSLIM);
|
||||
|
||||
pos.x = 420 + 50 + LXOFFSET;
|
||||
pos.x = 420 + 50 + LXOFFSET ();
|
||||
|
||||
if (world >= 0)
|
||||
{
|
||||
@ -2384,16 +2384,16 @@ CEvent::DrawButtons ()
|
||||
Term * pTerm = m_pDecor->GetTerminated ();
|
||||
|
||||
DrawTextCenter (
|
||||
gettext ("Ending conditions"), (10 + 134) / 2 + LXOFFSET, 20);
|
||||
gettext ("Ending conditions"), (10 + 134) / 2 + LXOFFSET (), 20);
|
||||
|
||||
pos.x = 170 + 42 * 2 + 4 + LXOFFSET;
|
||||
pos.x = 170 + 42 * 2 + 4 + LXOFFSET ();
|
||||
pos.y = 30 + 12 + 42 * 4;
|
||||
snprintf (
|
||||
text, sizeof (text), gettext ("Lost if less than %d Blupi"),
|
||||
pTerm->nbMinBlupi);
|
||||
DrawText (m_pPixmap, pos, text);
|
||||
|
||||
pos.x = 170 + 42 * 2 + 4 + LXOFFSET;
|
||||
pos.x = 170 + 42 * 2 + 4 + LXOFFSET ();
|
||||
pos.y = 30 + 12 + 42 * 5;
|
||||
snprintf (
|
||||
text, sizeof (text), gettext ("Impossible to win if less than %d Blupi"),
|
||||
@ -2404,15 +2404,16 @@ CEvent::DrawButtons ()
|
||||
// Dessine les textes pour les choix des boutons.
|
||||
if (m_phase == EV_PHASE_BUTTON)
|
||||
DrawTextCenter (
|
||||
gettext ("Available buttons"), (10 + 134) / 2 + LXOFFSET, 20);
|
||||
gettext ("Available buttons"), (10 + 134) / 2 + LXOFFSET (), 20);
|
||||
|
||||
// Dessine les textes pour le choix des musiques.
|
||||
if (m_phase == EV_PHASE_MUSIC)
|
||||
DrawTextCenter (gettext ("Music choice"), (10 + 134) / 2 + LXOFFSET, 20);
|
||||
DrawTextCenter (gettext ("Music choice"), (10 + 134) / 2 + LXOFFSET (), 20);
|
||||
|
||||
// Dessine les textes pour le choix de la région.
|
||||
if (m_phase == EV_PHASE_REGION)
|
||||
DrawTextCenter (gettext ("Scenery choice"), (10 + 134) / 2 + LXOFFSET, 20);
|
||||
DrawTextCenter (
|
||||
gettext ("Scenery choice"), (10 + 134) / 2 + LXOFFSET (), 20);
|
||||
|
||||
// Ajoute "Mission numéro".
|
||||
if (m_phase == EV_PHASE_INFO)
|
||||
@ -2426,7 +2427,7 @@ CEvent::DrawButtons ()
|
||||
snprintf (res, sizeof (res), "%s", gettext ("Construction number"));
|
||||
|
||||
lg = GetTextWidth (res);
|
||||
pos.x = (140 + 270) / 2 - lg / 2 + LXOFFSET;
|
||||
pos.x = (140 + 270) / 2 - lg / 2 + LXOFFSET ();
|
||||
pos.y = 70;
|
||||
if (m_bSchool)
|
||||
pos.x -= 40;
|
||||
@ -2442,7 +2443,7 @@ CEvent::DrawButtons ()
|
||||
{
|
||||
char * text = gettext ("Game paused");
|
||||
lg = GetTextWidth (text);
|
||||
pos.x = (140 + 270) / 2 - lg / 2 + LXOFFSET;
|
||||
pos.x = (140 + 270) / 2 - lg / 2 + LXOFFSET ();
|
||||
pos.y = 70;
|
||||
if (m_bSchool)
|
||||
pos.x -= 40;
|
||||
@ -2458,7 +2459,7 @@ CEvent::DrawButtons ()
|
||||
{
|
||||
char * text = gettext ("Help number");
|
||||
lg = GetTextWidth (text);
|
||||
pos.x = (140 + 270) / 2 - lg / 2 + LXOFFSET;
|
||||
pos.x = (140 + 270) / 2 - lg / 2 + LXOFFSET ();
|
||||
pos.y = 70;
|
||||
if (m_bSchool)
|
||||
pos.x -= 40;
|
||||
@ -2482,7 +2483,7 @@ CEvent::DrawButtons ()
|
||||
world = m_private;
|
||||
|
||||
lg = GetBignumWidth (world + 1);
|
||||
pos.x = (140 + 270) / 2 - lg / 2 + LXOFFSET;
|
||||
pos.x = (140 + 270) / 2 - lg / 2 + LXOFFSET ();
|
||||
pos.y = 100;
|
||||
if (m_bSchool)
|
||||
pos.x -= 40;
|
||||
@ -2510,7 +2511,7 @@ CEvent::DrawButtons ()
|
||||
pos.x = 150 + 50;
|
||||
pos.y = 230 + 13;
|
||||
}
|
||||
pos.x += LXOFFSET;
|
||||
pos.x += LXOFFSET ();
|
||||
DrawText (m_pPixmap, pos, gettext ("Easy"), FONTSLIM);
|
||||
}
|
||||
|
||||
@ -2526,7 +2527,7 @@ CEvent::DrawButtons ()
|
||||
pos.x = 150 + 50;
|
||||
pos.y = 230 + 42 + 13;
|
||||
}
|
||||
pos.x += LXOFFSET;
|
||||
pos.x += LXOFFSET ();
|
||||
DrawText (m_pPixmap, pos, gettext ("Difficult"), FONTSLIM);
|
||||
}
|
||||
}
|
||||
@ -2551,7 +2552,7 @@ CEvent::DrawButtons ()
|
||||
pente = 0;
|
||||
else
|
||||
pente = 19;
|
||||
pos.x += LXOFFSET;
|
||||
pos.x += LXOFFSET ();
|
||||
DrawTextRect (m_pPixmap, pos, m_libelle, pente, FONTSLIM);
|
||||
}
|
||||
|
||||
@ -2566,7 +2567,7 @@ CEvent::DrawButtons ()
|
||||
gettext ("No, not that way !"),
|
||||
};
|
||||
|
||||
pos.x = 60 + LXOFFSET;
|
||||
pos.x = 60 + LXOFFSET ();
|
||||
pos.y = 443;
|
||||
DrawText (m_pPixmap, pos, list[GetWorld () % 5]);
|
||||
}
|
||||
@ -2580,7 +2581,7 @@ CEvent::DrawButtons ()
|
||||
gettext ("Mission over..."),
|
||||
};
|
||||
|
||||
pos.x = 60 + LXOFFSET;
|
||||
pos.x = 60 + LXOFFSET ();
|
||||
pos.y = 443;
|
||||
DrawText (m_pPixmap, pos, list[GetWorld () % 5]);
|
||||
}
|
||||
@ -2597,7 +2598,7 @@ CEvent::DrawButtons ()
|
||||
if (m_bPrivate)
|
||||
text = gettext ("Last construction resolved !");
|
||||
|
||||
pos.x = 60 + LXOFFSET;
|
||||
pos.x = 60 + LXOFFSET ();
|
||||
pos.y = 443;
|
||||
DrawText (m_pPixmap, pos, text);
|
||||
}
|
||||
@ -2605,28 +2606,29 @@ CEvent::DrawButtons ()
|
||||
// Draw the game settings.
|
||||
if (m_phase == EV_PHASE_SETUP || m_phase == EV_PHASE_SETUPp)
|
||||
{
|
||||
DrawTextCenter (gettext ("Global game\nspeed"), 54 + 40 + LXOFFSET, 80);
|
||||
DrawTextCenter (gettext ("Global game\nspeed"), 54 + 40 + LXOFFSET (), 80);
|
||||
DrawTextCenter (
|
||||
gettext ("Scroll speed\nwith mouse"), 169 + 40 + LXOFFSET, 80);
|
||||
DrawTextCenter (gettext ("Sound effect\nvolume"), 284 + 40 + LXOFFSET, 80);
|
||||
DrawTextCenter (gettext ("Music\nvolume"), 399 + 40 + LXOFFSET, 80);
|
||||
DrawTextCenter (gettext ("Video\nsequences"), 514 + 40 + LXOFFSET, 80);
|
||||
gettext ("Scroll speed\nwith mouse"), 169 + 40 + LXOFFSET (), 80);
|
||||
DrawTextCenter (
|
||||
gettext ("Sound effect\nvolume"), 284 + 40 + LXOFFSET (), 80);
|
||||
DrawTextCenter (gettext ("Music\nvolume"), 399 + 40 + LXOFFSET (), 80);
|
||||
DrawTextCenter (gettext ("Video\nsequences"), 514 + 40 + LXOFFSET (), 80);
|
||||
|
||||
snprintf (res, sizeof (res), "x%d", m_speed);
|
||||
lg = GetTextWidth (res);
|
||||
pos.x = (54 + 40) - lg / 2 + LXOFFSET;
|
||||
pos.x = (54 + 40) - lg / 2 + LXOFFSET ();
|
||||
pos.y = 330 - 20;
|
||||
DrawText (m_pPixmap, pos, res);
|
||||
|
||||
snprintf (res, sizeof (res), "%d", m_pSound->GetAudioVolume ());
|
||||
lg = GetTextWidth (res);
|
||||
pos.x = (284 + 40) - lg / 2 + LXOFFSET;
|
||||
pos.x = (284 + 40) - lg / 2 + LXOFFSET ();
|
||||
pos.y = 330 - 20;
|
||||
DrawText (m_pPixmap, pos, res);
|
||||
|
||||
snprintf (res, sizeof (res), "%d", m_pSound->GetMidiVolume ());
|
||||
lg = GetTextWidth (res);
|
||||
pos.x = (399 + 40) - lg / 2 + LXOFFSET;
|
||||
pos.x = (399 + 40) - lg / 2 + LXOFFSET ();
|
||||
pos.y = 330 - 20;
|
||||
DrawText (m_pPixmap, pos, res);
|
||||
|
||||
@ -2634,7 +2636,7 @@ CEvent::DrawButtons ()
|
||||
if (m_pMovie->GetEnable () && m_bMovie)
|
||||
text = gettext ("Yes");
|
||||
lg = GetTextWidth (text);
|
||||
pos.x = (514 + 40) - lg / 2 + LXOFFSET;
|
||||
pos.x = (514 + 40) - lg / 2 + LXOFFSET ();
|
||||
pos.y = 330 - 20;
|
||||
DrawText (m_pPixmap, pos, text);
|
||||
|
||||
@ -2643,7 +2645,7 @@ CEvent::DrawButtons ()
|
||||
else
|
||||
snprintf (res, sizeof (res), "%d", m_scrollSpeed);
|
||||
lg = GetTextWidth (res);
|
||||
pos.x = (169 + 40) - lg / 2 + LXOFFSET;
|
||||
pos.x = (169 + 40) - lg / 2 + LXOFFSET ();
|
||||
pos.y = 330 - 20;
|
||||
DrawText (m_pPixmap, pos, res);
|
||||
}
|
||||
@ -2652,13 +2654,13 @@ CEvent::DrawButtons ()
|
||||
if (m_phase == EV_PHASE_SETTINGS)
|
||||
{
|
||||
DrawTextCenter (
|
||||
gettext ("Interface language\nand sounds"), 54 + 40 + LXOFFSET, 80);
|
||||
gettext ("Interface language\nand sounds"), 54 + 40 + LXOFFSET (), 80);
|
||||
DrawTextCenter (
|
||||
gettext ("Select the\nwindow mode"), 169 + 40 + LXOFFSET, 80);
|
||||
gettext ("Select the\nwindow mode"), 169 + 40 + LXOFFSET (), 80);
|
||||
DrawTextCenter (
|
||||
gettext ("Change the\nwindow size"), 284 + 40 + LXOFFSET, 80);
|
||||
gettext ("Change the\nwindow size"), 284 + 40 + LXOFFSET (), 80);
|
||||
DrawTextCenter (
|
||||
gettext ("Choose the\nmusic format"), 399 + 40 + LXOFFSET, 80);
|
||||
gettext ("Choose the\nmusic format"), 399 + 40 + LXOFFSET (), 80);
|
||||
|
||||
const auto locale = GetLocale ();
|
||||
std::string lang;
|
||||
@ -2676,14 +2678,14 @@ CEvent::DrawButtons ()
|
||||
lang = "Polski";
|
||||
|
||||
lg = GetTextWidth (lang.c_str ());
|
||||
pos.x = (54 + 40) - lg / 2 + LXOFFSET;
|
||||
pos.x = (54 + 40) - lg / 2 + LXOFFSET ();
|
||||
pos.y = 330 - 20;
|
||||
DrawText (m_pPixmap, pos, lang.c_str ());
|
||||
|
||||
const char * text =
|
||||
g_bFullScreen ? gettext ("Fullscreen") : gettext ("Windowed");
|
||||
lg = GetTextWidth (text);
|
||||
pos.x = (169 + 40) - lg / 2 + LXOFFSET;
|
||||
pos.x = (169 + 40) - lg / 2 + LXOFFSET ();
|
||||
pos.y = 330 - 20;
|
||||
DrawText (m_pPixmap, pos, text);
|
||||
|
||||
@ -2691,14 +2693,14 @@ CEvent::DrawButtons ()
|
||||
{
|
||||
snprintf (res, sizeof (res), "%dx", g_zoom);
|
||||
lg = GetTextWidth (res);
|
||||
pos.x = (284 + 40) - lg / 2 + LXOFFSET;
|
||||
pos.x = (284 + 40) - lg / 2 + LXOFFSET ();
|
||||
pos.y = 330 - 20;
|
||||
DrawText (m_pPixmap, pos, res);
|
||||
}
|
||||
|
||||
text = (g_restoreMidi && mid) || !ogg ? gettext ("Midi") : gettext ("Ogg");
|
||||
lg = GetTextWidth (text);
|
||||
pos.x = (399 + 40) - lg / 2 + LXOFFSET;
|
||||
pos.x = (399 + 40) - lg / 2 + LXOFFSET ();
|
||||
pos.y = 330 - 20;
|
||||
DrawText (m_pPixmap, pos, text);
|
||||
}
|
||||
@ -2710,14 +2712,14 @@ CEvent::DrawButtons ()
|
||||
|
||||
text = gettext ("You have played Planet Blupi.");
|
||||
lg = GetTextWidth (text);
|
||||
pos.x = LXIMAGE / 2 - lg / 2;
|
||||
pos.x = LXIMAGE () / 2 - lg / 2;
|
||||
pos.y = 20;
|
||||
DrawText (m_pPixmap, pos, text);
|
||||
|
||||
text = gettext ("We hope you have had as much fun playing the game as we "
|
||||
"had making it !");
|
||||
lg = GetTextWidth (text);
|
||||
pos.x = LXIMAGE / 2 - lg / 2;
|
||||
pos.x = LXIMAGE () / 2 - lg / 2;
|
||||
pos.y = 40;
|
||||
DrawText (m_pPixmap, pos, text);
|
||||
|
||||
@ -2741,7 +2743,7 @@ CEvent::DrawButtons ()
|
||||
|
||||
for (size_t i = 0; i < countof (libs); ++i)
|
||||
{
|
||||
pos.x = 30 + LXOFFSET;
|
||||
pos.x = 30 + LXOFFSET ();
|
||||
pos.y = 120 + i * 20;
|
||||
DrawText (m_pPixmap, pos, libs[i].c_str ());
|
||||
}
|
||||
@ -2749,13 +2751,13 @@ CEvent::DrawButtons ()
|
||||
text = gettext ("This game is an original creation of Epsitec SA, CH-1400 "
|
||||
"Yverdon-les-Bains");
|
||||
lg = GetTextWidth (text);
|
||||
pos.x = LXIMAGE / 2 - lg / 2;
|
||||
pos.x = LXIMAGE () / 2 - lg / 2;
|
||||
pos.y = 430;
|
||||
DrawText (m_pPixmap, pos, text);
|
||||
|
||||
text = gettext ("http://www.blupi.org info@blupi.org");
|
||||
lg = GetTextWidth (text);
|
||||
pos.x = LXIMAGE / 2 - lg / 2;
|
||||
pos.x = LXIMAGE () / 2 - lg / 2;
|
||||
pos.y = 450;
|
||||
DrawText (m_pPixmap, pos, text);
|
||||
}
|
||||
@ -2764,7 +2766,7 @@ CEvent::DrawButtons ()
|
||||
if (m_phase == EV_PHASE_INSERT)
|
||||
DrawTextCenter (
|
||||
gettext ("Insert CD-Rom Planet Blupi and wait a few seconds..."),
|
||||
LXIMAGE / 2, 20);
|
||||
LXIMAGE () / 2, 20);
|
||||
|
||||
if (m_phase == EV_PHASE_BUILD)
|
||||
SetEnable (EV_PHASE_UNDO, m_pDecor->IsUndo ());
|
||||
@ -2802,13 +2804,13 @@ CEvent::MousePosToSprite (Point pos)
|
||||
if (pos.x <= 5 && pos.x >= -2)
|
||||
bLeft = true;
|
||||
|
||||
if (pos.x >= LXIMAGE - 5 && pos.x <= LXIMAGE + 2)
|
||||
if (pos.x >= LXIMAGE () - 5 && pos.x <= LXIMAGE () + 2)
|
||||
bRight = true;
|
||||
|
||||
if (pos.y <= 5 && pos.y >= -2)
|
||||
bUp = true;
|
||||
|
||||
if (pos.y >= LYIMAGE - 5 && pos.y <= LYIMAGE + 2)
|
||||
if (pos.y >= LYIMAGE () - 5 && pos.y <= LYIMAGE () + 2)
|
||||
bDown = true;
|
||||
|
||||
if (bLeft)
|
||||
@ -2964,10 +2966,10 @@ CEvent::EventButtons (const SDL_Event & event, Point pos)
|
||||
lg = GetTextWidth (m_textToolTips);
|
||||
pos.x += 10;
|
||||
pos.y += 20;
|
||||
if (pos.x > LXIMAGE - lg)
|
||||
pos.x = LXIMAGE - lg;
|
||||
if (pos.y > LYIMAGE - 14)
|
||||
pos.y = LYIMAGE - 14;
|
||||
if (pos.x > LXIMAGE () - lg)
|
||||
pos.x = LXIMAGE () - lg;
|
||||
if (pos.y > LYIMAGE () - 14)
|
||||
pos.y = LYIMAGE () - 14;
|
||||
m_posToolTips = pos;
|
||||
break;
|
||||
}
|
||||
@ -3297,8 +3299,8 @@ CEvent::ChangePhase (Uint32 phase)
|
||||
filename = table[m_index].backName;
|
||||
if (filename.find ("%.3d") != std::string::npos)
|
||||
filename = string_format (table[m_index].backName, GetImageWorld ());
|
||||
totalDim.x = LXLOGIC;
|
||||
totalDim.y = LYLOGIC;
|
||||
totalDim.x = LXLOGIC ();
|
||||
totalDim.y = LYLOGIC ();
|
||||
iconDim.x = 0;
|
||||
iconDim.y = 0;
|
||||
if (!m_pPixmap->Cache (
|
||||
@ -4257,7 +4259,7 @@ CEvent::ChangeButtons (Sint32 message)
|
||||
Sint32 w1;
|
||||
SDL_GetWindowSize (g_window, &w1, nullptr);
|
||||
SetFullScreen (false);
|
||||
SetWindowSize (g_zoom * static_cast<double> (w1) / LXIMAGE, g_zoom);
|
||||
SetWindowSize (g_zoom * static_cast<double> (w1) / LXIMAGE (), g_zoom);
|
||||
break;
|
||||
}
|
||||
case EV_BUTTON5:
|
||||
@ -5513,8 +5515,8 @@ CEvent::TreatEventBase (const SDL_Event & event)
|
||||
if (m_phase != EV_PHASE_PLAY)
|
||||
ChangePhase (m_phase);
|
||||
|
||||
pos.x = LXIMAGE / 2;
|
||||
pos.y = LYIMAGE / 2;
|
||||
pos.x = LXIMAGE () / 2;
|
||||
pos.y = LYIMAGE () / 2;
|
||||
if (bEnable)
|
||||
m_pSound->PlayImage (SOUND_GOAL, pos);
|
||||
else
|
||||
@ -5722,8 +5724,8 @@ CEvent::TreatEventBase (const SDL_Event & event)
|
||||
sound = SOUND_CLOSE;
|
||||
else
|
||||
sound = SOUND_OPEN;
|
||||
pos.x = LXIMAGE / 2;
|
||||
pos.y = LYIMAGE / 2;
|
||||
pos.x = LXIMAGE () / 2;
|
||||
pos.y = LYIMAGE () / 2;
|
||||
m_pSound->PlayImage (sound, pos);
|
||||
m_pDecor->SetInfoMode (!m_pDecor->GetInfoMode ());
|
||||
}
|
||||
|
@ -290,10 +290,10 @@ CMovie::Render ()
|
||||
Kit_GetVideoData (m_player, m_videoTex);
|
||||
|
||||
SDL_Rect dstRect;
|
||||
dstRect.x = (LXIMAGE - LXLOGIC) / 2;
|
||||
dstRect.x = (LXIMAGE () - LXLOGIC ()) / 2;
|
||||
dstRect.y = 0;
|
||||
dstRect.w = LXLOGIC;
|
||||
dstRect.h = LYLOGIC;
|
||||
dstRect.w = LXLOGIC ();
|
||||
dstRect.h = LYLOGIC ();
|
||||
SDL_RenderCopy (g_renderer, m_videoTex, nullptr, &dstRect);
|
||||
|
||||
SDL_RenderPresent (g_renderer);
|
||||
|
@ -130,8 +130,8 @@ CPixmap::BltFast (Sint32 dstCh, size_t srcCh, Rect dstR, Rect srcR)
|
||||
{
|
||||
SDL_SetHint (SDL_HINT_RENDER_SCALE_QUALITY, "best");
|
||||
this->mainTexture = SDL_CreateTexture (
|
||||
g_renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, LXIMAGE,
|
||||
LYIMAGE);
|
||||
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))
|
||||
@ -323,8 +323,8 @@ CPixmap::Cache (
|
||||
SDL_QueryTexture (texture, &format, &access, &ow, &oh);
|
||||
|
||||
auto m = mode == EXPAND || channel == CHBACK;
|
||||
w = m ? LXIMAGE : ow;
|
||||
h = m ? LYIMAGE : oh;
|
||||
w = m ? LXIMAGE () : ow;
|
||||
h = m ? LYIMAGE () : oh;
|
||||
|
||||
if (m_SDLTextureInfo.find (channel) == m_SDLTextureInfo.end ())
|
||||
{
|
||||
@ -361,20 +361,20 @@ CPixmap::Cache (
|
||||
{
|
||||
case FIX:
|
||||
{
|
||||
if (channel == CHBACK && (ow < LXIMAGE || oh < LYIMAGE))
|
||||
if (channel == CHBACK && (ow < LXIMAGE () || oh < LYIMAGE ()))
|
||||
{
|
||||
if (chBackWide > 0)
|
||||
{
|
||||
Rect srcRect;
|
||||
srcRect.left = 0;
|
||||
srcRect.right = LXIMAGE;
|
||||
srcRect.right = LXIMAGE ();
|
||||
srcRect.top = 0;
|
||||
srcRect.bottom = LYIMAGE;
|
||||
srcRect.bottom = LYIMAGE ();
|
||||
this->DrawImage (-1, chBackWide, srcRect);
|
||||
}
|
||||
|
||||
SDL_Rect dst;
|
||||
dst.x = (LXIMAGE - ow) / 2;
|
||||
dst.x = (LXIMAGE () - ow) / 2;
|
||||
dst.y = 0;
|
||||
dst.w = ow;
|
||||
dst.h = oh;
|
||||
@ -391,12 +391,12 @@ CPixmap::Cache (
|
||||
src.x = 0;
|
||||
src.y = 0;
|
||||
src.w = POSDRAWX - 1;
|
||||
src.h = LYIMAGE;
|
||||
src.h = LYIMAGE ();
|
||||
dst = src;
|
||||
SDL_RenderCopy (g_renderer, texture, &src, &dst);
|
||||
src.x = ow - 16;
|
||||
src.w = 16;
|
||||
dst.x = LXIMAGE - 16;
|
||||
dst.x = LXIMAGE () - 16;
|
||||
dst.w = src.w;
|
||||
SDL_RenderCopy (g_renderer, texture, &src, &dst);
|
||||
src.x = POSDRAWX - 1;
|
||||
@ -969,7 +969,7 @@ CPixmap::GetDisplayScale ()
|
||||
// SDL_GetWindowDisplayMode (g_window, &displayMode);
|
||||
Sint32 w, h;
|
||||
SDL_GetWindowSize (g_window, &w, &h);
|
||||
return static_cast<double> (h / LYIMAGE);
|
||||
return static_cast<double> (h / LYIMAGE ());
|
||||
}
|
||||
|
||||
void
|
||||
@ -1012,6 +1012,6 @@ CPixmap::FromGameToDisplay (Sint32 & x, Sint32 & y)
|
||||
|
||||
double _w = w, _h = h;
|
||||
|
||||
x = x * _w / LXIMAGE;
|
||||
y = y * _h / LYIMAGE;
|
||||
x = x * _w / LXIMAGE ();
|
||||
y = y * _h / LYIMAGE ();
|
||||
}
|
||||
|
@ -288,17 +288,17 @@ CSound::PlayImage (Sounds channel, Point pos, Sint32 rank)
|
||||
if (volumex < 0)
|
||||
volumex = 0;
|
||||
}
|
||||
else if (pos.x > LXIMAGE)
|
||||
else if (pos.x > LXIMAGE ())
|
||||
{
|
||||
panRight = 255;
|
||||
panLeft = 0;
|
||||
volumex -= pos.x - LXIMAGE;
|
||||
volumex -= pos.x - LXIMAGE ();
|
||||
if (volumex < 0)
|
||||
volumex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
panRight = 255 * static_cast<Uint16> (pos.x) / LXIMAGE;
|
||||
panRight = 255 * static_cast<Uint16> (pos.x) / LXIMAGE ();
|
||||
panLeft = 255 - panRight;
|
||||
}
|
||||
|
||||
@ -308,9 +308,9 @@ CSound::PlayImage (Sounds channel, Point pos, Sint32 rank)
|
||||
if (volumey < 0)
|
||||
volumey = 0;
|
||||
}
|
||||
else if (pos.y > LYIMAGE)
|
||||
else if (pos.y > LYIMAGE ())
|
||||
{
|
||||
volumey -= pos.y - LYIMAGE;
|
||||
volumey -= pos.y - LYIMAGE ();
|
||||
if (volumey < 0)
|
||||
volumey = 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user