Merge pull request #5577 from ligfx/separateexpressionparsingandbinding
ControlReference/ExpressionParser: separate parsing from binding
This commit is contained in:
@@ -70,7 +70,7 @@
|
||||
#include "InputCommon/ControllerInterface/Device.h"
|
||||
#include "InputCommon/InputConfig.h"
|
||||
|
||||
using namespace ciface::ExpressionParser;
|
||||
using ciface::ExpressionParser::ParseStatus;
|
||||
|
||||
void InputConfigDialog::ConfigExtension(wxCommandEvent& event)
|
||||
{
|
||||
@@ -243,7 +243,7 @@ ControlButton::ControlButton(wxWindow* const parent, ControlReference* const _re
|
||||
m_configured_width(FromDIP(width))
|
||||
{
|
||||
if (label.empty())
|
||||
SetLabelText(StrToWxStr(_ref->expression));
|
||||
SetLabelText(StrToWxStr(_ref->GetExpression()));
|
||||
else
|
||||
SetLabel(StrToWxStr(label));
|
||||
}
|
||||
@@ -336,7 +336,7 @@ void ControlDialog::SelectControl(const std::string& name)
|
||||
void ControlDialog::UpdateGUI()
|
||||
{
|
||||
// update textbox
|
||||
textctrl->SetValue(StrToWxStr(control_reference->expression));
|
||||
textctrl->SetValue(StrToWxStr(control_reference->GetExpression()));
|
||||
|
||||
// updates the "bound controls:" label
|
||||
m_bound_label->SetLabel(
|
||||
@@ -347,11 +347,12 @@ void ControlDialog::UpdateGUI()
|
||||
case ParseStatus::SyntaxError:
|
||||
m_error_label->SetLabel(_("Syntax error"));
|
||||
break;
|
||||
case ParseStatus::NoDevice:
|
||||
m_error_label->SetLabel(_("Device not found"));
|
||||
case ParseStatus::Successful:
|
||||
m_error_label->SetLabel(control_reference->BoundCount() > 0 ? "" : _("Device not found"));
|
||||
break;
|
||||
default:
|
||||
case ParseStatus::EmptyExpression:
|
||||
m_error_label->SetLabel("");
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -364,7 +365,7 @@ void InputConfigDialog::UpdateGUI()
|
||||
{
|
||||
for (ControlButton* button : cgBox->control_buttons)
|
||||
{
|
||||
button->SetLabelText(StrToWxStr(button->control_reference->expression));
|
||||
button->SetLabelText(StrToWxStr(button->control_reference->GetExpression()));
|
||||
}
|
||||
|
||||
for (PadSetting* padSetting : cgBox->options)
|
||||
@@ -399,7 +400,7 @@ void InputConfigDialog::LoadDefaults(wxCommandEvent&)
|
||||
|
||||
bool ControlDialog::Validate()
|
||||
{
|
||||
control_reference->expression = WxStrToStr(textctrl->GetValue());
|
||||
control_reference->SetExpression(WxStrToStr(textctrl->GetValue()));
|
||||
|
||||
const auto lock = ControllerEmu::EmulatedController::GetStateLock();
|
||||
control_reference->UpdateReference(g_controller_interface,
|
||||
@@ -408,7 +409,7 @@ bool ControlDialog::Validate()
|
||||
UpdateGUI();
|
||||
|
||||
const auto parse_status = control_reference->GetParseStatus();
|
||||
return parse_status == ParseStatus::Successful || parse_status == ParseStatus::NoDevice;
|
||||
return parse_status == ParseStatus::Successful || parse_status == ParseStatus::EmptyExpression;
|
||||
}
|
||||
|
||||
void InputConfigDialog::SetDevice(wxCommandEvent&)
|
||||
@@ -438,7 +439,7 @@ void ControlDialog::SetDevice(wxCommandEvent&)
|
||||
|
||||
void ControlDialog::ClearControl(wxCommandEvent&)
|
||||
{
|
||||
control_reference->expression.clear();
|
||||
control_reference->SetExpression("");
|
||||
|
||||
const auto lock = ControllerEmu::EmulatedController::GetStateLock();
|
||||
control_reference->UpdateReference(g_controller_interface,
|
||||
@@ -497,7 +498,7 @@ void ControlDialog::SetSelectedControl(wxCommandEvent&)
|
||||
return;
|
||||
|
||||
textctrl->WriteText(expr);
|
||||
control_reference->expression = textctrl->GetValue();
|
||||
control_reference->SetExpression(WxStrToStr(textctrl->GetValue()));
|
||||
|
||||
const auto lock = ControllerEmu::EmulatedController::GetStateLock();
|
||||
control_reference->UpdateReference(g_controller_interface,
|
||||
@@ -533,7 +534,7 @@ void ControlDialog::AppendControl(wxCommandEvent& event)
|
||||
}
|
||||
|
||||
textctrl->WriteText(expr);
|
||||
control_reference->expression = textctrl->GetValue();
|
||||
control_reference->SetExpression(WxStrToStr(textctrl->GetValue()));
|
||||
|
||||
const auto lock = ControllerEmu::EmulatedController::GetStateLock();
|
||||
control_reference->UpdateReference(g_controller_interface,
|
||||
@@ -637,7 +638,7 @@ void InputConfigDialog::ConfigControl(wxEvent& event)
|
||||
void InputConfigDialog::ClearControl(wxEvent& event)
|
||||
{
|
||||
ControlButton* const btn = (ControlButton*)event.GetEventObject();
|
||||
btn->control_reference->expression.clear();
|
||||
btn->control_reference->SetExpression("");
|
||||
btn->control_reference->range = 1.0;
|
||||
|
||||
controller->UpdateReferences(g_controller_interface);
|
||||
@@ -716,7 +717,7 @@ bool InputConfigDialog::DetectButton(ControlButton* button)
|
||||
wxString control_name = ctrl->GetName();
|
||||
wxString expr;
|
||||
GetExpressionForControl(expr, control_name);
|
||||
button->control_reference->expression = expr;
|
||||
button->control_reference->SetExpression(WxStrToStr(expr));
|
||||
const auto lock = ControllerEmu::EmulatedController::GetStateLock();
|
||||
button->control_reference->UpdateReference(g_controller_interface,
|
||||
controller->default_device);
|
||||
|
||||
Reference in New Issue
Block a user