dolphin/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.cpp
JosJuice 0146456af0 Don't translate button names
Since these button names are printed on all real controllers,
we should show them in the same way as they are printed on
the controllers, regardless of the user's language. It seems
like this was intended all along (except for "Start"), but the
_ markers in TASInputDlg.cpp (accidentally?) led to the button
names in the controller configs also becoming translatable.

I'm making exceptions for "L" and "R" because translators
may want to mark them in some way (for instance "L-Digital")
to clarify the difference from "L-Analog" and "R-Analog".

I'm also making an exception for START/PAUSE because it's
referred to as スタート in Japanese games.

I'm changing "Home" and "Start" to uppercase for consistency
with how Nintendo refers to those buttons, and because someone
who isn't familiar with the Latin script might not know the
connection between the lowercase and uppercase letters (most
users likely do know the connection, but we shouldn't assume it),
and because leaving "Start" as "Start" makes it "collide" with
unrelated strings, such as the string for the button that starts
a netplay session.

To rename "Start" and "Home" without breaking INI
compatibility, I added a ui_name variable like in f5c82ad.
2017-05-06 16:29:10 +02:00

79 lines
2.3 KiB
C++

// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.h"
#include <cstddef>
#include <memory>
#include <string>
#include <utility>
#include "Common/Common.h"
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerEmu/Control/Control.h"
#include "InputCommon/ControllerEmu/Control/Input.h"
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
#include "VideoCommon/OnScreenDisplay.h"
namespace ControllerEmu
{
ModifySettingsButton::ModifySettingsButton(std::string button_name)
: Buttons(std::move(button_name))
{
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.5));
}
void ModifySettingsButton::AddInput(std::string button_name, bool toggle)
{
controls.emplace_back(new Input(std::move(button_name)));
threshold_exceeded.emplace_back(false);
associated_settings.emplace_back(false);
associated_settings_toggle.emplace_back(toggle);
}
void ModifySettingsButton::GetState()
{
for (size_t i = 0; i < controls.size(); ++i)
{
ControlState state = controls[i]->control_ref->State();
if (!associated_settings_toggle[i])
{
// not toggled
associated_settings[i] = state > numeric_settings[0]->GetValue();
}
else
{
// toggle (loading savestates does not en-/disable toggle)
// after we passed the threshold, we en-/disable. but after that, we don't change it
// anymore
if (!threshold_exceeded[i] && state > numeric_settings[0]->GetValue())
{
associated_settings[i] = !associated_settings[i];
if (associated_settings[i])
OSD::AddMessage(controls[i]->ui_name + ": on");
else
OSD::AddMessage(controls[i]->ui_name + ": off");
threshold_exceeded[i] = true;
}
if (state < numeric_settings[0]->GetValue())
threshold_exceeded[i] = false;
}
}
}
const std::vector<bool>& ModifySettingsButton::isSettingToggled() const
{
return associated_settings_toggle;
}
const std::vector<bool>& ModifySettingsButton::getSettingsModifier() const
{
return associated_settings;
}
} // namespace ControllerEmu