1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00

Continue right2left layout and reading

This commit is contained in:
Mathieu Schroeter 2019-02-04 22:53:47 +01:00
parent 743f460402
commit 3cd52b699d
3 changed files with 47 additions and 14 deletions

View File

@ -1538,7 +1538,7 @@ term:
const auto text = GetResHili (posMouse); const auto text = GetResHili (posMouse);
if (text) if (text)
{ {
posMouse.x += 10; posMouse.x += IsRightReading () ? 0 : 10;
posMouse.y += 20; posMouse.y += 20;
DrawText (m_pPixmap, posMouse, text); DrawText (m_pPixmap, posMouse, text);
} }
@ -1843,7 +1843,8 @@ CDecor::CelOkForAction (
GetFloor (cel, channel, icon); GetFloor (cel, channel, icon);
if ( // mine ? if ( // mine ?
action == EV_ACTION_BUILD4 && action == EV_ACTION_BUILD4 &&
((!g_restoreBugs && !m_decorMem[cel.x / 2][cel.y / 2].flagged) || // fixed ((!g_restoreBugs &&
!m_decorMem[cel.x / 2][cel.y / 2].flagged) || // fixed
(g_restoreBugs && (channel != CHFLOOR || icon != 71)))) // funny bug (g_restoreBugs && (channel != CHFLOOR || icon != 71)))) // funny bug
{ {
error = Errors::GROUND; // sol pas adéquat error = Errors::GROUND; // sol pas adéquat
@ -3504,4 +3505,4 @@ void
CDecor::InvalidateGrounds () CDecor::InvalidateGrounds ()
{ {
m_bGroundRedraw = true; m_bGroundRedraw = true;
} }

View File

@ -2294,28 +2294,30 @@ CEvent::DrawButtons ()
} }
m_menu.Draw (); m_menu.Draw ();
auto offset = IsRightReading () ? POSDRAWX + DIMDRAWX : 0;
// Dessine la rose des vents. // Dessine la rose des vents.
if (!m_bPause && !m_bDemoPlay) if (!m_bPause && !m_bDemoPlay)
{ {
DrawTextCenter (gettext ("N"), (10 + 134) / 2, 17); DrawTextCenter (gettext ("N"), (10 + 134) / 2 + offset, 17);
DrawTextCenter (gettext ("S"), (10 + 134) / 2, 126); DrawTextCenter (gettext ("S"), (10 + 134) / 2 + offset, 126);
DrawTextCenter (gettext ("W"), 14, 70); DrawTextCenter (gettext ("W"), 14 + offset, 70);
DrawTextCenter (gettext ("E"), 129, 70); DrawTextCenter (gettext ("E"), 129 + offset, 70);
} }
// Dessine la pause. // Dessine la pause.
if (m_bPause) if (m_bPause)
DrawTextCenter (gettext ("Game paused"), (10 + 134) / 2, 20); DrawTextCenter (gettext ("Game paused"), (10 + 134) / 2 + offset, 20);
else else
{ {
if (m_bDemoRec) // recording demo ? if (m_bDemoRec) // recording demo ?
DrawTextCenter (gettext ("REC"), (10 + 38) / 2, 20, FONTRED); DrawTextCenter (gettext ("REC"), (10 + 38) / 2 + offset, 20, FONTRED);
if (m_bDemoPlay) // playing demo ? if (m_bDemoPlay) // playing demo ?
DrawTextCenter (gettext ("Demo"), (10 + 134) / 2, 20, FONTRED); DrawTextCenter (gettext ("Demo"), (10 + 134) / 2 + offset, 20, FONTRED);
} }
// Dessine la vitesse. // Dessine la vitesse.
pos.x = 64; pos.x = IsRightReading () ? LXIMAGE () - 64 : 64;
pos.y = LYIMAGE () - 15; pos.y = LYIMAGE () - 15;
rect.left = pos.x; rect.left = pos.x;
rect.right = pos.x + 20; rect.right = pos.x + 20;
@ -3117,7 +3119,7 @@ CEvent::EventButtons (const SDL_Event & event, Point pos)
{ {
snprintf (m_textToolTips, sizeof (m_textToolTips), "%s", text); snprintf (m_textToolTips, sizeof (m_textToolTips), "%s", text);
lg = GetTextWidth (m_textToolTips); lg = GetTextWidth (m_textToolTips);
pos.x += IsRightReading () ? -10 : 10; pos.x += IsRightReading () ? 0 : 10;
pos.y += 20; pos.y += 20;
if (pos.x > LXIMAGE () + (IsRightReading () ? 0 : -lg)) if (pos.x > LXIMAGE () + (IsRightReading () ? 0 : -lg))
pos.x = LXIMAGE () - lg; pos.x = LXIMAGE () - lg;

View File

@ -180,10 +180,34 @@ GetCharWidth (const char *& c, Sint32 font)
void void
DrawText (CPixmap * pPixmap, Point pos, const char * pText, Sint32 font) DrawText (CPixmap * pPixmap, Point pos, const char * pText, Sint32 font)
{ {
Sint32 rank; Sint32 rank;
bool isNumber = false;
int numberSize = 0;
const char * it = nullptr;
int skip = 0;
while (*pText != '\0') while (*pText != '\0' || skip)
{ {
if (IsRightReading () && numberSize == 0)
{
it = pText;
isNumber = *pText >= '0' && *pText <= '9';
if (isNumber)
{
while (*pText >= '0' && *pText <= '9')
++pText;
numberSize = pText - it;
skip = numberSize - 1;
}
}
if (numberSize)
{
pText = it + numberSize - 1;
numberSize--;
}
rank = GetOffset (pText); rank = GetOffset (pText);
auto inc = rank > 127; auto inc = rank > 127;
@ -201,6 +225,12 @@ DrawText (CPixmap * pPixmap, Point pos, const char * pText, Sint32 font)
if (!IsRightReading ()) if (!IsRightReading ())
pos.x += GetCharWidth (pText, font); pos.x += GetCharWidth (pText, font);
if (!numberSize && skip > 0)
{
pText += skip;
skip = 0;
}
if (inc) if (inc)
pText++; pText++;
pText++; pText++;