|
|
@ -197,47 +197,72 @@ private:
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
command_result parseRectangle(color_ostream & out,
|
|
|
|
command_result parseRectangle(color_ostream & out,
|
|
|
|
|
|
|
|
vector<string> & input, int start, int end,
|
|
|
|
int & width, int & height, int & zLevels,
|
|
|
|
int & width, int & height, int & zLevels,
|
|
|
|
int oldWidth, int oldHeight, int oldZLevels,
|
|
|
|
|
|
|
|
bool hasConsole = true)
|
|
|
|
bool hasConsole = true)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
out << "Parse:" << endl
|
|
|
|
int newWidth = 0, newHeight = 0, newZLevels = 1;
|
|
|
|
<< "\tW:" << width << " - " << oldWidth << endl
|
|
|
|
// z is different so 'range w h' won't ask for it.
|
|
|
|
<< "\tW:" << height << " - " << oldHeight << endl
|
|
|
|
|
|
|
|
<< "\tW:" << zLevels << " - " << oldZLevels << endl
|
|
|
|
if (end > start + 1)
|
|
|
|
<< "Console: " << hasConsole << endl;
|
|
|
|
{
|
|
|
|
if (width < 1 || height < 1) {
|
|
|
|
newWidth = atoi(input[start++].c_str());
|
|
|
|
|
|
|
|
newHeight = atoi(input[start++].c_str());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (end > start) {
|
|
|
|
|
|
|
|
newZLevels = atoi(input[start++].c_str());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string command = "";
|
|
|
|
|
|
|
|
std::stringstream str;
|
|
|
|
|
|
|
|
CommandHistory hist;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (newWidth < 1) {
|
|
|
|
if (hasConsole) {
|
|
|
|
if (hasConsole) {
|
|
|
|
string command = "";
|
|
|
|
|
|
|
|
std::stringstream str;
|
|
|
|
|
|
|
|
Console &con = static_cast<Console&>(out);
|
|
|
|
Console &con = static_cast<Console&>(out);
|
|
|
|
CommandHistory hist;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
str.str("");
|
|
|
|
str.str("");
|
|
|
|
str << "Set range width <" << oldWidth << "> ";
|
|
|
|
str << "Set range width <" << width << "> ";
|
|
|
|
con.lineedit(str.str(), command, hist);
|
|
|
|
con.lineedit(str.str(), command, hist);
|
|
|
|
hist.add(command);
|
|
|
|
hist.add(command);
|
|
|
|
width = command == "" ? oldWidth : atoi(command.c_str());
|
|
|
|
newWidth = command == "" ? width : atoi(command.c_str());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (newHeight < 1) {
|
|
|
|
|
|
|
|
if (hasConsole) {
|
|
|
|
|
|
|
|
Console &con = static_cast<Console&>(out);
|
|
|
|
|
|
|
|
|
|
|
|
str.str("");
|
|
|
|
str.str("");
|
|
|
|
str << "Set range height <" << oldHeight << "> ";
|
|
|
|
str << "Set range height <" << height << "> ";
|
|
|
|
con.lineedit(str.str(), command, hist);
|
|
|
|
con.lineedit(str.str(), command, hist);
|
|
|
|
hist.add(command);
|
|
|
|
hist.add(command);
|
|
|
|
height = command == "" ? oldHeight : atoi(command.c_str());
|
|
|
|
newHeight = command == "" ? height : atoi(command.c_str());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (newZLevels < 1) {
|
|
|
|
|
|
|
|
if (hasConsole) {
|
|
|
|
|
|
|
|
Console &con = static_cast<Console&>(out);
|
|
|
|
|
|
|
|
|
|
|
|
str.str("");
|
|
|
|
str.str("");
|
|
|
|
str << "Set range z-levels <" << oldZLevels << "> ";
|
|
|
|
str << "Set range z-levels <" << zLevels << "> ";
|
|
|
|
con.lineedit(str.str(), command, hist);
|
|
|
|
con.lineedit(str.str(), command, hist);
|
|
|
|
hist.add(command);
|
|
|
|
hist.add(command);
|
|
|
|
zLevels = command == "" ? oldZLevels : atoi(command.c_str());
|
|
|
|
newZLevels = command == "" ? zLevels : atoi(command.c_str());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
width = width < 1? 1 : width;
|
|
|
|
width = newWidth < 1? 1 : newWidth;
|
|
|
|
height = height < 1? 1 : height;
|
|
|
|
height = newHeight < 1? 1 : newHeight;
|
|
|
|
zLevels = zLevels < 1? 1 : zLevels;
|
|
|
|
zLevels = newZLevels < 1? 1 : zLevels;
|
|
|
|
|
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|