Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/story_entities/story_entity.cc @ 9729

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

less realy useless debug output

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