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:
19 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

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

    r3280 r3370  
    4242    SetCommandLineArgument(ip, "127.0.0.1").information("Sever IP as strin in the form #.#.#.#");
    4343
    44     GSClient::GSClient(const GameStateConstrParams& params)
    45         : GameState(params)
     44    GSClient::GSClient(const GameStateInfo& info)
     45        : GameState(info)
    4646        , client_(0)
    4747    {
  • code/trunk/src/orxonox/gamestates/GSClient.h

    r3280 r3370  
    4040    {
    4141    public:
    42         GSClient(const GameStateConstrParams& params);
     42        GSClient(const GameStateInfo& info);
    4343        ~GSClient();
    4444
  • code/trunk/src/orxonox/gamestates/GSDedicated.cc

    r3351 r3370  
    5555    termios* GSDedicated::originalTerminalSettings_;
    5656
    57     GSDedicated::GSDedicated(const GameStateConstrParams& params)
    58         : GameState(params)
     57    GSDedicated::GSDedicated(const GameStateInfo& info)
     58        : GameState(info)
    5959        , server_(0)
    6060        , closeThread_(false)
  • code/trunk/src/orxonox/gamestates/GSDedicated.h

    r3304 r3370  
    4848    {
    4949    public:
    50         GSDedicated(const GameStateConstrParams& params);
     50        GSDedicated(const GameStateInfo& info);
    5151        ~GSDedicated();
    5252
  • 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}
  • code/trunk/src/orxonox/gamestates/GSGraphics.h

    r3327 r3370  
    5050    {
    5151    public:
    52         GSGraphics(const GameStateConstrParams& params);
     52        GSGraphics(const GameStateInfo& info);
    5353        ~GSGraphics();
    5454
     
    6161    private:
    6262        // managed singletons
    63         InputManager*         inputManager_;        //!< Reference to input management
    6463        InGameConsole*        console_;
    65         GUIManager*           guiManager_;          //!< Interface to GUI
    66         GraphicsManager*      graphicsManager_;     //!< Interface to Ogre
    6764        SoundManager*         soundManager_;        //!< Keeps track of SoundBase objects
    6865
  • code/trunk/src/orxonox/gamestates/GSIOConsole.cc

    r3280 r3370  
    3838    DeclareGameState(GSIOConsole, "ioConsole", false, false);
    3939
    40     GSIOConsole::GSIOConsole(const GameStateConstrParams& params)
    41         : GameState(params)
     40    GSIOConsole::GSIOConsole(const GameStateInfo& info)
     41        : GameState(info)
    4242    {
    4343    }
  • code/trunk/src/orxonox/gamestates/GSIOConsole.h

    r3280 r3370  
    3838    {
    3939    public:
    40         GSIOConsole(const GameStateConstrParams& params);
     40        GSIOConsole(const GameStateInfo& info);
    4141        ~GSIOConsole();
    4242
  • code/trunk/src/orxonox/gamestates/GSLevel.cc

    r3327 r3370  
    4040#include "core/GameMode.h"
    4141#include "core/Core.h"
     42#include "core/GraphicsManager.h"
     43#include "core/GUIManager.h"
    4244#include "core/Loader.h"
    4345#include "core/XMLFile.h"
     
    4749#include "objects/quest/QuestManager.h"
    4850#include "overlays/notifications/NotificationManager.h"
    49 #include "gui/GUIManager.h"
    5051#include "CameraManager.h"
    51 #include "GraphicsManager.h"
    5252#include "LevelManager.h"
    5353#include "PlayerManager.h"
     
    5555namespace orxonox
    5656{
    57     DeclareGameState(GSLevel, "level", false, true);
     57    DeclareGameState(GSLevel, "level", false, false);
    5858    SetConsoleCommand(GSLevel, showIngameGUI, true);
    5959
    6060    XMLFile* GSLevel::startFile_s = NULL;
    6161
    62     GSLevel::GSLevel(const GameStateConstrParams& params)
    63         : GameState(params)
     62    GSLevel::GSLevel(const GameStateInfo& info)
     63        : GameState(info)
    6464        , keyBinder_(0)
    6565        , gameInputState_(0)
  • code/trunk/src/orxonox/gamestates/GSLevel.h

    r3327 r3370  
    4141    {
    4242    public:
    43         GSLevel(const GameStateConstrParams& params);
     43        GSLevel(const GameStateInfo& info);
    4444        ~GSLevel();
    4545        void setConfigValues();
  • code/trunk/src/orxonox/gamestates/GSMainMenu.cc

    r3327 r3370  
    3636#include "core/Clock.h"
    3737#include "core/ConsoleCommand.h"
     38#include "core/GraphicsManager.h"
     39#include "core/GUIManager.h"
    3840#include "objects/Scene.h"
    39 #include "gui/GUIManager.h"
    4041#include "sound/SoundMainMenu.h"
    41 #include "GraphicsManager.h"
    4242
    4343namespace orxonox
     
    4545    DeclareGameState(GSMainMenu, "mainMenu", false, true);
    4646
    47     GSMainMenu::GSMainMenu(const GameStateConstrParams& params)
    48         : GameState(params)
     47    GSMainMenu::GSMainMenu(const GameStateInfo& info)
     48        : GameState(info)
    4949        , inputState_(0)
    50     {
    51     }
    52 
    53     GSMainMenu::~GSMainMenu()
    54     {
    55     }
    56 
    57     void GSMainMenu::activate()
    5850    {
    5951        inputState_ = InputManager::getInstance().createInputState("mainMenu");
     
    6557        // and a Camera
    6658        this->camera_ = this->scene_->getSceneManager()->createCamera("mainMenu/Camera");
     59    }
    6760
     61    GSMainMenu::~GSMainMenu()
     62    {
     63        InputManager::getInstance().destroyState("mainMenu");
     64
     65        this->scene_->getSceneManager()->destroyCamera(this->camera_);
     66        delete this->scene_;
     67    }
     68
     69    void GSMainMenu::activate()
     70    {
    6871        // show main menu
    69         GUIManager::getInstance().showGUI("mainmenu_3");
     72        GUIManager::getInstance().showGUI("mainmenu_4");
    7073        GUIManager::getInstance().setCamera(this->camera_);
    7174        GraphicsManager::getInstance().setCamera(this->camera_);
     
    107110
    108111        InputManager::getInstance().leaveState("mainMenu");
    109         InputManager::getInstance().destroyState("mainMenu");
    110112
    111113        GUIManager::getInstance().setCamera(0);
    112114        GraphicsManager::getInstance().setCamera(0);
    113         this->scene_->getSceneManager()->destroyCamera(this->camera_);
    114         delete this->scene_;
    115115
    116116/*
  • code/trunk/src/orxonox/gamestates/GSMainMenu.h

    r3327 r3370  
    4040    {
    4141    public:
    42         GSMainMenu(const GameStateConstrParams& params);
     42        GSMainMenu(const GameStateInfo& info);
    4343        ~GSMainMenu();
    4444
  • code/trunk/src/orxonox/gamestates/GSRoot.cc

    r3304 r3370  
    3030
    3131#include "core/Clock.h"
    32 #include "core/CommandLine.h"
    3332#include "core/ConsoleCommand.h"
    3433#include "core/Game.h"
    3534#include "core/GameMode.h"
     35#include "core/LuaBind.h"
    3636#include "network/NetworkFunction.h"
     37#include "ToluaBindCore.h"
     38#include "ToluaBindOrxonox.h"
    3739#include "tools/Timer.h"
    3840#include "interfaces/TimeFactorListener.h"
     
    4244namespace orxonox
    4345{
    44     DeclareGameState(GSRoot, "root", true, false);
    45     SetCommandLineSwitch(console).information("Start in console mode (text IO only)");
    46     // Shortcuts for easy direct loading
    47     SetCommandLineSwitch(server).information("Start in server mode");
    48     SetCommandLineSwitch(client).information("Start in client mode");
    49     SetCommandLineSwitch(dedicated).information("Start in dedicated server mode");
    50     SetCommandLineSwitch(standalone).information("Start in standalone mode");
     46    DeclareGameState(GSRoot, "root", false, false);
    5147
    52     GSRoot::GSRoot(const GameStateConstrParams& params)
    53         : GameState(params)
     48    GSRoot::GSRoot(const GameStateInfo& info)
     49        : GameState(info)
    5450        , timeFactor_(1.0f)
    5551        , bPaused_(false)
     
    5854        this->ccSetTimeFactor_ = 0;
    5955        this->ccPause_ = 0;
     56
     57        // Tell LuaBind about all tolua interfaces
     58        LuaBind::getInstance().addToluaInterface(&tolua_Core_open, "Core");
     59        LuaBind::getInstance().addToluaInterface(&tolua_Orxonox_open, "Orxonox");
    6060    }
    6161
     
    8888        // create the global LevelManager
    8989        this->levelManager_ = new LevelManager();
    90 
    91         // Load level directly?
    92         bool loadLevel = false;
    93         if (CommandLine::getValue("standalone").getBool())
    94         {
    95             Game::getInstance().requestStates("graphics, standalone, level");
    96             loadLevel = true;
    97         }
    98         if (CommandLine::getValue("server").getBool())
    99         {
    100             Game::getInstance().requestStates("graphics, server, level");
    101             loadLevel = true;
    102         }
    103         if (CommandLine::getValue("client").getBool())
    104         {
    105             Game::getInstance().requestStates("graphics, client, level");
    106             loadLevel = true;
    107         }
    108         if (CommandLine::getValue("dedicated").getBool())
    109         {
    110             Game::getInstance().requestStates("dedicated, level");
    111             loadLevel = true;
    112         }
    113        
    114         // Determine where to start otherwise
    115         if (!loadLevel && !CommandLine::getValue("console").getBool())
    116         {
    117             // Also load graphics
    118             Game::getInstance().requestState("graphics");
    119         }
    12090    }
    12191
     
    148118        }
    149119
    150         uint64_t timeBeforeTick = time.getRealMicroseconds();
    151 
    152120        for (ObjectList<TimerBase>::iterator it = ObjectList<TimerBase>::begin(); it; ++it)
    153121            it->tick(time);
     
    164132            it->tick(leveldt * this->timeFactor_);
    165133        /*** HACK *** HACK ***/
    166 
    167         uint64_t timeAfterTick = time.getRealMicroseconds();
    168 
    169         // Also add our tick time
    170         Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick);
    171134    }
    172135
     
    174137    @brief
    175138        Changes the speed of Orxonox
     139    @remark
     140        This function is a hack when placed here!
     141        Timefactor should be related to the scene (level or so), not the game
    176142    */
    177143    void GSRoot::setTimeFactor(float factor)
  • code/trunk/src/orxonox/gamestates/GSRoot.h

    r3280 r3370  
    3838    {
    3939    public:
    40         GSRoot(const GameStateConstrParams& params);
     40        GSRoot(const GameStateInfo& info);
    4141        ~GSRoot();
    4242
  • code/trunk/src/orxonox/gamestates/GSServer.cc

    r3280 r3370  
    4141    SetCommandLineArgument(port, 55556).shortcut("p").information("Network communication port to be used 0-65535 (default: 55556)");
    4242
    43     GSServer::GSServer(const GameStateConstrParams& params)
    44         : GameState(params)
     43    GSServer::GSServer(const GameStateInfo& info)
     44        : GameState(info)
    4545        , server_(0)
    4646    {
  • code/trunk/src/orxonox/gamestates/GSServer.h

    r3280 r3370  
    4040    {
    4141    public:
    42         GSServer(const GameStateConstrParams& params);
     42        GSServer(const GameStateInfo& info);
    4343        ~GSServer();
    4444
  • code/trunk/src/orxonox/gamestates/GSStandalone.cc

    r3280 r3370  
    3636    DeclareGameState(GSStandalone, "standalone", false, true);
    3737
    38     GSStandalone::GSStandalone(const GameStateConstrParams& params)
    39         : GameState(params)
     38    GSStandalone::GSStandalone(const GameStateInfo& info)
     39        : GameState(info)
    4040    {
    4141    }
  • code/trunk/src/orxonox/gamestates/GSStandalone.h

    r3280 r3370  
    3838    {
    3939    public:
    40         GSStandalone(const GameStateConstrParams& params);
     40        GSStandalone(const GameStateInfo& info);
    4141        ~GSStandalone();
    4242
Note: See TracChangeset for help on using the changeset viewer.