mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-03-06 14:27:44 +00:00
Qt: Group cheats together in categories in menu
This commit is contained in:
parent
37e565698f
commit
1b0b88f60b
|
@ -1111,24 +1111,44 @@ void QtHostInterface::populateCheatsMenu(QMenu* menu)
|
||||||
const bool has_cheat_list = System::HasCheatList();
|
const bool has_cheat_list = System::HasCheatList();
|
||||||
|
|
||||||
QMenu* enabled_menu = menu->addMenu(tr("&Enabled Cheats"));
|
QMenu* enabled_menu = menu->addMenu(tr("&Enabled Cheats"));
|
||||||
enabled_menu->setEnabled(has_cheat_list);
|
enabled_menu->setEnabled(false);
|
||||||
QMenu* apply_menu = menu->addMenu(tr("&Apply Cheats"));
|
QMenu* apply_menu = menu->addMenu(tr("&Apply Cheats"));
|
||||||
apply_menu->setEnabled(has_cheat_list);
|
apply_menu->setEnabled(false);
|
||||||
if (has_cheat_list)
|
if (has_cheat_list)
|
||||||
{
|
{
|
||||||
CheatList* cl = System::GetCheatList();
|
CheatList* cl = System::GetCheatList();
|
||||||
|
for (const std::string& group : cl->GetCodeGroups())
|
||||||
|
{
|
||||||
|
QMenu* enabled_submenu = nullptr;
|
||||||
|
QMenu* apply_submenu = nullptr;
|
||||||
|
|
||||||
for (u32 i = 0; i < cl->GetCodeCount(); i++)
|
for (u32 i = 0; i < cl->GetCodeCount(); i++)
|
||||||
{
|
{
|
||||||
CheatCode& cc = cl->GetCode(i);
|
CheatCode& cc = cl->GetCode(i);
|
||||||
|
if (cc.group != group)
|
||||||
|
continue;
|
||||||
|
|
||||||
QString desc(QString::fromStdString(cc.description));
|
QString desc(QString::fromStdString(cc.description));
|
||||||
if (cc.IsManuallyActivated())
|
if (cc.IsManuallyActivated())
|
||||||
{
|
{
|
||||||
QAction* action = apply_menu->addAction(desc);
|
if (!apply_submenu)
|
||||||
|
{
|
||||||
|
apply_menu->setEnabled(true);
|
||||||
|
apply_submenu = apply_menu->addMenu(QString::fromStdString(group));
|
||||||
|
}
|
||||||
|
|
||||||
|
QAction* action = apply_submenu->addAction(desc);
|
||||||
connect(action, &QAction::triggered, [this, i]() { applyCheat(i); });
|
connect(action, &QAction::triggered, [this, i]() { applyCheat(i); });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QAction* action = enabled_menu->addAction(desc);
|
if (!enabled_submenu)
|
||||||
|
{
|
||||||
|
enabled_menu->setEnabled(true);
|
||||||
|
enabled_submenu = enabled_menu->addMenu(QString::fromStdString(group));
|
||||||
|
}
|
||||||
|
|
||||||
|
QAction* action = enabled_submenu->addAction(desc);
|
||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
action->setChecked(cc.enabled);
|
action->setChecked(cc.enabled);
|
||||||
connect(action, &QAction::toggled, [this, i](bool enabled) { setCheatEnabled(i, enabled); });
|
connect(action, &QAction::toggled, [this, i](bool enabled) { setCheatEnabled(i, enabled); });
|
||||||
|
@ -1136,6 +1156,7 @@ void QtHostInterface::populateCheatsMenu(QMenu* menu)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void QtHostInterface::loadCheatList(const QString& filename)
|
void QtHostInterface::loadCheatList(const QString& filename)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue