diff options
| author | Jared Adams | 2012-04-19 21:13:07 -0600 |
|---|---|---|
| committer | Jared Adams | 2012-04-19 21:13:07 -0600 |
| commit | 52138d8998e38b6af550749ac7fd226a7bd86edd (patch) | |
| tree | 61f77061caa8a0f8843d5a0c776a494850643844 /plugins/liquids.cpp | |
| parent | f97e2bf4103cc09478220decd35c9732c10863aa (diff) | |
| download | dfhack-52138d8998e38b6af550749ac7fd226a7bd86edd.tar.gz dfhack-52138d8998e38b6af550749ac7fd226a7bd86edd.tar.bz2 dfhack-52138d8998e38b6af550749ac7fd226a7bd86edd.tar.xz | |
Improve the range function of tiletypes a bit and add the functionality to liquids.
Diffstat (limited to 'plugins/liquids.cpp')
| -rw-r--r-- | plugins/liquids.cpp | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/plugins/liquids.cpp b/plugins/liquids.cpp index 167e51ce..ff222126 100644 --- a/plugins/liquids.cpp +++ b/plugins/liquids.cpp @@ -107,22 +107,27 @@ command_result df_liquids (color_ostream &out_, vector <string> & parameters) return CR_FAILURE; } + std::vector<std::string> commands; bool end = false; out << "Welcome to the liquid spawner.\nType 'help' or '?' for a list of available commands, 'q' to quit.\nPress return after a command to confirm." << std::endl; while(!end) { - string command = ""; + string input = ""; std::stringstream str; str <<"[" << mode << ":" << brushname; if (brushname == "range") str << "(w" << width << ":h" << height << ":z" << z_levels << ")"; str << ":" << amount << ":" << flowmode << ":" << setmode << "]#"; - if(out.lineedit(str.str(),command,liquids_hist) == -1) + if(out.lineedit(str.str(),input,liquids_hist) == -1) return CR_FAILURE; - liquids_hist.add(command); + liquids_hist.add(input); + + commands.clear(); + Core::cheap_tokenise(input, commands); + string command = commands.empty() ? "" : commands[0]; if(command=="help" || command == "?") { @@ -195,28 +200,28 @@ command_result df_liquids (color_ostream &out_, vector <string> & parameters) } else if(command == "range" || command == "r") { - std::stringstream str; - CommandHistory range_hist; - str << " :set range width<" << width << "># "; - out.lineedit(str.str(),command,range_hist); - range_hist.add(command); - width = command == "" ? width : atoi (command.c_str()); - if(width < 1) width = 1; - - str.str(""); - str << " :set range height<" << height << "># "; - out.lineedit(str.str(),command,range_hist); - range_hist.add(command); - height = command == "" ? height : atoi (command.c_str()); - if(height < 1) height = 1; - - str.str(""); - str << " :set range z-levels<" << z_levels << "># "; - out.lineedit(str.str(),command,range_hist); - range_hist.add(command); - z_levels = command == "" ? z_levels : atoi (command.c_str()); - if(z_levels < 1) z_levels = 1; - if(width == 1 && height == 1 && z_levels == 1) + int oldWidth = width, oldHeight = height, oldZLevels = z_levels; + width = height = z_levels = 0; + + if (commands.size() >= 3) + { + width = atoi(commands[1].c_str()); + height = atoi(commands[2].c_str()); + + if (commands.size() >= 4) { + z_levels = atoi(commands[3].c_str()); + } + } + + command_result res = parseRectangle(out, width, height, z_levels, + oldWidth, oldHeight, oldZLevels); + + if (res != CR_OK) + { + return res; + } + + if (width == 1 && height == 1 && z_levels == 1) { brushname = "point"; } |
