Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3036 for code/trunk


Ignore:
Timestamp:
May 24, 2009, 2:39:16 AM (16 years ago)
Author:
bknecht
Message:

we do now save what level you chose last time and will preselect it for you on restart ;-). Of course you can still use —level or -l to choose your level in the old way.

Location:
code/trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/core/CMakeLists.txt

    r2896 r3036  
    6767
    6868GENERATE_SOURCE_GROUPS(${CORE_FILES})
    69 GENERATE_TOLUA_BINDINGS(Core CORE_FILES INPUTFILES LuaBind.h CommandExecutor.h)
     69GENERATE_TOLUA_BINDINGS(Core CORE_FILES INPUTFILES LuaBind.h CommandExecutor.h Game.h)
    7070
    7171ADD_LIBRARY(core SHARED ${CORE_FILES})
  • code/trunk/src/core/Game.cc

    r2927 r3036  
    122122        SetConfigValue(statisticsAvgLength_, 1000000)
    123123            .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
     124        SetConfigValue(levelName_, "presentation_dm.oxw")
     125            .description("Sets the preselection of the level in the main menu.");
     126    }
     127
     128    void Game::setLevel(std::string levelName)
     129    {
     130        ModifyConfigValue(levelName_, set, levelName);
     131    }
     132
     133    const std::string& Game::getLevel()
     134    {
     135        std::string levelName;
     136        CommandLine::getValue("level", &levelName);
     137        if (levelName == "")
     138            return levelName_;
     139        else
     140            return levelName;
    124141    }
    125142
  • code/trunk/src/core/Game.h

    r2946 r3036  
    4646    static bool MACRO_CONCATENATE(bGameStateDummy_##classname, __LINE__) = orxonox::Game::addGameState(new classname(name))
    4747
     48// tolua_begin
    4849namespace orxonox
    4950{
     
    5253        Main class responsible for running the game.
    5354    */
    54     class _CoreExport Game : public OrxonoxClass
     55    class _CoreExport Game
     56    // tolua_end
     57        : public OrxonoxClass
     58    // tolua_begin
    5559    {
     60    //tolua_end
    5661    public:
    5762        Game(int argc, char** argv);
     
    7883        static bool addGameState(GameState* state);
    7984        static void destroyStates();
    80         static Game& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
     85        static Game& getInstance() { assert(singletonRef_s); return *singletonRef_s; } //tolua_export
     86
     87        void setLevel(std::string levelName); //tolua_export
     88        const std::string& getLevel(); //tolua_export
    8189
    8290    private:
     
    114122        unsigned int                    statisticsRefreshCycle_;
    115123        unsigned int                    statisticsAvgLength_;
     124        std::string                     levelName_;
    116125
    117126        static std::map<std::string, GameState*> allStates_s;
    118127        static Game* singletonRef_s;        //!< Pointer to the Singleton
     128        // tolua_begin
    119129    };
    120130}
    121 
     131//tolua_end
    122132#endif /* _Game_H__ */
  • code/trunk/src/orxonox/gamestates/GSLevel.cc

    r3008 r3036  
    5858    AddGameState(GSLevel, "level");
    5959
    60     SetCommandLineArgument(level, "presentation_dm.oxw").shortcut("l");
     60    SetCommandLineArgument(level, "").shortcut("l");
    6161    SetConsoleCommand(GSLevel, showIngameGUI, true);
    62     SetConsoleCommand(GSLevel, setLevel, true);
    6362
    6463    XMLFile* GSLevel::startFile_s = NULL;
     
    254253        COUT(0) << "Loading level..." << std::endl;
    255254        std::string levelName;
    256         if (!startFile_s)
    257         {
    258             CommandLine::getValue("level", &levelName);
     255        CommandLine::getValue("level", &levelName);
     256        if (levelName == "")
     257            startFile_s = new XMLFile(Core::getMediaPathString() + "levels" + '/' + Game::getInstance().getLevel());
     258        else
    259259            startFile_s = new XMLFile(Core::getMediaPathString() + "levels" + '/' + levelName);
    260         }
    261260        Loader::open(startFile_s);
    262     }
    263 
    264     void GSLevel::setLevel(std::string levelName)
    265     {
    266         delete GSLevel::startFile_s;
    267         GSLevel::startFile_s = new XMLFile(Core::getMediaPathString() + "levels" + '/' + levelName);
    268261    }
    269262
Note: See TracChangeset for help on using the changeset viewer.