mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-25 11:34:55 +00:00
If duplicate unique inputs found, show which buttons have duplicates
This commit is contained in:
parent
226058d2e9
commit
65227f8bb3
@ -372,14 +372,32 @@ void KBMSettings::SaveKBMConfig(bool CloseOnSave) {
|
|||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
// Prevent duplicate inputs for KBM as this breaks the engine
|
// Prevent duplicate inputs for KBM as this breaks the engine
|
||||||
|
bool duplicateFound = false;
|
||||||
|
QSet<QString> duplicateInputs;
|
||||||
for (auto it = inputs.begin(); it != inputs.end(); ++it) {
|
for (auto it = inputs.begin(); it != inputs.end(); ++it) {
|
||||||
if (std::find(it + 1, inputs.end(), *it) != inputs.end()) {
|
if (std::find(it + 1, inputs.end(), *it) != inputs.end()) {
|
||||||
QMessageBox::information(this, tr("Unable to Save"),
|
duplicateFound = true;
|
||||||
tr("Cannot bind any unique input more than once"));
|
duplicateInputs.insert(QString::fromStdString(*it));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (duplicateFound) {
|
||||||
|
QStringList DuplicateButtons;
|
||||||
|
for (QString i : duplicateInputs) {
|
||||||
|
for (const auto& j : ButtonsList) {
|
||||||
|
if (j->text() == i)
|
||||||
|
DuplicateButtons.append(j->objectName() + " - " + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QString DuplicateList = DuplicateButtons.join("\n");
|
||||||
|
QMessageBox::information(
|
||||||
|
this, tr("Unable to Save"),
|
||||||
|
QString(tr("Cannot bind any unique input more than once. "
|
||||||
|
"Duplicate inputs mapped to the following buttons:\n\n%1")
|
||||||
|
.arg(DuplicateList)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> save;
|
std::vector<std::string> save;
|
||||||
bool CurrentLineEmpty = false, LastLineEmpty = false;
|
bool CurrentLineEmpty = false, LastLineEmpty = false;
|
||||||
for (auto const& line : lines) {
|
for (auto const& line : lines) {
|
||||||
|
Loading…
Reference in New Issue
Block a user