diff --git a/data/ui_scripts/branding/__init__.lua b/data/ui_scripts/branding/__init__.lua new file mode 100644 index 00000000..f0338fbc --- /dev/null +++ b/data/ui_scripts/branding/__init__.lua @@ -0,0 +1,92 @@ +local spacing = 10 +local topoffset = 15 + +local extrawidth = 50 +local extraheight = 40 + +LUI.MenuBuilder.m_types_build["SystemInfo"] = function (f6_arg0, f6_arg1) + local f6_local0 = LUI.MenuTemplate.spMenuOffset + local title = "LUA_MENU_SYSTEM_INFO_CAPS" + + local f6_local2 = false + local f6_local3 = 0 + + local menu = LUI.MenuTemplate.new(f6_arg0, { + menu_title = title, + menu_top_indent = f6_local0 + f6_local3, + showSelectButton = false, + skipAnim = f6_local2 + }) + + menu:setClass(LUI.SystemInfo) + menu:PopulateMissingProps(f6_arg1) + menu:ValidateProps(f6_arg1) + menu.id = "systemInfo_id" + + local f6_local5 = 300 + local f6_local6 = LUI.MenuTemplate.ListTop + f6_local0 + local f6_local7 = f6_arg1.menu_height + if not f6_local7 then + f6_local7 = f6_local5 + end + + f6_local7 = f6_local7 + f6_local6 - extraheight + + local f6_local9 = luiglobals.GenericMenuDims.OptionMenuWidth + 100 + local f6_local10 = menu.properties + local topoffset2 = LUI.MenuTemplate.ListTop + LUI.MenuTemplate.spMenuOffset + + local decobox = LUI.MenuBuilder.BuildRegisteredType("h1_box_deco", { + decoTopOffset = topoffset2 - topoffset + 15, + decoBottomOffset = -f6_local7, + decoRightOffset = -665 + extrawidth + }) + + menu:addElement(decobox) + + local decoleft = CoD.CreateState(0, 0.5, 8, 0.5, CoD.AnchorTypes.TopLeft) + decoleft.color = luiglobals.Colors.h1.light_grey + decobox:addElement(LUI.UILine.new(decoleft)) + + local decoright = CoD.CreateState(0, 0.5, -8, 0.5, CoD.AnchorTypes.TopRight) + decoright.color = luiglobals.Colors.h1.light_grey + decobox:addElement(LUI.UILine.new(decoright)) + + local element = LUI.UIVerticalList.new({ + leftAnchor = true, + rightAnchor = true, + topAnchor = true, + bottomAnchor = true, + left = spacing, + right = 100, + top = topoffset2 + 15, + bottom = 0, + spacing = spacing * 0.8 + }) + + element.id = "systemInfoList_id" + menu.vlist = element + menu:addElement(element) + + local optionmenuwidth = luiglobals.GenericMenuDims.OptionMenuWidth + luiglobals.GenericMenuDims.OptionMenuWidth = optionmenuwidth + extrawidth + + menu:AddInfo(Engine.Localize("MENU_SYSINFO_VERSION"), function() + return Engine.GetBuildNumber() + end) + + menu:AddInfo(Engine.Localize("MENU_SYSINFO_CUSTOMER_SUPPORT_LINK"), function() + return Engine.Localize("MENU_SYSINFO_CUSTOMER_SUPPORT_URL") + end) + + menu:AddInfo(Engine.Localize("MENU_SYSINFO_DONATION_LINK"), function() + return Engine.Localize("MENU_SYSINFO_DONATION_URL") + end) + + luiglobals.GenericMenuDims.OptionMenuWidth = optionmenuwidth + + menu:AddBackButton() + menu:registerEventHandler("menu_close", LUI.SystemInfo.LeaveMenu) + + return menu +end \ No newline at end of file diff --git a/src/client/component/branding.cpp b/src/client/component/branding.cpp index b14dcf65..95c9aa4d 100644 --- a/src/client/component/branding.cpp +++ b/src/client/component/branding.cpp @@ -5,12 +5,24 @@ #include "command.hpp" #include "game/game.hpp" +#include "game/ui_scripting/execution.hpp" + #include #include +#include namespace branding { - float color[4] = {0.9f, 0.9f, 0.5f, 1.f}; + namespace + { + float color[4] = {0.9f, 0.9f, 0.5f, 1.f}; + + int get_build_number_stub(game::hks::lua_State* s) + { + ui_scripting::push_value(VERSION); + return 1; + } + } void draw() { @@ -26,6 +38,12 @@ namespace branding void post_unpack() override { localized_strings::override("MENU_SP_CAMPAIGN", "H2-MOD"); + localized_strings::override("MENU_SYSINFO_CUSTOMER_SUPPORT_LINK", "Github Page"); + localized_strings::override("MENU_SYSINFO_CUSTOMER_SUPPORT_URL", "https://github.com/fedddddd/h2-mod"); + localized_strings::override("MENU_SYSINFO_DONATION_LINK", "Donation Link"); + localized_strings::override("MENU_SYSINFO_DONATION_URL", "https://paypal.me/fedecek"); + + utils::hook::jump(0x33D550_b, get_build_number_stub, true); } }; } diff --git a/src/client/game/ui_scripting/lua/context.cpp b/src/client/game/ui_scripting/lua/context.cpp index 9c3ff8c3..d5dadd90 100644 --- a/src/client/game/ui_scripting/lua/context.cpp +++ b/src/client/game/ui_scripting/lua/context.cpp @@ -1317,12 +1317,6 @@ namespace ui_scripting::lua table.set(name, convert({s, value})); }; - state["luiglobals"] = table((*::game::hks::lua_state)->globals.v.table); - state["CoD"] = state["luiglobals"]["CoD"]; - state["LUI"] = state["luiglobals"]["LUI"]; - state["Engine"] = state["luiglobals"]["Engine"]; - state["Game"] = state["luiglobals"]["Game"]; - auto function_type = state.new_usertype("function_"); function_type[sol::meta_function::call] = [](const function& function, const sol::this_state s, sol::variadic_args va) @@ -1345,6 +1339,12 @@ namespace ui_scripting::lua return sol::as_returns(returns); }; + state["luiglobals"] = table((*::game::hks::lua_state)->globals.v.table); + state["CoD"] = state["luiglobals"]["CoD"]; + state["LUI"] = state["luiglobals"]["LUI"]; + state["Engine"] = state["luiglobals"]["Engine"]; + state["Game"] = state["luiglobals"]["Game"]; + state.script(animation_script); } } diff --git a/src/client/resources/updater.lua b/src/client/resources/updater.lua index f73bf3f7..2e3b79f6 100644 --- a/src/client/resources/updater.lua +++ b/src/client/resources/updater.lua @@ -1,24 +1,24 @@ -LUI.menucallbacks = {} -LUI.originalmenus = {} +menucallbacks = {} +originalmenus = {} LUI.onmenuopen = function(name, callback) if (not LUI.MenuBuilder.m_types_build[name]) then return end - if (not LUI.menucallbacks[name]) then - LUI.menucallbacks[name] = {} + if (not menucallbacks[name]) then + menucallbacks[name] = {} end - luiglobals.table.insert(LUI.menucallbacks[name], callback) + table.insert(menucallbacks[name], callback) - if (not LUI.originalmenus[name]) then - LUI.originalmenus[name] = LUI.MenuBuilder.m_types_build[name] + if (not originalmenus[name]) then + originalmenus[name] = LUI.MenuBuilder.m_types_build[name] LUI.MenuBuilder.m_types_build[name] = function(...) local args = {...} - local menu = LUI.originalmenus[name](table.unpack(args)) + local menu = originalmenus[name](table.unpack(args)) - for k, v in luiglobals.next, LUI.menucallbacks[name] do + for k, v in luiglobals.next, menucallbacks[name] do v(menu, table.unpack(args)) end