mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-24 19:27:27 +00:00
DolphinQt: update for graphics mod 2.0
This commit is contained in:
parent
b8f60518c5
commit
5782af6107
2 changed files with 25 additions and 41 deletions
|
@ -23,7 +23,6 @@
|
||||||
#include "DolphinQt/QtUtils/ClearLayoutRecursively.h"
|
#include "DolphinQt/QtUtils/ClearLayoutRecursively.h"
|
||||||
#include "DolphinQt/Settings.h"
|
#include "DolphinQt/Settings.h"
|
||||||
#include "UICommon/GameFile.h"
|
#include "UICommon/GameFile.h"
|
||||||
#include "VideoCommon/GraphicsModSystem/Config/GraphicsMod.h"
|
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
GraphicsModListWidget::GraphicsModListWidget(const UICommon::GameFile& game)
|
GraphicsModListWidget::GraphicsModListWidget(const UICommon::GameFile& game)
|
||||||
|
@ -38,7 +37,7 @@ GraphicsModListWidget::GraphicsModListWidget(const UICommon::GameFile& game)
|
||||||
ConnectWidgets();
|
ConnectWidgets();
|
||||||
|
|
||||||
RefreshModList();
|
RefreshModList();
|
||||||
OnModChanged(std::nullopt);
|
OnModChanged(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsModListWidget::~GraphicsModListWidget()
|
GraphicsModListWidget::~GraphicsModListWidget()
|
||||||
|
@ -124,30 +123,17 @@ void GraphicsModListWidget::RefreshModList()
|
||||||
m_mod_list->setCurrentItem(nullptr);
|
m_mod_list->setCurrentItem(nullptr);
|
||||||
m_mod_list->clear();
|
m_mod_list->clear();
|
||||||
|
|
||||||
m_mod_group = GraphicsModGroupConfig(m_game_id);
|
m_mod_group = GraphicsModSystem::Config::GraphicsModGroup(m_game_id);
|
||||||
m_mod_group.Load();
|
m_mod_group.Load();
|
||||||
|
|
||||||
std::set<std::string> groups;
|
for (const auto& mod : m_mod_group.GetMods())
|
||||||
|
|
||||||
for (const GraphicsModConfig& mod : m_mod_group.GetMods())
|
|
||||||
{
|
{
|
||||||
for (const GraphicsTargetGroupConfig& group : mod.m_groups)
|
if (mod.m_mod.m_actions.empty())
|
||||||
groups.insert(group.m_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const GraphicsModConfig& mod : m_mod_group.GetMods())
|
|
||||||
{
|
|
||||||
// If no group matches the mod's features, or if the mod has no features, skip it
|
|
||||||
if (std::ranges::none_of(mod.m_features, [&groups](const GraphicsModFeatureConfig& feature) {
|
|
||||||
return groups.contains(feature.m_group);
|
|
||||||
}))
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
QListWidgetItem* item = new QListWidgetItem(QString::fromStdString(mod.m_title));
|
QListWidgetItem* item = new QListWidgetItem(QString::fromStdString(mod.m_mod.m_title));
|
||||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||||
item->setData(Qt::UserRole, QString::fromStdString(mod.GetAbsolutePath()));
|
item->setData(Qt::UserRole, static_cast<qulonglong>(mod.m_id));
|
||||||
item->setCheckState(mod.m_enabled ? Qt::Checked : Qt::Unchecked);
|
item->setCheckState(mod.m_enabled ? Qt::Checked : Qt::Unchecked);
|
||||||
|
|
||||||
m_mod_list->addItem(item);
|
m_mod_list->addItem(item);
|
||||||
|
@ -160,14 +146,13 @@ void GraphicsModListWidget::ModSelectionChanged()
|
||||||
return;
|
return;
|
||||||
if (m_mod_list->count() == 0)
|
if (m_mod_list->count() == 0)
|
||||||
return;
|
return;
|
||||||
const auto absolute_path = m_mod_list->currentItem()->data(Qt::UserRole).toString().toStdString();
|
OnModChanged(m_mod_list->currentItem()->data(Qt::UserRole).toULongLong());
|
||||||
OnModChanged(absolute_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsModListWidget::ModItemChanged(QListWidgetItem* item)
|
void GraphicsModListWidget::ModItemChanged(QListWidgetItem* item)
|
||||||
{
|
{
|
||||||
const auto absolute_path = item->data(Qt::UserRole).toString();
|
const auto id = item->data(Qt::UserRole).toULongLong();
|
||||||
GraphicsModConfig* mod = m_mod_group.GetMod(absolute_path.toStdString());
|
auto mod = m_mod_group.GetMod(id);
|
||||||
if (!mod)
|
if (!mod)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -185,39 +170,39 @@ void GraphicsModListWidget::ModItemChanged(QListWidgetItem* item)
|
||||||
m_needs_save = true;
|
m_needs_save = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsModListWidget::OnModChanged(const std::optional<std::string>& absolute_path)
|
void GraphicsModListWidget::OnModChanged(u64 id)
|
||||||
{
|
{
|
||||||
ClearLayoutRecursively(m_mod_meta_layout);
|
ClearLayoutRecursively(m_mod_meta_layout);
|
||||||
|
|
||||||
adjustSize();
|
adjustSize();
|
||||||
|
|
||||||
if (!absolute_path)
|
if (id == 0)
|
||||||
{
|
{
|
||||||
m_selected_mod_name->setText(tr("No graphics mod selected"));
|
m_selected_mod_name->setText(tr("No graphics mod selected"));
|
||||||
m_selected_mod_name->setAlignment(Qt::AlignCenter);
|
m_selected_mod_name->setAlignment(Qt::AlignCenter);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const GraphicsModConfig* mod = m_mod_group.GetMod(*absolute_path);
|
const auto mod = m_mod_group.GetMod(id);
|
||||||
if (!mod)
|
if (!mod)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_selected_mod_name->setText(QString::fromStdString(mod->m_title));
|
m_selected_mod_name->setText(QString::fromStdString(mod->m_mod.m_title));
|
||||||
m_selected_mod_name->setAlignment(Qt::AlignLeft);
|
m_selected_mod_name->setAlignment(Qt::AlignLeft);
|
||||||
QFont font = m_selected_mod_name->font();
|
QFont font = m_selected_mod_name->font();
|
||||||
font.setWeight(QFont::Bold);
|
font.setWeight(QFont::Bold);
|
||||||
m_selected_mod_name->setFont(font);
|
m_selected_mod_name->setFont(font);
|
||||||
|
|
||||||
if (!mod->m_author.empty())
|
if (!mod->m_mod.m_author.empty())
|
||||||
{
|
{
|
||||||
auto* author_label = new QLabel(tr("By: %1").arg(QString::fromStdString(mod->m_author)));
|
auto* author_label = new QLabel(tr("By: %1").arg(QString::fromStdString(mod->m_mod.m_author)));
|
||||||
m_mod_meta_layout->addWidget(author_label);
|
m_mod_meta_layout->addWidget(author_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mod->m_description.empty())
|
if (!mod->m_mod.m_description.empty())
|
||||||
{
|
{
|
||||||
auto* description_label =
|
auto* description_label =
|
||||||
new QLabel(tr("Description: %1").arg(QString::fromStdString(mod->m_description)));
|
new QLabel(tr("Description: %1").arg(QString::fromStdString(mod->m_mod.m_description)));
|
||||||
description_label->setWordWrap(true);
|
description_label->setWordWrap(true);
|
||||||
m_mod_meta_layout->addWidget(description_label);
|
m_mod_meta_layout->addWidget(description_label);
|
||||||
}
|
}
|
||||||
|
@ -227,11 +212,9 @@ void GraphicsModListWidget::SaveModList()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_mod_list->count(); i++)
|
for (int i = 0; i < m_mod_list->count(); i++)
|
||||||
{
|
{
|
||||||
const auto absolute_path = m_mod_list->model()
|
const auto id =
|
||||||
->data(m_mod_list->model()->index(i, 0), Qt::UserRole)
|
m_mod_list->model()->data(m_mod_list->model()->index(i, 0), Qt::UserRole).toULongLong();
|
||||||
.toString()
|
m_mod_group.GetMod(id)->m_weight = i;
|
||||||
.toStdString();
|
|
||||||
m_mod_group.GetMod(absolute_path)->m_weight = i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_loaded_game_is_running)
|
if (m_loaded_game_is_running)
|
||||||
|
@ -247,7 +230,8 @@ void GraphicsModListWidget::SaveToDisk()
|
||||||
m_mod_group.Save();
|
m_mod_group.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
const GraphicsModGroupConfig& GraphicsModListWidget::GetGraphicsModConfig() const
|
const GraphicsModSystem::Config::GraphicsModGroup&
|
||||||
|
GraphicsModListWidget::GetGraphicsModConfig() const
|
||||||
{
|
{
|
||||||
return m_mod_group;
|
return m_mod_group;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
|
|
||||||
void SaveToDisk();
|
void SaveToDisk();
|
||||||
|
|
||||||
const GraphicsModGroupConfig& GetGraphicsModConfig() const;
|
const GraphicsModSystem::Config::GraphicsModGroup& GetGraphicsModConfig() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void OpenGraphicsSettings();
|
void OpenGraphicsSettings();
|
||||||
|
@ -52,7 +52,7 @@ private:
|
||||||
void ModSelectionChanged();
|
void ModSelectionChanged();
|
||||||
void ModItemChanged(QListWidgetItem* item);
|
void ModItemChanged(QListWidgetItem* item);
|
||||||
|
|
||||||
void OnModChanged(const std::optional<std::string>& absolute_path);
|
void OnModChanged(u64 id);
|
||||||
|
|
||||||
void SaveModList();
|
void SaveModList();
|
||||||
|
|
||||||
|
@ -72,5 +72,5 @@ private:
|
||||||
GraphicsModWarningWidget* m_warning;
|
GraphicsModWarningWidget* m_warning;
|
||||||
|
|
||||||
std::string m_game_id;
|
std::string m_game_id;
|
||||||
GraphicsModGroupConfig m_mod_group;
|
GraphicsModSystem::Config::GraphicsModGroup m_mod_group;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue