Merge pull request #5347 from JosJuice/do-not-translate-button-names

Don't translate button names
This commit is contained in:
shuffle2 2017-06-05 19:05:09 -07:00 committed by GitHub
commit b9b3b1dc19
12 changed files with 60 additions and 35 deletions

View File

@ -56,7 +56,7 @@
<!-- GameCube buttons (May be shared with other stuff too) --> <!-- GameCube buttons (May be shared with other stuff too) -->
<string name="button_a">A</string> <string name="button_a">A</string>
<string name="button_b">B</string> <string name="button_b">B</string>
<string name="button_start">Start</string> <string name="button_start">START</string>
<string name="button_x">X</string> <string name="button_x">X</string>
<string name="button_y">Y</string> <string name="button_y">Y</string>
<string name="button_z">Z</string> <string name="button_z">Z</string>
@ -68,7 +68,7 @@
<string name="button_two">2</string> <string name="button_two">2</string>
<string name="button_minus">-</string> <string name="button_minus">-</string>
<string name="button_plus">+</string> <string name="button_plus">+</string>
<string name="button_home">Home</string> <string name="button_home">HOME</string>
<string name="ir_hide">Hide</string> <string name="ir_hide">Hide</string>
<string name="tilt_modifier">Modifier</string> <string name="tilt_modifier">Modifier</string>
<string name="shake_x">X</string> <string name="shake_x">X</string>

View File

