Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port/inputsource: Refactor Abstracted Input Handler #558

Closed
wants to merge 61 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
a829c42
Refactor to use SystemStringType
Yangff Jun 10, 2024
1aed11b
add platform abstraction for ue4ss entry
Yangff Jun 10, 2024
99a7739
use SystemString and UEString
Yangff Jun 10, 2024
96aeba8
fix rebase error on name
Yangff Jun 10, 2024
46b6f87
fix find_mod_by_name
Yangff Jun 10, 2024
6111367
use to_system_string
Yangff Jun 10, 2024
9f98303
temp roll back for UEGeneratedFile
Yangff Jun 10, 2024
3663389
fix rebase bug
Yangff Jun 10, 2024
83d59ee
fix find_lua_mod_by_name_internal
Yangff Jun 11, 2024
12f3449
fix rebase of new code
Yangff Jun 11, 2024
5a45542
disable cppmod in this attempt
Yangff Jun 11, 2024
2189f23
Use New String Types
Yangff Jun 11, 2024
0e1962c
Dynamic Output uses SystemString allowing interaction with STL
Yangff Jun 11, 2024
2cee23a
Refactor File APIs, using UTF-8 as native file encoding
Yangff Jun 11, 2024
c591dab
Add String Type Helper
Yangff Jun 11, 2024
a345798
Refactor Parser to use the new String Types
Yangff Jun 11, 2024
dea881a
Refactor JSON to use System String Type
Yangff Jun 11, 2024
3c086c3
Update Macro used by generated headers
Yangff Jun 11, 2024
f8c41db
Use of new String Types
Yangff Jun 11, 2024
ce3f9c1
UE related String Type
Yangff Jun 11, 2024
735ece1
Refactor to use new string types
Yangff Jun 11, 2024
c7582f3
Refactor the interfaction between Lua (C string), UE (UE string) and …
Yangff Jun 11, 2024
de04591
Refactor String Types used in STL
Yangff Jun 11, 2024
3d6c97d
Other Mod related refactor
Yangff Jun 11, 2024
22c2347
Proxygen should generate correct system string type
Yangff Jun 11, 2024
afaa872
Dumper and SDK Generator refactor
Yangff Jun 11, 2024
3f051f1
UE4SS Refactor
Yangff Jun 11, 2024
69cae39
GUI Refactor String Type
Yangff Jun 11, 2024
5f7cb6e
Refactor String Type and move platform related code
Yangff Jun 11, 2024
2d3726f
GUI Refactor, use system string for stl
Yangff Jun 11, 2024
fa9624c
Mod related string type
Yangff Jun 11, 2024
39da4a6
use system string for string manupilation when dumping
Yangff Jun 11, 2024
37d389e
Refactor string types in usmapgenerator
Yangff Jun 11, 2024
3220798
UVTD Refactor: use System String when formatting and use UEString for…
Yangff Jun 11, 2024
b094111
Parser Refactor: use System String Type
Yangff Jun 11, 2024
25b78ef
Add macros for Windows
Yangff Jun 11, 2024
a9e5b39
fix rebase error on name
Yangff Jun 10, 2024
789c500
fix find_mod_by_name
Yangff Jun 10, 2024
6a5e2e4
temp roll back for UEGeneratedFile
Yangff Jun 10, 2024
5ebcbd0
fix rebase bug
Yangff Jun 10, 2024
1709f55
fix find_lua_mod_by_name_internal
Yangff Jun 11, 2024
c8f069f
fix duplicated code by rebase
Yangff Jun 11, 2024
5ed93a5
fix code corrupted by rebase
Yangff Jun 11, 2024
6757d9f
fix rebase error
Yangff Jun 11, 2024
2d3055c
Fix: use UEStringViewType instaed of wstring_view
Yangff Jun 11, 2024
a992fa0
Use sysstr in ini parser
Yangff Jun 11, 2024
c710e1b
InputSource: add dep to DynamicOutput
Yangff Jun 11, 2024
17ecc69
Input Source: add windows platform code
Yangff Jun 11, 2024
53682d4
Input Source: add SPSC ring buffer for key queue
Yangff Jun 11, 2024
7e57636
Remove old code to refactor
Yangff Jun 11, 2024
7757121
Input Source: GLFW3
Yangff Jun 11, 2024
0da7925
Input Source: Win32 Async
Yangff Jun 11, 2024
7fee284
Input Source: Common Queued Source
Yangff Jun 11, 2024
05a34d7
Input Source: ModifierKeys ops
Yangff Jun 11, 2024
08df3c3
Input Source: Platform Init for input sources
Yangff Jun 11, 2024
bc97d3f
Input Source: Platform Input Abstract
Yangff Jun 11, 2024
efef00b
Input Source: Refactor Input Source Handler
Yangff Jun 11, 2024
fde09f0
Input Source: Input Handler in UE4SS
Yangff Jun 11, 2024
b84c691
Input Source: Apply HAS_INPUT macro
Yangff Jun 11, 2024
9c04e7c
Input Source: Use safe getter for input event
Yangff Jun 11, 2024
5658b39
Input Source: use new input_handler in UVTD
Yangff Jun 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
919 changes: 465 additions & 454 deletions UE4SS/generated_include/MacroSetter.hpp

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions UE4SS/include/ExceptionHandling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
#define UE4SS_ERROR_OUTPUTTER() \
if (!Output::has_internal_error()) \
{ \
Output::send<LogLevel::Error>(STR("Error: {}\n"), to_wstring(e.what())); \
Output::send<LogLevel::Error>(SYSSTR("Error: {}\n"), to_system(e.what())); \
} \
else \
{ \
printf_s("Internal Error: %s\n", e.what()); \
fprintf(stderr, "Internal Error: %s\n", e.what()); \
}

