r131 - trunk/src
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Thu Sep 1 09:23:04 EDT 2005
Author: jonas
Date: 2005-09-01 09:23:04 -0400 (Thu, 01 Sep 2005)
New Revision: 131
Modified:
trunk/src/editor.cpp
trunk/src/editor.h
trunk/src/gfxeng.cpp
trunk/src/objectpools.cpp
trunk/src/objectpools.h
trunk/src/players_common.cpp
trunk/src/scenario.cpp
trunk/src/scenario.h
Log:
GAME_PAUSED state fixes (update the whole scene if necessary).
ObjectsPool creates objects in game coordinates, not display coordinates.
Various editor improvements (the map editor is quite useable now):
- Various bug fixes
- Much improved TextInputBox
(e.g. allow nice Input entry titles/fields)
- Allow non centered layouts
- Much improved EditBox
- New Map creations
- Allow Map saving
- Allow Map loading
- Allow Map testing
- Much improved ObjectBox
(full featured object configuration before placing)
Modified: trunk/src/editor.cpp
===================================================================
--- trunk/src/editor.cpp 2005-09-01 00:01:51 UTC (rev 130)
+++ trunk/src/editor.cpp 2005-09-01 13:23:04 UTC (rev 131)
@@ -10,16 +10,19 @@
Editor::Editor() {
run_action(EDIT_RESET_ACTIONS);
string place_name="";
- save_name="newmap.txt";
+ save_name="newmap.cfg";
box=NULL;
}
Editor::~Editor() {
closeBox();
- saveBuf(save_name);
}
void Editor::run_action(Uint32 action, Uint16 x, Uint16 y) {
+ SDL_Rect shift=gfxeng->getShift();
+ Sint16 xs=x-shift.x;
+ Sint16 ys=y-shift.y;
+
gfxeng->update(UPDATE_ALL);
if (action&EDIT_RESET_ACTIONS) {
for (Uint8 i=0; i<6; i++) {
@@ -35,9 +38,8 @@
if (box) box->act(box->getCurrentEntry(x,y));
} else if (action&EDIT_PLACE_OBJECT) {
scenario->reloadMap();
- string next_name=scenario->pool->getNextObjectName(place_name);
- if (scenario->pool->addObjectbyName(place_name,place_image,x,y,next_name)) {
- appendtoBuf(place_name+" "+place_image+" "+itos(x)+" "+itos(y)+" "+next_name);
+ if (scenario->pool->addObjectbyName(place_name,place_image,xs,ys,place_arg1,place_arg2,place_arg3)) {
+ appendtoBuf(place_name+" "+place_image+" "+itos(xs)+" "+itos(ys)+" "+place_arg1+" "+place_arg2+" "+place_arg3);
}
// action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_ACT_BOX;
} else { }
@@ -76,8 +78,8 @@
}
Box* Editor::setBox(Box* newbox) {
- gfxeng->update(UPDATE_ALL);
- return box=newbox;
+ closeBox();
+ return box=newbox;
}
void Editor::closeBox() {
@@ -92,7 +94,9 @@
//don't forget the "::"
font(::font),
font_title(font),
- font_high(font2) {
+ font_high(font2),
+ centered(true) {
+ editor->run_action(EDIT_RESET_ACTIONS);
area.x=x;
area.y=y;
}
@@ -172,13 +176,66 @@
/* write entries */
for (Uint8 i=0; i<entries.size(); i++) {
tmph=DFONT*(i+1)+font->getHeight()*i+WFONT+font_title->getHeight();
- font->writeCenter(surface,entries[i],tmph);
+ if (centered) font->writeCenter(surface,entries[i],tmph);
+ else font->write(surface,entries[i],WFONT,tmph);
line.y=tmph+font->getHeight()+(int)((DFONT-line.h)/2);
SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,180));
}
}
EditBox::EditBox(Sint16 x, Sint16 y): Box(x,y) {
+ title="EDIT MAP";
+ entries.push_back("New");
+ entries.push_back("Save As...");
+ entries.push_back("Save");
+ entries.push_back("Open");
+ entries.push_back("Run");
+ entries.push_back("Quit");
+ entries.push_back("");
+ entries.push_back("Place Object");
+ entries.push_back("Remove Object");
+ entries.push_back("Move Object");
+ entries.push_back("Configure Object");
+ update();
+}
+
+void EditBox::act(Sint8 curentry) {
+ gfxeng->update(UPDATE_ALL);
+ if (curentry==-1 || curentry >= (Sint8)entries.size()) {
+ editor->closeBox();
+ } else if (entries[curentry]=="New") {
+ editor->setBox(new NewMapBox(area.x,area.y));
+ } else if (entries[curentry]=="Save As...") {
+ editor->setBox(new SaveAsBox(area.x,area.y));
+ } else if (entries[curentry]=="Save") {
+ if (editor->save_name=="newmap.cfg") {
+ editor->setBox(new SaveAsBox(area.x,area.y));
+ } else {
+ editor->saveBuf(editor->save_name);
+ editor->closeBox();
+ }
+ } else if (entries[curentry]=="Open") {
+ editor->setBox(new OpenMapBox(area.x,area.y));
+ } else if (entries[curentry]=="Run") {
+ setGameMode(GAME_PLAY);
+ scenario->reloadMap();
+ editor->closeBox();
+ } else if (entries[curentry]=="Place Object") {
+ editor->setBox(new PlaceBox(area.x,area.y));
+ } else if (entries[curentry]=="Remove Object") {
+ editor->closeBox();
+ } else if (entries[curentry]=="Move Object") {
+ editor->closeBox();
+ } else if (entries[curentry]=="Configure Object") {
+ editor->closeBox();
+ } else if (entries[curentry]=="Quit") {
+ quitGame(0);
+ } else {
+ editor->closeBox();
+ }
+}
+
+PlaceBox::PlaceBox(Sint16 x, Sint16 y): Box(x,y) {
title="PLACE";
entries.push_back("Wall");
entries.push_back("Exit");
@@ -206,55 +263,53 @@
update();
}
-void EditBox::act(Sint8 curentry) {
+void PlaceBox::act(Sint8 curentry) {
gfxeng->update(UPDATE_ALL);
if (curentry==-1 || curentry >= (Sint8)entries.size()) {
- editor->closeBox();
} else {
- editor->place_name=entries[curentry];
- if (editor->place_name=="Wall") {
- editor->place_image="viking1.bmp";
- } else if (editor->place_name=="Water") {
- editor->place_image="water.bmp";
- } else if (editor->place_name=="Exit") {
- editor->place_image="exit.bmp";
- } else if (editor->place_name=="Teleporter") {
- editor->place_image="viking1.bmp";
- } else if (editor->place_name=="Wind") {
- editor->place_image="teleport_01.bmp";
- } else if (editor->place_name=="Geyser") {
- editor->place_image="viking1.bmp";
- } else if (editor->place_name=="Trigger") {
- editor->place_image="key.bmp";
- } else if (editor->place_name=="Door") {
- editor->place_image="viking1.bmp";
- } else if (editor->place_name=="Spike") {
- editor->place_image="viking1.bmp";
- } else if (editor->place_name=="Heart") {
- editor->place_image="heart.bmp";
- } else if (editor->place_name=="Key") {
- editor->place_image="key.bmp";
- } else if (editor->place_name=="Bomb") {
- editor->place_image="bomb_fire.bmp";
- } else if (editor->place_name=="Erik") {
- editor->place_image="viking.bmp";
- } else if (editor->place_name=="Olaf") {
- editor->place_image="viking.bmp";
- } else if (editor->place_name=="Baleog") {
- editor->place_image="viking.bmp";
- } else if (editor->place_name=="Fang") {
- editor->place_image="viking.bmp";
- } else if (editor->place_name=="Scorch") {
- editor->place_image="viking.bmp";
- } else if (editor->place_name=="Plant") {
- editor->place_image="viking1.bmp";
- } else if (editor->place_name=="Zombie") {
- editor->place_image="viking.bmp";
+ string next_name=scenario->pool->getNextObjectName(entries[curentry]);
+ if (entries[curentry]=="Wall") {
+ editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Name: ",next_name));
+ } else if (entries[curentry]=="Water") {
+ editor->setBox(new ObjectBox(entries[curentry],"water.bmp",area.x,area.y,"Name: ",next_name));
+ } else if (entries[curentry]=="Exit") {
+ editor->setBox(new ObjectBox(entries[curentry],"exit.bmp",area.x,area.y,"Name: ",next_name));
+ } else if (entries[curentry]=="Teleporter") {
+ editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Teleport Destination (x coordinate): ","0","Teleport Destination (y coordinate): ","0","Name: ",next_name));
+ } else if (entries[curentry]=="Wind") {
+ editor->setBox(new ObjectBox(entries[curentry],"teleport_01.bmp",area.x,area.y,"Wind acceleration: ","0","Name: ",next_name));
+ } else if (entries[curentry]=="Geyser") {
+ editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Geyser force: ","0","Name: ",next_name));
+ } else if (entries[curentry]=="Trigger") {
+ editor->setBox(new ObjectBox(entries[curentry],"key.bmp",area.x,area.y,"Trigger target name: ","","Name: ",next_name,"Key name: ",""));
+ } else if (entries[curentry]=="Door") {
+ editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Key name: ","","Name: ",next_name));
+ } else if (entries[curentry]=="Spike") {
+ editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Direction (R=1,L=2,U=4,D=8): ","4","Name: ",next_name));
+ } else if (entries[curentry]=="Heart") {
+ editor->setBox(new ObjectBox(entries[curentry],"heart.bmp",area.x,area.y,"Name: ",next_name));
+ } else if (entries[curentry]=="Key") {
+ editor->setBox(new ObjectBox(entries[curentry],"key.bmp",area.x,area.y,"Name: ",next_name));
+ } else if (entries[curentry]=="Bomb") {
+ editor->setBox(new ObjectBox(entries[curentry],"bomb_fire.bmp",area.x,area.y,"Exploding time (in ms): ","0","Name: ",next_name));
+ } else if (entries[curentry]=="Erik") {
+ editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name));
+ } else if (entries[curentry]=="Olaf") {
+ editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name));
+ } else if (entries[curentry]=="Baleog") {
+ editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name));
+ } else if (entries[curentry]=="Fang") {
+ editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name));
+ } else if (entries[curentry]=="Scorch") {
+ editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name));
+ } else if (entries[curentry]=="Plant") {
+ editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Recovery time (in ms): ","0","Name: ",next_name));
+ } else if (entries[curentry]=="Zombie") {
+ editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name));
} else {
- editor->place_image="";
+ editor->run_action(EDIT_RESET_ACTIONS);
+ editor->closeBox();
}
- editor->action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_PLACE_OBJECT;
- editor->closeBox();
}
}
@@ -263,32 +318,127 @@
SDL_EnableUNICODE(1);
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
addGameMode(GAME_TEXT_INPUT);
+ editor->action_mouse_released[SDL_BUTTON_RIGHT]=NOTHING;
}
TextInputBox::~TextInputBox() {
SDL_EnableUNICODE(0);
SDL_EnableKeyRepeat(0,SDL_DEFAULT_REPEAT_INTERVAL);
removeGameMode(GAME_TEXT_INPUT);
- editor->run_action(EDIT_RESET_ACTIONS);
+ editor->action_mouse_released[SDL_BUTTON_RIGHT]=EDIT_BOX;
}
-
void TextInputBox::act(Sint8 button) {
- if (button>=0 && (Uint8)button<entries.size()) currententry=button;
+ if (button>=0 && (Uint8)button<einput.size()) currententry=button;
}
void TextInputBox::input(Uint16 akey) {
- if (currententry==-1) {
+ if (currententry==-1 || currententry>=(int)einput.size()) {
} else if (akey==(Uint16)config.keybind[KEY_ACT]) {
- editor->closeBox();
+ evaluateEntry();
// Backspace
} else if (akey==8) {
- if ( entries[currententry].begin() != entries[currententry].end() ) {
- entries[currententry].erase(entries[currententry].end()-1);
+ if ( einput[currententry].begin() != einput[currententry].end() ) {
+ einput[currententry].erase(einput[currententry].end()-1);
gfxeng->update(UPDATE_ALL);
update();
}
} else if ((Uint16)akey<32 || (Uint16)akey>126) {
} else {
- entries[currententry]+=(char)akey;
+ einput[currententry]+=(char)akey;
gfxeng->update(UPDATE_ALL);
update();
}
}
+void TextInputBox::evaluateEntry() {
+ editor->closeBox();
+}
+void TextInputBox::update() {
+ Uint8 maxs=max(entries.size(),max(einput.size(),etitles.size()));
+ Uint16 maxw=0;
+ string spaces="";
+ if (entries.size()<maxs) entries.resize(maxs);
+ if (etitles.size()<maxs) etitles.resize(maxs);
+ for (Uint8 i=0;i<einput.size(); i++) {
+ maxw=max(maxw,(Uint16)font->getTextWidth(etitles[i]));
+ }
+ for (Uint8 i=0; i<einput.size(); i++) {
+ spaces="";
+ while (font->getTextWidth(etitles[i]+spaces)<maxw) spaces+=" ";
+ spaces+=" ";
+ entries[i]=etitles[i]+spaces+einput[i];
+ }
+ for (Uint8 i=einput.size(); i<maxs; i++) {
+ entries[i]=etitles[i];
+ }
+ Box::update();
+}
+
+SaveAsBox::SaveAsBox(Sint16 x, Sint16 y): TextInputBox(x,y) {
+ title="Save As...";
+ einput.push_back(editor->save_name);
+ currententry=0;
+ update();
+}
+
+void SaveAsBox::evaluateEntry() {
+ editor->save_name=einput[0];
+ editor->saveBuf(editor->save_name);
+ editor->closeBox();
+}
+
+OpenMapBox::OpenMapBox(Sint16 x, Sint16 y): TextInputBox(x,y) {
+ title="Open Map";
+ einput.push_back(scenario->name);
+ currententry=0;
+ update();
+}
+
+void OpenMapBox::evaluateEntry() {
+ scenario->loadMap(einput[0]);
+ editor->closeBox();
+}
+
+NewMapBox::NewMapBox(Sint16 x, Sint16 y): TextInputBox(x,y) {
+ title="New Map";
+ centered=false;
+ etitles.push_back("Map file: "); einput.push_back("newmap.cfg");
+ etitles.push_back("Background image: "); einput.push_back(scenario->bgimage);
+ currententry=0;
+ update();
+}
+
+void NewMapBox::evaluateEntry() {
+ scenario->name=einput[0];
+ scenario->newMap(einput[1]);
+ scenario->reloadMap();
+ editor->closeBox();
+}
+
+ObjectBox::ObjectBox(string name, string image, Sint16 x, Sint16 y, string targ1, string arg1, string targ2, string arg2, string targ3, string arg3): TextInputBox(x,y),
+ objname(name) {
+ title=name+" Properties";
+ centered=false;
+ currententry=0;
+ etitles.push_back("Image name: "); einput.push_back(image);
+ if (targ1!="" || arg1!="") {
+ etitles.push_back(targ1);
+ einput.push_back(arg1);
+ }
+ if (targ2!="" || arg2!="") {
+ etitles.push_back(targ2);
+ einput.push_back(arg2);
+ }
+ if (targ3!="" || arg3!="") {
+ etitles.push_back(targ3);
+ einput.push_back(arg3);
+ }
+ update();
+}
+
+void ObjectBox::evaluateEntry() {
+ editor->place_name=objname;
+ editor->place_image=einput[0];
+ if (einput.size()>=2) editor->place_arg1=einput[1];
+ if (einput.size()>=3) editor->place_arg2=einput[2];
+ if (einput.size()>=4) editor->place_arg3=einput[3];
+ editor->action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_PLACE_OBJECT;
+ editor->closeBox();
+}
Modified: trunk/src/editor.h
===================================================================
--- trunk/src/editor.h 2005-09-01 00:01:51 UTC (rev 130)
+++ trunk/src/editor.h 2005-09-01 13:23:04 UTC (rev 131)
@@ -39,7 +39,9 @@
/// Area occupied by the selection box
SDL_Rect area;
/// Draw the box surface
- void update();
+ virtual void update();
+ /// True if the entries should be draw centered
+ bool centered;
};
class EditBox : public Box {
@@ -48,22 +50,60 @@
virtual void act(Sint8);
};
+class PlaceBox : public Box {
+ public:
+ PlaceBox(Sint16,Sint16);
+ virtual void act(Sint8);
+};
+
class TextInputBox : public Box {
public:
TextInputBox(Sint16,Sint16);
virtual ~TextInputBox();
virtual void act(Sint8);
virtual void input(Uint16);
+ virtual void evaluateEntry();
protected:
Sint8 currententry;
+ std::vector<string> etitles;
+ std::vector<string> einput;
+ virtual void update();
};
+class ObjectBox : public TextInputBox {
+ public:
+ ObjectBox(string,string,Sint16,Sint16,string targ1="",string arg1="",string targ2="",string arg2="",string targ3="",string arg3="");
+ protected:
+ virtual void evaluateEntry();
+ string objname;
+};
+class SaveAsBox : public TextInputBox {
+ public:
+ SaveAsBox(Sint16,Sint16);
+ protected:
+ virtual void evaluateEntry();
+};
+
+class OpenMapBox : public TextInputBox {
+ public:
+ OpenMapBox(Sint16,Sint16);
+ protected:
+ virtual void evaluateEntry();
+};
+
+class NewMapBox : public TextInputBox {
+ public:
+ NewMapBox(Sint16,Sint16);
+ protected:
+ virtual void evaluateEntry();
+};
+
+
/** \brief Handels editor specific tasks
*/
class Editor {
- friend class EditBox;
public:
Editor();
~Editor();
@@ -85,17 +125,18 @@
else return false;
}
Box* box;
- protected:
/// Name the saved map file
string save_name;
/// Object to place when clicking the left mouse button
string place_name;
/// Image name of the placed object
string place_image;
- /// Action type for the mouse buttons when clicking
- Uint32 action_mouse_pressed[6];
- /// Action type for the mouse buttons when releasing the button
- Uint32 action_mouse_released[6];
+ /// First additonal parameter of the placed object
+ string place_arg1;
+ /// Seconds additional parameter of the placed object
+ string place_arg2;
+ /// Third additional parameter of the placed object
+ string place_arg3;
/// Append a command to the buffered map file
void appendtoBuf(string);
/* TODO: add header modifiers */
@@ -103,6 +144,10 @@
string removefromBuf(string);
/// Save the map file buffer to the specified file if possible
int saveBuf(string);
+ /// Action type for the mouse buttons when clicking
+ Uint32 action_mouse_pressed[6];
+ /// Action type for the mouse buttons when releasing the button
+ Uint32 action_mouse_released[6];
};
#endif
Modified: trunk/src/gfxeng.cpp
===================================================================
--- trunk/src/gfxeng.cpp 2005-09-01 00:01:51 UTC (rev 130)
+++ trunk/src/gfxeng.cpp 2005-09-01 13:23:04 UTC (rev 131)
@@ -59,8 +59,11 @@
}
//Paused game
} else if (game_mode&GAME_PAUSED) {
- if (updatetype==UPDATE_ALL || updatetype==UPDATE_BAR) {
+ if (updatetype==UPDATE_ALL) {
+ drawScene();
drawPlayerBar();
+ } else if (updatetype==UPDATE_BAR) {
+ drawPlayerBar();
}
//Not paused running game
} else if (game_mode&GAME_PLAY) {
Modified: trunk/src/objectpools.cpp
===================================================================
--- trunk/src/objectpools.cpp 2005-09-01 00:01:51 UTC (rev 130)
+++ trunk/src/objectpools.cpp 2005-09-01 13:23:04 UTC (rev 131)
@@ -38,11 +38,11 @@
while (i!=objectspool.end()) i=removeObject(i);
}
-Object* ObjectsPool::addObjectbyName(const string& obj, const string& image, Sint16 x, Sint16 y, const string& arg1, const string& arg2, const string& arg3) {
- x-=gfxeng->getShift().x;
- y-=gfxeng->getShift().y;
+Object* ObjectsPool::addObjectbyName(const string& obj, const string& image, Sint16 x, Sint16 y, string& arg1, string& arg2, const string& arg3) {
//Set names...
- string name=obj;
+ if (arg1.empty()) arg1="0";
+ if (arg2.empty()) arg2="0";
+ string name=getNextObjectName(obj);
if (arg1!="0") {
//one additional parameter
if (name=="Trigger" || name=="Door" || name=="Bomb" || name=="TriggeredBomb" || name=="Plant" || name=="Geyser" || name=="Wind" || name=="Spike") {
Modified: trunk/src/objectpools.h
===================================================================
--- trunk/src/objectpools.h 2005-09-01 00:01:51 UTC (rev 130)
+++ trunk/src/objectpools.h 2005-09-01 13:23:04 UTC (rev 131)
@@ -30,7 +30,7 @@
/// \param arg3 Third argument as string
/// \return Pointer to the new entry in the objectspool or NULL if
/// the object was not recognized
- Object* addObjectbyName(const string& obj, const string& image, Sint16 x=0, Sint16 y=0, const string& arg1="0", const string& arg2="0", const string& arg3="0");
+ Object* addObjectbyName(const string& obj, const string& image, Sint16 x=0, Sint16 y=0, string& arg1="", string& arg2="", const string& arg3="");
//@{
/// Add an Object to the objectspool
/// \return Pointer to the new entry in the objectspool or NULL if it failed
Modified: trunk/src/players_common.cpp
===================================================================
--- trunk/src/players_common.cpp 2005-09-01 00:01:51 UTC (rev 130)
+++ trunk/src/players_common.cpp 2005-09-01 13:23:04 UTC (rev 131)
@@ -8,6 +8,8 @@
#include "sndcache.h"
#include "objectpools.h"
#include "scenario.h"
+//to allow gfxeng->update()
+#include "gfxeng.h"
#include "players_common.h"
@@ -97,12 +99,14 @@
}
void Player::removeItem(Uint8 num) {
+ gfxeng->update(UPDATE_BAR);
if (num>=MAX_ITEMS || items[num]==NULL) return;
delete items[num];
items[num]=NULL;
}
Item* Player::moveItem(Uint8 num) {
+ gfxeng->update(UPDATE_BAR);
if (num>=MAX_ITEMS || items[num]==NULL) return NULL;
Item* tmpit=items[num];
items[num]=NULL;
@@ -110,6 +114,7 @@
}
void Player::switchItem(bool right) {
+ gfxeng->update(UPDATE_BAR);
if (right) {
++currentitem;
if (currentitem>=MAX_ITEMS) currentitem=0;
@@ -120,6 +125,7 @@
}
Object* Player::dropItem(Uint8 num) {
+ gfxeng->update(UPDATE_ALL);
Item* tmpit=moveItem(num);
Object* tmpobj=NULL;
bool ok=false;
Modified: trunk/src/scenario.cpp
===================================================================
--- trunk/src/scenario.cpp 2005-09-01 00:01:51 UTC (rev 130)
+++ trunk/src/scenario.cpp 2005-09-01 13:23:04 UTC (rev 131)
@@ -13,7 +13,8 @@
area(NULL),
player(NULL),
failed(false),
- name("") {
+ name(""),
+ bgimage("") {
cout << "Scenario: ImageCache...\n";
imgcache=new ImageCache();
cout << "Scenario: SoundCache...\n";
@@ -51,6 +52,10 @@
player=NULL;
}
+void Scenario::newMap(string bgimage) {
+ mapbuf.clear();
+ mapbuf.push_back("Background "+bgimage);
+}
int Scenario::loadMapBuf(string mapname) {
name=mapname;
ifstream mapfile;
@@ -117,7 +122,10 @@
if (cname=="Background" && (!background)) {
background=new Background(image);
- if (background) area=background->getPos();
+ if (background) {
+ area=background->getPos();
+ bgimage=image;
+ }
//Background has to be first!
} else if (background) {
pool->addObjectbyName(cname,image,x,y,arg1,arg2,arg3);
Modified: trunk/src/scenario.h
===================================================================
--- trunk/src/scenario.h 2005-09-01 00:01:51 UTC (rev 130)
+++ trunk/src/scenario.h 2005-09-01 13:23:04 UTC (rev 131)
@@ -61,6 +61,8 @@
ObjectsPool* pool;
/// Physic Handler
PhysicHandler* physic;
+ /// Create a new empty map with the specified background
+ void newMap(string bgname);
/// Used to load the map file into a buffer
int loadMapBuf(string mapname);
/// Reload the map file using the buffered map file
@@ -75,6 +77,8 @@
bool failed;
/// Name of the map file
string name;
+ /// Name of the map background image
+ string bgimage;
std::vector<string> mapbuf;
private:
inline void reinitMap();
More information about the lostpenguins-commits
mailing list