diff --git a/data/ui_scripts/hud_info/__init__.lua b/data/ui_scripts/hud_info/__init__.lua index 8144b79..07dfbdd 100644 --- a/data/ui_scripts/hud_info/__init__.lua +++ b/data/ui_scripts/hud_info/__init__.lua @@ -2,5 +2,5 @@ if (game:issingleplayer()) then return end -include("settings") -include("hud") \ No newline at end of file +require("settings") +require("hud") \ No newline at end of file diff --git a/data/ui_scripts/hud_info/hud.lua b/data/ui_scripts/hud_info/hud.lua index f6a3bb0..405ebab 100644 --- a/data/ui_scripts/hud_info/hud.lua +++ b/data/ui_scripts/hud_info/hud.lua @@ -1,4 +1,4 @@ -local mphud = luiglobals.require("LUI.mp_hud.MPHud") +local mphud = require("LUI.mp_hud.MPHud") local barheight = 18 local textheight = 13 local textoffsety = barheight / 2 - textheight / 2 @@ -71,10 +71,10 @@ function infoelement(data) g = 0.3, b = 0.3, }, - material = luiglobals.RegisterMaterial("distort_hud_bkgnd_ui_blur") + material = RegisterMaterial("distort_hud_bkgnd_ui_blur") }) - local labelfont = luiglobals.RegisterFont("fonts/bodyFontBold", textheight) + local labelfont = RegisterFont("fonts/bodyFontBold", textheight) local label = LUI.UIText.new({ left = 5, @@ -92,11 +92,11 @@ function infoelement(data) label:setText(data.label) - local _, _, left = luiglobals.GetTextDimensions(data.label, labelfont, textheight) + local _, _, left = GetTextDimensions(data.label, labelfont, textheight) local value = LUI.UIText.new({ left = left + 5, top = textoffsety, - font = luiglobals.RegisterFont("fonts/bodyFont", textheight), + font = RegisterFont("fonts/bodyFont", textheight), height = textheight + 1, leftAnchor = true, topAnchor = true, @@ -160,4 +160,4 @@ LUI.MenuBuilder.m_types_build["mp_hud"] = function() hud.static:addElement(infobar) return hud -end \ No newline at end of file +end diff --git a/data/ui_scripts/hud_info/settings.lua b/data/ui_scripts/hud_info/settings.lua index 7a8e5e7..e439a14 100644 --- a/data/ui_scripts/hud_info/settings.lua +++ b/data/ui_scripts/hud_info/settings.lua @@ -1,4 +1,4 @@ -local pcoptions = luiglobals.require("LUI.PCOptions") +local pcoptions = require("LUI.PCOptions") game:addlocalizedstring("LUA_MENU_FPS", "FPS Counter") game:addlocalizedstring("LUA_MENU_FPS_DESC", "Show FPS Counter") @@ -33,9 +33,9 @@ pcoptions.VideoOptionsFeeder = function() "profileMenuOption_blacklevel", "@MENU_BRIGHTNESS", "@MENU_BRIGHTNESS_DESC1", - luiglobals.SliderBounds.PCBrightness.Min, - luiglobals.SliderBounds.PCBrightness.Max, - luiglobals.SliderBounds.PCBrightness.Step, + SliderBounds.PCBrightness.Min, + SliderBounds.PCBrightness.Max, + SliderBounds.PCBrightness.Step, function(element) element:processEvent({ name = "brightness_over", @@ -143,7 +143,7 @@ pcoptions.VideoOptionsFeeder = function() type = "UIGenericButton", id = "option_advanced_video", properties = { - style = luiglobals.GenericButtonSettings.Styles.GlassButton, + style = GenericButtonSettings.Styles.GlassButton, button_text = Engine.Localize("@LUA_MENU_ADVANCED_VIDEO"), desc_text = "", button_action_func = pcoptions.ButtonMenuAction, diff --git a/data/ui_scripts/scoreboard/__init__.lua b/data/ui_scripts/scoreboard/__init__.lua index 47d327f..a72cfce 100644 --- a/data/ui_scripts/scoreboard/__init__.lua +++ b/data/ui_scripts/scoreboard/__init__.lua @@ -2,13 +2,13 @@ if (game:issingleplayer() or Engine.InFrontend()) then return end -function luiglobals.GetPartyMaxPlayers() +function GetPartyMaxPlayers() return Engine.GetDvarInt("sv_maxclients") end local scoreboard = LUI.mp_hud.Scoreboard -scoreboard.maxPlayersOnTeam = luiglobals.GetTeamLimitForMaxPlayers(luiglobals.GetPartyMaxPlayers()) +scoreboard.maxPlayersOnTeam = GetTeamLimitForMaxPlayers(GetPartyMaxPlayers()) scoreboard.scoreColumns.ping = { width = Engine.IsZombiesMode() and 90 or 60, @@ -23,7 +23,7 @@ scoreboard.getColumnsForCurrentGameMode = function(a1) local columns = getcolumns(a1) if (Engine.IsZombiesMode()) then - luiglobals.table.insert(columns, scoreboard.scoreColumns.ping) + table.insert(columns, scoreboard.scoreColumns.ping) end return columns diff --git a/data/ui_scripts/server_list/__init__.lua b/data/ui_scripts/server_list/__init__.lua index dd59efe..0952091 100644 --- a/data/ui_scripts/server_list/__init__.lua +++ b/data/ui_scripts/server_list/__init__.lua @@ -1,6 +1,6 @@ -if (not LUI.mp_menus) then +if (game:issingleplayer() or not Engine.InFrontend()) then return end -include("lobby") -include("serverlist") +require("lobby") +require("serverlist") diff --git a/data/ui_scripts/server_list/lobby.lua b/data/ui_scripts/server_list/lobby.lua index aedebb4..596f8a5 100644 --- a/data/ui_scripts/server_list/lobby.lua +++ b/data/ui_scripts/server_list/lobby.lua @@ -1,4 +1,4 @@ -local Lobby = luiglobals.Lobby +local Lobby = Lobby local MPLobbyOnline = LUI.mp_menus.MPLobbyOnline local MenuData = LUI.mp_menus.MenuData @@ -6,79 +6,79 @@ game:addlocalizedstring("LUA_MENU_SERVERLIST", "Server List") game:addlocalizedstring("LUA_MENU_SERVERLIST_DESC", "Browse available servers."); function LeaveLobby(a1) - LUI.MarketingPanel.ClearViewedMessages({LUI.MarketingLocation.CaC, LUI.MarketingLocation.PlayOnline, - LUI.MarketingLocation.CaO}) - LeaveXboxLive() - LUI.FlowManager.RequestLeaveMenuByName("menu_xboxlive", nil, true) + LUI.MarketingPanel.ClearViewedMessages({LUI.MarketingLocation.CaC, LUI.MarketingLocation.PlayOnline, + LUI.MarketingLocation.CaO}) + LeaveXboxLive() + LUI.FlowManager.RequestLeaveMenuByName("menu_xboxlive", nil, true) end function menu_xboxlive(a1, a2) - Engine.SetDvarBool("ui_opensummary", false) - local menu = LUI.MPLobbyBase.new(a1, { - menu_title = "@PLATFORM_UI_HEADER_PLAY_MP_CAPS", - memberListState = Lobby.MemberListStates.Prelobby, - has_new_item_usage_widget = true - }) + Engine.SetDvarBool("ui_opensummary", false) + local menu = LUI.MPLobbyBase.new(a1, { + menu_title = "@PLATFORM_UI_HEADER_PLAY_MP_CAPS", + memberListState = Lobby.MemberListStates.Prelobby, + has_new_item_usage_widget = true + }) - menu:setClass(LUI.MPLobbyOnline) + menu:setClass(LUI.MPLobbyOnline) - menu.handleGamepadButton = MPLobbyOnline.menu_xboxlive_handleGamepadButton - if Engine.IsCoreMode() then - menu:AddNewItemsWidget() - end + menu.handleGamepadButton = MPLobbyOnline.menu_xboxlive_handleGamepadButton + if Engine.IsCoreMode() then + menu:AddNewItemsWidget() + end - local serverListButton = menu:AddButton("@LUA_MENU_SERVERLIST", function(a1, a2) - LUI.FlowManager.RequestAddMenu(a1, "menu_systemlink_join", true, nil) - end) - serverListButton:setDisabledRefreshRate(500) - if Engine.IsCoreMode() then - menu:AddCACButton() - menu:AddCAOButton() - menu:AddArmoryButton() - end + local serverListButton = menu:AddButton("@LUA_MENU_SERVERLIST", function(a1, a2) + LUI.FlowManager.RequestAddMenu(a1, "menu_systemlink_join", true, nil) + end) + serverListButton:setDisabledRefreshRate(500) + if Engine.IsCoreMode() then + menu:AddCACButton() + menu:AddCAOButton() + menu:AddArmoryButton() + end - serverListButton = menu:AddButton("@MENU_PRIVATE_MATCH", MPLobbyOnline.OnPrivateMatch, - MPLobbyOnline.disablePrivateMatchButton) - serverListButton:rename("menu_xboxlive_private_match") - serverListButton:setDisabledRefreshRate(500) - if not Engine.IsCoreMode() then - local leaderboardButton = menu:AddButton("@LUA_MENU_LEADERBOARD", "OpLeaderboardMain") - leaderboardButton:rename("OperatorMenu_leaderboard") - end + serverListButton = menu:AddButton("@MENU_PRIVATE_MATCH", MPLobbyOnline.OnPrivateMatch, + MPLobbyOnline.disablePrivateMatchButton) + serverListButton:rename("menu_xboxlive_private_match") + serverListButton:setDisabledRefreshRate(500) + if not Engine.IsCoreMode() then + local leaderboardButton = menu:AddButton("@LUA_MENU_LEADERBOARD", "OpLeaderboardMain") + leaderboardButton:rename("OperatorMenu_leaderboard") + end - if Engine.IsZombiesMode() then - menu:AddButton("@ZOMBIES_MENU_MOVIES", "ZombiesMoviesMenu") - end + if Engine.IsZombiesMode() then + menu:AddButton("@ZOMBIES_MENU_MOVIES", "ZombiesMoviesMenu") + end - menu:AddOptionsButton() - local natType = Lobby.GetNATType() - if natType then - menu:AddHelp({ - name = "add_button_helper_text", - button_ref = "nat", - helper_text = Engine.Localize("NETWORK_YOURNATTYPE", natType), - side = "left", - clickable = false - }) - end - if Engine.IsZombiesMode() then - menu:AddZombiesStats(true) - end + menu:AddOptionsButton() + local natType = Lobby.GetNATType() + if natType then + menu:AddHelp({ + name = "add_button_helper_text", + button_ref = "nat", + helper_text = Engine.Localize("NETWORK_YOURNATTYPE", natType), + side = "left", + clickable = false + }) + end + if Engine.IsZombiesMode() then + menu:AddZombiesStats(true) + end - menu.isSignInMenu = true - menu:registerEventHandler("gain_focus", LUI.MPLobbyOnline.OnGainFocus) - menu:registerEventHandler("player_joined", luiglobals.Cac.PlayerJoinedEvent) - menu:registerEventHandler("exit_live_lobby", LeaveLobby) + menu.isSignInMenu = true + menu:registerEventHandler("gain_focus", LUI.MPLobbyOnline.OnGainFocus) + menu:registerEventHandler("player_joined", Cac.PlayerJoinedEvent) + menu:registerEventHandler("exit_live_lobby", LeaveLobby) - if luiglobals.PersistentBackground.IsCurrent(luiglobals.PersistentBackground.Variants.AARBackground) then - luiglobals.PersistentBackground.Hide(luiglobals.PersistentBackground.Duration) - end + if PersistentBackground.IsCurrent(PersistentBackground.Variants.AARBackground) then + PersistentBackground.Hide(PersistentBackground.Duration) + end - if Engine.IsCoreMode() then - Engine.ExecNow("eliteclan_refresh", Engine.GetFirstActiveController()) - end + if Engine.IsCoreMode() then + Engine.ExecNow("eliteclan_refresh", Engine.GetFirstActiveController()) + end - return menu + return menu end LUI.MenuBuilder.m_types_build["menu_xboxlive"] = menu_xboxlive diff --git a/data/ui_scripts/server_list/serverlist.lua b/data/ui_scripts/server_list/serverlist.lua index bd3c51e..29eb4d7 100644 --- a/data/ui_scripts/server_list/serverlist.lua +++ b/data/ui_scripts/server_list/serverlist.lua @@ -1,10 +1,9 @@ -local Lobby = luiglobals.Lobby -local SystemLinkJoinMenu = LUI.mp_menus.SystemLinkJoinMenu - -if (not SystemLinkJoinMenu) then +if (game:issingleplayer() or not Engine.InFrontend()) then return end +local SystemLinkJoinMenu = LUI.mp_menus.SystemLinkJoinMenu + game:addlocalizedstring("PLATFORM_SYSTEM_LINK_TITLE", "SERVER LIST") game:addlocalizedstring("MENU_NUMPLAYERS", "Players") game:addlocalizedstring("MENU_PING", "Ping") diff --git a/data/ui_scripts/stats/__init__.lua b/data/ui_scripts/stats/__init__.lua index 9593b92..6bcbb01 100644 --- a/data/ui_scripts/stats/__init__.lua +++ b/data/ui_scripts/stats/__init__.lua @@ -1,5 +1,5 @@ if (game:issingleplayer() or not Engine.InFrontend()) then - return + return end game:addlocalizedstring("LUA_MENU_STATS", "Stats") @@ -7,11 +7,11 @@ game:addlocalizedstring("LUA_MENU_STATS_DESC", "Edit player stats settings.") game:addlocalizedstring("LUA_MENU_UNLOCKALL_ITEMS", "Unlock All Items") game:addlocalizedstring("LUA_MENU_UNLOCKALL_ITEMS_DESC", - "Whether items should be locked based on the player's stats or always unlocked.") + "Whether items should be locked based on the player's stats or always unlocked.") game:addlocalizedstring("LUA_MENU_UNLOCKALL_CLASSES", "Unlock All Classes") game:addlocalizedstring("LUA_MENU_UNLOCKALL_CLASSES_DESC", - "Whether classes should be locked based on the player's stats or always unlocked.") + "Whether classes should be locked based on the player's stats or always unlocked.") game:addlocalizedstring("LUA_MENU_PRESTIGE", "Prestige") game:addlocalizedstring("LUA_MENU_PRESTIGE_DESC", "Edit prestige level.") @@ -20,176 +20,176 @@ game:addlocalizedstring("LUA_MENU_RANK_DESC", "Edit rank.") local armorybutton = LUI.MPLobbyBase.AddArmoryButton LUI.MPLobbyBase.AddArmoryButton = function(menu) - armorybutton(menu) - menu:AddButton("@LUA_MENU_STATS", function(a1, a2) - LUI.FlowManager.RequestAddMenu(a1, "menu_stats", true, nil) - end) + armorybutton(menu) + menu:AddButton("@LUA_MENU_STATS", function(a1, a2) + LUI.FlowManager.RequestAddMenu(a1, "menu_stats", true, nil) + end) end -- button stuff for configuring function IsEnabled(dvar) - local enabled = Engine.GetDvarBool(dvar) - if enabled then - return Engine.Localize("@LUA_MENU_ENABLED") - end + local enabled = Engine.GetDvarBool(dvar) + if enabled then + return Engine.Localize("@LUA_MENU_ENABLED") + end - return Engine.Localize("@LUA_MENU_DISABLED") + return Engine.Localize("@LUA_MENU_DISABLED") end function ToggleEnable(dvar) - local enabled = Engine.GetDvarBool(dvar) - if enabled then - Engine.SetDvarBool(dvar, false) - else - Engine.SetDvarBool(dvar, true) - end + local enabled = Engine.GetDvarBool(dvar) + if enabled then + Engine.SetDvarBool(dvar, false) + else + Engine.SetDvarBool(dvar, true) + end end function GoDirection(dvar, direction, callback) - local value = Engine.GetDvarString(dvar) - value = tonumber(value) + local value = Engine.GetDvarString(dvar) + value = tonumber(value) - -- get rank data - local max = nil - if (dvar == "ui_rank_level_") then - max = luiglobals.Rank.GetMaxRank(CoD.PlayMode.Core) - elseif (dvar == "ui_prestige_level") then - max = luiglobals.Lobby.GetMaxPrestigeLevel() - end + -- get rank data + local max = nil + if (dvar == "ui_rank_level_") then + max = Rank.GetMaxRank(CoD.PlayMode.Core) + elseif (dvar == "ui_prestige_level") then + max = Lobby.GetMaxPrestigeLevel() + end - local new_value = nil - if (direction == "down") then - new_value = value - 1 - elseif (direction == "up") then - new_value = value + 1 - end + local new_value = nil + if (direction == "down") then + new_value = value - 1 + elseif (direction == "up") then + new_value = value + 1 + end - -- checking to make sure its < 0 or > max - if (new_value < 0) then - new_value = max - elseif (new_value > max) then - new_value = 0 - end + -- checking to make sure its < 0 or > max + if (new_value < 0) then + new_value = max + elseif (new_value > max) then + new_value = 0 + end - callback(new_value) + callback(new_value) - Engine.SetDvarFromString(dvar, new_value .. "") + Engine.SetDvarFromString(dvar, new_value .. "") end LUI.MenuBuilder.registerType("menu_stats", function(a1, a2) - local menu = LUI.MenuTemplate.new(a1, { - menu_title = Engine.ToUpperCase(Engine.Localize("@LUA_MENU_STATS")), - menu_width = luiglobals.GenericMenuDims.menu_right_wide - luiglobals.GenericMenuDims.menu_left, - menu_height = 548 - }) + local menu = LUI.MenuTemplate.new(a1, { + menu_title = Engine.ToUpperCase(Engine.Localize("@LUA_MENU_STATS")), + menu_width = GenericMenuDims.menu_right_wide - GenericMenuDims.menu_left, + menu_height = 548 + }) - menu:setClass(LUI.Options) - menu.controller = a2.exclusiveController + menu:setClass(LUI.Options) + menu.controller = a2.exclusiveController - local itemsbutton = menu:AddButtonVariant(luiglobals.GenericButtonSettings.Variants.Select, - "@LUA_MENU_UNLOCKALL_ITEMS", "@LUA_MENU_UNLOCKALL_ITEMS_DESC", function() - return IsEnabled("cg_unlockall_items") - end, function() - ToggleEnable("cg_unlockall_items") - end, function() - ToggleEnable("cg_unlockall_items") - end) + local itemsbutton = menu:AddButtonVariant(GenericButtonSettings.Variants.Select, + "@LUA_MENU_UNLOCKALL_ITEMS", "@LUA_MENU_UNLOCKALL_ITEMS_DESC", function() + return IsEnabled("cg_unlockall_items") + end, function() + ToggleEnable("cg_unlockall_items") + end, function() + ToggleEnable("cg_unlockall_items") + end) - local classesbutton = menu:AddButtonVariant(luiglobals.GenericButtonSettings.Variants.Select, - "@LUA_MENU_UNLOCKALL_CLASSES", "@LUA_MENU_UNLOCKALL_CLASSES_DESC", function() - return IsEnabled("cg_unlockall_classes") - end, function() - ToggleEnable("cg_unlockall_classes") - end, function() - ToggleEnable("cg_unlockall_classes") - end) + local classesbutton = menu:AddButtonVariant(GenericButtonSettings.Variants.Select, + "@LUA_MENU_UNLOCKALL_CLASSES", "@LUA_MENU_UNLOCKALL_CLASSES_DESC", function() + return IsEnabled("cg_unlockall_classes") + end, function() + ToggleEnable("cg_unlockall_classes") + end, function() + ToggleEnable("cg_unlockall_classes") + end) - local prestige = Engine.GetPlayerDataEx(0, CoD.StatsGroup.Ranked, "prestige") or 0 - local experience = Engine.GetPlayerDataEx(0, CoD.StatsGroup.Ranked, "experience") or 0 - local rank = luiglobals.AAR.GetRankForXP(experience, prestige) + local prestige = Engine.GetPlayerDataEx(0, CoD.StatsGroup.Ranked, "prestige") or 0 + local experience = Engine.GetPlayerDataEx(0, CoD.StatsGroup.Ranked, "experience") or 0 + local rank = AAR.GetRankForXP(experience, prestige) - local prestigevalue = prestige - local rankvalue = rank + local prestigevalue = prestige + local rankvalue = rank - -- save changes made - local save_changes = function() - Engine.SetPlayerDataEx(0, CoD.StatsGroup.Ranked, "prestige", tonumber(prestigevalue)) + -- save changes made + local save_changes = function() + Engine.SetPlayerDataEx(0, CoD.StatsGroup.Ranked, "prestige", tonumber(prestigevalue)) - local rank = tonumber(rankvalue) - local prestige = Engine.GetPlayerDataEx(0, CoD.StatsGroup.Ranked, "prestige") or 0 - local experience = rank == 0 and 0 or luiglobals.Rank.GetRankMaxXP(tonumber(rankvalue) - 1, prestige) + local rank = tonumber(rankvalue) + local prestige = Engine.GetPlayerDataEx(0, CoD.StatsGroup.Ranked, "prestige") or 0 + local experience = rank == 0 and 0 or Rank.GetRankMaxXP(tonumber(rankvalue) - 1, prestige) - Engine.SetPlayerDataEx(0, CoD.StatsGroup.Ranked, "experience", experience) - end + Engine.SetPlayerDataEx(0, CoD.StatsGroup.Ranked, "experience", experience) + end - -- back callback - local back = function() - save_changes() - LUI.common_menus.Options.HideOptionsBackground() - LUI.FlowManager.RequestLeaveMenu(menu) - end + -- back callback + local back = function() + save_changes() + LUI.common_menus.Options.HideOptionsBackground() + LUI.FlowManager.RequestLeaveMenu(menu) + end - -- create buttons and create callbacks - CreateEditButton(menu, "ui_prestige_level", "@LUA_MENU_PRESTIGE", "@LUA_MENU_PRESTIGE_DESC", function(value) - prestigevalue = value - end) - CreateEditButton(menu, "ui_rank_level_", "@LUA_MENU_RANK", "@LUA_MENU_RANK_DESC", function(value) - rankvalue = value - end) + -- create buttons and create callbacks + CreateEditButton(menu, "ui_prestige_level", "@LUA_MENU_PRESTIGE", "@LUA_MENU_PRESTIGE_DESC", function(value) + prestigevalue = value + end) + CreateEditButton(menu, "ui_rank_level_", "@LUA_MENU_RANK", "@LUA_MENU_RANK_DESC", function(value) + rankvalue = value + end) - menu:AddBottomDescription(menu:InitScrolling()) - menu:AddBackButton(back) + menu:AddBottomDescription(menu:InitScrolling()) + menu:AddBackButton(back) - LUI.common_menus.Options.ShowOptionsBackground() + LUI.common_menus.Options.ShowOptionsBackground() - return menu + return menu end) function CreateEditButton(menu, dvar, name, desc, callback) - local prestige = Engine.GetPlayerDataEx(0, CoD.StatsGroup.Ranked, "prestige") or 0 - local experience = Engine.GetPlayerDataEx(0, CoD.StatsGroup.Ranked, "experience") or 0 + local prestige = Engine.GetPlayerDataEx(0, CoD.StatsGroup.Ranked, "prestige") or 0 + local experience = Engine.GetPlayerDataEx(0, CoD.StatsGroup.Ranked, "experience") or 0 - local dvarValue = nil - local max = nil - if (dvar == "ui_rank_level_") then - dvarValue = luiglobals.AAR.GetRankForXP(experience, prestige) - max = luiglobals.Rank.GetMaxRank(CoD.PlayMode.Core) - elseif (dvar == "ui_prestige_level") then - dvarValue = prestige - max = luiglobals.Lobby.GetMaxPrestigeLevel() - end + local dvarValue = nil + local max = nil + if (dvar == "ui_rank_level_") then + dvarValue = AAR.GetRankForXP(experience, prestige) + max = Rank.GetMaxRank(CoD.PlayMode.Core) + elseif (dvar == "ui_prestige_level") then + dvarValue = prestige + max = Lobby.GetMaxPrestigeLevel() + end - Engine.SetDvarFromString(dvar, dvarValue .. "") + Engine.SetDvarFromString(dvar, dvarValue .. "") - menu:AddButtonVariant(luiglobals.GenericButtonSettings.Variants.Select, name, desc, function() - local dvarString = Engine.GetDvarString(dvar) + menu:AddButtonVariant(GenericButtonSettings.Variants.Select, name, desc, function() + local dvarString = Engine.GetDvarString(dvar) - if (dvar == "ui_rank_level_") then - dvarString = tonumber(dvarString) + 1 - end + if (dvar == "ui_rank_level_") then + dvarString = tonumber(dvarString) + 1 + end - return tostring(dvarString) - end, function() - GoDirection(dvar, "down", callback) - end, function() - GoDirection(dvar, "up", callback) - end) + return tostring(dvarString) + end, function() + GoDirection(dvar, "down", callback) + end, function() + GoDirection(dvar, "up", callback) + end) end -local isclasslocked = luiglobals.Cac.IsCustomClassLocked -luiglobals.Cac.IsCustomClassLocked = function(...) - if (Engine.GetDvarBool("cg_unlockall_classes")) then - return false - end +local isclasslocked = Cac.IsCustomClassLocked +Cac.IsCustomClassLocked = function(...) + if (Engine.GetDvarBool("cg_unlockall_classes")) then + return false + end - return isclasslocked(table.unpack({...})) + return isclasslocked(table.unpack({...})) end -local isdlcclasslocked = luiglobals.Cac.IsCustomClassDlcLocked -luiglobals.Cac.IsCustomClassDlcLocked = function(...) - if (Engine.GetDvarBool("cg_unlockall_classes")) then - return false - end +local isdlcclasslocked = Cac.IsCustomClassDlcLocked +Cac.IsCustomClassDlcLocked = function(...) + if (Engine.GetDvarBool("cg_unlockall_classes")) then + return false + end - return isdlcclasslocked(table.unpack({...})) + return isdlcclasslocked(table.unpack({...})) end diff --git a/src/client/component/logger.cpp b/src/client/component/logger.cpp index 05c7a09..120f85b 100644 --- a/src/client/component/logger.cpp +++ b/src/client/component/logger.cpp @@ -174,6 +174,9 @@ namespace logger } com_error_hook.create(game::Com_Error, com_error_stub); + + // Make havok script's print function actually print + utils::hook::jump(0x140701A1C, print); } }; } diff --git a/src/client/component/ui_scripting.cpp b/src/client/component/ui_scripting.cpp index a3646a2..08ec337 100644 --- a/src/client/component/ui_scripting.cpp +++ b/src/client/component/ui_scripting.cpp @@ -7,143 +7,350 @@ #include "scheduler.hpp" #include "command.hpp" -#include "ui_scripting.hpp" +#include "localized_strings.hpp" +#include "console.hpp" +#include "game_module.hpp" +#include "fps.hpp" -#include "game/ui_scripting/lua/engine.hpp" #include "game/ui_scripting/execution.hpp" -#include "game/ui_scripting/lua/error.hpp" +#include "game/scripting/execution.hpp" + +#include "ui_scripting.hpp" #include #include +#include namespace ui_scripting { namespace { - std::unordered_map converted_functions; + std::unordered_map> converted_functions; - utils::hook::detour hksi_lual_error_hook; - utils::hook::detour hksi_lual_error_hook2; utils::hook::detour hks_start_hook; utils::hook::detour hks_shutdown_hook; - utils::hook::detour hks_allocator_hook; - utils::hook::detour hks_frame_hook; + utils::hook::detour hks_package_require_hook; - bool error_hook_enabled = false; - - void hksi_lual_error_stub(game::hks::lua_State* s, const char* fmt, ...) + struct script { - char va_buffer[2048] = {0}; + std::string name; + std::string root; + }; - va_list ap; - va_start(ap, fmt); - vsprintf_s(va_buffer, fmt, ap); - va_end(ap); + struct globals_t + { + std::string in_require_script; + std::vector