Skip to content

Commit

Permalink
Merge pull request #116 from psiberx/master
Browse files Browse the repository at this point in the history
Fixed Variant and decoded more widget classes
  • Loading branch information
wopss authored Apr 23, 2024
2 parents cdcf6f0 + 464e5ae commit 3b1697f
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 4 deletions.
32 changes: 31 additions & 1 deletion include/RED4ext/NativeTypes-inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ RED4EXT_INLINE RED4ext::Variant::Variant(const RED4ext::CBaseRTTIType* aType, co
}
}

RED4EXT_INLINE RED4ext::Variant::Variant(const RED4ext::CName& aTypeName, const RED4ext::ScriptInstance aData)
RED4EXT_INLINE RED4ext::Variant::Variant(RED4ext::CName aTypeName)
: Variant(RED4ext::CRTTISystem::Get()->GetType(aTypeName))
{
}

RED4EXT_INLINE RED4ext::Variant::Variant(RED4ext::CName aTypeName, const RED4ext::ScriptInstance aData)
: Variant(RED4ext::CRTTISystem::Get()->GetType(aTypeName), aData)
{
}
Expand All @@ -143,11 +148,36 @@ RED4EXT_INLINE RED4ext::Variant::Variant(const Variant& aOther)
{
}

RED4EXT_INLINE RED4ext::Variant::Variant(Variant&& aOther) noexcept
: type(aOther.type)
{
std::copy(std::begin(aOther.inlined), std::end(aOther.inlined), std::begin(inlined));
std::fill(std::begin(aOther.inlined), std::end(aOther.inlined), static_cast<uint8_t>(0));
aOther.type = nullptr;
}

RED4EXT_INLINE RED4ext::Variant::~Variant()
{
Free();
}

RED4EXT_INLINE RED4ext::Variant& RED4ext::Variant::operator=(const Variant& aRhs)
{
Fill(aRhs.GetType(), aRhs.GetDataPtr());
return *this;
}

RED4EXT_INLINE RED4ext::Variant& RED4ext::Variant::operator=(Variant&& aRhs) noexcept
{
type = aRhs.type;
aRhs.type = nullptr;

std::copy(std::begin(aRhs.inlined), std::end(aRhs.inlined), std::begin(inlined));
std::fill(std::begin(aRhs.inlined), std::end(aRhs.inlined), static_cast<uint8_t>(0));

return *this;
}

RED4EXT_INLINE bool RED4ext::Variant::IsEmpty() const noexcept
{
return !type;
Expand Down
7 changes: 6 additions & 1 deletion include/RED4ext/NativeTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,15 @@ struct Variant
Variant() noexcept = default;
Variant(const CBaseRTTIType* aType);
Variant(const CBaseRTTIType* aType, const ScriptInstance aData);
Variant(const CName& aTypeName, const ScriptInstance aData);
Variant(CName aTypeName);
Variant(CName aTypeName, const ScriptInstance aData);
Variant(const Variant& aOther);
Variant(Variant&& aOther) noexcept;
~Variant();

Variant& operator=(const Variant& aRhs);
Variant& operator=(Variant&& aRhs) noexcept;

bool IsEmpty() const noexcept;
bool IsInlined() const noexcept;

Expand Down
10 changes: 10 additions & 0 deletions include/RED4ext/Scripting/Natives/Generated/ink/DrawArea.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

// This file is generated from the Game's Reflection data

#include <RED4ext/Scripting/Natives/inkDrawArea.hpp>

namespace RED4ext
{
RED4EXT_ASSERT_SIZE(ink::DrawArea, 0x4C);
using inkDrawArea = ink::DrawArea;
} // namespace RED4ext

/*
#include <cstdint>
#include <RED4ext/Common.hpp>
#include <RED4ext/Scripting/Natives/Generated/Vector2.hpp>
Expand All @@ -29,3 +38,4 @@ using inkDrawArea = ink::DrawArea;
} // namespace RED4ext
// clang-format on
*/
21 changes: 21 additions & 0 deletions include/RED4ext/Scripting/Natives/inkDrawArea.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once

#include <RED4ext/Common.hpp>
#include <RED4ext/Scripting/Natives/Generated/Vector2.hpp>
#include <RED4ext/Scripting/Natives/Generated/ink/UITransform.hpp>

namespace RED4ext::ink
{
struct DrawArea
{
static constexpr const char* NAME = "inkDrawArea";
static constexpr const char* ALIAS = NAME;

Vector2 size; // 00
float scale; // 08
Vector2 relativePosition; // 0C
Vector2 absolutePosition; // 14
UITransform transform; // 1C
};
RED4EXT_ASSERT_SIZE(DrawArea, 0x4C);
} // namespace RED4ext::ink
2 changes: 1 addition & 1 deletion include/RED4ext/Scripting/Natives/inkHUDLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ struct __declspec(align(0x10)) HUDLayer : ink::FullScreenLayer
RED4EXT_ASSERT_SIZE(HUDLayer, 0x200);
RED4EXT_ASSERT_OFFSET(HUDLayer, entries, 0x150);
RED4EXT_ASSERT_OFFSET(HUDLayer, definition, 0x188);
RED4EXT_ASSERT_OFFSET(HUDLayer, spawnLock, 0x198);
RED4EXT_ASSERT_OFFSET(HUDLayer, spawningLock, 0x198);
} // namespace RED4ext::ink
5 changes: 4 additions & 1 deletion include/RED4ext/Scripting/Natives/inkWidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ struct Widget : IScriptable
uint8_t unk1B0[0x1E0 - 0x1B0]; // 1B0
HDRColor tintColor; // 1E0
float opacity; // 1F0
uint8_t unk1F4[0x1F8 - 0x1F4]; // 1F4
SharedMutex parentLock; // 1F4
SharedMutex unk1F5; // 1F5
SharedMutex unk1F6; // 1F6
SharedMutex userDataLock; // 1F7
bool visible; // 1F8
bool canSupportFocus; // 1F9
bool fitToContent; // 1FA
Expand Down

0 comments on commit 3b1697f

Please sign in to comment.