1
Fork 0
mirror of https://github.com/redstrate/Novus.git synced 2025-06-07 21:57:46 +00:00

Remove fmt dependency

It's no longer used, and replaced with physis functions where formatting
was needed.
This commit is contained in:
Joshua Goins 2023-09-23 14:51:47 -04:00
parent 633e283abd
commit 2eccb10eda
12 changed files with 23 additions and 102 deletions

View file

@ -5,35 +5,16 @@ cmake_minimum_required(VERSION 3.25)
project(Novus) project(Novus)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
find_package(Qt5 COMPONENTS Core Widgets Concurrent CONFIG REQUIRED) find_package(Qt5 COMPONENTS Core Widgets Concurrent CONFIG REQUIRED)
include(FetchContent) include(FetchContent)
add_subdirectory(extern) 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 # macos
if(APPLE) if(APPLE)
set(USE_STANDALONE_WINDOW TRUE) set(USE_STANDALONE_WINDOW TRUE)
@ -44,7 +25,7 @@ add_subdirectory(exdviewer)
add_subdirectory(armoury) add_subdirectory(armoury)
add_subdirectory(argcracker) add_subdirectory(argcracker)
add_subdirectory(explorer) add_subdirectory(explorer)
add_subdirectory(bonedecomp) #add_subdirectory(bonedecomp) # not yet ported to physis
add_subdirectory(parts) add_subdirectory(parts)
add_subdirectory(common) add_subdirectory(common)
add_subdirectory(mdlviewer) add_subdirectory(mdlviewer)

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
#include <QString> #include <QString>
#include <fmt/core.h> #include <QDebug>
#include <physis.hpp> #include <physis.hpp>
@ -74,13 +74,13 @@ int main(int argc, char* argv[]) {
uint32_t bottom = TickCount() - tickRange; 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++) { for(uint32_t i = bottom; i < TickCount(); i++) {
QString decrypted = decryptGameArg(i, toCrack); QString decrypted = decryptGameArg(i, toCrack);
if(decrypted.contains(knownArg)) { if(decrypted.contains(knownArg)) {
fmt::print("Decrypted successfully: {}\n", decrypted.toStdString()); qInfo() << "Decrypted successfully:" << decrypted;
return 0; return 0;
} }
} }

View file

