Commit 4ba89374 authored by gerstrong's avatar gerstrong

Some cleanups.

Removed global strings to the singleton CBehavior class

git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@1214 4df4b0f3-56ce-47cb-b001-ed939b7d65a6
parent cc9333e5
......@@ -3,6 +3,15 @@
*
* Created on: 11.06.2010
* Author: gerstrong
*
* This engine stores all the behavior in the games,
* that can be read from the game-data files.
* Mainly the TileProperties are stored here,
* which for example decides whether something
* is blocked or not.
*
* Also Information-blocks like some Strings read from the Exe-files
* belong to this class
*/
#include "CBehaviorEngine.h"
......@@ -19,6 +28,23 @@ std::vector<CTileProperties> &CBehaviorEngine::getTileProperties()
CPhysicsSettings &CBehaviorEngine::getPhysicsSettings()
{ return m_PhysicsSettings; }
// returns a pointer to the string with name 'name'
std::string CBehaviorEngine::getString(const std::string& name)
{
for(int i=0;i<numStrings;i++)
{
if (name == strings[i].name)
{
// Returning is not enough anymore
// Convert the /h and /H into proper colours
// This is necessary since the new graphics engine
return strings[i].message;
}
}
return "UNKNOWN '" + name + "' STRING";
}
CBehaviorEngine::~CBehaviorEngine()
{
// TODO Auto-generated destructor stub
......
......@@ -16,12 +16,19 @@
#define CBEHAVIORENGINE_H_
#include <vector>
#include <string>
#include "CTileProperties.h"
#include "CPhysicsSettings.h"
#include "../CSingleton.h"
#define g_pBehaviorEngine CBehaviorEngine::Get()
struct stString
{
std::string name; // pointer to malloc'd area containing string name
std::string message; // pointer to malloc'd area containing string
};
class CBehaviorEngine : public CSingleton<CBehaviorEngine>
{
public:
......@@ -29,12 +36,24 @@ public:
std::vector<CTileProperties> &getTileProperties();
CPhysicsSettings &getPhysicsSettings();
std::string getString(const std::string& name);
void addMessage(const std::string &name, const std::string &message)
{
stString string;
string.name = name;
string.message = message;
strings.push_back(string);
}
virtual ~CBehaviorEngine();
private:
std::vector<CTileProperties> m_TileProperties;
CPhysicsSettings m_PhysicsSettings;
std::vector<stString> strings;
int numStrings;
};
#endif /* CBEHAVIORENGINE_H_ */
......@@ -15,6 +15,7 @@
#include "../sdl/CVideoDriver.h"
#include "../StringUtils.h"
#include "../common/Playerdefines.h"
#include "../common/CBehaviorEngine.h"
#include "../graphics/effects/CColorMerge.h"
#define FADE_SPEED 10
......@@ -78,7 +79,7 @@ void CStatusScreen::drawInventoryEp1()
dlgH = 15;
g_pGfxEngine->drawDialogBox( p_surface, dlgX,dlgY,dlgW,dlgH, SDL_MapRGB(p_surface->format, 172, 172, 172));
Font.drawFont( p_surface, getstring("EP1_StatusBox"), (dlgX+1)<<3, (dlgY+1)<<3, true);
Font.drawFont( p_surface, g_pBehaviorEngine->getString("EP1_StatusBox"), (dlgX+1)<<3, (dlgY+1)<<3, true);
// Now draw some white rects. Those are the holders for items, numbers, etc.
SDL_Rect rect;
......@@ -198,7 +199,7 @@ void CStatusScreen::drawInventoryEp2()
dlgW = 29;
dlgH = 14;
tempbuf = getstring("EP2_StatusBox");
tempbuf = g_pBehaviorEngine->getString("EP2_StatusBox");
g_pGfxEngine->drawDialogBox( p_surface, dlgX,dlgY,dlgW,dlgH, SDL_MapRGB(p_surface->format, 172, 172, 172));
Font.drawFont( p_surface, tempbuf, (dlgX+1)<<3, (dlgY+1)<<3, true);
......@@ -285,14 +286,14 @@ void CStatusScreen::drawInventoryEp2()
}
// cities saved
if (mp_level_completed[4]) Font.drawFont( p_surface, getstring("EP2_LVL4_TargetName"), (dlgX+1)<<3, (dlgY+8)<<3);
if (mp_level_completed[6]) Font.drawFont( p_surface, getstring("EP2_LVL6_TargetName"), (dlgX+8)<<3, (dlgY+8)<<3);
if (mp_level_completed[7]) Font.drawFont( p_surface, getstring("EP2_LVL7_TargetName"), (dlgX+1)<<3, (dlgY+9)<<3);
if (mp_level_completed[13]) Font.drawFont( p_surface, getstring("EP2_LVL13_TargetName"), (dlgX+8)<<3, (dlgY+9)<<3);
if (mp_level_completed[11]) Font.drawFont( p_surface, getstring("EP2_LVL11_TargetName"), (dlgX+1)<<3, (dlgY+10)<<3);
if (mp_level_completed[9]) Font.drawFont( p_surface, getstring("EP2_LVL9_TargetName"), (dlgX+8)<<3, (dlgY+10)<<3);
if (mp_level_completed[15]) Font.drawFont( p_surface, getstring("EP2_LVL15_TargetName"), (dlgX+1)<<3, (dlgY+11)<<3);
if (mp_level_completed[16]) Font.drawFont( p_surface, getstring("EP2_LVL16_TargetName"), (dlgX+8)<<3, (dlgY+11)<<3);
if (mp_level_completed[4]) Font.drawFont( p_surface, g_pBehaviorEngine->getString("EP2_LVL4_TargetName"), (dlgX+1)<<3, (dlgY+8)<<3);
if (mp_level_completed[6]) Font.drawFont( p_surface, g_pBehaviorEngine->getString("EP2_LVL6_TargetName"), (dlgX+8)<<3, (dlgY+8)<<3);
if (mp_level_completed[7]) Font.drawFont( p_surface, g_pBehaviorEngine->getString("EP2_LVL7_TargetName"), (dlgX+1)<<3, (dlgY+9)<<3);
if (mp_level_completed[13]) Font.drawFont( p_surface, g_pBehaviorEngine->getString("EP2_LVL13_TargetName"), (dlgX+8)<<3, (dlgY+9)<<3);
if (mp_level_completed[11]) Font.drawFont( p_surface, g_pBehaviorEngine->getString("EP2_LVL11_TargetName"), (dlgX+1)<<3, (dlgY+10)<<3);
if (mp_level_completed[9]) Font.drawFont( p_surface, g_pBehaviorEngine->getString("EP2_LVL9_TargetName"), (dlgX+8)<<3, (dlgY+10)<<3);
if (mp_level_completed[15]) Font.drawFont( p_surface, g_pBehaviorEngine->getString("EP2_LVL15_TargetName"), (dlgX+1)<<3, (dlgY+11)<<3);
if (mp_level_completed[16]) Font.drawFont( p_surface, g_pBehaviorEngine->getString("EP2_LVL16_TargetName"), (dlgX+8)<<3, (dlgY+11)<<3);
}
void CStatusScreen::drawInventoryEp3()
......@@ -310,7 +311,7 @@ void CStatusScreen::drawInventoryEp3()
dlgW = 29;
dlgH = 13;
tempbuf = getstring("EP3_StatusBox");
tempbuf = g_pBehaviorEngine->getString("EP3_StatusBox");
g_pGfxEngine->drawDialogBox( p_surface, dlgX,dlgY,dlgW,dlgH, SDL_MapRGB(p_surface->format, 172, 172, 172));
Font.drawFont( p_surface, tempbuf, (dlgX+1)<<3, (dlgY+1)<<3, true);
......
/* demobox.h */
// This file contains the image data for the 'demo' box
// shown on the screen while a demo is in progress.
// This is stored seperatly from the rest of the graphics
// because the original keen games did not have a demo and
// so EGALATCH contains no 'DEMO' graphics.
// Created by MAKEDMOH.BAS 03-22-2004 14:57:54
#define DEMOBOX_WIDTH 48
#define DEMOBOX_HEIGHT 16
/*unsigned char demobox_image[768] = { \
15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, \
15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, \
15,15,15,12,12,12,12,12,12,15,15,15,15,12,12,12,12,12,12,12,15,15,12,15,15,15,15,15,15,15,12,15,15,15,15,12,12,12,12,15,15,15,15,15,15,15,15,15,15, \
15,15,12,12,15,15,15,12,12,15,15,15,12,12,15,15,15,15,15,15,15,12,12,15,15,15,15,15,12,12,15,15,15,12,12,15,15,12,12,15,15,15,15,15,15,15,15,15,15, \
15,12,12,15,15,15,15,12,12,15,15,12,12,15,15,15,15,15,15,15,12,12,12,15,15,15,12,12,12,15,15,12,12,15,15,15,15,12,12,15,15,15,15,15,15,15,15,15,15, \
12,12,15,15,15,15,12,12,15,15,12,12,12,12,12,12,15,15,15,12,12,15,12,15,12,15,12,12,15,15,12,12,15,15,15,15,12,12,15,15,15,15,15,15,15,15,15,15,12, \
12,15,15,15,15,12,12,15,15,12,12,15,15,15,15,15,15,15,12,12,15,15,12,15,15,12,12,15,15,12,12,15,15,15,15,12,12,15,15,15,15,15,15,15,15,15,15,12,12, \
15,15,15,15,12,12,15,15,12,12,15,15,15,15,15,15,15,12,12,15,15,12,15,15,12,12,15,15,12,12,15,15,15,15,12,12,15,15,15,15,15,15,15,15,15,15,12,12,15, \
15,15,12,12,15,15,15,12,12,15,15,15,15,15,15,15,12,12,15,15,15,15,15,12,12,15,15,15,12,12,15,15,12,12,15,15,15,15,15,15,15,15,15,15,15,12,12,12,12, \
12,12,15,15,15,15,12,12,12,12,12,12,12,15,15,12,12,15,15,15,15,15,12,12,15,15,15,15,12,12,12,12,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, \
15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4, \
4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,15,4 ,4 ,12,12,12,12,12,12,12,12,12,12, \
12,12,12,12,12,12,15,12,12,15,15,15,15,15,15,12,12,15,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,4 ,4 ,15,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4, \
4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, \
15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, \
15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, \
};*/
unsigned char demobox_image[768] = { \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 0,12,12,12,12,12,12, 0, 0, 0, 0,12,12,12,12,12,12,12, 0, 0,12, 0, 0, 0, 0, 0, 0, 0,12, 0, 0, 0, 0,12,12,12,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0,12,12, 0, 0, 0,12,12, 0, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0,12,12, 0, 0, 0, 0, 0,12,12, 0, 0, 0,12,12, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0,12,12, 0, 0, 0, 0,12,12, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0,12,12,12, 0, 0, 0,12,12,12, 0, 0,12,12, 0, 0, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
12,12, 0, 0, 0, 0,12,12, 0, 0,12,12,12,12,12,12, 0, 0, 0,12,12, 0,12, 0,12, 0,12,12, 0, 0,12,12, 0, 0, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,12, \
12, 0, 0, 0, 0,12,12, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0,12,12, 0, 0,12, 0, 0,12,12, 0, 0,12,12, 0, 0, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,12,12, \
0, 0, 0, 0,12,12, 0, 0,12,12, 0, 0, 0, 0, 0, 0, 0,12,12, 0, 0,12, 0, 0,12,12, 0, 0,12,12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,0 , \
0 ,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,0 , \
15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, \
0 ,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,0 , \
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , \
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , \
};
......@@ -12,6 +12,7 @@
#define CMESSAGEBOX_H_
#include "../dialog/CDlgFrame.h"
#include "../common/CBehaviorEngine.h"
#include <string>
#include <vector>
......
......@@ -12,6 +12,7 @@
#include "CMessages.h"
#include "../StringUtils.h"
#include "../CLogFile.h"
#include "../common/CBehaviorEngine.h"
CMessages::CMessages(unsigned char *p_exebuf, char episode, int version) :
mp_exe(p_exebuf)
......@@ -148,18 +149,12 @@ bool CMessages::extractGlobalStrings()
// Still a bad idea, because it's global string.
if(!StringMap.empty())
{
std::map<std::string, std::string>::iterator i = StringMap.begin();
for(int c=0 ; c<MAX_STRINGS ; c++)
std::map<std::string, std::string>::iterator i;
for( i = StringMap.begin() ; i != StringMap.end() ; i++ )
{
strings[c].name = i->first;
strings[c].stringptr = i->second;
i++;
if( i == StringMap.end() )
break;
g_pBehaviorEngine->addMessage(i->first, i->second);
}
numStrings = StringMap.size();
g_pLogFile->ftextOut("Loaded %d strings from the exe-file.<br>", numStrings);
g_pLogFile->ftextOut("Loaded %d strings from the exe-file.<br>", StringMap.size());
return true;
}
return false;
......
......@@ -58,13 +58,8 @@ void CPlayGameGalaxy::process()
{
g_pGfxEngine->getTileMap(0).drawTile(g_pVideoDriver->getBlitSurface(),
16*x, 16*y, m_Map.at((x+2),(y+2),0) );
//printf("%d ", m_Map.at(x,y,0));
//g_pGfxEngine->getTileMap(0).drawTile(g_pVideoDriver->getBlitSurface(),
//16*x, 16*y, 10 );
}
printf("\n");
}
printf("\n");
}
void CPlayGameGalaxy::cleanup()
......
......@@ -59,7 +59,7 @@ void CEndingEp1::ReturnsToShip()
while(m_Player[0].scrollTriggers()); // Scroll the map to players position
mp_Textbox = new CMessageBox(getstring("EP1_ESEQ_PART1"), true);
mp_Textbox = new CMessageBox(g_pBehaviorEngine->getString("EP1_ESEQ_PART1"), true);
m_mustsetup = false;
}
......
......@@ -73,7 +73,7 @@ void CEndingEp2::HeadsForEarth()
m_Map.findTile(593, &x, &y);
m_Player[0].moveTo(x<<CSF, y<<CSF);
mp_Textbox = new CMessageBox(getstring("EP2_ESEQ_PART1"), true);
mp_Textbox = new CMessageBox(g_pBehaviorEngine->getString("EP2_ESEQ_PART1"), true);
m_mustsetup = false;
}
......@@ -125,7 +125,7 @@ void CEndingEp2::LimpsHome()
m_Map.drawAll();
mp_ShipFlySys->m_ShipQueuePtr = 0;
mp_Textbox = new CMessageBox(getstring("EP2_ESEQ_PART2"), true);
mp_Textbox = new CMessageBox(g_pBehaviorEngine->getString("EP2_ESEQ_PART2"), true);
m_mustsetup = false;
}
......
......@@ -58,10 +58,10 @@ void CEndingEp3::HonorScene()
m_Map.gotoPos(32, 32);
m_Map.drawAll();
m_TextBoxes.push_back(new CMessageBox(getstring("EP3_ESEQ_PAGE1"), true));
m_TextBoxes.push_back(new CMessageBox(getstring("EP3_ESEQ_PAGE2"), true));
m_TextBoxes.push_back(new CMessageBox(getstring("EP3_ESEQ_PAGE3"), true));
m_TextBoxes.push_back(new CMessageBox(getstring("EP3_ESEQ_PAGE4"), true));
m_TextBoxes.push_back(new CMessageBox(g_pBehaviorEngine->getString("EP3_ESEQ_PAGE1"), true));
m_TextBoxes.push_back(new CMessageBox(g_pBehaviorEngine->getString("EP3_ESEQ_PAGE2"), true));
m_TextBoxes.push_back(new CMessageBox(g_pBehaviorEngine->getString("EP3_ESEQ_PAGE3"), true));
m_TextBoxes.push_back(new CMessageBox(g_pBehaviorEngine->getString("EP3_ESEQ_PAGE4"), true));
int newtile = m_Map.at(2,12);
for(int x=0 ; x<22 ; x++) // This changes to the Oh No! Tiles to normal Stone-Tiles
......
......@@ -25,7 +25,7 @@ CFinaleStaticScene::CFinaleStaticScene(const std::string &game_path, const std::
void CFinaleStaticScene::push_string(const std::string &text, Uint32 delay)
{
CMessageBox *p_Textbox = new CMessageBox(getstring(text), true);
CMessageBox *p_Textbox = new CMessageBox(g_pBehaviorEngine->getString(text), true);
mp_textbox_list.push_back(p_Textbox);
......
......@@ -28,7 +28,7 @@ void CPlayGameVorticon::processInLevel()
// If the player touched a hint trigger in which we have to show a Message, do it so
std::string hinttext;
if( (hinttext=m_Player[i].pollHintMessage()) != "")
m_MessageBoxes.push_back(new CMessageBox(getstring(hinttext), false, true) );
m_MessageBoxes.push_back(new CMessageBox(g_pBehaviorEngine->getString(hinttext), false, true) );
// Check if the first player is dead, and if the others also are...
if(i==0) m_alldead = (m_Player[i].pdie == PDIE_DEAD);
......
......@@ -153,12 +153,12 @@ bool CPlayGameVorticon::init()
// In the case that we are in Episode 3 last Level, show Mortimer Messages
if( m_Episode == 3 && m_Level == 16 )
{
m_MessageBoxes.push_back(new CMessageBox(getstring("EP3_MORTIMER"),false, true));
m_MessageBoxes.push_back(new CMessageBox(getstring("EP3_MORTIMER2"),false, true));
m_MessageBoxes.push_back(new CMessageBox(getstring("EP3_MORTIMER3"),false, true));
m_MessageBoxes.push_back(new CMessageBox(getstring("EP3_MORTIMER4"),false, true));
m_MessageBoxes.push_back(new CMessageBox(getstring("EP3_MORTIMER5"),false, true));
m_MessageBoxes.push_back(new CMessageBox(getstring("EP3_MORTIMER6"),false, true));
m_MessageBoxes.push_back(new CMessageBox(g_pBehaviorEngine->getString("EP3_MORTIMER"),false, true));
m_MessageBoxes.push_back(new CMessageBox(g_pBehaviorEngine->getString("EP3_MORTIMER2"),false, true));
m_MessageBoxes.push_back(new CMessageBox(g_pBehaviorEngine->getString("EP3_MORTIMER3"),false, true));
m_MessageBoxes.push_back(new CMessageBox(g_pBehaviorEngine->getString("EP3_MORTIMER4"),false, true));
m_MessageBoxes.push_back(new CMessageBox(g_pBehaviorEngine->getString("EP3_MORTIMER5"),false, true));
m_MessageBoxes.push_back(new CMessageBox(g_pBehaviorEngine->getString("EP3_MORTIMER6"),false, true));
g_pSound->playSound(SOUND_MORTIMER, PLAY_FORCE);
}
......
......@@ -131,7 +131,7 @@ void CPlayGameVorticon::goBacktoMap()
void CPlayGameVorticon::YourShipNeedsTheseParts()
{
CMessageBox *MessageBox = new CMessageBox(getstring("EP1_SHIP"));
CMessageBox *MessageBox = new CMessageBox(g_pBehaviorEngine->getString("EP1_SHIP"));
bool joy, bat, vac, wis;
joy = bat = vac = wis = false;
......@@ -157,7 +157,7 @@ void CPlayGameVorticon::ShipEp3()
{
// get one of four random strings and display it!!
std::string strname = "EP3_SHIP"+ itoa((rand()%4)+1);
m_MessageBoxes.push_back(new CMessageBox(getstring(strname)));
m_MessageBoxes.push_back(new CMessageBox(g_pBehaviorEngine->getString(strname)));
}
void CPlayGameVorticon::showKeensLeft()
......@@ -181,7 +181,7 @@ const unsigned int KEENSLEFT_H = 4;
rect.x = (KEENSLEFT_X+1)*8; rect.y = (boxY+2)*8;
rect.w = (KEENSLEFT_W-1)*8; rect.h = (boxH-3)*8;
g_pGfxEngine->drawDialogBox( boxsurface, KEENSLEFT_X, boxY,KEENSLEFT_W,boxH, SDL_MapRGB(boxsurface->format, 172, 172, 172));
g_pGfxEngine->getFont(0).drawFont( boxsurface, getstring("LIVES_LEFT"),((KEENSLEFT_X+4)*8)+4,(boxY+1)*8, true);
g_pGfxEngine->getFont(0).drawFont( boxsurface, g_pBehaviorEngine->getString("LIVES_LEFT"),((KEENSLEFT_X+4)*8)+4,(boxY+1)*8, true);
SDL_FillRect(boxsurface, &rect, 0xFFFFFF);
y = ((boxY+2)*8)+4;
......
/*
* externals.h
*
* Created on: 08.10.2009
* Author: gerstrong
*/
#ifndef EXTERNALS_H_
#define EXTERNALS_H_
extern stString strings[MAX_STRINGS+1];
extern int numStrings;
#endif /* EXTERNALS_H_ */
......@@ -76,20 +76,3 @@ void fputl(unsigned long word, FILE *fp)
fputc(b, fp);
fputc(a, fp);
}
// returns a pointer to the string with name 'name'
std::string getstring(const std::string& name)
{
for(int i=0;i<numStrings;i++)
{
if (name == strings[i].name)
{
// Returning is not enough anymore
// Convert the /h and /H into proper colours
// This is necessary since the new graphics engine
return strings[i].stringptr;
}
}
return "UNKNOWN '" + name + "' STRING";
}
......@@ -88,20 +88,6 @@ struct stMap
struct SDL_Surface;
#define MAX_STRINGS 100
#define MAX_ATTRIBUTES 16
struct stString
{
std::string name; // pointer to malloc'd area containing string name
std::string stringptr; // pointer to malloc'd area containing string
int numAttributes;
unsigned char *attrnames[MAX_ATTRIBUTES+1];
unsigned int attrvalues[MAX_ATTRIBUTES+1];
};
#include "externals.h"
// default sprites...when an object is spawned it's sprite is set to this
// sprite. the object AI will immediately reset the sprite frame, so it
// wouldn't really matter what these are...except that it does because
......
......@@ -30,9 +30,6 @@
#include "CGame.h"
#include "FindFile.h"
stString strings[MAX_STRINGS+1];
int numStrings = 0;
void banner(void);
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment