diff --git a/CMakeLists.txt b/CMakeLists.txt index 59f12a8..4543a32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,35 +5,16 @@ cmake_minimum_required(VERSION 3.25) project(Novus) set(CMAKE_AUTOMOC ON) - set(CMAKE_CXX_STANDARD 17) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + find_package(Qt5 COMPONENTS Core Widgets Concurrent CONFIG REQUIRED) include(FetchContent) add_subdirectory(extern) -find_package(fmt QUIET) - -if(TARGET fmt::fmt) - message("Using system library for fmt") - - set(LIBRARIES fmt::fmt ${LIBRARIES}) -else() - message("Using built-in fmt") - - FetchContent_Declare( - fmt - GIT_REPOSITORY https://github.com/fmtlib/fmt - GIT_TAG master - ) - - FetchContent_MakeAvailable(fmt) - - set(LIBRARIES fmt::fmt ${LIBRARIES}) -endif() - # macos if(APPLE) set(USE_STANDALONE_WINDOW TRUE) @@ -44,7 +25,7 @@ add_subdirectory(exdviewer) add_subdirectory(armoury) add_subdirectory(argcracker) add_subdirectory(explorer) -add_subdirectory(bonedecomp) +#add_subdirectory(bonedecomp) # not yet ported to physis add_subdirectory(parts) add_subdirectory(common) add_subdirectory(mdlviewer) diff --git a/argcracker/src/main.cpp b/argcracker/src/main.cpp index 2bfc6b1..4d94503 100644 --- a/argcracker/src/main.cpp +++ b/argcracker/src/main.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include -#include +#include #include @@ -74,13 +74,13 @@ int main(int argc, char* argv[]) { uint32_t bottom = TickCount() - tickRange; - fmt::print("Beginning to crack {}...\n", toCrack); + qInfo() << "Beginning to crack" << toCrack << "..."; for(uint32_t i = bottom; i < TickCount(); i++) { QString decrypted = decryptGameArg(i, toCrack); if(decrypted.contains(knownArg)) { - fmt::print("Decrypted successfully: {}\n", decrypted.toStdString()); + qInfo() << "Decrypted successfully:" << decrypted; return 0; } } diff --git a/armoury/include/gearview.h b/armoury/include/gearview.h index c60e3b9..1e7a1e1 100644 --- a/armoury/include/gearview.h +++ b/armoury/include/gearview.h @@ -7,7 +7,6 @@ #include "mdlpart.h" #include #include -#include #include struct ModelInfo { @@ -20,13 +19,8 @@ struct GearInfo { Slot slot; ModelInfo modelInfo; - std::string getMtrlPath(int raceID) { - return fmt::format( - "chara/equipment/e{gearId:04d}/material/v{gearVersion:04d}/mt_c{raceId:04d}e{gearId:04d}_{slot}_a.mtrl", - fmt::arg("gearId", modelInfo.primaryID), - fmt::arg("gearVersion", modelInfo.gearVersion), - fmt::arg("raceId", raceID), - fmt::arg("slot", physis_get_slot_name(slot))); + std::string getMtrlPath(const std::string_view material_name) const { + return physis_build_gear_material_path(modelInfo.primaryID, modelInfo.gearVersion, material_name.data()); } }; diff --git a/armoury/include/mainwindow.h b/armoury/include/mainwindow.h index f681d88..dac260d 100644 --- a/armoury/include/mainwindow.h +++ b/armoury/include/mainwindow.h @@ -5,7 +5,6 @@ #include #include -#include #include #include diff --git a/armoury/src/gearview.cpp b/armoury/src/gearview.cpp index 5580d57..427cd71 100644 --- a/armoury/src/gearview.cpp +++ b/armoury/src/gearview.cpp @@ -227,24 +227,8 @@ void GearView::reloadModel() { for (int i = 0; i < mdl.num_material_names; i++) { const char* material_name = mdl.material_names[i]; - // std::string mtrl_path = - // loadedGear.gearInfo->getMtrlPath(201); - std::string mtrl_path = fmt::format( - "chara/equipment/e{gearId:04d}/material/" - "v{gearVersion:04d}{}", - material_name, - fmt::arg("gearId", gear.modelInfo.primaryID), - fmt::arg("gearVersion", gear.modelInfo.gearVersion)); - - int bodyCode = 1; - - // skin path - std::string skinmtrl_path = fmt::format( - "chara/human/c{raceCode:04d}/obj/body/b{bodyCode:04d}/" - "material/v0001{}", - material_name, - fmt::arg("raceCode", physis_get_race_code(fallbackRace, fallbackSubrace, currentGender)), - fmt::arg("bodyCode", bodyCode)); + const std::string mtrl_path = gear.getMtrlPath(material_name); + const std::string skinmtrl_path = physis_build_skin_material_path(physis_get_race_code(fallbackRace, fallbackSubrace, currentGender), 1, material_name); if (physis_gamedata_exists(data, mtrl_path.c_str())) { auto mat = physis_material_parse(cache.lookupFile(mtrl_path.c_str())); @@ -273,15 +257,7 @@ void GearView::reloadModel() { std::vector materials; for (int i = 0; i < mdl.num_material_names; i++) { const char* material_name = mdl.material_names[i]; - - std::string skinmtrl_path = fmt::format( - "chara/human/c{raceCode:04d}/obj/face/f{bodyCode:04d}/" - "material{}", - material_name, - fmt::arg("raceCode", physis_get_race_code(currentRace, currentSubrace, currentGender)), - fmt::arg("bodyCode", *face)); - - fmt::print("oops: {}", skinmtrl_path); + const std::string skinmtrl_path = physis_build_face_material_path(physis_get_race_code(currentRace, currentSubrace, currentGender), *face, material_name); if (physis_gamedata_exists(data, skinmtrl_path.c_str())) { auto mat = physis_material_parse(cache.lookupFile(skinmtrl_path.c_str())); @@ -303,15 +279,7 @@ void GearView::reloadModel() { std::vector materials; for (int i = 0; i < mdl.num_material_names; i++) { const char* material_name = mdl.material_names[i]; - - std::string skinmtrl_path = fmt::format( - "chara/human/c{raceCode:04d}/obj/hair/h{bodyCode:04d}/" - "material/v0001{}", - material_name, - fmt::arg("raceCode", physis_get_race_code(currentRace, currentSubrace, currentGender)), - fmt::arg("bodyCode", *hair)); - - fmt::print("oops: {}", skinmtrl_path); + const std::string skinmtrl_path = physis_build_hair_material_path(physis_get_race_code(currentRace, currentSubrace, currentGender), *hair, material_name); if (physis_gamedata_exists(data, skinmtrl_path.c_str())) { auto mat = physis_material_parse(cache.lookupFile(skinmtrl_path.c_str())); @@ -333,15 +301,7 @@ void GearView::reloadModel() { std::vector materials; for (int i = 0; i < mdl.num_material_names; i++) { const char* material_name = mdl.material_names[i]; - - std::string skinmtrl_path = fmt::format( - "chara/human/c{raceCode:04d}/obj/ear/e{bodyCode:04d}/" - "material/v0001{}", - material_name, - fmt::arg("raceCode", physis_get_race_code(currentRace, currentSubrace, currentGender)), - fmt::arg("bodyCode", *ear)); - - fmt::print("oops: {}", skinmtrl_path); + const std::string skinmtrl_path = physis_build_ear_material_path(physis_get_race_code(currentRace, currentSubrace, currentGender), *ear, material_name); if (physis_gamedata_exists(data, skinmtrl_path.c_str())) { auto mat = physis_material_parse(cache.lookupFile(skinmtrl_path.c_str())); @@ -361,13 +321,7 @@ void GearView::reloadModel() { auto mdl = physis_mdl_parse(mdl_data.size, mdl_data.data); const char* material_name = mdl.material_names[0]; - - std::string skinmtrl_path = fmt::format( - "chara/human/c{raceCode:04d}/obj/tail/t{bodyCode:04d}/" - "material/v0001{}", - material_name, - fmt::arg("raceCode", physis_get_race_code(currentRace, currentSubrace, currentGender)), - fmt::arg("bodyCode", *tail)); + const std::string skinmtrl_path = physis_build_tail_material_path(physis_get_race_code(currentRace, currentSubrace, currentGender), *tail, material_name); if (physis_gamedata_exists(data, skinmtrl_path.c_str())) { auto mat = physis_material_parse(cache.lookupFile(skinmtrl_path.c_str())); diff --git a/bonedecomp/src/main.cpp b/bonedecomp/src/main.cpp index 6c53f6e..d6eb747 100644 --- a/bonedecomp/src/main.cpp +++ b/bonedecomp/src/main.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include "gamedata.h" diff --git a/exdviewer/src/mainwindow.cpp b/exdviewer/src/mainwindow.cpp index a13bb2d..80bf50e 100644 --- a/exdviewer/src/mainwindow.cpp +++ b/exdviewer/src/mainwindow.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include "exdpart.h" diff --git a/explorer/src/filetreewindow.cpp b/explorer/src/filetreewindow.cpp index a122bfe..8d02feb 100644 --- a/explorer/src/filetreewindow.cpp +++ b/explorer/src/filetreewindow.cpp @@ -31,9 +31,9 @@ FileTreeWindow::FileTreeWindow(GameData* data, QWidget* parent) : QWidget(parent addPath("exd/" + QString(nameLowercase.c_str()) + ".exh"); auto exh = physis_gamedata_read_excel_sheet_header(data, sheetName); - for (int j = 0; j < exh.page_count; j++) { - for (int z = 0; z < exh.language_count; z++) { - std::string path = physis_gamedata_get_exd_filename(nameLowercase.c_str(), &exh, exh.languages[z], j); + for (int j = 0; j < exh->page_count; j++) { + for (int z = 0; z < exh->language_count; z++) { + std::string path = physis_gamedata_get_exd_filename(nameLowercase.c_str(), exh, exh->languages[z], j); addPath(("exd/" + path).c_str()); } diff --git a/mdlviewer/src/mainwindow.cpp b/mdlviewer/src/mainwindow.cpp index 8316ba3..554139f 100644 --- a/mdlviewer/src/mainwindow.cpp +++ b/mdlviewer/src/mainwindow.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include "aboutwindow.h" diff --git a/parts/mdl/mdlpart.cpp b/parts/mdl/mdlpart.cpp index c85be9d..def0bb5 100644 --- a/parts/mdl/mdlpart.cpp +++ b/parts/mdl/mdlpart.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include diff --git a/renderer/CMakeLists.txt b/renderer/CMakeLists.txt index e86822c..e7fed0a 100644 --- a/renderer/CMakeLists.txt +++ b/renderer/CMakeLists.txt @@ -19,7 +19,7 @@ endif() add_library(renderer src/renderer.cpp ${EXTRA_SRC}) target_include_directories(renderer PUBLIC include) -target_link_libraries(renderer PUBLIC Vulkan::Vulkan fmt::fmt physis z glm::glm ${EXTRA_LIBRARIES}) +target_link_libraries(renderer PUBLIC Qt5::Core Vulkan::Vulkan physis z ${EXTRA_LIBRARIES}) target_compile_definitions(renderer PUBLIC GLM_FORCE_RADIANS GLM_FORCE_DEPTH_ZERO_TO_ONE) if(USE_STANDALONE_WINDOW) diff --git a/renderer/src/renderer.cpp b/renderer/src/renderer.cpp index 3829c43..5aace5f 100644 --- a/renderer/src/renderer.cpp +++ b/renderer/src/renderer.cpp @@ -3,8 +3,8 @@ #include "renderer.hpp" +#include #include -#include #include #include #include @@ -33,8 +33,7 @@ DebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData) { - - fmt::print("{}\n", pCallbackData->pMessage); + qInfo() << pCallbackData->pMessage; return VK_FALSE; } @@ -199,7 +198,7 @@ Renderer::Renderer() { createDummyTexture(); - fmt::print("Initialized renderer!\n"); + qInfo() << "Initialized renderer!"; } bool Renderer::initSwapchain(VkSurfaceKHR surface, int width, int height) { @@ -437,7 +436,6 @@ void Renderer::render(std::vector models) { VK_NULL_HANDLE, &imageIndex); if (result == VK_ERROR_OUT_OF_DATE_KHR) { - fmt::print("error out of date\n"); return; } @@ -499,7 +497,6 @@ void Renderer::render(std::vector models) { const auto h = hash(model, material); if(!cachedDescriptors.count(h)) { - fmt::print("Caching descriptor for hash {}\n", h); if (auto descriptor = createDescriptorFor(model, material); descriptor != VK_NULL_HANDLE) { cachedDescriptors[h] = descriptor; } else { @@ -840,7 +837,7 @@ VkShaderModule Renderer::loadShaderFromDisk(const std::string_view path) { std::ifstream file(path.data(), std::ios::ate | std::ios::binary); if (!file.is_open()) { - throw std::runtime_error(fmt::format("failed to open shader file {}", path)); + qFatal("Failed to open shader file: %s", path.data()); } size_t fileSize = (size_t) file.tellg(); @@ -1187,7 +1184,7 @@ VkDescriptorSet Renderer::createDescriptorFor(const RenderModel& model, const Re vkAllocateDescriptorSets(device, &allocateInfo, &set); if (set == VK_NULL_HANDLE) { - fmt::print("Failed to create descriptor set!"); + qFatal("Failed to create descriptor set!"); return VK_NULL_HANDLE; }