Skip to content

Commit

Permalink
Add Uint64, Vector4, EulerAngles, Int64 and fix vsxmake project
Browse files Browse the repository at this point in the history
  • Loading branch information
maximegmd committed Dec 23, 2020
1 parent 5d074ce commit 4e7746c
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/reverse/BasicTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@

#include "RED4ext/REDreverse/CName.hpp"

std::string Vector4::ToString() const noexcept
{
return "Vector4{ x: " + std::to_string(x) + " y: " + std::to_string(y) + " z: " + std::to_string(z) + " w: " + std::to_string(w) + " }";
}

std::string EulerAngles::ToString() const noexcept
{
return "EulerAngles{ x: " + std::to_string(x) + " y: " + std::to_string(y) + " z: " + std::to_string(z) + " }";
}

std::string Quaternion::ToString() const noexcept
{
return "Quaternion{ x: " + std::to_string(x) + " y: " + std::to_string(y) + " z: " + std::to_string(z) + " w: " + std::to_string(w) + " }";
Expand Down
33 changes: 32 additions & 1 deletion src/reverse/BasicTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,39 @@ namespace RED4ext {
}
}

struct Quaternion
struct Vector4
{
Vector4(float aX, float aY, float aZ, float aW)
: x(aX), y(aY), z(aZ), w(aW)
{}

float x;
float y;
float z;
float w;

std::string ToString() const noexcept;
};

struct EulerAngles
{
EulerAngles(float aX, float aY, float aZ)
: x(aX), y(aY), z(aZ)
{}

float x;
float y;
float z;

std::string ToString() const noexcept;
};

struct Quaternion : Vector4
{
Quaternion(float aX, float aY, float aZ, float aW)
: Vector4(aX, aY, aZ, aW)
{}

float x;
float y;
float z;
Expand Down
5 changes: 5 additions & 0 deletions src/reverse/Converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@ RED4ext::REDreverse::CScriptableStackFrame::CStackType InternalToRED(MetaArray<H

static MetaArray<
LuaRED<int32_t, "Int32">,
LuaRED<int64_t, "Int64">,
LuaRED<uint32_t, "Uint32">,
LuaRED<uint64_t, "Uint64">,
LuaRED<float, "Float">,
LuaRED<bool, "Bool">,
LuaRED<Quaternion, "Quaternion">,
LuaRED<Vector4, "Vector4">,
LuaRED<EulerAngles, "EulerAngles">,
LuaRED<ItemID, "gameItemID">,
LuaRED<TweakDBID, "TweakDBID">,
LuaRED<CName, "CName">
Expand Down
1 change: 1 addition & 0 deletions src/reverse/Converter.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once

#include <sol/sol.hpp>
#include "RED4ext/REDreverse/Scripting/StackFrame.hpp"

Expand Down
16 changes: 16 additions & 0 deletions src/reverse/Scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,23 @@ Scripting::Scripting()
"Dump", &GameOptions::Dump,
"List", &GameOptions::List);

m_lua.new_usertype<Vector4>("Vector4",
sol::constructors<Vector4(float, float, float, float)>(),
sol::meta_function::to_string, &Vector4::ToString,
"x", sol::property(&Vector4::x),
"y", sol::property(&Vector4::y),
"z", sol::property(&Vector4::z),
"w", sol::property(&Vector4::w));

m_lua.new_usertype<EulerAngles>("EulerAngles",
sol::constructors<EulerAngles(float, float, float)>(),
sol::meta_function::to_string, &EulerAngles::ToString,
"x", sol::property(&EulerAngles::x),
"y", sol::property(&EulerAngles::y),
"z", sol::property(&EulerAngles::z));

m_lua.new_usertype<Quaternion>("Quaternion",
sol::constructors<Quaternion(float, float, float, float)>(),
sol::meta_function::to_string, &Quaternion::ToString,
"x", sol::property(&Quaternion::x),
"y", sol::property(&Quaternion::y),
Expand Down
3 changes: 2 additions & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set_languages("cxx17")

add_requires("spdlog", "nlohmann_json", "minhook", "imgui", "sol2", "tiltedcore")
add_requires("spdlog", "nlohmann_json", "minhook", "imgui", "sol2", "tiltedcore", { external = false })

add_rules("mode.debug", "mode.release")

Expand Down

0 comments on commit 4e7746c

Please sign in to comment.