Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/story_entities/story_entity.cc @ 8235

Last change on this file since 8235 was 7677, checked in by bensch, 18 years ago

orxonox/trunk: POD's

File size: 4.8 KB
RevLine 
[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
[7661]24#include "util/file.h"
25#include "util/loading/load_param.h"
[7193]26#include "util/loading/resource_manager.h"
[2636]27
[6424]28
[2636]29using namespace std;
30
31
[6424]32/**
33 *  default constructor initializes all needed data
34 */
[4592]35StoryEntity::StoryEntity ()
36{
[4597]37  this->setClassID(CL_STORY_ENTITY, "StoryEntity");
[6424]38
[7283]39  this->bInit = false;
40  this->bPaused = false;
41  this->bRunning = false;
[6424]42
[7221]43  this->loadFile = "";
[6424]44  this->storyID = -1;
[7221]45  this->description = "";
46  this->menuItemImage = "";
47  this->menuScreenshoot = "";
[6424]48  this->nextStoryID = WORLD_ID_GAMEEND;
[6839]49  this->bMenuEntry = false;
[4592]50}
[6153]51
[2636]52
[4592]53/**
[6424]54 *  deconstructor
55 */
56StoryEntity::~StoryEntity ()
57{}
[3221]58
[2636]59
[4592]60/**
[6424]61 *  loads the Parameters of a Campaign
62 * @param root: The XML-element to load from
63 */
64void StoryEntity::loadParams(const TiXmlElement* root)
[2636]65{
[6512]66  BaseObject::loadParams(root);
[2636]67
[6424]68  LoadParam(root, "identifier", this, StoryEntity, setStoryID)
[6993]69  .describe("A Unique Identifier for this StoryEntity");
[2636]70
[6992]71  LoadParam(root, "path", this, StoryEntity, setLoadFile)
[6993]72  .describe("DEPRICATED FORM OF file. The Filename of this StoryEntity (relative from the data-dir)");
[6992]73
74  LoadParam(root, "file", this, StoryEntity, setLoadFile)
[6993]75  .describe("The Filename of this StoryEntity (relative from the data-dir)");
[6992]76
[6424]77  LoadParam(root, "nextid", this, StoryEntity, setNextStoryID)
[6993]78  .describe("Sets the ID of the next StoryEntity");
[4592]79
[7010]80  LoadParam(root, "menu-entry", this, StoryEntity, addToGameMenu)
81      .describe("If this entry is 1, the world is contained in the SimpleGameMenu");
82
83
[7033]84
85  // so we can also do these things in the Campaign. (will be overwritten from the entities file)
[7010]86  LoadParam(root, "description", this, StoryEntity, setDescription)
87      .describe("Sets the description of this StoryEntity");
88
89  LoadParam(root, "menu-item-image", this, StoryEntity, setMenuItemImage)
90      .describe("If this entry is 1, the world is contained in the SimpleGameMenu");
91
92  LoadParam(root, "screenshoot", this, StoryEntity, setMenuScreenshoot)
93      .describe("If this entry is 1, the world is contained in the SimpleGameMenu");
94
[6424]95  PRINTF(4)("Loaded StoryEntity specific stuff\n");
[2636]96}
[6853]97
98
99/**
[6992]100 *  sets the track path of this world
101 * @param name the name of the path
102 */
[7221]103void StoryEntity::setLoadFile(const std::string& fileName)
[6992]104{
[7661]105  if (File(fileName).isFile())
[6992]106  {
[7221]107    this->loadFile =  fileName;
[6992]108  }
109  else
110    this->loadFile = ResourceManager::getFullName(fileName);
[6993]111
112  this->grabWorldInfo();
[6992]113}
114
115
116/**
[6853]117 * sets the descroption of this StoryEntity
118 * @param name name
119 */
[7221]120void StoryEntity::setDescription(const std::string& description)
[6853]121{
[7221]122  this->description = description;
[6853]123}
124
[6992]125/**
126 * sets the id of the next story entity: StoryEntities can choose their following entity themselfs.
127 * the entity id defined here  will be startet after this entity ends. this can be convenient if you
128 * want to have a non linear story with switches.
129 * @param nextStoryID the story id of the next StoryEntity
130 */
131void StoryEntity::setNextStoryID(int nextStoryID)
132{
[6993]133  this->nextStoryID = nextStoryID;
[6992]134}
[6853]135
136/**
[6993]137 * @brief grabs settings needed for displaying a MenuScreen.
138 */
139void StoryEntity::grabWorldInfo()
140{
[7677]141  PRINTF(3)("Grabbing the Worlds Settings\n", this->getLoadFile().c_str());
[7221]142  if( getLoadFile().empty())
143        return;
[6993]144  TiXmlDocument XMLDoc(this->getLoadFile());
145  // load the xml world file for further loading
146  if( !XMLDoc.LoadFile())
147  {
[7221]148    PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc.ErrorDesc(), this->getLoadFile().c_str(), XMLDoc.ErrorRow(), XMLDoc.ErrorCol());
[6993]149    return;
150  }
151  TiXmlElement* root = XMLDoc.RootElement();
152  if (root == NULL)
153    return;
154
155  if (root->Value() != NULL && !strcmp(root->Value(), "WorldDataFile"))
156  {
[7021]157    BaseObject::loadParams(root);
158
[6993]159    LoadParam(root, "description", this, StoryEntity, setDescription)
160    .describe("Sets the description of this StoryEntity");
161
162    LoadParam(root, "menu-item-image", this, StoryEntity, setMenuItemImage)
163    .describe("If this entry is 1, the world is contained in the SimpleGameMenu");
164
165    LoadParam(root, "screenshoot", this, StoryEntity, setMenuScreenshoot)
166    .describe("If this entry is 1, the world is contained in the SimpleGameMenu");
167  }
168}
169
170/**
[6853]171 * sets the menu item image of this StoryEntity
172 * @param name name
173 */
[7221]174void StoryEntity::setMenuItemImage(const std::string& image)
[6853]175{
[7221]176  this->menuItemImage = image;
[6853]177}
178
179
[7221]180/** sets the menu screenshoot of this StoryEntity
181 * @param name name
182 */
183void StoryEntity::setMenuScreenshoot(const std::string& image)
[6853]184{
[7221]185  this->menuScreenshoot = image;
[6853]186}
187
188
Note: See TracBrowser for help on using the repository browser.