add new data directory, and update updater

This commit is contained in:
m
2022-09-03 06:00:31 -05:00
parent b913ea7129
commit 748ab6899e
34 changed files with 286 additions and 265 deletions

View File

@ -0,0 +1,146 @@
if game:issingleplayer() then
return
end
-- from mpdepotbase.lua, global definition isn't working
InventoryCurrencyType = {
LaunchCredits = 1,
Credits = 2,
Parts = 3,
CoDPoints = 4,
Bonus = 5,
Max = 6
}
ItemRarity = {
Common = 0,
Rare = 1,
Legendary = 2,
Epic = 3
}
custom_depot = {
collection_details_menu = nil,
data = {
currencies = {
launchCredits = 0, -- LaunchCredits
credits = 0, -- Credits
parts = 0, -- Parts
codPoints = 0, -- CoDPoints
bonus = 0 -- Bonus
},
items = {},
reward_splashes = {},
has_accepted_mod_eula = false,
has_seen_mod_eula = false
},
directory_path = "players2/user",
file_name = "depot.json",
file_path = nil,
functions = {}
}
custom_depot.file_path = string.format("%s/%s", custom_depot.directory_path, custom_depot.file_name)
custom_depot.get_function = function(function_name)
if not function_name or not custom_depot.functions[function_name] then
return nil
end
return custom_depot.functions[function_name]
end
custom_depot.functions["save_depot_data"] = function()
io.writefile(custom_depot.file_path, json.encode(custom_depot.data), false)
end
custom_depot.functions["load_depot_data"] = function()
if not io.directoryexists(custom_depot.directory_path) then
io.createdirectory(custom_depot.directory_path)
end
if not io.fileexists(custom_depot.file_path) then
custom_depot.get_function("save_depot_data")()
end
custom_depot.data = json.decode(io.readfile(custom_depot.file_path))
end
local function convert_currency_to_string(type)
if type == InventoryCurrencyType.LaunchCredits then
return "launchCredits"
elseif type == InventoryCurrencyType.Credits then
return "credits"
elseif type == InventoryCurrencyType.Parts then
return "parts"
elseif type == InventoryCurrencyType.CoDPoints then
return "codPoints"
elseif type == InventoryCurrencyType.Bonus then
return "bonus"
end
end
custom_depot.functions["add_currency"] = function(currency_type, amount)
local type = convert_currency_to_string(currency_type)
custom_depot.data.currencies[type] = custom_depot.data.currencies[type] + amount
end
custom_depot.functions["remove_currency"] = function(currency_type, amount)
local type = convert_currency_to_string(currency_type)
custom_depot.data.currencies[type] = custom_depot.data.currencies[type] - amount
end
custom_depot.functions["get_currency"] = function(currency_type)
local type = convert_currency_to_string(currency_type)
if not currency_type or not custom_depot.data.currencies[type] then
return nil
end
return custom_depot.data.currencies[type]
end
custom_depot.functions["add_item"] = function(item, value)
custom_depot.data.items[item] = value
end
custom_depot.functions["has_item"] = function(item)
return custom_depot.data.items[item] ~= nil
end
custom_depot.functions["add_reward_splash"] = function(item, value)
custom_depot.data.reward_splashes[item] = value
end
custom_depot.functions["has_reward_splash"] = function(item)
return custom_depot.data.reward_splashes[item] ~= nil
end
custom_depot.functions["has_accepted_mod_eula"] = function()
return custom_depot.data.has_accepted_mod_eula
end
custom_depot.functions["set_has_accepted_mod_eula"] = function(value)
custom_depot.data.has_accepted_mod_eula = value
custom_depot.get_function("save_depot_data")()
end
custom_depot.functions["has_seen_mod_eula"] = function()
return custom_depot.data.has_seen_mod_eula
end
custom_depot.functions["set_has_seen_mod_eula"] = function(value)
custom_depot.data.has_seen_mod_eula = value
custom_depot.get_function("save_depot_data")()
end
custom_depot.get_function("load_depot_data")()
if Engine.InFrontend() then
require("mod_eula")
require("depot_override")
end
if not Engine.InFrontend() then
require("scoreboard_override")
end

View File