@ -7,7 +7,6 @@
#include "mdlpart.h" #include "mdlpart.h"
#include <QComboBox> #include <QComboBox>
#include <QWidget> #include <QWidget>
#include <fmt/format.h>
#include <physis.hpp> #include <physis.hpp>
struct ModelInfo { struct ModelInfo {
@ -20,13 +19,8 @@ struct GearInfo {
Slot slot; Slot slot;
ModelInfo modelInfo; ModelInfo modelInfo;
std::string getMtrlPath(int raceID) { std::string getMtrlPath(const std::string_view material_name) const {
return fmt::format( return physis_build_gear_material_path(modelInfo.primaryID, modelInfo.gearVersion, material_name.data());
"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)));
} }
}; };

View file

@ -5,7 +5,6 @@
#include <QComboBox> #include <QComboBox>
#include <QMainWindow> #include <QMainWindow>
#include <fmt/format.h>
#include <physis.hpp> #include <physis.hpp>
#include <unordered_map> #include <unordered_map>

View file

@ -227,24 +227,8 @@ void GearView::reloadModel() {
for (int i = 0; i < mdl.num_material_names; i++) { for (int i = 0; i < mdl.num_material_names; i++) {
const char* material_name = mdl.material_names[i]; const char* material_name = mdl.material_names[i];
// std::string mtrl_path = const std::string mtrl_path = gear.getMtrlPath(material_name);
// loadedGear.gearInfo->getMtrlPath(201); const std::string skinmtrl_path = physis_build_skin_material_path(physis_get_race_code(fallbackRace, fallbackSubrace, currentGender), 1, material_name);
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));
if (physis_gamedata_exists(data, mtrl_path.c_str())) { if (physis_gamedata_exists(data, mtrl_path.c_str())) {
auto mat = physis_material_parse(cache.lookupFile(mtrl_path.c_str())); auto mat = physis_material_parse(cache.lookupFile(mtrl_path.c_str()));
@ -273,15 +257,7 @@ void GearView::reloadModel() {
std::vector<physis_Material> materials; std::vector<physis_Material> materials;
for (int i = 0; i < mdl.num_material_names; i++) { for (int i = 0; i < mdl.num_material_names; i++) {
const char* material_name = mdl.material_names[i]; const char* material_name = mdl.material_names[i];
const std::string skinmtrl_path = physis_build_face_material_path(physis_get_race_code(currentRace, currentSubrace, currentGender), *face, material_name);
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);
if (physis_gamedata_exists(data, skinmtrl_path.c_str())) { if (physis_gamedata_exists(data, skinmtrl_path.c_str())) {
auto mat = physis_material_parse(cache.lookupFile(skinmtrl_path.c_str())); auto mat = physis_material_parse(cache.lookupFile(skinmtrl_path.c_str()));
@ -303,15 +279,7 @@ void GearView::reloadModel() {
std::vector<physis_Material> materials; std::vector<physis_Material> materials;
for (int i = 0; i < mdl.num_material_names; i++) { for (int i = 0; i < mdl.num_material_names; i++) {
const char* material_name = mdl.material_names[i]; const char* material_name = mdl.material_names[i];
const std::string skinmtrl_path = physis_build_hair_material_path(physis_get_race_code(currentRace, currentSubrace, currentGender), *hair, material_name);
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);
if (physis_gamedata_exists(data, skinmtrl_path.c_str())) { if (physis_gamedata_exists(data, skinmtrl_path.c_str())) {
auto mat = physis_material_parse(cache.lookupFile(skinmtrl_path.c_str())); auto mat = physis_material_parse(cache.lookupFile(skinmtrl_path.c_str()));
@ -333,15 +301,7 @@ void GearView::reloadModel() {
std::vector<physis_Material> materials; std::vector<physis_Material> materials;
for (int i = 0; i < mdl.num_material_names; i++) { for (int i = 0; i < mdl.num_material_names; i++) {
const char* material_name = mdl.material_names[i]; const char* material_name = mdl.material_names[i];
const std::string skinmtrl_path = physis_build_ear_material_path(physis_get_race_code(currentRace, currentSubrace, currentGender), *ear, material_name);
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);
if (physis_gamedata_exists(data, skinmtrl_path.c_str())) { if (physis_gamedata_exists(data, skinmtrl_path.c_str())) {
auto mat = physis_material_parse(cache.lookupFile(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); auto mdl = physis_mdl_parse(mdl_data.size, mdl_data.data);
const char* material_name = mdl.material_names[0]; const char* material_name = mdl.material_names[0];
const std::string skinmtrl_path = physis_build_tail_material_path(physis_get_race_code(currentRace, currentSubrace, currentGender), *tail, material_name);
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));
if (physis_gamedata_exists(data, skinmtrl_path.c_str())) { if (physis_gamedata_exists(data, skinmtrl_path.c_str())) {
auto mat = physis_material_parse(cache.lookupFile(skinmtrl_path.c_str())); auto mat = physis_material_parse(cache.lookupFile(skinmtrl_path.c_str()));

View file

@ -7,7 +7,6 @@
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
#include <QProcess> #include <QProcess>
#include <fmt/format.h>
#include <magic_enum.hpp> #include <magic_enum.hpp>
#include "gamedata.h" #include "gamedata.h"

View file

@ -11,7 +11,6 @@
#include <QMenuBar> #include <QMenuBar>
#include <QTableWidget> #include <QTableWidget>
#include <QUrl> #include <QUrl>
#include <fmt/core.h>
#include <physis.hpp> #include <physis.hpp>
#include "exdpart.h" #include "exdpart.h"

View file

@ -31,9 +31,9 @@ FileTreeWindow::FileTreeWindow(GameData* data, QWidget* parent) : QWidget(parent
addPath("exd/" + QString(nameLowercase.c_str()) + ".exh"); addPath("exd/" + QString(nameLowercase.c_str()) + ".exh");
auto exh = physis_gamedata_read_excel_sheet_header(data, sheetName); auto exh = physis_gamedata_read_excel_sheet_header(data, sheetName);
for (int j = 0; j < exh.page_count; j++) { for (int j = 0; j < exh->page_count; j++) {
for (int z = 0; z < exh.language_count; z++) { 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); std::string path = physis_gamedata_get_exd_filename(nameLowercase.c_str(), exh, exh->languages[z], j);
addPath(("exd/" + path).c_str()); addPath(("exd/" + path).c_str());
} }

View file

@ -12,7 +12,6 @@
#include <QMenuBar> #include <QMenuBar>
#include <QTableWidget> #include <QTableWidget>
#include <QUrl> #include <QUrl>
#include <fmt/core.h>
#include <physis.hpp> #include <physis.hpp>
#include "aboutwindow.h" #include "aboutwindow.h"

View file

@ -12,7 +12,6 @@
#include <QVulkanInstance> #include <QVulkanInstance>
#include <QVulkanWindow> #include <QVulkanWindow>
#include <QWindow> #include <QWindow>
#include <fmt/core.h>
#include <glm/gtc/quaternion.hpp> #include <glm/gtc/quaternion.hpp>
#include <glm/gtc/type_ptr.inl> #include <glm/gtc/type_ptr.inl>

View file

@ -19,7 +19,7 @@ endif()
add_library(renderer src/renderer.cpp ${EXTRA_SRC}) add_library(renderer src/renderer.cpp ${EXTRA_SRC})
target_include_directories(renderer PUBLIC include) 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) target_compile_definitions(renderer PUBLIC GLM_FORCE_RADIANS GLM_FORCE_DEPTH_ZERO_TO_ONE)
if(USE_STANDALONE_WINDOW) if(USE_STANDALONE_WINDOW)

View file

@ -3,8 +3,8 @@
#include "renderer.hpp" #include "renderer.hpp"
#include <QDebug>
#include <array> #include <array>
#include <fmt/core.h>
#include <fstream> #include <fstream>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/transform.hpp> #include <glm/gtx/transform.hpp>
@ -33,8 +33,7 @@ DebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT messageType, VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
void* pUserData) { void* pUserData) {
qInfo() << pCallbackData->pMessage;
fmt::print("{}\n", pCallbackData->pMessage);
return VK_FALSE; return VK_FALSE;
} }
@ -199,7 +198,7 @@ Renderer::Renderer() {
createDummyTexture(); createDummyTexture();
fmt::print("Initialized renderer!\n"); qInfo() << "Initialized renderer!";
} }
bool Renderer::initSwapchain(VkSurfaceKHR surface, int width, int height) { bool Renderer::initSwapchain(VkSurfaceKHR surface, int width, int height) {
@ -437,7 +436,6 @@ void Renderer::render(std::vector<RenderModel> models) {
VK_NULL_HANDLE, &imageIndex); VK_NULL_HANDLE, &imageIndex);
if (result == VK_ERROR_OUT_OF_DATE_KHR) { if (result == VK_ERROR_OUT_OF_DATE_KHR) {
fmt::print("error out of date\n");
return; return;
} }
@ -499,7 +497,6 @@ void Renderer::render(std::vector<RenderModel> models) {
const auto h = hash(model, material); const auto h = hash(model, material);
if(!cachedDescriptors.count(h)) { if(!cachedDescriptors.count(h)) {
fmt::print("Caching descriptor for hash {}\n", h);
if (auto descriptor = createDescriptorFor(model, material); descriptor != VK_NULL_HANDLE) { if (auto descriptor = createDescriptorFor(model, material); descriptor != VK_NULL_HANDLE) {
cachedDescriptors[h] = descriptor; cachedDescriptors[h] = descriptor;
} else { } else {
@ -840,7 +837,7 @@ VkShaderModule Renderer::loadShaderFromDisk(const std::string_view path) {
std::ifstream file(path.data(), std::ios::ate | std::ios::binary); std::ifstream file(path.data(), std::ios::ate | std::ios::binary);
if (!file.is_open()) { 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(); size_t fileSize = (size_t) file.tellg();
@ -1187,7 +1184,7 @@ VkDescriptorSet Renderer::createDescriptorFor(const RenderModel& model, const Re
vkAllocateDescriptorSets(device, &allocateInfo, &set); vkAllocateDescriptorSets(device, &allocateInfo, &set);
if (set == VK_NULL_HANDLE) { if (set == VK_NULL_HANDLE) {
fmt::print("Failed to create descriptor set!"); qFatal("Failed to create descriptor set!");
return VK_NULL_HANDLE; return VK_NULL_HANDLE;
} }