[2636] | 1 | |
---|
| 2 | |
---|
[4592] | 3 | /* |
---|
[2636] | 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 |
---|
[4592] | 15 | co-programmer: |
---|
[2636] | 16 | */ |
---|
| 17 | |
---|
| 18 | |
---|
[6424] | 19 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD |
---|
| 20 | |
---|
| 21 | |
---|
[2636] | 22 | #include "story_entity.h" |
---|
| 23 | |
---|
[6424] | 24 | #include "load_param.h" |
---|
[2636] | 25 | |
---|
[6424] | 26 | |
---|
[2636] | 27 | using namespace std; |
---|
| 28 | |
---|
| 29 | |
---|
[6424] | 30 | /** |
---|
| 31 | * default constructor initializes all needed data |
---|
| 32 | */ |
---|
[4592] | 33 | StoryEntity::StoryEntity () |
---|
| 34 | { |
---|
[4597] | 35 | this->setClassID(CL_STORY_ENTITY, "StoryEntity"); |
---|
[6424] | 36 | |
---|
[6153] | 37 | this->isInit = false; |
---|
| 38 | this->isPaused = false; |
---|
[6424] | 39 | this->isRunning = false; |
---|
| 40 | |
---|
| 41 | this->storyID = -1; |
---|
[6839] | 42 | this->description = NULL; |
---|
[6853] | 43 | this->menuItemImage = NULL; |
---|
[6878] | 44 | this->menuScreenshoot = NULL; |
---|
[6424] | 45 | this->nextStoryID = WORLD_ID_GAMEEND; |
---|
[6839] | 46 | this->bMenuEntry = false; |
---|
[4592] | 47 | } |
---|
[6153] | 48 | |
---|
[2636] | 49 | |
---|
[4592] | 50 | /** |
---|
[6424] | 51 | * deconstructor |
---|
| 52 | */ |
---|
| 53 | StoryEntity::~StoryEntity () |
---|
| 54 | {} |
---|
[3221] | 55 | |
---|
[2636] | 56 | |
---|
[4592] | 57 | /** |
---|
[6424] | 58 | * loads the Parameters of a Campaign |
---|
| 59 | * @param root: The XML-element to load from |
---|
| 60 | */ |
---|
| 61 | void StoryEntity::loadParams(const TiXmlElement* root) |
---|
[2636] | 62 | { |
---|
[6512] | 63 | BaseObject::loadParams(root); |
---|
[2636] | 64 | |
---|
[6424] | 65 | LoadParam(root, "identifier", this, StoryEntity, setStoryID) |
---|
| 66 | .describe("A Unique Identifier for this StoryEntity"); |
---|
[2636] | 67 | |
---|
[6424] | 68 | LoadParam(root, "nextid", this, StoryEntity, setNextStoryID) |
---|
| 69 | .describe("Sets the ID of the next StoryEntity"); |
---|
[4592] | 70 | |
---|
[6837] | 71 | LoadParam(root, "description", this, StoryEntity, setDescription) |
---|
| 72 | .describe("Sets the description of this StoryEntity"); |
---|
| 73 | |
---|
[6839] | 74 | LoadParam(root, "menu-entry", this, StoryEntity, addToGameMenu) |
---|
| 75 | .describe("If this entry is 1, the world is contained in the SimpleGameMenu"); |
---|
[6837] | 76 | |
---|
[6841] | 77 | LoadParam(root, "menu-item-image", this, StoryEntity, setMenuItemImage) |
---|
| 78 | .describe("If this entry is 1, the world is contained in the SimpleGameMenu"); |
---|
| 79 | |
---|
[6878] | 80 | LoadParam(root, "screenshoot", this, StoryEntity, setMenuScreenshoot) |
---|
[6841] | 81 | .describe("If this entry is 1, the world is contained in the SimpleGameMenu"); |
---|
| 82 | |
---|
[6424] | 83 | PRINTF(4)("Loaded StoryEntity specific stuff\n"); |
---|
[2636] | 84 | } |
---|
[6853] | 85 | |
---|
| 86 | |
---|
| 87 | /** |
---|
| 88 | * sets the descroption of this StoryEntity |
---|
| 89 | * @param name name |
---|
| 90 | */ |
---|
| 91 | void StoryEntity::setDescription(const char* description) |
---|
| 92 | { |
---|
| 93 | if (this->description) |
---|
| 94 | delete[] this->description; |
---|
| 95 | if (description!= NULL) |
---|
| 96 | { |
---|
| 97 | this->description= new char[strlen(description)+1]; |
---|
| 98 | strcpy(this->description, description); |
---|
| 99 | } |
---|
| 100 | else this->description= NULL; |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | |
---|
| 104 | /** |
---|
| 105 | * sets the menu item image of this StoryEntity |
---|
| 106 | * @param name name |
---|
| 107 | */ |
---|
| 108 | void StoryEntity::setMenuItemImage(const char* image) |
---|
| 109 | { |
---|
| 110 | if (this->menuItemImage) |
---|
| 111 | delete[] this->menuItemImage; |
---|
| 112 | if (image != NULL) |
---|
| 113 | { |
---|
| 114 | this->menuItemImage = new char[strlen(image)+1]; |
---|
| 115 | strcpy(this->menuItemImage, image); |
---|
| 116 | } |
---|
| 117 | else this->menuItemImage = NULL; |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | |
---|
| 121 | /** sets the menu screenshoot of this StoryEntity @param name name */ |
---|
| 122 | void StoryEntity::setMenuScreenshoot(const char* image) |
---|
| 123 | { |
---|
| 124 | if (this->menuScreenshoot) |
---|
| 125 | delete[] this->menuScreenshoot; |
---|
| 126 | if (image != NULL) |
---|
| 127 | { |
---|
| 128 | this->menuScreenshoot = new char[strlen(image)+1]; |
---|
| 129 | strcpy(this->menuScreenshoot, image); |
---|
| 130 | } |
---|
| 131 | else this->menuScreenshoot = NULL; |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | |
---|