r125 - trunk/src
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Wed Aug 31 05:42:45 EDT 2005
Author: jonas
Date: 2005-08-31 05:42:45 -0400 (Wed, 31 Aug 2005)
New Revision: 125
Added:
trunk/src/editor.cpp
trunk/src/editor.h
Modified:
trunk/src/Makefile
trunk/src/common.cpp
trunk/src/common.h
trunk/src/gfxeng.cpp
trunk/src/input.cpp
trunk/src/lost_penguins.cpp
trunk/src/menu.cpp
trunk/src/menu.h
trunk/src/objectpools.cpp
trunk/src/objectpools.h
Log:
added an Editor class, improved map editor (prelimenary object placements)
Modified: trunk/src/Makefile
===================================================================
--- trunk/src/Makefile 2005-08-30 16:48:53 UTC (rev 124)
+++ trunk/src/Makefile 2005-08-31 09:42:45 UTC (rev 125)
@@ -9,7 +9,7 @@
OBJS = common.o gfxeng.o input.o font.o lost_penguins.o scenario.o\
objects_common.o sfxeng.o players_common.o monsters_common.o\
characters_common.o objectpools.o weapons.o events.o imgcache.o\
- sndcache.o physics.o animation.o menu.o SDL_rotozoom.o
+ sndcache.o physics.o animation.o menu.o editor.o SDL_rotozoom.o
PLUGS = objects.a
BIN = ../lost_penguins
Modified: trunk/src/common.cpp
===================================================================
--- trunk/src/common.cpp 2005-08-30 16:48:53 UTC (rev 124)
+++ trunk/src/common.cpp 2005-08-31 09:42:45 UTC (rev 125)
@@ -13,6 +13,7 @@
Uint8 game_mode=NOTHING;
Menu* menu=NULL;
Box* box=NULL;
+Editor* editor=NULL;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const Uint32 rmask=0xff000000;
const Uint32 gmask=0x00ff0000;
Modified: trunk/src/common.h
===================================================================
--- trunk/src/common.h 2005-08-30 16:48:53 UTC (rev 124)
+++ trunk/src/common.h 2005-08-31 09:42:45 UTC (rev 125)
@@ -42,6 +42,7 @@
class Animation;
class Menu;
class Box;
+class Editor;
typedef std::set<Object *>::iterator object_iterator;
typedef std::set<Character *>::iterator character_iterator;
@@ -49,23 +50,23 @@
typedef std::set<Monster *>::iterator monster_iterator;
//General definitions
-#define NOTHING 0x00000000
-#define ALL 0xFFFFFFFF
-#define DIR_RIGHT 0x00000001
-#define DIR_LEFT 0x00000002
-#define DIR_UP 0x00000004
-#define DIR_DOWN 0x00000008
-#define DIR_ALL 0x0000000F
-#define DIR_UPR 0x00000005
-#define DIR_UPL 0x00000006
-#define DIR_DWR 0x00000009
-#define DIR_DWL 0x0000000A
-#define DIR_LR 0x00000003
+#define NOTHING 0x00000000
+#define ALL 0xFFFFFFFF
+#define DIR_RIGHT 0x00000001
+#define DIR_LEFT 0x00000002
+#define DIR_UP 0x00000004
+#define DIR_DOWN 0x00000008
+#define DIR_ALL 0x0000000F
+#define DIR_UPR 0x00000005
+#define DIR_UPL 0x00000006
+#define DIR_DWR 0x00000009
+#define DIR_DWL 0x0000000A
+#define DIR_LR 0x00000003
-#define GAME_PAUSED 0x00000001
-#define GAME_PLAY 0x00000002
-#define GAME_EDIT 0x00000004
-#define GAME_MENU 0x00000008
+#define GAME_PAUSED 0x00000001
+#define GAME_PLAY 0x00000002
+#define GAME_EDIT 0x00000004
+#define GAME_MENU 0x00000008
enum ConfigKey {
KEY_START,
@@ -148,10 +149,6 @@
Menu* closeMenu();
/// Close all menus (menu=NULL)
void closeMenus();
-/// Set the current box
-Box* setBox(Box* newbox);
-/// Close the current box
-void closeBox();
//@}
//global variables
@@ -183,8 +180,8 @@
extern Uint8 game_mode;
/// Currently used menu, NULL if not inside a menu
extern Menu* menu;
-/// Currently used box, NULL if there is no box
-extern Box* box;
+/// Editor
+extern Editor* editor;
//@}
#endif
Added: trunk/src/editor.cpp
===================================================================
--- trunk/src/editor.cpp 2005-08-30 16:48:53 UTC (rev 124)
+++ trunk/src/editor.cpp 2005-08-31 09:42:45 UTC (rev 125)
@@ -0,0 +1,212 @@
+#include "common.h"
+#include "scenario.h"
+#include "objectpools.h"
+#include "menu.h"
+#include "font.h"
+#include "editor.h"
+
+
+Editor::Editor() {
+ run_action(EDIT_RESET_ACTIONS);
+ string place_name="";
+}
+
+Editor::~Editor() {
+ closeBox();
+}
+
+void Editor::run_action(Uint32 action, Uint16 x, Uint16 y) {
+ if (action==EDIT_RESET_ACTIONS) {
+ for (Uint8 i=0; i<6; i++) {
+ action_mouse_pressed[i]=NOTHING;
+ action_mouse_released[i]=NOTHING;
+ }
+ action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_ACT_BOX;
+ action_mouse_pressed[SDL_BUTTON_RIGHT]=EDIT_BOX;
+ action_mouse_released[SDL_BUTTON_RIGHT]=EDIT_ACT_BOX;
+ } else if (action==EDIT_BOX) {
+ setBox(new EditBox(x,y));
+ } else if (action==EDIT_ACT_BOX) {
+ if (box) box->act(box->getCurrentEntry(x,y));
+ } else if (action==EDIT_PLACE_OBJECT) {
+ scenario->pool->addObjectbyName(place_name,place_image,x,y,scenario->pool->getNextObjectName(place_name));
+ action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_ACT_BOX;
+ } else { }
+}
+
+Box* Editor::setBox(Box* newbox) {
+ return box=newbox;
+}
+
+void Editor::closeBox() {
+ if (box) delete box;
+ box=NULL;
+}
+
+Box::Box(Sint16 x, Sint16 y):
+ title("MENU"),
+ surface(NULL),
+ //don't forget the "::"
+ font(::font),
+ font_title(font),
+ font_high(font2) {
+ area.x=x;
+ area.y=y;
+}
+Box::~Box() {
+}
+
+void Box::act(Sint8) {
+ editor->closeBox();
+}
+
+const SDL_Rect& Box::getArea() {
+ Uint16 tmp=0;
+ Uint16 maxwidth=font_title->getTextWidth(title);
+ for (Uint8 i=0; i<entries.size(); i++) {
+ tmp=max(font->getTextWidth(entries[i]),font_high->getTextWidth(entries[i]));
+ maxwidth=max(maxwidth,tmp);
+ }
+ area.w=maxwidth+2*WFONT;
+ area.h=entries.size()*(DFONT+font->getHeight())+2*WFONT+font_title->getHeight();
+ return area;
+}
+
+Sint8 Box::getCurrentEntry(Sint16 x, Sint16 y) {
+ getArea();
+ if (
+ (x>=(area.x+area.w)) ||
+ (x<=area.x) ||
+ (y>=(area.y+area.h)) ||
+ (y<=(area.y+WFONT+font_title->getHeight()+(int)(DFONT/2)))) {
+ return -1;
+ }
+ Sint16 tmp=y-area.y-WFONT-font_title->getHeight()-(int)(DFONT/2);
+ Uint16 entrysize=DFONT+font->getHeight();
+ Uint8 currententry=0;
+ while (tmp>entrysize) {
+ tmp-=entrysize;
+ ++currententry;
+ }
+ return currententry;
+}
+
+void Box::update() {
+ if (surface==NULL) {
+ getArea();
+ SDL_Surface* tmp=SDL_CreateRGBSurface(vflags, area.w, area.h, 32, rmask, gmask, bmask, amask);
+ surface=SDL_DisplayFormatAlpha(tmp);
+ SDL_FreeSurface(tmp);
+ SDL_FillRect(surface,0,SDL_MapRGBA(surface->format,200,200,200,180));
+
+ /* create a border */
+ Sint16 tmph=0;
+ SDL_Rect line;
+ line.x=0;
+ line.y=0;
+ line.w=BORDERSIZE;
+ line.h=area.h;
+ SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,255));
+ line.x=area.w-BORDERSIZE;
+ SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,255));
+ line.x=0;
+ line.y=0;
+ line.w=area.w;
+ line.h=BORDERSIZE;
+ SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,255));
+ line.y=area.h-BORDERSIZE;
+ SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,255));
+
+ /* write title */
+ font_title->writeCenter(surface,title,WFONT);
+ line.y=font_title->getHeight()+(int)((DFONT-line.h)/2);
+ SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,255));
+ line.h=LINESIZE;
+
+ /* 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);
+ 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="PLACE";
+ entries.push_back("Wall");
+ entries.push_back("Exit");
+ entries.push_back("Water");
+ entries.push_back("Teleporter");
+ entries.push_back("Wind");
+ entries.push_back("Geyser");
+ entries.push_back("Trigger");
+ entries.push_back("Door");
+ entries.push_back("Spike");
+
+ entries.push_back("Heart");
+ entries.push_back("Key");
+ entries.push_back("Bomb");
+
+ entries.push_back("Erik");
+ entries.push_back("Olaf");
+ entries.push_back("Baleog");
+ entries.push_back("Fang");
+ entries.push_back("Scorch");
+
+ entries.push_back("Plant");
+ entries.push_back("Zombie");
+
+ update();
+}
+
+void EditBox::act(Sint8 curentry) {
+ 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=="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";
+ } else {
+ editor->place_image="";
+ }
+ editor->action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_PLACE_OBJECT;
+ editor->action_mouse_released[SDL_BUTTON_LEFT]=EDIT_RESET_ACTIONS;
+ editor->closeBox();
+ }
+}
Added: trunk/src/editor.h
===================================================================
--- trunk/src/editor.h 2005-08-30 16:48:53 UTC (rev 124)
+++ trunk/src/editor.h 2005-08-31 09:42:45 UTC (rev 125)
@@ -0,0 +1,86 @@
+#ifndef DEF_EDITOR_H
+#define DEF_EDITOR_H 1
+
+#define EDIT_RESET_ACTIONS 0x00000001
+#define EDIT_BOX 0x00000004
+#define EDIT_ACT_BOX 0x00000008
+#define EDIT_PLACE_OBJECT 0x00000010
+
+/** \brief abstract selection box base class
+
+*/
+class Box {
+ friend class Editor;
+ friend class GraphicsEngine;
+ public:
+ Box(Sint16,Sint16);
+ virtual ~Box();
+ /// Name of the menu
+ string title;
+ /// Main menu function, depends on currententry (changed by input), overload this.
+ virtual void act(Sint8) = 0;
+ Uint8 getSize() {
+ return entries.size();
+ }
+ const SDL_Rect& getArea();
+ Sint8 getCurrentEntry(Sint16,Sint16);
+ protected:
+ /// Menu surface to be drawn
+ SDL_Surface* surface;
+ /// List of all Box entry names
+ std::vector<string> entries;
+ /// Font for non highlighted menu entries
+ Font* font;
+ /// Font for the menu title
+ Font* font_title;
+ /// Font for the selected menu entry
+ Font* font_high;
+ /// Area occupied by the selection box
+ SDL_Rect area;
+ /// Draw the box surface
+ void update();
+};
+
+class EditBox : public Box {
+ public:
+ EditBox(Sint16,Sint16);
+ virtual void act(Sint8);
+};
+
+/** \brief Handels editor specific tasks
+
+*/
+class Editor {
+ friend class EditBox;
+ public:
+ Editor();
+ ~Editor();
+ void run_action(Uint32 action, Uint16 x=0, Uint16 y=0);
+ Uint32 getActionMPressed(Uint8 button) {
+ if (button>=1 && button <6) return action_mouse_pressed[button];
+ else return NOTHING;
+ }
+ Uint32 getActionMReleased(Uint8 button) {
+ if (button>=1 && button <6) return action_mouse_released[button];
+ else return NOTHING;
+ }
+ /// Set the current box
+ Box* setBox(Box* newbox);
+ /// Close the current box
+ void closeBox();
+ bool hasBox() {
+ if (box && box->surface) return true;
+ else return false;
+ }
+ Box* box;
+ protected:
+ /// 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];
+ Uint32 action_mouse_released[6];
+};
+
+#endif
Modified: trunk/src/gfxeng.cpp
===================================================================
--- trunk/src/gfxeng.cpp 2005-08-30 16:48:53 UTC (rev 124)
+++ trunk/src/gfxeng.cpp 2005-08-31 09:42:45 UTC (rev 125)
@@ -6,6 +6,7 @@
#include "imgcache.h"
#include "scenario.h"
#include "menu.h"
+#include "editor.h"
//Only needed for fps
#include "scenario.h"
#include "physics.h"
@@ -327,10 +328,10 @@
}
void GraphicsEngine::drawBox() {
- if (box && box->surface) {
+ if (editor->hasBox()) {
SDL_Rect tmprect;
- tmprect=box->area;
- SDL_BlitSurface(box->surface,0,screen,&tmprect);
+ tmprect=editor->box->area;
+ SDL_BlitSurface(editor->box->surface,0,screen,&tmprect);
}
}
Modified: trunk/src/input.cpp
===================================================================
--- trunk/src/input.cpp 2005-08-30 16:48:53 UTC (rev 124)
+++ trunk/src/input.cpp 2005-08-31 09:42:45 UTC (rev 125)
@@ -9,8 +9,8 @@
#include "menu.h"
#include "physics.h"
#include "objects_common.h"
+#include "editor.h"
-
InputHandler::InputHandler() {
au_pause=sndcache->loadWAV("pause.wav");
SDL_PumpEvents();
@@ -193,40 +193,11 @@
quitGame(0);
}
case SDL_MOUSEBUTTONUP: {
- switch (event.button.button) {
- case SDL_BUTTON_LEFT: {
- break;
- }
- case SDL_BUTTON_RIGHT: {
- if (box) box->act(box->getCurrentEntry(event.button.x,event.button.y));
- break;
- }
- case SDL_BUTTON_MIDDLE: {
- break;
- }
- default: {
- break;
- }
- }
+ editor->run_action(editor->getActionMReleased(event.button.button),event.button.x,event.button.y);
break;
}
case SDL_MOUSEBUTTONDOWN: {
- switch (event.button.button) {
- case SDL_BUTTON_LEFT: {
- if (box) box->act(box->getCurrentEntry(event.button.x,event.button.y));
- break;
- }
- case SDL_BUTTON_RIGHT: {
- setBox(new EditBox(event.button.x,event.button.y));
- break;
- }
- case SDL_BUTTON_MIDDLE: {
- break;
- }
- default: {
- break;
- }
- }
+ editor->run_action(editor->getActionMPressed(event.button.button),event.button.x,event.button.y);
break;
}
case SDL_KEYDOWN: {
Modified: trunk/src/lost_penguins.cpp
===================================================================
--- trunk/src/lost_penguins.cpp 2005-08-30 16:48:53 UTC (rev 124)
+++ trunk/src/lost_penguins.cpp 2005-08-31 09:42:45 UTC (rev 125)
@@ -10,6 +10,7 @@
#include "sfxeng.h"
#include "objectpools.h"
#include "menu.h"
+#include "editor.h"
#include "players_common.h"
@@ -64,7 +65,6 @@
int quitGame(int errorcode=0) {
cout << endl << "Quitting game (exit code: " << errorcode << ")...\n";
- closeBox();
closeMenus();
delete scenario;
cout << "Scenario closed...\n";
@@ -77,8 +77,11 @@
delete sndcache;
cout << "Deleting ImageCache...\n";
delete imgcache;
+ if (editor) {
+ cout << "Deleting Editor...\n";
+ delete editor;
+ }
cout << "Quiting SDL...\n";
-
SDL_Quit();
exit(errorcode);
}
Modified: trunk/src/menu.cpp
===================================================================
--- trunk/src/menu.cpp 2005-08-30 16:48:53 UTC (rev 124)
+++ trunk/src/menu.cpp 2005-08-31 09:42:45 UTC (rev 125)
@@ -5,6 +5,7 @@
#include "sfxeng.h"
#include "font.h"
#include "menu.h"
+#include "editor.h"
Menu* setMenu(Menu* newmenu) {
if (menu) gfxeng->update(UPDATE_MENU);
@@ -76,8 +77,9 @@
//Add a proper Map creation menu, etc..., FIXME
if ((config.map!="") && (scenario->loadMap(config.map)==0)) {
closeMenu();
+ cout << "Starting editor...\n" << endl;
game_mode|=GAME_EDIT;
- cout << "Starting game...\n" << endl;
+ if (!editor) editor=new Editor();
} else {
cout << "Select a valid map first...\n" << endl;
}
@@ -284,122 +286,3 @@
}
*/
}
-
-Box* setBox(Box* newbox) {
- gfxeng->update(UPDATE_ALL);
- return box=newbox;
-}
-
-void closeBox() {
- if (box) delete box;
- box=NULL;
- gfxeng->update(UPDATE_ALL);
-}
-
-Box::Box(Sint16 x, Sint16 y):
- title("MENU"),
- //don't forget the "::"
- font(::font),
- font_title(font),
- font_high(font2),
- surface(NULL) {
- area.x=x;
- area.y=y;
-}
-Box::~Box() {
-}
-
-void Box::act(Sint8) {
- closeBox();
-}
-
-const SDL_Rect& Box::getArea() {
- Uint16 tmp=0;
- Uint16 maxwidth=font_title->getTextWidth(title);
- for (Uint8 i=0; i<entries.size(); i++) {
- tmp=max(font->getTextWidth(entries[i]),font_high->getTextWidth(entries[i]));
- maxwidth=max(maxwidth,tmp);
- }
- area.w=maxwidth+2*WFONT;
- area.h=entries.size()*(DFONT+font->getHeight())+2*WFONT+font_title->getHeight();
- return area;
-}
-
-Sint8 Box::getCurrentEntry(Sint16 x, Sint16 y) {
- getArea();
- if (
- (x>=(area.x+area.w)) ||
- (x<=area.x) ||
- (y>=(area.y+area.h)) ||
- (y<=(area.y+WFONT+font_title->getHeight()+(int)(DFONT/2)))) {
- return -1;
- }
- Sint16 tmp=y-area.y-WFONT-font_title->getHeight()-(int)(DFONT/2);
- Uint16 entrysize=DFONT+font->getHeight();
- Uint8 currententry=0;
- while (tmp>entrysize) {
- tmp-=entrysize;
- ++currententry;
- }
- return currententry;
-}
-
-void Box::update() {
- if (surface==NULL) {
- getArea();
- SDL_Surface* tmp=SDL_CreateRGBSurface(vflags, area.w, area.h, 32, rmask, gmask, bmask, amask);
- surface=SDL_DisplayFormatAlpha(tmp);
- SDL_FreeSurface(tmp);
- SDL_FillRect(surface,0,SDL_MapRGBA(surface->format,200,200,200,180));
-
- /* create a border */
- Sint16 tmph=0;
- SDL_Rect line;
- line.x=0;
- line.y=0;
- line.w=BORDERSIZE;
- line.h=area.h;
- SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,255));
- line.x=area.w-BORDERSIZE;
- SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,255));
- line.x=0;
- line.y=0;
- line.w=area.w;
- line.h=BORDERSIZE;
- SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,255));
- line.y=area.h-BORDERSIZE;
- SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,255));
-
- /* write title */
- font_title->writeCenter(surface,title,WFONT);
- line.y=font_title->getHeight()+(int)((DFONT-line.h)/2);
- SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,255));
- line.h=LINESIZE;
-
- /* 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);
- 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="PLACE";
- entries.resize(4);
- entries[0]="Olaf";
- entries[1]="Water";
- entries[2]="Zombie";
- entries[3]="Exit";
- update();
-}
-
-void EditBox::act(Sint8 curentry) {
- if (curentry==1) {
- setBox(new EditBox(area.x+10,area.y+10));
- } else {
- closeBox();
- }
-}
Modified: trunk/src/menu.h
===================================================================
--- trunk/src/menu.h 2005-08-30 16:48:53 UTC (rev 124)
+++ trunk/src/menu.h 2005-08-31 09:42:45 UTC (rev 125)
@@ -110,46 +110,4 @@
void update();
};
-
-/** \brief abstract selection box base class
-
-*/
-class Box {
- friend class GraphicsEngine;
- friend class InputHandler;
- public:
- Box(Sint16,Sint16);
- virtual ~Box();
- /// Name of the menu
- string title;
- /// Main menu function, depends on currententry (changed by input), overload this.
- virtual void act(Sint8) = 0;
- Uint8 getSize() {
- return entries.size();
- }
- const SDL_Rect& getArea();
- Sint8 getCurrentEntry(Sint16,Sint16);
- protected:
- /// List of all Box entry names
- std::vector<string> entries;
- /// Font for non highlighted menu entries
- Font* font;
- /// Font for the menu title
- Font* font_title;
- /// Font for the selected menu entry
- Font* font_high;
- /// Area occupied by the selection box
- SDL_Rect area;
- /// Menu surface to be drawn
- SDL_Surface* surface;
- /// Draw the box surface
- void update();
-};
-
-class EditBox : public Box {
- public:
- EditBox(Sint16,Sint16);
- virtual void act(Sint8);
-};
-
#endif
Modified: trunk/src/objectpools.cpp
===================================================================
--- trunk/src/objectpools.cpp 2005-08-30 16:48:53 UTC (rev 124)
+++ trunk/src/objectpools.cpp 2005-08-31 09:42:45 UTC (rev 125)
@@ -110,6 +110,14 @@
}
}
+string ObjectsPool::getNextObjectName(const string& basename) {
+ int objnum=1;
+ while(getObject(basename+itos(objnum))) {
+ objnum++;
+ }
+ return basename+itos(objnum);
+}
+
//yeah, a pyramide... ;) serious, this is _NOT_ good
//hmm, but it can be used as a bad example on how "_not_ to do things"... ;-)
///\todo Fix this mess
Modified: trunk/src/objectpools.h
===================================================================
--- trunk/src/objectpools.h 2005-08-30 16:48:53 UTC (rev 124)
+++ trunk/src/objectpools.h 2005-08-31 09:42:45 UTC (rev 125)
@@ -49,6 +49,8 @@
/// \pre The name must be unique (otherwise it's basically random)
/// \return Pointer to the Object or NULL if it wasn't found
Object* getObject(const string& oname);
+ /// Helper function to return the next available object name corresponding to the given base name
+ string getNextObjectName(const string& basename);
//@{
/// Remove an Object (using an object_iterator) from all pools it belongs to
/// \return object_iterator to the next entry in the pool or the end()
More information about the lostpenguins-commits
mailing list