Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7876


Ignore:
Timestamp:
Feb 13, 2011, 5:49:41 PM (13 years ago)
Author:
dafrick
Message:

Extending startGame and similar console commands, now also the level to be started (or in case of startClient, the destination) can be specified (but doesn't have to).
Additionally startMainMenu is now in GSLevel and can only be executed in a Level, as opposed to only in the MainMenu as it was before.
Added changeGame console command which works in a level in standalone mode to change to a different level.

Location:
code/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/data/gui/scripts/HostMenu.lua

    r7689 r7876  
    104104        local level = P.levelList[index+1]
    105105        if level ~= nil then
    106             orxonox.LevelManager:getInstance():setDefaultLevel(level:getXMLFilename())
    107             orxonox.execute(P.multiplayerMode)
     106            orxonox.execute(P.multiplayerMode .. " " .. level:getXMLFilename())
    108107            hideAllMenuSheets()
    109108        end
  • code/trunk/data/gui/scripts/MultiplayerMenu.lua

    r7801 r7876  
    7575
    7676function P.MultiplayerJoinButton_clicked(e)
    77     local choice = winMgr:getWindow("orxonox/MultiplayerListbox"):getFirstSelectedItem()   
     77    local choice = winMgr:getWindow("orxonox/MultiplayerListbox"):getFirstSelectedItem()
     78    local destination = nil
    7879    if choice then
    79         local client = orxonox.Client:getInstance()
    8080        local index = tolua.cast(choice, "CEGUI::ListboxItem"):getID()
    81         client:setDestination( P.serverList[index][2], 55556 )
     81        destination = P.serverList[index][2]
    8282    else
    8383        return
    8484    end
    85     orxonox.execute("startClient")
     85    orxonox.execute("startClient " .. destination)
    8686    hideAllMenuSheets()
    8787end
  • code/trunk/data/gui/scripts/SingleplayerMenu.lua

    r7689 r7876  
    7474        local level = P.levelList[index+1]
    7575        if level ~= nil then
    76             orxonox.LevelManager:getInstance():setDefaultLevel(level:getXMLFilename())
    77             orxonox.execute("startGame")
     76            orxonox.execute("startGame " .. level:getXMLFilename())
    7877            hideAllMenuSheets()
    7978        end
  • code/trunk/src/libraries/core/GUIManager.cc

    r7874 r7876  
    6262#include "Core.h"
    6363#include "CoreIncludes.h"
     64#include "Game.h"
    6465#include "GraphicsManager.h"
    6566#include "LuaState.h"
     
    522523            this->mouseLeft();
    523524    }
     525
    524526}
  • code/trunk/src/orxonox/gamestates/GSLevel.cc

    r7870 r7876  
    5151    DeclareGameState(GSLevel, "level", false, false);
    5252
     53    static const std::string __CC_startMainMenu_name = "startMainMenu";
     54    static const std::string __CC_changeGame_name = "changeGame";
     55
     56    SetConsoleCommand(__CC_startMainMenu_name, &GSLevel::startMainMenu).deactivate();
     57    SetConsoleCommand(__CC_changeGame_name, &GSLevel::changeGame).defaultValues(BLANKSTRING).deactivate();
     58
    5359    GSLevel::GSLevel(const GameStateInfo& info)
    5460        : GameState(info)
     
    94100            // connect the HumanPlayer to the game
    95101            PlayerManager::getInstance().clientConnected(0);
    96         }
     102
     103            ModifyConsoleCommand(__CC_startMainMenu_name).activate();
     104        }
     105
     106        if (GameMode::isStandalone())
     107            ModifyConsoleCommand(__CC_changeGame_name).activate();
    97108    }
    98109
     
    121132            InputManager::getInstance().destroyState("guiKeysOnly");
    122133            InputManager::getInstance().destroyState("guiMouseOnly");
    123         }
     134
     135            ModifyConsoleCommand(__CC_startMainMenu_name  ).deactivate();
     136        }
     137
     138        if (GameMode::isStandalone())
     139            ModifyConsoleCommand(__CC_changeGame_name).deactivate();
    124140    }
    125141
     
    166182            COUT(3) << " Try harder!" << std::endl;
    167183    }
     184
     185    /**
     186    @brief
     187        Starts the MainMenu.
     188    */
     189    /*static*/ void GSLevel::startMainMenu(void)
     190    {
     191        // HACK
     192        Game::getInstance().popState();
     193        Game::getInstance().popState();
     194    }
     195
     196    /**
     197    @brief
     198        Terminates the current game and starts a new game.
     199    @param level
     200        The filename of the level to be started.
     201    */
     202    /*static*/ void GSLevel::changeGame(const std::string& level)
     203    {
     204        if(level != BLANKSTRING)
     205            LevelManager::getInstance().setDefaultLevel(level);
     206
     207        // HACK
     208        Game::getInstance().popState();
     209        Game::getInstance().popState();
     210        Game::getInstance().requestStates("standalone, level");
     211    }
    168212}
  • code/trunk/src/orxonox/gamestates/GSLevel.h

    r6417 r7876  
    4949        void update(const Clock& time);
    5050
     51        static void startMainMenu(void); //!< Starts the MainMenu
     52        static void changeGame(const std::string& level); //!< Terminates the current game and starts a new game.
     53
    5154    protected:
    5255        void loadLevel();
  • code/trunk/src/orxonox/gamestates/GSMainMenu.cc

    r7854 r7876  
    3131#include <OgreSceneManager.h>
    3232
    33 #include "core/input/KeyBinderManager.h"
    34 #include "core/Game.h"
    3533#include "core/ConfigValueIncludes.h"
    3634#include "core/CoreIncludes.h"
     35#include "core/Game.h"
    3736#include "core/GraphicsManager.h"
    3837#include "core/GUIManager.h"
    3938#include "core/command/ConsoleCommand.h"
     39#include "core/input/KeyBinderManager.h"
     40#include "network/Client.h"
     41#include "util/StringUtils.h"
     42#include "LevelManager.h"
    4043#include "Scene.h"
    4144#include "sound/AmbientSound.h"
     
    5255    static const std::string __CC_startClient_name          = "startClient";
    5356    static const std::string __CC_startDedicated_name       = "startDedicated";
    54     static const std::string __CC_startMainMenu_name        = "startMainMenu";
    5557    static const std::string __CC_setMainMenuSoundPath_name = "setMMSoundPath";
    5658
    57     SetConsoleCommand(__CC_startStandalone_name,      &GSMainMenu::startStandalone).deactivate();
    58     SetConsoleCommand(__CC_startServer_name,          &GSMainMenu::startServer    ).deactivate();
    59     SetConsoleCommand(__CC_startClient_name,          &GSMainMenu::startClient    ).deactivate();
    60     SetConsoleCommand(__CC_startDedicated_name,       &GSMainMenu::startDedicated ).deactivate();
    61     SetConsoleCommand(__CC_startMainMenu_name,        &GSMainMenu::startMainMenu  ).deactivate();
     59    SetConsoleCommand(__CC_startStandalone_name,      &GSMainMenu::startStandalone).defaultValues(BLANKSTRING).deactivate();
     60    SetConsoleCommand(__CC_startServer_name,          &GSMainMenu::startServer    ).defaultValues(BLANKSTRING).deactivate();
     61    SetConsoleCommand(__CC_startClient_name,          &GSMainMenu::startClient    ).defaultValues(BLANKSTRING).deactivate();
     62    SetConsoleCommand(__CC_startDedicated_name,       &GSMainMenu::startDedicated ).defaultValues(BLANKSTRING).deactivate();
    6263    SetConsoleCommand(__CC_setMainMenuSoundPath_name, &GSMainMenu::setMainMenuSoundPath).hide();
    6364
     
    106107        ModifyConsoleCommand(__CC_startClient_name    ).activate();
    107108        ModifyConsoleCommand(__CC_startDedicated_name ).activate();
    108         ModifyConsoleCommand(__CC_startMainMenu_name  ).activate();
    109109        ModifyConsoleCommand(__CC_setMainMenuSoundPath_name).setObject(this);
    110110
     
    138138        ModifyConsoleCommand(__CC_startClient_name    ).deactivate();
    139139        ModifyConsoleCommand(__CC_startDedicated_name ).deactivate();
    140         ModifyConsoleCommand(__CC_startMainMenu_name  ).deactivate();
    141140        ModifyConsoleCommand(__CC_setMainMenuSoundPath_name).setObject(0);
    142141    }
     
    171170    }
    172171
    173     void GSMainMenu::startStandalone()
    174     {
    175         // HACK - HACK
     172    /**
     173    @brief
     174        Start a level in standalone mode.
     175    @param level
     176        The filename of the level to be started. If empty, the default level is started.
     177    */
     178    void GSMainMenu::startStandalone(const std::string& level)
     179    {
     180        if(level != BLANKSTRING)
     181            LevelManager::getInstance().setDefaultLevel(level);
     182
     183        // HACK
    176184        Game::getInstance().popState();
    177185        Game::getInstance().requestStates("standalone, level");
    178186    }
    179187
    180     void GSMainMenu::startServer()
    181     {
    182         // HACK - HACK
     188    /**
     189    @brief
     190        Start a level in server mode.
     191    @param level
     192        The filename of the level to be started. If empty, the default level is started.
     193    */
     194    void GSMainMenu::startServer(const std::string& level)
     195    {
     196        if(level != BLANKSTRING)
     197            LevelManager::getInstance().setDefaultLevel(level);
     198
     199        // HACK
    183200        Game::getInstance().popState();
    184201        Game::getInstance().requestStates("server, level");
    185202    }
    186203
    187     void GSMainMenu::startClient()
    188     {
    189         // HACK - HACK
     204    /**
     205    @brief
     206        Connect to a game as client.
     207    @param destination
     208        The destination to connect to. If empty, the client connects to the default destination.
     209    */
     210    void GSMainMenu::startClient(const std::string& destination)
     211    {
     212        if(destination != BLANKSTRING)
     213            Client::getInstance()->setDestination(destination, NETWORK_PORT);
     214
     215        // HACK
    190216        Game::getInstance().popState();
    191217        Game::getInstance().requestStates("client, level");
    192218    }
    193219
    194     void GSMainMenu::startDedicated()
    195     {
    196         // HACK - HACK
     220    /**
     221    @brief
     222        Start a level in dedicated mode.
     223    @param level
     224        The filename of the level to be started. If empty, the default level is started.
     225    */
     226    void GSMainMenu::startDedicated(const std::string& level)
     227    {
     228        if(level != BLANKSTRING)
     229            LevelManager::getInstance().setDefaultLevel(level);
     230
     231        // HACK
    197232        Game::getInstance().popState();
    198233        Game::getInstance().popState();
    199234        Game::getInstance().requestStates("server, level");
    200235    }
    201     void GSMainMenu::startMainMenu()
    202     {
    203         // HACK - HACK
    204         Game::getInstance().popState();
    205         Game::getInstance().popState();
    206         Game::getInstance().requestStates("mainmenu");
    207     }
     236
    208237}
  • code/trunk/src/orxonox/gamestates/GSMainMenu.h

    r6746 r7876  
    5353        void setMainMenuSoundPath(const std::string& path);
    5454
    55         static void startStandalone();
    56         static void startServer();
    57         static void startClient();
    58         static void startDedicated();
    59         static void startMainMenu();
     55        static void startStandalone(const std::string& level = BLANKSTRING); //!< Start a level in standalone mode.
     56        static void startServer(const std::string& level = BLANKSTRING); //!< Start a level in server mode.
     57        static void startClient(const std::string& destination = BLANKSTRING); //!< Connect to a game as client.
     58        static void startDedicated(const std::string& level = BLANKSTRING); //!< Start a level in dedicated mode.
    6059        static void startIOConsole();
    6160
Note: See TracChangeset for help on using the changeset viewer.