Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.