Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 26, 2008, 4:26:04 PM (16 years ago)
Author:
rgrieder
Message:

Still working on the GameStates, but I have to save the work because of some major changes.

  • Exported InputManager- and TclThreadManager-tick to GSGraphics instead of Core
  • Fixed a few bugs in GameState by adding an internal state variable as bitfield (quite practical)
  • Fixed a bug in InputManager that occurred when destroying an active InputState
  • Added GSIO and GSIOConsole (3 lines of loop code with std::cin, but works ;))
  • Added more boost thread includes to OrxonoxStableHeaders.h
  • Many changes in all GameState derived classes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gui/src/orxonox/gamestates/GSLevel.cc

    r1664 r1670  
    3030#include "GSLevel.h"
    3131
    32 #include "core/ConsoleCommand.h"
    3332#include "core/input/InputManager.h"
    3433#include "core/input/SimpleInputState.h"
    3534#include "core/input/KeyBinder.h"
    3635#include "core/Loader.h"
    37 #include "core/CommandLine.h"
    38 #include "overlays/console/InGameConsole.h"
    39 #include "gui/GUIManager.h"
    4036#include "objects/Backlight.h"
    4137#include "tools/ParticleInterface.h"
     38#include "Settings.h"
    4239#include "Radar.h"
    43 #include "Settings.h"
    4440#include "GraphicsEngine.h"
    4541
    4642namespace orxonox
    4743{
    48     SetCommandLineArgument(port, 55556).setShortcut("p").setInformation("PORT");
    49     SetCommandLineArgument(ip, "127.0.0.0").setInformation("#.#.#.#");
    50 
    51     GSLevel::GSLevel()
    52         : GameState("level")
     44    GSLevel::GSLevel(const std::string& name)
     45        : GameState(name)
    5346        , timefactor_(1.0f)
    5447        , keyBinder_(0)
     48        , inputState_(0)
    5549        , radar_(0)
    5650        , startLevel_(0)
     
    6559    void GSLevel::enter()
    6660    {
     61        inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20);
    6762        keyBinder_ = new KeyBinder();
    6863        keyBinder_->loadBindings();
    69         InputManager::getInstance().createInputState<SimpleInputState>("game", 20)->setHandler(keyBinder_);
     64        inputState_->setHandler(keyBinder_);
    7065
    7166        // create Ogre SceneManager for the level
     
    7974        hud_ = new Level(Settings::getDataPath() + "overlay/hud.oxo");
    8075        Loader::load(hud_);
    81 
    82         // call the loader
    83         COUT(0) << "Loading level..." << std::endl;
    84         startLevel_ = new Level(Settings::getDataPath() + "levels/sample.oxw");
    85         Loader::open(startLevel_);
    86 
    87         // add console commands
    88         FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
    89         functor->setObject(this);
    90         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor"));
    91 
    92         // level is loaded: we can start capturing the input
    93         InputManager::getInstance().requestEnterState("game");
    9476    }
    9577
    9678    void GSLevel::leave()
    9779    {
    98         InputManager::getInstance().requestLeaveState("game");
    99 
    100         // TODO: Remove and destroy console command
    101 
    102         Loader::unload(startLevel_);
    103         delete this->startLevel_;
    104 
    10580        Loader::unload(hud_);
    10681        delete this->hud_;
     
    11691        // TODO: delete SceneManager
    11792
    118         InputManager::getInstance().destroyState("game");
     93        inputState_->setHandler(0);
     94        InputManager::getInstance().requestDestroyState("game");
    11995        delete this->keyBinder_;
    12096    }
    12197
    122     bool GSLevel::tick(float dt)
     98    void GSLevel::ticked(float dt)
    12399    {
    124100        // Call those objects that need the real time
     
    128104        for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
    129105            it->tick(dt * this->timefactor_);
    130 
    131         // TODO: split file into server/client/standalone
    132         // call server/client with normal dt
    133         //if (client_g)
    134         //    client_g->tick(dt * this->timefactor_);
    135         //if (server_g)
    136         //    server_g->tick(dt * this->timefactor_);
    137 
    138         return true;
    139106    }
    140107
     
    153120            it->setTimeFactor(timefactor_);
    154121    }
     122
     123    void GSLevel::loadLevel()
     124    {
     125        // call the loader
     126        COUT(0) << "Loading level..." << std::endl;
     127        startLevel_ = new Level(Settings::getDataPath() + "levels/sample.oxw");
     128        Loader::open(startLevel_);
     129    }
     130
     131    void GSLevel::unloadLevel()
     132    {
     133        Loader::unload(startLevel_);
     134        delete this->startLevel_;
     135    }
    155136}
Note: See TracChangeset for help on using the changeset viewer.