From 9994286c055cbc33a6cc76af2ccfb64cb3b11ac0 Mon Sep 17 00:00:00 2001 From: KKyang Date: Thu, 17 Dec 2015 13:01:30 +0800 Subject: [PATCH] Update for new cave configure. --- ioworldgenoverridelua.cpp | 57 ++++++++- template/worldgenoverride_world.lua | 173 +++++++++++++++------------- 2 files changed, 148 insertions(+), 82 deletions(-) diff --git a/ioworldgenoverridelua.cpp b/ioworldgenoverridelua.cpp index b705702..31aa654 100644 --- a/ioworldgenoverridelua.cpp +++ b/ioworldgenoverridelua.cpp @@ -25,10 +25,45 @@ bool IOWorldGenOverrideLua::readLuaFile(std::vector &PV, std::vector QString msg; msg = file.readLine(); msg = msg.trimmed(); - if(msg.indexOf("override_enabled = true,") > -1) + if(msg.indexOf("preset = ") > -1) { - while(!file.atEnd()) + if(msg.contains("preset = ")) { + properties P; + P.group = "Overall"; + P.name = "preset"; + P.settings = msg.split("--")[0].split('=')[1].replace(" ","").replace('"',"").replace(',',""); + PV.push_back(P); + + std::vector select; + if(msg.indexOf(QString("-- ")) > 0) + { + msg = msg.split("-- ")[msg.split("-- ").size() - 1]; +#ifdef QT_DEBUG + qDebug() << msg; +#endif + msg = msg.split(":")[msg.split(":").size() - 1]; +#ifdef QT_DEBUG + qDebug() << msg; +#endif + QStringList inGroupData = msg.split(","); + for(int i = 0; i < inGroupData.size(); i++) + { + select.push_back(inGroupData[i].replace(" ","").replace('"',"")); + } + } + else + { + select.push_back("never"); + select.push_back("rare"); + select.push_back("default"); + select.push_back("often"); + select.push_back("always"); + } + IV.push_back(select); + } + while(!file.atEnd()) + { QString data = file.readLine().trimmed(); QString segment = data.split("--")[0]; if(segment.indexOf('{') > -1) @@ -117,9 +152,23 @@ bool IOWorldGenOverrideLua::writeLuaFile(std::vector &PV, std::vecto stream << "return{\n\n"; stream << " override_enabled = true,\n"; + properties &pp = PV[0]; + std::vector &sss = IV[0]; + stream << " preset = " << pp.settings << ", -- "; + QString show; + for(int j = 0; j < sss.size(); j++) + { + show = show + QString('"') + sss[j] + QString('"'); + if(j == sss.size() - 1) + { + break; + } + show = show + QString(", "); + } + stream << show << "\n"; QString last_group_name; - for(int i = 0; i < PV.size(); i++) + for(int i = 1; i < PV.size(); i++) { properties &p = PV[i]; std::vector &ss = IV[i]; @@ -132,7 +181,7 @@ bool IOWorldGenOverrideLua::writeLuaFile(std::vector &PV, std::vecto if(p.group.compare("misc")) { stream << " " << p.group << " = { -- "; - QString show; + show.clear(); for(int j = 0; j < ss.size(); j++) { show = show + QString('"') + ss[j] + QString('"'); diff --git a/template/worldgenoverride_world.lua b/template/worldgenoverride_world.lua index a0dc706..f5b10bf 100644 --- a/template/worldgenoverride_world.lua +++ b/template/worldgenoverride_world.lua @@ -1,80 +1,97 @@ return { - - override_enabled = true, - unprepared = { -- "never", "rare", "default", "often", "always" - berrybush = "default", - cactus = "default", - carrot = "default", - mushroom = "default", - }, - misc = { - task_set = "default", -- Biomes: "default", "classic", "cave_default" - start_location = "default", -- Start: "default", "plus", "darkness", "caves" - autumn = "default", -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random" - boons = "default", -- "never", "rare", "default", "often", "always" - branching = "default", -- "never", "least", "default", "most" - day = "default", -- "default", "longday", "longdusk", "longnight", "noday", "nodusk", "nonight", "onlyday", "onlydusk", "onlynight" - frograin = "default", -- "never", "rare", "default", "often", "always" - lightning = "default", -- "never", "rare", "default", "often", "always" - loop = "default", -- "never", "default", "always" - season_start = "default", -- "default", "winter", "spring", "summer", "random" - spring = "default", -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random" - summer = "default", -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random" - touchstone = "default", -- "never", "rare", "default", "often", "always" - weather = "default", -- "never", "rare", "default", "often", "always" - wildfires = "default", -- "never", "rare", "default", "often", "always" - winter = "default", -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random" - world_size = "default", -- "default", "medium", "large", "huge" - }, - animals = { -- "never", "rare", "default", "often", "always" - alternatehunt = "default", - angrybees = "default", - beefalo = "default", - beefaloheat = "default", - bees = "default", - birds = "default", - butterfly = "default", - buzzard = "default", - catcoon = "default", - frogs = "default", - hunt = "default", - lightninggoat = "default", - moles = "default", - penguins = "default", - perd = "default", - pigs = "default", - rabbits = "default", - tallbirds = "default", - }, - monsters = { -- "never", "rare", "default", "often", "always" - bearger = "default", - chess = "default", - deciduousmonster = "default", - deerclops = "default", - dragonfly = "default", - goosemoose = "default", - houndmound = "default", - hounds = "default", - krampus = "default", - liefs = "default", - lureplants = "default", - merm = "default", - spiders = "default", - tentacles = "default", - walrus = "default", - }, - resources = { -- "never", "rare", "default", "often", "always" - flint = "default", - flowers = "default", - grass = "default", - marshbush = "default", - meteorshowers = "default", - meteorspawner = "default", - reeds = "default", - rock = "default", - rock_ice = "default", - sapling = "default", - trees = "default", - tumbleweed = "default", - }, + override_enabled = true, + preset = SURVIVAL_TOGETHER, -- "SURVIVAL_TOGETHER", "SURVIVAL_TOGETHER_CLASSIC", "SURVIVAL_DEFAULT_PLUS", "COMPLETE_DARKNESS", "DST_CAVE" + unprepared = { -- "never", "rare", "default", "often", "always" + banana = "default", + berrybush = "default", + cactus = "default", + carrot = "default", + lichen = "default", + mushroom = "default", + }, + misc = { + autumn = "default", -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random" + boons = "default", -- "never", "rare", "default", "often", "always" + branching = "default", -- "never", "least", "default", "most" + cavelight = "default", -- "veryslow", "slow", "default", "fast", "veryfast" + day = "default", -- "default", "longday", "longdusk", "longnight", "noday", "nodusk", "nonight", "onlyday", "onlydusk", "onlynight" + earthquakes = "default", -- "never", "rare", "default", "often", "always" + frograin = "default", -- "never", "rare", "default", "often", "always" + lightning = "default", -- "never", "rare", "default", "often", "always" + loop = "default", -- "never", "default", "always" + regrowth = "default", -- "veryslow", "slow", "default", "fast", "veryfast" + season_start = "default", -- "default", "winter", "spring", "summer", "autumnorspring", "winterorsummer", "random" + spring = "default", -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random" + start_location = "default", -- "caves", "default", "plus", "darkness" + summer = "default", -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random" + task_set = "default", -- "classic", "default", "cave_default" + touchstone = "default", -- "never", "rare", "default", "often", "always" + weather = "default", -- "never", "rare", "default", "often", "always" + wildfires = "default", -- "never", "rare", "default", "often", "always" + winter = "default", -- "noseason", "veryshortseason", "shortseason", "default", "longseason", "verylongseason", "random" + world_size = "default", -- "small", "medium", "default", "huge" + }, + animals = { -- "never", "rare", "default", "often", "always" + alternatehunt = "default", + angrybees = "default", + beefalo = "default", + beefaloheat = "default", + bees = "default", + birds = "default", + bunnymen = "default", + butterfly = "default", + buzzard = "default", + catcoon = "default", + frogs = "default", + hunt = "default", + lightninggoat = "default", + moles = "default", + monkey = "default", + penguins = "default", + perd = "default", + pigs = "default", + rabbits = "default", + rocky = "default", + slurper = "default", + slurtles = "default", + tallbirds = "default", + }, + monsters = { -- "never", "rare", "default", "often", "always" + bats = "default", + bearger = "default", + chess = "default", + deciduousmonster = "default", + deerclops = "default", + dragonfly = "default", + fissure = "default", + goosemoose = "default", + houndmound = "default", + hounds = "default", + krampus = "default", + liefs = "default", + lureplants = "default", + merm = "default", + spiders = "default", + tentacles = "default", + walrus = "default", + worms = "default", + }, + resources = { -- "never", "rare", "default", "often", "always" + fern = "default", + flint = "default", + flower_cave = "default", + flowers = "default", + grass = "default", + marshbush = "default", + meteorshowers = "default", + meteorspawner = "default", + mushtree = "default", + reeds = "default", + rock = "default", + rock_ice = "default", + sapling = "default", + trees = "default", + tumbleweed = "default", + wormlights = "default", + }, } \ No newline at end of file