| 1 | |
|---|
| 2 | |
|---|
| 3 | /* |
|---|
| 4 | orxonox - the future of 3D-vertical-scrollers |
|---|
| 5 | |
|---|
| 6 | Copyright (C) 2004 orx |
|---|
| 7 | |
|---|
| 8 | This program is free software; you can redistribute it and/or modify |
|---|
| 9 | it under the terms of the GNU General Public License as published by |
|---|
| 10 | the Free Software Foundation; either version 2, or (at your option) |
|---|
| 11 | any later version. |
|---|
| 12 | |
|---|
| 13 | ### File Specific: |
|---|
| 14 | main-programmer: Patrick Boenzli |
|---|
| 15 | co-programmer: |
|---|
| 16 | */ |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | #include "story_entity.h" |
|---|
| 23 | |
|---|
| 24 | #include "load_param.h" |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | using namespace std; |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | /** |
|---|
| 31 | * default constructor initializes all needed data |
|---|
| 32 | */ |
|---|
| 33 | StoryEntity::StoryEntity () |
|---|
| 34 | { |
|---|
| 35 | this->setClassID(CL_STORY_ENTITY, "StoryEntity"); |
|---|
| 36 | |
|---|
| 37 | this->isInit = false; |
|---|
| 38 | this->isPaused = false; |
|---|
| 39 | this->isRunning = false; |
|---|
| 40 | |
|---|
| 41 | this->storyID = -1; |
|---|
| 42 | this->description = NULL; |
|---|
| 43 | this->menuItemImage = NULL; |
|---|
| 44 | this->nextStoryID = WORLD_ID_GAMEEND; |
|---|
| 45 | this->bMenuEntry = false; |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | /** |
|---|
| 50 | * deconstructor |
|---|
| 51 | */ |
|---|
| 52 | StoryEntity::~StoryEntity () |
|---|
| 53 | {} |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | /** |
|---|
| 57 | * loads the Parameters of a Campaign |
|---|
| 58 | * @param root: The XML-element to load from |
|---|
| 59 | */ |
|---|
| 60 | void StoryEntity::loadParams(const TiXmlElement* root) |
|---|
| 61 | { |
|---|
| 62 | BaseObject::loadParams(root); |
|---|
| 63 | |
|---|
| 64 | LoadParam(root, "identifier", this, StoryEntity, setStoryID) |
|---|
| 65 | .describe("A Unique Identifier for this StoryEntity"); |
|---|
| 66 | |
|---|
| 67 | LoadParam(root, "nextid", this, StoryEntity, setNextStoryID) |
|---|
| 68 | .describe("Sets the ID of the next StoryEntity"); |
|---|
| 69 | |
|---|
| 70 | LoadParam(root, "description", this, StoryEntity, setDescription) |
|---|
| 71 | .describe("Sets the description of this StoryEntity"); |
|---|
| 72 | |
|---|
| 73 | LoadParam(root, "menu-entry", this, StoryEntity, addToGameMenu) |
|---|
| 74 | .describe("If this entry is 1, the world is contained in the SimpleGameMenu"); |
|---|
| 75 | |
|---|
| 76 | LoadParam(root, "menu-item-image", this, StoryEntity, setMenuItemImage) |
|---|
| 77 | .describe("If this entry is 1, the world is contained in the SimpleGameMenu"); |
|---|
| 78 | |
|---|
| 79 | LoadParam(root, "menu-screenshoot", this, StoryEntity, setMenuScreenshoot) |
|---|
| 80 | .describe("If this entry is 1, the world is contained in the SimpleGameMenu"); |
|---|
| 81 | |
|---|
| 82 | PRINTF(4)("Loaded StoryEntity specific stuff\n"); |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | /** |
|---|
| 87 | * sets the descroption of this StoryEntity |
|---|
| 88 | * @param name name |
|---|
| 89 | */ |
|---|
| 90 | void StoryEntity::setDescription(const char* description) |
|---|
| 91 | { |
|---|
| 92 | if (this->description) |
|---|
| 93 | delete[] this->description; |
|---|
| 94 | if (description!= NULL) |
|---|
| 95 | { |
|---|
| 96 | this->description= new char[strlen(description)+1]; |
|---|
| 97 | strcpy(this->description, description); |
|---|
| 98 | } |
|---|
| 99 | else this->description= NULL; |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | /** |
|---|
| 104 | * sets the menu item image of this StoryEntity |
|---|
| 105 | * @param name name |
|---|
| 106 | */ |
|---|
| 107 | void StoryEntity::setMenuItemImage(const char* image) |
|---|
| 108 | { |
|---|
| 109 | if (this->menuItemImage) |
|---|
| 110 | delete[] this->menuItemImage; |
|---|
| 111 | if (image != NULL) |
|---|
| 112 | { |
|---|
| 113 | this->menuItemImage = new char[strlen(image)+1]; |
|---|
| 114 | strcpy(this->menuItemImage, image); |
|---|
| 115 | } |
|---|
| 116 | else this->menuItemImage = NULL; |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | /** sets the menu screenshoot of this StoryEntity @param name name */ |
|---|
| 121 | void StoryEntity::setMenuScreenshoot(const char* image) |
|---|
| 122 | { |
|---|
| 123 | if (this->menuScreenshoot) |
|---|
| 124 | delete[] this->menuScreenshoot; |
|---|
| 125 | if (image != NULL) |
|---|
| 126 | { |
|---|
| 127 | this->menuScreenshoot = new char[strlen(image)+1]; |
|---|
| 128 | strcpy(this->menuScreenshoot, image); |
|---|
| 129 | } |
|---|
| 130 | else this->menuScreenshoot = NULL; |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | |
|---|