InputConfigDiag: Use "..." for complicated expressions

The full expression is quite often too big for a simple button
label, so encourage people to use the full editor to edit it.
This commit is contained in:
Jasper St. Pierre 2013-06-17 06:52:03 -04:00
parent 62281fbfde
commit c5c86d17dc
4 changed files with 32 additions and 2 deletions

View File

@ -238,8 +238,13 @@ void GamepadPage::UpdateGUI()
// buttons // buttons
std::vector<ControlButton*>::const_iterator i = (*g)->control_buttons.begin() std::vector<ControlButton*>::const_iterator i = (*g)->control_buttons.begin()
, e = (*g)->control_buttons.end(); , e = (*g)->control_buttons.end();
for (; i!=e; ++i) for (; i!=e; ++i) {
(*i)->SetLabel(StrToWxStr((*i)->control_reference->expression)); ControllerInterface::ControlReference *r = (*i)->control_reference;
if (r->IsComplicated())
(*i)->SetLabel("...");
else
(*i)->SetLabel(StrToWxStr((*i)->control_reference->expression));
}
// cboxes // cboxes
std::vector<PadSetting*>::const_iterator si = (*g)->options.begin() std::vector<PadSetting*>::const_iterator si = (*g)->options.begin()

View File

@ -73,6 +73,13 @@ public:
return 0; return 0;
} }
bool IsComplicated() {
if (parsed_expression)
return parsed_expression->is_complicated;
else
return false;
}
protected: protected:
ControlReference(const bool _is_input) : range(1), is_input(_is_input), parsed_expression(NULL) {} ControlReference(const bool _is_input) : range(1), is_input(_is_input), parsed_expression(NULL) {}
ciface::ExpressionParser::Expression *parsed_expression; ciface::ExpressionParser::Expression *parsed_expression;

View File

@ -209,6 +209,7 @@ public:
virtual ~ExpressionNode() {} virtual ~ExpressionNode() {}
virtual ControlState GetValue() { return 0; } virtual ControlState GetValue() { return 0; }
virtual void SetValue(ControlState state) {} virtual void SetValue(ControlState state) {}
virtual bool IsComplicated() { return false; }
virtual operator std::string() { return ""; } virtual operator std::string() { return ""; }
}; };
@ -230,6 +231,11 @@ public:
control->ToOutput()->SetState(value); control->ToOutput()->SetState(value);
} }
virtual bool IsComplicated()
{
return false;
}
virtual operator std::string() virtual operator std::string()
{ {
return "`" + (std::string)qualifier + "`"; return "`" + (std::string)qualifier + "`";
@ -276,6 +282,11 @@ public:
rhs->SetValue(value); rhs->SetValue(value);
} }
virtual bool IsComplicated()
{
return true;
}
virtual operator std::string() virtual operator std::string()
{ {
return OpName(op) + "(" + (std::string)(*lhs) + ", " + (std::string)(*rhs) + ")"; return OpName(op) + "(" + (std::string)(*lhs) + ", " + (std::string)(*rhs) + ")";
@ -318,6 +329,11 @@ public:
} }
} }
virtual bool IsComplicated()
{
return true;
}
virtual operator std::string() virtual operator std::string()
{ {
return OpName(op) + "(" + (std::string)(*inner) + ")"; return OpName(op) + "(" + (std::string)(*inner) + ")";
@ -361,6 +377,7 @@ public:
expr = new Expression(); expr = new Expression();
expr->expr = expr_node; expr->expr = expr_node;
expr->num_controls = CountNumControls(); expr->num_controls = CountNumControls();
expr->is_complicated = expr_node->IsComplicated();
*expr_out = expr; *expr_out = expr;
return EXPRESSION_PARSE_SUCCESS; return EXPRESSION_PARSE_SUCCESS;

View File

@ -53,6 +53,7 @@ public:
ControlState GetValue(); ControlState GetValue();
void SetValue (ControlState state); void SetValue (ControlState state);
int num_controls; int num_controls;
bool is_complicated;
private: private:
ExpressionNode *expr; ExpressionNode *expr;