1
Fork 0
mirror of https://github.com/redstrate/Novus.git synced 2025-04-28 06:37:44 +00:00
novus/mdlviewer/src/mainwindow.cpp

117 lines
3.3 KiB
C++
Raw Normal View History

2022-04-11 21:59:37 -04:00
#include "mainwindow.h"
#include <QHBoxLayout>
#include <QLineEdit>
2023-07-07 16:16:21 -04:00
#include <QListWidget>
#include <QTableWidget>
#include <QTimer>
2023-07-07 16:16:21 -04:00
#include <QAction>
#include <QFileDialog>
#include <QMenuBar>
2023-07-07 16:16:21 -04:00
#include <QPushButton>
#include <QTreeWidget>
2023-07-07 16:16:21 -04:00
#include <glm/gtc/type_ptr.hpp>
#include <magic_enum.hpp>
2022-08-10 14:52:28 -04:00
#include <physis.hpp>
#include "cmpeditor.h"
2022-08-10 14:52:28 -04:00
MainWindow::MainWindow(GameData* in_data) : data(*in_data) {
2022-04-11 21:59:37 -04:00
setWindowTitle("mdlviewer");
setMinimumSize(QSize(800, 600));
2022-04-11 21:59:37 -04:00
auto fileMenu = menuBar()->addMenu("File");
// TODO: move to a dedicated mdlview?
/*auto openMDLFile = fileMenu->addAction("Open MDL...");
connect(openMDLFile, &QAction::triggered, [=] {
auto fileName = QFileDialog::getOpenFileName(nullptr,
"Open MDL File",
"~",
"FFXIV Model File (*.mdl)");
2022-08-10 14:52:28 -04:00
auto buffer = physis_read_file(fileName.toStdString().c_str());
loadedGear.model = physis_mdl_parse(buffer.size, buffer.data);
reloadGearAppearance();
});*/
auto toolsMenu = menuBar()->addMenu("Tools");
auto cmpEditorMenu = toolsMenu->addAction("CMP Editor");
connect(cmpEditorMenu, &QAction::triggered, [=] {
auto cmpEditor = new CmpEditor(in_data);
cmpEditor->show();
});
2022-04-11 21:59:37 -04:00
auto dummyWidget = new QWidget();
setCentralWidget(dummyWidget);
auto layout = new QHBoxLayout();
2022-04-11 21:59:37 -04:00
dummyWidget->setLayout(layout);
// smallclothes body
{
GearInfo info = {};
info.name = "Smallclothes Body";
info.slot = Slot::Body;
gears.push_back(info);
}
// smallclothes legs
{
GearInfo info = {};
info.name = "Smallclothes Legs";
info.slot = Slot::Legs;
gears.push_back(info);
}
2022-08-10 14:52:28 -04:00
auto exh = physis_gamedata_read_excel_sheet_header(&data, "Item");
auto exd = physis_gamedata_read_excel_sheet(&data, "Item", exh, Language::English, 1);
2023-07-07 16:16:21 -04:00
for (int i = 0; i < exd.row_count; i++) {
2022-08-10 14:52:28 -04:00
const auto row = exd.row_data[i];
auto primaryModel = row.column_data[47].u_int64._0;
auto secondaryModel = row.column_data[48].u_int64._0;
int16_t parts[4];
memcpy(parts, &primaryModel, sizeof(int16_t) * 4);
GearInfo info = {};
2022-08-10 14:52:28 -04:00
info.name = row.column_data[9].string._0;
info.slot = physis_slot_from_id(row.column_data[17].u_int8._0);
info.modelInfo.primaryID = parts[0];
gears.push_back(info);
}
auto listWidget = new QListWidget();
2023-07-07 16:16:21 -04:00
for (auto gear : gears)
listWidget->addItem(gear.name.c_str());
listWidget->setMaximumWidth(200);
layout->addWidget(listWidget);
gearView = new SingleGearView(&data);
connect(gearView, &SingleGearView::addToFullModelViewer, this, [=](GearInfo& info) {
fullModelViewer->addGear(info);
});
layout->addWidget(gearView);
connect(listWidget, &QListWidget::itemClicked, [this](QListWidgetItem* item) {
2023-07-07 16:16:21 -04:00
for (auto& gear : gears) {
if (gear.name == item->text().toStdString()) {
gearView->setGear(gear);
return;
}
}
});
fullModelViewer = new FullModelViewer(&data);
fullModelViewer->show();
}