[4597] | 1 | /*! |
---|
[5039] | 2 | * @file story_entity.h |
---|
[6424] | 3 | * holds the base class of everything that is playable - that is part of the story |
---|
| 4 | */ |
---|
[2636] | 5 | |
---|
[3221] | 6 | |
---|
[3224] | 7 | #ifndef _STORY_ENTITY_H |
---|
| 8 | #define _STORY_ENTITY_H |
---|
[2636] | 9 | |
---|
[3608] | 10 | #include "base_object.h" |
---|
[2636] | 11 | #include "story_def.h" |
---|
[3608] | 12 | #include "error.h" |
---|
[2636] | 13 | |
---|
[6424] | 14 | |
---|
| 15 | typedef enum StoryEntityState |
---|
| 16 | { |
---|
| 17 | SE_STATE_RUN = 0, |
---|
| 18 | SE_STATE_STOP, |
---|
| 19 | SE_STATE_PAUSE, |
---|
| 20 | |
---|
| 21 | SE_STATE_NUM |
---|
| 22 | }; |
---|
| 23 | |
---|
| 24 | |
---|
[3221] | 25 | //! A class that represents something to play in orxonox. it is a container for worlds, movies, mission briefings, etc... |
---|
[7283] | 26 | class StoryEntity : virtual public BaseObject |
---|
| 27 | { |
---|
[9869] | 28 | ObjectListDeclaration(StoryEntity); |
---|
[2636] | 29 | |
---|
[7283] | 30 | public: |
---|
[2636] | 31 | StoryEntity (); |
---|
[3221] | 32 | virtual ~StoryEntity (); |
---|
[2636] | 33 | |
---|
[6512] | 34 | virtual void loadParams(const TiXmlElement* root); |
---|
[6424] | 35 | |
---|
| 36 | /* initialisation and loading */ |
---|
| 37 | /** initializes a Story Entity to the needed values */ |
---|
[8717] | 38 | virtual ErrorMessage init() { return ErrorMessage(); }; |
---|
[6424] | 39 | /** called to load the data into the StoryEntity*/ |
---|
[8717] | 40 | virtual ErrorMessage loadData() { return ErrorMessage(); }; |
---|
[6424] | 41 | /** function that unloads the data from the StoryEntity */ |
---|
[8717] | 42 | virtual ErrorMessage unloadData() { return ErrorMessage(); }; |
---|
[2636] | 43 | |
---|
[6424] | 44 | /* running, stopping and pausing */ |
---|
| 45 | /** starts the Entity. Starts the main cycle */ |
---|
| 46 | virtual bool start() = 0; |
---|
| 47 | /** Stops the entity. */ |
---|
| 48 | virtual bool stop() = 0; |
---|
| 49 | /** pauses the Entity, you can resume the game by calling the resume() function */ |
---|
| 50 | virtual bool pause() = 0; |
---|
| 51 | /** resumes a paused StoryEntity */ |
---|
| 52 | virtual bool resume() = 0; |
---|
| 53 | /** function that is been called when the StoryEntity is started via start() */ |
---|
| 54 | virtual void run() = 0; |
---|
[6153] | 55 | |
---|
[6424] | 56 | /* properties interface */ |
---|
| 57 | /** returns the state of this StoryEntity */ |
---|
| 58 | StoryEntityState getState(); |
---|
[2636] | 59 | |
---|
[6424] | 60 | /** sets the story id of the current entity, this enables it to be identified in a global context. @param storyID the story id */ |
---|
| 61 | inline void setStoryID(int storyID) { this->storyID = storyID; } |
---|
| 62 | /** sets the story id of the current entity, this enables it to be identified in a global context. @returns the story id */ |
---|
| 63 | inline int getStoryID() { return this->storyID; } |
---|
[6992] | 64 | |
---|
[7221] | 65 | void setLoadFile(const std::string& fileName); |
---|
[6992] | 66 | /** @returns the Filename this StoryEntity was loaded with */ |
---|
[7221] | 67 | const std::string& getLoadFile() const { return this->loadFile; } |
---|
[6992] | 68 | |
---|
[10319] | 69 | bool setNextStoryName(const std::string& nextStoryName); |
---|
[6992] | 70 | void setNextStoryID(int nextStoryID); |
---|
[6424] | 71 | /** gets the story id of the current entity @returns story id */ |
---|
[6992] | 72 | inline int getNextStoryID() const { return this->nextStoryID; } |
---|
[7221] | 73 | inline void setDescription(const std::string& description); |
---|
[6837] | 74 | /** @returns the description of this StoryEntity */ |
---|
[7221] | 75 | inline const std::string& getDescription() { return this->description; } |
---|
[6992] | 76 | |
---|
[6993] | 77 | void grabWorldInfo(); |
---|
[6839] | 78 | /** toggle the menu visibility: SimpleMenu specific */ |
---|
[6993] | 79 | inline void addToGameMenu(bool toggle) { this->bMenuEntry = toggle; } |
---|
[6839] | 80 | /** @returns true if the GameWorld should be contained in the SimpleMenu: SimpleMenu specific */ |
---|
| 81 | inline bool isContainedInMenu() { return this->bMenuEntry; } |
---|
[6841] | 82 | /** sets the menu item image of this StoryEntity @param name name */ |
---|
[7221] | 83 | inline void setMenuItemImage(const std::string& image); |
---|
[6841] | 84 | /** @returns the menu item image of this StoryEntity */ |
---|
[7221] | 85 | inline const std::string& getMenuItemImage() { return this->menuItemImage; } |
---|
| 86 | inline void setMenuScreenshoot(const std::string& image); |
---|
[6841] | 87 | /** @returns the menu screenshoot of this StoryEntity */ |
---|
[7221] | 88 | inline const std::string& getMenuScreenshoot() { return this->menuScreenshoot; } |
---|
[2636] | 89 | |
---|
[7283] | 90 | protected: |
---|
| 91 | bool bInit; //!< if the entity is initialized, this has to be true. |
---|
| 92 | bool bRunning; //!< is true if the entity is running |
---|
| 93 | bool bPaused; //!< is true if the entity is paused |
---|
[2636] | 94 | |
---|
[6424] | 95 | |
---|
[7283] | 96 | private: |
---|
| 97 | int storyID; //!< this is the number of this entity, identifying it in a list/tree... |
---|
| 98 | int nextStoryID; //!< if this entity has finished, this entity shall be called |
---|
| 99 | std::string loadFile; //!< The file from which this world is loaded |
---|
[6992] | 100 | |
---|
[7283] | 101 | std::string description; //!< the description of the StoryEntity |
---|
| 102 | std::string menuItemImage; //!< the item image of the StoryEntity |
---|
| 103 | std::string menuScreenshoot; //!< the screenshoot of the StoryEntity |
---|
| 104 | bool bMenuEntry; //!< If true, this GameWorld apears in the SimpleMenu: SimpleMenu specific |
---|
[2636] | 105 | }; |
---|
| 106 | |
---|
[3224] | 107 | #endif /* _STORY_ENTITY_H */ |
---|