Add cg_drawfps + fixes
This commit is contained in:
parent
949a0821f8
commit
9d0f319c02
@ -93,6 +93,7 @@ function infoelement(data)
|
|||||||
local value = LUI.UIText.new({
|
local value = LUI.UIText.new({
|
||||||
left = left + 5,
|
left = left + 5,
|
||||||
top = textoffsety,
|
top = textoffsety,
|
||||||
|
font = labelfont.Font,
|
||||||
height = textheight,
|
height = textheight,
|
||||||
leftAnchor = true,
|
leftAnchor = true,
|
||||||
topAnchor = true,
|
topAnchor = true,
|
||||||
@ -156,3 +157,4 @@ LUI.onmenuopen("mp_hud", function(hud)
|
|||||||
|
|
||||||
hud.static:addElement(infobar)
|
hud.static:addElement(infobar)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
if (game:issingleplayer() or not Engine.InFrontend()) then
|
if (game:issingleplayer() or not Engine.InFrontend()) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
game:addlocalizedstring("LUA_MENU_STATS", "Stats")
|
game:addlocalizedstring("LUA_MENU_STATS", "Stats")
|
||||||
@ -7,11 +7,15 @@ 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", "Unlock all items")
|
||||||
game:addlocalizedstring("LUA_MENU_UNLOCKALL_ITEMS_DESC",
|
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_LOOT", "Unlock all loot")
|
||||||
|
game:addlocalizedstring("LUA_MENU_UNLOCKALL_LOOT_DESC",
|
||||||
|
"Whether loot 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", "Unlock all classes")
|
||||||
game:addlocalizedstring("LUA_MENU_UNLOCKALL_CLASSES_DESC",
|
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", "Prestige")
|
||||||
game:addlocalizedstring("LUA_MENU_PRESTIGE_DESC", "Edit prestige level.")
|
game:addlocalizedstring("LUA_MENU_PRESTIGE_DESC", "Edit prestige level.")
|
||||||
@ -25,166 +29,152 @@ game:addlocalizedstring("LUA_MENU_SETTINGS", "Settings")
|
|||||||
game:addlocalizedstring("LUA_MENU_EDIT_STATS", "Edit Stats")
|
game:addlocalizedstring("LUA_MENU_EDIT_STATS", "Edit Stats")
|
||||||
|
|
||||||
function createdivider(menu, text)
|
function createdivider(menu, text)
|
||||||
local element = LUI.UIElement.new({
|
local element = LUI.UIElement.new({
|
||||||
leftAnchor = true,
|
leftAnchor = true,
|
||||||
rightAnchor = true,
|
rightAnchor = true,
|
||||||
left = 0,
|
left = 0,
|
||||||
right = 0,
|
right = 0,
|
||||||
topAnchor = true,
|
topAnchor = true,
|
||||||
bottomAnchor = false,
|
bottomAnchor = false,
|
||||||
top = 0,
|
top = 0,
|
||||||
bottom = 33.33
|
bottom = 33.33
|
||||||
})
|
})
|
||||||
|
|
||||||
element.scrollingToNext = true
|
element.scrollingToNext = true
|
||||||
element:addElement(LUI.MenuBuilder.BuildRegisteredType("h1_option_menu_titlebar", {
|
element:addElement(LUI.MenuBuilder.BuildRegisteredType("h1_option_menu_titlebar", {
|
||||||
title_bar_text = Engine.ToUpperCase(Engine.Localize(text))
|
title_bar_text = Engine.ToUpperCase(Engine.Localize(text))
|
||||||
}))
|
}))
|
||||||
|
|
||||||
menu.list:addElement(element)
|
menu.list:addElement(element)
|
||||||
end
|
end
|
||||||
|
|
||||||
local personalizationbutton = LUI.MPLobbyBase.AddPersonalizationButton
|
local personalizationbutton = LUI.MPLobbyBase.AddPersonalizationButton
|
||||||
LUI.MPLobbyBase.AddPersonalizationButton = function(menu)
|
LUI.MPLobbyBase.AddPersonalizationButton = function(menu)
|
||||||
personalizationbutton(menu)
|
personalizationbutton(menu)
|
||||||
menu:AddButton("@LUA_MENU_STATS", function()
|
menu:AddButton("@LUA_MENU_STATS", function()
|
||||||
LUI.FlowManager.RequestAddMenu(nil, "stats_menu")
|
LUI.FlowManager.RequestAddMenu(nil, "stats_menu")
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
LUI.MenuBuilder.registerType("stats_menu", function(a1)
|
LUI.MenuBuilder.registerType("stats_menu", function(a1)
|
||||||
local menu = LUI.MenuTemplate.new(a1, {
|
local menu = LUI.MenuTemplate.new(a1, {
|
||||||
menu_title = Engine.ToUpperCase(Engine.Localize("@LUA_MENU_STATS")),
|
menu_title = Engine.ToUpperCase(Engine.Localize("@LUA_MENU_STATS")),
|
||||||
menu_width = luiglobals.GenericMenuDims.OptionMenuWidth
|
menu_width = luiglobals.GenericMenuDims.OptionMenuWidth
|
||||||
})
|
})
|
||||||
|
|
||||||
createdivider(menu, "@LUA_MENU_SETTINGS")
|
createdivider(menu, "@LUA_MENU_SETTINGS")
|
||||||
|
|
||||||
LUI.Options.CreateOptionButton(menu, "cg_unlockall_items", "@LUA_MENU_UNLOCKALL_ITEMS",
|
LUI.Options.CreateOptionButton(menu, "cg_unlockall_items", "@LUA_MENU_UNLOCKALL_ITEMS",
|
||||||
"@LUA_MENU_UNLOCKALL_ITEMS_DESC", {{
|
"@LUA_MENU_UNLOCKALL_ITEMS_DESC", {{
|
||||||
text = "@LUA_MENU_ENABLED",
|
text = "@LUA_MENU_ENABLED",
|
||||||
value = true
|
value = true
|
||||||
}, {
|
}, {
|
||||||
text = "@LUA_MENU_DISABLED",
|
text = "@LUA_MENU_DISABLED",
|
||||||
value = false
|
value = false
|
||||||
}}, nil, nil)
|
}}, nil, nil)
|
||||||
|
|
||||||
LUI.Options.CreateOptionButton(menu, "cg_unlockall_classes", "@LUA_MENU_UNLOCKALL_CLASSES",
|
LUI.Options.CreateOptionButton(menu, "cg_unlockall_loot", "@LUA_MENU_UNLOCKALL_LOOT",
|
||||||
"@LUA_MENU_UNLOCKALL_CLASSES_DESC", {{
|
"@LUA_MENU_UNLOCKALL_LOOT_DESC", {{
|
||||||
text = "@LUA_MENU_ENABLED",
|
text = "@LUA_MENU_ENABLED",
|
||||||
value = true
|
value = true
|
||||||
}, {
|
}, {
|
||||||
text = "@LUA_MENU_DISABLED",
|
text = "@LUA_MENU_DISABLED",
|
||||||
value = false
|
value = false
|
||||||
}}, nil, nil)
|
}}, nil, nil)
|
||||||
|
|
||||||
createdivider(menu, "@LUA_MENU_EDIT_STATS")
|
LUI.Options.CreateOptionButton(menu, "cg_unlockall_classes", "@LUA_MENU_UNLOCKALL_CLASSES",
|
||||||
|
"@LUA_MENU_UNLOCKALL_CLASSES_DESC", {{
|
||||||
|
text = "@LUA_MENU_ENABLED",
|
||||||
|
value = true
|
||||||
|
}, {
|
||||||
|
text = "@LUA_MENU_DISABLED",
|
||||||
|
value = false
|
||||||
|
}}, nil, nil)
|
||||||
|
|
||||||
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
createdivider(menu, "@LUA_MENU_EDIT_STATS")
|
||||||
local experience = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "experience") or 0
|
|
||||||
local rank = luiglobals.Lobby.GetRankForXP(experience, prestige)
|
|
||||||
|
|
||||||
local saved = true
|
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
||||||
local prestigevalue = prestige
|
local experience = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "experience") or 0
|
||||||
local rankvalue = rank
|
local rank = Lobby.GetRankForXP(experience, prestige)
|
||||||
local rankbutton = nil
|
|
||||||
|
|
||||||
prestigeeditbutton(menu, function(value)
|
prestigeeditbutton(menu, function(value)
|
||||||
prestigevalue = value
|
Engine.SetPlayerData(0, CoD.StatsGroup.Ranked, "prestige", tonumber(value))
|
||||||
saved = false
|
end)
|
||||||
end)
|
|
||||||
|
|
||||||
rankbutton = rankeditbutton(menu, function(value)
|
rankeditbutton(menu, function(value)
|
||||||
rankvalue = value
|
local rank = tonumber(value)
|
||||||
saved = false
|
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
||||||
end)
|
local experience = rank == 0 and 0 or Rank.GetRankMaxXP(tonumber(value) - 1, prestige)
|
||||||
|
|
||||||
local savebutton = menu:AddButton("@LUA_MENU_SAVE", function()
|
Engine.SetPlayerData(0, CoD.StatsGroup.Ranked, "experience", experience)
|
||||||
Engine.SetPlayerData(0, CoD.StatsGroup.Ranked, "prestige", tonumber(prestigevalue))
|
end)
|
||||||
|
|
||||||
local rank = tonumber(rankvalue)
|
LUI.Options.InitScrollingList(menu.list, nil)
|
||||||
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
LUI.Options.AddOptionTextInfo(menu)
|
||||||
local experience = rank == 0 and 0 or luiglobals.Rank.GetRankMaxXP(tonumber(rankvalue) - 1, prestige)
|
|
||||||
|
|
||||||
Engine.SetPlayerData(0, CoD.StatsGroup.Ranked, "experience", experience)
|
menu:AddBackButton()
|
||||||
|
|
||||||
saved = true
|
return menu
|
||||||
end, nil, nil, nil, {
|
|
||||||
desc_text = Engine.Localize("LUA_MENU_SAVE_DESC")
|
|
||||||
})
|
|
||||||
|
|
||||||
LUI.Options.InitScrollingList(menu.list, nil)
|
|
||||||
LUI.Options.AddOptionTextInfo(menu)
|
|
||||||
|
|
||||||
menu:AddBackButton(function()
|
|
||||||
if (saved) then
|
|
||||||
LUI.FlowManager.RequestLeaveMenu(menu)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
LUI.yesnopopup({
|
|
||||||
title = Engine.Localize("@MENU_NOTICE"),
|
|
||||||
text = Engine.Localize("@LUA_MENU_UNSAVED_CHANGES"),
|
|
||||||
callback = function(result)
|
|
||||||
if (result) then
|
|
||||||
LUI.FlowManager.RequestLeaveMenu(menu)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end)
|
|
||||||
|
|
||||||
return menu
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function prestigeeditbutton(menu, callback)
|
function prestigeeditbutton(menu, callback)
|
||||||
local options = {}
|
local options = {}
|
||||||
local max = luiglobals.Lobby.GetMaxPrestigeLevel()
|
local max = Lobby.GetMaxPrestigeLevel()
|
||||||
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
||||||
|
|
||||||
for i = 0, max do
|
for i = 0, max do
|
||||||
game:addlocalizedstring("LUA_MENU_" .. i, i .. "")
|
game:addlocalizedstring("LUA_MENU_" .. i, i .. "")
|
||||||
|
|
||||||
table.insert(options, {
|
table.insert(options, {
|
||||||
text = "@" .. i,
|
text = "@" .. i,
|
||||||
value = i .. ""
|
value = i .. ""
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
Engine.SetDvarFromString("ui_prestige_level", prestige .. "")
|
Engine.SetDvarFromString("ui_prestige_level", prestige .. "")
|
||||||
|
|
||||||
LUI.Options.CreateOptionButton(menu, "ui_prestige_level", "@LUA_MENU_PRESTIGE", "@LUA_MENU_PRESTIGE_DESC", options,
|
LUI.Options.CreateOptionButton(menu, "ui_prestige_level", "@LUA_MENU_PRESTIGE", "@LUA_MENU_PRESTIGE_DESC", options,
|
||||||
nil, nil, callback)
|
nil, nil, callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
function rankeditbutton(menu, callback)
|
function rankeditbutton(menu, callback)
|
||||||
local options = {}
|
local options = {}
|
||||||
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
||||||
local experience = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "experience") or 0
|
local experience = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "experience") or 0
|
||||||
|
|
||||||
local rank = luiglobals.Lobby.GetRankForXP(experience, prestige)
|
local rank = Lobby.GetRankForXP(experience, prestige)
|
||||||
local max = luiglobals.Rank.GetMaxRank(prestige)
|
local max = Rank.GetMaxRank(prestige)
|
||||||
local maxprestige = luiglobals.Lobby.GetMaxPrestigeLevel()
|
local maxprestige = Lobby.GetMaxPrestigeLevel()
|
||||||
|
|
||||||
for i = 0, max do
|
for i = 0, max do
|
||||||
game:addlocalizedstring("LUA_MENU_" .. i, i .. "")
|
game:addlocalizedstring("LUA_MENU_" .. i, i .. "")
|
||||||
|
|
||||||
table.insert(options, {
|
table.insert(options, {
|
||||||
text = "@" .. (i + 1),
|
text = "@" .. (i + 1),
|
||||||
value = i .. ""
|
value = i .. ""
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
Engine.SetDvarFromString("ui_rank_level_", rank .. "")
|
Engine.SetDvarFromString("ui_rank_level_", rank .. "")
|
||||||
|
|
||||||
return LUI.Options.CreateOptionButton(menu, "ui_rank_level_", "@LUA_MENU_RANK", "@LUA_MENU_RANK_DESC", options, nil,
|
return LUI.Options.CreateOptionButton(menu, "ui_rank_level_", "@LUA_MENU_RANK", "@LUA_MENU_RANK_DESC", options, nil,
|
||||||
nil, callback)
|
nil, callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
local isclasslocked = luiglobals.Cac.IsCustomClassLocked
|
local isclasslocked = Cac.IsCustomClassLocked
|
||||||
luiglobals.Cac.IsCustomClassLocked = function(...)
|
Cac.IsCustomClassLocked = function(...)
|
||||||
if (Engine.GetDvarBool("cg_unlockall_classes")) then
|
if (Engine.GetDvarBool("cg_unlockall_classes")) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
return isclasslocked(table.unpack({...}))
|
return isclasslocked(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
local getlockstate = Engine.GetItemLockState
|
||||||
|
Engine.GetItemLockState = function(...)
|
||||||
|
local status, state, msg = getlockstate(...)
|
||||||
|
if (state == Cac.ItemLockStatus.NotInInventory and Engine.GetDvarBool("cg_unlockall_loot")) then
|
||||||
|
return "Unlocked", 0, ""
|
||||||
|
end
|
||||||
|
return status, state, msg
|
||||||
end
|
end
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "game/game.hpp"
|
#include "game/game.hpp"
|
||||||
#include "game/dvars.hpp"
|
#include "game/dvars.hpp"
|
||||||
|
#include "dvars.hpp"
|
||||||
|
|
||||||
#include <utils/hook.hpp>
|
#include <utils/hook.hpp>
|
||||||
#include <utils/string.hpp>
|
#include <utils/string.hpp>
|
||||||
@ -87,8 +88,6 @@ namespace fps
|
|||||||
cg_perf.previous_ms = cg_perf.current_ms;
|
cg_perf.previous_ms = cg_perf.current_ms;
|
||||||
|
|
||||||
perf_calc_fps(&cg_perf, cg_perf.frame_ms);
|
perf_calc_fps(&cg_perf, cg_perf.frame_ms);
|
||||||
|
|
||||||
utils::hook::invoke<void>(SELECT_VALUE(0x1405487A0, 0x1406575A0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cg_draw_fps()
|
void cg_draw_fps()
|
||||||
@ -98,14 +97,17 @@ namespace fps
|
|||||||
const auto fps = fps::get_fps();
|
const auto fps = fps::get_fps();
|
||||||
|
|
||||||
const auto font = game::R_RegisterFont("fonts/fira_mono_regular.ttf", 25);
|
const auto font = game::R_RegisterFont("fonts/fira_mono_regular.ttf", 25);
|
||||||
const auto fps_string = utils::string::va("%i", fps);
|
if (font)
|
||||||
|
{
|
||||||
|
const auto fps_string = utils::string::va("%i", fps);
|
||||||
|
|
||||||
const auto x = (game::ScrPlace_GetViewPlacement()->realViewportSize[0] - 15.0f) - game::R_TextWidth(
|
const auto x = (game::ScrPlace_GetViewPlacement()->realViewportSize[0] - 15.0f) -
|
||||||
fps_string, 0x7FFFFFFF, font);
|
game::R_TextWidth(fps_string, 0x7FFFFFFF, font);
|
||||||
const auto y = font->pixelHeight + 10.f;
|
const auto y = font->pixelHeight + 10.f;
|
||||||
|
|
||||||
const auto fps_color = fps >= 60 ? fps_color_good : (fps >= 30 ? fps_color_ok : fps_color_bad);
|
const auto fps_color = fps >= 60 ? fps_color_good : (fps >= 30 ? fps_color_ok : fps_color_bad);
|
||||||
game::R_AddCmdDrawText(fps_string, 0x7FFFFFFF, font, x, y, 1.f, 1.f, 0.0f, fps_color, 6);
|
game::R_AddCmdDrawText(fps_string, 0x7FFFFFFF, font, x, y, 1.f, 1.f, 0.0f, fps_color, 6);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,8 +126,7 @@ namespace fps
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
game::dvar_t* cg_draw_fps_register_stub(const char* name, const char** _enum, const int value, unsigned int /*flags*/,
|
game::dvar_t* cg_draw_fps_register_stub()
|
||||||
const char* desc)
|
|
||||||
{
|
{
|
||||||
cg_drawfps = dvars::register_int("cg_drawFps", 0, 0, 2, game::DVAR_FLAG_SAVED, "Draw frames per second");
|
cg_drawfps = dvars::register_int("cg_drawFps", 0, 0, 2, game::DVAR_FLAG_SAVED, "Draw frames per second");
|
||||||
return cg_drawfps;
|
return cg_drawfps;
|
||||||
@ -151,22 +152,31 @@ namespace fps
|
|||||||
|
|
||||||
// fps setup
|
// fps setup
|
||||||
cg_perf.perf_start = std::chrono::high_resolution_clock::now();
|
cg_perf.perf_start = std::chrono::high_resolution_clock::now();
|
||||||
utils::hook::call(SELECT_VALUE(0x14018D261, 0x14025B747), &perf_update);
|
|
||||||
|
|
||||||
// change cg_drawfps flags to saved
|
utils::hook::jump(SELECT_VALUE(0, 0x343847_b), utils::hook::assemble([](utils::hook::assembler& a)
|
||||||
utils::hook::call(SELECT_VALUE(0x140139F48, 0x140222A46), &cg_draw_fps_register_stub);
|
{
|
||||||
|
a.pushad64();
|
||||||
|
a.call_aligned(perf_update);
|
||||||
|
a.popad64();
|
||||||
|
|
||||||
|
a.call(0x702250_b);
|
||||||
|
a.mov(edx, 3);
|
||||||
|
a.xor_(ecx, ecx);
|
||||||
|
a.jmp(0x343853_b);
|
||||||
|
}), true);
|
||||||
|
|
||||||
|
// Don't register cg_drawfps
|
||||||
|
utils::hook::nop(0x31D74F_b, 0x1C);
|
||||||
|
utils::hook::nop(0x31D76F_b, 0x7);
|
||||||
|
|
||||||
scheduler::loop(cg_draw_fps, scheduler::pipeline::renderer);
|
scheduler::loop(cg_draw_fps, scheduler::pipeline::renderer);
|
||||||
|
|
||||||
if (game::environment::is_sp())
|
cg_drawfps = dvars::register_int("cg_drawFps", 0, 0, 2, game::DVAR_FLAG_SAVED, "Draw frames per second");
|
||||||
{
|
|
||||||
cg_drawfps = dvars::register_int("cg_drawFps", 0, 0, 2, game::DVAR_FLAG_SAVED, "Draw frames per second");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (game::environment::is_mp())
|
if (game::environment::is_mp())
|
||||||
{
|
{
|
||||||
// fix ping value
|
// fix ping value
|
||||||
utils::hook::nop(0x14025AC41, 2);
|
utils::hook::nop(0x342C6C_b, 2);
|
||||||
|
|
||||||
cg_drawping = dvars::register_int("cg_drawPing", 0, 0, 1, game::DVAR_FLAG_SAVED, "Choose to draw ping");
|
cg_drawping = dvars::register_int("cg_drawPing", 0, 0, 1, game::DVAR_FLAG_SAVED, "Choose to draw ping");
|
||||||
|
|
||||||
@ -179,4 +189,4 @@ namespace fps
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//REGISTER_COMPONENT(fps::component)
|
REGISTER_COMPONENT(fps::component)
|
||||||
|
@ -41,16 +41,6 @@ namespace stats
|
|||||||
return is_item_unlocked_hook2.invoke<int>(a1, a2, a3, a4, a5, a6);
|
return is_item_unlocked_hook2.invoke<int>(a1, a2, a3, a4, a5, a6);
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_item_unlocked_stub3(int a1)
|
|
||||||
{
|
|
||||||
if (cg_unlock_all_items->current.enabled)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return is_item_unlocked_hook3.invoke<int>(a1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int is_item_unlocked()
|
int is_item_unlocked()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@ -75,14 +65,15 @@ namespace stats
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
is_item_unlocked_hook.create(0x19E6E0_b, is_item_unlocked_stub);
|
||||||
|
is_item_unlocked_hook2.create(0x19E070_b, is_item_unlocked_stub2);
|
||||||
|
|
||||||
cg_unlock_all_items = dvars::register_bool("cg_unlockall_items", false, game::DVAR_FLAG_SAVED,
|
cg_unlock_all_items = dvars::register_bool("cg_unlockall_items", false, game::DVAR_FLAG_SAVED,
|
||||||
"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.");
|
||||||
dvars::register_bool("cg_unlockall_classes", false, game::DVAR_FLAG_SAVED,
|
dvars::register_bool("cg_unlockall_classes", false, game::DVAR_FLAG_SAVED,
|
||||||
"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.");
|
||||||
|
dvars::register_bool("cg_unlockall_loot", false, game::DVAR_FLAG_SAVED,
|
||||||
is_item_unlocked_hook.create(0x19E6E0_b, is_item_unlocked_stub);
|
"Whether loot should be locked based on the player's stats or always unlocked.");
|
||||||
is_item_unlocked_hook2.create(0x19E070_b, is_item_unlocked_stub2);
|
|
||||||
is_item_unlocked_hook3.create(0x19D390_b, is_item_unlocked_stub3);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <utils/string.hpp>
|
#include <utils/string.hpp>
|
||||||
#include <utils/hook.hpp>
|
#include <utils/hook.hpp>
|
||||||
#include <utils/io.hpp>
|
#include <utils/io.hpp>
|
||||||
|
#include <utils/binary_resource.hpp>
|
||||||
|
|
||||||
namespace ui_scripting
|
namespace ui_scripting
|
||||||
{
|
{
|
||||||
@ -35,6 +36,8 @@ namespace ui_scripting
|
|||||||
utils::hook::detour hks_load_hook;
|
utils::hook::detour hks_load_hook;
|
||||||
utils::hook::detour db_find_xasset_header_hook;
|
utils::hook::detour db_find_xasset_header_hook;
|
||||||
|
|
||||||
|
const auto lui_common = utils::nt::load_resource(LUI_COMMON);
|
||||||
|
|
||||||
struct script
|
struct script
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
@ -185,7 +188,7 @@ namespace ui_scripting
|
|||||||
|
|
||||||
game_type["getping"] = [](const game&)
|
game_type["getping"] = [](const game&)
|
||||||
{
|
{
|
||||||
//return *::game::mp::ping;
|
return *::game::mp::ping;
|
||||||
};
|
};
|
||||||
|
|
||||||
game_type["issingleplayer"] = [](const game&)
|
game_type["issingleplayer"] = [](const game&)
|
||||||
@ -218,6 +221,8 @@ namespace ui_scripting
|
|||||||
lua["table"]["unpack"] = lua["unpack"];
|
lua["table"]["unpack"] = lua["unpack"];
|
||||||
lua["luiglobals"] = lua;
|
lua["luiglobals"] = lua;
|
||||||
|
|
||||||
|
load_script("lui_common", lui_common);
|
||||||
|
|
||||||
load_scripts("h1-mod/ui_scripts/");
|
load_scripts("h1-mod/ui_scripts/");
|
||||||
load_scripts("data/ui_scripts/");
|
load_scripts("data/ui_scripts/");
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ namespace game
|
|||||||
WEAK symbol<int> svs_numclients{0x0, 0x2DC338C};
|
WEAK symbol<int> svs_numclients{0x0, 0x2DC338C};
|
||||||
WEAK symbol<int> gameTime{0x0, 0x0};
|
WEAK symbol<int> gameTime{0x0, 0x0};
|
||||||
|
|
||||||
WEAK symbol<int> ping{0x0, 0x0};
|
WEAK symbol<int> ping{0x0, 0x2ECCF40};
|
||||||
|
|
||||||
WEAK symbol<int> sv_serverId_value{0x0, 0x0};
|
WEAK symbol<int> sv_serverId_value{0x0, 0x0};
|
||||||
|
|
||||||
|
@ -1,6 +1,30 @@
|
|||||||
menucallbacks = {}
|
local menucallbacks = {}
|
||||||
originalmenus = {}
|
local originalmenus = {}
|
||||||
stack = {}
|
local stack = {}
|
||||||
|
|
||||||
|
function getchildren(element)
|
||||||
|
local children = {}
|
||||||
|
local first = element:getFirstChild()
|
||||||
|
|
||||||
|
while (first) do
|
||||||
|
table.insert(children, first)
|
||||||
|
first = first:getNextSibling()
|
||||||
|
end
|
||||||
|
|
||||||
|
return children
|
||||||
|
end
|
||||||
|
|
||||||
|
function printchildtree(element, indent, last)
|
||||||
|
indent = indent or ""
|
||||||
|
|
||||||
|
print(indent .. "+- " .. element.id .. " " .. (element:getText() or ""))
|
||||||
|
indent = indent .. (last and " " or "| ")
|
||||||
|
|
||||||
|
local children = getchildren(element)
|
||||||
|
for i = 1, #children do
|
||||||
|
printchildtree(children[i], indent, i == #children)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
LUI.MenuBuilder.m_types_build["generic_waiting_popup_"] = function (menu, event)
|
LUI.MenuBuilder.m_types_build["generic_waiting_popup_"] = function (menu, event)
|
||||||
local oncancel = stack.oncancel
|
local oncancel = stack.oncancel
|
||||||
@ -14,9 +38,7 @@ LUI.MenuBuilder.m_types_build["generic_waiting_popup_"] = function (menu, event)
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
local listchildren = popup:getChildById("LUIHorizontalList"):getchildren()
|
popup.text = popup:getLastChild():getPreviousSibling():getPreviousSibling()
|
||||||
local children = listchildren[2]:getchildren()
|
|
||||||
popup.text = children[2]
|
|
||||||
|
|
||||||
stack = {
|
stack = {
|
||||||
ret = popup
|
ret = popup
|
||||||
@ -76,10 +98,10 @@ LUI.onmenuopen = function(name, callback)
|
|||||||
originalmenus[name] = LUI.MenuBuilder.m_types_build[name]
|
originalmenus[name] = LUI.MenuBuilder.m_types_build[name]
|
||||||
LUI.MenuBuilder.m_types_build[name] = function(...)
|
LUI.MenuBuilder.m_types_build[name] = function(...)
|
||||||
local args = {...}
|
local args = {...}
|
||||||
local menu = originalmenus[name](table.unpack(args))
|
local menu = originalmenus[name](unpack(args))
|
||||||
|
|
||||||
for k, v in luiglobals.next, menucallbacks[name] do
|
for k, v in next, menucallbacks[name] do
|
||||||
v(menu, table.unpack(args))
|
v(menu, unpack(args))
|
||||||
end
|
end
|
||||||
|
|
||||||
return menu
|
return menu
|
||||||
@ -136,7 +158,7 @@ LUI.openpopupmenu = function(menu, args)
|
|||||||
end
|
end
|
||||||
|
|
||||||
LUI.yesnopopup = function(data)
|
LUI.yesnopopup = function(data)
|
||||||
for k, v in luiglobals.next, data do
|
for k, v in next, data do
|
||||||
stack[k] = v
|
stack[k] = v
|
||||||
end
|
end
|
||||||
LUI.FlowManager.RequestPopupMenu(nil, "generic_yes_no_popup_")
|
LUI.FlowManager.RequestPopupMenu(nil, "generic_yes_no_popup_")
|
||||||
@ -144,21 +166,9 @@ LUI.yesnopopup = function(data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
LUI.confirmationpopup = function(data)
|
LUI.confirmationpopup = function(data)
|
||||||
for k, v in luiglobals.next, data do
|
for k, v in next, data do
|
||||||
stack[k] = v
|
stack[k] = v
|
||||||
end
|
end
|
||||||
LUI.FlowManager.RequestPopupMenu(nil, "generic_confirmation_popup_")
|
LUI.FlowManager.RequestPopupMenu(nil, "generic_confirmation_popup_")
|
||||||
return stack.ret
|
return stack.ret
|
||||||
end
|
end
|
||||||
|
|
||||||
function userdata_:getchildren()
|
|
||||||
local children = {}
|
|
||||||
local first = self:getFirstChild()
|
|
||||||
|
|
||||||
while (first) do
|
|
||||||
table.insert(children, first)
|
|
||||||
first = first:getNextSibling()
|
|
||||||
end
|
|
||||||
|
|
||||||
return children
|
|
||||||
end
|
|
||||||
|
Loading…
Reference in New Issue
Block a user