diff options
| author | Petr Mrázek | 2012-05-19 18:37:02 +0200 |
|---|---|---|
| committer | Petr Mrázek | 2012-05-19 18:37:02 +0200 |
| commit | b8ce3b45e128deb6aac01b4bce44e6bad2ea2f9a (patch) | |
| tree | 9d245807f151d5b2f24cba40533e79bdbf691db2 /plugins/liquids.cpp | |
| parent | ba45ac42c204f2ab6b50c01531e72fcf68c32a7c (diff) | |
| parent | f3ca3addbf4b842ceef567837edf768646ce07e7 (diff) | |
| download | dfhack-b8ce3b45e128deb6aac01b4bce44e6bad2ea2f9a.tar.gz dfhack-b8ce3b45e128deb6aac01b4bce44e6bad2ea2f9a.tar.bz2 dfhack-b8ce3b45e128deb6aac01b4bce44e6bad2ea2f9a.tar.xz | |
Merge https://github.com/jaxad0127/dfhack
Diffstat (limited to 'plugins/liquids.cpp')
| -rw-r--r-- | plugins/liquids.cpp | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/plugins/liquids.cpp b/plugins/liquids.cpp index c4a92596..be826828 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,14 @@ 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; + command_result res = parseRectangle(out, commands, 1, commands.size(), + width, height, z_levels); + if (res != CR_OK) + { + return res; + } - 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) + if (width == 1 && height == 1 && z_levels == 1) { brushname = "point"; } |
