Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 25, 2009, 1:18:03 PM (15 years ago)
Author:
dafrick
Message:

Merged presentation2 branch into pickup2 branch.

Location:
code/branches/pickup2
Files:
6 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickup2

  • code/branches/pickup2/src/orxonox/gamestates/CMakeLists.txt

    r5929 r6412  
    11ADD_SOURCE_FILES(ORXONOX_SRC_FILES
    22  GSClient.cc
    3   GSDedicated.cc
    4   GSDedicatedClient.cc
    53  GSGraphics.cc
    6   GSIOConsole.cc
    74  GSLevel.cc
    85  GSMainMenu.cc
  • code/branches/pickup2/src/orxonox/gamestates/GSClient.cc

    r5929 r6412  
    2929#include "GSClient.h"
    3030
    31 #include "util/Clock.h"
     31#include "util/Debug.h"
    3232#include "util/Exception.h"
    33 #include "core/CommandLine.h"
     33#include "core/CommandLineParser.h"
    3434#include "core/Game.h"
    3535#include "core/GameMode.h"
     
    3838namespace orxonox
    3939{
    40     DeclareGameState(GSClient, "client", false, true);
     40    DeclareGameState(GSClient, "client", false, false);
    4141
    4242    SetCommandLineArgument(ip, "127.0.0.1").information("Sever IP as string in the form #.#.#.#");
     
    5656        GameMode::setIsClient(true);
    5757
    58         this->client_ = new Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port"));
     58        this->client_ = new Client(CommandLineParser::getValue("ip").getString(), CommandLineParser::getValue("port"));
    5959
    6060        if(!client_->establishConnection())
  • code/branches/pickup2/src/orxonox/gamestates/GSGraphics.cc

    r5929 r6412  
    6464    void GSGraphics::activate()
    6565    {
    66         // add console command to toggle GUI
    67         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSGraphics::toggleGUI, this), "toggleGUI"));
     66
    6867    }
    6968
     
    7877    }
    7978
    80     /**
    81     @brief
    82         Toggles the visibility of the current GUI
    83 
    84         This function just executes a Lua function in the main script of the GUI by accessing the GUIManager.
    85         For more details on this function check out the Lua code.
    86     */
    87     void GSGraphics::toggleGUI()
    88     {
    89         GUIManager::getInstance().executeCode("toggleGUI()");
    90     }
    91 
    9279    void GSGraphics::update(const Clock& time)
    9380    {
  • code/branches/pickup2/src/orxonox/gamestates/GSGraphics.h

    r5929 r6412  
    5757        void update(const Clock& time);
    5858
    59         void toggleGUI();
    60 
    6159    private:
    6260    };
  • code/branches/pickup2/src/orxonox/gamestates/GSLevel.cc

    r5929 r6412  
    5656        , guiKeysOnlyInputState_(0)
    5757        , startFile_(0)
     58        , bShowIngameGUI_(false)
    5859    {
    5960    }
     
    7879            guiKeysOnlyInputState_ = InputManager::getInstance().createInputState("guiKeysOnly");
    7980            guiKeysOnlyInputState_->setKeyHandler(GUIManager::getInstancePtr());
    80 
    81             CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSLevel::showIngameGUI, this), "showIngameGUI"));
    8281        }
    8382
     
    9190            // level is loaded: we can start capturing the input
    9291            InputManager::getInstance().enterState("game");
    93            
     92
    9493            // connect the HumanPlayer to the game
    9594            PlayerManager::getInstance().clientConnected(0);
    96         }
    97     }
    98 
    99     void GSLevel::showIngameGUI(bool show)
    100     {
    101         if (show)
    102         {
    103             GUIManager::getInstance().showGUI("inGameTest");
    104             GUIManager::getInstance().executeCode("showCursor()");
    105             InputManager::getInstance().enterState("guiMouseOnly");
    106         }
    107         else
    108         {
    109             GUIManager::getInstance().executeCode("hideGUI(\"inGameTest\")");
    110             GUIManager::getInstance().executeCode("hideCursor()");
    111             InputManager::getInstance().leaveState("guiMouseOnly");
    11295        }
    11396    }
     
    117100        if (GameMode::showsGraphics())
    118101        {
    119             // disconnect the HumanPlayer
    120             PlayerManager::getInstance().clientDisconnected(0);
    121            
    122102            // unload all compositors (this is only necessary because we don't yet destroy all resources!)
    123103            Ogre::CompositorManager::getSingleton().removeAll();
     
    125105            InputManager::getInstance().leaveState("game");
    126106        }
     107
     108        // disconnect all HumanPlayers
     109        PlayerManager::getInstance().disconnectAllClients();
    127110
    128111        if (GameMode::isMaster())
     
    152135        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
    153136            this->staticObjects_.insert(*it);
    154        
     137
    155138        // call the loader
    156139        COUT(0) << "Loading level..." << std::endl;
     
    171154            if (find == this->staticObjects_.end())
    172155            {
    173                 COUT(3) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << ")" << std::endl;
     156                COUT(3) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << ')' << std::endl;
    174157            }
    175158        }
  • code/branches/pickup2/src/orxonox/gamestates/GSLevel.h

    r5929 r6412  
    5252        void loadLevel();
    5353        void unloadLevel();
    54         void showIngameGUI(bool show);
    5554
    5655        InputState*              gameInputState_;          //!< input state for normal ingame playing
     
    6059        XMLFile* startFile_;
    6160        std::set<BaseObject*> staticObjects_;
     61        bool bShowIngameGUI_;
    6262    };
    6363}
  • code/branches/pickup2/src/orxonox/gamestates/GSMainMenu.cc

    r5929 r6412  
    3636#include "core/Game.h"
    3737#include "core/ConsoleCommand.h"
     38#include "core/ConfigValueIncludes.h"
     39#include "core/CoreIncludes.h"
    3840#include "core/GraphicsManager.h"
    3941#include "core/GUIManager.h"
     
    4951        , inputState_(0)
    5052    {
     53        RegisterRootObject(GSMainMenu);
    5154        inputState_ = InputManager::getInstance().createInputState("mainMenu");
    5255        inputState_->setMouseMode(MouseMode::Nonexclusive);
     
    6467            // Load sound
    6568            this->ambient_ = new AmbientSound(0);
    66             this->ambient_->setSource("ambient/mainmenu.wav");
     69            this->ambient_->setSyncMode(0x0);
    6770        }
    6871    }
     
    7174    {
    7275        if (GameMode::playsSound())
    73             delete this->ambient_;
     76            this->ambient_->destroy();
    7477
    7578        InputManager::getInstance().destroyState("mainMenu");
     
    8285    {
    8386        // show main menu
    84         GUIManager::getInstance().showGUI("MainMenu");
     87        GUIManager::getInstance().showGUI("MainMenu", true, GraphicsManager::getInstance().isFullScreen());
    8588        GUIManager::getInstance().setCamera(this->camera_);
     89        GUIManager::getInstance().setBackground("MainMenuBackground");
     90//         GUIManager::getInstance().setBackground("");
    8691        GraphicsManager::getInstance().setCamera(this->camera_);
    8792
     
    9196        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startDedicated), "startDedicated"));
    9297        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startMainMenu), "startMainMenu"));
    93         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startIOConsole), "startIOConsole"));
     98
     99        // create command to change sound path
     100        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::setMainMenuSoundPath, this), "setMMSoundPath"));
    94101
    95102        KeyBinderManager::getInstance().setToDefault();
    96103        InputManager::getInstance().enterState("mainMenu");
    97104
     105        this->setConfigValues();
     106
    98107        if (GameMode::playsSound())
    99108        {
    100             this->ambient_->setLoop(true);
    101             this->ambient_->play();
     109            this->ambient_->setLooping(true);
     110            this->ambient_->play(); // works without source
    102111        }
    103112    }
     
    113122
    114123        GUIManager::getInstance().setCamera(0);
     124        GUIManager::getInstance().setBackground("");
     125        GUIManager::hideGUI("MainMenu");
    115126        GraphicsManager::getInstance().setCamera(0);
    116127    }
     
    118129    void GSMainMenu::update(const Clock& time)
    119130    {
     131    }
     132
     133    void GSMainMenu::setConfigValues()
     134    {
     135        SetConfigValue(soundPathMain_, "mainmenu.ogg")
     136            .description("Contains the path to the main menu sound file.")
     137            .callback(this, &GSMainMenu::reloadSound);
     138    }
     139
     140    void GSMainMenu::reloadSound()
     141    {
     142        if (GameMode::playsSound())
     143        {
     144            this->ambient_->setAmbientSource(soundPathMain_);
     145        }
     146    }
     147
     148    const std::string& GSMainMenu::getMainMenuSoundPath()
     149    {
     150        return soundPathMain_;
     151    }
     152
     153    void GSMainMenu::setMainMenuSoundPath(const std::string& path)
     154    {
     155        ModifyConfigValue(soundPathMain_, set, path);
    120156    }
    121157
     
    146182        Game::getInstance().popState();
    147183        Game::getInstance().popState();
    148         Game::getInstance().requestStates("dedicated, level");
     184        Game::getInstance().requestStates("server, level");
    149185    }
    150186    void GSMainMenu::startMainMenu()
     
    155191        Game::getInstance().requestStates("mainmenu");
    156192    }
    157     void GSMainMenu::startIOConsole()
    158     {
    159         // HACK - HACK
    160         Game::getInstance().popState();
    161         Game::getInstance().popState();
    162         Game::getInstance().requestStates("ioConsole");
    163     }
    164193}
  • code/branches/pickup2/src/orxonox/gamestates/GSMainMenu.h

    r5929 r6412  
    3434#include "util/OgreForwardRefs.h"
    3535#include "core/GameState.h"
     36#include "core/OrxonoxClass.h"
    3637
    3738namespace orxonox
    3839{
    39     class _OrxonoxExport GSMainMenu : public GameState
     40    class _OrxonoxExport GSMainMenu : public GameState, public OrxonoxClass
    4041    {
    4142    public:
     
    4647        void deactivate();
    4748        void update(const Clock& time);
     49
     50        void setConfigValues();
     51        void reloadSound();
     52        const std::string& getMainMenuSoundPath();
     53        void setMainMenuSoundPath(const std::string& path);
    4854
    4955        static void startStandalone();
     
    6167        // ambient sound for the main menu
    6268        AmbientSound*     ambient_;
     69        std::string       soundPathMain_;
    6370    };
    6471}
  • code/branches/pickup2/src/orxonox/gamestates/GSRoot.cc

    r5929 r6412  
    3030
    3131#include "util/Clock.h"
     32#include "core/BaseObject.h"
    3233#include "core/ConsoleCommand.h"
    3334#include "core/Game.h"
     
    4546    GSRoot::GSRoot(const GameStateInfo& info)
    4647        : GameState(info)
    47         , timeFactor_(1.0f)
    4848        , bPaused_(false)
    4949        , timeFactorPauseBackup_(1.0f)
     
    5555        NetworkFunctionBase::destroyAllNetworkFunctions();
    5656    }
    57    
     57
    5858    void GSRoot::printObjects()
    5959    {
    6060        unsigned int nr=0;
    61         for(ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it; ++it){
    62             if( dynamic_cast<Synchronisable*>(*it) )
     61        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it; ++it)
     62        {
     63            if (dynamic_cast<Synchronisable*>(*it))
    6364                COUT(0) << "object: " << it->getIdentifier()->getName() << " id: " << dynamic_cast<Synchronisable*>(*it)->getObjectID() << std::endl;
    6465            else
     
    6768        }
    6869        COUT(0) << "currently got " << nr << " objects" << std::endl;
    69    
    7070    }
    7171
     
    7373    {
    7474        // reset game speed to normal
    75         this->timeFactor_ = 1.0f;
     75        TimeFactorListener::setTimeFactor(1.0f);
    7676
    7777        // time factor console command
     
    9090    void GSRoot::update(const Clock& time)
    9191    {
    92         if (this->getActivity().topState)
     92        for (ObjectList<Timer>::iterator it = ObjectList<Timer>::begin(); it; )
    9393        {
    94             // This state can not 'survive' on its own.
    95             // Load a user interface therefore
    96             Game::getInstance().requestState("ioConsole");
     94            Timer* object = *it;
     95            ++it;
     96            object->tick(time);
    9797        }
    98 
    99         for (ObjectList<Timer>::iterator it = ObjectList<Timer>::begin(); it; )
    100             (it++)->tick(time);
    10198
    10299        /*** HACK *** HACK ***/
     
    108105            leveldt = 0.0f;
    109106        }
     107        float realdt = leveldt * TimeFactorListener::getTimeFactor();
    110108        for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; )
    111             (it++)->tick(leveldt * this->timeFactor_);
     109        {
     110            Tickable* object = *it;
     111            ++it;
     112            object->tick(realdt);
     113        }
    112114        /*** HACK *** HACK ***/
    113115    }
     
    126128            if (!this->bPaused_)
    127129            {
    128                 TimeFactorListener::timefactor_s = factor;
    129 
    130                 for (ObjectList<TimeFactorListener>::iterator it = ObjectList<TimeFactorListener>::begin(); it != ObjectList<TimeFactorListener>::end(); ++it)
    131                     it->changedTimeFactor(factor, this->timeFactor_);
    132 
    133                 this->timeFactor_ = factor;
     130                TimeFactorListener::setTimeFactor(factor);
    134131            }
    135132            else
     
    144141            if (!this->bPaused_)
    145142            {
    146                 this->timeFactorPauseBackup_ = this->timeFactor_;
     143                this->timeFactorPauseBackup_ = TimeFactorListener::getTimeFactor();
    147144                this->setTimeFactor(0.0f);
    148145                this->bPaused_ = true;
     
    155152        }
    156153    }
     154
     155    float GSRoot::getTimeFactor()
     156    {
     157        return TimeFactorListener::getTimeFactor();
     158    }
    157159}
  • code/branches/pickup2/src/orxonox/gamestates/GSRoot.h

    r5929 r6412  
    5151        void setTimeFactor(float factor);
    5252        void pause();
    53         float getTimeFactor() { return this->timeFactor_; }
     53        float getTimeFactor();
    5454
    5555    private:
    56         float                 timeFactor_;              //!< A factor that sets the gamespeed. 1 is normal.
    5756        bool                  bPaused_;
    5857        float                 timeFactorPauseBackup_;
  • code/branches/pickup2/src/orxonox/gamestates/GSServer.cc

    r5929 r6412  
    3030
    3131#include "util/Debug.h"
    32 #include "core/CommandLine.h"
     32#include "core/CommandLineParser.h"
    3333#include "core/Game.h"
    3434#include "core/GameMode.h"
     
    3737namespace orxonox
    3838{
    39     DeclareGameState(GSServer, "server", false, true);
     39    DeclareGameState(GSServer, "server", false, false);
    4040
    4141    SetCommandLineArgument(port, 55556).shortcut("p").information("Network communication port to be used 0-65535 (default: 55556)");
     
    5555        GameMode::setHasServer(true);
    5656
    57         this->server_ = new Server(CommandLine::getValue("port"));
     57        this->server_ = new Server(CommandLineParser::getValue("port"));
    5858        COUT(0) << "Loading scene in server mode" << std::endl;
    5959
Note: See TracChangeset for help on using the changeset viewer.