@ -0,0 +1,332 @@
GetCurrencyBalance = function(currency_type)
return custom_depot.get_function("get_currency")(currency_type)
end
Inventory_PurchaseItem_orig = Engine.Inventory_PurchaseItem
Engine.Inventory_PurchaseItem = function(controller, item_guid, unk2)
if not custom_depot.get_function("has_item")(item_guid) then
custom_depot.get_function("add_item")(item_guid, true)
local item_value = Engine.TableLookup(LootTable.File, LootTable.Cols.GUID, item_guid, LootTable.Cols.Value)
custom_depot.get_function("remove_currency")(InventoryCurrencyType.Parts, item_value)
custom_depot.get_function("save_depot_data")()
if custom_depot.collection_details_menu then
custom_depot.collection_details_menu:OnCraftedItem()
end
end
return Inventory_PurchaseItem_orig(controller, item_guid, unk2)
end
GetItemLockState_orig = Engine.GetItemLockState
Engine.GetItemLockState = function(controller, item_guid)
if custom_depot.get_function("has_item")(item_guid) then
return "Unlocked", 0, ""
end
return GetItemLockState_orig(controller, item_guid)
end
GetItemSet_orig = GetItemSet
GetItemSet = function(item_set_id)
local item_set = GetItemSet_orig(item_set_id)
local items_unlocked = 0
for k, v in pairs(item_set.setItems) do
if custom_depot.get_function("has_item")(v.guid) and (not v.isOwned or v.lockState == "Unlocked") then
v.isOwned = true
v.lockState = "Unlocked"
items_unlocked = items_unlocked + 1
end
end
if items_unlocked == #item_set.setItems then
if not item_set.completed then
item_set.completed = true
end
if not custom_depot.get_function("has_item")(item_set.setReward.guid) then
custom_depot.get_function("add_item")(item_set.setReward.guid, true)
custom_depot.get_function("save_depot_data")()
if custom_depot.collection_details_menu then
custom_depot.collection_details_menu:OnCompletedSet()
end
end
end
item_set.numOwned = items_unlocked
return item_set
end
GetItemSets_orig = GetItemSets
GetItemSets = function()
local item_sets = GetItemSets_orig()
local completed_sets = 0
for i = 1, #item_sets.seasons do
local seasons_completed_sets = 0
local sets = item_sets.seasons[i].sets
local rewardData = item_sets.seasons[i].rewardData
for i = 1, #sets do
if sets[i].completed then
completed_sets = completed_sets + 1
seasons_completed_sets = seasons_completed_sets + 1
end
end
if item_sets.seasons[i].completedSets == #sets then
rewardData.setReward.isOwned = true
rewardData.setReward.lockState = "Unlocked"
rewardData.completed = true
if not custom_depot.get_function("has_item")(rewardData.setReward.guid) then
custom_depot.get_function("add_item")(rewardData.setReward.guid, true)
custom_depot.get_function("save_depot_data")()
end
end
item_sets.seasons[i].completedSets = seasons_completed_sets
end
for k, v in pairs(item_sets.itemToSetMap) do
local items_unlocked = 0
for i = 1, #v.setItems do
if custom_depot.get_function("has_item")(v.setItems[i].guid) and
(not v.setItems[i].isOwned or v.setItems[i].lockState == "Unlocked") then
v.setItems[i].isOwned = true
v.setItems[i].lockState = "Unlocked"
items_unlocked = items_unlocked + 1
end
end
if items_unlocked == #v.setItems then
if not v.completed then
v.completed = true
completed_sets = completed_sets + 1
end
if not custom_depot.get_function("has_item")(v.setReward.guid) then
custom_depot.get_function("add_item")(v.setReward.guid, true)
custom_depot.get_function("save_depot_data")()
end
end
v.numOwned = items_unlocked
end
item_sets.completedSets = completed_sets
return item_sets
end
IsContentPromoUnlocked_orig = IsContentPromoUnlocked
IsContentPromoUnlocked = function()
return true
end
TryShowCollectionCompleted_orig = TryShowCollectionCompleted
TryShowCollectionCompleted = function(controller, reward_data, unk1)
if reward_data.completed then
if not custom_depot.get_function("has_reward_splash")(reward_data.setReward.guid) then
LUI.FlowManager.RequestAddMenu(nil, "MPDepotCollectionRewardSplash", true, controller, false, {
collectionData = reward_data
})
if custom_depot.collection_details_menu then
custom_depot.collection_details_menu:OnCompletedSet()
end
custom_depot.get_function("add_reward_splash")(reward_data.setReward.guid, true)
custom_depot.get_function("save_depot_data")()
end
return true
else
return false
end
end
TryShowSeasonCompleted_orig = TryShowSeasonCompleted
TryShowSeasonCompleted = function(controller, reward_data, unk1)
if reward_data.completed then
if not custom_depot.get_function("has_reward_splash")(reward_data.setReward.guid) then
LUI.FlowManager.RequestAddMenu(nil, "MPDepotCollectionRewardSplash", true, controller, false, {
collectionData = reward_data
})
if custom_depot.collection_details_menu then
custom_depot.collection_details_menu:OnCompletedSet()
end
custom_depot.get_function("add_reward_splash")(reward_data.setReward.guid, true)
custom_depot.get_function("save_depot_data")()
end
return true
else
return false
end
end
MPDepotCollectionDetailsMenu_orig = LUI.MenuBuilder.m_types_build["MPDepotCollectionDetailsMenu"]
MPDepotCollectionDetailsMenu = function(unk1, unk2)
custom_depot.collection_details_menu = MPDepotCollectionDetailsMenu_orig(unk1, unk2)
return custom_depot.collection_details_menu
end
LUI.MenuBuilder.m_types_build["MPDepotCollectionDetailsMenu"] = MPDepotCollectionDetailsMenu
MPDepotOpenLootMenu_orig = LUI.MenuBuilder.m_types_build["MPDepotOpenLootMenu"]
MPDepotOpenLootMenu = function(unk1, unk2)
local open_loot_menu = MPDepotOpenLootMenu_orig(unk1, unk2)
local supply_drop_orig = open_loot_menu.m_eventHandlers["supply_drop"]
open_loot_menu:registerEventHandler("supply_drop", function(f48_arg0, f48_arg1)
f48_arg1.success = true
f48_arg1.transaction = f48_arg0.supplyDropTransaction
f48_arg1.duplicateRefund = false
f48_arg1.items = {}
f48_arg1.currencies = {}
f48_arg1.replacements = {}
f48_arg1.cards = {}
local supply_drop_price = LUI.MPDepot.GetSupplyDropPrice(f48_arg0.supplyDropType)
custom_depot.get_function("remove_currency")(supply_drop_price.type, supply_drop_price.amount)
custom_depot.get_function("save_depot_data")()
for i = 1, unk2.crateType:find("_basic") and math.random(1, 2) or math.random(2, 3) do
local items_list = LUI.MPLootDropsBase.GetGenericItemList(x, LUI.MPDepot.LootDropsData[LUI.MPDepot
.SuppyDropLootStream[unk2.crateType]].lootTableColName)
local random_item = items_list[math.random(#items_list)]
while random_item.inventoryItemType ~= Cac.InventoryItemType.Loot do
random_item = items_list[math.random(#items_list)]
end
if random_item then
f48_arg1.items[i] = random_item.guid
end
end
for i = 1, #f48_arg1.items do
if not custom_depot.get_function("has_item")(f48_arg1.items[i]) then
custom_depot.get_function("add_item")(f48_arg1.items[i], true)
else
local item_rarity = tonumber(Engine.TableLookup(LootTable.File, LootTable.Cols.GUID, f48_arg1.items[i],
LootTable.Cols.Rarity))
local dismantled_amount = 0
if item_rarity == ItemRarity.Common then
dismantled_amount = math.random(1, 75)
elseif item_rarity == ItemRarity.Rare then
dismantled_amount = math.random(75, 155)
elseif item_rarity == ItemRarity.Legendary then
dismantled_amount = math.random(155, 260)
elseif item_rarity == ItemRarity.Epic then
dismantled_amount = math.random(260, 550)
end
table.insert(f48_arg1.replacements, {
item_index = i,
currency = {
amount = dismantled_amount
}
})
custom_depot.get_function("add_currency")(InventoryCurrencyType.Parts, dismantled_amount)
end
end
custom_depot.get_function("save_depot_data")()
supply_drop_orig(f48_arg0, f48_arg1)
end)
local slow_purchase_transfer_orig = open_loot_menu.m_eventHandlers["slow_purchase_transfer"]
open_loot_menu:registerEventHandler("slow_purchase_transfer", function(f33_arg0, f33_arg1)
local f33_local0 = 0
if f33_arg0.slowPurchaseTimer then
f33_arg0.slowPurchaseTimer:close()
f33_arg0.slowPurchaseTimer = nil
end
local f33_local1 = CoD.CreateState(-500, 0, 500, 20, CoD.AnchorTypes.Top)
f33_local1.font = CoD.TextSettings.BodyFont.Font
f33_local1.verticalAlignment = LUI.VerticalAlignment.Top
f33_local1.horizontalAlignment = LUI.HorizontalAlignment.Center
f33_local1.color = Colors.mw1_green
f33_local1.alpha = 1
f33_arg0.slowPurchaseText = LUI.UIText.new(f33_local1)
f33_arg0:addElement(f33_arg0.slowPurchaseText)
f33_arg0.slowPurchaseText:setText(Engine.Localize("@DEPOT_TRANSFER_IN_PROGRESS_DOT"))
f33_arg0.slowPurchaseText.textState = 1
f33_arg0.slowPurchaseText:registerEventHandler("update_slow_purchase_text", f0_local30)
f33_arg0.slowPurchaseText:addElement(LUI.UITimer.new(1000, "update_slow_purchase_text"))
local f33_local2 = LUI.MenuBuilder.BuildRegisteredType("progressBar")
f33_local2:registerAnimationState("default", {
topAnchor = false,
bottomAnchor = true,
leftAnchor = false,
rightAnchor = false,
top = 0,
height = 40
})
f33_local2:animateToState("default")
f33_arg0.slowPurchaseText:addElement(f33_local2)
f33_local2:animateFill(f33_local0)
f33_arg0.purchaseTimeoutTimer = LUI.UITimer.new(f33_local0, "abort_purchase_transfer", nil, true)
f33_arg0:addElement(f33_arg0.purchaseTimeoutTimer)
end)
return open_loot_menu
end
LUI.MenuBuilder.m_types_build["MPDepotOpenLootMenu"] = MPDepotOpenLootMenu
AddLootDropTabSelector_orig = LUI.MPDepotBase.AddLootDropTabSelector
LUI.MPDepotBase.AddLootDropTabSelector = function(unk1, unk2)
if not custom_depot.get_function("has_accepted_mod_eula")() then
local item_sets = GetItemSets()
unk1:AddButtonWithInfo("depot_collections", "@DEPOT_COLLECTIONS", "MPDepotCollectionsMenu", nil, nil,
Engine.Localize("@MPUI_X_SLASH_Y", item_sets.completedSets, item_sets.numSets))
unk1:AddButtonWithInfo("depot_armory", "@DEPOT_ARMORY", "MPDepotArmoryMenu")
return
end
AddLootDropTabSelector_orig(unk1, unk2)
end
MPDepotMenu_orig = LUI.MenuBuilder.m_types_build["MPDepotMenu"]
MPDepotMenu = function(unk1, unk2)
local depot_menu = MPDepotMenu_orig(unk1, unk2)
if not custom_depot.get_function("has_seen_mod_eula")() then
LUI.FlowManager.RequestAddMenu(nil, "mod_eula", true, 0, false, {
acceptCallback = function()
custom_depot.get_function("set_has_accepted_mod_eula")(true)
custom_depot.get_function("set_has_seen_mod_eula")(true)
LUI.FlowManager.RequestLeaveMenu(depot_menu)
end,
declineCallback = function()
custom_depot.get_function("set_has_accepted_mod_eula")(false)
custom_depot.get_function("set_has_seen_mod_eula")(true)
end
})
end
return depot_menu
end
LUI.MenuBuilder.m_types_build["MPDepotMenu"] = MPDepotMenu
GetLootDataForRef_orig = LUI.InventoryUtils.GetLootDataForRef
LUI.InventoryUtils.GetLootDataForRef = function(f13_arg0, f13_arg1, f13_arg2, f13_arg3, f13_arg4)
local loot_data = GetLootDataForRef_orig(f13_arg0, f13_arg1, f13_arg2, f13_arg3, f13_arg4)
if loot_data and custom_depot.get_function("has_item")(loot_data.guid) then
loot_data.lockState = "Unlocked"
end
return loot_data
end

View File

@ -0,0 +1,13 @@
local mod_eula = function(unk1, unk2)
return LUI.EULABase.new(CoD.CreateState(0, 0, 0, 0, CoD.AnchorTypes.All), {
textStrings = LUI.EULABase.CreateTextStrings("@CUSTOM_DEPOT_EULA_", 6),
declineCallback = function(unk3)
unk2.declineCallback(unk3)
end,
acceptCallback = function(unk4)
unk2.acceptCallback(unk4)
end
})
end
LUI.MenuBuilder.registerPopupType("mod_eula", mod_eula)

View File

@ -0,0 +1,56 @@
-- from roundend.lua, dev comments says that the game["round_end"] array contains indexes for this table
local ending_reasons = {"MP_DRAW", "LUA_MENU_REPORT_DRAW", "MP_ROUND_WIN", "MP_ROUND_LOSS", "LUA_MENU_REPORT_VICTORY",
"LUA_MENU_REPORT_DEFEAT", "MP_HALFTIME", "MP_OVERTIME", "MP_ROUNDEND", "MP_INTERMISSION",
"MP_SWITCHING_SIDES", "MP_MATCH_BONUS_IS", "MP_MATCH_TIE", "MP_GAME_END", "SPLASHES_BLANK"}
local function starts_with(str, start)
return str:sub(1, #start) == start
end
local player_old_score = 0
local scoreboard_orig = LUI.MenuBuilder.m_types_build["scoreboard"]
local scoreboard = function(unk1, unk2)
local scoreboard = scoreboard_orig(unk1, unk2)
scoreboard:registerOmnvarHandler("ui_round_end", function(f22_arg0, f22_arg1)
if GameX.IsRankedMatch() then
local player_score = 0
local gamemode = GameX.GetGameMode()
local player_stats = Game.GetPlayerScoreInfoAtRank(Game.GetPlayerTeam(), Game.GetPlayerScoreRanking())
--[[
this will do the job for when its needed, aka when round loss/win occurs
this check may be true more than once cuz this callback happens 3 times,
but the player_old_score variable will stop us from adding more currency
]] --
local unlocalized_string = ending_reasons[Game.GetOmnvar("ui_round_end_title")]
local is_round_based = starts_with(unlocalized_string, "MP_ROUND") or IsGameTypeRoundBased(gamemode)
if is_round_based or gamemode == "conf" or gamemode == "war" then
player_score = player_stats.score
else
player_score = player_stats.extrascore0
end
local currency_gain = math.floor((player_score - player_old_score) * 10 / 100)
if currency_gain <= 0 then
return
end
custom_depot.get_function("add_currency")(InventoryCurrencyType.Parts, currency_gain)
if custom_depot.functions["has_accepted_mod_eula"]() then
custom_depot.get_function("add_currency")(InventoryCurrencyType.Credits, math.random(2, 3))
end
player_old_score = player_score
custom_depot.get_function("save_depot_data")()
end
end)
return scoreboard
end
LUI.MenuBuilder.m_types_build["scoreboard"] = scoreboard

View File

@ -0,0 +1,272 @@
if (game:issingleplayer() or Engine.InFrontend()) then
return
end
local container = LUI.UIVerticalList.new({
topAnchor = true,
rightAnchor = true,
top = 20,
right = 200,
width = 200,
spacing = 5,
})
function canasktojoin(userid)
history = history or {}
if (history[userid] ~= nil) then
return false
end
history[userid] = true
game:ontimeout(function()
history[userid] = nil
end, 15000)
return true
end
function truncatename(name, length)
if (#name <= length - 3) then
return name
end
return name:sub(1, length - 3) .. "..."
end
function addrequest(request)
if (not canasktojoin(request.userid)) then
return
end
if (container.temp) then
container:removeElement(container.temp)
container.temp = nil
end
local invite = LUI.UIElement.new({
leftAnchor = true,
rightAnchor = true,
height = 75,
})
invite:registerAnimationState("move_in", {
leftAnchor = true,
height = 75,
width = 200,
left = -220,
})
invite:animateToState("move_in", 100)
local background = LUI.UIImage.new({
topAnchor = true,
leftAnchor = true,
rightAnchor = true,
bottomAnchor = true,
top = 1,
left = 1,
bottom = -1,
right = -1,
material = RegisterMaterial("white"),
color = {
r = 0,
b = 0,
g = 0,
},
alpha = 0.6,
})
local border = LUI.UIImage.new({
topAnchor = true,
leftAnchor = true,
rightAnchor = true,
bottomAnchor = true,
material = RegisterMaterial("btn_focused_rect_innerglow"),
})
border:setup9SliceImage(10, 5, 0.25, 0.12)
local paddingvalue = 10
local padding = LUI.UIElement.new({
topAnchor = true,
leftAnchor = true,
rightAnchor = true,
bottomAnchor = true,
top = paddingvalue,
left = paddingvalue,
right = -paddingvalue,
bottom = -paddingvalue,
})
local avatarmaterial = discord.getavatarmaterial(request.userid)
local avatar = LUI.UIImage.new({
leftAnchor = true,
topAnchor = true,
width = 32,
height = 32,
left = 1,
material = RegisterMaterial(avatarmaterial)
})
local username = LUI.UIText.new({
leftAnchor = true,
topAnchor = true,
height = 12,
left = 32 + paddingvalue,
color = Colors.white,
alignment = LUI.Alignment.Left,
rightAnchor = true,
font = CoD.TextSettings.BodyFontBold.Font
})
username:setText(string.format("%s^7#%s requested to join your game!",
truncatename(request.username, 18), request.discriminator))
local buttons = LUI.UIElement.new({
leftAnchor = true,
rightAnchor = true,
topAnchor = true,
top = 37,
height = 18,
})
local createbutton = function(text, left)
local button = LUI.UIElement.new({
leftAnchor = left,
rightAnchor = not left,
topAnchor = true,
height = 18,
width = 85,
material = RegisterMaterial("btn_focused_rect_innerglow"),
})
local center = LUI.UIText.new({
rightAnchor = true,
height = 12,
width = 85,
top = -6.5,
alignment = LUI.Alignment.Center,
font = CoD.TextSettings.BodyFontBold.Font
})
button:setup9SliceImage(10, 5, 0.25, 0.12)
center:setText(text)
button:addElement(center)
return button
end
buttons:addElement(createbutton("[F1] Accept", true))
buttons:addElement(createbutton("[F2] Deny"))
local fadeouttime = 50
local timeout = 10 * 1000 - fadeouttime
local function close()
container:processEvent({
name = "update_navigation",
dispatchToChildren = true
})
invite:animateToState("fade_out", fadeouttime)
invite:addElement(LUI.UITimer.new(fadeouttime + 50, "remove"))
invite:registerEventHandler("remove", function()
container:removeElement(invite)
if (container.temp) then
container:removeElement(container.temp)
container.temp = nil
end
local temp = LUI.UIElement.new({})
container.temp = temp
container:addElement(temp)
end)
end
buttons:registerEventHandler("keydown_", function(element, event)
if (event.key == "F1") then
close()
discord.respond(request.userid, discord.reply.yes)
end
if (event.key == "F2") then
close()
discord.respond(request.userid, discord.reply.no)
end
end)
invite:registerAnimationState("fade_out", {
leftAnchor = true,
rightAnchor = true,
height = 75,
alpha = 0,
left = 0
})
invite:addElement(LUI.UITimer.new(timeout, "end_invite"))
invite:registerEventHandler("end_invite", function()
close()
discord.respond(request.userid, discord.reply.ignore)
end)
local bar = LUI.UIImage.new({
bottomAnchor = true,
leftAnchor = true,
bottom = -3,
left = 3,
width = 200 - 6,
material = RegisterMaterial("white"),
height = 2,
color = {
r = 92 / 255,
g = 206 / 255,
b = 113 / 255,
}
})
bar:registerAnimationState("closing", {
bottomAnchor = true,
leftAnchor = true,
bottom = -3,
left = 3,
width = 0,
height = 2,
})
bar:animateToState("closing", timeout)
avatar:registerEventHandler("update", function()
local avatarmaterial = discord.getavatarmaterial(request.userid)
avatar:setImage(RegisterMaterial(avatarmaterial))
end)
avatar:addElement(LUI.UITimer.new(100, "update"))
invite:addElement(background)
invite:addElement(bar)
invite:addElement(border)
invite:addElement(padding)
padding:addElement(username)
padding:addElement(avatar)
padding:addElement(buttons)
container:addElement(invite)
end
container:registerEventHandler("keydown", function(element, event)
local first = container:getFirstChild()
if (not first) then
return
end
first:processEvent({
name = "keydown_",
key = event.key
})
end)
LUI.roots.UIRoot0:registerEventHandler("discord_join_request", function(element, event)
addrequest(event.request)
end)
LUI.roots.UIRoot0:addElement(container)

View File

@ -0,0 +1,6 @@
if (game:issingleplayer()) then
return
end
require("settings")
require("hud")

View File

@ -0,0 +1,198 @@
local mphud = luiglobals.require("LUI.mp_hud.MPHud")
local barheight = 16
local textheight = 13
local textoffsety = barheight / 2 - textheight / 2
function createinfobar()
local infobar = LUI.UIElement.new({
left = 213,
top = -6,
height = barheight,
width = 70,
leftAnchor = true,
topAnchor = true
})
infobar:registerAnimationState("minimap_on", {
left = 213,
top = -6,
height = barheight,
width = 70,
leftAnchor = true,
topAnchor = true
})
infobar:registerAnimationState("minimap_off", {
left = 0,
top = 0,
height = barheight,
width = 70,
leftAnchor = true,
topAnchor = true
})
infobar:registerAnimationState("hud_on", {
alpha = 1
})
infobar:registerAnimationState("hud_off", {
alpha = 0
})
return infobar
end
function updateinfobarvisibility()
local root = Engine.GetLuiRoot()
local menus = root:AnyActiveMenusInStack()
local infobar = root.infobar
if (not infobar) then
return
end
if (menus or Game.InKillCam()) then
infobar:animateToState("hud_off")
else
infobar:animateToState("hud_on")
end
local validstates = {
"hud_on",
"active",
"nosignal",
"scrambled"
}
infobar:animateToState("minimap_off")
for i = 1, #validstates do
if (validstates[i] == root.hud.minimap.current_state) then
infobar:animateToState("minimap_on")
break
end
end
end
function populateinfobar(infobar)
elementoffset = 0
if (Engine.GetDvarBool("cg_infobar_fps")) then
infobar:addElement(infoelement({
label = "FPS: ",
getvalue = function()
return game:getfps()
end,
width = 70,
interval = 100
}))
end
if (Engine.GetDvarBool("cg_infobar_ping")) then
infobar:addElement(infoelement({
label = "Latency: ",
getvalue = function()
return game:getping() .. " ms"
end,
width = 115,
interval = 100
}))
end
updateinfobarvisibility()
end
function infoelement(data)
local container = LUI.UIElement.new({
bottomAnchor = true,
leftAnchor = true,
topAnchor = true,
width = data.width,
left = elementoffset
})
elementoffset = elementoffset + data.width + 10
local background = LUI.UIImage.new({
bottomAnchor = true,
leftAnchor = true,
topAnchor = true,
rightAnchor = true,
material = luiglobals.RegisterMaterial("white"),
color = luiglobals.Colors.black,
alpha = 0.5
})
local labelfont = CoD.TextSettings.FontBold110
local label = LUI.UIText.new({
left = 5,
top = textoffsety,
font = labelfont.Font,
height = textheight,
leftAnchor = true,
topAnchor = true,
color = {
r = 0.8,
g = 0.8,
b = 0.8
}
})
label:setText(data.label)
local _, _, left = luiglobals.GetTextDimensions(data.label, labelfont.Font, textheight)
local value = LUI.UIText.new({
left = left + 5,
top = textoffsety,
font = labelfont.Font,
height = textheight,
leftAnchor = true,
topAnchor = true,
color = {
r = 0.6,
g = 0.6,
b = 0.6
}
})
value:addElement(LUI.UITimer.new(data.interval, "update"))
value:setText(data.getvalue())
value:addEventHandler("update", function()
value:setText(data.getvalue())
end)
container:addElement(background)
container:addElement(label)
container:addElement(value)
return container
end
local updatehudvisibility = mphud.updateHudVisibility
mphud.updateHudVisibility = function(a1, a2)
updatehudvisibility(a1, a2)
updateinfobarvisibility()
end
LUI.onmenuopen("mp_hud", function(hud)
if (Engine.InFrontend()) then
return
end
local infobar = createinfobar()
local root = Engine.GetLuiRoot()
root.infobar = infobar
root.hud = hud
populateinfobar(infobar)
root:registerEventHandler("update_hud_infobar_settings", function()
infobar:removeAllChildren()
populateinfobar(infobar)
end)
root:processEvent({
name = "update_hud_infobar_settings"
})
hud.static.scalable:addElement(infobar)
end)

View File

@ -0,0 +1,133 @@
local pcdisplay = luiglobals.require("LUI.PCDisplay")
function createdivider(menu, text)
local element = LUI.UIElement.new({
leftAnchor = true,
rightAnchor = true,
left = 0,
right = 0,
topAnchor = true,
bottomAnchor = false,
top = 0,
bottom = 33.33
})
element.scrollingToNext = true
element:addElement(LUI.MenuBuilder.BuildRegisteredType("h1_option_menu_titlebar", {
title_bar_text = text
}))
menu.list:addElement(element)
end
pcdisplay.CreateOptions = function(menu)
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
"@LUA_MENU_COLORBLIND_FILTER", "@LUA_MENU_COLOR_BLIND_DESC", LUI.Options.GetRenderColorBlindText,
LUI.Options.RenderColorBlindToggle, LUI.Options.RenderColorBlindToggle)
if Engine.IsMultiplayer() and Engine.GetDvarType("cg_paintballFx") == luiglobals.DvarTypeTable.DvarBool then
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
"@LUA_MENU_PAINTBALL", "@LUA_MENU_PAINTBALL_DESC",
LUI.Options.GetDvarEnableTextFunc("cg_paintballFx", false), LUI.Options.ToggleDvarFunc("cg_paintballFx"),
LUI.Options.ToggleDvarFunc("cg_paintballFx"))
end
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select, "@LUA_MENU_BLOOD",
"@LUA_MENU_BLOOD_DESC", LUI.Options.GetDvarEnableTextFunc("cg_blood", false), LUI.Options
.ToggleProfiledataFunc("showblood", Engine.GetControllerForLocalClient(0)), LUI.Options
.ToggleProfiledataFunc("showblood", Engine.GetControllerForLocalClient(0)))
if not Engine.IsMultiplayer() then
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
"@LUA_MENU_CROSSHAIR", "@LUA_MENU_CROSSHAIR_DESC",
LUI.Options.GetDvarEnableTextFunc("cg_drawCrosshairOption", false),
LUI.Options.ToggleDvarFunc("cg_drawCrosshairOption"), LUI.Options.ToggleDvarFunc("cg_drawCrosshairOption"))
LUI.Options.CreateOptionButton(menu, "cg_drawDamageFeedbackOption", "@LUA_MENU_HIT_MARKER",
"@LUA_MENU_HIT_MARKER_DESC", {{
text = "@LUA_MENU_ENABLED",
value = true
}, {
text = "@LUA_MENU_DISABLED",
value = false
}})
end
if Engine.IsMultiplayer() then
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
"@MENU_DISPLAY_KILLSTREAK_COUNTER", "@MENU_DISPLAY_KILLSTREAK_COUNTER_DESC",
pcdisplay.GetDisplayKillstreakCounterText, pcdisplay.DisplayKillstreakCounterToggle,
pcdisplay.DisplayKillstreakCounterToggle)
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
"@MENU_DISPLAY_MEDAL_SPLASHES", "@MENU_DISPLAY_MEDAL_SPLASHES_DESC", pcdisplay.GetDisplayMedalSplashesText,
pcdisplay.DisplayMedalSplashesToggle, pcdisplay.DisplayMedalSplashesToggle)
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Select,
"@MENU_DISPLAY_WEAPON_EMBLEMS", "@MENU_DISPLAY_WEAPON_EMBLEMS_DESC", pcdisplay.GetDisplayWeaponEmblemsText,
pcdisplay.DisplayWeaponEmblemsToggle, pcdisplay.DisplayWeaponEmblemsToggle)
end
LUI.Options.AddButtonOptionVariant(menu, luiglobals.GenericButtonSettings.Variants.Common, "@MENU_BRIGHTNESS",
"@MENU_BRIGHTNESS_DESC1", nil, nil, nil, pcdisplay.OpenBrightnessMenu, nil, nil, nil)
local reddotbounds = {
step = 0.2,
max = 4,
min = 0.2
}
LUI.Options.AddButtonOptionVariant(
menu,
GenericButtonSettings.Variants.Slider,
"@LUA_MENU_RED_DOT_BRIGHTNESS",
"@LUA_MENU_RED_DOT_BRIGHTNESS_DESC",
function()
return (Engine.GetDvarFloat( "r_redDotBrightnessScale" ) -
reddotbounds.min) / (reddotbounds.max - reddotbounds.min)
end,
function()
Engine.SetDvarFloat("r_redDotBrightnessScale",
math.min(reddotbounds.max,
math.max(reddotbounds.min, Engine.GetDvarFloat("r_redDotBrightnessScale") - reddotbounds.step))
)
end,
function()
Engine.SetDvarFloat("r_redDotBrightnessScale",
math.min(reddotbounds.max,
math.max(reddotbounds.min, Engine.GetDvarFloat("r_redDotBrightnessScale") + reddotbounds.step))
)
end
)
createdivider(menu, "TELEMETRY")
LUI.Options.CreateOptionButton(menu, "cg_infobar_ping", "@LUA_MENU_LATENCY", "@LUA_MENU_LATENCY_DESC", {{
text = "@LUA_MENU_ENABLED",
value = true
}, {
text = "@LUA_MENU_DISABLED",
value = false
}}, nil, nil, function(value)
Engine.SetDvarBool("cg_infobar_ping", value)
Engine.GetLuiRoot():processEvent({
name = "update_hud_infobar_settings"
})
end)
LUI.Options.CreateOptionButton(menu, "cg_infobar_fps", "@LUA_MENU_FPS", "@LUA_MENU_FPS_DESC", {{
text = "@LUA_MENU_ENABLED",
value = true
}, {
text = "@LUA_MENU_DISABLED",
value = false
}}, nil, nil, function(value)
Engine.SetDvarBool("cg_infobar_fps", value)
Engine.GetLuiRoot():processEvent({
name = "update_hud_infobar_settings"
})
end)
LUI.Options.InitScrollingList(menu.list, nil)
end

