commit
e2295ad7b2
29
data/cdata/scripts/ending/credits.gsc
Normal file
29
data/cdata/scripts/ending/credits.gsc
Normal file
@ -0,0 +1,29 @@
|
||||
main()
|
||||
{
|
||||
replacefunc(maps\_credit_h2_autogen::_id_B775, ::initiwcredits);
|
||||
}
|
||||
|
||||
initcredits_h2mod()
|
||||
{
|
||||
maps\_credits::addcenterimage("LOGO_H2MOD", 256, 64, 2);
|
||||
maps\_credits::addspace();
|
||||
maps\_credits::addcenterheading(&"CREDIT_H2MOD_DEVELOPERS");
|
||||
maps\_credits::addgap();
|
||||
maps\_credits::addcenternamedouble(&"CREDIT_H2MOD_FED", &"CREDIT_H2MOD_VLAD");
|
||||
maps\_credits::addcenternamedouble(&"CREDIT_H2MOD_FUTURE", &"CREDIT_H2MOD_NETADR");
|
||||
maps\_credits::addgap();
|
||||
maps\_credits::addcenterheading(&"CREDIT_H2MOD_SPECIAL_THANKS");
|
||||
maps\_credits::addgap();
|
||||
maps\_credits::addcenternamedouble(&"CREDIT_H2MOD_SNAKE", &"CREDIT_H2MOD_QUAK");
|
||||
maps\_credits::addcenternamedouble(&"CREDIT_H2MOD_XENSIK", &"CREDIT_H2MOD_JARIK");
|
||||
}
|
||||
|
||||
initiwcredits()
|
||||
{
|
||||
initcredits_h2mod();
|
||||
maps\_credit_h2_autogen::initiwcredits_iw();
|
||||
maps\_credit_h2_autogen::initiwcredits_beenox();
|
||||
maps\_credit_h2_autogen::initiwcredits_ca();
|
||||
maps\_credit_h2_autogen::initiwcredits_nerve();
|
||||
maps\_credit_h2_autogen::initiwcredits_irongalaxy();
|
||||
}
|
@ -1,298 +1,2 @@
|
||||
local spacing = 10
|
||||
local topoffset = 15
|
||||
|
||||
local extrawidth = 50
|
||||
local extraheight1 = 0
|
||||
|
||||
local function makelink(element, link)
|
||||
element:setHandleMouseMove(true)
|
||||
element:setHandleMouseButton(true)
|
||||
element:registerAnimationState("focused", {
|
||||
color = {
|
||||
r = 1,
|
||||
g = 1,
|
||||
b = 1
|
||||
}
|
||||
})
|
||||
|
||||
local entered = false
|
||||
element:registerEventHandler("mouseenter", function()
|
||||
if (not entered) then
|
||||
Engine.PlaySound(CoD.SFX.MouseOver)
|
||||
entered = true
|
||||
end
|
||||
|
||||
element:animateToState("focused")
|
||||
end)
|
||||
|
||||
element:registerEventHandler("mouseleave", function()
|
||||
entered = false
|
||||
element:animateToState("default")
|
||||
end)
|
||||
|
||||
element:registerEventHandler("leftmousedown", function()
|
||||
Engine.PlaySound(CoD.SFX.MouseClick)
|
||||
game:openlink(link)
|
||||
end)
|
||||
end
|
||||
|
||||
local addlinkinfo = function(menu, key, value, link)
|
||||
local text = Engine.Localize(value)
|
||||
local element = menu:AddInfo(Engine.Localize(key), function()
|
||||
return text
|
||||
end)
|
||||
|
||||
local linkelement = element:getFirstChild():getNextSibling()
|
||||
makelink(linkelement, link)
|
||||
end
|
||||
|
||||
local function getnumcredits()
|
||||
local csv = "credits.csv"
|
||||
local rowcount = Engine.TableGetRowCount(csv)
|
||||
return rowcount
|
||||
end
|
||||
|
||||
local extraheight2 = getnumcredits() * 25 / 2
|
||||
|
||||
local function addcredits(menu)
|
||||
local cols = {
|
||||
name = 0,
|
||||
link = 1
|
||||
}
|
||||
|
||||
local csv = "credits.csv"
|
||||
local rowcount = Engine.TableGetRowCount(csv)
|
||||
|
||||
local num = 0
|
||||
local creditselement = LUI.UIElement.new({
|
||||
topAnchor = true,
|
||||
leftAnchor = true,
|
||||
left = 500,
|
||||
width = 30,
|
||||
top = 255
|
||||
})
|
||||
|
||||
menu:addElement(creditselement)
|
||||
|
||||
menu:AddInfo(Engine.Localize("MENU_CREDITS"), function()
|
||||
return ""
|
||||
end)
|
||||
|
||||
local num = 0
|
||||
local addcredit = function(name, link)
|
||||
local row = num % 4
|
||||
local col = num >= 4 and 0 or 1
|
||||
local text = Engine.Localize(name)
|
||||
|
||||
local element = LUI.UIText.new({
|
||||
rightAnchor = true,
|
||||
topAnchor = true,
|
||||
right = -10 + (col * -100),
|
||||
top = 25 * row,
|
||||
width = 90,
|
||||
height = LUI.MenuGenericButtons.ButtonLabelFont.Height * 0.8,
|
||||
font = LUI.MenuGenericButtons.ButtonLabelFont.Font,
|
||||
color = Colors.h1.light_grey,
|
||||
alignment = Engine.IsRightToLeftLanguage() and LUI.Alignment.None or LUI.Alignment.Right
|
||||
})
|
||||
|
||||
element.id = "credits_" .. num
|
||||
element:setText(text)
|
||||
creditselement:addElement(element)
|
||||
makelink(element, link)
|
||||
|
||||
num = num + 1
|
||||
end
|
||||
|
||||
for i = 0, rowcount - 1 do
|
||||
local name = Engine.TableLookupByRow(csv, i, cols.name)
|
||||
local link = Engine.TableLookupByRow(csv, i, cols.link)
|
||||
addcredit(name, link)
|
||||
end
|
||||
end
|
||||
|
||||
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 - extraheight1
|
||||
|
||||
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)
|
||||
|
||||
addlinkinfo(menu, "MENU_SYSINFO_CUSTOMER_SUPPORT_LINK", "MENU_SYSINFO_CUSTOMER_SUPPORT_URL", "github")
|
||||
|
||||
luiglobals.GenericMenuDims.OptionMenuWidth = optionmenuwidth
|
||||
|
||||
menu:AddBackButton()
|
||||
menu:registerEventHandler("menu_close", LUI.SystemInfo.LeaveMenu)
|
||||
|
||||
return menu
|
||||
end
|
||||
|
||||
local startmap = Engine.StreamingInstallMap
|
||||
Engine.StreamingInstallMap = function(map, args, ...)
|
||||
if (args == "set ui_play_credits 1; devmap ending;") then
|
||||
LUI.FlowManager.RequestAddMenu(nil, "credits_menu")
|
||||
else
|
||||
startmap(map, args, ...)
|
||||
end
|
||||
end
|
||||
|
||||
local creditsmap = function()
|
||||
LUI.FlowManager.PushMenuStackToDVar()
|
||||
|
||||
if LUI.LevelSelect.IsAllLevelCompleted() then
|
||||
Engine.SetDvarString("ui_char_museum_mode", "credits_2", true)
|
||||
else
|
||||
Engine.SetDvarString("ui_char_museum_mode", "credits_black", true)
|
||||
end
|
||||
|
||||
startmap("ending", "set ui_play_credits 1; devmap ending;")
|
||||
end
|
||||
|
||||
LUI.MenuBuilder.registerType("credits_menu", function(f6_arg0, f6_arg1)
|
||||
local f6_local0 = LUI.MenuTemplate.spMenuOffset
|
||||
local title = "MENU_SP_CREDITS_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:AddButton("MENU_SP_CREDITS_CAPS", creditsmap, nil, true, nil, {
|
||||
desc_text = Engine.Localize("@LUA_MENU_CREDITS_DESC")
|
||||
})
|
||||
|
||||
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 - extraheight2
|
||||
|
||||
local f6_local9 = luiglobals.GenericMenuDims.OptionMenuWidth + 100
|
||||
local f6_local10 = menu.properties
|
||||
local topoffset2 = LUI.MenuTemplate.ListTop + LUI.MenuTemplate.spMenuOffset + 50
|
||||
|
||||
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
|
||||
|
||||
addlinkinfo(menu, "MENU_SYSINFO_CUSTOMER_SUPPORT_LINK", "MENU_SYSINFO_CUSTOMER_SUPPORT_URL", "github")
|
||||
addlinkinfo(menu, "MENU_SYSINFO_DONATION_LINK", "MENU_SYSINFO_DONATION_URL", "donate")
|
||||
|
||||
addcredits(menu)
|
||||
|
||||
luiglobals.GenericMenuDims.OptionMenuWidth = optionmenuwidth
|
||||
|
||||
menu:AddBackButton()
|
||||
menu:registerEventHandler("menu_close", LUI.SystemInfo.LeaveMenu)
|
||||
|
||||
return menu
|
||||
end)
|
||||
require("credits")
|
||||
require("mainmenu")
|
||||
|
300
data/cdata/ui_scripts/branding/credits.lua
Normal file
300
data/cdata/ui_scripts/branding/credits.lua
Normal file
@ -0,0 +1,300 @@
|
||||
local spacing = 10
|
||||
local topoffset = 15
|
||||
|
||||
local extrawidth = 50
|
||||
local extraheight1 = 0
|
||||
|
||||
local function makelink(element, link)
|
||||
element:setHandleMouseMove(true)
|
||||
element:setHandleMouseButton(true)
|
||||
element:registerAnimationState("focused", {
|
||||
color = {
|
||||
r = 1,
|
||||
g = 1,
|
||||
b = 1
|
||||
}
|
||||
})
|
||||
|
||||
local entered = false
|
||||
element:registerEventHandler("mouseenter", function()
|
||||
if (not entered) then
|
||||
Engine.PlaySound(CoD.SFX.MouseOver)
|
||||
entered = true
|
||||
end
|
||||
|
||||
element:animateToState("focused")
|
||||
end)
|
||||
|
||||
element:registerEventHandler("mouseleave", function()
|
||||
entered = false
|
||||
element:animateToState("default")
|
||||
end)
|
||||
|
||||
element:registerEventHandler("leftmousedown", function()
|
||||
Engine.PlaySound(CoD.SFX.MouseClick)
|
||||
game:openlink(link)
|
||||
end)
|
||||
end
|
||||
|
||||
local addlinkinfo = function(menu, key, value, link)
|
||||
local text = Engine.Localize(value)
|
||||
local element = menu:AddInfo(Engine.Localize(key), function()
|
||||
return text
|
||||
end)
|
||||
|
||||
local linkelement = element:getFirstChild():getNextSibling()
|
||||
makelink(linkelement, link)
|
||||
end
|
||||
|
||||
local function getnumcredits()
|
||||
local csv = "credits.csv"
|
||||
local rowcount = Engine.TableGetRowCount(csv)
|
||||
return rowcount
|
||||
end
|
||||
|
||||
local extraheight2 = getnumcredits() * 25 / 2
|
||||
|
||||
local function addcredits(menu)
|
||||
local cols = {
|
||||
name = 0,
|
||||
link = 1
|
||||
}
|
||||
|
||||
local csv = "credits.csv"
|
||||
local rowcount = Engine.TableGetRowCount(csv)
|
||||
|
||||
local num = 0
|
||||
local creditselement = LUI.UIElement.new({
|
||||
topAnchor = true,
|
||||
leftAnchor = true,
|
||||
left = 500,
|
||||
width = 30,
|
||||
top = 255
|
||||
})
|
||||
|
||||
menu:addElement(creditselement)
|
||||
|
||||
menu:AddInfo(Engine.Localize("MENU_CREDITS"), function()
|
||||
return ""
|
||||
end)
|
||||
|
||||
local num = 0
|
||||
local addcredit = function(name, link)
|
||||
local row = num % 4
|
||||
local col = num >= 4 and 0 or 1
|
||||
local text = Engine.Localize(name)
|
||||
|
||||
local element = LUI.UIText.new({
|
||||
rightAnchor = true,
|
||||
topAnchor = true,
|
||||
right = -10 + (col * -100),
|
||||
top = 25 * row,
|
||||
width = 90,
|
||||
height = LUI.MenuGenericButtons.ButtonLabelFont.Height * 0.8,
|
||||
font = LUI.MenuGenericButtons.ButtonLabelFont.Font,
|
||||
color = Colors.h1.light_grey,
|
||||
alignment = Engine.IsRightToLeftLanguage() and LUI.Alignment.None or LUI.Alignment.Right
|
||||
})
|
||||
|
||||
element.id = "credits_" .. num
|
||||
element:setText(text)
|
||||
creditselement:addElement(element)
|
||||
makelink(element, link)
|
||||
|
||||
num = num + 1
|
||||
end
|
||||
|
||||
for i = 0, rowcount - 1 do
|
||||
local name = Engine.TableLookupByRow(csv, i, cols.name)
|
||||
local link = Engine.TableLookupByRow(csv, i, cols.link)
|
||||
addcredit(name, link)
|
||||
end
|
||||
end
|
||||
|
||||
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 - extraheight1
|
||||
|
||||
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)
|
||||
|
||||
addlinkinfo(menu, "MENU_SYSINFO_CUSTOMER_SUPPORT_LINK", "MENU_SYSINFO_CUSTOMER_SUPPORT_URL", "github")
|
||||
|
||||
luiglobals.GenericMenuDims.OptionMenuWidth = optionmenuwidth
|
||||
|
||||
menu:AddBackButton()
|
||||
menu:registerEventHandler("menu_close", LUI.SystemInfo.LeaveMenu)
|
||||
|
||||
return menu
|
||||
end
|
||||
|
||||
local startmap = Engine.StreamingInstallMap
|
||||
Engine.StreamingInstallMap = function(map, args, ...)
|
||||
if (args == "set ui_play_credits 1; devmap ending;") then
|
||||
LUI.FlowManager.RequestAddMenu(nil, "credits_menu")
|
||||
else
|
||||
startmap(map, args, ...)
|
||||
end
|
||||
end
|
||||
|
||||
local creditsmap = function()
|
||||
LUI.FlowManager.PushMenuStackToDVar()
|
||||
|
||||
if LUI.LevelSelect.IsAllLevelCompleted() then
|
||||
Engine.SetDvarString("ui_char_museum_mode", "credits_2", true)
|
||||
else
|
||||
Engine.SetDvarString("ui_char_museum_mode", "credits_black", true)
|
||||
end
|
||||
|
||||
startmap("ending", "set ui_play_credits 1; devmap ending;")
|
||||
end
|
||||
|
||||
LUI.MenuBuilder.registerType("credits_menu", function(f6_arg0, f6_arg1)
|
||||
local f6_local0 = LUI.MenuTemplate.spMenuOffset
|
||||
local title = "MENU_SP_CREDITS_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
|
||||
})
|
||||
|
||||
PersistentBackground.ChangeBackground(nil, CoD.Background.CampaignRegular)
|
||||
|
||||
menu:AddButton("MENU_SP_CREDITS_CAPS", creditsmap, nil, true, nil, {
|
||||
desc_text = Engine.Localize("@LUA_MENU_CREDITS_DESC")
|
||||
})
|
||||
|
||||
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 - extraheight2
|
||||
|
||||
local f6_local9 = luiglobals.GenericMenuDims.OptionMenuWidth + 100
|
||||
local f6_local10 = menu.properties
|
||||
local topoffset2 = LUI.MenuTemplate.ListTop + LUI.MenuTemplate.spMenuOffset + 50
|
||||
|
||||
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
|
||||
|
||||
addlinkinfo(menu, "MENU_SYSINFO_CUSTOMER_SUPPORT_LINK", "MENU_SYSINFO_CUSTOMER_SUPPORT_URL", "github")
|
||||
addlinkinfo(menu, "MENU_SYSINFO_DONATION_LINK", "MENU_SYSINFO_DONATION_URL", "donate")
|
||||
|
||||
addcredits(menu)
|
||||
|
||||
luiglobals.GenericMenuDims.OptionMenuWidth = optionmenuwidth
|
||||
|
||||
menu:AddBackButton()
|
||||
menu:registerEventHandler("menu_close", LUI.SystemInfo.LeaveMenu)
|
||||
|
||||
return menu
|
||||
end)
|
4
data/cdata/ui_scripts/branding/mainmenu.lua
Normal file
4
data/cdata/ui_scripts/branding/mainmenu.lua
Normal file
@ -0,0 +1,4 @@
|
||||
LUI.onmenuopen("main_campaign", function(menu)
|
||||
local headertext = menu:getFirstDescendentById("header_text")
|
||||
headertext:setText("H2-MOD")
|
||||
end)
|
@ -42,17 +42,10 @@ function getmodname(path)
|
||||
local modinfo = mods.getinfo(path)
|
||||
|
||||
if (not modinfo.isvalid) then
|
||||
game:addlocalizedstring(path, path)
|
||||
local desc = Engine.Localize("LUA_MENU_MOD_DESC_DEFAULT", path)
|
||||
|
||||
local desc = Engine.Localize("LUA_MENU_MOD_DESC_DEFAULT", string.el(path))
|
||||
return path, desc
|
||||
else
|
||||
game:addlocalizedstring(modinfo.name, modinfo.name)
|
||||
game:addlocalizedstring(modinfo.description, modinfo.description)
|
||||
game:addlocalizedstring(modinfo.author, modinfo.author)
|
||||
game:addlocalizedstring(modinfo.version, modinfo.version)
|
||||
local desc = Engine.Localize("@LUA_MENU_MOD_DESC",
|
||||
modinfo.description, modinfo.author, modinfo.version)
|
||||
local desc = Engine.Localize("@LUA_MENU_MOD_DESC", string.el(modinfo.description), string.el(modinfo.author), string.el(modinfo.version))
|
||||
return modinfo.name, desc
|
||||
end
|
||||
end
|
||||
@ -67,18 +60,10 @@ LUI.MenuBuilder.registerType("mods_menu", function(a1)
|
||||
uppercase_title = true
|
||||
})
|
||||
|
||||
--[[menu:AddButton("@LUA_MENU_WORKSHOP", function()
|
||||
if (LUI.MenuBuilder.m_types_build["mods_workshop_menu"]) then
|
||||
LUI.FlowManager.RequestAddMenu(nil, "mods_workshop_menu")
|
||||
end
|
||||
end, nil, true, nil, {
|
||||
desc_text = Engine.Localize("@LUA_MENU_WORKSHOP_DESC")
|
||||
})--]]
|
||||
|
||||
local modfolder = game:getloadedmod()
|
||||
if (modfolder ~= "") then
|
||||
local name = getmodname(modfolder)
|
||||
createdivider(menu, Engine.Localize("@LUA_MENU_LOADED_MOD", name:truncate(24)))
|
||||
createdivider(menu, Engine.Localize("@LUA_MENU_LOADED_MOD", string.el(name:truncate(24))))
|
||||
|
||||
menu:AddButton("@LUA_MENU_UNLOAD", function()
|
||||
Engine.Exec("unloadmod")
|
||||
@ -98,8 +83,7 @@ LUI.MenuBuilder.registerType("mods_menu", function(a1)
|
||||
local name, desc = getmodname(mods[i])
|
||||
|
||||
if (mods[i] ~= modfolder) then
|
||||
game:addlocalizedstring(name, name)
|
||||
menu:AddButton(name, function()
|
||||
menu:AddButton(string.el(name), function()
|
||||
Engine.Exec("loadmod " .. mods[i])
|
||||
end, nil, true, nil, {
|
||||
desc_text = desc
|
||||
|
@ -8,6 +8,7 @@ fra_h2_mod_common
|
||||
h2_mod_common
|
||||
h2_mod_patch_af_caves
|
||||
h2_mod_patch_dc_whitehouse
|
||||
h2_mod_patch_ending
|
||||
h2_mod_pre_gfx
|
||||
ita_h2_mod_common
|
||||
jpf_h2_mod_common
|
||||
|
2
data/zone_source/h2_mod_patch_ending.csv
Normal file
2
data/zone_source/h2_mod_patch_ending.csv
Normal file
@ -0,0 +1,2 @@
|
||||
material,logo_h2mod
|
||||
localize,english
|
|
BIN
data/zonetool/h2_mod_patch_ending/images/logo_h2mod.dds
Normal file
BIN
data/zonetool/h2_mod_patch_ending/images/logo_h2mod.dds
Normal file
Binary file not shown.
@ -0,0 +1,12 @@
|
||||
{
|
||||
"CREDIT_H2MOD_DEVELOPERS": "DEVELOPERS",
|
||||
"CREDIT_H2MOD_SPECIAL_THANKS": "SPECIAL THANKS",
|
||||
"CREDIT_H2MOD_FED": "fed",
|
||||
"CREDIT_H2MOD_VLAD": "Vlad",
|
||||
"CREDIT_H2MOD_FUTURE": "Future",
|
||||
"CREDIT_H2MOD_JARIK": "JariKCoding",
|
||||
"CREDIT_H2MOD_NETADR": "netadr",
|
||||
"CREDIT_H2MOD_QUAK": "quaK",
|
||||
"CREDIT_H2MOD_SNAKE": "momo5502",
|
||||
"CREDIT_H2MOD_XENSIK": "xensik"
|
||||
}
|
26
data/zonetool/h2_mod_patch_ending/materials/logo_h2mod.json
Normal file
26
data/zonetool/h2_mod_patch_ending/materials/logo_h2mod.json
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "logo_h2mod",
|
||||
"techniqueSet->name": "2d",
|
||||
"gameFlags": 4,
|
||||
"sortKey": 61,
|
||||
"renderFlags": 0,
|
||||
"textureAtlasRowCount": 1,
|
||||
"textureAtlasColumnCount": 1,
|
||||
"textureAtlasFrameBlend": 0,
|
||||
"textureAtlasAsArray": 0,
|
||||
"surfaceTypeBits": 0,
|
||||
"cameraRegion": 14,
|
||||
"materialType": 0,
|
||||
"assetFlags": 0,
|
||||
"constantTable": null,
|
||||
"textureTable": [
|
||||
{
|
||||
"image": "logo_h2mod",
|
||||
"semantic": 0,
|
||||
"samplerState": 19,
|
||||
"lastCharacter": 112,
|
||||
"firstCharacter": 99,
|
||||
"typeHash": 2695565377
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
BIN
data/zonetool/h2_mod_patch_ending/techsets/constantbuffer/2d.cbt
Normal file
BIN
data/zonetool/h2_mod_patch_ending/techsets/constantbuffer/2d.cbt
Normal file
Binary file not shown.
BIN
data/zonetool/h2_mod_patch_ending/techsets/state/2d.statebits
Normal file
BIN
data/zonetool/h2_mod_patch_ending/techsets/state/2d.statebits
Normal file
Binary file not shown.
@ -0,0 +1,31 @@
|
||||
[
|
||||
{
|
||||
"loadBits": [
|
||||
10,
|
||||
3759013900,
|
||||
65535,
|
||||
251732325,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"depthStencilStateBits": [
|
||||
9938018369548,
|
||||
17664666632780,
|
||||
4418985394188,
|
||||
2211374301773,
|
||||
19872279822925,
|
||||
9938018369549,
|
||||
17664666632781,
|
||||
281474443903821,
|
||||
281474443903809,
|
||||
281474440757260,
|
||||
9938018369548
|
||||
],
|
||||
"blendStateBits": [
|
||||
251732325,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"rasterizerState": 33
|
||||
}
|
||||
]
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"stateFlags": 0
|
||||
}
|
@ -95,5 +95,26 @@
|
||||
"MENU_CREDITS_5": "netadr",
|
||||
"MENU_CREDITS_6": "quaK",
|
||||
"MENU_CREDITS_7": "xensik",
|
||||
"MENU_CREDITS_8": "ZoneTool"
|
||||
"MENU_CREDITS_8": "ZoneTool",
|
||||
|
||||
"LUA_MENU_SP_LOCATION_AF_CAVES": "LUA_MENU_SP_LOCATION_AF_CAVES",
|
||||
"LUA_MENU_SP_LOCATION_AF_CHASE": "LUA_MENU_SP_LOCATION_AF_CHASE",
|
||||
"LUA_MENU_SP_LOCATION_AIRPORT": "LUA_MENU_SP_LOCATION_AIRPORT",
|
||||
"LUA_MENU_SP_LOCATION_ARCADIA": "LUA_MENU_SP_LOCATION_ARCADIA",
|
||||
"LUA_MENU_SP_LOCATION_BONEYARD": "LUA_MENU_SP_LOCATION_BONEYARD",
|
||||
"LUA_MENU_SP_LOCATION_CLIFFHANGER": "LUA_MENU_SP_LOCATION_CLIFFHANGER",
|
||||
"LUA_MENU_SP_LOCATION_CONTINGENCY": "LUA_MENU_SP_LOCATION_CONTINGENCY",
|
||||
"LUA_MENU_SP_LOCATION_DC_WHITEHOUSE": "LUA_MENU_SP_LOCATION_DC_WHITEHOUSE",
|
||||
"LUA_MENU_SP_LOCATION_DCBURNING": "LUA_MENU_SP_LOCATION_DCBURNING",
|
||||
"LUA_MENU_SP_LOCATION_DCEMP": "LUA_MENU_SP_LOCATION_DCEMP",
|
||||
"LUA_MENU_SP_LOCATION_ENDING": "LUA_MENU_SP_LOCATION_ENDING",
|
||||
"LUA_MENU_SP_LOCATION_ESTATE": "LUA_MENU_SP_LOCATION_ESTATE",
|
||||
"LUA_MENU_SP_LOCATION_FAVELA": "LUA_MENU_SP_LOCATION_FAVELA",
|
||||
"LUA_MENU_SP_LOCATION_FAVELA_ESCAPE": "LUA_MENU_SP_LOCATION_FAVELA_ESCAPE",
|
||||
"LUA_MENU_SP_LOCATION_GULAG": "LUA_MENU_SP_LOCATION_GULAG",
|
||||
"LUA_MENU_SP_LOCATION_INVASION": "LUA_MENU_SP_LOCATION_INVASION",
|
||||
"LUA_MENU_SP_LOCATION_OILRIG": "LUA_MENU_SP_LOCATION_OILRIG",
|
||||
"LUA_MENU_SP_LOCATION_ROADKILL": "LUA_MENU_SP_LOCATION_ROADKILL",
|
||||
"LUA_MENU_SP_LOCATION_TRAINER": "LUA_MENU_SP_LOCATION_TRAINER",
|
||||
"LUA_MENU_SP_LOCATION_MUSEUM": "LUA_MENU_SP_LOCATION_MUSEUM"
|
||||
}
|
2
deps/GSL
vendored
2
deps/GSL
vendored
@ -1 +1 @@
|
||||
Subproject commit 9f85e4e0880bf90d51b8dee15c65386b8e8e9fc2
|
||||
Subproject commit b080081c9c089549956949c0ddaa3094c69098e6
|
2
deps/asmjit
vendored
2
deps/asmjit
vendored
@ -1 +1 @@
|
||||
Subproject commit 8552e286c2960d18df0e096166f29a26f2d3c2f1
|
||||
Subproject commit d4dfd8e86529465efc4365f27b125d90552c700e
|
@ -4,7 +4,6 @@
|
||||
#include "game/game.hpp"
|
||||
#include "game/dvars.hpp"
|
||||
|
||||
#include "localized_strings.hpp"
|
||||
#include "scheduler.hpp"
|
||||
#include "command.hpp"
|
||||
|
||||
@ -46,7 +45,7 @@ namespace branding
|
||||
game::rectDef_s text_rect{};
|
||||
|
||||
game::UI_DrawWrappedText(placement, "h2-mod", &rect, font,
|
||||
5.f, 13.f, 0.20f, color, 0, 0, &text_rect, 0);
|
||||
5.f, 12.f, 0.17f, color, 0, 0, &text_rect, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,8 +56,6 @@ namespace branding
|
||||
{
|
||||
scheduler::loop(draw, scheduler::pipeline::renderer);
|
||||
|
||||
localized_strings::override("MENU_SP_CAMPAIGN", "H2-MOD");
|
||||
|
||||
ui_get_formatted_build_number_hook.create(0x1406057D0, ui_get_formatted_build_number_stub);
|
||||
}
|
||||
};
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
#include "command.hpp"
|
||||
#include "console.hpp"
|
||||
#include "localized_strings.hpp"
|
||||
#include "mods.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
@ -74,16 +73,6 @@ namespace fastfiles
|
||||
return result;
|
||||
}
|
||||
|
||||
void add_missing_localized_strings()
|
||||
{
|
||||
for (auto map = &game::maps[0]; map->unk; ++map)
|
||||
{
|
||||
const auto str = utils::string::va("LUA_MENU_SP_LOCATION_%s",
|
||||
utils::string::to_upper(map->name).data());
|
||||
localized_strings::override(str, str);
|
||||
}
|
||||
}
|
||||
|
||||
utils::hook::detour db_read_stream_file_hook;
|
||||
void db_read_stream_file_stub(int a1, int a2)
|
||||
{
|
||||
@ -597,8 +586,6 @@ namespace fastfiles
|
||||
db_try_load_x_file_internal_hook.create(0x1404173B0, db_try_load_x_file_internal);
|
||||
db_find_xasset_header.create(game::DB_FindXAssetHeader, db_find_xasset_header_stub);
|
||||
|
||||
add_missing_localized_strings();
|
||||
|
||||
// Allow loading of mixed compressor types
|
||||
utils::hook::nop(0x1403E66A7, 2);
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include "filesystem.hpp"
|
||||
#include "console.hpp"
|
||||
#include "localized_strings.hpp"
|
||||
#include "mods.hpp"
|
||||
#include "language.hpp"
|
||||
|
||||
@ -42,8 +41,6 @@ namespace filesystem
|
||||
mods::set_mod(mod_path.value());
|
||||
}
|
||||
|
||||
localized_strings::clear();
|
||||
|
||||
utils::hook::invoke<void>(0x14060BF50, name);
|
||||
}
|
||||
|
||||
|
@ -267,10 +267,10 @@ namespace fps
|
||||
|
||||
const auto font = fps_font;
|
||||
const auto fps_string = utils::string::va("%i", fps);
|
||||
const auto x = screen_max[0] - 10.f - game::R_TextWidth(fps_string, 0x7FFFFFFF, font);
|
||||
const auto x = screen_max[0] - 15.f - game::R_TextWidth(fps_string, 0x7FFFFFFF, font);
|
||||
const auto color = fps >= 60 ? fps_color_good : (fps >= 30 ? fps_color_ok : fps_color_bad);
|
||||
|
||||
game::R_AddCmdDrawText(fps_string, 0x7FFFFFFF, font, x, 30.f, 1.0f, 1.0f, 0.0f, color, 1);
|
||||
game::R_AddCmdDrawText(fps_string, 0x7FFFFFFF, font, x, 35.f, 1.0f, 1.0f, 0.0f, color, 1);
|
||||
}
|
||||
|
||||
void draw_pos()
|
||||
|
@ -209,9 +209,9 @@ namespace gsc
|
||||
}
|
||||
}
|
||||
|
||||
void load_scripts(const std::filesystem::path& root_dir)
|
||||
void load_scripts(const std::filesystem::path& root_dir, const std::string& subfolder)
|
||||
{
|
||||
std::filesystem::path script_dir = root_dir / "scripts";
|
||||
std::filesystem::path script_dir = root_dir / subfolder;
|
||||
if (!utils::io::directory_exists(script_dir.generic_string()))
|
||||
{
|
||||
return;
|
||||
@ -248,9 +248,11 @@ namespace gsc
|
||||
}
|
||||
}, true);
|
||||
|
||||
const auto mapname = game::Dvar_FindVar("mapname");
|
||||
for (const auto& path : filesystem::get_search_paths())
|
||||
{
|
||||
load_scripts(path);
|
||||
load_scripts(path, "scripts");
|
||||
load_scripts(path, "scripts/"s + mapname->current.string);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,6 @@
|
||||
#include "language.hpp"
|
||||
#include "config.hpp"
|
||||
|
||||
#include "localized_strings.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/io.hpp>
|
||||
#include <utils/string.hpp>
|
||||
|
@ -1,199 +0,0 @@
|
||||
#include <std_include.hpp>
|
||||
#include "loader/component_loader.hpp"
|
||||
|
||||
#include "localized_strings.hpp"
|
||||
#include "game_console.hpp"
|
||||
#include "filesystem.hpp"
|
||||
#include "console.hpp"
|
||||
|
||||
#include "game/game.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/string.hpp>
|
||||
#include <utils/concurrency.hpp>
|
||||
#include <utils/io.hpp>
|
||||
|
||||
namespace localized_strings
|
||||
{
|
||||
namespace
|
||||
{
|
||||
utils::hook::detour seh_string_ed_get_string_hook;
|
||||
|
||||
struct localize_entry
|
||||
{
|
||||
std::string value{};
|
||||
bool volatile_{};
|
||||
};
|
||||
|
||||
using localized_map = std::unordered_map<std::string, localize_entry>;
|
||||
utils::concurrency::container<localized_map> localized_overrides;
|
||||
|
||||
const char* seh_string_ed_get_string(const char* reference)
|
||||
{
|
||||
return localized_overrides.access<const char*>([&](const localized_map& map)
|
||||
{
|
||||
const auto entry = map.find(reference);
|
||||
if (entry != map.end())
|
||||
{
|
||||
return utils::string::va("%s", entry->second.value.data());
|
||||
}
|
||||
|
||||
return seh_string_ed_get_string_hook.invoke<const char*>(reference);
|
||||
});
|
||||
}
|
||||
|
||||
game::XAssetHeader db_find_localize_entry_stub(game::XAssetType type, const char* name, int allow_create_default)
|
||||
{
|
||||
const auto value = localized_overrides.access<const char*>([&](const localized_map& map)
|
||||
-> const char*
|
||||
{
|
||||
const auto entry = map.find(name);
|
||||
if (entry != map.end())
|
||||
{
|
||||
return utils::string::va("%s", entry->second.value.data());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
});
|
||||
|
||||
if (value == nullptr)
|
||||
{
|
||||
return game::DB_FindXAssetHeader(type, name, allow_create_default);
|
||||
}
|
||||
|
||||
static game::LocalizeEntry entry{};
|
||||
entry.value = value;
|
||||
entry.name = name;
|
||||
|
||||
return static_cast<game::XAssetHeader>(&entry);
|
||||
}
|
||||
|
||||
bool parse_localized_strings_file(const std::string& data)
|
||||
{
|
||||
rapidjson::Document j;
|
||||
j.Parse(data.data());
|
||||
|
||||
if (!j.IsObject())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
localized_overrides.access([&](localized_map& map)
|
||||
{
|
||||
const auto obj = j.GetObj();
|
||||
for (const auto& [key, value] : obj)
|
||||
{
|
||||
if (!key.IsString() || !value.IsString())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto name = key.GetString();
|
||||
const auto str = value.GetString();
|
||||
|
||||
const auto entry = map.find(name);
|
||||
if (entry == map.end() || entry->second.volatile_)
|
||||
{
|
||||
map[name] = {str, true};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool try_load_file(const std::string& path, const std::string& language)
|
||||
{
|
||||
const auto file = utils::string::va("%s/localizedstrings/%s.json", path.data(), language.data());
|
||||
if (!utils::io::file_exists(file))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
console::info("[Localized strings] Parsing %s\n", file);
|
||||
const auto data = utils::io::read_file(file);
|
||||
if (!parse_localized_strings_file(data))
|
||||
{
|
||||
console::error("[Localized strings] Invalid language json file\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void load_localized_strings()
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
const auto search_paths = filesystem::get_search_paths_rev();
|
||||
const auto language = game::SEH_GetCurrentLanguageName();
|
||||
|
||||
for (const auto& path : search_paths)
|
||||
{
|
||||
bool found_in_current_path = false;
|
||||
|
||||
if (try_load_file(path, "english"))
|
||||
{
|
||||
found_in_current_path = true;
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (language != "english"s && !try_load_file(path, language) && found_in_current_path)
|
||||
{
|
||||
console::warn("[Localized strings] No valid language file found for '%s' in '%s/localizedstrings/', falling back to 'english'\n",
|
||||
language, path.data());
|
||||
}
|
||||
else
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
console::warn("[Localized strings] No valid language file found!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void override(const std::string& key, const std::string& value, bool volatile_)
|
||||
{
|
||||
localized_overrides.access([&](localized_map& map)
|
||||
{
|
||||
map[key] = {value, volatile_};
|
||||
});
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
localized_overrides.access([&](localized_map& map)
|
||||
{
|
||||
for (auto i = map.begin(); i != map.end();)
|
||||
{
|
||||
if (i->second.volatile_)
|
||||
{
|
||||
i = map.erase(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
++i;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
load_localized_strings();
|
||||
}
|
||||
|
||||
class component final : public component_interface
|
||||
{
|
||||
public:
|
||||
void post_unpack() override
|
||||
{
|
||||
// Change some localized strings
|
||||
seh_string_ed_get_string_hook.create(0x1405E5FD0, &seh_string_ed_get_string);
|
||||
utils::hook::call(0x1405E5AB9, db_find_localize_entry_stub);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
REGISTER_COMPONENT(localized_strings::component)
|
@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace localized_strings
|
||||
{
|
||||
void override(const std::string& key, const std::string& value, bool volatile_ = false);
|
||||
void clear();
|
||||
}
|
@ -9,7 +9,6 @@
|
||||
#include "filesystem.hpp"
|
||||
#include "fonts.hpp"
|
||||
#include "mods.hpp"
|
||||
#include "localized_strings.hpp"
|
||||
#include "loadscreen.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
@ -25,7 +24,7 @@ namespace mods
|
||||
{
|
||||
struct mod_zone_info
|
||||
{
|
||||
bool has_common_zones;
|
||||
bool has_common_zones{};
|
||||
std::vector<mod_zone> zones;
|
||||
};
|
||||
|
||||
@ -63,8 +62,6 @@ namespace mods
|
||||
loadscreen::clear();
|
||||
}
|
||||
|
||||
localized_strings::clear();
|
||||
|
||||
db_release_xassets_hook.invoke<void>();
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "command.hpp"
|
||||
|
||||
#include "filesystem.hpp"
|
||||
#include "localized_strings.hpp"
|
||||
#include "scripting.hpp"
|
||||
#include "fastfiles.hpp"
|
||||
#include "mods.hpp"
|
||||
@ -320,12 +319,6 @@ namespace ui_scripting
|
||||
return path.value_or("");
|
||||
};
|
||||
|
||||
game_type["addlocalizedstring"] = [](const game&, const std::string& string,
|
||||
const std::string& value)
|
||||
{
|
||||
localized_strings::override(string, value, true);
|
||||
};
|
||||
|
||||
game_type["setlanguage"] = [](const game&, const std::string& language)
|
||||
{
|
||||
language::set(language);
|
||||
@ -361,6 +354,13 @@ namespace ui_scripting
|
||||
ShellExecuteA(nullptr, "open", link->second.data(), nullptr, nullptr, SW_SHOWNORMAL);
|
||||
};
|
||||
|
||||
lua["string"]["escapelocalization"] = [](const std::string& str)
|
||||
{
|
||||
return "\x1F"s.append(str);
|
||||
};
|
||||
|
||||
lua["string"]["el"] = lua["string"]["escapelocalization"];
|
||||
|
||||
lua["Engine"]["SetLanguage"] = [](const int index)
|
||||
{
|
||||
language::set_from_index(index);
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "component/command.hpp"
|
||||
#include "component/fastfiles.hpp"
|
||||
#include "component/mods.hpp"
|
||||
#include "component/localized_strings.hpp"
|
||||
#include "component/scheduler.hpp"
|
||||
#include "component/filesystem.hpp"
|
||||
|
||||
@ -787,12 +786,6 @@ namespace scripting::lua
|
||||
return mod.value_or("");
|
||||
};
|
||||
|
||||
game_type["addlocalizedstring"] = [](const game&, const std::string& string,
|
||||
const std::string& value)
|
||||
{
|
||||
localized_strings::override(string, value, true);
|
||||
};
|
||||
|
||||
game_type["overridedvarint"] = [](const game&, const std::string& dvar, const int value)
|
||||
{
|
||||
scripting::get_dvar_int_overrides[dvar] = value;
|
||||
|
@ -5,341 +5,341 @@
|
||||
|
||||
namespace ui_scripting
|
||||
{
|
||||
/***************************************************************
|
||||
* Lightuserdata
|
||||
**************************************************************/
|
||||
/***************************************************************
|
||||
* Lightuserdata
|
||||
**************************************************************/
|
||||
|
||||
lightuserdata::lightuserdata(void* ptr_)
|
||||
: ptr(ptr_)
|
||||
{
|
||||
}
|
||||
lightuserdata::lightuserdata(void* ptr_)
|
||||
: ptr(ptr_)
|
||||
{
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* Userdata
|
||||
**************************************************************/
|
||||
/***************************************************************
|
||||
* Userdata
|
||||
**************************************************************/
|
||||
|
||||
userdata::userdata(void* ptr_)
|
||||
: ptr(ptr_)
|
||||
{
|
||||
this->add();
|
||||
}
|
||||
userdata::userdata(void* ptr_)
|
||||
: ptr(ptr_)
|
||||
{
|
||||
this->add();
|
||||
}
|
||||
|
||||
userdata::userdata(const userdata& other)
|
||||
{
|
||||
this->operator=(other);
|
||||
}
|
||||
userdata::userdata(const userdata& other)
|
||||
{
|
||||
this->operator=(other);
|
||||
}
|
||||
|
||||
userdata::userdata(userdata&& other) noexcept
|
||||
{
|
||||
this->ptr = other.ptr;
|
||||
this->ref = other.ref;
|
||||
other.ref = 0;
|
||||
}
|
||||
userdata::userdata(userdata&& other) noexcept
|
||||
{
|
||||
this->ptr = other.ptr;
|
||||
this->ref = other.ref;
|
||||
other.ref = 0;
|
||||
}
|
||||
|
||||
userdata::~userdata()
|
||||
{
|
||||
this->release();
|
||||
}
|
||||
userdata::~userdata()
|
||||
{
|
||||
this->release();
|
||||
}
|
||||
|
||||
userdata& userdata::operator=(const userdata& other)
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
this->release();
|
||||
this->ptr = other.ptr;
|
||||
this->ref = other.ref;
|
||||
this->add();
|
||||
}
|
||||
userdata& userdata::operator=(const userdata& other)
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
this->release();
|
||||
this->ptr = other.ptr;
|
||||
this->ref = other.ref;
|
||||
this->add();
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
userdata& userdata::operator=(userdata&& other) noexcept
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
this->release();
|
||||
this->ptr = other.ptr;
|
||||
this->ref = other.ref;
|
||||
other.ref = 0;
|
||||
}
|
||||
userdata& userdata::operator=(userdata&& other) noexcept
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
this->release();
|
||||
this->ptr = other.ptr;
|
||||
this->ref = other.ref;
|
||||
other.ref = 0;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void userdata::add()
|
||||
{
|
||||
game::hks::HksObject value{};
|
||||
value.v.ptr = this->ptr;
|
||||
value.t = game::hks::TUSERDATA;
|
||||
void userdata::add()
|
||||
{
|
||||
game::hks::HksObject value{};
|
||||
value.v.ptr = this->ptr;
|
||||
value.t = game::hks::TUSERDATA;
|
||||
|
||||
const auto state = *game::hks::lua_state;
|
||||
const auto top = state->m_apistack.top;
|
||||
const auto state = *game::hks::lua_state;
|
||||
const auto top = state->m_apistack.top;
|
||||
|
||||
push_value(value);
|
||||
push_value(value);
|
||||
|
||||
this->ref = game::hks::hksi_luaL_ref(*game::hks::lua_state, -10000);
|
||||
state->m_apistack.top = top;
|
||||
}
|
||||
this->ref = game::hks::hksi_luaL_ref(*game::hks::lua_state, -10000);
|
||||
state->m_apistack.top = top;
|
||||
}
|
||||
|
||||
void userdata::release()
|
||||
{
|
||||
if (this->ref)
|
||||
{
|
||||
game::hks::hksi_luaL_unref(*game::hks::lua_state, -10000, this->ref);
|
||||
}
|
||||
}
|
||||
void userdata::release()
|
||||
{
|
||||
if (this->ref)
|
||||
{
|
||||
game::hks::hksi_luaL_unref(*game::hks::lua_state, -10000, this->ref);
|
||||
}
|
||||
}
|
||||
|
||||
void userdata::set(const script_value& key, const script_value& value) const
|
||||
{
|
||||
set_field(*this, key, value);
|
||||
}
|
||||
void userdata::set(const script_value& key, const script_value& value) const
|
||||
{
|
||||
set_field(*this, key, value);
|
||||
}
|
||||
|
||||
script_value userdata::get(const script_value& key) const
|
||||
{
|
||||
return get_field(*this, key);
|
||||
}
|
||||
script_value userdata::get(const script_value& key) const
|
||||
{
|
||||
return get_field(*this, key);
|
||||
}
|
||||
|
||||
userdata_value userdata::operator[](const script_value& key) const
|
||||
{
|
||||
return {*this, key};
|
||||
}
|
||||
userdata_value userdata::operator[](const script_value& key) const
|
||||
{
|
||||
return {*this, key};
|
||||
}
|
||||
|
||||
userdata_value::userdata_value(const userdata& table, const script_value& key)
|
||||
: userdata_(table)
|
||||
, key_(key)
|
||||
{
|
||||
this->value_ = this->userdata_.get(key).get_raw();
|
||||
}
|
||||
userdata_value::userdata_value(const userdata& table, const script_value& key)
|
||||
: userdata_(table)
|
||||
, key_(key)
|
||||
{
|
||||
this->value_ = this->userdata_.get(key).get_raw();
|
||||
}
|
||||
|
||||
void userdata_value::operator=(const script_value& value)
|
||||
{
|
||||
this->userdata_.set(this->key_, value);
|
||||
this->value_ = value.get_raw();
|
||||
}
|
||||
void userdata_value::operator=(const script_value& value)
|
||||
{
|
||||
this->userdata_.set(this->key_, value);
|
||||
this->value_ = value.get_raw();
|
||||
}
|
||||
|
||||
bool userdata_value::operator==(const script_value& value)
|
||||
{
|
||||
return this->userdata_.get(this->key_) == value;
|
||||
}
|
||||
bool userdata_value::operator==(const script_value& value)
|
||||
{
|
||||
return this->userdata_.get(this->key_) == value;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* Table
|
||||
**************************************************************/
|
||||
/***************************************************************
|
||||
* Table
|
||||
**************************************************************/
|
||||
|
||||
table::table()
|
||||
{
|
||||
const auto state = *game::hks::lua_state;
|
||||
this->ptr = game::hks::Hashtable_Create(state, 0, 0);
|
||||
this->add();
|
||||
}
|
||||
table::table()
|
||||
{
|
||||
const auto state = *game::hks::lua_state;
|
||||
this->ptr = game::hks::Hashtable_Create(state, 0, 0);
|
||||
this->add();
|
||||
}
|
||||
|
||||
table::table(game::hks::HashTable* ptr_)
|
||||
: ptr(ptr_)
|
||||
{
|
||||
this->add();
|
||||
}
|
||||
table::table(game::hks::HashTable* ptr_)
|
||||
: ptr(ptr_)
|
||||
{
|
||||
this->add();
|
||||
}
|
||||
|
||||
table::table(const table& other)
|
||||
{
|
||||
this->operator=(other);
|
||||
}
|
||||
table::table(const table& other)
|
||||
{
|
||||
this->operator=(other);
|
||||
}
|
||||
|
||||
table::table(table&& other) noexcept
|
||||
{
|
||||
this->ptr = other.ptr;
|
||||
this->ref = other.ref;
|
||||
other.ref = 0;
|
||||
}
|
||||
table::table(table&& other) noexcept
|
||||
{
|
||||
this->ptr = other.ptr;
|
||||
this->ref = other.ref;
|
||||
other.ref = 0;
|
||||
}
|
||||
|
||||
table::~table()
|
||||
{
|
||||
this->release();
|
||||
}
|
||||
table::~table()
|
||||
{
|
||||
this->release();
|
||||
}
|
||||
|
||||
table& table::operator=(const table& other)
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
this->release();
|
||||
this->ptr = other.ptr;
|
||||
this->ref = other.ref;
|
||||
this->add();
|
||||
}
|
||||
table& table::operator=(const table& other)
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
this->release();
|
||||
this->ptr = other.ptr;
|
||||
this->ref = other.ref;
|
||||
this->add();
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
table& table::operator=(table&& other) noexcept
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
this->release();
|
||||
this->ptr = other.ptr;
|
||||
this->ref = other.ref;
|
||||
other.ref = 0;
|
||||
}
|
||||
table& table::operator=(table&& other) noexcept
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
this->release();
|
||||
this->ptr = other.ptr;
|
||||
this->ref = other.ref;
|
||||
other.ref = 0;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void table::add()
|
||||
{
|
||||
game::hks::HksObject value{};
|
||||
value.v.table = this->ptr;
|
||||
value.t = game::hks::TTABLE;
|
||||
void table::add()
|
||||
{
|
||||
game::hks::HksObject value{};
|
||||
value.v.table = this->ptr;
|
||||
value.t = game::hks::TTABLE;
|
||||
|
||||
const auto state = *game::hks::lua_state;
|
||||
const auto top = state->m_apistack.top;
|
||||
const auto state = *game::hks::lua_state;
|
||||
const auto top = state->m_apistack.top;
|
||||
|
||||
push_value(value);
|
||||
push_value(value);
|
||||
|
||||
this->ref = game::hks::hksi_luaL_ref(*game::hks::lua_state, -10000);
|
||||
state->m_apistack.top = top;
|
||||
}
|
||||
this->ref = game::hks::hksi_luaL_ref(*game::hks::lua_state, -10000);
|
||||
state->m_apistack.top = top;
|
||||
}
|
||||
|
||||
void table::release()
|
||||
{
|
||||
if (this->ref)
|
||||
{
|
||||
game::hks::hksi_luaL_unref(*game::hks::lua_state, -10000, this->ref);
|
||||
}
|
||||
}
|
||||
void table::release()
|
||||
{
|
||||
if (this->ref)
|
||||
{
|
||||
game::hks::hksi_luaL_unref(*game::hks::lua_state, -10000, this->ref);
|
||||
}
|
||||
}
|
||||
|
||||
void table::set(const script_value& key, const script_value& value) const
|
||||
{
|
||||
set_field(*this, key, value);
|
||||
}
|
||||
void table::set(const script_value& key, const script_value& value) const
|
||||
{
|
||||
set_field(*this, key, value);
|
||||
}
|
||||
|
||||
table_value table::operator[](const script_value& key) const
|
||||
{
|
||||
return {*this, key};
|
||||
}
|
||||
table_value table::operator[](const script_value& key) const
|
||||
{
|
||||
return {*this, key};
|
||||
}
|
||||
|
||||
script_value table::get(const script_value& key) const
|
||||
{
|
||||
return get_field(*this, key);
|
||||
}
|
||||
script_value table::get(const script_value& key) const
|
||||
{
|
||||
return get_field(*this, key);
|
||||
}
|
||||
|
||||
table_value::table_value(const table& table, const script_value& key)
|
||||
: table_(table)
|
||||
, key_(key)
|
||||
{
|
||||
this->value_ = this->table_.get(key).get_raw();
|
||||
}
|
||||
table_value::table_value(const table& table, const script_value& key)
|
||||
: table_(table)
|
||||
, key_(key)
|
||||
{
|
||||
this->value_ = this->table_.get(key).get_raw();
|
||||
}
|
||||
|
||||
void table_value::operator=(const script_value& value)
|
||||
{
|
||||
this->table_.set(this->key_, value);
|
||||
this->value_ = value.get_raw();
|
||||
}
|
||||
void table_value::operator=(const script_value& value)
|
||||
{
|
||||
this->table_.set(this->key_, value);
|
||||
this->value_ = value.get_raw();
|
||||
}
|
||||
|
||||
void table_value::operator=(const table_value& value)
|
||||
{
|
||||
this->table_.set(this->key_, value);
|
||||
this->value_ = value.get_raw();
|
||||
}
|
||||
void table_value::operator=(const table_value& value)
|
||||
{
|
||||
this->table_.set(this->key_, value);
|
||||
this->value_ = value.get_raw();
|
||||
}
|
||||
|
||||
bool table_value::operator==(const script_value& value)
|
||||
{
|
||||
return this->table_.get(this->key_) == value;
|
||||
}
|
||||
bool table_value::operator==(const script_value& value)
|
||||
{
|
||||
return this->table_.get(this->key_) == value;
|
||||
}
|
||||
|
||||
bool table_value::operator==(const table_value& value)
|
||||
{
|
||||
return this->table_.get(this->key_) == value;
|
||||
}
|
||||
bool table_value::operator==(const table_value& value)
|
||||
{
|
||||
return this->table_.get(this->key_) == value;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* Function
|
||||
**************************************************************/
|
||||
/***************************************************************
|
||||
* Function
|
||||
**************************************************************/
|
||||
|
||||
function::function(game::hks::lua_function func)
|
||||
{
|
||||
const auto state = *game::hks::lua_state;
|
||||
this->ptr = game::hks::cclosure_Create(state, func, 0, 0, 0);
|
||||
this->type = game::hks::HksObjectType::TCFUNCTION;
|
||||
this->add();
|
||||
}
|
||||
function::function(game::hks::lua_function func)
|
||||
{
|
||||
const auto state = *game::hks::lua_state;
|
||||
this->ptr = game::hks::cclosure_Create(state, func, 0, 0, 0);
|
||||
this->type = game::hks::HksObjectType::TCFUNCTION;
|
||||
this->add();
|
||||
}
|
||||
|
||||
function::function(game::hks::cclosure* ptr_, game::hks::HksObjectType type_)
|
||||
: ptr(ptr_)
|
||||
, type(type_)
|
||||
{
|
||||
this->add();
|
||||
}
|
||||
function::function(game::hks::cclosure* ptr_, game::hks::HksObjectType type_)
|
||||
: ptr(ptr_)
|
||||
, type(type_)
|
||||
{
|
||||
this->add();
|
||||
}
|
||||
|
||||
function::function(const function& other)
|
||||
{
|
||||
this->operator=(other);
|
||||
}
|
||||
function::function(const function& other)
|
||||
{
|
||||
this->operator=(other);
|
||||
}
|
||||
|
||||
function::function(function&& other) noexcept
|
||||
{
|
||||
this->ptr = other.ptr;
|
||||
this->type = other.type;
|
||||
this->ref = other.ref;
|
||||
other.ref = 0;
|
||||
}
|
||||
function::function(function&& other) noexcept
|
||||
{
|
||||
this->ptr = other.ptr;
|
||||
this->type = other.type;
|
||||
this->ref = other.ref;
|
||||
other.ref = 0;
|
||||
}
|
||||
|
||||
function::~function()
|
||||
{
|
||||
this->release();
|
||||
}
|
||||
function::~function()
|
||||
{
|
||||
this->release();
|
||||
}
|
||||
|
||||
function& function::operator=(const function& other)
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
this->release();
|
||||
this->ptr = other.ptr;
|
||||
this->type = other.type;
|
||||
this->ref = other.ref;
|
||||
this->add();
|
||||
}
|
||||
function& function::operator=(const function& other)
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
this->release();
|
||||
this->ptr = other.ptr;
|
||||
this->type = other.type;
|
||||
this->ref = other.ref;
|
||||
this->add();
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
function& function::operator=(function&& other) noexcept
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
this->release();
|
||||
this->ptr = other.ptr;
|
||||
this->type = other.type;
|
||||
this->ref = other.ref;
|
||||
other.ref = 0;
|
||||
}
|
||||
function& function::operator=(function&& other) noexcept
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
this->release();
|
||||
this->ptr = other.ptr;
|
||||
this->type = other.type;
|
||||
this->ref = other.ref;
|
||||
other.ref = 0;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void function::add()
|
||||
{
|
||||
game::hks::HksObject value{};
|
||||
value.v.cClosure = this->ptr;
|
||||
value.t = this->type;
|
||||
void function::add()
|
||||
{
|
||||
game::hks::HksObject value{};
|
||||
value.v.cClosure = this->ptr;
|
||||
value.t = this->type;
|
||||
|
||||
const auto state = *game::hks::lua_state;
|
||||
const auto top = state->m_apistack.top;
|
||||
const auto state = *game::hks::lua_state;
|
||||
const auto top = state->m_apistack.top;
|
||||
|
||||
push_value(value);
|
||||
push_value(value);
|
||||
|
||||
this->ref = game::hks::hksi_luaL_ref(*game::hks::lua_state, -10000);
|
||||
state->m_apistack.top = top;
|
||||
}
|
||||
this->ref = game::hks::hksi_luaL_ref(*game::hks::lua_state, -10000);
|
||||
state->m_apistack.top = top;
|
||||
}
|
||||
|
||||
void function::release()
|
||||
{
|
||||
if (this->ref)
|
||||
{
|
||||
game::hks::hksi_luaL_unref(*game::hks::lua_state, -10000, this->ref);
|
||||
}
|
||||
}
|
||||
void function::release()
|
||||
{
|
||||
if (this->ref)
|
||||
{
|
||||
game::hks::hksi_luaL_unref(*game::hks::lua_state, -10000, this->ref);
|
||||
}
|
||||
}
|
||||
|
||||
arguments function::call(const arguments& arguments) const
|
||||
{
|
||||
return call_script_function(*this, arguments);
|
||||
}
|
||||
arguments function::call(const arguments& arguments) const
|
||||
{
|
||||
return call_script_function(*this, arguments);
|
||||
}
|
||||
}
|
||||
|
@ -5,132 +5,132 @@
|
||||
|
||||
namespace ui_scripting
|
||||
{
|
||||
class lightuserdata
|
||||
{
|
||||
public:
|
||||
lightuserdata(void*);
|
||||
void* ptr;
|
||||
};
|
||||
class lightuserdata
|
||||
{
|
||||
public:
|
||||
lightuserdata(void*);
|
||||
void* ptr;
|
||||
};
|
||||
|
||||
class userdata_value;
|
||||
class userdata_value;
|
||||
|
||||
class userdata
|
||||
{
|
||||
public:
|
||||
userdata(void*);
|
||||
class userdata
|
||||
{
|
||||
public:
|
||||
userdata(void*);
|
||||
|
||||
userdata(const userdata& other);
|
||||
userdata(userdata&& other) noexcept;
|
||||
userdata(const userdata& other);
|
||||
userdata(userdata&& other) noexcept;
|
||||
|
||||
~userdata();
|
||||
~userdata();
|
||||
|
||||
userdata& operator=(const userdata& other);
|
||||
userdata& operator=(userdata&& other) noexcept;
|
||||
userdata& operator=(const userdata& other);
|
||||
userdata& operator=(userdata&& other) noexcept;
|
||||
|
||||
script_value get(const script_value& key) const;
|
||||
void set(const script_value& key, const script_value& value) const;
|
||||
script_value get(const script_value& key) const;
|
||||
void set(const script_value& key, const script_value& value) const;
|
||||
|
||||
userdata_value operator[](const script_value& key) const;
|
||||
userdata_value operator[](const script_value& key) const;
|
||||
|
||||
void* ptr;
|
||||
void* ptr;
|
||||
|
||||
private:
|
||||
void add();
|
||||
void release();
|
||||
private:
|
||||
void add();
|
||||
void release();
|
||||
|
||||
int ref{};
|
||||
};
|
||||
int ref{};
|
||||
};
|
||||
|
||||
class userdata_value : public script_value
|
||||
{
|
||||
public:
|
||||
userdata_value(const userdata& table, const script_value& key);
|
||||
void operator=(const script_value& value);
|
||||
bool operator==(const script_value& value);
|
||||
private:
|
||||
userdata userdata_;
|
||||
script_value key_;
|
||||
};
|
||||
class userdata_value : public script_value
|
||||
{
|
||||
public:
|
||||
userdata_value(const userdata& table, const script_value& key);
|
||||
void operator=(const script_value& value);
|
||||
bool operator==(const script_value& value);
|
||||
private:
|
||||
userdata userdata_;
|
||||
script_value key_;
|
||||
};
|
||||
|
||||
class table_value;
|
||||
class table_value;
|
||||
|
||||
class table
|
||||
{
|
||||
public:
|
||||
table();
|
||||
table(game::hks::HashTable* ptr_);
|
||||
class table
|
||||
{
|
||||
public:
|
||||
table();
|
||||
table(game::hks::HashTable* ptr_);
|
||||
|
||||
table(const table& other);
|
||||
table(table&& other) noexcept;
|
||||
table(const table& other);
|
||||
table(table&& other) noexcept;
|
||||
|
||||
~table();
|
||||
~table();
|
||||
|
||||
table& operator=(const table& other);
|
||||
table& operator=(table&& other) noexcept;
|
||||
table& operator=(const table& other);
|
||||
table& operator=(table&& other) noexcept;
|
||||
|
||||
script_value get(const script_value& key) const;
|
||||
void set(const script_value& key, const script_value& value) const;
|
||||
script_value get(const script_value& key) const;
|
||||
void set(const script_value& key, const script_value& value) const;
|
||||
|
||||
table_value operator[](const script_value& key) const;
|
||||
table_value operator[](const script_value& key) const;
|
||||
|
||||
game::hks::HashTable* ptr;
|
||||
game::hks::HashTable* ptr;
|
||||
|
||||
private:
|
||||
void add();
|
||||
void release();
|
||||
private:
|
||||
void add();
|
||||
void release();
|
||||
|
||||
int ref{};
|
||||
};
|
||||
int ref{};
|
||||
};
|
||||
|
||||
class table_value : public script_value
|
||||
{
|
||||
public:
|
||||
table_value(const table& table, const script_value& key);
|
||||
void operator=(const script_value& value);
|
||||
void operator=(const table_value& value);
|
||||
bool operator==(const script_value& value);
|
||||
bool operator==(const table_value& value);
|
||||
private:
|
||||
table table_;
|
||||
script_value key_;
|
||||
};
|
||||
class table_value : public script_value
|
||||
{
|
||||
public:
|
||||
table_value(const table& table, const script_value& key);
|
||||
void operator=(const script_value& value);
|
||||
void operator=(const table_value& value);
|
||||
bool operator==(const script_value& value);
|
||||
bool operator==(const table_value& value);
|
||||
private:
|
||||
table table_;
|
||||
script_value key_;
|
||||
};
|
||||
|
||||
class function
|
||||
{
|
||||
public:
|
||||
function(game::hks::lua_function);
|
||||
function(game::hks::cclosure*, game::hks::HksObjectType);
|
||||
class function
|
||||
{
|
||||
public:
|
||||
function(game::hks::lua_function);
|
||||
function(game::hks::cclosure*, game::hks::HksObjectType);
|
||||
|
||||
template <typename F>
|
||||
function(F f)
|
||||
{
|
||||
this->ptr = ui_scripting::convert_function(f);
|
||||
this->type = game::hks::TCFUNCTION;
|
||||
}
|
||||
template <typename F>
|
||||
function(F f)
|
||||
{
|
||||
this->ptr = ui_scripting::convert_function(f);
|
||||
this->type = game::hks::TCFUNCTION;
|
||||
}
|
||||
|
||||
function(const function& other);
|
||||
function(function&& other) noexcept;
|
||||
function(const function& other);
|
||||
function(function&& other) noexcept;
|
||||
|
||||
~function();
|
||||
~function();
|
||||
|
||||
function& operator=(const function& other);
|
||||
function& operator=(function&& other) noexcept;
|
||||
function& operator=(const function& other);
|
||||
function& operator=(function&& other) noexcept;
|
||||
|
||||
arguments call(const arguments& arguments) const;
|
||||
arguments call(const arguments& arguments) const;
|
||||
|
||||
template<class ...T>
|
||||
arguments operator()(T... arguments) const
|
||||
{
|
||||
return this->call({arguments...});
|
||||
}
|
||||
template<class ...T>
|
||||
arguments operator()(T... arguments) const
|
||||
{
|
||||
return this->call({arguments...});
|
||||
}
|
||||
|
||||
game::hks::cclosure* ptr;
|
||||
game::hks::HksObjectType type;
|
||||
game::hks::cclosure* ptr;
|
||||
game::hks::HksObjectType type;
|
||||
|
||||
private:
|
||||
void add();
|
||||
void release();
|
||||
private:
|
||||
void add();
|
||||
void release();
|
||||
|
||||
int ref{};
|
||||
};
|
||||
int ref{};
|
||||
};
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ namespace utils::nt
|
||||
ZeroMemory(&process_info, sizeof(process_info));
|
||||
startup_info.cb = sizeof(startup_info);
|
||||
|
||||
char current_dir[MAX_PATH];
|
||||
char current_dir[MAX_PATH]{};
|
||||
GetCurrentDirectoryA(sizeof(current_dir), current_dir);
|
||||
|
||||
std::string command_line = GetCommandLineA();
|
||||
@ -253,8 +253,8 @@ namespace utils::nt
|
||||
}
|
||||
}
|
||||
|
||||
CreateProcessA(self.get_path().data(), command_line.data(), nullptr, nullptr, false, NULL, nullptr, current_dir,
|
||||
&startup_info, &process_info);
|
||||
CreateProcessA(self.get_path().data(), command_line.data(), nullptr, nullptr, false,
|
||||
CREATE_NEW_CONSOLE, nullptr, current_dir, &startup_info, &process_info);
|
||||
|
||||
if (process_info.hThread && process_info.hThread != INVALID_HANDLE_VALUE) CloseHandle(process_info.hThread);
|
||||
if (process_info.hProcess && process_info.hProcess != INVALID_HANDLE_VALUE) CloseHandle(process_info.hProcess);
|
||||
|
Loading…
x
Reference in New Issue
Block a user