namespace RC
Expand Down
4 changes: 2 additions & 2 deletions UE4SS/include/GUI/ConsoleOutputDevice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace RC::Output

public:
auto has_optional_arg() const -> bool override;
auto receive(File::StringViewType fmt) const -> void override;
auto receive_with_optional_arg(File::StringViewType fmt, int32_t optional_arg = 0) const -> void override;
auto receive(SystemStringViewType fmt) const -> void override;
auto receive_with_optional_arg(SystemStringViewType fmt, int32_t optional_arg = 0) const -> void override;
};
} // namespace RC::Output
6 changes: 3 additions & 3 deletions UE4SS/include/GUI/GUITab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ namespace RC::GUI
private:
RenderFunctionType render_function{};
CppUserModBase* owner{};
StringType tab_name{};
UEStringType tab_name{};

public:
GUITab() = delete;
GUITab(StringViewType name, RenderFunctionType render_function) : tab_name(name), render_function(render_function){};
GUITab(StringViewType name, RenderFunctionType render_function, CppUserModBase* owner)
GUITab(UEStringViewType name, RenderFunctionType render_function) : tab_name(name), render_function(render_function){};
GUITab(UEStringViewType name, RenderFunctionType render_function, CppUserModBase* owner)
: tab_name(name), render_function(render_function), owner(owner){};
~GUITab() = default;

Expand Down
8 changes: 4 additions & 4 deletions UE4SS/include/GUI/LiveView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ namespace RC::GUI
Output::Targets<Output::FileDevice> output{};
FProperty* property{};
UObject* container{};
StringType object_name{};
StringType property_name{};
StringType property_value{};
UEStringType object_name{};
UEStringType property_name{};
UEStringType property_value{};
size_t hash{};
std::string history{};
float history_previous_max_scroll_y{};
Expand All @@ -77,7 +77,7 @@ namespace RC::GUI
std::pair<int, int> function_hook_ids{};

Watch() = delete;
Watch(StringType&& object_name, StringType&& property_name);
Watch(UEStringType&& object_name, UEStringType&& property_name);
};

