X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain.cpp;h=0d1961fff1de7fc5d3daf4b2de217558729d724b;hb=5a8ee4889d770bc512838bf965b7770c52d8b7f5;hp=73469471da4e8cc48b0d10c85bf91b0958002eb1;hpb=bcaab74f1f4cb8c9fcd65cc8cb8bd290834bf72f;p=minetest.git diff --git a/src/main.cpp b/src/main.cpp index 73469471d..0d1961fff 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -972,60 +972,29 @@ int main(int argc, char *argv[]) if(port == 0) port = 30000; - // Map directory - std::string world_path = porting::path_user + DIR_DELIM + "server" + DIR_DELIM + "worlds" + DIR_DELIM + "world"; + // World directory + std::string commanded_world = ""; if(cmd_args.exists("world")) - world_path = cmd_args.get("world"); + commanded_world = cmd_args.get("world"); else if(cmd_args.exists("map-dir")) - world_path = cmd_args.get("map-dir"); + commanded_world = cmd_args.get("map-dir"); else if(g_settings->exists("map-dir")) - world_path = g_settings->get("map-dir"); - else{ - // No map-dir option was specified. - // Check if the world is found from the default directory, and if - // not, see if the legacy world directory exists. - std::string legacy_world_path = porting::path_user+DIR_DELIM+".."+DIR_DELIM+"world"; - if(!fs::PathExists(world_path) && fs::PathExists(legacy_world_path)){ - errorstream<<"Warning: Using legacy world directory \"" - <get("map-dir"); - // Determine gameid - std::string gameid = ""; - if(cmd_args.exists("gameid")) - gameid = cmd_args.get("gameid"); - std::string world_gameid = getWorldGameId(world_path); - if(world_gameid == ""){ - if(gameid != "") - world_gameid = gameid; - else{ - world_gameid = "mesetint"; - } - } - if(gameid == "") - gameid = world_gameid; - else if(world_gameid != ""){ - if(world_gameid != gameid){ - errorstream<<"World gameid mismatch"<setColor(gui::EGDC_3D_SHADOW, video::SColor(0,0,0,0)); skin->setColor(gui::EGDC_3D_HIGH_LIGHT, video::SColor(255,0,0,0)); skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(255,0,0,0)); + skin->setColor(gui::EGDC_HIGH_LIGHT, video::SColor(255,70,100,50)); + skin->setColor(gui::EGDC_HIGH_LIGHT_TEXT, video::SColor(255,255,255,255)); /* GUI stuff @@ -1198,6 +1207,8 @@ int main(int argc, char *argv[]) // The password entered during the menu screen, std::string password; + bool first_loop = true; + /* Menu-game loop */ @@ -1223,6 +1234,9 @@ int main(int argc, char *argv[]) guiroot = guienv->addStaticText(L"", core::rect(0, 0, 10000, 10000)); + SubgameSpec gamespec; + WorldSpec worldspec; + /* Out-of-game menu loop. @@ -1230,30 +1244,54 @@ 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; menudata.address = narrow_to_wide(address); menudata.name = narrow_to_wide(playername); menudata.port = narrow_to_wide(itos(port)); + if(cmd_args.exists("password")) + menudata.password = narrow_to_wide(cmd_args.get("password")); menudata.fancy_trees = g_settings->getBool("new_style_leaves"); menudata.smooth_lighting = g_settings->getBool("smooth_lighting"); menudata.clouds_3d = g_settings->getBool("enable_3d_clouds"); menudata.opaque_water = g_settings->getBool("opaque_water"); menudata.creative_mode = g_settings->getBool("creative_mode"); menudata.enable_damage = g_settings->getBool("enable_damage"); - if(cmd_args.exists("password")) - menudata.password = narrow_to_wide(cmd_args.get("password")); + // Get world listing for the menu + std::vector worldspecs = getAvailableWorlds(); + for(std::vector::const_iterator i = worldspecs.begin(); + 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) + menudata.selected_world = 0; + else + menudata.selected_world = -1; + // If a world was commanded, append and select it + if(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) + +L" ["+narrow_to_wide(spec.gameid)+L"]"); + menudata.selected_world = menudata.worlds.size()-1; + } if(skip_main_menu == false) { @@ -1304,15 +1342,33 @@ int main(int argc, char *argv[]) infostream<<"Dropping main menu"<drop(); - - // Delete map if requested - if(menudata.delete_map) - { - bool r = fs::RecursiveDeleteContent(world_path); - if(r == false) - error_message = L"Delete failed"; + } + + // Set world path to selected one + if(menudata.selected_world != -1){ + worldspec = worldspecs[menudata.selected_world]; + infostream<<"Selected world: "<updateConfigFile(configpath.c_str()); - + + // If local game + if(address == "") + { + if(menudata.selected_world == -1){ + error_message = L"No world selected and no address " + L"provided. Nothing to do."; + errorstream<