Skip to content

Commit

Permalink
Normalize
Browse files Browse the repository at this point in the history
  • Loading branch information
angryzor committed Jun 3, 2024
1 parent 474c721 commit 6638064
Show file tree
Hide file tree
Showing 32 changed files with 490 additions and 229 deletions.
33 changes: 19 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
cmake_minimum_required(VERSION 3.28)
# DevTools
project(devtools VERSION 0.1.20
DESCRIPTION "Sonic Forces DevTools"
project(devtools VERSION 0.1.21
DESCRIPTION "Hedgehog Engine 2 DevTools"
LANGUAGES CXX)

set(PROJECT_AUTHOR "angryzor")
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")



add_subdirectory(vendor EXCLUDE_FROM_ALL)

# 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(DEBUGGER_WORKING_DIRECTORY_wars "build/main/projects/exec")
set(MOD_SUBFOLDER_wars "build/main/projects/exec/Mods/devtools")
set(UPDATE_SERVER_NAMESPACE_wars "sonic-forces")
set(FRIENDLY_GAME_NAME_wars "Sonic Forces")

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(DEBUGGER_WORKING_DIRECTORY_rangers "")
set(MOD_SUBFOLDER_rangers "Mods/devtools")
set(UPDATE_SERVER_NAMESPACE_rangers "sonic-frontiers")
set(FRIENDLY_GAME_NAME_rangers "Sonic Frontiers")

# 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(PROJECT_DESCRIPTION "${FRIENDLY_GAME_NAME_${DEVTOOLS_TARGET_SDK}} DevTools")
set(PROJECT_LONG_DESCRIPTION "In-engine development kit for ${FRIENDLY_GAME_NAME_${DEVTOOLS_TARGET_SDK}}")
set(GAME_FOLDER_${DEVTOOLS_TARGET_SDK} ${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})
set(UPDATE_SERVER_NAMESPACE ${UPDATE_SERVER_NAMESPACE_${DEVTOOLS_TARGET_SDK}})
cmake_path(SET GAME_FOLDER_NORMALIZED NORMALIZE ${GAME_FOLDER_${DEVTOOLS_TARGET_SDK}})
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 ${DEBUGGER_WORKING_DIRECTORY_${DEVTOOLS_TARGET_SDK}} OUTPUT_VARIABLE DEBUGGER_WORKING_DIRECTORY)
cmake_path(APPEND GAME_FOLDER_NORMALIZED ${MOD_SUBFOLDER_${DEVTOOLS_TARGET_SDK}} OUTPUT_VARIABLE MOD_FOLDER)

if(DEFINED ENV{${SDK_VAR_${DEVTOOLS_TARGET_SDK}}})
Expand Down Expand Up @@ -66,7 +70,7 @@ foreach(DEVTOOLS_TARGET_SDK rangers wars)
PROPERTIES
OUTPUT_NAME "devtools"
VS_DEBUGGER_COMMAND ${GAME_EXECUTABLE}
VS_DEBUGGER_WORKING_DIRECTORY ${WORKING_DIRECTORY}
VS_DEBUGGER_WORKING_DIRECTORY ${DEBUGGER_WORKING_DIRECTORY}
)

foreach(LIB ${DEVTOOLS_TARGET_SDK}-sdk HedgeLib filewatch detours imgui imgui-backend-win32 imgui-backend-dx11 imgui-file-dialog imguizmo implot)
Expand All @@ -75,11 +79,12 @@ foreach(DEVTOOLS_TARGET_SDK rangers wars)

