Skip to content

Commit

Permalink
Further porting
Browse files Browse the repository at this point in the history
  • Loading branch information
angryzor committed Oct 28, 2024
1 parent 42d130b commit 576ecd2
Show file tree
Hide file tree
Showing 22 changed files with 277 additions and 70 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.28)
# DevTools
project(devtools VERSION 0.1.47
project(devtools VERSION 0.1.48
DESCRIPTION "Hedgehog Engine 2 DevTools"
LANGUAGES CXX)

Expand Down
11 changes: 11 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ target_sources(${DEVTOOLS_TARGET}
io/binary/serialization/resource-rfls/ResFxColFile2.cpp
io/binary/serialization/resource-rfls/ResObjectWorld.cpp
io/binary/serialization/resource-rfls/ResSurfRideProject.cpp
io/binary/serialization/resource-rfls/ResReflection.cpp
resources/ManagedMemoryRegistry.cpp
resources/ReloadManager.cpp
reflection/HSONTemplateGeneration.cpp
Expand Down Expand Up @@ -115,6 +116,7 @@ target_sources(${DEVTOOLS_TARGET}
io/binary/serialization/resource-rfls/ResFxColFile2.h
io/binary/serialization/resource-rfls/ResObjectWorld.h
io/binary/serialization/resource-rfls/ResSurfRideProject.h
io/binary/serialization/resource-rfls/ResReflection.h
io/binary/serialization/Types.h
resources/managed-memory/ManagedCArray.h
resources/ManagedMemoryRegistry.h
Expand Down Expand Up @@ -298,3 +300,12 @@ if(${DEVTOOLS_TARGET_SDK} STREQUAL "rangers")
ui/tools/${DEVTOOLS_TARGET_SDK}/NeedleFxSceneDataTester.h
)
endif()

if(${DEVTOOLS_TARGET_SDK} STREQUAL "miller")
target_sources(${DEVTOOLS_TARGET}
PRIVATE
ui/core-services/GraphicsContextInspector.cpp
PRIVATE FILE_SET HEADERS FILES
ui/core-services/GraphicsContextInspector.h
)
endif()
14 changes: 7 additions & 7 deletions src/debug-rendering/GOCVisualDebugDrawRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ GOCVisualDebugDrawRenderer::GOCVisualDebugDrawRenderer(csl::fnd::IAllocator* all
#else
GOCVisualDebugDrawRenderer::GOCVisualDebugDrawRenderer(csl::fnd::IAllocator* allocator)
: CompatibleObject{ allocator }
//, memCtx{ true }
//, unk2{ &memCtx }
//, unk3{ &unk2 }
//, drawContext{ RESOLVE_STATIC_VARIABLE(hh::gfnd::DrawSystem::CreateDrawContext)(allocator, &unk3) }
//, renderable{ new (allocator) Renderable(allocator, this) }
, memCtx{ true }
, unk2{ &memCtx }
, unk3{ &unk2 }
, 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);
renderable->name = "DevTools Debug Overlay";
hh::gfnd::GraphicsContext::GetInstance()->AddRenderableToViewport(renderable, 7);// 5);
}

void GOCVisualDebugDrawRenderer::AddGOC(GOCMyVisualDebugDraw* goc) {
Expand Down
6 changes: 3 additions & 3 deletions src/debug-rendering/GOCVisualDebugDrawRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class GOCVisualDebugDrawRenderer : public CompatibleObject
static bool renderOcclusionCapsules;
static uint8_t gocVisualDebugDrawOpacity;
#ifndef DEVTOOLS_TARGET_SDK_wars
//hh::needle::CScratchMemoryContext memCtx;
//hh::gfnd::DrawContext::Unk2 unk2;
//hh::gfnd::DrawContext::Unk3 unk3;
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() };
Expand Down
19 changes: 19 additions & 0 deletions src/io/binary/containers/binary-file/BinaryFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <hedgelib/csl/hl_csl_move_array.h>
#include <hedgelib/io/hl_file.h>
#include <io/binary/serialization/Reflection.h>
#include <io/binary/serialization/resource-rfls/ResReflection.h>
#include <ui/Desktop.h>
#include "BinaryFile.h"
#include "Types.h"
Expand Down Expand Up @@ -67,4 +68,22 @@ namespace devtools::io::binary::containers {
writer.finish_data_block();
writer.finish();
}

void BinaryFile::SerializeRef2(const wchar_t* filename, void* obj, const hh::fnd::RflClass* rflClass) {
hl::file_stream stream{ filename, hl::file::mode::write };
hl::bina::v2::writer64 writer{ stream };

writer.start(hl::bina::endian_flag::little, hl::bina::v2::ver_210);
writer.start_data_block();

Backend backend{ writer };
serialization::ReflectionSerializer<Backend> serializer{ Desktop::instance->GetAllocator(), backend, writer.tell() };

ResReflectionHeader header{ rflClass->nameHash };
serializer.Serialize(&header, &hh::fnd::RflClassTraits<ResReflectionHeader>::rflClass);
serializer.Serialize(obj, rflClass);

writer.finish_data_block();
writer.finish();
}
}
4 changes: 4 additions & 0 deletions src/io/binary/containers/binary-file/BinaryFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ namespace devtools::io::binary::containers {
class BinaryFile {
public:
static void Serialize(const wchar_t* filename, void* obj, const hh::fnd::RflClass* rflClass);
static void SerializeRef2(const wchar_t* filename, void* obj, const hh::fnd::RflClass* rflClass);
template<rfl::RflClass T> static void Serialize(const wchar_t* filename, T* obj) {
Serialize(filename, obj, &RESOLVE_STATIC_VARIABLE(T::rflClass));
}
template<rfl::RflClass T> static void SerializeRef2(const wchar_t* filename, T* obj) {
SerializeRef2(filename, obj, &RESOLVE_STATIC_VARIABLE(T::rflClass));
}
};
}
15 changes: 15 additions & 0 deletions src/io/binary/serialization/resource-rfls/ResReflection.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "ResReflection.h"

ResReflectionHeader::ResReflectionHeader(unsigned int hash) : hash{ hash } {}

#include <reflection/RflClassGen.h>

using namespace hh::fnd;

namespace reflection::serialization::resource_rfls::reflection {
auto resReflectionHeaderMembers = CreateRflClassMembers<void, unsigned int, unsigned int, unsigned int, unsigned int>("magic", "version", "hash", "padding");
}

using namespace reflection::serialization::resource_rfls::reflection;

const RflClass RflClassTraitsImpl<ResReflectionHeader>::rflClass{ "ResReflectionHeader", nullptr, static_cast<uint32_t>(sizeof(ResReflectionHeader)), nullptr, 0, resReflectionHeaderMembers.data(), static_cast<uint32_t>(resReflectionHeaderMembers.size()), nullptr };
13 changes: 13 additions & 0 deletions src/io/binary/serialization/resource-rfls/ResReflection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once
#include <reflection/RflClassGenFwd.h>

struct ResReflectionHeader {
unsigned int magic{ 0x32464552u };
unsigned int version{ 0x30302E31u };
unsigned int hash{};
unsigned int padding{};

ResReflectionHeader(unsigned int hash);
};

template<> struct hh::fnd::RflClassTraits<ResReflectionHeader> : RflClassTraitsImpl<ResReflectionHeader> {};
Loading

0 comments on commit 576ecd2

Please sign in to comment.