2023-08-06 08:48:11 -04:00
|
|
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-04-11 21:59:37 -04:00
|
|
|
#include "mainwindow.h"
|
|
|
|
|
2022-04-12 12:19:46 -04:00
|
|
|
#include <QHBoxLayout>
|
2023-07-07 16:16:21 -04:00
|
|
|
#include <QListWidget>
|
|
|
|
#include <QTableWidget>
|
2022-04-12 16:19:06 -04:00
|
|
|
#include <QTimer>
|
2023-04-09 15:31:19 -04:00
|
|
|
|
2024-02-04 15:13:46 -05:00
|
|
|
#include <KLocalizedString>
|
2023-07-07 16:16:21 -04:00
|
|
|
#include <QAction>
|
2023-08-06 08:48:11 -04:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QDesktopServices>
|
2022-04-12 20:18:22 -04:00
|
|
|
#include <QFileDialog>
|
2022-04-28 23:20:58 -04:00
|
|
|
#include <QMenuBar>
|
2024-02-04 14:00:46 -05:00
|
|
|
#include <QSplitter>
|
2023-07-07 16:16:21 -04:00
|
|
|
#include <magic_enum.hpp>
|
2022-04-28 17:50:05 -04:00
|
|
|
|
2023-07-06 17:37:49 -04:00
|
|
|
#include "cmpeditor.h"
|
2023-07-09 10:54:27 -04:00
|
|
|
#include "filecache.h"
|
2023-09-23 15:45:38 -04:00
|
|
|
#include "gearlistwidget.h"
|
2023-12-10 11:11:01 -05:00
|
|
|
#include "penumbraapi.h"
|
2023-12-09 16:34:51 -05:00
|
|
|
#include "settingswindow.h"
|
2022-05-03 13:19:48 -04:00
|
|
|
|
2023-10-10 18:10:42 -04:00
|
|
|
MainWindow::MainWindow(GameData *in_data)
|
|
|
|
: NovusMainWindow()
|
|
|
|
, data(*in_data)
|
|
|
|
, cache(FileCache{*in_data})
|
2023-12-10 11:11:01 -05:00
|
|
|
, m_api(new PenumbraApi(this))
|
2023-10-10 18:10:42 -04:00
|
|
|
{
|
2023-04-09 15:31:19 -04:00
|
|
|
setMinimumSize(QSize(800, 600));
|
2023-10-10 18:20:59 -04:00
|
|
|
setupMenubar();
|
2023-07-06 17:37:49 -04:00
|
|
|
|
2024-02-04 14:00:46 -05:00
|
|
|
auto dummyWidget = new QSplitter();
|
2024-02-04 14:58:21 -05:00
|
|
|
dummyWidget->setChildrenCollapsible(false);
|
2022-04-11 21:59:37 -04:00
|
|
|
setCentralWidget(dummyWidget);
|
|
|
|
|
2023-07-08 09:13:02 -04:00
|
|
|
auto gearListWidget = new GearListWidget(&data);
|
|
|
|
gearListWidget->setMaximumWidth(350);
|
2023-12-09 22:35:59 -05:00
|
|
|
connect(gearListWidget, &GearListWidget::gearSelected, this, [this](const GearInfo &gear) {
|
2023-07-08 09:13:02 -04:00
|
|
|
gearView->setGear(gear);
|
|
|
|
});
|
2024-02-04 14:00:46 -05:00
|
|
|
dummyWidget->addWidget(gearListWidget);
|
2022-04-11 23:11:33 -04:00
|
|
|
|
2023-07-09 10:54:27 -04:00
|
|
|
gearView = new SingleGearView(&data, cache);
|
2023-12-09 22:35:59 -05:00
|
|
|
connect(gearView, &SingleGearView::addToFullModelViewer, this, [this](GearInfo &info) {
|
2023-04-09 15:31:19 -04:00
|
|
|
fullModelViewer->addGear(info);
|
2022-04-12 12:39:33 -04:00
|
|
|
});
|
2023-12-10 11:11:01 -05:00
|
|
|
connect(gearView, &SingleGearView::importedModel, m_api, &PenumbraApi::redrawAll);
|
2023-09-26 20:21:06 -04:00
|
|
|
|
2024-02-04 14:11:11 -05:00
|
|
|
materialView = new MaterialView(&data);
|
|
|
|
|
|
|
|
metadataView = new MetadataView(&data);
|
|
|
|
|
2023-09-26 20:21:06 -04:00
|
|
|
auto tabWidget = new QTabWidget();
|
2024-02-04 15:13:46 -05:00
|
|
|
tabWidget->addTab(gearView, i18nc("@title:tab", "Models"));
|
|
|
|
tabWidget->addTab(materialView, i18nc("@title:tab", "Materials"));
|
|
|
|
tabWidget->addTab(metadataView, i18nc("@title:tab", "Metadata"));
|
2024-02-04 14:00:46 -05:00
|
|
|
tabWidget->setDocumentMode(true); // Don't draw the borders
|
|
|
|
tabWidget->tabBar()->setExpanding(true);
|
|
|
|
dummyWidget->addWidget(tabWidget);
|
2023-09-26 20:21:06 -04:00
|
|
|
|
|
|
|
fullModelViewer = new FullModelViewer(&data, cache);
|
2023-12-09 22:35:59 -05:00
|
|
|
connect(fullModelViewer, &FullModelViewer::loadingChanged, this, [this](const bool loading) {
|
2023-09-25 23:48:03 -04:00
|
|
|
gearView->setFMVAvailable(!loading);
|
|
|
|
});
|
2023-10-10 18:20:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::setupAdditionalMenus(QMenuBar *menuBar)
|
|
|
|
{
|
2024-02-04 15:13:46 -05:00
|
|
|
auto toolsMenu = menuBar->addMenu(i18nc("@title:menu", "Tools"));
|
2023-10-10 18:20:59 -04:00
|
|
|
|
2024-02-04 15:13:46 -05:00
|
|
|
auto cmpEditorMenu = toolsMenu->addAction(i18nc("@action:inmenu CMP is an abbreviation", "CMP Editor"));
|
2024-02-03 10:34:05 -05:00
|
|
|
cmpEditorMenu->setIcon(QIcon::fromTheme(QStringLiteral("document-edit")));
|
|
|
|
connect(cmpEditorMenu, &QAction::triggered, [this] {
|
|
|
|
auto cmpEditor = new CmpEditor(&data);
|
|
|
|
cmpEditor->show();
|
|
|
|
});
|
|
|
|
|
2024-02-04 15:13:46 -05:00
|
|
|
auto windowMenu = menuBar->addMenu(i18nc("@title:menu", "Window"));
|
2024-02-03 10:34:05 -05:00
|
|
|
|
2024-02-04 15:13:46 -05:00
|
|
|
auto fmvMenu = windowMenu->addAction(i18nc("@action:inmenu", "Full Model Viewer"));
|
2023-12-10 07:29:51 -05:00
|
|
|
fmvMenu->setCheckable(true);
|
2024-02-03 10:34:05 -05:00
|
|
|
fmvMenu->setIcon(QIcon::fromTheme(QStringLiteral("user-symbolic")));
|
2023-12-10 07:29:51 -05:00
|
|
|
connect(fmvMenu, &QAction::toggled, [this](bool toggled) {
|
|
|
|
if (toggled) {
|
|
|
|
fullModelViewer->show();
|
|
|
|
} else {
|
|
|
|
fullModelViewer->hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
connect(fullModelViewer, &FullModelViewer::visibleChanged, this, [this, fmvMenu] {
|
|
|
|
fmvMenu->setChecked(fullModelViewer->isVisible());
|
|
|
|
});
|
|
|
|
|
2024-02-04 15:13:46 -05:00
|
|
|
auto settingsMenu = menuBar->addMenu(i18nc("@title:menu", "Settings"));
|
2023-12-09 16:34:51 -05:00
|
|
|
|
2024-02-04 15:13:46 -05:00
|
|
|
auto settingsAction = settingsMenu->addAction(i18nc("@action:inmenu", "Configure Armoury…"));
|
2024-02-03 10:34:05 -05:00
|
|
|
settingsAction->setIcon(QIcon::fromTheme(QStringLiteral("configure-symbolic")));
|
|
|
|
connect(settingsAction, &QAction::triggered, [this] {
|
2023-12-09 16:34:51 -05:00
|
|
|
auto settingsWindow = new SettingsWindow();
|
|
|
|
settingsWindow->show();
|
|
|
|
});
|
2023-10-10 18:20:59 -04:00
|
|
|
}
|
2023-10-12 23:44:48 -04:00
|
|
|
|
|
|
|
#include "moc_mainwindow.cpp"
|