Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 25, 2007, 10:37:29 PM (17 years ago)
Author:
rgrieder
Message:
  • adapted the core to be an actual windows dll (only tested with MSVC)
  • misc header files dependency changes
Location:
code/branches/FICN/src/loader
Files:
1 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/loader/LevelLoader.cc

    r681 r682  
    11/*
    2  *   ORXONOX - the hottest 3D action shooter ever to exist
    3  *
    4  *
    5  *   License notice:
    6  *
    7  *   This program is free software; you can redistribute it and/or
    8  *   modify it under the terms of the GNU General Public License
    9  *   as published by the Free Software Foundation; either version 2
    10  *   of the License, or (at your option) any later version.
    11  *
    12  *   This program is distributed in the hope that it will be useful,
    13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15  *   GNU General Public License for more details.
    16  *
    17  *   You should have received a copy of the GNU General Public License
    18  *   along with this program; if not, write to the Free Software
    19  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    20  *
    21  *   Author:
    22  *     Nicolas Perrenoud <nicolape@ee.ethz.ch>
    23  *   Co-authors:
    24  *      ...
    25  *
    26  */
    27 
    28 // #include <string>
    29 // #include <vector>
    30 // #include <iostream>
    31 #include <algorithm>
    32 #include <iterator>
    33 
     2*   ORXONOX - the hottest 3D action shooter ever to exist
     3*
     4*
     5*   License notice:
     6*
     7*   This program is free software; you can redistribute it and/or
     8*   modify it under the terms of the GNU General Public License
     9*   as published by the Free Software Foundation; either version 2
     10*   of the License, or (at your option) any later version.
     11*
     12*   This program is distributed in the hope that it will be useful,
     13*   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15*   GNU General Public License for more details.
     16*
     17*   You should have received a copy of the GNU General Public License
     18*   along with this program; if not, write to the Free Software
     19*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     20*
     21*   Author:
     22*     Nicolas Perrenoud <nicolape@ee.ethz.ch>
     23*   Co-authors:
     24*      ...
     25*
     26*/
     27
     28#include <OgreOverlay.h>
    3429#include <OgreOverlayManager.h>
    3530
     31#include "orxonox/core/Error.h"
     32#include "orxonox/core/Debug.h"
     33#include "orxonox/core/CoreIncludes.h"
     34
     35#include "audio/AudioManager.h"
     36#include "orxonox/objects/BaseObject.h"
     37#include "orxonox/Orxonox.h"
     38
    3639#include "LevelLoader.h"
    37 // #include "tinyxml/tinyxml.h"
    38 #include "orxonox/core/CoreIncludes.h"
    39 #include "orxonox/core/Error.h"
    40 #include "orxonox/objects/BaseObject.h"
    41 #include "audio/AudioManager.h"
    42 #include "orxonox/Orxonox.h"
    43 
    44 using namespace std;
    4540
    4641namespace loader
    4742{
    4843
    49 LevelLoader::LevelLoader(string file, string path)
    50 {
    51   valid_ = false;
    52 
    53   // Load XML level file
    54   path.append("/");
    55   path.append(file);
    56 
    57   // Open xml file
    58   doc.LoadFile(path);
    59 
    60   // Check if file was loaded
    61   if (doc.LoadFile())
     44  LevelLoader::LevelLoader(std::string file, std::string path)
    6245  {
    63     TiXmlHandle hDoc(&doc);
    64     TiXmlHandle hRoot(0);
    65     TiXmlElement* pElem;
    66 
    67     // Check for root element
    68     pElem = hDoc.FirstChildElement("orxonoxworld").Element();
    69     if (pElem)
     46    valid_ = false;
     47
     48    // Load XML level file
     49    path.append("/");
     50    path.append(file);
     51
     52    // Open xml file
     53    doc_.LoadFile(path);
     54
     55    // Check if file was loaded
     56    if (doc_.LoadFile())
    7057    {
    71       // Set root element
    72       hRoot = TiXmlHandle(pElem);
    73       rootElement = hRoot.Element();
    74 
    75       // Set level description
    76       pElem = hRoot.FirstChild("description").Element();
     58      TiXmlHandle hDoc(&doc_);
     59      TiXmlHandle hRoot(0);
     60      TiXmlElement* pElem;
     61
     62      // Check for root element
     63      pElem = hDoc.FirstChildElement("orxonoxworld").Element();
    7764      if (pElem)
    7865      {
    79         description_ = pElem->GetText();
    80       }
    81 
    82       // Set level name
    83       name_ = rootElement->Attribute("name");
    84       image_ = rootElement->Attribute("image");
    85 
    86       valid_ = true;
     66        // Set root element
     67        hRoot = TiXmlHandle(pElem);
     68        rootElement_ = hRoot.Element();
     69
     70        // Set level description
     71        pElem = hRoot.FirstChild("description").Element();
     72        if (pElem)
     73        {
     74          description_ = pElem->GetText();
     75        }
     76
     77        // Set level name
     78        name_ = rootElement_->Attribute("name");
     79        image_ = rootElement_->Attribute("image");
     80
     81        valid_ = true;
     82      }
     83      else
     84      {
     85        orxonox::Error("Level file has no valid root node");
     86      }
    8787    }
    8888    else
    8989    {
    90       orxonox::Error("Level file has no valid root node");
     90      orxonox::Error("Could not load level file ");
    9191    }
    9292  }
    93   else
    94   {
    95     orxonox::Error("Could not load level file ");
    96   }
    97 }
    9893
    9994  void LevelLoader::loadLevel()
     
    111106
    112107      // Set loading screen
    113       loadElem = rootElement->FirstChildElement("loading");
     108      loadElem = rootElement_->FirstChildElement("loading");
    114109      if (loadElem)
    115110      {
     
    145140      // Load audio
    146141      audio::AudioManager* auMan = orxonox::Orxonox::getSingleton()->getAudioManagerPointer();
    147       audioElem = rootElement->FirstChildElement("audio");
     142      audioElem = rootElement_->FirstChildElement("audio");
    148143
    149144      if (audioElem)
     
    174169
    175170      // Load world
    176       worldElem = rootElement->FirstChildElement("world");
     171      worldElem = rootElement_->FirstChildElement("world");
    177172      if (worldElem)
    178173      {
     
    192187            else
    193188            {
    194                 COUT(2) << "Warning: '"<< tElem->Value() <<"' is not a valid classname." << std::endl;
     189              COUT(2) << "Warning: '"<< tElem->Value() <<"' is not a valid classname." << std::endl;
    195190            }
    196191          }
     
    201196      {
    202197        // FIXME: check for potential initialisation of mLoadOverlay
    203          mLoadOverlay->hide();
     198        mLoadOverlay->hide();
    204199      }
    205200
     
    214209  }
    215210
    216 
    217 
    218211}
    219 
  • code/branches/FICN/src/loader/LevelLoader.h

    r678 r682  
    1010
    1111#include <string>
    12 #include <vector>
    13 #include <iostream>
    1412
    15 #include "LoaderPlatform.h"
     13#include "LoaderPrereqs.h"
    1614#include "tinyxml/tinyxml.h"
    1715
    18 //#include "xml/xmlParser.h"
    19 
     16class TiXmlDocument;   // Forward declaration
     17class TiXmlElement;    // Forward declaration
    2018
    2119namespace loader
     
    2523  public:
    2624    // Constructors, loads the level file and some information data
    27     LevelLoader(std::string file, std::string dir="levels");
     25    LevelLoader(std::string file, std::string dir = "levels");
    2826    // Destructor
    29     ~LevelLoader();
     27    virtual ~LevelLoader();
    3028    // Loads all level data
    3129    void loadLevel();
     
    5250
    5351    // Xml-Stuff
    54     TiXmlDocument doc;
    55     TiXmlElement* rootElement;
    56 
     52    TiXmlDocument doc_;
     53    TiXmlElement *rootElement_;
    5754  };
    5855}
Note: See TracChangeset for help on using the changeset viewer.