View File

@ -0,0 +1,5 @@
require("loading")
if (Engine.InFrontend()) then
require("download")
end

View File

@ -0,0 +1,115 @@
function createdivider(menu, text)
local element = LUI.UIElement.new({
leftAnchor = true,
rightAnchor = true,
left = 0,
right = 0,
topAnchor = true,
bottomAnchor = false,
top = 0,
bottom = 33.33
})
element.scrollingToNext = true
element:addElement(LUI.MenuBuilder.BuildRegisteredType("h1_option_menu_titlebar", {
title_bar_text = Engine.ToUpperCase(text)
}))
element.text = element:getFirstChild():getFirstChild():getNextSibling()
menu.list:addElement(element)
return element
end
function string:truncate(length)
if (#self <= length) then
return self
end
return self:sub(1, length - 3) .. "..."
end
if (game:issingleplayer()) then
LUI.addmenubutton("main_campaign", {
index = 6,
text = "@MENU_MODS",
description = Engine.Localize("@MENU_MODS_DESC"),
callback = function()
LUI.FlowManager.RequestAddMenu(nil, "mods_menu")
end
})
end
function getmodname(path)
local name = path
game:addlocalizedstring(name, name)
local desc = Engine.Localize("LUA_MENU_MOD_DESC_DEFAULT", name)
local infofile = path .. "/info.json"
if (io.fileexists(infofile)) then
pcall(function()
local data = json.decode(io.readfile(infofile))
game:addlocalizedstring(data.description, data.description)
game:addlocalizedstring(data.author, data.author)
game:addlocalizedstring(data.version, data.version)
desc = Engine.Localize("@LUA_MENU_MOD_DESC",
data.description, data.author, data.version)
name = data.name
end)
end
return name, desc
end
LUI.MenuBuilder.registerType("mods_menu", function(a1)
local menu = LUI.MenuTemplate.new(a1, {
menu_title = "@MENU_MODS",
exclusiveController = 0,
menu_width = 400,
menu_top_indent = LUI.MenuTemplate.spMenuOffset,
showTopRightSmallBar = true
})
local modfolder = game:getloadedmod()
if (modfolder ~= "") then
local name = getmodname(modfolder)
createdivider(menu, Engine.Localize("@LUA_MENU_LOADED_MOD", name:truncate(24)))
menu:AddButton("@LUA_MENU_UNLOAD", function()
Engine.Exec("unloadmod")
end, nil, true, nil, {
desc_text = Engine.Localize("@LUA_MENU_UNLOAD_DESC")
})
end
createdivider(menu, Engine.Localize("@LUA_MENU_AVAILABLE_MODS"))
if (io.directoryexists("mods")) then
local mods = io.listfiles("mods/")
for i = 1, #mods do
if (io.directoryexists(mods[i]) and not io.directoryisempty(mods[i])) then
local name, desc = getmodname(mods[i])
if (mods[i] ~= modfolder) then
game:addlocalizedstring(name, name)
menu:AddButton(name, function()
Engine.Exec("loadmod " .. mods[i])
end, nil, true, nil, {
desc_text = desc
})
end
end
end
end
menu:AddBackButton(function(a1)
Engine.PlaySound(CoD.SFX.MenuBack)
LUI.FlowManager.RequestLeaveMenu(a1)
end)
LUI.Options.InitScrollingList(menu.list, nil)
menu:CreateBottomDivider()
menu.optionTextInfo = LUI.Options.AddOptionTextInfo(menu)
return menu
end)

View File

@ -0,0 +1,20 @@
if (game:issingleplayer()) then
return
end
if (Engine.InFrontend()) then
require("shaderdialog")
require("gamemodes")
require("no_mode_switch")
require("disable_useless_things")
end
-- defined in mp_hud/hudutils.lua
function GetGameModeName()
return Engine.Localize(Engine.TableLookup(GameTypesTable.File,
GameTypesTable.Cols.Ref, GameX.GetGameMode(), GameTypesTable.Cols.Name))
end
function NeverAllowChangeTeams()
return false
end

View File

@ -0,0 +1,17 @@
-- Disable CP
Engine.SetDvarInt("ui_enable_cp", 0)
-- Disable CP store
Engine.SetDvarInt("ui_show_store", 0)
-- Remove CoD account button
if Engine.IsMultiplayer() and CoD.IsCoDAccountRegistrationAvailableInMyRegion() then
LUI.removemenubutton("pc_controls", 4)
end
-- Remove social button
LUI.MenuBuilder.m_definitions["online_friends_widget"] = function()
return {
type = "UIElement"
}
end

View File

@ -0,0 +1,11 @@
Cac.GameModes.Data = {
Standard = {
Label = Engine.Localize("@MPUI_STANDARD_CAPS"),
Image = "h1_ui_icon_playlist_standard",
List =
{
"dm", "war", "sd", "dom", "conf", "sab", "koth", "hp", "gun",
"dd", "ctf" -- missing gamemodes from UI
}
}
}

View File

@ -0,0 +1,13 @@
LUI.MenuBuilder.m_definitions["main_choose_exe_popup_menu"] = function()
return {
type = "generic_yesno_popup",
id = "main_choose_exe_popup_menu_id",
properties = {
popup_title = Engine.Localize("@MENU_NOTICE"),
message_text = Engine.Localize("@MENU_QUIT_WARNING"),
yes_action = function()
Engine.Quit()
end
}
}
end

View File

@ -0,0 +1,25 @@
LUI.MenuBuilder.registerPopupType("ShaderCacheDialog_original", LUI.ShaderCacheDialog.new)
local function dialog(...)
if (game:sharedget("has_accepted_shader_caching") == "1") then
return LUI.ShaderCacheDialog.new(...)
end
return LUI.MenuBuilder.BuildRegisteredType("generic_yesno_popup", {
popup_title = Engine.Localize("@MENU_WARNING"),
message_text = Engine.Localize("@PLATFORM_SHADER_PRECACHE_ASK"),
yes_action = function()
game:sharedset("has_accepted_shader_caching", "1")
LUI.FlowManager.RequestAddMenu(nil, "ShaderCacheDialog_original")
end,
yes_text = Engine.Localize("@MENU_YES"),
no_text = Engine.Localize("@MENU_NO_DONT_ASK"),
no_action = function()
Engine.SetDvarInt("r_preloadShadersFrontendAllow", 0)
end,
default_focus_index = 2,
cancel_will_close = false
})
end
LUI.MenuBuilder.m_types_build["ShaderCacheDialog"] = dialog

View File

@ -0,0 +1,6 @@
if (not LUI.mp_menus) then
return
end
require("lobby")
require("serverlist")

View File

@ -0,0 +1,87 @@
local Lobby = luiglobals.Lobby
local MPLobbyOnline = LUI.mp_menus.MPLobbyOnline
function LeaveLobby(f5_arg0)
LeaveXboxLive()
if Lobby.IsInPrivateParty() == false or Lobby.IsPrivatePartyHost() then
LUI.FlowManager.RequestLeaveMenuByName("menu_xboxlive")
Engine.ExecNow("clearcontrollermap")
end
end
function menu_xboxlive(f16_arg0, f16_arg1)
local menu = LUI.MPLobbyBase.new(f16_arg0, {
menu_title = "@PLATFORM_UI_HEADER_PLAY_MP_CAPS",
memberListState = Lobby.MemberListStates.Prelobby
})
menu:setClass(LUI.MPLobbyOnline)
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:AddBarracksButton()
menu:AddPersonalizationButton()
menu:AddDepotButton()
-- kinda a weird place to do this, but it's whatever
-- add "MODS" button below depot button
local modsButton = menu:AddButton("@MENU_MODS", function(a1, a2)
LUI.FlowManager.RequestAddMenu(a1, "mods_menu", true, nil)
end)
end
local privateMatchButton = menu:AddButton("@MENU_PRIVATE_MATCH", MPLobbyOnline.OnPrivateMatch,
MPLobbyOnline.disablePrivateMatchButton)
privateMatchButton:rename("menu_xboxlive_private_match")
privateMatchButton:setDisabledRefreshRate(500)
if not Engine.IsCoreMode() then
local leaderboardButton = menu:AddButton("@LUA_MENU_LEADERBOARD", "OpLeaderboardMain")
leaderboardButton:rename("OperatorMenu_leaderboard")
end
menu:AddOptionsButton()
local natType = Lobby.GetNATType()
if natType then
local natTypeText = Engine.Localize("NETWORK_YOURNATTYPE", natType)
local properties = CoD.CreateState(nil, nil, 2, -62, CoD.AnchorTypes.BottomRight)
properties.width = 250
properties.height = CoD.TextSettings.BodyFontVeryTiny.Height
properties.font = CoD.TextSettings.BodyFontVeryTiny.Font
properties.color = luiglobals.Colors.white
properties.alpha = 0.25
local self = LUI.UIText.new(properties)
self:setText(natTypeText)
menu:addElement(self)
end
menu.isSignInMenu = true
menu:registerEventHandler("gain_focus", LUI.MPLobbyOnline.OnGainFocus)
menu:registerEventHandler("player_joined", luiglobals.Cac.PlayerJoinedEvent)
menu:registerEventHandler("exit_live_lobby", LeaveLobby)
if Engine.IsCoreMode() then
Engine.ExecNow("eliteclan_refresh", Engine.GetFirstActiveController())
end
local root = Engine.GetLuiRoot()
if (root.vltimer) then
root.vltimer:close()
end
root.vltimer = LUI.UITimer.new(4000, "vl")
root:addElement(root.vltimer)
root:registerEventHandler("vl", function()
if (Engine.GetDvarBool("virtualLobbyReady")) then
root.vltimer:close()
game:virtuallobbypresentable()
end
end)
return menu
end
LUI.MenuBuilder.m_types_build["menu_xboxlive"] = menu_xboxlive

View File

@ -0,0 +1,258 @@
local Lobby = luiglobals.Lobby
local SystemLinkJoinMenu = LUI.mp_menus.SystemLinkJoinMenu
if (not SystemLinkJoinMenu) then
return
end
local columns = {
{
offset = 40,
text = "@MENU_HOST_NAME",
dataindex = 0
},
{
offset = 500,
text = "@MENU_MAP",
dataindex = 1
},
{
offset = 700,
text = "@MENU_TYPE1",
dataindex = 3
},
{
offset = 950,
text = "@MENU_NUMPLAYERS",
dataindex = 2
},
{
offset = 1100,
text = "@MENU_PING",
dataindex = 4
},
{
offset = 10,
image = "s1_icon_locked",
customelement = function(value, offset)
return LUI.UIImage.new({
leftAnchor = true,
topAnchor = true,
height = 20,
width = 20,
left = offset,
top = 2,
material = RegisterMaterial(CoD.Material.RestrictedIcon),
alpha = value == "1" and 1 or 0,
color = {
r = 1,
b = 1,
g = 1
}
})
end,
dataindex = 5
}
}
function textlength(text, font, height)
local _, _, width = luiglobals.GetTextDimensions(text, font, height)
return width
end
function trimtext(text, font, height, maxwidth)
if (maxwidth < 0) then
return text
end
while (textlength(text, font, height) > maxwidth) do
text = text:sub(1, #text - 1)
end
return text
end
SystemLinkJoinMenu.AddHeaderButton = function(menu, f12_arg1, width)
local state = CoD.CreateState(0, f12_arg1, nil, nil, CoD.AnchorTypes.TopLeft)
state.width = width
local element = LUI.UIElement.new(state)
local button = SystemLinkJoinMenu.CreateButton("header", 24)
button:addElement(LUI.Divider.new(CoD.CreateState(nil, 0, nil, nil, CoD.AnchorTypes.TopLeftRight), 40,
LUI.Divider.Grey))
button:makeNotFocusable()
button:addElement(LUI.Divider.new(CoD.CreateState(nil, 0, nil, nil, CoD.AnchorTypes.BottomLeftRight), 40,
LUI.Divider.Grey))
button.m_eventHandlers = {}
for i = 1, #columns do
if (columns[i].text) then
SystemLinkJoinMenu.MakeText(button.textHolder, columns[i].offset, Engine.Localize(columns[i].text), nil)
elseif (columns[i].image) then
local image = LUI.UIImage.new({
leftAnchor = true,
topAnchor = true,
height = 20,
width = 20,
top = 2,
left = columns[i].offset,
material = RegisterMaterial(columns[i].image)
})
button.textHolder:addElement(image)
end
end
element:addElement(button)
menu:addElement(element)
end
SystemLinkJoinMenu.AddServerButton = function(menu, controller, index)
local button = SystemLinkJoinMenu.CreateButton(index or "header", 24)
button:makeFocusable()
button.index = index
button:addEventHandler("button_action", SystemLinkJoinMenu.OnJoinGame)
local gettext = function(i)
local text = Lobby.GetServerData(controller, index, columns[i].dataindex)
if (columns[i].customelement) then
text = columns[i].customelement(text)
end
local islast = not columns[i + 1]
local end_ = islast and 1130 or columns[i + 1].offset
local maxlength = end_ - columns[i].offset
if (maxlength < 0) then
maxlength = columns[i].offset - end_
end
if (not islast) then
maxlength = maxlength - 50
end
return trimtext(text, CoD.TextSettings.TitleFontSmall.Font, 14, maxlength)
end
for i = 1, #columns do
if (columns[i].customelement) then
local value = Lobby.GetServerData(controller, index, columns[i].dataindex)
local element = columns[i].customelement(value, columns[i].offset)
button.textHolder:addElement(element)
else
SystemLinkJoinMenu.MakeText(button.textHolder, columns[i].offset, gettext(i), luiglobals.Colors.h1.medium_grey)
end
end
menu.list:addElement(button)
return button
end
SystemLinkJoinMenu.MakeText = function(menu, f5_arg1, text, color)
local state = CoD.CreateState(f5_arg1, nil, f5_arg1 + 200, nil, CoD.AnchorTypes.Left)
state.font = CoD.TextSettings.TitleFontSmall.Font
state.top = -6
state.height = 14
state.alignment = nil
state.glow = LUI.GlowState.None
state.color = color
local el = LUI.UIText.new(state)
el:registerAnimationState("focused", {
color = luiglobals.Colors.white
})
el:registerEventHandler("focused", function(element, event)
element:animateToState("focused", 0)
end)
el:registerEventHandler("unfocused", function(element, event)
element:animateToState("default", 0)
end)
el:setText(text)
menu:addElement(el)
return el
end
function menu_systemlink_join(f19_arg0, f19_arg1)
local width = 1145
local menu = LUI.MenuTemplate.new(f19_arg0, {
menu_title = "@PLATFORM_SYSTEM_LINK_TITLE",
menu_width = width,
menu_top_indent = 20,
disableDeco = true,
spacing = 1
})
SystemLinkJoinMenu.AddHeaderButton(menu, 80, width)
SystemLinkJoinMenu.AddLowerCounter(menu, width)
SystemLinkJoinMenu.UpdateCounterText(menu, nil)
Lobby.BuildServerList(Engine.GetFirstActiveController())
local playercount = LUI.UIText.new({
rightAnchor = true,
topAnchor = true,
height = 18,
bottom = 58,
font = CoD.TextSettings.BodyFont.Font,
width = 300,
alignment = LUI.Alignment.Right,
})
menu:addElement(playercount)
local servercount = LUI.UIText.new({
rightAnchor = true,
topAnchor = true,
height = 18,
bottom = 58 - 25,
font = CoD.TextSettings.BodyFont.Font,
width = 300,
alignment = LUI.Alignment.Right,
})
menu:addElement(servercount)
menu.list:registerEventHandler(LUI.UIScrollIndicator.UpdateEvent, function(element, event)
SystemLinkJoinMenu.UpdateCounterText(menu, event)
playercount:setText(Engine.Localize("@SERVERLIST_PLAYER_COUNT", serverlist:getplayercount()))
servercount:setText(Engine.Localize("@SERVERLIST_SERVER_COUNT", serverlist:getservercount()))
end)
SystemLinkJoinMenu.UpdateGameList(menu)
menu:registerEventHandler("updateGameList", SystemLinkJoinMenu.UpdateGameList)
LUI.ButtonHelperText.ClearHelperTextObjects(menu.help, {
side = "all"
})
menu:AddHelp({
name = "add_button_helper_text",
button_ref = "button_alt1",
helper_text = Engine.Localize("@MENU_SB_TOOLTIP_BTN_REFRESH"),
side = "right",
clickable = true,
priority = -1000
}, function(f21_arg0, f21_arg1)
SystemLinkJoinMenu.RefreshServers(f21_arg0, f21_arg1, menu)
end)
menu:AddHelp({
name = "add_button_helper_text",
button_ref = "button_action",
helper_text = Engine.Localize("@MENU_JOIN_GAME1"),
side = "left",
clickable = false,
priority = -1000
}, nil, nil, true)
menu:AddBackButton()
Lobby.RefreshServerList(Engine.GetFirstActiveController())
return menu
end
LUI.MenuBuilder.m_types_build["menu_systemlink_join"] = menu_systemlink_join

View File

@ -0,0 +1,145 @@
if (game:issingleplayer() or not Engine.InFrontend()) then
return
end
function createdivider(menu, text)
local element = LUI.UIElement.new({
leftAnchor = true,
rightAnchor = true,
left = 0,
right = 0,
topAnchor = true,
bottomAnchor = false,
top = 0,
bottom = 33.33
})
element.scrollingToNext = true
element:addElement(LUI.MenuBuilder.BuildRegisteredType("h1_option_menu_titlebar", {
title_bar_text = Engine.ToUpperCase(Engine.Localize(text))
}))
menu.list:addElement(element)
end
local personalizationbutton = LUI.MPLobbyBase.AddPersonalizationButton
LUI.MPLobbyBase.AddPersonalizationButton = function(menu)
personalizationbutton(menu)
menu:AddButton("@LUA_MENU_STATS", function()
LUI.FlowManager.RequestAddMenu(nil, "stats_menu")
end)
end
LUI.MenuBuilder.registerType("stats_menu", function(a1)
local menu = LUI.MenuTemplate.new(a1, {
menu_title = Engine.ToUpperCase(Engine.Localize("@LUA_MENU_STATS")),
menu_width = luiglobals.GenericMenuDims.OptionMenuWidth
})
createdivider(menu, "@LUA_MENU_SETTINGS")
LUI.Options.CreateOptionButton(menu, "cg_unlockall_items", "@LUA_MENU_UNLOCKALL_ITEMS",
"@LUA_MENU_UNLOCKALL_ITEMS_DESC", {{
text = "@LUA_MENU_ENABLED",
value = true
}, {
text = "@LUA_MENU_DISABLED",
value = false
}}, nil, nil)
LUI.Options.CreateOptionButton(menu, "cg_unlockall_loot", "@LUA_MENU_UNLOCKALL_LOOT",
"@LUA_MENU_UNLOCKALL_LOOT_DESC", {{
text = "@LUA_MENU_ENABLED",
value = true
}, {
text = "@LUA_MENU_DISABLED",
value = false
}}, nil, nil)
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)
createdivider(menu, "@LUA_MENU_EDIT_STATS")
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
local experience = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "experience") or 0
local rank = Lobby.GetRankForXP(experience, prestige)
prestigeeditbutton(menu, function(value)
Engine.SetPlayerData(0, CoD.StatsGroup.Ranked, "prestige", tonumber(value))
end)
rankeditbutton(menu, function(value)
local rank = tonumber(value)
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
local experience = rank == 0 and 0 or Rank.GetRankMaxXP(tonumber(value) - 1, prestige)
Engine.SetPlayerData(0, CoD.StatsGroup.Ranked, "experience", experience)
end)
LUI.Options.InitScrollingList(menu.list, nil)
LUI.Options.AddOptionTextInfo(menu)
menu:AddBackButton()
return menu
end)
function prestigeeditbutton(menu, callback)
local options = {}
local max = Lobby.GetMaxPrestigeLevel()
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
for i = 0, max do
game:addlocalizedstring("LUA_MENU_" .. i, i .. "")
table.insert(options, {
text = "@" .. i,
value = i .. ""
})
end
Engine.SetDvarFromString("ui_prestige_level", prestige .. "")
LUI.Options.CreateOptionButton(menu, "ui_prestige_level", "@LUA_MENU_PRESTIGE", "@LUA_MENU_PRESTIGE_DESC", options,
nil, nil, callback)
end
function rankeditbutton(menu, callback)
local options = {}
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
local experience = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "experience") or 0
local rank = Lobby.GetRankForXP(experience, prestige)
local max = Rank.GetMaxRank(prestige)
local maxprestige = Lobby.GetMaxPrestigeLevel()
for i = 0, max do
game:addlocalizedstring("LUA_MENU_" .. i, i .. "")
table.insert(options, {
text = "@" .. (i + 1),
value = i .. ""
})
end
Engine.SetDvarFromString("ui_rank_level_", rank .. "")
return LUI.Options.CreateOptionButton(menu, "ui_rank_level_", "@LUA_MENU_RANK", "@LUA_MENU_RANK_DESC", options, nil,
nil, callback)
end
local isclasslocked = Cac.IsCustomClassLocked
Cac.IsCustomClassLocked = function(...)
if (Engine.GetDvarBool("cg_unlockall_classes")) then
return false
end
return isclasslocked(...)
end