Skip to content

Commit

Permalink
Lua: Migrate utility functions to separate files
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jun 26, 2024
1 parent 5286661 commit 329001f
Show file tree
Hide file tree
Showing 8 changed files with 515 additions and 457 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -597,9 +597,13 @@ set(luavrlib_SOURCES "")
list(APPEND luavrlib_SOURCES
"lua-api/lib/src/ScriptContext.cpp"
"lua-api/lib/src/ScriptState.cpp"
"lua-api/lib/src/ScriptUtility.cpp"
"lua-api/lib/src/datatypes/StructObject.cpp"
"lua-api/lib/src/datatypes/Vector.cpp"
"lua-api/lib/include/ScriptContext.hpp"
"lua-api/lib/include/ScriptState.hpp"
"lua-api/lib/include/ScriptUtility.hpp"
"lua-api/lib/include/datatypes/StructObject.hpp"
"lua-api/lib/include/datatypes/Vector.hpp"
)

Expand Down
16 changes: 16 additions & 0 deletions lua-api/lib/include/ScriptUtility.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <sol/sol.hpp>
#include <uevr/API.hpp>

namespace lua::utility {
uevr::API::UScriptStruct* get_vector_struct();
bool is_ue5();

sol::object prop_to_object(sol::this_state s, void* self, uevr::API::FProperty* desc, bool is_self_temporary = false);
sol::object prop_to_object(sol::this_state s, uevr::API::UObject* self, const std::wstring& name);
void set_property(sol::this_state s, uevr::API::UObject* self, const std::wstring& name, sol::object value);

sol::object call_function(sol::this_state s, uevr::API::UObject* self, uevr::API::UFunction* fn, sol::variadic_args args);
sol::object call_function(sol::this_state s, uevr::API::UObject* self, const std::wstring& name, sol::variadic_args args);
}
15 changes: 15 additions & 0 deletions lua-api/lib/include/datatypes/StructObject.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#include <uevr/API.hpp>
#include <sol/sol.hpp>

namespace lua::datatypes {
struct StructObject {
StructObject(void* obj, uevr::API::UStruct* def) : object{ obj }, desc{ def } {}

void* object{ nullptr };
uevr::API::UStruct* desc{ nullptr };
};

void bind_struct_object(sol::state_view& lua);
}
5 changes: 5 additions & 0 deletions lua-api/lib/include/datatypes/Vector.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#pragma once

#define GLM_ENABLE_EXPERIMENTAL

#include <glm/vec3.hpp>
#include <glm/vec2.hpp>
#include <glm/vec4.hpp>
#include <glm/gtx/euler_angles.hpp>
#include <glm/gtx/vector_angle.hpp>

#include <sol/sol.hpp>
#include <uevr/API.hpp>

Expand Down
Loading

0 comments on commit 329001f

Please sign in to comment.