mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-06-25 11:56:18 +00:00
Qt: If duplicate unique inputs found, show which buttons have duplicates (#3098)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* If duplicate unique inputs found, show which buttons have duplicates * remove duplicate button from list * cleanup * Set clang-format off for long translatable string
This commit is contained in:
parent
226058d2e9
commit
3f40a8d46e
1 changed files with 27 additions and 10 deletions
|
@ -33,13 +33,13 @@ KBMSettings::KBMSettings(std::shared_ptr<GameInfoClass> game_info_get, QWidget*
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonsList = {
|
ButtonsList = {
|
||||||
ui->CrossButton, ui->CircleButton, ui->TriangleButton, ui->SquareButton,
|
ui->CrossButton, ui->CircleButton, ui->TriangleButton, ui->SquareButton,
|
||||||
ui->L1Button, ui->R1Button, ui->L2Button, ui->R2Button,
|
ui->L1Button, ui->R1Button, ui->L2Button, ui->R2Button,
|
||||||
ui->L3Button, ui->R3Button, ui->TouchpadButton, ui->OptionsButton,
|
ui->L3Button, ui->R3Button, ui->OptionsButton, ui->TouchpadButton,
|
||||||
ui->TouchpadButton, ui->DpadUpButton, ui->DpadDownButton, ui->DpadLeftButton,
|
ui->DpadUpButton, ui->DpadDownButton, ui->DpadLeftButton, ui->DpadRightButton,
|
||||||
ui->DpadRightButton, ui->LStickUpButton, ui->LStickDownButton, ui->LStickLeftButton,
|
ui->LStickUpButton, ui->LStickDownButton, ui->LStickLeftButton, ui->LStickRightButton,
|
||||||
ui->LStickRightButton, ui->RStickUpButton, ui->RStickDownButton, ui->RStickLeftButton,
|
ui->RStickUpButton, ui->RStickDownButton, ui->RStickLeftButton, ui->RStickRightButton,
|
||||||
ui->RStickRightButton, ui->LHalfButton, ui->RHalfButton};
|
ui->LHalfButton, ui->RHalfButton};
|
||||||
|
|
||||||
ButtonConnects();
|
ButtonConnects();
|
||||||
SetUIValuestoMappings("default");
|
SetUIValuestoMappings("default");
|
||||||
|
@ -372,14 +372,31 @@ 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> duplicateMappings;
|
||||||
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"));
|
duplicateMappings.insert(QString::fromStdString(*it));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (duplicateFound) {
|
||||||
|
QStringList duplicatesList;
|
||||||
|
for (const QString mapping : duplicateMappings) {
|
||||||
|
for (const auto& button : ButtonsList) {
|
||||||
|
if (button->text() == mapping)
|
||||||
|
duplicatesList.append(button->objectName() + " - " + mapping);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QMessageBox::information(
|
||||||
|
this, tr("Unable to Save"),
|
||||||
|
// clang-format off
|
||||||
|
QString(tr("Cannot bind any unique input more than once. Duplicate inputs mapped to the following buttons:\n\n%1").arg(duplicatesList.join("\n"))));
|
||||||
|
// clang-format on
|
||||||
|
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…
Add table
Add a link
Reference in a new issue