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

Add support for Polish special characters

This commit is contained in:
krzys-h 2017-09-12 17:09:50 +02:00
parent 8a31aaf0e5
commit 3064ffb130
5 changed files with 60 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
resources/image/text_pl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@ -833,7 +833,10 @@ DoInit (int argc, char * argv[], bool & exit)
totalDim.y = DIMTEXTY * 8 * 3;
iconDim.x = DIMTEXTX;
iconDim.y = DIMTEXTY;
if (!g_pPixmap->Cache (CHTEXT, "image/text.png", totalDim, iconDim))
std::string text_filename = "image/text.png";
if (GetLocale() == "pl")
text_filename = "image/text_pl.png"; // TODO: Merge into one texture, or use TTF fonts instead?
if (!g_pPixmap->Cache (CHTEXT, text_filename, totalDim, iconDim))
{
InitFail ("Cache text.png");
return EXIT_FAILURE;
@ -843,7 +846,10 @@ DoInit (int argc, char * argv[], bool & exit)
totalDim.y = DIMLITTLEY * 8;
iconDim.x = DIMLITTLEX;
iconDim.y = DIMLITTLEY;
if (!g_pPixmap->Cache (CHLITTLE, "image/little.png", totalDim, iconDim))
std::string little_filename = "image/little.png";
if (GetLocale() == "pl")
little_filename = "image/little_pl.png"; // TODO: Merge into one texture, or use TTF fonts instead?
if (!g_pPixmap->Cache (CHLITTLE, little_filename, totalDim, iconDim))
{
InitFail ("Cache little.png");
return EXIT_FAILURE;

View File

@ -3702,6 +3702,31 @@ CEvent::SetLanguage (Language lang)
SDL_SetWindowTitle (g_window, gettext ("Planet Blupi"));
m_pSound->CacheAll ();
Point totalDim, iconDim;
totalDim.x = DIMTEXTX * 16;
totalDim.y = DIMTEXTY * 8 * 3;
iconDim.x = DIMTEXTX;
iconDim.y = DIMTEXTY;
std::string text_filename = "image/text.png";
if (GetLocale() == "pl")
text_filename = "image/text_pl.png";
if (!m_pPixmap->Cache (CHTEXT, text_filename, totalDim, iconDim))
{
printf ("Error (Cache text.png)");
}
totalDim.x = DIMLITTLEX * 16;
totalDim.y = DIMLITTLEY * 8;
iconDim.x = DIMLITTLEX;
iconDim.y = DIMLITTLEY;
std::string little_filename = "image/little.png";
if (GetLocale() == "pl")
little_filename = "image/little_pl.png";
if (!m_pPixmap->Cache (CHLITTLE, little_filename, totalDim, iconDim))
{
printf ("Error (Cache little.png)");
}
}
// Clic dans un bouton.

View File

@ -22,13 +22,14 @@
#include <stdlib.h>
#include "def.h"
#include "misc.h"
#include "pixmap.h"
#include "text.h"
/**
* \brief Return the character offset for the sprite.
*
* \param[in] c - The character (incremented if 0xC3 UTF-8).
* \param[in] c - The character (incremented if 0xC3 or 0xC4 or 0xC5 UTF-8).
* \returns the offset.
*/
static Sint32
@ -43,13 +44,35 @@ GetOffset (const char *& c)
0xAE, 0xB4, 0xB9, 0xBB, 0xA4, 0xB6, 0xA7, // UTF-8
};
static const unsigned char table_accents_pl[] = {
/* Polish */
/* ń * ó ę * ć * * */
0x84, 0xFF, 0xB3, 0x99, 0xFF, 0x87, 0xFF, 0xFF, // UTF-8
/* ź ż * * ą ł ś */
0xBA, 0xBC, 0xFF, 0xFF, 0x85, 0x82, 0x9B, // UTF-8
};
if (static_cast<unsigned char> (*c) == 0xC3)
c++;
if (static_cast<unsigned char> (*c) == 0xC4)
c++;
if (static_cast<unsigned char> (*c) == 0xC5)
c++;
for (unsigned int i = 0; i < countof (table_accents); ++i)
if(GetLocale() == "pl") {
for (unsigned int i = 0; i < countof (table_accents_pl); ++i)
{
if ((unsigned char) *c == table_accents_pl[i])
return 15 + i;
}
}
else
{
if ((unsigned char) *c == table_accents[i])
return 15 + i;
for (unsigned int i = 0; i < countof (table_accents); ++i)
{
if ((unsigned char) *c == table_accents[i])
return 15 + i;
}
}
if (*c < 0)
return 1; // square