More branding

This commit is contained in:
Federico Cecchetto 2022-02-02 23:58:46 +01:00
parent 71beb8bac4
commit c7ad7d4528
4 changed files with 126 additions and 16 deletions

View File

@ -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

View File

@ -5,12 +5,24 @@
#include "command.hpp"
#include "game/game.hpp"
#include "game/ui_scripting/execution.hpp"
#include <utils/hook.hpp>
#include <utils/string.hpp>
#include <version.h>
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);
}
};
}

View File

@ -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_");
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);
}
}

View File

@ -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