Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 1, 2009, 11:44:53 AM (15 years ago)
Author:
rgrieder
Message:

Moved the singleton creation/destruction mess to the Core class by using just two possible Scopes:

  • ScopeID::Root for singletons that may always persists
  • ScopeID::Graphics for singletons that only work when graphics was loaded
Location:
code/branches/core5/src/orxonox/gamestates
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/orxonox/gamestates/GSGraphics.cc

    r5842 r5850  
    4646#include "core/Loader.h"
    4747#include "core/XMLFile.h"
    48 #include "overlays/InGameConsole.h"
    49 #include "sound/SoundManager.h"
    5048
    5149// HACK:
     
    5856    GSGraphics::GSGraphics(const GameStateInfo& info)
    5957        : GameState(info)
    60         , console_(0)
    61         , soundManager_(0)
    6258        , masterKeyBinder_(0)
    6359        , masterInputState_(0)
     
    10096        masterKeyBinder_->loadBindings("masterKeybindings.ini");
    10197
    102         // Load the SoundManager
    103         soundManager_ = new SoundManager();
    104 
    105         // Load the InGameConsole
    106         console_ = new InGameConsole();
    107         console_->initialise();
    108 
    10998        // add console command to toggle GUI
    11099        this->ccToggleGUI_ = createConsoleCommand(createFunctor(&GSGraphics::toggleGUI, this), "toggleGUI");
     
    131120*/
    132121
    133         this->console_->destroy();
    134 
    135122        Loader::unload(this->debugOverlay_);
    136123        delete this->debugOverlay_;
    137 
    138         this->soundManager_->destroy();
    139124
    140125        // HACK: (destroys a resource smart pointer)
     
    170155            Game::getInstance().requestState("mainMenu");
    171156        }
    172 
    173         this->console_->update(time);
    174157    }
    175158}
  • code/branches/core5/src/orxonox/gamestates/GSGraphics.h

    r5842 r5850  
    6060
    6161    private:
    62         // managed singletons
    63         InGameConsole*        console_;
    64         SoundManager*         soundManager_;        //!< Keeps track of SoundBase objects
    65 
    6662        KeyBinder*            masterKeyBinder_;     //!< Key binder for master key bindings
    6763        InputState*           masterInputState_;    //!< Special input state for master input
  • code/branches/core5/src/orxonox/gamestates/GSLevel.cc

    r5842 r5850  
    4141#include "core/Game.h"
    4242#include "core/GameMode.h"
    43 #include "core/GraphicsManager.h"
    4443#include "core/GUIManager.h"
    4544#include "core/Loader.h"
    4645#include "core/XMLFile.h"
    4746
    48 #include "tools/interfaces/Tickable.h"
    49 #include "CameraManager.h"
    5047#include "LevelManager.h"
    5148#include "PlayerManager.h"
    52 #include "infos/HumanPlayer.h"
    5349
    5450namespace orxonox
     
    6561        , guiMouseOnlyInputState_(0)
    6662        , guiKeysOnlyInputState_(0)
    67         , cameraManager_(0)
    6863    {
    6964        RegisterObject(GSLevel);
     
    9893            guiKeysOnlyInputState_ = InputManager::getInstance().createInputState("guiKeysOnly");
    9994            guiKeysOnlyInputState_->setKeyHandler(GUIManager::getInstancePtr());
    100 
    101             // create the global CameraManager
    102             this->cameraManager_ = new CameraManager(GraphicsManager::getInstance().getViewport());
    103         }
    104 
    105         this->playerManager_ = new PlayerManager();
    106 
    107         this->scope_GSLevel_ = new Scope<ScopeID::GSLevel>();
     95        }
    10896
    10997        if (GameMode::isMaster())
     
    126114           
    127115            // connect the HumanPlayer to the game
    128             this->playerManager_->clientConnected(0);
     116            PlayerManager::getInstance().clientConnected(0);
    129117        }
    130118    }
     
    165153        {
    166154            // disconnect the HumanPlayer
    167             this->playerManager_->clientDisconnected(0);
     155            PlayerManager::getInstance().clientDisconnected(0);
    168156           
    169157            // unload all compositors (this is only necessary because we don't yet destroy all resources!)
     
    184172        if (GameMode::isMaster())
    185173            this->unloadLevel();
    186 
    187         if (this->cameraManager_)
    188         {
    189             delete this->cameraManager_;
    190             this->cameraManager_ = 0;
    191         }
    192 
    193         if (this->playerManager_)
    194         {
    195             this->playerManager_->destroy();
    196             this->playerManager_ = 0;
    197         }
    198 
    199         if (this->scope_GSLevel_)
    200         {
    201             delete this->scope_GSLevel_;
    202             this->scope_GSLevel_ = NULL;
    203         }
    204174
    205175        if (GameMode::showsGraphics())
  • code/branches/core5/src/orxonox/gamestates/GSLevel.h

    r5842 r5850  
    3333
    3434#include <string>
    35 #include "util/Scope.h"
    3635#include "core/OrxonoxClass.h"
    3736#include "core/GameState.h"
     
    6766        InputState*              guiMouseOnlyInputState_;  //!< input state if we only need the mouse to use the GUI
    6867        InputState*              guiKeysOnlyInputState_;   //!< input state if we only need the keys to use the GUI
    69         CameraManager*           cameraManager_;           //!< camera manager for this level
    70         PlayerManager*           playerManager_;           //!< player manager for this level
    71         Scope<ScopeID::GSLevel>* scope_GSLevel_;
    7268
    7369        //##### ConfigValues #####
  • code/branches/core5/src/orxonox/gamestates/GSRoot.cc

    r5831 r5850  
    3737#include "tools/interfaces/TimeFactorListener.h"
    3838#include "tools/interfaces/Tickable.h"
    39 #include "LevelManager.h"
    4039
    4140namespace orxonox
     
    7069        this->ccPause_ = createConsoleCommand(createFunctor(&GSRoot::pause, this), "pause");
    7170        CommandExecutor::addConsoleCommandShortcut(this->ccPause_).accessLevel(AccessLevel::Offline);
    72 
    73         // create the LevelManager
    74         this->levelManager_ = new LevelManager();
    7571    }
    7672
     
    9086        }
    9187*/
    92 
    93         this->levelManager_->destroy();
    9488    }
    9589
  • code/branches/core5/src/orxonox/gamestates/GSRoot.h

    r5842 r5850  
    5656        float                 timeFactorPauseBackup_;
    5757
    58         LevelManager*         levelManager_;            //!< global level manager
    59 
    6058        // console commands
    6159        ConsoleCommand*       ccSetTimeFactor_;
Note: See TracChangeset for help on using the changeset viewer.