private:
Expand Down
4 changes: 2 additions & 2 deletions UE4SS/include/GUI/LiveView/Filter/ClassNamesFilter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace RC::GUI::Filter
class ClassNamesFilter
{
public:
static inline StringType s_debug_name{STR("ClassNamesFilter")};
static inline UEStringType s_debug_name{STR("ClassNamesFilter")};
static inline std::string s_internal_class_names{};
static inline std::vector<StringType> list_class_names;
static inline std::vector<UEStringType> list_class_names;
static inline bool b_is_exclude{true};

static auto post_eval(UObject* object) -> bool
Expand Down
2 changes: 1 addition & 1 deletion UE4SS/include/GUI/LiveView/Filter/DefaultObjectsOnly.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace RC::GUI::Filter
class DefaultObjectsOnly
{
public:
static inline StringType s_debug_name{STR("DefaultObjectsOnly")};
static inline UEStringType s_debug_name{STR("DefaultObjectsOnly")};
static inline bool s_enabled{};

static auto pre_eval(UObject* object) -> bool
Expand Down
29 changes: 29 additions & 0 deletions UE4SS/include/GUI/LiveView/Filter/ExcludeClassName.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include <GUI/LiveView/Filter/SearchFilter.hpp>
#include <Unreal/UClass.hpp>

namespace RC::GUI::Filter
{
class ExcludeClassName
{
public:
static inline UEStringType s_debug_name{STR("ExcludeClassName")};
static inline UEStringType s_value{};
static inline std::string s_internal_value{};

static auto post_eval(UObject* object) -> bool
{
if (!s_value.empty())
{
auto class_name = object->GetClassPrivate()->GetName();
auto pos = class_name.find(s_value);
return pos != class_name.npos;
}
else
{
return false;
}
}
};
} // namespace RC::GUI::Filter
2 changes: 1 addition & 1 deletion UE4SS/include/GUI/LiveView/Filter/FunctionParamFlags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace RC::GUI::Filter
class FunctionParamFlags
{
public:
static inline StringType s_debug_name{STR("FunctionParamFlags")};
static inline UEStringType s_debug_name{STR("FunctionParamFlags")};
static inline bool s_enabled{};
static inline std::array<bool, 255> s_checkboxes{};
static inline EPropertyFlags s_value{};
Expand Down
4 changes: 2 additions & 2 deletions UE4SS/include/GUI/LiveView/Filter/HasProperty.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace RC::GUI::Filter
class HasProperty
{
public:
static inline StringType s_debug_name{STR("HasProperty")};
static inline UEStringType s_debug_name{STR("HasProperty")};
static inline std::string s_internal_properties{};
static inline std::vector<StringType> list_properties{};
static inline std::vector<UEStringType> list_properties{};

static auto post_eval(UObject* object) -> bool
{
Expand Down
2 changes: 1 addition & 1 deletion UE4SS/include/GUI/LiveView/Filter/HasPropertyType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace RC::GUI::Filter
class HasPropertyType
{
public:
static inline StringType s_debug_name{STR("HasPropertyType")};
static inline UEStringType s_debug_name{STR("HasPropertyType")};
static inline std::string s_internal_property_types{};
static inline std::vector<FName> list_property_types{};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace RC::GUI::Filter
class IncludeDefaultObjects
{
public:
static inline StringType s_debug_name{STR("IncludeDefaultObjects")};
static inline UEStringType s_debug_name{STR("IncludeDefaultObjects")};
static inline bool s_enabled{true};

static auto pre_eval(UObject* object) -> bool
Expand Down
2 changes: 1 addition & 1 deletion UE4SS/include/GUI/LiveView/Filter/InstancesOnly.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace RC::GUI::Filter
class InstancesOnly
{
public:
static inline StringType s_debug_name{STR("InstancesOnly")};
static inline UEStringType s_debug_name{STR("InstancesOnly")};
static inline bool s_enabled{};
static auto pre_eval(UObject* object) -> bool
{
Expand Down
2 changes: 1 addition & 1 deletion UE4SS/include/GUI/LiveView/Filter/NonInstancesOnly.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace RC::GUI::Filter
class NonInstancesOnly
{
public:
static inline StringType s_debug_name{STR("NonInstancesOnly")};
static inline UEStringType s_debug_name{STR("NonInstancesOnly")};
static inline bool s_enabled{};

static auto pre_eval(UObject* object) -> bool
Expand Down
6 changes: 3 additions & 3 deletions UE4SS/include/LuaCustomMemberFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ namespace RC::LuaBackCompat

// Backwards compatibility with UE4SS 1.3.

auto StaticFindObject(UClass* ObjectClass, UObject* InObjectPackage, const wchar_t* OrigInName, bool bExactClass = false) -> UObject*;
auto StaticFindObject(const wchar_t* OrigInName) -> UObject*;
auto NotifyOnNewObject(const wchar_t* class_name, std::function<void(UObject*)>& callable) -> void;
auto StaticFindObject(UClass* ObjectClass, UObject* InObjectPackage, const UECharType* OrigInName, bool bExactClass = false) -> UObject*;
auto StaticFindObject(const UECharType* OrigInName) -> UObject*;
auto NotifyOnNewObject(const UECharType* class_name, std::function<void(UObject*)>& callable) -> void;

auto lua_RegisterHook_wrapper(lua_State*) -> int;
auto lua_UObjectBase_IsA_wrapper(lua_State*) -> int;
Expand Down
10 changes: 6 additions & 4 deletions UE4SS/include/LuaType/LuaCustomProperty.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <string>
#include <vector>

#include <File/Macros.hpp>

namespace RC::Unreal
{
class UObject;
Expand All @@ -17,11 +19,11 @@ namespace RC::LuaType
class LuaCustomProperty
{
public:
std::wstring m_name{};
SystemStringType m_name{};
std::unique_ptr<Unreal::CustomProperty> m_property;

public:
LuaCustomProperty(std::wstring name, std::unique_ptr<Unreal::CustomProperty> property);
LuaCustomProperty(SystemStringType name, std::unique_ptr<Unreal::CustomProperty> property);

private:
class PropertyList
Expand All @@ -30,9 +32,9 @@ namespace RC::LuaType
std::vector<LuaCustomProperty> properties;

public:
auto add(std::wstring property_name, std::unique_ptr<Unreal::CustomProperty>) -> void;
auto add(SystemStringType property_name, std::unique_ptr<Unreal::CustomProperty>) -> void;
auto clear() -> void;
auto find_or_nullptr(Unreal::UObject* base, std::wstring property_name) -> Unreal::FProperty*;
auto find_or_nullptr(Unreal::UObject* base, SystemStringType property_name) -> Unreal::FProperty*;
};

public:
Expand Down
20 changes: 10 additions & 10 deletions UE4SS/include/LuaType/LuaUObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ namespace RC::LuaType
{
lua.throw_error("Function 'GetProperty' requires a string as the first parameter");
}
std::wstring property_name = to_wstring(lua.get_string(2));
auto property_name = to_system(lua.get_string(2));

auto reflection_table = lua.get_table();
const auto& reflected_object = reflection_table.get_userdata_field<SelfType>("ReflectedObject").get_remote_cpp_object();
Expand All @@ -478,7 +478,7 @@ namespace RC::LuaType
{
obj_as_struct = reflected_object->GetClassPrivate();
}
auto* property = obj_as_struct->FindProperty(Unreal::FName(property_name));
auto* property = obj_as_struct->FindProperty(Unreal::FName(to_ue(property_name)));

construct_xproperty(lua, property);
return 1;
Expand Down Expand Up @@ -586,7 +586,7 @@ No overload found for function 'UObject.ProcessConsoleExec'.
{
lua.throw_error(error_overload_not_found);
}
auto cmd = to_wstring(lua.get_string());
auto cmd = to_system(lua.get_string());

if (lua.get_stack_size() < 2)
{
Expand All @@ -601,7 +601,7 @@ No overload found for function 'UObject.ProcessConsoleExec'.
auto executor = lua.get_userdata<LuaType::UObject>();

auto ar = Unreal::FOutputDevice{};
auto return_value = lua_object.get_remote_cpp_object()->ProcessConsoleExec(cmd.c_str(), ar, executor.get_remote_cpp_object());
auto return_value = lua_object.get_remote_cpp_object()->ProcessConsoleExec(to_ue_string(cmd).c_str(), ar, executor.get_remote_cpp_object());

lua.set_bool(return_value);
return 1;
Expand Down Expand Up @@ -641,7 +641,7 @@ No overload found for function 'UObject.ProcessConsoleExec'.
{
auto& lua_object = lua.get_userdata<SelfType>();

const std::wstring& member_name = to_const_wstring(lua.get_string());
auto member_name = to_system_string(lua.get_string());

// If nullptr then we assume the UObject wasn't found so lets return an invalid UObject to Lua
// This allows the safe chaining of "__index" as long as the Lua script checks ":IsValid()" before using the object
Expand All @@ -656,17 +656,17 @@ No overload found for function 'UObject.ProcessConsoleExec'.
SelfType::construct(lua, static_cast<DerivedType*>(nullptr));
break;
case Operation::Set:
Output::send(STR("[Lua][Error] Tried setting member variable '{}' but UObject instance is nullptr\n"), member_name);
Output::send(SYSSTR("[Lua][Error] Tried setting member variable '{}' but UObject instance is nullptr\n"), member_name);
break;
default:
Output::send(STR("[Lua][Error] The UObject instance is nullptr & operation type was invalid\n"));
Output::send(SYSSTR("[Lua][Error] The UObject instance is nullptr & operation type was invalid\n"));
break;
}

return;
}

Unreal::FName property_name = Unreal::FName(member_name);
Unreal::FName property_name = Unreal::FName(to_ue(member_name));
Unreal::FField* field = LuaCustomProperty::StaticStorage::property_list.find_or_nullptr(lua_object.get_remote_cpp_object(), member_name);

if (!field)
Expand Down Expand Up @@ -777,10 +777,10 @@ No overload found for function 'UObject.ProcessConsoleExec'.
{
// We can either throw an error and kill the execution
/**/
std::wstring property_type_name = property_type.ToString();
auto property_type_name = to_string(property_type.ToString());
lua.throw_error(std::format(
"[LocalUnrealParam::prepare_to_handle] Tried accessing unreal property without a registered handler. Property type '{}' not supported.",
to_string(property_type_name)));
property_type_name));
//*/

// Or we can treat unhandled property types as some sort of generic type
Expand Down
10 changes: 5 additions & 5 deletions UE4SS/include/Mod/CppMod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace RC
typedef void (*uninstall_type)(CppUserModBase*);

private:
std::wstring m_dlls_path;
SystemStringType m_dlls_path;

HMODULE m_main_dll_module = NULL;
DLL_DIRECTORY_COOKIE m_dlls_path_cookie = NULL;
Expand All @@ -32,7 +32,7 @@ namespace RC
CppUserModBase* m_mod = nullptr;

public:
CppMod(UE4SSProgram&, std::wstring&& mod_name, std::wstring&& mod_path);
CppMod(UE4SSProgram&, SystemStringType&& mod_name, SystemStringType&& mod_path);
CppMod(CppMod&) = delete;
CppMod(CppMod&&) = delete;
~CppMod() override;
Expand All @@ -41,7 +41,7 @@ namespace RC
auto start_mod() -> void override;
auto uninstall() -> void override;

auto fire_on_lua_start(StringViewType mod_name,
auto fire_on_lua_start(SystemStringViewType mod_name,
LuaMadeSimple::Lua& lua,
LuaMadeSimple::Lua& main_lua,
LuaMadeSimple::Lua& async_lua,
Expand All @@ -50,7 +50,7 @@ namespace RC
auto fire_on_lua_start(LuaMadeSimple::Lua& lua, LuaMadeSimple::Lua& main_lua, LuaMadeSimple::Lua& async_lua, std::vector<LuaMadeSimple::Lua*>& hook_luas)
-> void;

auto fire_on_lua_stop(StringViewType mod_name,
auto fire_on_lua_stop(SystemStringViewType mod_name,
LuaMadeSimple::Lua& lua,
LuaMadeSimple::Lua& main_lua,
LuaMadeSimple::Lua& async_lua,
Expand All @@ -63,6 +63,6 @@ namespace RC
auto fire_ui_init() -> void override;
auto fire_program_start() -> void override;
auto fire_update() -> void override;
auto fire_dll_load(std::wstring_view dll_name) -> void;
auto fire_dll_load(SystemStringViewType dll_name) -> void;
};
} // namespace RC
Loading