Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
magcius committed Jun 25, 2013
1 parent 62281fb commit c5c86d1
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Source/Core/DolphinWX/Src/InputConfigDiag.cpp
Expand Up @@ -238,8 +238,13 @@ void GamepadPage::UpdateGUI()
// buttons
std::vector<ControlButton*>::const_iterator i = (*g)->control_buttons.begin()
, e = (*g)->control_buttons.end();
for (; i!=e; ++i)
(*i)->SetLabel(StrToWxStr((*i)->control_reference->expression));
for (; i!=e; ++i) {
ControllerInterface::ControlReference *r = (*i)->control_reference;
if (r->IsComplicated())
(*i)->SetLabel("...");
else
(*i)->SetLabel(StrToWxStr((*i)->control_reference->expression));
}

// cboxes
std::vector<PadSetting*>::const_iterator si = (*g)->options.begin()
Expand Down
Expand Up @@ -73,6 +73,13 @@ class ControllerInterface : public DeviceContainer
return 0;
}

bool IsComplicated() {
if (parsed_expression)
return parsed_expression->is_complicated;
else
return false;
}

protected:
ControlReference(const bool _is_input) : range(1), is_input(_is_input), parsed_expression(NULL) {}
ciface::ExpressionParser::Expression *parsed_expression;
Expand Down
Expand Up @@ -209,6 +209,7 @@ class ExpressionNode
virtual ~ExpressionNode() {}
virtual ControlState GetValue() { return 0; }
virtual void SetValue(ControlState state) {}
virtual bool IsComplicated() { return false; }
virtual operator std::string() { return ""; }
};

Expand All @@ -230,6 +231,11 @@ class ControlExpression : public ExpressionNode
control->ToOutput()->SetState(value);
}

virtual bool IsComplicated()
{
return false;
}

virtual operator std::string()
{
return "`" + (std::string)qualifier + "`";
Expand Down Expand Up @@ -276,6 +282,11 @@ class BinaryExpression : public ExpressionNode
rhs->SetValue(value);
}

virtual bool IsComplicated()
{
return true;
}

virtual operator std::string()
{
return OpName(op) + "(" + (std::string)(*lhs) + ", " + (std::string)(*rhs) + ")";
Expand Down Expand Up @@ -318,6 +329,11 @@ class UnaryExpression : public ExpressionNode
}
}

virtual bool IsComplicated()
{
return true;
}

virtual operator std::string()
{
return OpName(op) + "(" + (std::string)(*inner) + ")";
Expand Down Expand Up @@ -361,6 +377,7 @@ class Parser
expr = new Expression();
expr->expr = expr_node;
expr->num_controls = CountNumControls();
expr->is_complicated = expr_node->IsComplicated();
*expr_out = expr;

return EXPRESSION_PARSE_SUCCESS;
Expand Down
Expand Up @@ -53,6 +53,7 @@ class Expression
ControlState GetValue();
void SetValue (ControlState state);
int num_controls;
bool is_complicated;

private:
ExpressionNode *expr;
Expand Down

0 comments on commit c5c86d1

Please sign in to comment.