From 474c7215dd50fdce4094958275326e7c9628c6d6 Mon Sep 17 00:00:00 2001 From: angryzor Date: Sun, 2 Jun 2024 01:46:01 +0200 Subject: [PATCH] Almost SDK-agnostic --- .gitmodules | 5 +- CMakeLists.txt | 110 +++++--- natvis/CMakeLists.txt | 2 +- rangers-sdk | 1 - sdks/rangers-sdk | 1 + sdks/wars-sdk | 1 + src/CMakeLists.txt | 22 +- src/Pch.h | 7 + .../GOCVisualDebugDrawRenderer.cpp | 7 +- src/hot-reload/ReloadManager.cpp | 8 +- src/ui/common/editors/Basic.h | 37 ++- src/ui/common/editors/GraphicsContext.cpp | 41 ++- src/ui/common/editors/LevelInfo.h | 3 + src/ui/common/editors/ObjectData.cpp | 16 +- .../editors/{ => rangers}/LevelInfo.cpp | 4 +- src/ui/common/editors/wars/LevelInfo.cpp | 175 ++++++++++++ src/ui/game-services/GameServiceInspector.cpp | 258 ++++-------------- src/ui/game-services/GameServiceInspector.h | 1 - .../game-service-inspectors/CameraManager.cpp | 41 +++ .../game-service-inspectors/CameraManager.h | 3 + .../game-service-inspectors/CameraService.cpp | 17 ++ .../game-service-inspectors/CameraService.h | 3 + .../FxParamManager.cpp | 35 --- .../game-service-inspectors/FxParamManager.h | 25 -- .../GameModeResourceManager.cpp | 15 + .../GameModeResourceManager.h | 3 + .../game-service-inspectors/LevelInfo.cpp | 25 ++ .../game-service-inspectors/LevelInfo.h | 3 + .../game-service-inspectors/ObjectWorld.cpp | 54 ++++ .../game-service-inspectors/ObjectWorld.h | 3 + .../game-service-inspectors/StageInfo.cpp | 13 + .../game-service-inspectors/StageInfo.h | 3 + .../TerrainManager.cpp | 10 + .../game-service-inspectors/TerrainManager.h | 1 + .../rangers/FxParamManager.cpp | 107 ++++++++ .../wars/FxParamManager.cpp | 60 ++++ .../LevelEditor/LevelEditor.cpp | 14 +- .../rangers/GOCPlayerParameter.cpp | 14 +- .../editors/ResObjectWorldEditor.cpp | 2 +- src/utilities/CompatibleObject.cpp | 5 + 40 files changed, 783 insertions(+), 372 deletions(-) delete mode 160000 rangers-sdk create mode 160000 sdks/rangers-sdk create mode 160000 sdks/wars-sdk rename src/ui/common/editors/{ => rangers}/LevelInfo.cpp (99%) create mode 100644 src/ui/common/editors/wars/LevelInfo.cpp create mode 100644 src/ui/game-services/game-service-inspectors/CameraManager.cpp create mode 100644 src/ui/game-services/game-service-inspectors/CameraManager.h create mode 100644 src/ui/game-services/game-service-inspectors/CameraService.cpp create mode 100644 src/ui/game-services/game-service-inspectors/CameraService.h delete mode 100644 src/ui/game-services/game-service-inspectors/FxParamManager.cpp create mode 100644 src/ui/game-services/game-service-inspectors/GameModeResourceManager.cpp create mode 100644 src/ui/game-services/game-service-inspectors/GameModeResourceManager.h create mode 100644 src/ui/game-services/game-service-inspectors/LevelInfo.cpp create mode 100644 src/ui/game-services/game-service-inspectors/LevelInfo.h create mode 100644 src/ui/game-services/game-service-inspectors/ObjectWorld.cpp create mode 100644 src/ui/game-services/game-service-inspectors/ObjectWorld.h create mode 100644 src/ui/game-services/game-service-inspectors/StageInfo.cpp create mode 100644 src/ui/game-services/game-service-inspectors/StageInfo.h create mode 100644 src/ui/game-services/game-service-inspectors/TerrainManager.cpp create mode 100644 src/ui/game-services/game-service-inspectors/TerrainManager.h create mode 100644 src/ui/game-services/game-service-inspectors/rangers/FxParamManager.cpp create mode 100644 src/ui/game-services/game-service-inspectors/wars/FxParamManager.cpp diff --git a/.gitmodules b/.gitmodules index 05851cf..62e693b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,7 +5,7 @@ path = vendor/filewatch/filewatch url = https://github.com/ThomasMonkman/filewatch.git [submodule "rangers-sdk"] - path = rangers-sdk + path = sdks/rangers-sdk url = https://github.com/angryzor/rangers-sdk.git [submodule "vendor/hedgelib/HedgeLib"] path = vendor/hedgelib/HedgeLib @@ -22,3 +22,6 @@ [submodule "vendor/implot/implot"] path = vendor/implot/implot url = https://github.com/epezent/implot.git +[submodule "sdks/wars-sdk"] + path = sdks/wars-sdk + url = https://github.com/angryzor/wars-sdk.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 696c823..f61aa58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,55 +9,77 @@ set(PROJECT_LONG_DESCRIPTION "In-engine development kit for Sonic Forces") set(PROJECT_COPYRIGHT "Copyright (c) 2024 angryzor - Licensed under GPL3") string(TIMESTAMP PROJECT_BUILD_DATE "%Y-%m-%d") -set(DEVTOOLS_GAME_FOLDER "C:\\Program Files (x86)\\Steam\\steamapps\\common\\SonicForces" CACHE STRING "The location of your game folder.") -cmake_path(SET DEVTOOLS_GAME_FOLDER_NORMALIZED NORMALIZE ${DEVTOOLS_GAME_FOLDER}) -cmake_path(APPEND DEVTOOLS_GAME_FOLDER_NORMALIZED "build/main/projects/exec/Sonic Forces.exe" OUTPUT_VARIABLE SONIC_FORCES_GAME_EXECUTABLE) -if(DEFINED ENV{SONIC_FORCES_SDK}) - message("SONIC_FORCES_SDK environment variable found. Using this version instead of the local submodule.") - cmake_path(SET WARS_SDK_PATH NORMALIZE $ENV{SONIC_FORCES_SDK}) -else() - set(WARS_SDK_PATH wars-sdk) -endif() add_subdirectory(vendor EXCLUDE_FROM_ALL) -add_subdirectory(${WARS_SDK_PATH} wars-sdk EXCLUDE_FROM_ALL) -# DevTools -add_library(devtools SHARED) -target_compile_features(devtools PRIVATE cxx_std_17) -target_compile_options(devtools PRIVATE /ZI /permissive-) -target_compile_definitions(devtools - PRIVATE - DEVTOOLS_BINARY_FILENAME=$ - DEVTOOLS_PROJECT_AUTHOR="${PROJECT_AUTHOR}" - DEVTOOLS_PROJECT_DESCRIPTION="${PROJECT_DESCRIPTION}" - DEVTOOLS_PROJECT_LONG_DESCRIPTION="${PROJECT_LONG_DESCRIPTION}" - DEVTOOLS_PROJECT_COPYRIGHT="${PROJECT_COPYRIGHT}" - DEVTOOLS_BUILD_DATE="${PROJECT_BUILD_DATE}" - DEVTOOLS_VERSION=${PROJECT_VERSION} - DEVTOOLS_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} - DEVTOOLS_VERSION_MINOR=${PROJECT_VERSION_MINOR} - DEVTOOLS_VERSION_PATCH=${PROJECT_VERSION_PATCH} -) -set_target_properties(devtools - PROPERTIES - VS_DEBUGGER_COMMAND ${SONIC_FORCES_GAME_EXECUTABLE} - VS_DEBUGGER_WORKING_DIRECTORY "${DEVTOOLS_GAME_FOLDER_NORMALIZED}/build/main/projects/exec" -) - -foreach(LIB wars-sdk HedgeLib filewatch detours imgui imgui-backend-win32 imgui-backend-dx11 imgui-file-dialog imguizmo implot) - target_link_libraries(devtools PRIVATE ${LIB}) -endforeach() +# Settings for target sdks +set(SDK_VAR_wars "SONIC_FORCES_SDK") +set(GAME_FOLDER_DEFAULT_wars "C:\\Program Files (x86)\\Steam\\steamapps\\common\\SonicForces") +set(GAME_EXECUTABLE_wars "build/main/projects/exec/Sonic Forces.exe") +set(WORKING_DIRECTORY_wars "build/main/projects/exec") +set(MOD_SUBFOLDER_wars "build/main/projects/exec/Mods/devtools") + +set(SDK_VAR_rangers "SONIC_FRONTIERS_SDK") +set(GAME_FOLDER_DEFAULT_rangers "C:\\Program Files (x86)\\Steam\\steamapps\\common\\SonicFrontiers") +set(GAME_EXECUTABLE_rangers "Sonic Frontiers.exe") +set(WORKING_DIRECTORY_rangers "") +set(MOD_SUBFOLDER_rangers "Mods/devtools") + +# The main target +foreach(DEVTOOLS_TARGET_SDK rangers wars) + set(GAME_FOLDER ${GAME_FOLDER_DEFAULT_${DEVTOOLS_TARGET_SDK}} CACHE STRING "The location of your ${DEVTOOLS_TARGET_SDK} game folder.") + set(DEVTOOLS_TARGET devtools-${DEVTOOLS_TARGET_SDK}) + cmake_path(SET GAME_FOLDER_NORMALIZED NORMALIZE ${GAME_FOLDER}) + cmake_path(APPEND GAME_FOLDER_NORMALIZED ${GAME_EXECUTABLE_${DEVTOOLS_TARGET_SDK}} OUTPUT_VARIABLE GAME_EXECUTABLE) + cmake_path(APPEND GAME_FOLDER_NORMALIZED ${WORKING_DIRECTORY_${DEVTOOLS_TARGET_SDK}} OUTPUT_VARIABLE WORKING_DIRECTORY) + cmake_path(APPEND GAME_FOLDER_NORMALIZED ${MOD_SUBFOLDER_${DEVTOOLS_TARGET_SDK}} OUTPUT_VARIABLE MOD_FOLDER) -add_subdirectory(src) -add_subdirectory(natvis) -configure_file(Mod.ini.in Mod.ini) + if(DEFINED ENV{${SDK_VAR_${DEVTOOLS_TARGET_SDK}}}) + message("${SDK_VAR_${DEVTOOLS_TARGET_SDK}} environment variable found. Using this version instead of the local submodule.") + cmake_path(SET SDK_PATH NORMALIZE $ENV{${SDK_VAR_${DEVTOOLS_TARGET_SDK}}}) + else() + set(SDK_PATH ${DEVTOOLS_TARGET_SDK}-sdk) + endif() -set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT devtools) + add_subdirectory(${SDK_PATH} ${DEVTOOLS_TARGET_SDK}-sdk EXCLUDE_FROM_ALL) -cmake_path(APPEND DEVTOOLS_GAME_FOLDER_NORMALIZED "build/main/projects/exec/Mods/devtools" OUTPUT_VARIABLE MOD_FOLDER) + add_library(${DEVTOOLS_TARGET} SHARED) + target_compile_features(${DEVTOOLS_TARGET} PRIVATE cxx_std_17) + target_compile_options(${DEVTOOLS_TARGET} PRIVATE /ZI /permissive-) + target_compile_definitions(${DEVTOOLS_TARGET} + PRIVATE + DEVTOOLS_BINARY_FILENAME=$ + DEVTOOLS_TARGET_SDK="${DEVTOOLS_TARGET_SDK}" + DEVTOOLS_TARGET_SDK_${DEVTOOLS_TARGET_SDK}=1 + DEVTOOLS_PROJECT_AUTHOR="${PROJECT_AUTHOR}" + DEVTOOLS_PROJECT_DESCRIPTION="${PROJECT_DESCRIPTION}" + DEVTOOLS_PROJECT_LONG_DESCRIPTION="${PROJECT_LONG_DESCRIPTION}" + DEVTOOLS_PROJECT_COPYRIGHT="${PROJECT_COPYRIGHT}" + DEVTOOLS_BUILD_DATE="${PROJECT_BUILD_DATE}" + DEVTOOLS_VERSION=${PROJECT_VERSION} + DEVTOOLS_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} + DEVTOOLS_VERSION_MINOR=${PROJECT_VERSION_MINOR} + DEVTOOLS_VERSION_PATCH=${PROJECT_VERSION_PATCH} + ) + set_target_properties(${DEVTOOLS_TARGET} + PROPERTIES + OUTPUT_NAME "devtools" + VS_DEBUGGER_COMMAND ${GAME_EXECUTABLE} + VS_DEBUGGER_WORKING_DIRECTORY ${WORKING_DIRECTORY} + ) -install(TARGETS devtools RUNTIME DESTINATION "${MOD_FOLDER}") -install(DIRECTORY resources/ DESTINATION "${MOD_FOLDER}") -install(FILES LICENSE.txt "${CMAKE_CURRENT_BINARY_DIR}/Mod.ini" DESTINATION "${MOD_FOLDER}") + foreach(LIB ${DEVTOOLS_TARGET_SDK}-sdk HedgeLib filewatch detours imgui imgui-backend-win32 imgui-backend-dx11 imgui-file-dialog imguizmo implot) + target_link_libraries(${DEVTOOLS_TARGET} PRIVATE ${LIB}) + endforeach() + + add_subdirectory(src ${DEVTOOLS_TARGET}/src) + add_subdirectory(natvis ${DEVTOOLS_TARGET}/natvis) + configure_file(Mod.ini.in Mod.ini) + + set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${DEVTOOLS_TARGET}) + + install(TARGETS ${DEVTOOLS_TARGET} RUNTIME DESTINATION "${MOD_FOLDER}") + install(DIRECTORY resources/ DESTINATION "${MOD_FOLDER}") + install(FILES LICENSE.txt "${CMAKE_CURRENT_BINARY_DIR}/Mod.ini" DESTINATION "${MOD_FOLDER}") +endforeach() diff --git a/natvis/CMakeLists.txt b/natvis/CMakeLists.txt index b9c2127..f81af86 100644 --- a/natvis/CMakeLists.txt +++ b/natvis/CMakeLists.txt @@ -1,4 +1,4 @@ -target_sources(devtools +target_sources(${DEVTOOLS_TARGET} PRIVATE Eigen.natvis ) diff --git a/rangers-sdk b/rangers-sdk deleted file mode 160000 index 2f0df2b..0000000 --- a/rangers-sdk +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2f0df2bb468f1d1660c88d6dca5ef4da7941345c diff --git a/sdks/rangers-sdk b/sdks/rangers-sdk new file mode 160000 index 0000000..b7122f1 --- /dev/null +++ b/sdks/rangers-sdk @@ -0,0 +1 @@ +Subproject commit b7122f1362a8ff936bb9360de4a7efba8a3530f3 diff --git a/sdks/wars-sdk b/sdks/wars-sdk new file mode 160000 index 0000000..a96ea58 --- /dev/null +++ b/sdks/wars-sdk @@ -0,0 +1 @@ +Subproject commit a96ea58621d0242b4f275b724ccf364d25aefc9f diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2193d9f..893517e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,8 +1,8 @@ -target_precompile_headers(devtools +target_precompile_headers(${DEVTOOLS_TARGET} PRIVATE Pch.h ) -target_sources(devtools +target_sources(${DEVTOOLS_TARGET} PRIVATE devtools.rc DllMain.cpp @@ -17,8 +17,8 @@ target_sources(devtools # ui/common/editors/Camera.cpp ui/common/editors/ObjectData.cpp ui/common/editors/Reflection.cpp - # ui/common/editors/GraphicsContext.cpp - # ui/common/editors/LevelInfo.cpp + ui/common/editors/GraphicsContext.cpp + ui/common/editors/${DEVTOOLS_TARGET_SDK}/LevelInfo.cpp # ui/common/editors/Needle.cpp # ui/common/editors/SurfRide.cpp ui/common/viewers/Basic.cpp @@ -38,14 +38,17 @@ target_sources(devtools # ui/core-services/MemoryInspector.cpp ui/Desktop.cpp # ui/game-modes/GameModeInspector.cpp - ui/game-services/game-service-inspectors/FxParamManager.cpp + ui/game-services/game-service-inspectors/${DEVTOOLS_TARGET_SDK}/FxParamManager.cpp + ui/game-services/game-service-inspectors/ObjectWorld.cpp + ui/game-services/game-service-inspectors/StageInfo.cpp + ui/game-services/game-service-inspectors/CameraManager.cpp ui/game-services/GameServiceInspector.cpp ui/operation-modes/LevelEditor/LevelEditor.cpp ui/operation-modes/LevelEditor/ObjectDataInspector.cpp ui/operation-modes/LevelEditor/ObjectLibrary.cpp ui/operation-modes/LevelEditor/SetObjectList.cpp ui/operation-modes/ObjectInspection/component-inspectors/GOCTransform.cpp - ui/operation-modes/ObjectInspection/component-inspectors/wars/GOCPlayerParameter.cpp + ui/operation-modes/ObjectInspection/component-inspectors/${DEVTOOLS_TARGET_SDK}/GOCPlayerParameter.cpp ui/operation-modes/ObjectInspection/ObjectInspection.cpp ui/operation-modes/ObjectInspection/ObjectInspector.cpp ui/operation-modes/ObjectInspection/ObjectList.cpp @@ -55,7 +58,7 @@ target_sources(devtools # ui/operation-modes/SurfRideEditor/SurfRideEditor.cpp ui/operation-modes/OperationMode.cpp # ui/resources/editors/ResEffectEditor.cpp - # ui/resources/editors/ResObjectWorldEditor.cpp + ui/resources/editors/ResObjectWorldEditor.cpp # ui/resources/editors/ResMaterialEditor.cpp ui/resources/editors/ResReflectionEditor.cpp # ui/resources/editors/ResSurfRideProjectEditor.cpp @@ -112,13 +115,16 @@ target_sources(devtools ui/fonts/Inter.h ui/game-modes/GameModeInspector.h ui/game-services/game-service-inspectors/FxParamManager.h + ui/game-services/game-service-inspectors/ObjectWorld.h + ui/game-services/game-service-inspectors/StageInfo.h + ui/game-services/game-service-inspectors/CameraManager.h ui/game-services/GameServiceInspector.h ui/operation-modes/LevelEditor/LevelEditor.h ui/operation-modes/LevelEditor/ObjectDataInspector.h ui/operation-modes/LevelEditor/ObjectLibrary.h ui/operation-modes/LevelEditor/SetObjectList.h ui/operation-modes/ObjectInspection/component-inspectors/GOCTransform.h - ui/operation-modes/ObjectInspection/component-inspectors/wars/GOCPlayerParameter.h + ui/operation-modes/ObjectInspection/component-inspectors/${DEVTOOLS_TARGET_SDK}/GOCPlayerParameter.h ui/operation-modes/ObjectInspection/ObjectInspection.h ui/operation-modes/ObjectInspection/ObjectInspector.h ui/operation-modes/ObjectInspection/ObjectList.h diff --git a/src/Pch.h b/src/Pch.h index 609e44a..ea56cfc 100644 --- a/src/Pch.h +++ b/src/Pch.h @@ -13,7 +13,14 @@ #include #include + +#ifdef DEVTOOLS_TARGET_SDK_wars #include +#endif + +#ifdef DEVTOOLS_TARGET_SDK_rangers +#include +#endif #include #include diff --git a/src/debug-rendering/GOCVisualDebugDrawRenderer.cpp b/src/debug-rendering/GOCVisualDebugDrawRenderer.cpp index 8a5e2f7..135f4cf 100644 --- a/src/debug-rendering/GOCVisualDebugDrawRenderer.cpp +++ b/src/debug-rendering/GOCVisualDebugDrawRenderer.cpp @@ -59,7 +59,7 @@ HOOK(bool, __fastcall, VisualDebugDrawSetup, 0x140682D50, GOCMyVisualDebugDraw* csl::ut::Color8 fillColor{ setupInfo.color }; //fillColor.a = 80; fillColor.a = GOCVisualDebugDrawRenderer::gocVisualDebugDrawOpacity; - gocVisual->fillGeometry->Initialize(GOCVisualDebugDrawRenderer::instance->drawContext, *setupInfo.geometry, {}); + gocVisual->fillGeometry->Initialize(GOCVisualDebugDrawRenderer::instance->drawContext, *setupInfo.geometry); gocVisual->fillGeometry->SetColor(fillColor); gocVisual->hasGeometry = true; @@ -124,8 +124,7 @@ void GOCVisualDebugDrawRenderer::Renderable::Render(const hh::gfnd::RenderablePa continue; //goc->geometry->Render(renderer->drawContext, goc->worldMatrix); - goc->fillGeometry->SetTransform(goc->worldMatrix); - goc->fillGeometry->Render(renderer->drawContext); + goc->fillGeometry->Render(renderer->drawContext, goc->worldMatrix); } if (renderer->enabled) { @@ -169,7 +168,7 @@ void GOCVisualDebugDrawRenderer::Renderable::Render(const hh::gfnd::RenderablePa Eigen::Affine3f affine; affine.fromPositionOrientationScale(cGoc->worldPos.m_Position, cGoc->worldPos.m_Rotation, cGoc->scale); - renderer->drawContext->DrawSphereFixed({ TransformToAffine3f(cGoc->frame->fullTransform) * affine }, 1, { 255, 0, 255, 255 }); + renderer->drawContext->DrawSphere({ TransformToAffine3f(cGoc->frame->fullTransform) * affine }, 1, { 255, 0, 255, 255 }); } } } diff --git a/src/hot-reload/ReloadManager.cpp b/src/hot-reload/ReloadManager.cpp index ca79aad..0ac1c3b 100644 --- a/src/hot-reload/ReloadManager.cpp +++ b/src/hot-reload/ReloadManager.cpp @@ -122,8 +122,8 @@ void ReloadManager::Reload(void* buffer, size_t fileSize, hh::game::ResObjectWor auto* allocator = layer->GetAllocator(); bool wasEnabled = layer->IsEnable(); - //if (auto* levelEditor = dynamic_cast(&*Desktop::instance->operationMode)) - // levelEditor->Deselect(); + if (auto* levelEditor = dynamic_cast(&*Desktop::instance->operationMode)) + levelEditor->Deselect(); { Reference l{ layer }; @@ -140,8 +140,8 @@ void ReloadManager::Reload(void* buffer, size_t fileSize, hh::game::ResObjectWor chunk->AddLayer(hh::game::ObjectWorldChunkLayer::Create(allocator, resource)); chunk->SetLayerEnabled(resource->GetName(), wasEnabled); - //if (auto* levelEditor = dynamic_cast(&*Desktop::instance->operationMode)) - // levelEditor->ReloadObjectWorldData(); + if (auto* levelEditor = dynamic_cast(&*Desktop::instance->operationMode)) + levelEditor->ReloadObjectWorldData(); success = true; break; diff --git a/src/ui/common/editors/Basic.h b/src/ui/common/editors/Basic.h index 5073e94..974c692 100644 --- a/src/ui/common/editors/Basic.h +++ b/src/ui/common/editors/Basic.h @@ -8,25 +8,6 @@ static bool Editor(const char* label, T& obj) { return DragScalar(label, obj); } -template -static bool Editor(const char* label, T(&arr)[Len]) { - bool edited{}; - char name[200]; - snprintf(name, sizeof(name), "%s[0..%zd]", label, Len); - - if (ImGui::TreeNode(name)) { - for (size_t i = 0; i < Len; i++) { - snprintf(name, sizeof(name), "%s[%zd]", label, i); - edited |= Editor(name, arr[i]); - } - - ImGui::TreePop(); - } - - return edited; -} - - template static bool Editor(const char* label, Eigen::Matrix& mat) { bool edited{}; @@ -68,3 +49,21 @@ template static bool Editor(const char* label, T*& gameObject) { return Editor(label, reinterpret_cast(gameObject)); } + +template +static bool Editor(const char* label, T(&arr)[Len]) { + bool edited{}; + char name[200]; + snprintf(name, sizeof(name), "%s[0..%zd]", label, Len); + + if (ImGui::TreeNode(name)) { + for (size_t i = 0; i < Len; i++) { + snprintf(name, sizeof(name), "%s[%zd]", label, i); + edited |= Editor(name, arr[i]); + } + + ImGui::TreePop(); + } + + return edited; +} diff --git a/src/ui/common/editors/GraphicsContext.cpp b/src/ui/common/editors/GraphicsContext.cpp index 0896399..962bbff 100644 --- a/src/ui/common/editors/GraphicsContext.cpp +++ b/src/ui/common/editors/GraphicsContext.cpp @@ -2,6 +2,7 @@ #include #include +const char* projectionTypeNames[]{ "Perspective (FOV)", "Perspective (frustum)", "Orthogonal" }; bool Editor(const char* label, hh::gfnd::ViewportData& viewport) { bool edited{}; @@ -13,29 +14,45 @@ bool Editor(const char* label, hh::gfnd::ViewportData& viewport) edited |= Editor("Y", viewport.viewportDimensions.y); edited |= Editor("Width", viewport.viewportDimensions.width); edited |= Editor("Height", viewport.viewportDimensions.height); - Viewer("Render width", viewport.viewportDimensions.maybeRenderWidth); - Viewer("Render height", viewport.viewportDimensions.maybeRenderHeight); + // Viewer("Render width", viewport.viewportDimensions.maybeRenderWidth); + // Viewer("Render height", viewport.viewportDimensions.maybeRenderHeight); ImGui::EndGroup(); + ImGui::SeparatorText("View settings"); + if (BeginVectorViewerTable("LookAt position", false)) { + Viewer("LookAt position", viewport.lookAtPos); + EndVectorViewerTable(); + } + ImGui::SeparatorText("Projection settings"); - Viewer("Aspect ratio", viewport.aspectRatio); - Viewer("FOV", viewport.fov); - Viewer("Near clipping plane", viewport.nearClip); - Viewer("Far clipping plane", viewport.farClip); + Viewer("Projection type", projectionTypeNames[static_cast(viewport.projectionType)]); + + switch (viewport.projectionType) { + case hh::gfnd::ViewportData::ProjectionType::PERSPECTIVE_FOV: + Viewer("Aspect ratio", viewport.projectionParameters.fov.aspectRatio); + Viewer("FOV", viewport.projectionParameters.fov.fov); + Viewer("Near clipping plane", viewport.projectionParameters.fov.nearClip); + Viewer("Far clipping plane", viewport.projectionParameters.fov.farClip); + break; + default: + Viewer("Top", viewport.projectionParameters.frustum.top); + Viewer("Bottom", viewport.projectionParameters.frustum.bottom); + Viewer("Left", viewport.projectionParameters.frustum.left); + Viewer("Right", viewport.projectionParameters.frustum.right); + Viewer("Near clipping plane", viewport.projectionParameters.frustum.nearClip); + Viewer("Far clipping plane", viewport.projectionParameters.frustum.farClip); + break; + } ImGui::SeparatorText("View matrix"); Viewer("View matrix", viewport.viewMatrix); - ImGui::SeparatorText("Inverse view matrix"); - Viewer("Inverse view matrix", viewport.inverseViewMatrix); + //ImGui::SeparatorText("Inverse view matrix"); + //Viewer("Inverse view matrix", viewport.inverseViewMatrix); ImGui::SeparatorText("Projection matrix"); Viewer("Projection matrix", viewport.projMatrix); - if (BeginVectorViewerTable("LookAt position", false)) { - Viewer("LookAt position", viewport.lookAtPos); - EndVectorViewerTable(); - } //Editor("Unk5", viewport.unk5); //Editor("Unk7", viewport.unk7); //Editor("Unk8", viewport.unk8); diff --git a/src/ui/common/editors/LevelInfo.h b/src/ui/common/editors/LevelInfo.h index 5fca2fa..f80af20 100644 --- a/src/ui/common/editors/LevelInfo.h +++ b/src/ui/common/editors/LevelInfo.h @@ -1,4 +1,7 @@ #pragma once bool Editor(const char* label, app::level::StageData& obj); + +#ifdef DEVTOOLS_TARGET_SDK_rangers bool Editor(const char* label, app::level::PlayerInformation& playerInfo); +#endif diff --git a/src/ui/common/editors/ObjectData.cpp b/src/ui/common/editors/ObjectData.cpp index 62e3492..df29dff 100644 --- a/src/ui/common/editors/ObjectData.cpp +++ b/src/ui/common/editors/ObjectData.cpp @@ -28,6 +28,13 @@ struct GOCActivatorSpawner { float m_distance{}; }; +hh::fnd::RflClassMember gocActivatorSpawnerMembers[]{ + { "m_range", nullptr, nullptr, hh::fnd::RflClassMember::TYPE_FLOAT, hh::fnd::RflClassMember::TYPE_VOID, 0, 0, offsetof(GOCActivatorSpawner, m_range), nullptr }, + { "m_distance", nullptr, nullptr, hh::fnd::RflClassMember::TYPE_FLOAT, hh::fnd::RflClassMember::TYPE_VOID, 0, 0, offsetof(GOCActivatorSpawner, m_distance), nullptr }, +}; + +hh::fnd::RflClass gocActivatorSpawnerClass{ "GOCActivatorSpawner", nullptr, sizeof(GOCActivatorSpawner), nullptr, 0, gocActivatorSpawnerMembers, 2, nullptr }; + //ComponentData* CreateComponentData(const GOComponentRegistry::GOComponentRegistryItem* gocRegItem) { // auto* allocator = hh::fnd::MemoryRouter::GetModuleAllocator(); // @@ -82,7 +89,14 @@ bool Editor(const char* label, hh::game::ObjectData& obj) if (editedTransform) UpdateLocalTransform(ObjectTransformDataToAffine3f(localTransformData), obj); - //ImGui::SeparatorText("Component configuration"); + ImGui::SeparatorText("Component configuration"); + for (auto* componentConfig : obj.componentData) { + if (ImGui::CollapsingHeader(componentConfig->type)) { + ImGui::Text("Configuration:"); + if (!strcmp(componentConfig->type, "RangeSpawning")) + edited |= ReflectionEditor("Component properties", componentConfig->data, &gocActivatorSpawnerClass); + } + } //for (auto* componentConfig : obj.componentData) { // auto* gocInfo = objSystem->goComponentRegistry->GetComponentInformationByName(componentConfig->type); diff --git a/src/ui/common/editors/LevelInfo.cpp b/src/ui/common/editors/rangers/LevelInfo.cpp similarity index 99% rename from src/ui/common/editors/LevelInfo.cpp rename to src/ui/common/editors/rangers/LevelInfo.cpp index 10a8025..a75db87 100644 --- a/src/ui/common/editors/LevelInfo.cpp +++ b/src/ui/common/editors/rangers/LevelInfo.cpp @@ -1,5 +1,5 @@ -#include "LevelInfo.h" -#include "Basic.h" +#include +#include #include static const char* chunkTypeNames[] = { "INITIAL", "AFTER" }; diff --git a/src/ui/common/editors/wars/LevelInfo.cpp b/src/ui/common/editors/wars/LevelInfo.cpp new file mode 100644 index 0000000..f0dc61a --- /dev/null +++ b/src/ui/common/editors/wars/LevelInfo.cpp @@ -0,0 +1,175 @@ +#include +#include + +using namespace app::level; + +static const char* chunkTypeNames[] = { "INITIAL", "AFTER" }; +static const char* characterNames[] = { "SONIC", "BUDDY", "TAG", "CLASSIC", "NONE", "SHADOW" }; + +bool Editor(const char* label, app::player::CharacterId& charId) { + return ComboEnum(label, charId, characterNames); +} + +template +bool Editor(const char* label, StageData::List& list) { + bool edited{}; + + if (ImGui::TreeNode(label)) { + edited |= Editor("Count", list.count); + edited |= Editor("Items", list.items); + ImGui::TreePop(); + } + + return edited; +} + +bool Editor(const char* label, StageData& data) { + bool edited{}; + + ImGui::PushID(&data); + + edited |= Editor("Name", data.name); + edited |= Editor("Directory", data.dir); + edited |= Editor("Background music", data.bgm); + edited |= Editor("Ambience", data.amb); + edited |= Editor("Background music retry start", data.bgmRetryStart); + edited |= Editor("Background music retry fade", data.bgmRetryFade); + + int missingIdx{ -1 }; + edited |= DragScalar("Stage number", data.stageNumber, &missingIdx); + edited |= DragScalar("Category number", data.categoryNumber, &missingIdx); + edited |= DragScalar("Sequence number", data.sequenceNumber, &missingIdx); + + if (ImGui::TreeNode("Attributes")) { + edited |= CheckboxFlags("Boss", data.attributeFlags, StageData::AttributeFlag::BOSS); + edited |= CheckboxFlags("Extra", data.attributeFlags, StageData::AttributeFlag::EXTRA); + edited |= CheckboxFlags("Special", data.attributeFlags, StageData::AttributeFlag::SPECIAL); + edited |= CheckboxFlags("DLC", data.attributeFlags, StageData::AttributeFlag::DLC); + edited |= CheckboxFlags("Credit", data.attributeFlags, StageData::AttributeFlag::CREDIT); + edited |= CheckboxFlags("Character change", data.attributeFlags, StageData::AttributeFlag::CHARA_CHANGE); + edited |= CheckboxFlags("Shift BP", data.attributeFlags, StageData::AttributeFlag::SHIFTBP); + edited |= CheckboxFlags("Top view", data.attributeFlags, StageData::AttributeFlag::TOP_VIEW); + edited |= CheckboxFlags("AppGfxParam", data.attributeFlags, StageData::AttributeFlag::APP_GFX_PARAM); + edited |= CheckboxFlags("Number ring", data.attributeFlags, StageData::AttributeFlag::NUMBER_RING); + edited |= CheckboxFlags("Yellow moon ring / Title", data.attributeFlags, StageData::AttributeFlag::YELLOW_MOON_RING_OR_TITLE); + edited |= CheckboxFlags("Use SOS", data.attributeFlags, StageData::AttributeFlag::USE_SOS); + ImGui::TreePop(); + } + + edited |= Editor("Character ID", data.characterId); + + edited |= Editor("Static sectors", data.staticSectors); + edited |= Editor("Dynamic sectors", data.dynamicSectors); + edited |= Editor("Opening events", data.openingEvents); + edited |= Editor("Cleared events", data.clearedEvents); + + edited |= ComboEnum("Chunk type", data.chunkType, chunkTypeNames); + + ImGui::PopID(); + + return edited; +} + + +// template +// bool Editor(const char* label, PlayerInformation::Unk1& data) { +// bool edited{}; +// ImGui::PushID(label); + +// char checkboxLabel[100]; +// snprintf(checkboxLabel, sizeof(checkboxLabel), "%s###%s", data.isSet ? "" : label, "Is Set"); + +// edited |= Editor(checkboxLabel, data.isSet); + +// if (data.isSet) { +// ImGui::SameLine(); +// edited |= Editor(label, data.value); +// } + +// ImGui::PopID(); +// return edited; +// } + +// bool Editor(const char* label, PlayerInformation& playerInfo) +// { +// bool edited{}; +// ImGui::PushID(label); +// //Unk1> playerObject; +// edited |= Editor("characterId", playerInfo.characterId); +// edited |= Editor("position", playerInfo.position); +// edited |= Editor("vector440", playerInfo.vector440); +// edited |= Editor("rotation", playerInfo.rotation); +// edited |= Editor("dword80", playerInfo.dword80); +// edited |= Editor("vector490", playerInfo.vector490); +// edited |= Editor("vector4B0", playerInfo.vector4B0); +// edited |= Editor("vector4D0", playerInfo.vector4D0); +// edited |= Editor("vector4F0", playerInfo.vector4F0); +// edited |= Editor("vector4110", playerInfo.vector4110); +// edited |= Editor("vector4130", playerInfo.vector4130); +// edited |= Editor("vector4150", playerInfo.vector4150); +// edited |= Editor("vector4170", playerInfo.vector4170); +// edited |= Editor("vector4190", playerInfo.vector4190); +// edited |= Editor("vector41B0", playerInfo.vector41B0); +// edited |= Editor("vector41D0", playerInfo.vector41D0); +// edited |= Editor("vector41F0", playerInfo.vector41F0); +// edited |= Editor("vector4210", playerInfo.vector4210); +// edited |= Editor("vector4230", playerInfo.vector4230); +// edited |= Editor("vector4250", playerInfo.vector4250); +// edited |= Editor("vector4270", playerInfo.vector4270); +// edited |= Editor("word290", playerInfo.word290); +// //if (playerInfo->qword294.isSet) Editor("qword294", playerInfo->qword294.value); +// //if (playerInfo->qword2A0.isSet) Editor("qword2A0", playerInfo->qword2A0.value); +// edited |= Editor("Boost gauge count", playerInfo.boostGaugeCount); +// edited |= Editor("Stamina", playerInfo.stamina); +// edited |= Editor("dword2BC", playerInfo.dword2BC); +// edited |= Editor("word2C4", playerInfo.word2C4); +// edited |= Editor("dword2C8", playerInfo.dword2C8); +// edited |= Editor("Quick CyLoop amount", playerInfo.quickCyloopAmount); +// edited |= Editor("qword2D8", playerInfo.qword2D8); +// edited |= Editor("dword2E4", playerInfo.dword2E4); +// //uint32_t dword2EC; +// //uint32_t dword2F0; +// edited |= Editor("Ground normal", playerInfo.groundNormal); +// edited |= Editor("Altitude", playerInfo.altitude); +// edited |= Editor("vector4330", playerInfo.vector4330); +// edited |= Editor("dword350", playerInfo.dword350); +// edited |= Editor("dword358", playerInfo.dword358); +// //uint32_t dword360; +// //uint32_t dword364; +// //uint32_t dword368; +// //uint32_t dword36C; +// //uint32_t dword370; +// //uint32_t dword374; +// //uint32_t dword378; +// //uint32_t dword37C; +// //uint32_t dword380; +// //uint32_t dword384; +// //uint32_t dword388; +// //uint32_t dword38C; +// //uint32_t dword390; +// //uint32_t dword394; +// //uint64_t qword398; +// //uint32_t dword3A0; +// //uint32_t dword3A4; +// //uint32_t dword3A8; +// //uint32_t dword3AC; +// //uint32_t dword3B0; +// //uint32_t dword3B4; +// //uint32_t dword3B8; +// //uint32_t dword3BC; +// //if (playerInfo->qword3C0.isSet) Editor("qword3C0", playerInfo->qword3C0.value); +// edited |= Editor("Max rings", playerInfo.maxRings); +// //uint32_t dword3D4; +// //uint32_t dword3D8; +// //if (playerInfo->unk13241.isSet) Editor("unk13241", playerInfo->unk13241.value); +// edited |= Editor("vector4480", playerInfo.vector4480); +// //if (playerInfo->qword4A0.isSet) Editor("qword4A0", playerInfo->qword4A0.value); +// edited |= Editor("dword4AC", playerInfo.dword4AC); +// edited |= Editor("word4B4", playerInfo.word4B4); +// edited |= Editor("dword4B8", playerInfo.dword4B8); +// edited |= Editor("dword4C0", playerInfo.dword4C0); +// edited |= Editor("transform44F0", playerInfo.transform44F0); +// //Unk4 qword510[3]; +// ImGui::PopID(); +// return edited; +// } diff --git a/src/ui/game-services/GameServiceInspector.cpp b/src/ui/game-services/GameServiceInspector.cpp index ac8024e..f59dc13 100644 --- a/src/ui/game-services/GameServiceInspector.cpp +++ b/src/ui/game-services/GameServiceInspector.cpp @@ -1,16 +1,65 @@ #include "GameServiceInspector.h" #include #include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include +#ifdef DEVTOOLS_TARGET_SDK_wars #include "game-service-inspectors/FxParamManager.h" +#include "game-service-inspectors/ObjectWorld.h" +#include "game-service-inspectors/StageInfo.h" +#include "game-service-inspectors/CameraManager.h" + +typedef std::tuple< + app::gfx::FxParamManager, + hh::game::ObjectWorld, + app::level::StageInfo, + hh::game::CameraManager +> InspectableServices; +#endif + +#ifdef DEVTOOLS_TARGET_SDK_rangers +#include "game-service-inspectors/FxParamManager.h" +#include "game-service-inspectors/ObjectWorld.h" +#include "game-service-inspectors/StageInfo.h" +#include "game-service-inspectors/LevelInfo.h" +#include "game-service-inspectors/CameraManager.h" +#include "game-service-inspectors/CameraService.h" +#include "game-service-inspectors/GameModeResourceManager.h" +#include "game-service-inspectors/TerrainManager.h" + +typedef std::tuple< + app::gfx::FxParamManager, + hh::game::ObjectWorld, + app::level::StageInfo, + app::level::LevelInfo, + hh::game::CameraManager, + app::camera::CameraService, + app::game::GameModeResourceManager, + app::trr::TerrainManager +> InspectableServices; + +#endif + + +template +bool RenderServiceInspector(hh::game::GameService& service) { + bool result{ service.pStaticClass == T::GetClass() }; + + if (result) { + RenderGameServiceInspector(static_cast(service)); + } + + return result; +} + +template +class ServiceIterator; +template +class ServiceIterator> { +public: + static void Render(hh::game::GameService& service) { + (RenderServiceInspector(service) || ...) || (ImGui::Text("Inspector for this service not yet implemented"), true); + } +}; using namespace hh::game; @@ -24,198 +73,7 @@ void GameServiceInspector::RenderContents() { for (auto* service : gameManager->GetServices()) { ImGui::PushID(service); if (ImGui::CollapsingHeader(service->pStaticClass->pName)) - RenderServiceInspector(*service); + ServiceIterator<>::Render(*service); ImGui::PopID(); } } - -void GameServiceInspector::RenderServiceInspector(hh::game::GameService& service) { - if (service.pStaticClass == app::gfx::FxParamManager::GetClass()) { - RenderGameServiceInspector(static_cast(service)); - } - // else if (service.pStaticClass == hh::game::ObjectWorld::GetClass()) { - // RenderObjectWorldInspector(static_cast(service)); - // } - // else if (service.pStaticClass == app::level::StageInfo::GetClass()) { - // RenderStageInfoInspector(static_cast(service)); - // } - // else if (service.pStaticClass == app::level::LevelInfo::GetClass()) { - // RenderLevelInfoInspector(static_cast(service)); - // } - // else if (service.pStaticClass == app::game::GameModeResourceManager::GetClass()) { - // RenderGameModeResourceManagerInspector(static_cast(service)); - // } - // else if (service.pStaticClass == app::trr::TerrainManager::GetClass()) { - // RenderTerrainManagerInspector(static_cast(service)); - // } - // else if (service.pStaticClass == hh::game::CameraManager::GetClass()) { - // RenderCameraManagerInspector(static_cast(service)); - // } - // else if (service.pStaticClass == app::camera::CameraService::GetClass()) { - // RenderCameraServiceInspector(static_cast(service)); - // } - else { - ImGui::Text("Inspector for this service not yet implemented"); - } -} - -// void GameServiceInspector::RenderObjectWorldInspector(hh::game::ObjectWorld& objWorld) { -// int i = 0; -// for (auto* chunk : objWorld.GetWorldChunks()) { -// if (ImGui::TreeNode(chunk, "Chunk %d", i++)) { -// bool editorMode = chunk->IsStatusEditor(); - -// if (ImGui::Checkbox("Editor mode", &editorMode)) -// chunk->SetEditorStatus(editorMode); - -// if (ImGui::CollapsingHeader("Layers")) { -// for (auto* layer : chunk->GetLayers()) { -// if (ImGui::TreeNode(layer, layer->GetName())) { -// bool enabled = layer->IsEnable(); - -// if (ImGui::Checkbox("Enabled", &enabled)) -// chunk->SetLayerEnabled(layer->GetName(), enabled); - -// if (ImGui::Button("Edit resource")) -// ResObjectWorldEditor::Create(Desktop::instance->GetAllocator(), layer->GetResource()); - -// ImGui::TreePop(); -// } -// } -// } - -// if (ImGui::CollapsingHeader("Object statuses")) { -// for (auto& status : chunk->GetObjectStatuses()) { -// if (ImGui::TreeNode(&status, status.objectData->name)) { -// CheckboxFlags("Enabled", status.flags, WorldObjectStatus::Flag::ENABLED); -// CheckboxFlags("Is alive", status.flags, WorldObjectStatus::Flag::IS_ALIVE); -// CheckboxFlags("Started", status.flags, WorldObjectStatus::Flag::STARTED); -// CheckboxFlags("No restart", status.flags, WorldObjectStatus::Flag::NO_RESTART); - -// Editor("Spawn priority", status.spawnPriority); - -// ImGui::SeparatorText("Object Data"); -// Editor("Object data", *status.objectData); - -// ImGui::TreePop(); -// } -// } -// } -// ImGui::TreePop(); -// } -// } -// } - -// void GameServiceInspector::RenderStageInfoInspector(app::level::StageInfo& service) -// { -// ImGui::SeparatorText("Stages"); -// for (auto& stage : service.stages) { -// if (ImGui::TreeNodeEx(stage, ImGuiTreeNodeFlags_None, "%s", stage->name.c_str())) { -// Editor("Stage data", *stage); -// ImGui::TreePop(); -// } -// } -// } - -// void GameServiceInspector::RenderLevelInfoInspector(app::level::LevelInfo& service) -// { -// auto* stageData = service.GetStageData(); -// ImGui::SeparatorText("Stage data"); -// if (stageData) -// Editor("Stage data", *stageData); -// else -// ImGui::Text("No stage data loaded."); - -// if (ImGui::TreeNode("PlayerInformation")) { -// for (size_t i = 0; i < 2; i++) { -// auto* playerInfo = service.GetPlayerInformation(i); -// char nodeName[50]; -// snprintf(nodeName, sizeof(nodeName), "Player %zd", i); - -// if (ImGui::TreeNode(nodeName)) { -// Editor(nodeName, *playerInfo); -// ImGui::TreePop(); -// } -// } -// ImGui::TreePop(); -// } -// } - -// void GameServiceInspector::RenderGameModeResourceManagerInspector(app::game::GameModeResourceManager& service) -// { -// for (auto& module : service.modules) { -// if (ImGui::TreeNodeEx(module, ImGuiTreeNodeFlags_DefaultOpen, "%x", module->GetNameHash())) { -// ImGui::Text("Module flags: %x", module->flags); -// if (ImGui::TreeNode("Resources")) { -// for (auto& resource : module->resourceCollection->resources) { -// ImGui::Text("%s", resource.name); -// } -// ImGui::TreePop(); -// } -// ImGui::TreePop(); -// } -// } -// } - -// void GameServiceInspector::RenderTerrainManagerInspector(app::trr::TerrainManager& service) -// { -// Viewer("Unk11", service.currentTerrain); -// Viewer("Unk10 count", service.unk10.size()); -// //ImGui::SeparatorText("Unk13s:"); -// //if (service.unk13.) -// //for (auto i = service.unk13.begin(); i != service.unk13.end(); i++) { -// // ImGui::Text("%s", i.key()); -// //} -// } - -// void GameServiceInspector::RenderCameraManagerInspector(hh::game::CameraManager& service) -// { -// ImGui::SeparatorText("Components"); -// for (auto* component : service.GetComponents()) { -// if (ImGui::TreeNode(component, component->name)) { -// ImGui::Text("Viewport ID: %d", component->viewportId); -// Editor("Viewport data", component->viewportData); -// ImGui::TreePop(); -// } -// } - -// ImGui::SeparatorText("Camera stacks"); -// for (int i = 0; i < service.GetCameraCount(); i++) { -// ImGui::PushID(i); -// if (ImGui::TreeNode("Camera stack", "Camera stack %d", i)) { -// csl::ut::MoveArray components{ hh::fnd::MemoryRouter::GetTempAllocator() }; -// service.GetComponents(i, components); - -// if (components.size() > 0) { -// ImGui::SeparatorText("Components"); - -// for (auto* component : components) { -// if (ImGui::TreeNode(component, component->name)) { -// ImGui::Text("Viewport ID: %d", component->viewportId); -// Editor("Viewport data", component->viewportData); -// ImGui::TreePop(); -// } -// } -// } - -// ImGui::TreePop(); -// } -// ImGui::PopID(); -// } -// } - -// void GameServiceInspector::RenderCameraServiceInspector(app::camera::CameraService& service) -// { -// for (auto& bridgeUnit : service.cameraBridges) { -// if (bridgeUnit.cameraBridge.cameraFrameId != -1 && bridgeUnit.cameraComponent != nullptr && ImGui::TreeNodeEx(&bridgeUnit, ImGuiTreeNodeFlags_None, "%d", bridgeUnit.cameraBridge.cameraFrameId)) { -// ImGui::Text("Camera frame ID: %d - %s", bridgeUnit.cameraBridge.cameraFrameId, bridgeUnit.cameraBridge.cameraFrame->name.c_str()); -// Editor("CameraFrame", bridgeUnit.cameraBridge.cameraFrame); -// if (ImGui::TreeNodeEx("Component", ImGuiTreeNodeFlags_None, "%s", bridgeUnit.cameraComponent->name.c_str())) { -// ImGui::Text("Viewport ID: %d", bridgeUnit.cameraComponent->viewportId); -// Editor("Viewport data", bridgeUnit.cameraComponent->viewportData); -// ImGui::TreePop(); -// } -// ImGui::TreePop(); -// } -// } -// } diff --git a/src/ui/game-services/GameServiceInspector.h b/src/ui/game-services/GameServiceInspector.h index 6a39fec..633e590 100644 --- a/src/ui/game-services/GameServiceInspector.h +++ b/src/ui/game-services/GameServiceInspector.h @@ -8,5 +8,4 @@ class GameServiceInspector : public StandaloneWindow public: GameServiceInspector(csl::fnd::IAllocator* allocator); virtual void RenderContents() override; - static void RenderServiceInspector(hh::game::GameService& service); }; diff --git a/src/ui/game-services/game-service-inspectors/CameraManager.cpp b/src/ui/game-services/game-service-inspectors/CameraManager.cpp new file mode 100644 index 0000000..d2b107e --- /dev/null +++ b/src/ui/game-services/game-service-inspectors/CameraManager.cpp @@ -0,0 +1,41 @@ +#include "CameraManager.h" +#include + +using namespace hh::game; +using namespace hh::gfnd; + +void RenderGameServiceInspector(hh::game::CameraManager& service) +{ + ImGui::SeparatorText("Components"); + for (auto* component : service.GetComponents()) { + if (ImGui::TreeNode(component, component->name)) { + ImGui::Text("Viewport ID: %d", component->viewportId); + Editor("Viewport data", component->viewportData); + ImGui::TreePop(); + } + } + + ImGui::SeparatorText("Camera stacks"); + for (int i = 0; i < service.GetCameraCount(); i++) { + ImGui::PushID(i); + if (ImGui::TreeNode("Camera stack", "Camera stack %d", i)) { + csl::ut::MoveArray components{ hh::fnd::MemoryRouter::GetTempAllocator() }; + service.GetComponents(i, components); + + if (components.size() > 0) { + ImGui::SeparatorText("Components"); + + for (auto* component : components) { + if (ImGui::TreeNode(component, component->name)) { + ImGui::Text("Viewport ID: %d", component->viewportId); + Editor("Viewport data", component->viewportData); + ImGui::TreePop(); + } + } + } + + ImGui::TreePop(); + } + ImGui::PopID(); + } +} diff --git a/src/ui/game-services/game-service-inspectors/CameraManager.h b/src/ui/game-services/game-service-inspectors/CameraManager.h new file mode 100644 index 0000000..a48d86e --- /dev/null +++ b/src/ui/game-services/game-service-inspectors/CameraManager.h @@ -0,0 +1,3 @@ +#pragma once + +void RenderGameServiceInspector(hh::game::CameraManager& service); diff --git a/src/ui/game-services/game-service-inspectors/CameraService.cpp b/src/ui/game-services/game-service-inspectors/CameraService.cpp new file mode 100644 index 0000000..7e20ccb --- /dev/null +++ b/src/ui/game-services/game-service-inspectors/CameraService.cpp @@ -0,0 +1,17 @@ +#include "CameraService.h" + +void RenderGameServiceInspector(app::camera::CameraService& service) +{ + for (auto& bridgeUnit : service.cameraBridges) { + if (bridgeUnit.cameraBridge.cameraFrameId != -1 && bridgeUnit.cameraComponent != nullptr && ImGui::TreeNodeEx(&bridgeUnit, ImGuiTreeNodeFlags_None, "%d", bridgeUnit.cameraBridge.cameraFrameId)) { + ImGui::Text("Camera frame ID: %d - %s", bridgeUnit.cameraBridge.cameraFrameId, bridgeUnit.cameraBridge.cameraFrame->name.c_str()); + Editor("CameraFrame", bridgeUnit.cameraBridge.cameraFrame); + if (ImGui::TreeNodeEx("Component", ImGuiTreeNodeFlags_None, "%s", bridgeUnit.cameraComponent->name.c_str())) { + ImGui::Text("Viewport ID: %d", bridgeUnit.cameraComponent->viewportId); + Editor("Viewport data", bridgeUnit.cameraComponent->viewportData); + ImGui::TreePop(); + } + ImGui::TreePop(); + } + } +} diff --git a/src/ui/game-services/game-service-inspectors/CameraService.h b/src/ui/game-services/game-service-inspectors/CameraService.h new file mode 100644 index 0000000..82a2c79 --- /dev/null +++ b/src/ui/game-services/game-service-inspectors/CameraService.h @@ -0,0 +1,3 @@ +#pragma once + +void RenderGameServiceInspector(app::camera::CameraService& service); \ No newline at end of file diff --git a/src/ui/game-services/game-service-inspectors/FxParamManager.cpp b/src/ui/game-services/game-service-inspectors/FxParamManager.cpp deleted file mode 100644 index 960cd5b..0000000 --- a/src/ui/game-services/game-service-inspectors/FxParamManager.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "FxParamManager.h" - -void RenderGameServiceInspector(app::gfx::FxParamManager& service) { - ImGui::SeparatorText("Interpolated parameters"); - Editor("NeedleFxParameter", service.parameters); - - ImGui::SeparatorText("Interpolators"); - - if (ImGui::TreeNode("NeedleFXParameter")) { - RenderFxParamManagerInterpolatorInspector("FxBloomParameter", *service.paramInterpolators.bloomInterpolator); - RenderFxParamManagerInterpolatorInspector("FxDOFParameter", *service.paramInterpolators.dofInterpolator); - //RenderFxParamManagerInterpolatorInspector>("ToneMapType", *service.paramInterpolators.toneMapTypeInterpolator); - //RenderFxParamManagerInterpolatorInspector>("ExposureMode", *service.paramInterpolators.exposureModeInterpolator); - RenderFxParamManagerInterpolatorInspector("FxColorContrastParameter", *service.paramInterpolators.colorContrastInterpolator); - RenderFxParamManagerInterpolatorInspector("FxToneMapParameter", *service.paramInterpolators.toneMapInterpolator); - RenderFxParamManagerInterpolatorInspector("FxExposureParameter", *service.paramInterpolators.exposureInterpolator); - RenderFxParamManagerInterpolatorInspector("FxShadowMapParameter", *service.paramInterpolators.shadowMapInterpolator); - RenderFxParamManagerInterpolatorInspector("FxScreenBlurParameter", *service.paramInterpolators.blurInterpolator); - RenderFxParamManagerInterpolatorInspector("FxSSAOParameter", *service.paramInterpolators.ssaoInterpolator); - RenderFxParamManagerInterpolatorInspector("FxLightFieldParameter", *service.paramInterpolators.lightFieldInterpolator); - RenderFxParamManagerInterpolatorInspector("FxSHLightFieldParameter", *service.paramInterpolators.shLightFieldInterpolator); - RenderFxParamManagerInterpolatorInspector("FxLightScatteringParameter", *service.paramInterpolators.lightScatteringInterpolator); - RenderFxParamManagerInterpolatorInspector("FxRLRParameter", *service.paramInterpolators.rlrInterpolator); - RenderFxParamManagerInterpolatorInspector("FxOcclusionCapsuleParameter", *service.paramInterpolators.occlusionCapsuleInterpolator); - RenderFxParamManagerInterpolatorInspector("FxGodrayParameter", *service.paramInterpolators.godrayInterpolator); - RenderFxParamManagerInterpolatorInspector("FxScreenSpaceGodrayParameter", *service.paramInterpolators.ssGodrayInterpolator); - RenderFxParamManagerInterpolatorInspector("FxHeatHazeParameter", *service.paramInterpolators.heatHazeInterpolator); - RenderFxParamManagerInterpolatorInspector("FxSceneEnvironmentParameter", *service.paramInterpolators.sceneEnvironmentInterpolator); - RenderFxParamManagerInterpolatorInspector("FxRenderOption", *service.paramInterpolators.renderOptionInterpolator); - RenderFxParamManagerInterpolatorInspector("FxSGGIParameter", *service.paramInterpolators.sggiInterpolator); - RenderFxParamManagerInterpolatorInspector("FxTAAParameter", *service.paramInterpolators.taaInterpolator); - RenderFxParamManagerInterpolatorInspector("FxEffectParameter", *service.paramInterpolators.effectInterpolator); - ImGui::TreePop(); - } -} diff --git a/src/ui/game-services/game-service-inspectors/FxParamManager.h b/src/ui/game-services/game-service-inspectors/FxParamManager.h index 662afc8..b609bd3 100644 --- a/src/ui/game-services/game-service-inspectors/FxParamManager.h +++ b/src/ui/game-services/game-service-inspectors/FxParamManager.h @@ -2,29 +2,4 @@ #include #include -template static void RenderFxParamManagerInterpolatorInspector(const char* name, app::gfx::FxParamManager::InterpolatorT& interpolator) { - if (ImGui::TreeNode(name)) { - ImGui::Text("Enabled group bits: %x", interpolator.interpolationGroupEnabledBits); - - unsigned short i{ 0 }; - for (auto& interpolationJob : interpolator.interpolationJobs) { - char nodename[200]; - snprintf(nodename, sizeof(nodename), "Job %d", i++); - - if (ImGui::TreeNode(nodename)) { - ImGui::Text("Active on interpolation groups %x", interpolationJob.interpolationGroupMemberBits); - ImGui::Text("Owner hash: %zx", interpolationJob.ownerId); - ImGui::Text("Priority: %d", interpolationJob.priority); - Editor("Unk6", interpolationJob.unk6); - ImGui::Text("Tween duration: %f", 1 / interpolationJob.tweenPositionIncrementPerSecond); - ImGui::SliderFloat("Current time", &interpolationJob.currentTweenPosition, 0.0f, 1.0f); - ImGui::SeparatorText("Target parameters"); - Editor("Target parameters", interpolationJob.parameters); - ImGui::TreePop(); - } - } - ImGui::TreePop(); - } -} - void RenderGameServiceInspector(app::gfx::FxParamManager& service); diff --git a/src/ui/game-services/game-service-inspectors/GameModeResourceManager.cpp b/src/ui/game-services/game-service-inspectors/GameModeResourceManager.cpp new file mode 100644 index 0000000..94826f5 --- /dev/null +++ b/src/ui/game-services/game-service-inspectors/GameModeResourceManager.cpp @@ -0,0 +1,15 @@ +void RenderGameServiceInspector(app::game::GameModeResourceManager& service) +{ + for (auto& module : service.modules) { + if (ImGui::TreeNodeEx(module, ImGuiTreeNodeFlags_DefaultOpen, "%x", module->GetNameHash())) { + ImGui::Text("Module flags: %x", module->flags); + if (ImGui::TreeNode("Resources")) { + for (auto& resource : module->resourceCollection->resources) { + ImGui::Text("%s", resource.name); + } + ImGui::TreePop(); + } + ImGui::TreePop(); + } + } +} diff --git a/src/ui/game-services/game-service-inspectors/GameModeResourceManager.h b/src/ui/game-services/game-service-inspectors/GameModeResourceManager.h new file mode 100644 index 0000000..870de34 --- /dev/null +++ b/src/ui/game-services/game-service-inspectors/GameModeResourceManager.h @@ -0,0 +1,3 @@ +#pragma once + +void RenderGameServiceInspector(app::game::GameModeResourceManager& service); \ No newline at end of file diff --git a/src/ui/game-services/game-service-inspectors/LevelInfo.cpp b/src/ui/game-services/game-service-inspectors/LevelInfo.cpp new file mode 100644 index 0000000..f34b760 --- /dev/null +++ b/src/ui/game-services/game-service-inspectors/LevelInfo.cpp @@ -0,0 +1,25 @@ +#include "LevelInfo.h" + +void RenderGameServiceInspector(app::level::LevelInfo& service) +{ + auto* stageData = service.GetStageData(); + ImGui::SeparatorText("Stage data"); + if (stageData) + Editor("Stage data", *stageData); + else + ImGui::Text("No stage data loaded."); + + if (ImGui::TreeNode("PlayerInformation")) { + for (size_t i = 0; i < 2; i++) { + auto* playerInfo = service.GetPlayerInformation(i); + char nodeName[50]; + snprintf(nodeName, sizeof(nodeName), "Player %zd", i); + + if (ImGui::TreeNode(nodeName)) { + Editor(nodeName, *playerInfo); + ImGui::TreePop(); + } + } + ImGui::TreePop(); + } +} diff --git a/src/ui/game-services/game-service-inspectors/LevelInfo.h b/src/ui/game-services/game-service-inspectors/LevelInfo.h new file mode 100644 index 0000000..aee63d1 --- /dev/null +++ b/src/ui/game-services/game-service-inspectors/LevelInfo.h @@ -0,0 +1,3 @@ +#pragma once + +void RenderGameServiceInspector(app::level::LevelInfo& service); diff --git a/src/ui/game-services/game-service-inspectors/ObjectWorld.cpp b/src/ui/game-services/game-service-inspectors/ObjectWorld.cpp new file mode 100644 index 0000000..e3bc5d6 --- /dev/null +++ b/src/ui/game-services/game-service-inspectors/ObjectWorld.cpp @@ -0,0 +1,54 @@ +#include "ObjectWorld.h" +#include +#include +#include +#include + +using namespace hh::game; + +void RenderGameServiceInspector(hh::game::ObjectWorld& objWorld) { + int i = 0; + for (auto* chunk : objWorld.GetWorldChunks()) { + if (ImGui::TreeNode(chunk, "Chunk %d", i++)) { + bool editorMode = chunk->IsStatusEditor(); + + if (ImGui::Checkbox("Editor mode", &editorMode)) + chunk->SetEditorStatus(editorMode); + + if (ImGui::CollapsingHeader("Layers")) { + for (auto* layer : chunk->GetLayers()) { + if (ImGui::TreeNode(layer, layer->GetName())) { + bool enabled = layer->IsEnable(); + + if (ImGui::Checkbox("Enabled", &enabled)) + chunk->SetLayerEnabled(layer->GetName(), enabled); + + if (ImGui::Button("Edit resource")) + ResObjectWorldEditor::Create(Desktop::instance->GetAllocator(), layer->GetResource()); + + ImGui::TreePop(); + } + } + } + + if (ImGui::CollapsingHeader("Object statuses")) { + for (auto& status : chunk->GetObjectStatuses()) { + if (ImGui::TreeNode(&status, status.objectData->name)) { + CheckboxFlags("Enabled", status.flags, WorldObjectStatus::Flag::ENABLED); + CheckboxFlags("Is alive", status.flags, WorldObjectStatus::Flag::IS_ALIVE); + CheckboxFlags("Started", status.flags, WorldObjectStatus::Flag::STARTED); + CheckboxFlags("No restart", status.flags, WorldObjectStatus::Flag::NO_RESTART); + + //Editor("Spawn priority", status.spawnPriority); + + ImGui::SeparatorText("Object Data"); + Editor("Object data", *status.objectData); + + ImGui::TreePop(); + } + } + } + ImGui::TreePop(); + } + } +} diff --git a/src/ui/game-services/game-service-inspectors/ObjectWorld.h b/src/ui/game-services/game-service-inspectors/ObjectWorld.h new file mode 100644 index 0000000..6efe2b0 --- /dev/null +++ b/src/ui/game-services/game-service-inspectors/ObjectWorld.h @@ -0,0 +1,3 @@ +#pragma once + +void RenderGameServiceInspector(hh::game::ObjectWorld& objWorld); diff --git a/src/ui/game-services/game-service-inspectors/StageInfo.cpp b/src/ui/game-services/game-service-inspectors/StageInfo.cpp new file mode 100644 index 0000000..a876215 --- /dev/null +++ b/src/ui/game-services/game-service-inspectors/StageInfo.cpp @@ -0,0 +1,13 @@ +#include "StageInfo.h" +#include + +void RenderGameServiceInspector(app::level::StageInfo& service) +{ + ImGui::SeparatorText("Stages"); + for (auto& stage : service.stages) { + if (ImGui::TreeNodeEx(&stage, ImGuiTreeNodeFlags_None, "%s", stage.GetName())) { + Editor("Stage data", stage); + ImGui::TreePop(); + } + } +} diff --git a/src/ui/game-services/game-service-inspectors/StageInfo.h b/src/ui/game-services/game-service-inspectors/StageInfo.h new file mode 100644 index 0000000..bf2d1b4 --- /dev/null +++ b/src/ui/game-services/game-service-inspectors/StageInfo.h @@ -0,0 +1,3 @@ +#pragma once + +void RenderGameServiceInspector(app::level::StageInfo& service); diff --git a/src/ui/game-services/game-service-inspectors/TerrainManager.cpp b/src/ui/game-services/game-service-inspectors/TerrainManager.cpp new file mode 100644 index 0000000..5e0a07f --- /dev/null +++ b/src/ui/game-services/game-service-inspectors/TerrainManager.cpp @@ -0,0 +1,10 @@ +void RenderGameServiceInspector(app::trr::TerrainManager& service) +{ + Viewer("Unk11", service.currentTerrain); + Viewer("Unk10 count", service.unk10.size()); + //ImGui::SeparatorText("Unk13s:"); + //if (service.unk13.) + //for (auto i = service.unk13.begin(); i != service.unk13.end(); i++) { + // ImGui::Text("%s", i.key()); + //} +} diff --git a/src/ui/game-services/game-service-inspectors/TerrainManager.h b/src/ui/game-services/game-service-inspectors/TerrainManager.h new file mode 100644 index 0000000..92a214e --- /dev/null +++ b/src/ui/game-services/game-service-inspectors/TerrainManager.h @@ -0,0 +1 @@ +void RenderGameServiceInspector(app::trr::TerrainManager& service); diff --git a/src/ui/game-services/game-service-inspectors/rangers/FxParamManager.cpp b/src/ui/game-services/game-service-inspectors/rangers/FxParamManager.cpp new file mode 100644 index 0000000..6f85126 --- /dev/null +++ b/src/ui/game-services/game-service-inspectors/rangers/FxParamManager.cpp @@ -0,0 +1,107 @@ +#include + +template static void RenderFxParamManagerInterpolatorInspector(const char* name, app::gfx::FxParamManager::Interpolator& interpolator) { + if (ImGui::TreeNode(name)) { + ImGui::Text("Enabled group bits: %x", interpolator.interpolationGroupEnabledBits); + + unsigned short i{ 0 }; + for (auto& interpolationJob : interpolator.interpolationJobs) { + char nodename[200]; + snprintf(nodename, sizeof(nodename), "Job %d", i++); + + if (ImGui::TreeNode(nodename)) { + ImGui::Text("Active on interpolation groups %x", interpolationJob.interpolationGroupMemberBits); + ImGui::Text("Owner hash: %zx", interpolationJob.ownerId); + ImGui::Text("Priority: %d", interpolationJob.priority); + Editor("Unk6", interpolationJob.unk6); + ImGui::Text("Tween duration: %f", 1 / interpolationJob.tweenPositionIncrementPerSecond); + ImGui::SliderFloat("Current time", &interpolationJob.currentTweenPosition, 0.0f, 1.0f); + ImGui::SeparatorText("Target parameters"); + Editor("Target parameters", interpolationJob.parameters); + ImGui::TreePop(); + } + } + ImGui::TreePop(); + } +} + +void RenderGameServiceInspector(app::gfx::FxParamManager& service) { + ImGui::SeparatorText("SceneParameters"); + ImGui::Text("Current: %d", service.currentSceneParameters); + ImGui::Text("SceneParameters list:"); + + for (size_t i = 0; i < 2; i++) { + if (auto* sceneParameters = service.sceneParameters[i]) { + if (ImGui::TreeNode(sceneParameters, "%d", i)) { + Editor("Scene data", *sceneParameters->GetSceneData()); + ImGui::TreePop(); + } + } + } + + ImGui::SeparatorText("Interpolated parameters"); + Editor("NeedleFxParameter", service.parameters); + Editor("NeedleFxSceneConfig", service.sceneConfig); + + ImGui::SeparatorText("Interpolators"); + + if (ImGui::TreeNode("NeedleFXParameter")) { + RenderFxParamManagerInterpolatorInspector("FxBloomParameter", service.paramInterpolators.bloomInterpolator); + RenderFxParamManagerInterpolatorInspector("FxDOFParameter", service.paramInterpolators.dofInterpolator); + RenderFxParamManagerInterpolatorInspector("FxColorContrastParameter", service.paramInterpolators.colorContrastInterpolator); + RenderFxParamManagerInterpolatorInspector("FxToneMapParameter", service.paramInterpolators.tonemapInterpolator); + RenderFxParamManagerInterpolatorInspector("FxCameraControlParameter", service.paramInterpolators.cameraControlInterpolator); + RenderFxParamManagerInterpolatorInspector("FxShadowMapParameter", service.paramInterpolators.shadowmapInterpolator); + RenderFxParamManagerInterpolatorInspector("FxShadowHeightMapParameter", service.paramInterpolators.shadowHeightMapInterpolator); + RenderFxParamManagerInterpolatorInspector("FxVolumetricShadowParameter", service.paramInterpolators.volShadowInterpolator); + RenderFxParamManagerInterpolatorInspector("FxScreenBlurParameter", service.paramInterpolators.blurInterpolator); + RenderFxParamManagerInterpolatorInspector("FxSSAOParameter", service.paramInterpolators.ssaoInterpolator); + RenderFxParamManagerInterpolatorInspector("FxSHLightFieldParameter", service.paramInterpolators.shlightfieldInterpolator); + RenderFxParamManagerInterpolatorInspector("FxLightScatteringParameter", service.paramInterpolators.lightscatteringInterpolator); + RenderFxParamManagerInterpolatorInspector("FxRLRParameter", service.paramInterpolators.rlrInterpolator); + RenderFxParamManagerInterpolatorInspector("FxSSGIParameter", service.paramInterpolators.ssgiInterpolator); + RenderFxParamManagerInterpolatorInspector("FxPlanarReflectionParameter", service.paramInterpolators.planarReflectionInterpolator); + RenderFxParamManagerInterpolatorInspector("FxOcclusionCapsuleParameter", service.paramInterpolators.occlusionCapsuleInterpolator); + RenderFxParamManagerInterpolatorInspector("FxGodrayParameter", service.paramInterpolators.godrayInterpolator); + RenderFxParamManagerInterpolatorInspector("FxScreenSpaceGodrayParameter", service.paramInterpolators.ssGodrayInterpolator); + RenderFxParamManagerInterpolatorInspector("FxHeatHazeParameter", service.paramInterpolators.heatHazeInterpolator); + RenderFxParamManagerInterpolatorInspector("FxSceneEnvironmentParameter", service.paramInterpolators.sceneEnvInterpolator); + RenderFxParamManagerInterpolatorInspector("FxRenderOption", service.paramInterpolators.renderOptionInterpolator); + RenderFxParamManagerInterpolatorInspector("FxSGGIParameter", service.paramInterpolators.sggiInterpolator); + RenderFxParamManagerInterpolatorInspector("FxTAAParameter", service.paramInterpolators.taaInterpolator); + RenderFxParamManagerInterpolatorInspector("FxEffectParameter", service.paramInterpolators.effectInterpolator); + RenderFxParamManagerInterpolatorInspector("FxAtmosphereParameter", service.paramInterpolators.atmosphereInterpolator); + RenderFxParamManagerInterpolatorInspector("FxDensityParameter", service.paramInterpolators.densityInterpolator); + RenderFxParamManagerInterpolatorInspector("FxWindComputeParameter", service.paramInterpolators.windInterpolator); + RenderFxParamManagerInterpolatorInspector("FxGpuEnvironmentParameter", service.paramInterpolators.gpuEnvironmentInterpolator); + RenderFxParamManagerInterpolatorInspector("FxInteractiveWaveParameter", service.paramInterpolators.interactiveWaveInterpolator); + RenderFxParamManagerInterpolatorInspector("FxChromaticAberrationParameter", service.paramInterpolators.chromaticAberrationInterpolator); + RenderFxParamManagerInterpolatorInspector("FxVignetteParameter", service.paramInterpolators.vignetteInterpolator); + RenderFxParamManagerInterpolatorInspector("FxTerrainMaterialBlendingParameter", service.paramInterpolators.terrainBlendInterpolator); + RenderFxParamManagerInterpolatorInspector("FxWeatherParameter", service.paramInterpolators.weatherInterpolator); + RenderFxParamManagerInterpolatorInspector("FxColorAccessibilityFilterParameter", service.paramInterpolators.colorAccessibilityInterpolator); + RenderFxParamManagerInterpolatorInspector("FxCyberNoiseEffectParameter", service.paramInterpolators.cyberNoiseInterpolator); + RenderFxParamManagerInterpolatorInspector("FxCyberSpaceStartNoiseParameter", service.paramInterpolators.cyberStartNoiseInterpolator); + RenderFxParamManagerInterpolatorInspector("FxCyberNPCSSEffectRenderParameter", service.paramInterpolators.cyberNPCSSInterpolator); + RenderFxParamManagerInterpolatorInspector("FxDentParameter", service.paramInterpolators.dentInterpolator); + RenderFxParamManagerInterpolatorInspector("FxFieldScanEffectRenderParameter", service.paramInterpolators.fieldScanInterpolator); + RenderFxParamManagerInterpolatorInspector("FxSeparableSSSParameter", service.paramInterpolators.ssssInterpolator); + ImGui::TreePop(); + } + + if (ImGui::TreeNode("NeedleFXSceneConfig")) { + RenderFxParamManagerInterpolatorInspector("FxRenderTargetSetting", service.sceneConfigInterpolators.fxRenderTargetSettingInterpolator); + RenderFxParamManagerInterpolatorInspector("FxAntiAliasing", service.sceneConfigInterpolators.fxAntiAliasingInterpolator); + RenderFxParamManagerInterpolatorInspector("StageCommonAtmosphereParameter", service.sceneConfigInterpolators.stageCommonAtmosphereParameterInterpolator); + RenderFxParamManagerInterpolatorInspector("FxLODParameter", service.sceneConfigInterpolators.fxLODParameterInterpolator); + RenderFxParamManagerInterpolatorInspector("FxDetailParameter", service.sceneConfigInterpolators.fxDetailParameterInterpolator); + RenderFxParamManagerInterpolatorInspector("FxDynamicResolutionParameter", service.sceneConfigInterpolators.fxDynamicResolutionParameterInterpolator); + RenderFxParamManagerInterpolatorInspector("StageCommonTimeProgressParameter", service.sceneConfigInterpolators.stageCommonTimeProgressParameterInterpolator); + ImGui::TreePop(); + } + + //ImGui::SeparatorText("Extensions"); + //for (auto* extension : service.extensions) { + // ImGui::Text("%zx", extension->GetRuntimeTypeInfo()); + //} +} diff --git a/src/ui/game-services/game-service-inspectors/wars/FxParamManager.cpp b/src/ui/game-services/game-service-inspectors/wars/FxParamManager.cpp new file mode 100644 index 0000000..c4b4f85 --- /dev/null +++ b/src/ui/game-services/game-service-inspectors/wars/FxParamManager.cpp @@ -0,0 +1,60 @@ +#include + +template static void RenderFxParamManagerInterpolatorInspector(const char* name, app::gfx::FxParamManager::InterpolatorT& interpolator) { + if (ImGui::TreeNode(name)) { + ImGui::Text("Enabled group bits: %x", interpolator.interpolationGroupEnabledBits); + + unsigned short i{ 0 }; + for (auto& interpolationJob : interpolator.interpolationJobs) { + char nodename[200]; + snprintf(nodename, sizeof(nodename), "Job %d", i++); + + if (ImGui::TreeNode(nodename)) { + ImGui::Text("Active on interpolation groups %x", interpolationJob.interpolationGroupMemberBits); + ImGui::Text("Owner hash: %zx", interpolationJob.ownerId); + ImGui::Text("Priority: %d", interpolationJob.priority); + Editor("Unk6", interpolationJob.unk6); + ImGui::Text("Tween duration: %f", 1 / interpolationJob.tweenPositionIncrementPerSecond); + ImGui::SliderFloat("Current time", &interpolationJob.currentTweenPosition, 0.0f, 1.0f); + ImGui::SeparatorText("Target parameters"); + Editor("Target parameters", interpolationJob.parameters); + ImGui::TreePop(); + } + } + ImGui::TreePop(); + } +} + +void RenderGameServiceInspector(app::gfx::FxParamManager& service) { + ImGui::SeparatorText("Interpolated parameters"); + Editor("NeedleFxParameter", service.parameters); + + ImGui::SeparatorText("Interpolators"); + + if (ImGui::TreeNode("NeedleFXParameter")) { + RenderFxParamManagerInterpolatorInspector("FxBloomParameter", *service.paramInterpolators.bloomInterpolator); + RenderFxParamManagerInterpolatorInspector("FxDOFParameter", *service.paramInterpolators.dofInterpolator); + //RenderFxParamManagerInterpolatorInspector:Enum>("ToneMapType", *service.paramInterpolators.toneMapTypeInterpolator); + //RenderFxParamManagerInterpolatorInspector:Enum>("ExposureMode", *service.paramInterpolators.exposureModeInterpolator); + RenderFxParamManagerInterpolatorInspector("FxColorContrastParameter", *service.paramInterpolators.colorContrastInterpolator); + RenderFxParamManagerInterpolatorInspector("FxToneMapParameter", *service.paramInterpolators.toneMapInterpolator); + RenderFxParamManagerInterpolatorInspector("FxExposureParameter", *service.paramInterpolators.exposureInterpolator); + RenderFxParamManagerInterpolatorInspector("FxShadowMapParameter", *service.paramInterpolators.shadowMapInterpolator); + RenderFxParamManagerInterpolatorInspector("FxScreenBlurParameter", *service.paramInterpolators.blurInterpolator); + RenderFxParamManagerInterpolatorInspector("FxSSAOParameter", *service.paramInterpolators.ssaoInterpolator); + RenderFxParamManagerInterpolatorInspector("FxLightFieldParameter", *service.paramInterpolators.lightFieldInterpolator); + RenderFxParamManagerInterpolatorInspector("FxSHLightFieldParameter", *service.paramInterpolators.shLightFieldInterpolator); + RenderFxParamManagerInterpolatorInspector("FxLightScatteringParameter", *service.paramInterpolators.lightScatteringInterpolator); + RenderFxParamManagerInterpolatorInspector("FxRLRParameter", *service.paramInterpolators.rlrInterpolator); + RenderFxParamManagerInterpolatorInspector("FxOcclusionCapsuleParameter", *service.paramInterpolators.occlusionCapsuleInterpolator); + RenderFxParamManagerInterpolatorInspector("FxGodrayParameter", *service.paramInterpolators.godrayInterpolator); + RenderFxParamManagerInterpolatorInspector("FxScreenSpaceGodrayParameter", *service.paramInterpolators.ssGodrayInterpolator); + RenderFxParamManagerInterpolatorInspector("FxHeatHazeParameter", *service.paramInterpolators.heatHazeInterpolator); + RenderFxParamManagerInterpolatorInspector("FxSceneEnvironmentParameter", *service.paramInterpolators.sceneEnvironmentInterpolator); + RenderFxParamManagerInterpolatorInspector("FxRenderOption", *service.paramInterpolators.renderOptionInterpolator); + RenderFxParamManagerInterpolatorInspector("FxSGGIParameter", *service.paramInterpolators.sggiInterpolator); + RenderFxParamManagerInterpolatorInspector("FxTAAParameter", *service.paramInterpolators.taaInterpolator); + RenderFxParamManagerInterpolatorInspector("FxEffectParameter", *service.paramInterpolators.effectInterpolator); + ImGui::TreePop(); + } +} diff --git a/src/ui/operation-modes/LevelEditor/LevelEditor.cpp b/src/ui/operation-modes/LevelEditor/LevelEditor.cpp index 27dbfe2..6b3dbaf 100644 --- a/src/ui/operation-modes/LevelEditor/LevelEditor.cpp +++ b/src/ui/operation-modes/LevelEditor/LevelEditor.cpp @@ -27,7 +27,7 @@ LevelEditor::LevelEditor(csl::fnd::IAllocator* allocator) : OperationMode{ alloc box.CreateBox({ 0, 0, 0 }, { 0.3, 0.3, 0.3 }, csl::math::Quaternion::Identity); targetBox = RESOLVE_STATIC_VARIABLE(hh::gfnd::DrawSystem::CreateGraphicsGeometry)(nullptr, allocator); - targetBox->Initialize(GOCVisualDebugDrawRenderer::instance->drawContext, box, {}); + targetBox->Initialize(GOCVisualDebugDrawRenderer::instance->drawContext, box); targetBox->SetColor({ 255, 0, 255, 255 }); } @@ -52,8 +52,7 @@ void LevelEditor::RenderDebugVisuals(hh::gfnd::DrawContext& ctx) auto* gameObject = focusedChunk->GetGameObjectByObjectId(status.objectData->id); if (gameObject && ((!gameObject->GetComponent() || gameObject->GetComponent() == gameObject->GetComponent()) && !gameObject->GetComponent())) { - targetBox->SetTransform({ ObjectTransformDataToAffine3f(status.objectData->transform) }); - targetBox->Render(&ctx); + targetBox->Render(&ctx, { ObjectTransformDataToAffine3f(status.objectData->transform) }); } } } @@ -295,7 +294,8 @@ void LevelEditor::SpawnObject() { auto* resource = placeTargetLayer->GetResource(); auto* alloc = resource->GetAllocator(); - char name[200]; + // FIXME: We're leaking memory here because the string does not get freed. + auto name = new char[100]; snprintf(name, sizeof(name), "%s_%zd", objectClassToPlace->name, resource->GetObjects().size()); auto* objData = new (alloc) ObjectData{ @@ -316,7 +316,7 @@ void LevelEditor::SpawnObject() { } // FIXME: We're leaking memory here because the spawnerData does not get freed. - auto* rangeSpawningData = new (GetAllocator()) RangeSpawningData{ 50, 20 }; + auto* rangeSpawningData = new (GetAllocator()) RangeSpawningData{ 500, 200 }; auto* rangeSpawning = new (GetAllocator()) ComponentData{ "RangeSpawning", rangeSpawningData }; objData->componentData.push_back(rangeSpawning); @@ -333,7 +333,7 @@ void LevelEditor::Select(const csl::ut::MoveArray& objs) for (auto* object : objs) { auto* status = object->GetWorldObjectStatus(); - if (status != nullptr && focusedChunk->GetObjectIndexById(status->objectData->id) != -1) + if (status != nullptr && focusedChunk->GetObjectIndexByObjectData(status->objectData) != -1) focusedObjects.push_back(status->objectData); } NotifySelectedObject(); @@ -352,7 +352,7 @@ void LevelEditor::Select(hh::game::GameObject* gameObject) Deselect(); auto* status = gameObject->GetWorldObjectStatus(); - if (status != nullptr && focusedChunk->GetObjectIndexById(status->objectData->id) != -1) + if (status != nullptr && focusedChunk->GetObjectIndexByObjectData(status->objectData) != -1) focusedObjects.push_back(status->objectData); NotifySelectedObject(); } diff --git a/src/ui/operation-modes/ObjectInspection/component-inspectors/rangers/GOCPlayerParameter.cpp b/src/ui/operation-modes/ObjectInspection/component-inspectors/rangers/GOCPlayerParameter.cpp index a03eb2d..16dcdd3 100644 --- a/src/ui/operation-modes/ObjectInspection/component-inspectors/rangers/GOCPlayerParameter.cpp +++ b/src/ui/operation-modes/ObjectInspection/component-inspectors/rangers/GOCPlayerParameter.cpp @@ -1,6 +1,8 @@ #include "GOCPlayerParameter.h" #include -//#include +#include +#include +#include template void RenderModeParameterInspector(const char* label, R (¶meters)[4]) { @@ -57,21 +59,21 @@ void RenderComponentInspector(app::player::GOCPlayerParameter& component) { if (ImGui::Button("Edit character parameters...")) switch (component.characterId) { case app::player::CharacterId::SONIC: - ResReflectionEditor::Create(GetAllocator(), &component.characterParameters->sonic); + ResReflectionEditor::Create(Desktop::instance->GetAllocator(), &component.characterParameters->sonic); break; case app::player::CharacterId::AMY: - ResReflectionEditor::Create(GetAllocator(), &component.characterParameters->amy); + ResReflectionEditor::Create(Desktop::instance->GetAllocator(), &component.characterParameters->amy); break; case app::player::CharacterId::KNUCKLES: - ResReflectionEditor::Create(GetAllocator(), &component.characterParameters->knuckles); + ResReflectionEditor::Create(Desktop::instance->GetAllocator(), &component.characterParameters->knuckles); break; case app::player::CharacterId::TAILS: - ResReflectionEditor::Create(GetAllocator(), &component.characterParameters->tails); + ResReflectionEditor::Create(Desktop::instance->GetAllocator(), &component.characterParameters->tails); break; } if (ImGui::Button("Edit Camera Set parameters...")) - ResReflectionEditor::Create(GetAllocator(), &*component.cameraSetParameters); + ResReflectionEditor::Create(Desktop::instance->GetAllocator(), &*component.cameraSetParameters); if (ImGui::TreeNode("Currently loaded mode parameters")) { ImGui::SeparatorText("Mode packages"); diff --git a/src/ui/resources/editors/ResObjectWorldEditor.cpp b/src/ui/resources/editors/ResObjectWorldEditor.cpp index 2fecacf..e191dea 100644 --- a/src/ui/resources/editors/ResObjectWorldEditor.cpp +++ b/src/ui/resources/editors/ResObjectWorldEditor.cpp @@ -17,7 +17,7 @@ ResObjectWorldEditor* ResObjectWorldEditor::Create(csl::fnd::IAllocator* allocat void ResObjectWorldEditor::RenderContents() { for (auto* obj : resource->GetObjects()) { - if (ImGui::TreeNode(obj, "%s", obj->name.c_str())) { + if (ImGui::TreeNode(obj, "%s", obj->GetName())) { Editor("Object data", *obj); ImGui::TreePop(); } diff --git a/src/utilities/CompatibleObject.cpp b/src/utilities/CompatibleObject.cpp index d039da2..676ed29 100644 --- a/src/utilities/CompatibleObject.cpp +++ b/src/utilities/CompatibleObject.cpp @@ -1,5 +1,10 @@ #include "CompatibleObject.h" +#ifdef DEVTOOLS_TARGET_SDK_wars CompatibleObject::CompatibleObject(csl::fnd::IAllocator* allocator) : hh::fnd::ReferencedObject{} { pAllocator = allocator; } +#else +CompatibleObject::CompatibleObject(csl::fnd::IAllocator* allocator) : hh::fnd::ReferencedObject{ allocator, true } { +} +#endif \ No newline at end of file