mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-07-01 00:35:54 +02:00
[desktop] Add mod importer from folder and zip (#3472)
Closes #3125 Adds buttons to the addons page that imports a mod (or mods) from zip or folder. Currently known to work with mods that provide proper romfs/exefs things, unsure about cheats and such. Also works on mods that just stuff things into the root of the zip. TODO: - [ ] test folder more thoroughly - [ ] cheats - [ ] test all sorts of mod pack types Signed-off-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3472 Reviewed-by: Lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
08232ce642
commit
e07e269bd7
18 changed files with 570 additions and 14 deletions
66
src/yuzu/configuration/addon/mod_select_dialog.cpp
Normal file
66
src/yuzu/configuration/addon/mod_select_dialog.cpp
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <qnamespace.h>
|
||||
#include "mod_select_dialog.h"
|
||||
#include "ui_mod_select_dialog.h"
|
||||
|
||||
ModSelectDialog::ModSelectDialog(const QStringList& mods, QWidget* parent)
|
||||
: QDialog(parent), ui(new Ui::ModSelectDialog) {
|
||||
ui->setupUi(this);
|
||||
|
||||
item_model = new QStandardItemModel(ui->treeView);
|
||||
ui->treeView->setModel(item_model);
|
||||
|
||||
// We must register all custom types with the Qt Automoc system so that we are able to use it
|
||||
// with signals/slots. In this case, QList falls under the umbrella of custom types.
|
||||
qRegisterMetaType<QList<QStandardItem*>>("QList<QStandardItem*>");
|
||||
|
||||
for (const auto& mod : mods) {
|
||||
const auto basename = QFileInfo(mod).fileName();
|
||||
|
||||
auto* const first_item = new QStandardItem;
|
||||
first_item->setText(basename);
|
||||
first_item->setData(mod);
|
||||
|
||||
first_item->setCheckable(true);
|
||||
first_item->setCheckState(Qt::Checked);
|
||||
|
||||
item_model->appendRow(first_item);
|
||||
}
|
||||
|
||||
ui->treeView->expandAll();
|
||||
ui->treeView->resizeColumnToContents(0);
|
||||
|
||||
int rows = item_model->rowCount();
|
||||
int height =
|
||||
ui->treeView->contentsMargins().top() * 4 + ui->treeView->contentsMargins().bottom() * 4;
|
||||
int width = 0;
|
||||
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
height += ui->treeView->sizeHintForRow(i);
|
||||
width = qMax(width, item_model->item(i)->sizeHint().width());
|
||||
}
|
||||
|
||||
width += ui->treeView->contentsMargins().left() * 4 + ui->treeView->contentsMargins().right() * 4;
|
||||
ui->treeView->setMinimumHeight(qMin(height, 600));
|
||||
ui->treeView->setMinimumWidth(qMin(width, 700));
|
||||
adjustSize();
|
||||
|
||||
connect(this, &QDialog::accepted, this, [this]() {
|
||||
QStringList selected_mods;
|
||||
|
||||
for (qsizetype i = 0; i < item_model->rowCount(); ++i) {
|
||||
auto* const item = item_model->item(i);
|
||||
if (item->checkState() == Qt::Checked)
|
||||
selected_mods << item->data().toString();
|
||||
}
|
||||
|
||||
emit modsSelected(selected_mods);
|
||||
});
|
||||
}
|
||||
|
||||
ModSelectDialog::~ModSelectDialog() {
|
||||
delete ui;
|
||||
}
|
||||
26
src/yuzu/configuration/addon/mod_select_dialog.h
Normal file
26
src/yuzu/configuration/addon/mod_select_dialog.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
namespace Ui {
|
||||
class ModSelectDialog;
|
||||
}
|
||||
|
||||
class ModSelectDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ModSelectDialog(const QStringList &mods, QWidget* parent = nullptr);
|
||||
~ModSelectDialog();
|
||||
|
||||
signals:
|
||||
void modsSelected(const QStringList &mods);
|
||||
private:
|
||||
Ui::ModSelectDialog* ui;
|
||||
|
||||
QStandardItemModel* item_model;
|
||||
};
|
||||
99
src/yuzu/configuration/addon/mod_select_dialog.ui
Normal file
99
src/yuzu/configuration/addon/mod_select_dialog.ui
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ModSelectDialog</class>
|
||||
<widget class="QDialog" name="ModSelectDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>430</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>The specified folder or archive contains the following mods. Select which ones to install.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeView" name="treeView">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::ContextMenuPolicy::NoContextMenu</enum>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::EditTrigger::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollMode::ScrollPerPixel</enum>
|
||||
</property>
|
||||
<property name="uniformRowHeights">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="headerHidden">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ModSelectDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ModSelectDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Loading…
Add table
Add a link
Reference in a new issue