Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 30, 2009, 2:10:44 PM (15 years ago)
Author:
rgrieder
Message:

Merged resource branch back to the trunk. Changes:

  • Automated graphics loading by evaluating whether a GameState requires it
  • Using native Tcl library (x3n)

Windows users: Update your dependency package!

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/gamestates/GSGraphics.cc

    r3327 r3370  
    3535#include "GSGraphics.h"
    3636
    37 #include <boost/filesystem.hpp>
    38 #include <OgreRenderWindow.h>
    39 
    4037#include "util/Convert.h"
    4138#include "core/Clock.h"
     
    4441#include "core/Core.h"
    4542#include "core/Game.h"
    46 #include "core/GameMode.h"
     43#include "core/GUIManager.h"
    4744#include "core/input/InputManager.h"
    4845#include "core/input/KeyBinder.h"
     
    5148#include "core/XMLFile.h"
    5249#include "overlays/console/InGameConsole.h"
    53 #include "gui/GUIManager.h"
    5450#include "sound/SoundManager.h"
    55 #include "GraphicsManager.h"
     51
     52// HACK:
     53#include "overlays/map/Map.h"
    5654
    5755namespace orxonox
    5856{
    59     DeclareGameState(GSGraphics, "graphics", true, true);
     57    DeclareGameState(GSGraphics, "graphics", false, true);
    6058
    61     GSGraphics::GSGraphics(const GameStateConstrParams& params)
    62         : GameState(params)
    63         , inputManager_(0)
     59    GSGraphics::GSGraphics(const GameStateInfo& info)
     60        : GameState(info)
    6461        , console_(0)
    65         , guiManager_(0)
    66         , graphicsManager_(0)
    6762        , soundManager_(0)
    6863        , masterKeyBinder_(0)
     
    7065        , debugOverlay_(0)
    7166    {
     67        // load master key bindings
     68        masterInputState_ = InputManager::getInstance().createInputState("master", true);
     69        masterKeyBinder_ = new KeyBinder();
     70        masterInputState_->setKeyHandler(masterKeyBinder_);
    7271    }
    7372
    7473    GSGraphics::~GSGraphics()
    7574    {
     75        InputManager::getInstance().destroyState("master");
     76        delete this->masterKeyBinder_;
    7677    }
    7778
     
    9394    void GSGraphics::activate()
    9495    {
    95         GameMode::setShowsGraphics(true);
    96 
    97         // Load OGRE including the render window
    98         this->graphicsManager_ = new GraphicsManager();
    99 
    10096        // load debug overlay
    10197        COUT(3) << "Loading Debug Overlay..." << std::endl;
    102         this->debugOverlay_ = new XMLFile((Core::getMediaPath() / "overlay" / "debug.oxo").string());
     98        this->debugOverlay_ = new XMLFile(Core::getMediaPathString() + "overlay/debug.oxo");
    10399        Loader::open(debugOverlay_);
    104100
    105         // The render window width and height are used to set up the mouse movement.
    106         size_t windowHnd = 0;
    107         Ogre::RenderWindow* renderWindow = GraphicsManager::getInstance().getRenderWindow();
    108         renderWindow->getCustomAttribute("WINDOW", &windowHnd);
    109 
    110         // Calls the InputManager which sets up the input devices.
    111         inputManager_ = new InputManager(windowHnd);
    112 
    113         // load master key bindings
    114         masterInputState_ = InputManager::getInstance().createInputState("master", true);
    115         masterKeyBinder_ = new KeyBinder();
    116101        masterKeyBinder_->loadBindings("masterKeybindings.ini");
    117         masterInputState_->setKeyHandler(masterKeyBinder_);
    118102
    119103        // Load the SoundManager
     
    123107        console_ = new InGameConsole();
    124108        console_->initialise();
    125 
    126         // load the CEGUI interface
    127         guiManager_ = new GUIManager();
    128         guiManager_->initialise(renderWindow);
    129109
    130110        // add console command to toggle GUI
     
    154134*/
    155135
    156         masterInputState_->setHandler(0);
    157         InputManager::getInstance().destroyState("master");
    158         delete this->masterKeyBinder_;
    159 
    160         delete this->guiManager_;
    161136        delete this->console_;
    162137
     
    166141        delete this->soundManager_;
    167142
    168         delete this->inputManager_;
    169         this->inputManager_ = 0;
    170 
    171         delete graphicsManager_;
    172 
    173         GameMode::setShowsGraphics(false);
     143        // HACK: (destroys a resource smart pointer)
     144        Map::hackDestroyMap();
    174145    }
    175146
     
    203174        }
    204175
    205         uint64_t timeBeforeTick = time.getRealMicroseconds();
    206 
    207         this->inputManager_->update(time);
    208176        this->console_->update(time);
    209 
    210         uint64_t timeAfterTick = time.getRealMicroseconds();
    211 
    212         // Also add our tick time
    213         Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick);
    214 
    215         // Process gui events
    216         this->guiManager_->update(time);
    217         // Render
    218         this->graphicsManager_->update(time);
    219177    }
    220178}
Note: See TracChangeset for help on using the changeset viewer.