diff --git a/sagasu/include/filetreemodel.h b/sagasu/include/filetreemodel.h index 37c2e68..a58040e 100644 --- a/sagasu/include/filetreemodel.h +++ b/sagasu/include/filetreemodel.h @@ -26,7 +26,7 @@ class FileTreeModel : public QAbstractItemModel Q_OBJECT public: - explicit FileTreeModel(bool showUnknown, const QString &gamePath, GameData *data, QObject *parent = nullptr); + explicit FileTreeModel(HashDatabase &database, bool showUnknown, const QString &gamePath, GameData *data, QObject *parent = nullptr); int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; @@ -47,6 +47,6 @@ private: QHash knownDirHashes; - HashDatabase m_database; + HashDatabase &m_database; bool m_showUnknown = false; }; \ No newline at end of file diff --git a/sagasu/include/filetreewindow.h b/sagasu/include/filetreewindow.h index 39be6b1..2114d9c 100644 --- a/sagasu/include/filetreewindow.h +++ b/sagasu/include/filetreewindow.h @@ -14,7 +14,7 @@ class FileTreeWindow : public QWidget Q_OBJECT public: - explicit FileTreeWindow(const QString &gamePath, GameData *data, QWidget *parent = nullptr); + explicit FileTreeWindow(HashDatabase &database, const QString &gamePath, GameData *data, QWidget *parent = nullptr); Q_SIGNALS: void extractFile(const QString &path); @@ -28,4 +28,5 @@ private: QSortFilterProxyModel *m_searchModel = nullptr; QCheckBox *m_unknownCheckbox = nullptr; QString m_gamePath; + HashDatabase &m_database; }; \ No newline at end of file diff --git a/sagasu/include/hashdatabase.h b/sagasu/include/hashdatabase.h index f86bf31..88b5208 100644 --- a/sagasu/include/hashdatabase.h +++ b/sagasu/include/hashdatabase.h @@ -16,6 +16,7 @@ public: void addFolder(const QString &folder); void addFile(const QString &file); + void importFileList(const QString &path); QVector getKnownFolders(); diff --git a/sagasu/include/mainwindow.h b/sagasu/include/mainwindow.h index 19b207a..50b91bc 100644 --- a/sagasu/include/mainwindow.h +++ b/sagasu/include/mainwindow.h @@ -8,6 +8,7 @@ #include #include "filecache.h" +#include "hashdatabase.h" #include "novusmainwindow.h" struct GameData; @@ -17,10 +18,14 @@ class MainWindow : public NovusMainWindow public: MainWindow(const QString &gamePath, GameData *data); +protected: + void setupFileMenu(QMenu *menu) override; + private: GameData *data = nullptr; QTabWidget *partHolder = nullptr; FileCache fileCache; + HashDatabase m_database; void refreshParts(const QString &path); }; \ No newline at end of file diff --git a/sagasu/src/filetreemodel.cpp b/sagasu/src/filetreemodel.cpp index 534581e..a39528f 100644 --- a/sagasu/src/filetreemodel.cpp +++ b/sagasu/src/filetreemodel.cpp @@ -6,10 +6,11 @@ #include -FileTreeModel::FileTreeModel(bool showUnknown, const QString &gamePath, GameData *data, QObject *parent) +FileTreeModel::FileTreeModel(HashDatabase &database, bool showUnknown, const QString &gamePath, GameData *data, QObject *parent) : QAbstractItemModel(parent) , gameData(data) , m_showUnknown(showUnknown) + , m_database(database) { rootItem = new TreeInformation(); rootItem->type = TreeType::Root; diff --git a/sagasu/src/filetreewindow.cpp b/sagasu/src/filetreewindow.cpp index 64f4a69..8dbad3c 100644 --- a/sagasu/src/filetreewindow.cpp +++ b/sagasu/src/filetreewindow.cpp @@ -8,10 +8,11 @@ #include #include -FileTreeWindow::FileTreeWindow(const QString &gamePath, GameData *data, QWidget *parent) +FileTreeWindow::FileTreeWindow(HashDatabase &database, const QString &gamePath, GameData *data, QWidget *parent) : QWidget(parent) , data(data) , m_gamePath(gamePath) + , m_database(database) { auto layout = new QVBoxLayout(); layout->setContentsMargins(0, 0, 0, 0); @@ -74,7 +75,7 @@ FileTreeWindow::FileTreeWindow(const QString &gamePath, GameData *data, QWidget void FileTreeWindow::refreshModel() { // TODO: this should really be handled by the proxy - m_fileModel = new FileTreeModel(m_unknownCheckbox->isChecked(), m_gamePath, data); + m_fileModel = new FileTreeModel(m_database, m_unknownCheckbox->isChecked(), m_gamePath, data); m_searchModel->setSourceModel(m_fileModel); } diff --git a/sagasu/src/hashdatabase.cpp b/sagasu/src/hashdatabase.cpp index 089c73c..ef7f923 100644 --- a/sagasu/src/hashdatabase.cpp +++ b/sagasu/src/hashdatabase.cpp @@ -3,6 +3,7 @@ #include "hashdatabase.h" +#include #include #include @@ -93,4 +94,15 @@ QString HashDatabase::getFilename(const uint32_t i) return query.value(0).toString(); } +void HashDatabase::importFileList(const QString &path) +{ + QFile file(path); + file.open(QIODevice::ReadOnly); + + QTextStream stream(&file); + while (!stream.atEnd()) { + addFile(stream.readLine()); + } +} + #include "moc_hashdatabase.cpp" \ No newline at end of file diff --git a/sagasu/src/mainwindow.cpp b/sagasu/src/mainwindow.cpp index 1f38992..613d48b 100644 --- a/sagasu/src/mainwindow.cpp +++ b/sagasu/src/mainwindow.cpp @@ -34,7 +34,7 @@ MainWindow::MainWindow(const QString &gamePath, GameData *data) auto layout = new QHBoxLayout(); dummyWidget->setLayout(layout); - auto tree = new FileTreeWindow(gamePath, data); + auto tree = new FileTreeWindow(m_database, gamePath, data); connect(tree, &FileTreeWindow::extractFile, this, [this, data](const QString &path) { const QFileInfo info(path); @@ -89,7 +89,7 @@ void MainWindow::refreshParts(const QString &path) partHolder->addTab(exdWidget, QStringLiteral("Note")); } else if (info.completeSuffix() == QStringLiteral("mdl")) { auto mdlWidget = new MDLPart(data, fileCache); - mdlWidget->addModel(physis_mdl_parse(file), QStringLiteral("mdl"), {}, 0); + mdlWidget->addModel(physis_mdl_parse(file), glm::vec3(), QStringLiteral("mdl"), {}, 0); partHolder->addTab(mdlWidget, QStringLiteral("Model")); } else if (info.completeSuffix() == QStringLiteral("tex") || info.completeSuffix() == QStringLiteral("atex")) { auto texWidget = new TexPart(data); @@ -116,3 +116,14 @@ void MainWindow::refreshParts(const QString &path) auto propertiesWidget = new FilePropertiesWindow(path, file); partHolder->addTab(propertiesWidget, QStringLiteral("Properties")); } + +void MainWindow::setupFileMenu(QMenu *menu) +{ + auto openList = menu->addAction(QStringLiteral("Import path list...")); + openList->setIcon(QIcon::fromTheme(QStringLiteral("document-open"))); + connect(openList, &QAction::triggered, [this] { + auto fileName = QFileDialog::getOpenFileName(nullptr, QStringLiteral("Open Path List"), QStringLiteral("~")); + + m_database.importFileList(fileName); + }); +}