mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-04-06 06:55:02 +00:00
Qt: fix duplicate button or combo warning
This commit is contained in:
parent
4c106960c5
commit
0c27b63ab4
4 changed files with 18 additions and 14 deletions
|
|
@ -76,7 +76,7 @@ std::string cfg_pad::get_button_string(std::vector<pad::combo>& combos)
|
|||
for (const pad::combo& combo : combos)
|
||||
{
|
||||
// Merge all keys for this combo (seperated by '&')
|
||||
combo_strings.push_back(fmt::merge(combo.buttons(), "&"));
|
||||
combo_strings.push_back(combo.to_string());
|
||||
}
|
||||
|
||||
// Merge combos (seperated by ',')
|
||||
|
|
|
|||
|
|
@ -28,6 +28,11 @@ namespace pad
|
|||
m_buttons.insert(button);
|
||||
}
|
||||
|
||||
std::string to_string() const
|
||||
{
|
||||
return fmt::merge(m_buttons, "&");
|
||||
}
|
||||
|
||||
bool operator==(const combo& other) const
|
||||
{
|
||||
return m_buttons == other.m_buttons;
|
||||
|
|
|
|||
|
|
@ -2102,7 +2102,7 @@ void pad_settings_dialog::ApplyCurrentPlayerConfig(int new_player_id)
|
|||
return;
|
||||
}
|
||||
|
||||
m_duplicate_buttons[m_last_player_id].clear();
|
||||
m_duplicate_combos[m_last_player_id].clear();
|
||||
|
||||
auto& player = g_cfg_input.player[m_last_player_id];
|
||||
m_last_player_id = new_player_id;
|
||||
|
|
@ -2110,7 +2110,7 @@ void pad_settings_dialog::ApplyCurrentPlayerConfig(int new_player_id)
|
|||
// Check for duplicate button choices
|
||||
if (m_handler->m_type != pad_handler::null)
|
||||
{
|
||||
std::set<std::string> unique_button_strings;
|
||||
std::set<std::string> unique_combo_strings;
|
||||
for (const auto& [id, button] : m_cfg_entries)
|
||||
{
|
||||
// Let's ignore special keys, unless we're using a keyboard
|
||||
|
|
@ -2122,13 +2122,12 @@ void pad_settings_dialog::ApplyCurrentPlayerConfig(int new_player_id)
|
|||
|
||||
for (const pad::combo& combo : cfg_pad::get_combos(button.button_string()))
|
||||
{
|
||||
for (const std::string& button_string : combo.buttons())
|
||||
std::string combo_string = combo.to_string();
|
||||
|
||||
if (const auto& [it, ok] = unique_combo_strings.insert(combo_string); !ok)
|
||||
{
|
||||
if (const auto& [it, ok] = unique_button_strings.insert(button_string); !ok)
|
||||
{
|
||||
m_duplicate_buttons[m_last_player_id] = button_string;
|
||||
break;
|
||||
}
|
||||
m_duplicate_combos[m_last_player_id] = std::move(combo_string);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2212,16 +2211,16 @@ void pad_settings_dialog::save(bool check_duplicates)
|
|||
|
||||
if (check_duplicates)
|
||||
{
|
||||
for (const auto& [player_id, key] : m_duplicate_buttons)
|
||||
for (const auto& [player_id, combo] : m_duplicate_combos)
|
||||
{
|
||||
if (!key.empty())
|
||||
if (!combo.empty())
|
||||
{
|
||||
int result = QMessageBox::Yes;
|
||||
m_gui_settings->ShowConfirmationBox(
|
||||
tr("Warning!"),
|
||||
tr("The %0 button <b>%1</b> of <b>Player %2</b> was assigned at least twice.<br>Please consider adjusting the configuration.<br><br>Continue anyway?<br>")
|
||||
tr("The %0 button or combo <b>%1</b> of <b>Player %2</b> was assigned at least twice.<br>Please consider adjusting the configuration.<br><br>Continue anyway?<br>")
|
||||
.arg(QString::fromStdString(g_cfg_input.player[player_id]->handler.to_string()))
|
||||
.arg(QString::fromStdString(key))
|
||||
.arg(QString::fromStdString(combo))
|
||||
.arg(player_id + 1),
|
||||
gui::ib_same_buttons, &result, this);
|
||||
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ private:
|
|||
QButtonGroup* m_pad_buttons = nullptr;
|
||||
atomic_t<u32> m_button_id = button_ids::id_pad_begin;
|
||||
std::map<int /*id*/, pad_button /*info*/> m_cfg_entries;
|
||||
std::map<int /*id*/, std::string> m_duplicate_buttons;
|
||||
std::map<int /*id*/, std::string> m_duplicate_combos;
|
||||
|
||||
// Real time stick values
|
||||
int m_lx = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue