From 5c31965691478212a5d8ebd4112ab92ace28c8d1 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 27 Apr 2024 13:07:05 -0400 Subject: [PATCH] Add visible textures to the material editor along with constants --- extern/libphysis | 2 +- mateditor/CMakeLists.txt | 1 + mateditor/include/materialpropertyedit.h | 1 + mateditor/src/mainwindow.cpp | 2 +- mateditor/src/materialpropertyedit.cpp | 32 ++++++++++++++++++++++++ 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/extern/libphysis b/extern/libphysis index 63051e0..bccb050 160000 --- a/extern/libphysis +++ b/extern/libphysis @@ -1 +1 @@ -Subproject commit 63051e0056a521d9165445fe6f6f1a2221dcea37 +Subproject commit bccb0503fadb1cd69f27e9aa62ff4d446de76226 diff --git a/mateditor/CMakeLists.txt b/mateditor/CMakeLists.txt index 407afc1..b5a46ef 100644 --- a/mateditor/CMakeLists.txt +++ b/mateditor/CMakeLists.txt @@ -19,6 +19,7 @@ target_link_libraries(novus-mateditor PRIVATE Novus::Common Novus::MdlPart + Novus::TexPart Physis::Physis Physis::Logger Qt6::Core diff --git a/mateditor/include/materialpropertyedit.h b/mateditor/include/materialpropertyedit.h index fc6f5a0..f89fd7a 100644 --- a/mateditor/include/materialpropertyedit.h +++ b/mateditor/include/materialpropertyedit.h @@ -29,6 +29,7 @@ private: QTabWidget *m_tabWidget = nullptr; QVBoxLayout *m_propertiesLayout = nullptr; QVBoxLayout *m_texturesLayout = nullptr; + QVBoxLayout *m_constantsLayout = nullptr; physis_Material m_material = {}; physis_SHPK m_shpk = {}; diff --git a/mateditor/src/mainwindow.cpp b/mateditor/src/mainwindow.cpp index 3b80f14..c938c0c 100644 --- a/mateditor/src/mainwindow.cpp +++ b/mateditor/src/mainwindow.cpp @@ -20,7 +20,7 @@ MainWindow::MainWindow(GameData *data) setMinimumSize(1280, 720); setupMenubar(); - auto matFile = physis_gamedata_extract_file(data, "chara/equipment/e0028/material/v0020/mt_c0101e0028_top_a.mtrl"); + auto matFile = physis_gamedata_extract_file(data, "chara/equipment/e0028/material/v0001/mt_c0101e0028_top_a.mtrl"); m_material = physis_material_parse(matFile); auto dummyWidget = new QSplitter(); diff --git a/mateditor/src/materialpropertyedit.cpp b/mateditor/src/materialpropertyedit.cpp index d7ec867..5990b94 100644 --- a/mateditor/src/materialpropertyedit.cpp +++ b/mateditor/src/materialpropertyedit.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "materialpropertyedit.h" +#include "texpart.h" #include #include @@ -355,8 +356,13 @@ MaterialPropertyEdit::MaterialPropertyEdit(GameData *data, QWidget *parent) m_texturesLayout = new QVBoxLayout(); texturesTab->setLayout(m_texturesLayout); + auto constantsTab = new QWidget(); + m_constantsLayout = new QVBoxLayout(); + constantsTab->setLayout(m_constantsLayout); + m_tabWidget->addTab(propertiesTab, i18n("Parameters")); m_tabWidget->addTab(texturesTab, i18n("Textures")); + m_tabWidget->addTab(constantsTab, i18n("Constants")); setLayout(m_itemsLayout); @@ -502,6 +508,32 @@ void MaterialPropertyEdit::rebuild() auto groupBox = new QGroupBox(name); m_texturesLayout->addWidget(groupBox); + + auto layout = new QFormLayout(); + groupBox->setLayout(layout); + + auto texWidget = new TexPart(m_data); + texWidget->load(physis_gamedata_extract_file(m_data, m_material.textures[i])); + layout->addRow(i18n("Value:"), texWidget); + } + + child = nullptr; + while ((child = m_constantsLayout->takeAt(0)) != nullptr) { + child->widget()->setParent(nullptr); + child->widget()->deleteLater(); + } + + for (int i = 0; i < m_material.num_constants; i++) { + const auto constant = m_material.constants[i]; + + auto groupBox = new QGroupBox(QString::number(constant.id)); + m_constantsLayout->addWidget(groupBox); + + auto layout = new QFormLayout(); + groupBox->setLayout(layout); + + auto label = new QLabel(QString::number(constant.value)); + layout->addRow(i18n("Value:"), label); } }