1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

World creation button and dialog and functionality

This commit is contained in:
Perttu Ahola 2012-03-13 00:06:37 +02:00
parent 82073025cc
commit 591527d878
11 changed files with 492 additions and 87 deletions

View file

@ -46,7 +46,9 @@ SubgameSpec findSubgame(const std::string &id)
+ DIR_DELIM + id);
addon_paths.insert(user_server + DIR_DELIM + "addons"
+ DIR_DELIM + id);
return SubgameSpec(id, game_path, addon_paths);
// TODO: Read proper name from game_path/game.conf
std::string game_name = id;
return SubgameSpec(id, game_path, addon_paths, game_name);
}
std::set<std::string> getAvailableGameIds()
@ -69,6 +71,16 @@ std::set<std::string> getAvailableGameIds()
return gameids;
}
std::vector<SubgameSpec> getAvailableGames()
{
std::vector<SubgameSpec> specs;
std::set<std::string> gameids = getAvailableGameIds();
for(std::set<std::string>::const_iterator i = gameids.begin();
i != gameids.end(); i++)
specs.push_back(findSubgame(*i));
return specs;
}
#define LEGACY_GAMEID "mesetint"
std::string getWorldGameId(const std::string &world_path, bool can_be_legacy)
@ -132,4 +144,18 @@ std::vector<WorldSpec> getAvailableWorlds()
return worlds;
}
bool initializeWorld(const std::string &path, const std::string &gameid)
{
infostream<<"Initializing world at "<<path<<std::endl;
// Create world.mt if does not already exist
std::string worldmt_path = path + DIR_DELIM + "world.mt";
if(!fs::PathExists(worldmt_path)){
infostream<<"Creating world.mt ("<<worldmt_path<<")"<<std::endl;
fs::CreateAllDirs(path);
std::ofstream of(worldmt_path.c_str(), std::ios::binary);
of<<"gameid = "<<gameid<<"\n";
}
return true;
}