From 5d770b5cdafe21a8fe66b712a089befa57832b9a Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 16 Mar 2022 00:31:24 -0400 Subject: [PATCH] Add basic window to view map.exd --- CMakeLists.txt | 11 +++++++++-- include/mainwindow.h | 13 +++++++++++++ libxiv | 2 +- src/main.cpp | 13 ++++++------- src/mainwindow.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 75 insertions(+), 10 deletions(-) create mode 100644 include/mainwindow.h create mode 100644 src/mainwindow.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 6010aeb..34369c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,19 @@ project(Novus) +set(CMAKE_AUTOMOC ON) + +set(CMAKE_CXX_STANDARD 17) + +find_package(Qt5 COMPONENTS Core Widgets CONFIG REQUIRED) + add_subdirectory(libxiv) find_package(fmt) add_executable(novus - src/main.cpp) + src/main.cpp + src/mainwindow.cpp) target_include_directories(novus PUBLIC include) -target_link_libraries(novus PUBLIC libxiv fmt::fmt z) \ No newline at end of file +target_link_libraries(novus PUBLIC libxiv fmt::fmt z Qt5::Core Qt5::Widgets) \ No newline at end of file diff --git a/include/mainwindow.h b/include/mainwindow.h new file mode 100644 index 0000000..59c6816 --- /dev/null +++ b/include/mainwindow.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +class GameData; + +class MainWindow : public QMainWindow { +public: + MainWindow(GameData& data); + +private: + GameData& data; +}; \ No newline at end of file diff --git a/libxiv b/libxiv index 2e74f47..3befb90 160000 --- a/libxiv +++ b/libxiv @@ -1 +1 @@ -Subproject commit 2e74f477cfce2363a0d652ff8167cae16051bf2f +Subproject commit 3befb9070b02b52f90b34de6bc36c4f200e05ea4 diff --git a/src/main.cpp b/src/main.cpp index f211523..63e494d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,16 +1,15 @@ -#include +#include +#include "mainwindow.h" #include "gamedata.h" int main(int argc, char* argv[]) { - if(argc < 3) { - fmt::print("novus [sqpack directory] [game path] [out path]"); - return -1; - } + QApplication app(argc, argv); GameData data(argv[1]); - data.extractFile(argv[2], argv[3]); + MainWindow w(data); + w.show(); - return 0; + return app.exec(); } \ No newline at end of file diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp new file mode 100644 index 0000000..0db7bb2 --- /dev/null +++ b/src/mainwindow.cpp @@ -0,0 +1,46 @@ +#include "mainwindow.h" + +#include +#include +#include + +#include "gamedata.h" +#include "exhparser.h" +#include "exdparser.h" + +MainWindow::MainWindow(GameData& data) : data(data) { + setWindowTitle("Novus"); + + QWidget* dummyWidget = new QWidget(); + setCentralWidget(dummyWidget); + + QVBoxLayout* layout = new QVBoxLayout(); + dummyWidget->setLayout(layout); + + QTableWidget* listWidget = new QTableWidget(); + + data.extractFile("exd/map.exh", "map.exh"); + data.extractFile("exd/map_0.exd", "map_0.exd"); + + auto exh = readEXH("map.exh"); + for(auto column : exh.columnDefinitions) { + fmt::print("type = {}, offset = {}\n", column.type, column.offset); + } + + listWidget->setColumnCount(exh.columnDefinitions.size()); + listWidget->setRowCount(exh.header.rowCount); + + for(auto page : exh.pages) { + fmt::print("page, row count = {}, start id = {}\n", page.rowCount, page.startId); + auto exd = readEXD(exh, page); + for(int i = 0; i < exd.rows.size(); i++) { + for(int j = 0; j < exd.rows[i].data.size(); j++) { + auto newItem = new QTableWidgetItem(exd.rows[i].data[j].data.c_str()); + + listWidget->setItem(i, j, newItem); + } + } + } + + layout->addWidget(listWidget); +} \ No newline at end of file