Skip to content

Commit b8ce3b4

Browse files
committed
2 parents ba45ac4 + f3ca3ad commit b8ce3b4

4 files changed

Lines changed: 171 additions & 80 deletions

File tree

README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,14 +825,15 @@ Or this:
825825

826826
This will hide previously revealed tiles (or show hidden with the 0 option).
827827

828-
Any paint or filter option can be disabled entirely by using the ANY keyword:
828+
Any paint or filter option (or the entire paint or filter) can be disabled entirely by using the ANY keyword:
829829

830830
::
831831

832832
paint hidden ANY
833833
paint shape ANY
834834
filter material any
835835
filter shape any
836+
filter any
836837

837838
You can use several different brushes for painting tiles:
838839
* Point. (point)

plugins/Brushes.h

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,85 @@ class FloodBrush : public Brush
206206
Core *c_;
207207
};
208208

209-
inline std::ostream &operator<<(std::ostream &stream, const Brush& brush) {
209+
command_result parseRectangle(color_ostream & out,
210+
vector<string> & input, int start, int end,
211+
int & width, int & height, int & zLevels,
212+
bool hasConsole = true)
213+
{
214+
int newWidth = 0, newHeight = 0, newZLevels = 0;
215+
216+
if (end > start + 1)
217+
{
218+
newWidth = atoi(input[start++].c_str());
219+
newHeight = atoi(input[start++].c_str());
220+
if (end > start) {
221+
newZLevels = atoi(input[start++].c_str());
222+
} else {
223+
newZLevels = 1; // So 'range w h' won't ask for it.
224+
}
225+
}
226+
227+
string command = "";
228+
std::stringstream str;
229+
CommandHistory hist;
230+
231+
if (newWidth < 1) {
232+
if (hasConsole) {
233+
Console &con = static_cast<Console&>(out);
234+
235+
str.str("");
236+
str << "Set range width <" << width << "> ";
237+
con.lineedit(str.str(), command, hist);
238+
hist.add(command);
239+
newWidth = command.empty() ? width : atoi(command.c_str());
240+
} else {
241+
return CR_WRONG_USAGE;
242+
}
243+
}
244+
245+
if (newHeight < 1) {
246+
if (hasConsole) {
247+
Console &con = static_cast<Console&>(out);
248+
249+
str.str("");
250+
str << "Set range height <" << height << "> ";
251+
con.lineedit(str.str(), command, hist);
252+
hist.add(command);
253+
newHeight = command.empty() ? height : atoi(command.c_str());
254+
} else {
255+
return CR_WRONG_USAGE;
256+
}
257+
}
258+
259+
if (newZLevels < 1) {
260+
if (hasConsole) {
261+
Console &con = static_cast<Console&>(out);
262+
263+
str.str("");
264+
str << "Set range z-levels <" << zLevels << "> ";
265+
con.lineedit(str.str(), command, hist);
266+
hist.add(command);
267+
newZLevels = command.empty() ? zLevels : atoi(command.c_str());
268+
} else {
269+
return CR_WRONG_USAGE;
270+
}
271+
}
272+
273+
width = newWidth < 1? 1 : newWidth;
274+
height = newHeight < 1? 1 : newHeight;
275+
zLevels = newZLevels < 1? 1 : newZLevels;
276+
277+
return CR_OK;
278+
}
279+
280+
inline std::ostream &operator<<(std::ostream &stream, const Brush& brush)
281+
{
210282
stream << brush.str();
211283
return stream;
212284
}
213285

214-
inline std::ostream &operator<<(std::ostream &stream, const Brush* brush) {
286+
inline std::ostream &operator<<(std::ostream &stream, const Brush* brush)
287+
{
215288
stream << brush->str();
216289
return stream;
217290
}

plugins/liquids.cpp

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,27 @@ command_result df_liquids (color_ostream &out_, vector <string> & parameters)
107107
return CR_FAILURE;
108108
}
109109

110+
std::vector<std::string> commands;
110111
bool end = false;
111112

112113
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;
113114

114115
while(!end)
115116
{
116-
string command = "";
117+
string input = "";
117118

118119
std::stringstream str;
119120
str <<"[" << mode << ":" << brushname;
120121
if (brushname == "range")
121122
str << "(w" << width << ":h" << height << ":z" << z_levels << ")";
122123
str << ":" << amount << ":" << flowmode << ":" << setmode << "]#";
123-
if(out.lineedit(str.str(),command,liquids_hist) == -1)
124+
if(out.lineedit(str.str(),input,liquids_hist) == -1)
124125
return CR_FAILURE;
125-
liquids_hist.add(command);
126+
liquids_hist.add(input);
127+
128+
commands.clear();
129+
Core::cheap_tokenise(input, commands);
130+
string command = commands.empty() ? "" : commands[0];
126131

127132
if(command=="help" || command == "?")
128133
{
@@ -195,28 +200,14 @@ command_result df_liquids (color_ostream &out_, vector <string> & parameters)
195200
}
196201
else if(command == "range" || command == "r")
197202
{
198-
std::stringstream str;
199-
CommandHistory range_hist;
200-
str << " :set range width<" << width << "># ";
201-
out.lineedit(str.str(),command,range_hist);
202-
range_hist.add(command);
203-
width = command == "" ? width : atoi (command.c_str());
204-
if(width < 1) width = 1;
205-
206-
str.str("");
207-
str << " :set range height<" << height << "># ";
208-
out.lineedit(str.str(),command,range_hist);
209-
range_hist.add(command);
210-
height = command == "" ? height : atoi (command.c_str());
211-
if(height < 1) height = 1;
203+
command_result res = parseRectangle(out, commands, 1, commands.size(),
204+
width, height, z_levels);
205+
if (res != CR_OK)
206+
{
207+
return res;
208+
}
212209

213-
str.str("");
214-
str << " :set range z-levels<" << z_levels << "># ";
215-
out.lineedit(str.str(),command,range_hist);
216-
range_hist.add(command);
217-
z_levels = command == "" ? z_levels : atoi (command.c_str());
218-
if(z_levels < 1) z_levels = 1;
219-
if(width == 1 && height == 1 && z_levels == 1)
210+
if (width == 1 && height == 1 && z_levels == 1)
220211
{
221212
brushname = "point";
222213
}

0 commit comments

Comments
 (0)