mirror of
https://github.com/redstrate/Novus.git
synced 2025-04-25 05:17:44 +00:00
Add exlpart for showing the contents of excel list files
This commit is contained in:
parent
a0e87b914d
commit
f271eb7991
5 changed files with 74 additions and 1 deletions
2
extern/libphysis
vendored
2
extern/libphysis
vendored
|
@ -1 +1 @@
|
|||
Subproject commit aff19962aeb5d5ab7365c3e610a47ce5ab74d7cd
|
||||
Subproject commit e44fb6433086669500254f4deb1aceff7ab0fde2
|
|
@ -2,5 +2,6 @@
|
|||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
add_subdirectory(exd)
|
||||
add_subdirectory(exl)
|
||||
add_subdirectory(hex)
|
||||
add_subdirectory(mdl)
|
||||
|
|
7
parts/exl/CMakeLists.txt
Normal file
7
parts/exl/CMakeLists.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
# SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
add_library(exlpart STATIC)
|
||||
target_sources(exlpart PRIVATE exlpart.cpp)
|
||||
target_link_libraries(exlpart PUBLIC physis z Qt6::Core Qt6::Widgets)
|
||||
target_include_directories(exlpart PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
44
parts/exl/exlpart.cpp
Normal file
44
parts/exl/exlpart.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "exlpart.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QVBoxLayout>
|
||||
#include <physis.hpp>
|
||||
|
||||
EXLPart::EXLPart(GameData *data)
|
||||
: data(data)
|
||||
{
|
||||
auto layout = new QVBoxLayout();
|
||||
m_tableWidget = new QTableWidget();
|
||||
layout->addWidget(m_tableWidget);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
void EXLPart::load(physis_Buffer file)
|
||||
{
|
||||
auto exl = physis_gamedata_read_excel_list(file);
|
||||
if (exl.entry_count > 0) {
|
||||
m_tableWidget->clear();
|
||||
|
||||
m_tableWidget->setColumnCount(2);
|
||||
m_tableWidget->setRowCount(exl.entry_count);
|
||||
|
||||
m_tableWidget->setHorizontalHeaderLabels({QStringLiteral("Key"), QStringLiteral("Value")});
|
||||
|
||||
for (int i = 0; i < exl.entry_count; i++) {
|
||||
auto keyItem = new QTableWidgetItem(QLatin1String(exl.entry_keys[i]));
|
||||
auto valueItem = new QTableWidgetItem(QString::number(exl.entry_values[i]));
|
||||
|
||||
m_tableWidget->setItem(i, 0, keyItem);
|
||||
m_tableWidget->setItem(i, 1, valueItem);
|
||||
}
|
||||
|
||||
m_tableWidget->resizeColumnsToContents();
|
||||
}
|
||||
}
|
21
parts/exl/exlpart.h
Normal file
21
parts/exl/exlpart.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QTableWidget>
|
||||
#include <QWidget>
|
||||
#include <physis.hpp>
|
||||
|
||||
class EXLPart : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit EXLPart(GameData *data);
|
||||
|
||||
void load(physis_Buffer file);
|
||||
|
||||
private:
|
||||
GameData *data = nullptr;
|
||||
|
||||
QTableWidget *m_tableWidget = nullptr;
|
||||
};
|
Loading…
Add table
Reference in a new issue