From fc51d054e6be145b2efc20efa0946b73669ff563 Mon Sep 17 00:00:00 2001 From: Mathieu Schroeter Date: Tue, 7 Feb 2017 19:42:34 +0100 Subject: [PATCH] Replace a lot of string resources by gettext calls --- decor.cpp | 413 +++++++++++++++++++++++++++++++--------------------- decor.h | 2 +- decstat.cpp | 91 ++++++------ event.cpp | 48 +++--- text.cpp | 4 +- text.h | 4 +- 6 files changed, 324 insertions(+), 238 deletions(-) diff --git a/decor.cpp b/decor.cpp index ff33643..a48e4a3 100644 --- a/decor.cpp +++ b/decor.cpp @@ -3,6 +3,8 @@ #include #include +#include +#include "gettext.h" #include "def.h" #include "resource.h" #include "pixmap.h" @@ -1516,13 +1518,12 @@ void CDecor::Build(RECT clip, POINT posMouse) { if ( m_textCount == 0 ) { - n = GetResHili(posMouse); - if ( n != -1 ) + const auto text = GetResHili(posMouse); + if (text) { - LoadString(n, m_text, 50); posMouse.x += 10; posMouse.y += 20; - DrawText(m_pPixmap, posMouse, m_text); + DrawText(m_pPixmap, posMouse, text); } } else @@ -3009,188 +3010,274 @@ void CDecor::CelHiliRepeat(int list) // Retourne l'identificateur du texte correspondant à // l'objet ou au blupi visé par la souris. -int CDecor::GetResHili(POINT posMouse) +const char *CDecor::GetResHili(POINT posMouse) { - int res, icon; + int icon; + const char *res = nullptr; - // Les valeurs négatives correspondent aux objets placés - // au coin inf/droite de la cellule. - static short table_object[] = + // Les valeurs `corner == true` correspondent aux objets placés + // au coin inf/droit de la cellule. + struct object_t { - 131, // nb - 0,0,0,0,0,0, - TX_OBJ_ARBRE, TX_OBJ_ARBRE, TX_OBJ_ARBRE, - TX_OBJ_ARBRE, TX_OBJ_ARBRE, TX_OBJ_ARBRE, - TX_OBJ_FUSEE,0, - TX_OBJ_METAL, - 0, -TX_OBJ_ARMURE, - 0,0,0, - TX_OBJ_MUR, TX_OBJ_MUR, TX_OBJ_MUR, TX_OBJ_MUR, - TX_OBJ_MUR, TX_OBJ_MUR, TX_OBJ_MUR, - TX_OBJ_TOUR, - TX_OBJ_LABO, TX_OBJ_LABO, - TX_OBJ_ARBREb, TX_OBJ_ARBREb, TX_OBJ_ARBREb, - TX_OBJ_ARBREb, TX_OBJ_ARBREb, TX_OBJ_ARBREb, - -TX_OBJ_PLANCHE, - TX_OBJ_ROC, TX_OBJ_ROC, TX_OBJ_ROC, TX_OBJ_ROC, - TX_OBJ_ROC, TX_OBJ_ROC, TX_OBJ_ROC, - -TX_OBJ_PIERRE, - TX_OBJ_FEU, TX_OBJ_FEU, TX_OBJ_FEU, TX_OBJ_FEU, - TX_OBJ_FEU, TX_OBJ_FEU, TX_OBJ_FEU, TX_OBJ_FEU, - 0,0,0,0, - -TX_OBJ_TOMATE, -TX_OBJ_TOMATE, -TX_OBJ_TOMATE, -TX_OBJ_TOMATE, - TX_OBJ_CABANE, TX_OBJ_CABANE, - -TX_OBJ_OEUF, TX_OBJ_OEUF, - TX_OBJ_PALISSADE, TX_OBJ_PALISSADE, TX_OBJ_PALISSADE, TX_OBJ_PALISSADE, - TX_OBJ_PALISSADE, TX_OBJ_PALISSADE, TX_OBJ_PALISSADE, - TX_OBJ_PONT, TX_OBJ_PONT, - 0,0,0,0,0,0, - -TX_OBJ_POTION, - TX_OBJ_FLEUR1, -TX_OBJ_BOUQUET1, - TX_OBJ_FLEUR2, -TX_OBJ_BOUQUET2, - -TX_OBJ_DYNAMITE, -TX_OBJ_DYNAMITE, -TX_OBJ_DYNAMITE, - 0,0,0,0, - -TX_OBJ_POISON, - -TX_OBJ_PIEGE, - TX_OBJ_FLEUR3, -TX_OBJ_BOUQUET3, - -TX_OBJ_ENNEMIp, -TX_OBJ_ENNEMIp, -TX_OBJ_ENNEMIp, - TX_OBJ_ENNEMI, TX_OBJ_ENNEMI, TX_OBJ_ENNEMI, TX_OBJ_ENNEMI, - TX_OBJ_ENNEMI, TX_OBJ_ENNEMI, TX_OBJ_ENNEMI, TX_OBJ_ENNEMI, - TX_OBJ_ENNEMI, TX_OBJ_ENNEMI, TX_OBJ_ENNEMI, TX_OBJ_ENNEMI, - TX_OBJ_ENNEMI, TX_OBJ_ENNEMI, - TX_OBJ_MAISON, - -TX_OBJ_ENNEMIp, - TX_OBJ_ENNEMI, TX_OBJ_ENNEMI, - -TX_OBJ_BATEAU, - -TX_OBJ_JEEP, - TX_OBJ_USINE, TX_OBJ_USINE, - TX_OBJ_MINEFER, TX_OBJ_MINEFER, - -TX_OBJ_FER, - TX_OBJ_DRAPEAU, - -TX_OBJ_MINE, - TX_OBJ_MINEFER, - -TX_OBJ_MINE, - TX_OBJ_ENNEMI, TX_OBJ_ENNEMI, - -TX_OBJ_ENNEMIp, + bool corner; + const char *text; }; - static short table_floor[] = - { - 85, // nb - 0, - TX_OBJ_HERBE, - TX_OBJ_RIVE, TX_OBJ_RIVE, TX_OBJ_RIVE, TX_OBJ_RIVE, - TX_OBJ_RIVE, TX_OBJ_RIVE, TX_OBJ_RIVE, TX_OBJ_RIVE, - TX_OBJ_RIVE, TX_OBJ_RIVE, TX_OBJ_RIVE, TX_OBJ_RIVE, - TX_OBJ_EAU, - TX_OBJ_DALLE, TX_OBJ_DALLE, - TX_OBJ_HACHURE, - TX_OBJ_GLACE, - TX_OBJ_MOUSSEb, - TX_OBJ_MOUSSE, - TX_OBJ_MIXTE, TX_OBJ_MIXTE, TX_OBJ_MIXTE, TX_OBJ_MIXTE, - TX_OBJ_MIXTE, TX_OBJ_MIXTE, TX_OBJ_MIXTE, TX_OBJ_MIXTE, - TX_OBJ_MIXTE, TX_OBJ_MIXTE, TX_OBJ_MIXTE, TX_OBJ_MIXTE, - TX_OBJ_TERRE, - TX_OBJ_MIXTE, TX_OBJ_MIXTE, TX_OBJ_MIXTE, TX_OBJ_MIXTE, - TX_OBJ_MIXTE, TX_OBJ_MIXTE, TX_OBJ_MIXTE, TX_OBJ_MIXTE, - TX_OBJ_MIXTE, TX_OBJ_MIXTE, TX_OBJ_MIXTE, TX_OBJ_MIXTE, - TX_OBJ_TERRE, TX_OBJ_TERRE, TX_OBJ_TERRE, - TX_OBJ_HERBE, TX_OBJ_HERBE, TX_OBJ_HERBE, - TX_OBJ_COUVEUSE, TX_OBJ_COUVEUSE, TX_OBJ_COUVEUSE, - TX_OBJ_COUVEUSE, TX_OBJ_COUVEUSE, - TX_OBJ_HERBE, - TX_OBJ_MOUSSE, - TX_OBJ_PONT, TX_OBJ_PONT, TX_OBJ_PONT, - TX_OBJ_PONT, TX_OBJ_PONT, TX_OBJ_PONT, - TX_OBJ_ENNEMIs, TX_OBJ_MIXTE, TX_OBJ_ENNEMIs, - TX_OBJ_EAU, TX_OBJ_EAU, TX_OBJ_EAU, - TX_OBJ_TERRE, - 0,0,0,0, - 0,0, - TX_OBJ_MIXTE, TX_OBJ_MIXTE, - TX_OBJ_TELEPORTE, TX_OBJ_TELEPORTE, TX_OBJ_TELEPORTE, - TX_OBJ_TELEPORTE, TX_OBJ_TELEPORTE, + static const std::unordered_map tableObject = { + { 6, { false, gettext ("Tree") } }, + { 7, { false, gettext ("Tree") } }, + { 8, { false, gettext ("Tree") } }, + { 9, { false, gettext ("Tree") } }, + { 10, { false, gettext ("Tree") } }, + { 11, { false, gettext ("Tree") } }, + { 12, { false, gettext ("Enemy rocket") } }, + { 14, { false, gettext ("Platinium") } }, + { 16, { true, gettext ("Armour") } }, + { 20, { false, gettext ("Wall") } }, + { 21, { false, gettext ("Wall") } }, + { 22, { false, gettext ("Wall") } }, + { 23, { false, gettext ("Wall") } }, + { 24, { false, gettext ("Wall") } }, + { 25, { false, gettext ("Wall") } }, + { 26, { false, gettext ("Wall") } }, + { 27, { false, gettext ("Protection tower") } }, + { 28, { false, gettext ("Laboratory") } }, + { 29, { false, gettext ("Laboratory") } }, + { 30, { false, gettext ("Tree trunks") } }, + { 31, { false, gettext ("Tree trunks") } }, + { 32, { false, gettext ("Tree trunks") } }, + { 33, { false, gettext ("Tree trunks") } }, + { 34, { false, gettext ("Tree trunks") } }, + { 35, { false, gettext ("Tree trunks") } }, + { 36, { true, gettext ("Planks") } }, + { 37, { false, gettext ("Rocks") } }, + { 38, { false, gettext ("Rocks") } }, + { 39, { false, gettext ("Rocks") } }, + { 40, { false, gettext ("Rocks") } }, + { 41, { false, gettext ("Rocks") } }, + { 42, { false, gettext ("Rocks") } }, + { 43, { false, gettext ("Rocks") } }, + { 44, { true, gettext ("Stones") } }, + { 45, { false, gettext ("Fire") } }, + { 46, { false, gettext ("Fire") } }, + { 47, { false, gettext ("Fire") } }, + { 48, { false, gettext ("Fire") } }, + { 49, { false, gettext ("Fire") } }, + { 50, { false, gettext ("Fire") } }, + { 51, { false, gettext ("Fire") } }, + { 52, { false, gettext ("Fire") } }, + { 57, { true, gettext ("Tomatoes") } }, + { 58, { true, gettext ("Tomatoes") } }, + { 59, { true, gettext ("Tomatoes") } }, + { 60, { true, gettext ("Tomatoes") } }, + { 61, { false, gettext ("Garden shed") } }, + { 62, { false, gettext ("Garden shed") } }, + { 63, { true, gettext ("Eggs") } }, + { 64, { false, gettext ("Eggs") } }, + { 65, { false, gettext ("Palisade") } }, + { 66, { false, gettext ("Palisade") } }, + { 67, { false, gettext ("Palisade") } }, + { 68, { false, gettext ("Palisade") } }, + { 69, { false, gettext ("Palisade") } }, + { 70, { false, gettext ("Palisade") } }, + { 71, { false, gettext ("Palisade") } }, + { 72, { false, gettext ("Bridge") } }, + { 73, { false, gettext ("Bridge") } }, + { 80, { true, gettext ("Medical potion") } }, + { 81, { false, pgettext ("Flower|1|", "Flowers") } }, + { 82, { true, pgettext ("Flower|1|", "Bunch of flowers") } }, + { 83, { false, pgettext ("Flower|2|", "Flowers") } }, + { 84, { true, pgettext ("Flower|2|", "Bunch of flowers") } }, + { 85, { true, gettext ("Dynamite") } }, + { 86, { true, gettext ("Dynamite") } }, + { 87, { true, gettext ("Dynamite") } }, + { 92, { true, gettext ("Poison") } }, + { 93, { true, gettext ("Sticky trap") } }, + { 94, { false, pgettext ("Flower|3|", "Flowers") } }, + { 95, { true, pgettext ("Flower|3|", "Bunch of flowers") } }, + { 96, { true, gettext ("Trapped enemy") } }, + { 97, { true, gettext ("Trapped enemy") } }, + { 98, { true, gettext ("Trapped enemy") } }, + { 99, { false, gettext ("Enemy construction") } }, + { 100, { false, gettext ("Enemy construction") } }, + { 101, { false, gettext ("Enemy construction") } }, + { 102, { false, gettext ("Enemy construction") } }, + { 103, { false, gettext ("Enemy construction") } }, + { 104, { false, gettext ("Enemy construction") } }, + { 105, { false, gettext ("Enemy construction") } }, + { 106, { false, gettext ("Enemy construction") } }, + { 107, { false, gettext ("Enemy construction") } }, + { 108, { false, gettext ("Enemy construction") } }, + { 109, { false, gettext ("Enemy construction") } }, + { 110, { false, gettext ("Enemy construction") } }, + { 111, { false, gettext ("Enemy construction") } }, + { 112, { false, gettext ("Enemy construction") } }, + { 113, { false, gettext ("Blupi's house") } }, + { 114, { true, gettext ("Trapped enemy") } }, + { 115, { false, gettext ("Enemy construction") } }, + { 116, { false, gettext ("Enemy construction") } }, + { 117, { true, gettext ("Boat") } }, + { 118, { true, gettext ("Jeep") } }, + { 119, { false, gettext ("Workshop") } }, + { 120, { false, gettext ("Workshop") } }, + { 121, { false, gettext ("Mine") } }, + { 122, { false, gettext ("Mine") } }, + { 123, { true, gettext ("Iron") } }, + { 124, { false, gettext ("Flag") } }, + { 125, { true, gettext ("Time bomb") } }, + { 126, { false, gettext ("Mine") } }, + { 127, { true, gettext ("Time bomb") } }, + { 128, { false, gettext ("Enemy construction") } }, + { 129, { false, gettext ("Enemy construction") } }, + { 130, { true, gettext ("Trapped enemy") } }, }; - if ( m_bHideTooltips ) return -1; // rien si menu présent + static const std::unordered_map tableFloor = { + { 1, { false, gettext ("Normal ground") } }, + { 2, { false, gettext ("Bank") } }, + { 3, { false, gettext ("Bank") } }, + { 4, { false, gettext ("Bank") } }, + { 5, { false, gettext ("Bank") } }, + { 6, { false, gettext ("Bank") } }, + { 7, { false, gettext ("Bank") } }, + { 8, { false, gettext ("Bank") } }, + { 9, { false, gettext ("Bank") } }, + { 10, { false, gettext ("Bank") } }, + { 11, { false, gettext ("Bank") } }, + { 12, { false, gettext ("Bank") } }, + { 13, { false, gettext ("Bank") } }, + { 14, { false, gettext ("Water") } }, + { 15, { false, gettext ("Paving stones") } }, + { 16, { false, gettext ("Paving stones") } }, + { 17, { false, gettext ("Striped paving stones") } }, + { 18, { false, gettext ("Ice") } }, + { 19, { false, gettext ("Burnt ground") } }, + { 20, { false, gettext ("Inflammable ground") } }, + { 21, { false, gettext ("Miscellaneous ground") } }, + { 22, { false, gettext ("Miscellaneous ground") } }, + { 23, { false, gettext ("Miscellaneous ground") } }, + { 24, { false, gettext ("Miscellaneous ground") } }, + { 25, { false, gettext ("Miscellaneous ground") } }, + { 26, { false, gettext ("Miscellaneous ground") } }, + { 27, { false, gettext ("Miscellaneous ground") } }, + { 28, { false, gettext ("Miscellaneous ground") } }, + { 29, { false, gettext ("Miscellaneous ground") } }, + { 30, { false, gettext ("Miscellaneous ground") } }, + { 31, { false, gettext ("Miscellaneous ground") } }, + { 32, { false, gettext ("Miscellaneous ground") } }, + { 33, { false, gettext ("Sterile ground") } }, + { 34, { false, gettext ("Miscellaneous ground") } }, + { 35, { false, gettext ("Miscellaneous ground") } }, + { 36, { false, gettext ("Miscellaneous ground") } }, + { 37, { false, gettext ("Miscellaneous ground") } }, + { 38, { false, gettext ("Miscellaneous ground") } }, + { 39, { false, gettext ("Miscellaneous ground") } }, + { 40, { false, gettext ("Miscellaneous ground") } }, + { 41, { false, gettext ("Miscellaneous ground") } }, + { 42, { false, gettext ("Miscellaneous ground") } }, + { 43, { false, gettext ("Miscellaneous ground") } }, + { 44, { false, gettext ("Miscellaneous ground") } }, + { 45, { false, gettext ("Miscellaneous ground") } }, + { 46, { false, gettext ("Sterile ground") } }, + { 47, { false, gettext ("Sterile ground") } }, + { 48, { false, gettext ("Sterile ground") } }, + { 49, { false, gettext ("Normal ground") } }, + { 50, { false, gettext ("Normal ground") } }, + { 51, { false, gettext ("Normal ground") } }, + { 52, { false, gettext ("Incubator") } }, + { 53, { false, gettext ("Incubator") } }, + { 54, { false, gettext ("Incubator") } }, + { 55, { false, gettext ("Incubator") } }, + { 56, { false, gettext ("Incubator") } }, + { 57, { false, gettext ("Normal ground") } }, + { 58, { false, gettext ("Inflammable ground") } }, + { 59, { false, gettext ("Bridge") } }, + { 60, { false, gettext ("Bridge") } }, + { 61, { false, gettext ("Bridge") } }, + { 62, { false, gettext ("Bridge") } }, + { 63, { false, gettext ("Bridge") } }, + { 64, { false, gettext ("Bridge") } }, + { 65, { false, gettext ("Enemy ground") } }, + { 66, { false, gettext ("Miscellaneous ground") } }, + { 67, { false, gettext ("Enemy ground") } }, + { 68, { false, gettext ("Water") } }, + { 69, { false, gettext ("Water") } }, + { 70, { false, gettext ("Water") } }, + { 71, { false, gettext ("Sterile ground") } }, + { 78, { false, gettext ("Miscellaneous ground") } }, + { 79, { false, gettext ("Miscellaneous ground") } }, + { 80, { false, gettext ("Teleporter") } }, + { 81, { false, gettext ("Teleporter") } }, + { 82, { false, gettext ("Teleporter") } }, + { 83, { false, gettext ("Teleporter") } }, + { 84, { false, gettext ("Teleporter") } }, + }; - if ( posMouse.x < POSDRAWX || - posMouse.x > POSDRAWX+DIMDRAWX || - posMouse.y < POSDRAWY || - posMouse.y > POSDRAWY+DIMDRAWY ) return -1; + if (m_bHideTooltips) + return nullptr; // rien si menu présent + + if ( posMouse.x < POSDRAWX + || posMouse.x > POSDRAWX + DIMDRAWX + || posMouse.y < POSDRAWY + || posMouse.y > POSDRAWY + DIMDRAWY) + return nullptr; if ( m_celHili.x != -1 ) { if ( m_rankHili != -1 ) // blupi visé ? { - if ( m_blupi[m_rankHili].perso == 0 ) // blupi ? + switch (m_blupi[m_rankHili].perso) { - res = TX_OBJ_BLUPI; - if ( m_blupi[m_rankHili].energy <= MAXENERGY/4 ) - { - res = TX_OBJ_BLUPIf; - } - if ( m_blupi[m_rankHili].bMalade ) - { - res = TX_OBJ_BLUPIm; - } - } - if ( m_blupi[m_rankHili].perso == 1 ) // araignée ? - { - res = TX_OBJ_ARAIGNEE; - } - if ( m_blupi[m_rankHili].perso == 2 ) // virus ? - { - res = TX_OBJ_VIRUS; - } - if ( m_blupi[m_rankHili].perso == 3 ) // tracks ? - { - res = TX_OBJ_TRACKS; - } - if ( m_blupi[m_rankHili].perso == 4 ) // robot ? - { - res = TX_OBJ_ROBOT; - } - if ( m_blupi[m_rankHili].perso == 5 ) // bombe ? - { - res = TX_OBJ_BOMBE; - } - if ( m_blupi[m_rankHili].perso == 7 ) // electro ? - { - res = TX_OBJ_ELECTRO; - } - if ( m_blupi[m_rankHili].perso == 8 ) // disciple ? - { - res = TX_OBJ_DISCIPLE; + case 0: // blupi ? + if (m_blupi[m_rankHili].energy <= MAXENERGY / 4) + return gettext ("Tired Blupi"); + if (m_blupi[m_rankHili].bMalade) + return gettext ("Sick Blupi"); + return gettext ("Blupi"); + case 1: // araignée ? + return gettext ("Spider"); + case 2: // virus ? + return gettext ("Virus"); + case 3: // tracks ? + return gettext ("Bulldozer"); + case 4: // robot ? + return gettext ("Master robot"); + case 5: // bombe ? + return gettext ("Bouncing bomb"); + case 7: // electro ? + return gettext ("Electrocutor"); + case 8: // disciple ? + return gettext ("Helper robot"); } - return res; + return nullptr; } - else - { - icon = m_decor[m_celHili.x/2][m_celHili.y/2].objectIcon; - if ( icon != -1 && icon < table_object[0] ) - { - res = table_object[1+icon]; - if ( res != 0 ) - { - if ( res > 0 ) return res; - if ( m_celHili.x%2 != 0 && - m_celHili.y%2 != 0 ) return -res; - } - } - icon = m_decor[m_celHili.x/2][m_celHili.y/2].floorIcon; - if ( icon != -1 && icon < table_floor[0] ) + icon = m_decor[m_celHili.x/2][m_celHili.y/2].objectIcon; + if (icon != -1) + { + const auto obj = tableObject.find (icon); + if (obj != tableObject.end ()) { - res = table_floor[1+icon]; - if ( res != 0 ) return res; + if (!obj->second.corner) + return obj->second.text; + + if ( m_celHili.x % 2 + && m_celHili.y % 2) + return obj->second.text; } } + + icon = m_decor[m_celHili.x/2][m_celHili.y/2].floorIcon; + if (icon != -1) + { + const auto obj = tableFloor.find (icon); + if (obj != tableFloor.end ()) + return obj->second.text; + } } - return -1; + return nullptr; } // Indique si le menu est présent et qu'il faut cacher diff --git a/decor.h b/decor.h index d309ea0..8c874d1 100644 --- a/decor.h +++ b/decor.h @@ -424,7 +424,7 @@ public: void CelHili(POINT pos, int action); void CelHiliButton(POINT cel, int button); void CelHiliRepeat(int list); - int GetResHili(POINT posMouse); + const char *GetResHili(POINT posMouse); void HideTooltips(bool bHide); void UndoOpen(); diff --git a/decstat.cpp b/decstat.cpp index de2edb3..f167d8e 100644 --- a/decstat.cpp +++ b/decstat.cpp @@ -1,6 +1,7 @@ // DecStat.cpp // +#include "gettext.h" #include "RESOURCE.H" #include "DECOR.H" #include "TEXT.H" @@ -29,7 +30,7 @@ typedef struct short lastIcon; // négatif si sol short drawIcon; short bBigIcon; - short text; + const char *text; short nb; short lastShow; } @@ -44,7 +45,7 @@ static Statistic table_statistic[] = 0,0, // 76, false, - TX_OBJ_BLUPIm, + gettext ("Sick Blupi"), 0, 0, }, { // STATBLUPIf = 1 @@ -53,7 +54,7 @@ static Statistic table_statistic[] = 0,0, // 13, false, - TX_OBJ_BLUPIf, + gettext ("Tired Blupi"), 0, 0, }, { // STATBLUPI = 2 @@ -62,7 +63,7 @@ static Statistic table_statistic[] = 0,0, // 14, false, - TX_OBJ_BLUPI, + gettext ("Blupi"), 0, 0, }, { // STATDISCIPLE = 3 @@ -71,7 +72,7 @@ static Statistic table_statistic[] = 0,0, // 85, false, - TX_OBJ_DISCIPLE, + gettext ("Helper robot"), 0, 0, }, { // 4 @@ -80,7 +81,7 @@ static Statistic table_statistic[] = 117,117, // bateau 58, false, - TX_OBJ_BATEAU, + gettext ("Boat"), 0, 0, }, { // 5 @@ -89,7 +90,7 @@ static Statistic table_statistic[] = 118,118, // jeep 65, false, - TX_OBJ_JEEP, + gettext ("Jeep"), 0, 0, }, { // 6 @@ -98,7 +99,7 @@ static Statistic table_statistic[] = 16,16, // armure 106, false, - TX_OBJ_ARMURE, + gettext ("Armour"), 0, 0, }, { // 7 @@ -107,7 +108,7 @@ static Statistic table_statistic[] = 93,93, // piège 70, false, - TX_OBJ_PIEGE, + gettext ("Sticky trap"), 0, 0, }, { // 8 @@ -116,7 +117,7 @@ static Statistic table_statistic[] = 92,92, // poison 71, false, - TX_OBJ_POISON, + gettext ("Poison"), 0, 0, }, { // 9 @@ -125,7 +126,7 @@ static Statistic table_statistic[] = 85,85, // dynamite 57, false, - TX_OBJ_DYNAMITE, + gettext ("Dynamite"), 0, 0, }, { // 10 @@ -134,7 +135,7 @@ static Statistic table_statistic[] = 125,125, // mine 63, false, - TX_OBJ_MINE, + gettext ("Time bomb"), 0, 0, }, { // 11 @@ -143,7 +144,7 @@ static Statistic table_statistic[] = 60,60, // tomate 28, false, - TX_OBJ_TOMATE, + gettext ("Tomatoes"), 0, 0, }, { // 12 @@ -152,7 +153,7 @@ static Statistic table_statistic[] = 80,80, // bouteille 34, false, - TX_OBJ_POTION, + gettext ("Medical potion"), 0, 0, }, { // 13 @@ -161,7 +162,7 @@ static Statistic table_statistic[] = 36,36, // planches 22, false, - TX_OBJ_PLANCHE, + gettext ("Planks"), 0, 0, }, { // 14 @@ -170,7 +171,7 @@ static Statistic table_statistic[] = 44,44, // pierres 27, false, - TX_OBJ_PIERRE, + gettext ("Stones"), 0, 0, }, { // 15 @@ -179,7 +180,7 @@ static Statistic table_statistic[] = 124,124, // drapeau 64, true, - TX_OBJ_DRAPEAU, + gettext ("Flag"), 0, 0, }, { // 16 @@ -188,7 +189,7 @@ static Statistic table_statistic[] = 123,123, // fer 62, false, - TX_OBJ_FER, + gettext ("Iron"), 0, 0, }, { // 17 @@ -197,7 +198,7 @@ static Statistic table_statistic[] = 82,82, // fleurs1 72, false, - TX_OBJ_FLEUR1, + pgettext ("Flower|1|", "Flowers"), 0, 0, }, { // 18 @@ -206,7 +207,7 @@ static Statistic table_statistic[] = 84,84, // fleurs2 73, false, - TX_OBJ_FLEUR2, + pgettext ("Flower|2|", "Flowers"), 0, 0, }, { // 19 @@ -215,7 +216,7 @@ static Statistic table_statistic[] = 95,95, // fleurs3 74, false, - TX_OBJ_FLEUR3, + pgettext ("Flower|3|", "Flowers"), 0, 0, }, { // 20 @@ -224,7 +225,7 @@ static Statistic table_statistic[] = 61,61, // cabane 19, true, - TX_OBJ_CABANE, + gettext ("Garden shed"), 0, 0, }, { // 21 @@ -233,7 +234,7 @@ static Statistic table_statistic[] = -52,-56, // couveuse 25, false, - TX_OBJ_COUVEUSE, + gettext ("Incubator"), 0, 0, }, { // 22 @@ -242,7 +243,7 @@ static Statistic table_statistic[] = -80,-84, // téléporteur 101, false, - TX_OBJ_TELEPORTE, + gettext ("Teleporter"), 0, 0, }, { // 23 @@ -251,7 +252,7 @@ static Statistic table_statistic[] = 28,29, // laboratoire 35, true, - TX_OBJ_LABO, + gettext ("Laboratory"), 0, 0, }, { // 24 @@ -260,7 +261,7 @@ static Statistic table_statistic[] = 121,122, // mine de fer 61, true, - TX_OBJ_MINEFER, + gettext ("Mine"), 0, 0, }, { // 25 @@ -269,7 +270,7 @@ static Statistic table_statistic[] = 119,120, // usine 59, true, - TX_OBJ_USINE, + gettext ("Workshop"), 0, 0, }, { // 26 @@ -278,7 +279,7 @@ static Statistic table_statistic[] = 27,27, // tour 33, true, - TX_OBJ_TOUR, + gettext ("Protection tower"), 0, 0, }, { // STATFEU = 27 @@ -287,7 +288,7 @@ static Statistic table_statistic[] = 0,0, // 37, true, - TX_OBJ_FEU, + gettext ("Fire"), 0, 0, }, { // STATROBOT = 28 @@ -296,7 +297,7 @@ static Statistic table_statistic[] = 0,0, // 56, false, - TX_OBJ_ROBOT, + gettext ("Master robot"), 0, 0, }, { // STATTRACKS = 29 @@ -305,7 +306,7 @@ static Statistic table_statistic[] = 0,0, // 17, false, - TX_OBJ_TRACKS, + gettext ("Bulldozer"), 0, 0, }, { // STATBOMBE = 30 @@ -314,7 +315,7 @@ static Statistic table_statistic[] = 0,0, // 38, false, - TX_OBJ_BOMBE, + gettext ("Bouncing bomb"), 0, 0, }, { // STATARAIGNEE = 31 @@ -323,7 +324,7 @@ static Statistic table_statistic[] = 0,0, // 15, false, - TX_OBJ_ARAIGNEE, + gettext ("Spider"), 0, 0, }, { // STATVIRUS = 32 @@ -332,7 +333,7 @@ static Statistic table_statistic[] = 0,0, // 16, false, - TX_OBJ_VIRUS, + gettext ("Virus"), 0, 0, }, { // STATELECTRO = 33 @@ -341,7 +342,7 @@ static Statistic table_statistic[] = 0,0, // 75, false, - TX_OBJ_ELECTRO, + gettext ("Electrocutor"), 0, 0, }, @@ -351,7 +352,7 @@ static Statistic table_statistic[] = 0,0, -1, false, - 0, + "", 999, 999, }, }; @@ -662,9 +663,10 @@ void CDecor::StatisticDraw() { POINT pos; RECT rect; - int rank, icon, nb, textRes; + int rank, icon, nb; Statistic* pStatistic; char text[50]; + const char *textRes; pStatistic = table_statistic; @@ -684,7 +686,7 @@ void CDecor::StatisticDraw() nb --; } - textRes = 0; + textRes = ""; for ( rank=0 ; rank= 100 ) { - if ( m_statHili == 100 ) textRes = TX_BUTTON_PLAY_STOP; - if ( m_statHili == 101 ) textRes = TX_BUTTON_PLAY_SETUP; - if ( m_statHili == 102 ) textRes = TX_BUTTON_PLAY_WRITE; + if ( m_statHili == 100 ) textRes = gettext ("Interrupt"); + if ( m_statHili == 101 ) textRes = gettext ("Settings"); + if ( m_statHili == 102 ) textRes = gettext ("Save"); } // Dessine le nom de la statistique survolée. @@ -771,12 +773,11 @@ void CDecor::StatisticDraw() rect.bottom = pos.y+16; m_pPixmap->DrawPart(-1, CHBACK, pos, rect, 1); // dessine le fond - if ( textRes != 0 ) + if (strlen (textRes)) { - LoadString(textRes, text, 50); - nb = GetTextWidth(text); + nb = GetTextWidth(textRes); pos.x += (POSDRAWX-nb)/2; - DrawText(m_pPixmap, pos, text); + DrawText(m_pPixmap, pos, textRes); } m_bStatRedraw = false; // dessin plus nécessaire diff --git a/event.cpp b/event.cpp index 1b63695..c87ac23 100644 --- a/event.cpp +++ b/event.cpp @@ -2292,22 +2292,18 @@ bool CEvent::DrawButtons() pos.y = 330-20; DrawText(m_pPixmap, pos, res); - if ( m_pMovie->GetEnable() ) - { - if ( m_bMovie ) LoadString(TX_OUI, res, 50); - else LoadString(TX_NON, res, 50); - } - else - { - LoadString(TX_NON, res, 50); - } - lg = GetTextWidth(res); + char *text = gettext ("No"); + if (m_pMovie->GetEnable() && m_bMovie) + text = gettext ("Yes"); + lg = GetTextWidth(text); pos.x = (514+40)-lg/2; pos.y = 330-20; - DrawText(m_pPixmap, pos, res); + DrawText(m_pPixmap, pos, text); - if ( m_scrollSpeed == 0 ) LoadString(TX_INFO_NOSCROLL, res, 50); - else sprintf(res, "%d", m_scrollSpeed); + if (!m_scrollSpeed) + snprintf (res, sizeof (res), gettext ("None")); + else + sprintf(res, "%d", m_scrollSpeed); lg = GetTextWidth(res); pos.x = (169+40)-lg/2; pos.y = 330-20; @@ -2317,33 +2313,35 @@ bool CEvent::DrawButtons() // Affiche le texte de fin de la version demo. if ( m_phase == WM_PHASE_BYE ) { - LoadString(TX_FULL_END1, res, 100); + char *text; - lg = GetTextWidth(res); + text = gettext ("You have played Planet Blupi."); + + lg = GetTextWidth(text); pos.x = LXIMAGE/2-lg/2; pos.y = 20; - DrawText(m_pPixmap, pos, res); + DrawText(m_pPixmap, pos, text); - LoadString(TX_FULL_END2, res, 100); + text = gettext ("We hope you have had as much fun playing the game as we had making it !"); - lg = GetTextWidth(res); + lg = GetTextWidth(text); pos.x = LXIMAGE/2-lg/2; pos.y = 40; - DrawText(m_pPixmap, pos, res); + DrawText(m_pPixmap, pos, text); - LoadString(TX_FULL_END3, res, 100); + text = gettext ("This game is an original creation of EPSITEC SA, CH-1092 Belmont"); - lg = GetTextWidth(res); + lg = GetTextWidth(text); pos.x = LXIMAGE/2-lg/2; pos.y = 430; - DrawText(m_pPixmap, pos, res); + DrawText(m_pPixmap, pos, text); - LoadString(TX_FULL_END4, res, 100); + text = gettext ("http://www.blupi.com blupi@epsitec.ch"); - lg = GetTextWidth(res); + lg = GetTextWidth(text); pos.x = LXIMAGE/2-lg/2; pos.y = 450; - DrawText(m_pPixmap, pos, res); + DrawText(m_pPixmap, pos, text); } // Affiche le texte lorsqu'il faut insérer le CD-Rom. diff --git a/text.cpp b/text.cpp index 0ce7aa6..bc942f2 100644 --- a/text.cpp +++ b/text.cpp @@ -74,7 +74,7 @@ int GetCharWidth(char c, int font) // Affiche un texte. -void DrawText(CPixmap *pPixmap, POINT pos, char *pText, int font) +void DrawText(CPixmap *pPixmap, POINT pos, const char *pText, int font) { int rank; @@ -269,7 +269,7 @@ int GetTextHeight(char *pText, int font, int part) // Retourne la longueur d'un texte. -int GetTextWidth(char *pText, int font) +int GetTextWidth(const char *pText, int font) { int width = 0; diff --git a/text.h b/text.h index 54965b5..5e95ada 100644 --- a/text.h +++ b/text.h @@ -8,7 +8,7 @@ #define FONTLITTLE 10 extern -void DrawText(CPixmap *pPixmap, POINT pos, char *pText, int font=0); +void DrawText(CPixmap *pPixmap, POINT pos, const char *pText, int font=0); extern void DrawTextPente(CPixmap *pPixmap, POINT pos, char *pText, @@ -25,7 +25,7 @@ extern int GetTextHeight(char *pText, int font=0, int part=-1); extern -int GetTextWidth(char *pText, int font=0); +int GetTextWidth(const char *pText, int font=0); extern void DrawBignum(CPixmap *pPixmap, POINT pos, int num);