@ -33,7 +33,7 @@ static const u16 trigger_bitmasks[] = {
static const u16 dpad_bitmasks[] = {PAD_BUTTON_UP, PAD_BUTTON_DOWN, PAD_BUTTON_LEFT, static const u16 dpad_bitmasks[] = {PAD_BUTTON_UP, PAD_BUTTON_DOWN, PAD_BUTTON_LEFT,
PAD_BUTTON_RIGHT}; PAD_BUTTON_RIGHT};
static const char* const named_buttons[] = {"A", "B", "X", "Y", "Z", _trans("Start")}; static const char* const named_buttons[] = {"A", "B", "X", "Y", "Z", "Start"};
static const char* const named_triggers[] = { static const char* const named_triggers[] = {
// i18n: The left trigger button (labeled L on real controllers) // i18n: The left trigger button (labeled L on real controllers)
@ -50,7 +50,11 @@ GCPad::GCPad(const unsigned int index) : m_index(index)
// buttons // buttons
groups.emplace_back(m_buttons = new ControllerEmu::Buttons(_trans("Buttons"))); groups.emplace_back(m_buttons = new ControllerEmu::Buttons(_trans("Buttons")));
for (unsigned int i = 0; i < sizeof(named_buttons) / sizeof(*named_buttons); ++i) for (unsigned int i = 0; i < sizeof(named_buttons) / sizeof(*named_buttons); ++i)
m_buttons->controls.emplace_back(new ControllerEmu::Input(named_buttons[i])); {
// i18n: The START/PAUSE button on GameCube controllers
const std::string& ui_name = (named_buttons[i] == "Start") ? _trans("START") : named_buttons[i];
m_buttons->controls.emplace_back(new ControllerEmu::Input(named_buttons[i], ui_name));
}
// sticks // sticks
groups.emplace_back(m_main_stick = new ControllerEmu::AnalogStick( groups.emplace_back(m_main_stick = new ControllerEmu::AnalogStick(

View File

@ -64,7 +64,10 @@ Classic::Classic(ExtensionReg& reg) : Attachment(_trans("Classic"), reg)
// buttons // buttons
groups.emplace_back(m_buttons = new ControllerEmu::Buttons(_trans("Buttons"))); groups.emplace_back(m_buttons = new ControllerEmu::Buttons(_trans("Buttons")));
for (auto& classic_button_name : classic_button_names) for (auto& classic_button_name : classic_button_names)
m_buttons->controls.emplace_back(new ControllerEmu::Input(classic_button_name)); {
const std::string& ui_name = (classic_button_name == "Home") ? "HOME" : classic_button_name;
m_buttons->controls.emplace_back(new ControllerEmu::Input(classic_button_name, ui_name));
}
// sticks // sticks
groups.emplace_back(m_left_stick = new ControllerEmu::AnalogStick( groups.emplace_back(m_left_stick = new ControllerEmu::AnalogStick(

View File

@ -257,7 +257,10 @@ Wiimote::Wiimote(const unsigned int index)
// buttons // buttons
groups.emplace_back(m_buttons = new ControllerEmu::Buttons(_trans("Buttons"))); groups.emplace_back(m_buttons = new ControllerEmu::Buttons(_trans("Buttons")));
for (auto& named_button : named_buttons) for (auto& named_button : named_buttons)
m_buttons->controls.emplace_back(new ControllerEmu::Input(named_button)); {
const std::string& ui_name = (named_button == "Home") ? "HOME" : named_button;
m_buttons->controls.emplace_back(new ControllerEmu::Input(named_button, ui_name));
}
// ir // ir
// i18n: IR stands for infrared and refers to the pointer functionality of Wii Remotes // i18n: IR stands for infrared and refers to the pointer functionality of Wii Remotes

View File

@ -968,16 +968,16 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
for (const auto& control : group->controls) for (const auto& control : group->controls)
{ {
wxStaticText* const label = wxStaticText* const label =
new wxStaticText(parent, wxID_ANY, wxGetTranslation(StrToWxStr(control->name))); new wxStaticText(parent, wxID_ANY, wxGetTranslation(StrToWxStr(control->ui_name)));
ControlButton* const control_button = ControlButton* const control_button =
new ControlButton(parent, control->control_ref.get(), control->name, 80); new ControlButton(parent, control->control_ref.get(), control->ui_name, 80);
control_button->SetFont(small_font); control_button->SetFont(small_font);
control_buttons.push_back(control_button); control_buttons.push_back(control_button);
if (std::find(exclude_groups.begin(), exclude_groups.end(), control_group->name) == if (std::find(exclude_groups.begin(), exclude_groups.end(), control_group->name) ==
exclude_groups.end() && exclude_groups.end() &&
std::find(exclude_buttons.begin(), exclude_buttons.end(), control->name) == std::find(exclude_buttons.begin(), exclude_buttons.end(), control->ui_name) ==
exclude_buttons.end()) exclude_buttons.end())
eventsink->control_buttons.push_back(control_button); eventsink->control_buttons.push_back(control_button);

View File

@ -139,7 +139,7 @@ static void DrawButton(const std::vector<unsigned int>& bitmasks, unsigned int b
gc->DrawRectangle(n * 12, (row == 0) ? 0 : (row * 11), 14, 12); gc->DrawRectangle(n * 12, (row == 0) ? 0 : (row * 11), 14, 12);
// text // text
const std::string name = g->control_group->controls[(row * 8) + n]->name; const std::string name = g->control_group->controls[(row * 8) + n]->ui_name;
// Matrix transformation needs to be disabled so we don't draw scaled/zoomed text. // Matrix transformation needs to be disabled so we don't draw scaled/zoomed text.
wxGraphicsMatrix old_matrix = gc->GetTransform(); wxGraphicsMatrix old_matrix = gc->GetTransform();
gc->SetTransform(null_matrix); gc->SetTransform(null_matrix);
@ -399,7 +399,7 @@ static void DrawControlGroupBox(wxGraphicsContext* gc, ControlGroupBox* g)
// text // text
// We don't want the text to be scaled/zoomed // We don't want the text to be scaled/zoomed
gc->SetTransform(null_matrix); gc->SetTransform(null_matrix);
gc->DrawText(StrToWxStr(g->control_group->controls[n]->name), 3 * g->m_scale, gc->DrawText(StrToWxStr(g->control_group->controls[n]->ui_name), 3 * g->m_scale,
(n * 12 + 1) * g->m_scale); (n * 12 + 1) * g->m_scale);
gc->SetTransform(scale_matrix); gc->SetTransform(scale_matrix);
} }
@ -437,9 +437,9 @@ static void DrawControlGroupBox(wxGraphicsContext* gc, ControlGroupBox* g)
// text // text
// We don't want the text to be scaled/zoomed // We don't want the text to be scaled/zoomed
gc->SetTransform(null_matrix); gc->SetTransform(null_matrix);
gc->DrawText(StrToWxStr(g->control_group->controls[n + trigger_count]->name), 3 * g->m_scale, gc->DrawText(StrToWxStr(g->control_group->controls[n + trigger_count]->ui_name),
(n * 12 + 1) * g->m_scale); 3 * g->m_scale, (n * 12 + 1) * g->m_scale);
gc->DrawText(StrToWxStr(std::string(1, g->control_group->controls[n]->name[0])), gc->DrawText(StrToWxStr(std::string(1, g->control_group->controls[n]->ui_name[0])),
(64 + 3) * g->m_scale, (n * 12 + 1) * g->m_scale); (64 + 3) * g->m_scale, (n * 12 + 1) * g->m_scale);
gc->SetTransform(scale_matrix); gc->SetTransform(scale_matrix);
} }

View File

@ -86,9 +86,9 @@ void TASInputDlg::CreateBaseLayout()
m_controls[0] = &m_main_stick.x_cont; m_controls[0] = &m_main_stick.x_cont;
m_controls[1] = &m_main_stick.y_cont; m_controls[1] = &m_main_stick.y_cont;
m_a = CreateButton(_("A")); m_a = CreateButton("A");
m_a.checkbox->SetClientData(&m_a); m_a.checkbox->SetClientData(&m_a);
m_b = CreateButton(_("B")); m_b = CreateButton("B");
m_b.checkbox->SetClientData(&m_b); m_b.checkbox->SetClientData(&m_b);
m_dpad_up = CreateButton(_("Up")); m_dpad_up = CreateButton(_("Up"));
m_dpad_up.checkbox->SetClientData(&m_dpad_up); m_dpad_up.checkbox->SetClientData(&m_dpad_up);
@ -140,15 +140,15 @@ void TASInputDlg::CreateWiiLayout(int num)
wxStaticBoxSizer* const axisBox = wxStaticBoxSizer* const axisBox =
CreateAccelLayout(&m_x_cont, &m_y_cont, &m_z_cont, _("Orientation")); CreateAccelLayout(&m_x_cont, &m_y_cont, &m_z_cont, _("Orientation"));
m_plus = CreateButton(_("+")); m_plus = CreateButton("+");
m_plus.checkbox->SetClientData(&m_plus); m_plus.checkbox->SetClientData(&m_plus);
m_minus = CreateButton(_("-")); m_minus = CreateButton("-");
m_minus.checkbox->SetClientData(&m_minus); m_minus.checkbox->SetClientData(&m_minus);
m_one = CreateButton(_("1")); m_one = CreateButton("1");
m_one.checkbox->SetClientData(&m_one); m_one.checkbox->SetClientData(&m_one);
m_two = CreateButton(_("2")); m_two = CreateButton("2");
m_two.checkbox->SetClientData(&m_two); m_two.checkbox->SetClientData(&m_two);
m_home = CreateButton(_("Home")); m_home = CreateButton("HOME");
m_home.checkbox->SetClientData(&m_home); m_home.checkbox->SetClientData(&m_home);
m_cc_szr = CreateCCLayout(); m_cc_szr = CreateCCLayout();
@ -188,9 +188,9 @@ void TASInputDlg::CreateWiiLayout(int num)
wxStaticBoxSizer* const nunchukaxisBox = wxStaticBoxSizer* const nunchukaxisBox =
CreateAccelLayout(&m_nx_cont, &m_ny_cont, &m_nz_cont, _("Nunchuk orientation")); CreateAccelLayout(&m_nx_cont, &m_ny_cont, &m_nz_cont, _("Nunchuk orientation"));
m_c = CreateButton(_("C")); m_c = CreateButton("C");
m_c.checkbox->SetClientData(&m_c); m_c.checkbox->SetClientData(&m_c);
m_z = CreateButton(_("Z")); m_z = CreateButton("Z");
m_z.checkbox->SetClientData(&m_z); m_z.checkbox->SetClientData(&m_z);
for (Control* const control : m_controls) for (Control* const control : m_controls)
@ -246,9 +246,8 @@ void TASInputDlg::FinishLayout()
wxBoxSizer* TASInputDlg::CreateCCLayout() wxBoxSizer* TASInputDlg::CreateCCLayout()
{ {
const std::array<wxString, 15> button_names{{_("Down"), _("Up"), _("Left"), _("Right"), _("A"), const std::array<wxString, 15> button_names{{_("Down"), _("Up"), _("Left"), _("Right"), "A", "B",
_("B"), _("X"), _("Y"), _("+"), _("-"), _("L"), "X", "Y", "+", "-", "L", "R", "ZR", "ZL", "HOME"}};
_("R"), _("ZR"), _("ZL"), _("Home")}};
for (size_t i = 0; i < button_names.size(); ++i) for (size_t i = 0; i < button_names.size(); ++i)
{ {
m_cc_buttons[i] = CreateButton(button_names[i]); m_cc_buttons[i] = CreateButton(button_names[i]);
@ -386,17 +385,18 @@ void TASInputDlg::CreateGCLayout()
control->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this); control->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this);
} }
m_x = CreateButton(_("X")); m_x = CreateButton("X");
m_x.checkbox->SetClientData(&m_x); m_x.checkbox->SetClientData(&m_x);
m_y = CreateButton(_("Y")); m_y = CreateButton("Y");
m_y.checkbox->SetClientData(&m_y); m_y.checkbox->SetClientData(&m_y);
m_l = CreateButton(_("L")); m_l = CreateButton("L");
m_l.checkbox->SetClientData(&m_l); m_l.checkbox->SetClientData(&m_l);
m_r = CreateButton(_("R")); m_r = CreateButton("R");
m_r.checkbox->SetClientData(&m_r); m_r.checkbox->SetClientData(&m_r);
m_z = CreateButton(_("Z")); m_z = CreateButton("Z");
m_z.checkbox->SetClientData(&m_z); m_z.checkbox->SetClientData(&m_z);
m_start = CreateButton(_("Start")); // i18n: The START/PAUSE button on GameCube controllers
m_start = CreateButton(_("START"));
m_start.checkbox->SetClientData(&m_start); m_start.checkbox->SetClientData(&m_start);
const int space5 = FromDIP(5); const int space5 = FromDIP(5);

View File

@ -9,8 +9,14 @@
namespace ControllerEmu namespace ControllerEmu
{ {
Control::Control(std::unique_ptr<ControlReference> ref, const std::string& name_,
const std::string& ui_name_)
: control_ref(std::move(ref)), name(name_), ui_name(ui_name_)
{
}
Control::Control(std::unique_ptr<ControlReference> ref, const std::string& name_) Control::Control(std::unique_ptr<ControlReference> ref, const std::string& name_)
: control_ref(std::move(ref)), name(name_) : Control(std::move(ref), name_, name_)
{ {
} }

View File

@ -18,8 +18,11 @@ public:
std::unique_ptr<ControlReference> const control_ref; std::unique_ptr<ControlReference> const control_ref;
const std::string name; const std::string name;
const std::string ui_name;
protected: protected:
Control(std::unique_ptr<ControlReference> ref, const std::string& name,
const std::string& ui_name);
Control(std::unique_ptr<ControlReference> ref, const std::string& name); Control(std::unique_ptr<ControlReference> ref, const std::string& name);
}; };
} // namespace ControllerEmu } // namespace ControllerEmu

View File

@ -10,6 +10,11 @@
namespace ControllerEmu namespace ControllerEmu
{ {
Input::Input(const std::string& name_, const std::string& ui_name_)
: Control(std::make_unique<InputReference>(), name_, ui_name_)
{
}
Input::Input(const std::string& name_) : Control(std::make_unique<InputReference>(), name_) Input::Input(const std::string& name_) : Control(std::make_unique<InputReference>(), name_)
{ {
} }

View File

@ -12,6 +12,7 @@ namespace ControllerEmu
class Input : public Control class Input : public Control
{ {
public: public:
Input(const std::string& name, const std::string& ui_name);
explicit Input(const std::string& name); explicit Input(const std::string& name);
}; };
} // namespace ControllerEmu } // namespace ControllerEmu

View File

@ -54,9 +54,9 @@ void ModifySettingsButton::GetState()
associated_settings[i] = !associated_settings[i]; associated_settings[i] = !associated_settings[i];
if (associated_settings[i]) if (associated_settings[i])
OSD::AddMessage(controls[i]->name + ": on"); OSD::AddMessage(controls[i]->ui_name + ": on");
else else
OSD::AddMessage(controls[i]->name + ": off"); OSD::AddMessage(controls[i]->ui_name + ": off");
threshold_exceeded[i] = true; threshold_exceeded[i] = true;
} }