From ae41124f931fea51fb25332925e80319f6be6c9a Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Thu, 12 Oct 2023 21:33:09 -0400 Subject: [PATCH] exdpart: Add more header information, adapt to physis API changes --- karuku/src/mainwindow.cpp | 12 ++++++---- parts/exd/exdpart.cpp | 48 +++++++++++++++++++++++++++++---------- parts/exd/exdpart.h | 9 +++++--- 3 files changed, 50 insertions(+), 19 deletions(-) diff --git a/karuku/src/mainwindow.cpp b/karuku/src/mainwindow.cpp index fe9e2d8..e73931b 100644 --- a/karuku/src/mainwindow.cpp +++ b/karuku/src/mainwindow.cpp @@ -44,10 +44,14 @@ MainWindow::MainWindow(GameData *data) auto exdPart = new EXDPart(data); layout->addWidget(exdPart); - connect(listWidget, &QListWidget::itemClicked, this, [exdPart](QListWidgetItem *item) { - auto name = item->text().toStdString(); - auto nameLowercase = item->text().toLower().toStdString(); + connect(listWidget, &QListWidget::itemClicked, this, [data, exdPart](QListWidgetItem *item) { + auto nameLowercase = item->text().toLower(); - exdPart->loadSheet(QString::fromStdString(name.c_str())); + auto path = QStringLiteral("exd/%1.exh").arg(nameLowercase); + auto pathStd = path.toStdString(); + + auto file = physis_gamedata_extract_file(data, pathStd.c_str()); + + exdPart->loadSheet(item->text(), file); }); } \ No newline at end of file diff --git a/parts/exd/exdpart.cpp b/parts/exd/exdpart.cpp index 7163e42..b307ba8 100644 --- a/parts/exd/exdpart.cpp +++ b/parts/exd/exdpart.cpp @@ -5,24 +5,37 @@ #include #include -#include -#include +#include +#include #include #include -#include +#include +#include +#include #include -EXDPart::EXDPart(GameData* data) : data(data) { - pageTabWidget = new QTabWidget(); - +EXDPart::EXDPart(GameData *data) + : data(data) +{ auto layout = new QVBoxLayout(); - layout->addWidget(pageTabWidget); setLayout(layout); + + auto headerBox = new QGroupBox(QStringLiteral("Header")); + layout->addWidget(headerBox); + headerFormLayout = new QFormLayout(); + headerBox->setLayout(headerFormLayout); + + auto contentsBox = new QGroupBox(QStringLiteral("Contents")); + layout->addWidget(contentsBox); + auto contentsBoxLayout = new QVBoxLayout(); + contentsBox->setLayout(contentsBoxLayout); + + pageTabWidget = new QTabWidget(); + contentsBoxLayout->addWidget(pageTabWidget); } -void EXDPart::loadSheet(const QString& name) { - qDebug() << "Loading" << name; - +void EXDPart::loadSheet(QString name, physis_Buffer buffer) +{ pageTabWidget->clear(); QFile definitionFile(QStringLiteral("Achievement.json")); @@ -38,7 +51,7 @@ void EXDPart::loadSheet(const QString& name) { && definition.toObject()[QLatin1String("converter")].toObject()[QLatin1String("type")].toString() == QStringLiteral("link")) { auto linkName = definition.toObject()[QLatin1String("converter")].toObject()[QLatin1String("target")].toString(); - auto linkExh = physis_gamedata_read_excel_sheet_header(data, linkName.toStdString().c_str()); + auto linkExh = physis_parse_excel_sheet_header(buffer); auto linkExd = physis_gamedata_read_excel_sheet(data, linkName.toStdString().c_str(), linkExh, getSuitableLanguage(linkExh), 0); if (linkExd.p_ptr != nullptr) { @@ -48,7 +61,18 @@ void EXDPart::loadSheet(const QString& name) { } } - auto exh = physis_gamedata_read_excel_sheet_header(data, name.toStdString().c_str()); + auto exh = physis_parse_excel_sheet_header(buffer); + + QLayoutItem *child; + while ((child = headerFormLayout->takeAt(0)) != 0) { + delete child->widget(); + delete child; + } + + headerFormLayout->addRow(QStringLiteral("Num Rows"), new QLabel(QString::number(exh->row_count))); + headerFormLayout->addRow(QStringLiteral("Num Columns"), new QLabel(QString::number(exh->column_count))); + headerFormLayout->addRow(QStringLiteral("Num Pages"), new QLabel(QString::number(exh->page_count))); + headerFormLayout->addRow(QStringLiteral("Num Languages"), new QLabel(QString::number(exh->language_count))); for(int i = 0; i < exh->page_count; i++) { auto tableWidget = new QTableWidget(); diff --git a/parts/exd/exdpart.h b/parts/exd/exdpart.h index 3a54e0d..343b68f 100644 --- a/parts/exd/exdpart.h +++ b/parts/exd/exdpart.h @@ -3,21 +3,24 @@ #pragma once -#include -#include +#include #include +#include +#include #include +// TODO: rename to "EXDH" or "Excel" part or something similar because you cannot preview EXD on it's own class EXDPart : public QWidget { public: explicit EXDPart(GameData* data); - void loadSheet(const QString& name); + void loadSheet(QString name, physis_Buffer buffer); private: GameData* data = nullptr; QTabWidget* pageTabWidget = nullptr; + QFormLayout *headerFormLayout = nullptr; struct CachedExcel { physis_EXH* exh = nullptr;