add_subdirectory(src ${DEVTOOLS_TARGET}/src)
add_subdirectory(natvis ${DEVTOOLS_TARGET}/natvis)
configure_file(Mod.ini.in Mod.ini)
configure_file(Mod.ini.in ${DEVTOOLS_TARGET}/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}")
install(DIRECTORY resources/common/ DESTINATION "${MOD_FOLDER}")
install(DIRECTORY resources/${DEVTOOLS_TARGET_SDK}/ DESTINATION "${MOD_FOLDER}")
install(FILES LICENSE.txt "${CMAKE_CURRENT_BINARY_DIR}/${DEVTOOLS_TARGET}/Mod.ini" DESTINATION "${MOD_FOLDER}")
endforeach()
2 changes: 1 addition & 1 deletion Mod.ini.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Description="${PROJECT_LONG_DESCRIPTION}"
Date="${PROJECT_BUILD_DATE}"
AuthorURL="https://github.com/angryzor"
[Main]
UpdateServer="https://raw.githubusercontent.com/angryzor/hmm-update-server/main/sonic-frontiers/devtools/"
UpdateServer="https://raw.githubusercontent.com/angryzor/hmm-update-server/main/${UPDATE_SERVER_NAMESPACE}/devtools/"
SaveFile=""
ID="angryzor.devtools"
IncludeDir0="."
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion sdks/rangers-sdk
Submodule rangers-sdk updated 4 files
+13,667 −14,957 addresses.csv
+1 −1 rangers-api
+23,639 −30,584 src/thunks.asm
+48 −48 type-export-entry.cpp
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ target_sources(${DEVTOOLS_TARGET}
ui/common/Theme.cpp
ui/common/Translations.cpp
ui/Context.cpp
ui/Input.cpp
# ui/core-services/GameUpdaterInspector.cpp
# ui/core-services/GraphicsContextInspector.cpp
# ui/core-services/RenderManagerInspector.cpp
Expand Down Expand Up @@ -105,6 +106,7 @@ target_sources(${DEVTOOLS_TARGET}
ui/common/Translations.h
ui/common/TreeView.h
ui/Context.h
ui/Input.h
ui/core-services/GameUpdaterInspector.h
ui/core-services/GraphicsContextInspector.h
ui/core-services/RenderManagerInspector.h
Expand Down
2 changes: 2 additions & 0 deletions src/Pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@

#ifdef DEVTOOLS_TARGET_SDK_wars
#include <wars-sdk.h>
#define he2sdk warssdk
#endif

#ifdef DEVTOOLS_TARGET_SDK_rangers
#include <rangers-sdk.h>
#define he2sdk rangerssdk
#endif

#include <imgui.h>
Expand Down
31 changes: 25 additions & 6 deletions src/debug-rendering/GOCVisualDebugDrawRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class GOCMyVisualDebugDraw : public GOCVisualDebugDraw {
//hh::fnd::Reference<hh::gfnd::GraphicsGeometry> geometry;
hh::fnd::Reference<hh::gfnd::GraphicsGeometry> fillGeometry;
csl::ut::Color<uint8_t> color{ 0, 0, 0, 0 };
bool hasGeometry;
bool hasGeometry{};

GOCMyVisualDebugDraw(csl::fnd::IAllocator* allocator);
virtual void OnGOCEvent(GOCEvent event, GameObject& ownerGameObject, void* data);
Expand All @@ -30,7 +30,11 @@ hh::game::GOComponent* GOCMyVisualDebugDraw::Create(csl::fnd::IAllocator* alloca
}

GOCMyVisualDebugDraw::GOCMyVisualDebugDraw(csl::fnd::IAllocator* allocator)
#ifdef DEVTOOLS_TARGET_SDK_wars
: GOCVisualDebugDraw{}
#else
: GOCVisualDebugDraw{ allocator }
#endif
//, geometry{ RESOLVE_STATIC_VARIABLE(hh::gfnd::DrawSystemNeedle::CreateGraphicsGeometry)(nullptr, allocator) }
, fillGeometry{ RESOLVE_STATIC_VARIABLE(hh::gfnd::DrawSystemNeedle::CreateGraphicsGeometry)(nullptr, allocator) }
{
Expand Down Expand Up @@ -77,14 +81,21 @@ void GOCVisualDebugDrawRenderer::InstallHooks() {
//GOCMyVisualDebugDraw::InstallHooks();
}

#ifdef DEVTOOLS_TARGET_SDK_wars
GOCVisualDebugDrawRenderer::GOCVisualDebugDrawRenderer(csl::fnd::IAllocator* allocator)
: CompatibleObject{ allocator }
//, memCtx{ true }
//, unk2{ &memCtx }
//, unk3{ &unk2 }
, drawContext{ RESOLVE_STATIC_VARIABLE(hh::gfnd::DrawSystem::CreateDrawContext)(allocator) }
, renderable{ new (allocator) Renderable(allocator, this) }
#else
GOCVisualDebugDrawRenderer::GOCVisualDebugDrawRenderer(csl::fnd::IAllocator* allocator)
: CompatibleObject{ allocator }
, memCtx{ true }
, unk2{ &memCtx }
, unk3{ &unk2 }
//, sharedDDRes{ RESOLVE_STATIC_VARIABLE(hh::gfnd::DrawSystem::CreateSharedDebugDrawResource)(allocator) }
, drawContext{ RESOLVE_STATIC_VARIABLE(hh::gfnd::DrawSystem::CreateDrawContext)(allocator) }//, & unk3) }
, drawContext{ RESOLVE_STATIC_VARIABLE(hh::gfnd::DrawSystem::CreateDrawContext)(allocator, &unk3) }
, renderable{ new (allocator) Renderable(allocator, this) }
#endif
{
renderable->name = "DevTools Debug Overlay";
hh::gfnd::GraphicsContext::GetInstance()->AddRenderableToViewport(renderable, 7);// 5);
Expand Down Expand Up @@ -158,6 +169,7 @@ void GOCVisualDebugDrawRenderer::Renderable::Render(const hh::gfnd::RenderablePa
}
}
}
#ifdef DEVTOOLS_TARGET_SDK_wars
if (renderOcclusionCapsules) {
for (auto* gameObject : gameManager->objects) {
for (auto* goc : gameObject->components) {
Expand All @@ -173,6 +185,7 @@ void GOCVisualDebugDrawRenderer::Renderable::Render(const hh::gfnd::RenderablePa
}
}
}
#endif

//auto renderParam = static_cast<RenderingEngineRangers*>(static_cast<RenderManager*>(RenderManager::GetInstance())->GetNeedleResourceDevice())->mainRenderUnit->pipelineInfo->renderParam;
//for (size_t i = 0; i < renderParam.numViewports; i++) {
Expand Down Expand Up @@ -201,7 +214,13 @@ void GOCVisualDebugDrawRenderer::Renderable::Render(const hh::gfnd::RenderablePa
renderer->drawContext->EndScene();
}

GOCVisualDebugDrawRenderer::Renderable::Renderable(csl::fnd::IAllocator* allocator, GOCVisualDebugDrawRenderer* renderer) : hh::gfnd::Renderable{}, renderer{ renderer }
GOCVisualDebugDrawRenderer::Renderable::Renderable(csl::fnd::IAllocator* allocator, GOCVisualDebugDrawRenderer* renderer)
#ifdef DEVTOOLS_TARGET_SDK_wars
: hh::gfnd::Renderable{}
#else
: hh::gfnd::Renderable{ allocator }
#endif
, renderer{ renderer }
{
}

Expand Down
8 changes: 5 additions & 3 deletions src/debug-rendering/GOCVisualDebugDrawRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ class GOCVisualDebugDrawRenderer : public CompatibleObject
static bool renderColliders;
static bool renderOcclusionCapsules;
static uint8_t gocVisualDebugDrawOpacity;
//hh::needle::CScratchMemoryContext memCtx;
//hh::gfnd::DrawContext::Unk2 unk2;
//hh::gfnd::DrawContext::Unk3 unk3;
#ifndef DEVTOOLS_TARGET_SDK_wars
hh::needle::CScratchMemoryContext memCtx;
hh::gfnd::DrawContext::Unk2 unk2;
hh::gfnd::DrawContext::Unk3 unk3;
#endif
hh::gfnd::DrawContext* drawContext;
csl::ut::MoveArray<DebugRenderable*> additionalRenderables{ GetAllocator() };
GOCVisualDebugDrawRenderer(csl::fnd::IAllocator* allocator);
Expand Down
Loading

0 comments on commit 6638064

Please sign in to comment.