]> git.lizzy.rs Git - minetest.git/blobdiff - src/main.cpp
Remember selected world by path
[minetest.git] / src / main.cpp
index 01c9b2c5c287200b5b46008b0da01af70901a1c1..41cf583f5740c2bed78d1ca30dbb12040a3169a7 100644 (file)
@@ -70,6 +70,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "mods.h"
 #include "utility_string.h"
 #include "subgame.h"
+#include "quicktune.h"
 
 /*
        Settings.
@@ -1207,6 +1208,8 @@ int main(int argc, char *argv[])
        // The password entered during the menu screen,
        std::string password;
 
+       bool first_loop = true;
+
        /*
                Menu-game loop
        */
@@ -1242,16 +1245,18 @@ int main(int argc, char *argv[])
                        */
                        while(kill == false)
                        {
+                               // If skip_main_menu, only go through here once
+                               if(skip_main_menu && !first_loop){
+                                       kill = true;
+                                       break;
+                               }
+                               first_loop = false;
+                               
                                // Cursor can be non-visible when coming from the game
                                device->getCursorControl()->setVisible(true);
                                // Some stuff are left to scene manager when coming from the game
                                // (map at least?)
                                smgr->clear();
-                               // Reset or hide the debug gui texts
-                               /*guitext->setText(L"Minetest-c55");
-                               guitext2->setVisible(false);
-                               guitext_info->setVisible(false);
-                               guitext_chat->setVisible(false);*/
                                
                                // Initialize menu data
                                MainMenuData menudata;
@@ -1272,14 +1277,27 @@ int main(int argc, char *argv[])
                                                i != worldspecs.end(); i++)
                                        menudata.worlds.push_back(narrow_to_wide(
                                                        i->name + " [" + i->gameid + "]"));
-                               // Select if there is only one
-                               if(worldspecs.size() == 1)
+                               // Default to selecting nothing
+                               menudata.selected_world = -1;
+                               // If there is only one world, select it
+                               if(worldspecs.size() == 1){
                                        menudata.selected_world = 0;
-                               else
-                                       menudata.selected_world = -1;
+                               }
+                               // Otherwise try to select according to selected_world_path
+                               else if(g_settings->exists("selected_world_path")){
+                                       std::string trypath = g_settings->get("selected_world_path");
+                                       for(u32 i=0; i<worldspecs.size(); i++){
+                                               if(worldspecs[i].path == trypath){
+                                                       menudata.selected_world = i;
+                                                       break;
+                                               }
+                                       }
+                               }
                                // If a world was commanded, append and select it
                                if(commanded_world != ""){
-                                       std::string gameid = getWorldGameId(commanded_world);
+                                       std::string gameid = getWorldGameId(commanded_world, true);
+                                       if(gameid == "")
+                                               gameid = g_settings->get("default_game");
                                        WorldSpec spec(commanded_world, "[commanded world]", gameid);
                                        worldspecs.push_back(spec);
                                        menudata.worlds.push_back(narrow_to_wide(spec.name)
@@ -1383,6 +1401,9 @@ int main(int argc, char *argv[])
                                g_settings->set("name", playername);
                                g_settings->set("address", address);
                                g_settings->set("port", itos(port));
+                               if(menudata.selected_world != -1)
+                                       g_settings->set("selected_world_path",
+                                                       worldspecs[menudata.selected_world].path);
                                // Update configuration file
                                if(configpath != "")
                                        g_settings->updateConfigFile(configpath.c_str());
@@ -1499,6 +1520,22 @@ int main(int argc, char *argv[])
        // Update configuration file
        if(configpath != "")
                g_settings->updateConfigFile(configpath.c_str());
+       
+       // Print modified quicktune values
+       {
+               bool header_printed = false;
+               std::vector<std::string> names = getQuicktuneNames();
+               for(u32 i=0; i<names.size(); i++){
+                       QuicktuneValue val = getQuicktuneValue(names[i]);
+                       if(!val.modified)
+                               continue;
+                       if(!header_printed){
+                               dstream<<"Modified quicktune values:"<<std::endl;
+                               header_printed = true;
+                       }
+                       dstream<<names[i]<<" = "<<val.getString()<<std::endl;
+               }
+       }
 
        END_DEBUG_EXCEPTION_HANDLER(errorstream)