mirror of
https://github.com/blupi-games/planetblupi
synced 2024-12-30 10:15:36 +01:00
Final gettext convert (no more LoadString)
This commit is contained in:
parent
4785cd25a8
commit
67831eab7c
54
decblupi.cpp
54
decblupi.cpp
@ -1,6 +1,8 @@
|
||||
// DecBlupi.cpp
|
||||
//
|
||||
|
||||
#include <unordered_map>
|
||||
#include "gettext.h"
|
||||
#include "DEF.H"
|
||||
#include "DECOR.H"
|
||||
#include "ACTION.H"
|
||||
@ -1041,46 +1043,61 @@ void CDecor::ListRemove(int rank)
|
||||
// Retourne -1 si aucune répétiton n'est possible.
|
||||
|
||||
int CDecor::ListSearch(int rank, int button, POINT cel,
|
||||
int &textForButton)
|
||||
const char *&textForButton)
|
||||
{
|
||||
int i, j, param, nb;
|
||||
|
||||
static const char *errors[] = {
|
||||
/* 0 */ translate ("1: Grow tomatoes\n2: Eat"),
|
||||
/* 1 */ translate ("1: Make a bunch\n2: Transform"),
|
||||
/* 2 */ translate ("1: Take\n2: Transform"),
|
||||
/* 3 */ translate ("1: Extract iron\n2: Make a bomb"),
|
||||
/* 4 */ translate ("1: Extract iron\n2: Make a Jeep"),
|
||||
/* 5 */ translate ("1: Extract iron\n2: Make an armour"),
|
||||
/* 6 */ translate ("1: Cut down a tree \n2: Make a palisade"),
|
||||
/* 7 */ translate ("1: Take\n2: Build palisade"),
|
||||
/* 8 */ translate ("1: Cut down a tree \n2: Build a bridge"),
|
||||
/* 9 */ translate ("1: Take\n2: Build a bridge"),
|
||||
/* 10 */ translate ("1: Cut down a tree \n2: Make a boat"),
|
||||
/* 11 */ translate ("1: Take\n2: Make a boat"),
|
||||
};
|
||||
|
||||
static int table_series[] =
|
||||
{
|
||||
TX_REPEAT_CULTIVE,
|
||||
0, // errors
|
||||
2, BUTTON_CULTIVE, BUTTON_MANGE,
|
||||
|
||||
TX_REPEAT_FLEUR,
|
||||
1, // errors
|
||||
4, BUTTON_FLEUR, BUTTON_CARRY, BUTTON_LABO, BUTTON_DEPOSE,
|
||||
|
||||
TX_REPEAT_FLEURQ,
|
||||
2, // errors
|
||||
3, BUTTON_CARRY, BUTTON_LABO, BUTTON_DEPOSE,
|
||||
|
||||
TX_REPEAT_FABMINE,
|
||||
3, // errors
|
||||
3, BUTTON_EXTRAIT, BUTTON_FABMINE, BUTTON_DEPOSE,
|
||||
|
||||
TX_REPEAT_FABJEEP,
|
||||
4, // errors
|
||||
3, BUTTON_EXTRAIT, BUTTON_FABJEEP, BUTTON_DJEEP,
|
||||
|
||||
TX_REPEAT_FABARMURE,
|
||||
5, // errors
|
||||
3, BUTTON_EXTRAIT, BUTTON_FABARMURE, BUTTON_DARMURE,
|
||||
|
||||
TX_REPEAT_PALIS,
|
||||
6, // errors
|
||||
4, BUTTON_ABAT, BUTTON_CARRY, BUTTON_DEPOSE, BUTTON_PALIS,
|
||||
|
||||
TX_REPEAT_PALISQ,
|
||||
7, // errors
|
||||
3, BUTTON_CARRY, BUTTON_DEPOSE, BUTTON_PALIS,
|
||||
|
||||
TX_REPEAT_PONT,
|
||||
8, // errors
|
||||
4, BUTTON_ABAT, BUTTON_CARRY, BUTTON_DEPOSE, BUTTON_PONT,
|
||||
|
||||
TX_REPEAT_PONTQ,
|
||||
9, // errors
|
||||
3, BUTTON_CARRY, BUTTON_DEPOSE, BUTTON_PONT,
|
||||
|
||||
TX_REPEAT_BATEAU,
|
||||
10, // errors
|
||||
4, BUTTON_ABAT, BUTTON_CARRY, BUTTON_DEPOSE, BUTTON_BATEAU,
|
||||
|
||||
TX_REPEAT_BATEAUQ,
|
||||
11, // errors
|
||||
3, BUTTON_CARRY, BUTTON_DEPOSE, BUTTON_BATEAU,
|
||||
|
||||
-1,
|
||||
@ -1107,7 +1124,7 @@ int CDecor::ListSearch(int rank, int button, POINT cel,
|
||||
goto next;
|
||||
}
|
||||
}
|
||||
textForButton = table_series[i];
|
||||
textForButton = gettext (errors[table_series[i]]);
|
||||
return nb-1;
|
||||
}
|
||||
|
||||
@ -4533,14 +4550,16 @@ bool CDecor::IsWorkBlupi(int rank)
|
||||
// pour le blupi sélectionné.
|
||||
|
||||
void CDecor::BlupiGetButtons(POINT pos, int &nb,
|
||||
int *pButtons, int *pErrors, int &perso)
|
||||
int *pButtons, int *pErrors,
|
||||
std::unordered_map<int, const char *> &texts, int &perso)
|
||||
{
|
||||
int* pB = pButtons;
|
||||
int* pE = pErrors;
|
||||
POINT cel, cel2;
|
||||
int i, rank, button, error, channel, icon, textForButton;
|
||||
int i, rank, button, error, channel, icon;
|
||||
bool bBuild = false;
|
||||
bool bPut;
|
||||
const char *textForButton;
|
||||
|
||||
static int table_buttons[] =
|
||||
{
|
||||
@ -4713,7 +4732,8 @@ void CDecor::BlupiGetButtons(POINT pos, int &nb,
|
||||
m_blupi[m_rankBlupiHili].repeatLevelHope = rank;
|
||||
|
||||
pButtons[nb] = BUTTON_REPEAT;
|
||||
pErrors[nb] = textForButton;
|
||||
pErrors[nb] = 500;
|
||||
texts[nb] = textForButton;
|
||||
nb ++;
|
||||
return;
|
||||
}
|
||||
|
6
decor.h
6
decor.h
@ -2,6 +2,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <unordered_map>
|
||||
#include "DEF.H"
|
||||
#include "SOUND.H"
|
||||
#include "PIXMAP.H"
|
||||
@ -254,7 +255,7 @@ public:
|
||||
int ListGetParam(int rank, int button, POINT cel);
|
||||
bool ListPut(int rank, int button, POINT cel, POINT cMem);
|
||||
void ListRemove(int rank);
|
||||
int ListSearch(int rank, int button, POINT cel, int &textForButton);
|
||||
int ListSearch(int rank, int button, POINT cel, const char *&textForButton);
|
||||
bool RepeatAdjust(int rank, int button, POINT &cel, POINT &cMem,
|
||||
int param, int list);
|
||||
void GoalStart(int rank, int action, POINT cel);
|
||||
@ -294,7 +295,8 @@ public:
|
||||
bool IsBlupiHere(POINT cel, int direct, bool bSkipInMove);
|
||||
void GetLevelJauge(int *pLevels, int *pTypes);
|
||||
bool IsWorkBlupi(int rank);
|
||||
void BlupiGetButtons(POINT pos, int &nb, int *pButtons, int *pErrors, int &perso);
|
||||
void BlupiGetButtons(POINT pos, int &nb, int *pButtons, int *pErrors,
|
||||
std::unordered_map<int, const char *> &texts, int &perso);
|
||||
void TerminatedInit();
|
||||
int IsTerminated();
|
||||
Term* GetTerminated();
|
||||
|
@ -1926,8 +1926,9 @@ bool CEvent::DrawButtons()
|
||||
{
|
||||
m_pDecor->BlupiGetButtons(m_menuPos, m_menuNb,
|
||||
m_menuButtons, m_menuErrors,
|
||||
m_menuTexts,
|
||||
m_menuPerso);
|
||||
m_menu.Update(m_menuNb, m_menuButtons, m_menuErrors);
|
||||
m_menu.Update(m_menuNb, m_menuButtons, m_menuErrors, m_menuTexts);
|
||||
|
||||
button = m_menu.GetSel();
|
||||
m_pDecor->CelHiliButton(m_menuCel, button);
|
||||
@ -3469,7 +3470,7 @@ bool CEvent::PlayUp(POINT pos, Uint16 mod)
|
||||
else
|
||||
{
|
||||
m_pDecor->BlupiGetButtons(pos, m_menuNb, m_menuButtons,
|
||||
m_menuErrors, m_menuPerso);
|
||||
m_menuErrors, m_menuTexts, m_menuPerso);
|
||||
if ( m_menuNb == 0 )
|
||||
{
|
||||
m_pDecor->BlupiSound(-1, table_sound_boing[Random(0,2)], pos);
|
||||
@ -3480,7 +3481,7 @@ bool CEvent::PlayUp(POINT pos, Uint16 mod)
|
||||
m_menuPos = pos;
|
||||
m_menu.Create(m_pPixmap, m_pSound,
|
||||
pos, m_menuNb, m_menuButtons, m_menuErrors,
|
||||
m_menuPerso);
|
||||
m_menuTexts, m_menuPerso);
|
||||
m_bMenu = true;
|
||||
m_pDecor->HideTooltips(true); // plus de tooltips pour décor
|
||||
}
|
||||
|
2
event.h
2
event.h
@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include "jauge.h"
|
||||
#include "menu.h"
|
||||
#include "button.h"
|
||||
@ -176,6 +177,7 @@ protected:
|
||||
int m_menuNb;
|
||||
int m_menuButtons[MAXBUTTON];
|
||||
int m_menuErrors[MAXBUTTON];
|
||||
std::unordered_map<int, const char *> m_menuTexts;
|
||||
int m_menuPerso;
|
||||
POINT m_menuCel;
|
||||
POINT m_oldMousePos;
|
||||
|
11
menu.cpp
11
menu.cpp
@ -142,6 +142,7 @@ CMenu::~CMenu()
|
||||
|
||||
bool CMenu::Create(CPixmap *pPixmap, CSound *pSound,
|
||||
POINT pos, int nb, int *pButtons, int *pErrors,
|
||||
std::unordered_map<int, const char *> &texts,
|
||||
int perso)
|
||||
{
|
||||
pos.x -= DIMBUTTONX/2;
|
||||
@ -153,7 +154,7 @@ bool CMenu::Create(CPixmap *pPixmap, CSound *pSound,
|
||||
m_pos = pos;
|
||||
m_perso = perso;
|
||||
|
||||
Update(nb, pButtons, pErrors);
|
||||
Update(nb, pButtons, pErrors, texts);
|
||||
|
||||
if ( m_pos.x < POSDRAWX ) m_pos.x = POSDRAWX;
|
||||
if ( m_pos.y < POSDRAWY ) m_pos.y = POSDRAWY;
|
||||
@ -176,7 +177,8 @@ bool CMenu::Create(CPixmap *pPixmap, CSound *pSound,
|
||||
|
||||
// Met à jour le menu.
|
||||
|
||||
void CMenu::Update(int nb, int *pButtons, int *pErrors)
|
||||
void CMenu::Update(int nb, int *pButtons, int *pErrors,
|
||||
std::unordered_map<int, const char *> &texts)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -195,6 +197,7 @@ void CMenu::Update(int nb, int *pButtons, int *pErrors)
|
||||
m_buttons[i] = pButtons[i];
|
||||
m_errors[i] = pErrors[i];
|
||||
}
|
||||
m_texts = texts;
|
||||
}
|
||||
|
||||
// Détruit le menu.
|
||||
@ -270,7 +273,7 @@ void CMenu::Draw()
|
||||
|
||||
if ( m_errors[i] >= 100 ) // no ressource au lieu erreur ?
|
||||
{
|
||||
LoadString(m_errors[i], text, 50);
|
||||
snprintf (text, sizeof (text), m_texts[i]);
|
||||
pText = strchr(text, '\n');
|
||||
if ( pText != nullptr ) *pText = 0;
|
||||
}
|
||||
@ -309,7 +312,7 @@ void CMenu::Draw()
|
||||
{
|
||||
if ( m_errors[i] >= 100 ) // no ressource au lieu erreur ?
|
||||
{
|
||||
LoadString(m_errors[i], text, 50);
|
||||
snprintf (text, sizeof (text), m_texts[i]);
|
||||
pText = strchr(text, '\n');
|
||||
if ( pText != nullptr ) strcpy(text, pText+1);
|
||||
}
|
||||
|
6
menu.h
6
menu.h
@ -2,6 +2,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <unordered_map>
|
||||
#include "def.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@ -14,8 +15,10 @@ public:
|
||||
|
||||
bool Create(CPixmap *pPixmap, CSound *pSound,
|
||||
POINT pos, int nb, int *pButtons, int *pErrors,
|
||||
std::unordered_map<int, const char *> &texts,
|
||||
int perso);
|
||||
void Update(int nb, int *pButtons, int *pErrors);
|
||||
void Update(int nb, int *pButtons, int *pErrors,
|
||||
std::unordered_map<int, const char *> &texts);
|
||||
void Delete();
|
||||
void Draw();
|
||||
int GetSel();
|
||||
@ -43,6 +46,7 @@ protected:
|
||||
int m_perso;
|
||||
int m_buttons[MAXBUTTON];
|
||||
int m_errors[MAXBUTTON];
|
||||
std::unordered_map<int, const char *> m_texts;
|
||||
UINT m_messages[MAXBUTTON];
|
||||
int m_selRank;
|
||||
};
|
||||
|
8
misc.cpp
8
misc.cpp
@ -31,14 +31,6 @@ void OutputDebug(char *pMessage)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Charge un texte dans une ressource.
|
||||
|
||||
void LoadString(UINT nID, char *pBuffer, int lgBuffer)
|
||||
{
|
||||
LoadString(g_hInstance, nID, pBuffer, lgBuffer);
|
||||
}
|
||||
|
||||
// Conversion de la position de la souris.
|
||||
|
||||
POINT ConvLongToPos(LPARAM lParam)
|
||||
|
Loading…
x
Reference in New Issue
Block a user