Fallback fonts + localizations (#262)
* Fallback fonts + localizations * cannot find address on h1 [skip] * fix build * fix language menu * small fix * improved regular font * format LUI stuff [skip ci] Co-authored-by: m <mjkzyalt@gmail.com>
This commit is contained in:
@ -1,272 +1,272 @@
|
||||
if (game:issingleplayer() or Engine.InFrontend()) then
|
||||
return
|
||||
return
|
||||
end
|
||||
|
||||
local container = LUI.UIVerticalList.new({
|
||||
topAnchor = true,
|
||||
rightAnchor = true,
|
||||
top = 20,
|
||||
right = 200,
|
||||
width = 200,
|
||||
spacing = 5,
|
||||
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 = history or {}
|
||||
if (history[userid] ~= nil) then
|
||||
return false
|
||||
end
|
||||
|
||||
history[userid] = true
|
||||
game:ontimeout(function()
|
||||
history[userid] = nil
|
||||
end, 15000)
|
||||
history[userid] = true
|
||||
game:ontimeout(function()
|
||||
history[userid] = nil
|
||||
end, 15000)
|
||||
|
||||
return true
|
||||
return true
|
||||
end
|
||||
|
||||
function truncatename(name, length)
|
||||
if (#name <= length - 3) then
|
||||
return name
|
||||
end
|
||||
if (#name <= length - 3) then
|
||||
return name
|
||||
end
|
||||
|
||||
return name:sub(1, length - 3) .. "..."
|
||||
return name:sub(1, length - 3) .. "..."
|
||||
end
|
||||
|
||||
function addrequest(request)
|
||||
if (not canasktojoin(request.userid)) then
|
||||
return
|
||||
end
|
||||
if (not canasktojoin(request.userid)) then
|
||||
return
|
||||
end
|
||||
|
||||
if (container.temp) then
|
||||
container:removeElement(container.temp)
|
||||
container.temp = nil
|
||||
end
|
||||
if (container.temp) then
|
||||
container:removeElement(container.temp)
|
||||
container.temp = nil
|
||||
end
|
||||
|
||||
local invite = LUI.UIElement.new({
|
||||
leftAnchor = true,
|
||||
rightAnchor = true,
|
||||
height = 75,
|
||||
})
|
||||
local invite = LUI.UIElement.new({
|
||||
leftAnchor = true,
|
||||
rightAnchor = true,
|
||||
height = 75
|
||||
})
|
||||
|
||||
invite:registerAnimationState("move_in", {
|
||||
leftAnchor = true,
|
||||
height = 75,
|
||||
width = 200,
|
||||
left = -220,
|
||||
})
|
||||
invite:registerAnimationState("move_in", {
|
||||
leftAnchor = true,
|
||||
height = 75,
|
||||
width = 200,
|
||||
left = -220
|
||||
})
|
||||
|
||||
invite:animateToState("move_in", 100)
|
||||
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 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"),
|
||||
})
|
||||
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)
|
||||
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 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 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
|
||||
})
|
||||
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))
|
||||
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 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 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)
|
||||
local center = LUI.UIText.new({
|
||||
rightAnchor = true,
|
||||
height = 12,
|
||||
width = 85,
|
||||
top = -6.5,
|
||||
alignment = LUI.Alignment.Center,
|
||||
font = CoD.TextSettings.BodyFontBold.Font
|
||||
})
|
||||
|
||||
return button
|
||||
end
|
||||
button:setup9SliceImage(10, 5, 0.25, 0.12)
|
||||
center:setText(text)
|
||||
button:addElement(center)
|
||||
|
||||
buttons:addElement(createbutton("[F1] Accept", true))
|
||||
buttons:addElement(createbutton("[F2] Deny"))
|
||||
return button
|
||||
end
|
||||
|
||||
local fadeouttime = 50
|
||||
local timeout = 10 * 1000 - fadeouttime
|
||||
buttons:addElement(createbutton("[F1] Accept", true))
|
||||
buttons:addElement(createbutton("[F2] Deny"))
|
||||
|
||||
local function close()
|
||||
container:processEvent({
|
||||
name = "update_navigation",
|
||||
dispatchToChildren = true
|
||||
})
|
||||
invite:animateToState("fade_out", fadeouttime)
|
||||
invite:addElement(LUI.UITimer.new(fadeouttime + 50, "remove"))
|
||||
local fadeouttime = 50
|
||||
local timeout = 10 * 1000 - fadeouttime
|
||||
|
||||
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
|
||||
local function close()
|
||||
container:processEvent({
|
||||
name = "update_navigation",
|
||||
dispatchToChildren = true
|
||||
})
|
||||
invite:animateToState("fade_out", fadeouttime)
|
||||
invite:addElement(LUI.UITimer.new(fadeouttime + 50, "remove"))
|
||||
|
||||
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: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
|
||||
|
||||
invite:addElement(LUI.UITimer.new(timeout, "end_invite"))
|
||||
invite:registerEventHandler("end_invite", function()
|
||||
close()
|
||||
discord.respond(request.userid, discord.reply.ignore)
|
||||
end)
|
||||
buttons:registerEventHandler("keydown_", function(element, event)
|
||||
if (event.key == "F1") then
|
||||
close()
|
||||
discord.respond(request.userid, discord.reply.yes)
|
||||
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,
|
||||
}
|
||||
})
|
||||
if (event.key == "F2") then
|
||||
close()
|
||||
discord.respond(request.userid, discord.reply.no)
|
||||
end
|
||||
end)
|
||||
|
||||
bar:registerAnimationState("closing", {
|
||||
bottomAnchor = true,
|
||||
leftAnchor = true,
|
||||
bottom = -3,
|
||||
left = 3,
|
||||
width = 0,
|
||||
height = 2,
|
||||
})
|
||||
invite:registerAnimationState("fade_out", {
|
||||
leftAnchor = true,
|
||||
rightAnchor = true,
|
||||
height = 75,
|
||||
alpha = 0,
|
||||
left = 0
|
||||
})
|
||||
|
||||
bar:animateToState("closing", timeout)
|
||||
invite:addElement(LUI.UITimer.new(timeout, "end_invite"))
|
||||
invite:registerEventHandler("end_invite", function()
|
||||
close()
|
||||
discord.respond(request.userid, discord.reply.ignore)
|
||||
end)
|
||||
|
||||
avatar:registerEventHandler("update", function()
|
||||
local avatarmaterial = discord.getavatarmaterial(request.userid)
|
||||
avatar:setImage(RegisterMaterial(avatarmaterial))
|
||||
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
|
||||
}
|
||||
})
|
||||
|
||||
avatar:addElement(LUI.UITimer.new(100, "update"))
|
||||
bar:registerAnimationState("closing", {
|
||||
bottomAnchor = true,
|
||||
leftAnchor = true,
|
||||
bottom = -3,
|
||||
left = 3,
|
||||
width = 0,
|
||||
height = 2
|
||||
})
|
||||
|
||||
invite:addElement(background)
|
||||
invite:addElement(bar)
|
||||
invite:addElement(border)
|
||||
invite:addElement(padding)
|
||||
padding:addElement(username)
|
||||
padding:addElement(avatar)
|
||||
padding:addElement(buttons)
|
||||
bar:animateToState("closing", timeout)
|
||||
|
||||
container:addElement(invite)
|
||||
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()
|
||||
local first = container:getFirstChild()
|
||||
|
||||
if (not first) then
|
||||
return
|
||||
end
|
||||
if (not first) then
|
||||
return
|
||||
end
|
||||
|
||||
first:processEvent({
|
||||
name = "keydown_",
|
||||
key = event.key
|
||||
})
|
||||
first:processEvent({
|
||||
name = "keydown_",
|
||||
key = event.key
|
||||
})
|
||||
end)
|
||||
|
||||
LUI.roots.UIRoot0:registerEventHandler("discord_join_request", function(element, event)
|
||||
addrequest(event.request)
|
||||
addrequest(event.request)
|
||||
end)
|
||||
|
||||
LUI.roots.UIRoot0:addElement(container)
|
||||
|
@ -4,195 +4,190 @@ 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
|
||||
})
|
||||
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_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("minimap_off", {
|
||||
left = 0,
|
||||
top = 0,
|
||||
height = barheight,
|
||||
width = 70,
|
||||
leftAnchor = true,
|
||||
topAnchor = true
|
||||
})
|
||||
|
||||
infobar:registerAnimationState("hud_on", {
|
||||
alpha = 1
|
||||
})
|
||||
infobar:registerAnimationState("hud_on", {
|
||||
alpha = 1
|
||||
})
|
||||
|
||||
infobar:registerAnimationState("hud_off", {
|
||||
alpha = 0
|
||||
})
|
||||
infobar:registerAnimationState("hud_off", {
|
||||
alpha = 0
|
||||
})
|
||||
|
||||
return infobar
|
||||
return infobar
|
||||
end
|
||||
|
||||
function updateinfobarvisibility()
|
||||
local root = Engine.GetLuiRoot()
|
||||
local menus = root:AnyActiveMenusInStack()
|
||||
local infobar = root.infobar
|
||||
local root = Engine.GetLuiRoot()
|
||||
local menus = root:AnyActiveMenusInStack()
|
||||
local infobar = root.infobar
|
||||
|
||||
if (not infobar) then
|
||||
return
|
||||
end
|
||||
if (not infobar) then
|
||||
return
|
||||
end
|
||||
|
||||
if (menus or Game.InKillCam()) then
|
||||
infobar:animateToState("hud_off")
|
||||
else
|
||||
infobar:animateToState("hud_on")
|
||||
end
|
||||
if (menus or Game.InKillCam()) then
|
||||
infobar:animateToState("hud_off")
|
||||
else
|
||||
infobar:animateToState("hud_on")
|
||||
end
|
||||
|
||||
local validstates = {
|
||||
"hud_on",
|
||||
"active",
|
||||
"nosignal",
|
||||
"scrambled"
|
||||
}
|
||||
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
|
||||
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
|
||||
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_fps")) then
|
||||
infobar:addElement(infoelement({
|
||||
label = Engine.Localize("@MPHUD_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
|
||||
if (Engine.GetDvarBool("cg_infobar_ping")) then
|
||||
infobar:addElement(infoelement({
|
||||
label = Engine.Localize("@MPHUD_LATENCY"),
|
||||
getvalue = function()
|
||||
return game:getping() .. Engine.Localize("@MPHUD_LATENCY_MS")
|
||||
end,
|
||||
width = 115,
|
||||
interval = 100
|
||||
}))
|
||||
end
|
||||
|
||||
updateinfobarvisibility()
|
||||
updateinfobarvisibility()
|
||||
end
|
||||
|
||||
function infoelement(data)
|
||||
local container = LUI.UIElement.new({
|
||||
bottomAnchor = true,
|
||||
leftAnchor = true,
|
||||
topAnchor = true,
|
||||
width = data.width,
|
||||
left = elementoffset
|
||||
})
|
||||
local container = LUI.UIElement.new({
|
||||
bottomAnchor = true,
|
||||
leftAnchor = true,
|
||||
topAnchor = true,
|
||||
width = data.width,
|
||||
left = elementoffset
|
||||
})
|
||||
|
||||
elementoffset = elementoffset + data.width + 10
|
||||
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 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 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
|
||||
}
|
||||
})
|
||||
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)
|
||||
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
|
||||
}
|
||||
})
|
||||
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)
|
||||
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)
|
||||
container:addElement(background)
|
||||
container:addElement(label)
|
||||
container:addElement(value)
|
||||
|
||||
return container
|
||||
return container
|
||||
end
|
||||
|
||||
local updatehudvisibility = mphud.updateHudVisibility
|
||||
mphud.updateHudVisibility = function(a1, a2)
|
||||
updatehudvisibility(a1, a2)
|
||||
updateinfobarvisibility()
|
||||
updatehudvisibility(a1, a2)
|
||||
updateinfobarvisibility()
|
||||
end
|
||||
|
||||
LUI.onmenuopen("mp_hud", function(hud)
|
||||
if (Engine.InFrontend()) then
|
||||
return
|
||||
end
|
||||
if (Engine.InFrontend()) then
|
||||
return
|
||||
end
|
||||
|
||||
local infobar = createinfobar()
|
||||
local root = Engine.GetLuiRoot()
|
||||
root.infobar = infobar
|
||||
root.hud = hud
|
||||
populateinfobar(infobar)
|
||||
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:registerEventHandler("update_hud_infobar_settings", function()
|
||||
infobar:removeAllChildren()
|
||||
populateinfobar(infobar)
|
||||
end)
|
||||
|
||||
root:processEvent({
|
||||
name = "update_hud_infobar_settings"
|
||||
})
|
||||
root:processEvent({
|
||||
name = "update_hud_infobar_settings"
|
||||
})
|
||||
|
||||
hud.static.scalable:addElement(infobar)
|
||||
hud.static.scalable:addElement(infobar)
|
||||
end)
|
||||
|
@ -1,133 +1,121 @@
|
||||
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
|
||||
})
|
||||
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
|
||||
}))
|
||||
element.scrollingToNext = true
|
||||
element:addElement(LUI.MenuBuilder.BuildRegisteredType("h1_option_menu_titlebar", {
|
||||
title_bar_text = text
|
||||
}))
|
||||
|
||||
menu.list:addElement(element)
|
||||
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)
|
||||
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
|
||||
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)))
|
||||
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"))
|
||||
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
|
||||
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)
|
||||
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_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.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)
|
||||
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
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
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")
|
||||
createdivider(menu, Engine.Localize("@LUA_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_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.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)
|
||||
LUI.Options.InitScrollingList(menu.list, nil)
|
||||
end
|
||||
|
@ -1,32 +1,32 @@
|
||||
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
|
||||
})
|
||||
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.scrollingToNext = true
|
||||
element:addElement(LUI.MenuBuilder.BuildRegisteredType("h1_option_menu_titlebar", {
|
||||
title_bar_text = Engine.ToUpperCase(text)
|
||||
}))
|
||||
|
||||
element.text = element:getFirstChild():getFirstChild():getNextSibling()
|
||||
element.text = element:getFirstChild():getFirstChild():getNextSibling()
|
||||
|
||||
menu.list:addElement(element)
|
||||
return element
|
||||
menu.list:addElement(element)
|
||||
return element
|
||||
end
|
||||
|
||||
function string:truncate(length)
|
||||
if (#self <= length) then
|
||||
return self
|
||||
end
|
||||
if (#self <= length) then
|
||||
return self
|
||||
end
|
||||
|
||||
return self:sub(1, length - 3) .. "..."
|
||||
return self:sub(1, length - 3) .. "..."
|
||||
end
|
||||
|
||||
if (game:issingleplayer()) then
|
||||
@ -41,75 +41,75 @@ if (game:issingleplayer()) then
|
||||
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"
|
||||
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
|
||||
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
|
||||
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 menu = LUI.MenuTemplate.new(a1, {
|
||||
menu_title = "@MENU_MODS",
|
||||
exclusiveController = 0,
|
||||
menu_width = 400,
|
||||
menu_top_indent = LUI.MenuTemplate.spMenuOffset,
|
||||
showTopRightSmallBar = true,
|
||||
uppercase_title = true
|
||||
})
|
||||
|
||||
local modfolder = game:getloadedmod()
|
||||
if (modfolder ~= "") then
|
||||
local name = getmodname(modfolder)
|
||||
createdivider(menu, Engine.Localize("@LUA_MENU_LOADED_MOD", name:truncate(24)))
|
||||
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
|
||||
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"))
|
||||
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 (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)
|
||||
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
|
||||
|
||||
LUI.Options.InitScrollingList(menu.list, nil)
|
||||
menu:CreateBottomDivider()
|
||||
menu.optionTextInfo = LUI.Options.AddOptionTextInfo(menu)
|
||||
menu:AddBackButton(function(a1)
|
||||
Engine.PlaySound(CoD.SFX.MenuBack)
|
||||
LUI.FlowManager.RequestLeaveMenu(a1)
|
||||
end)
|
||||
|
||||
return menu
|
||||
LUI.Options.InitScrollingList(menu.list, nil)
|
||||
menu:CreateBottomDivider()
|
||||
menu.optionTextInfo = LUI.Options.AddOptionTextInfo(menu)
|
||||
|
||||
return menu
|
||||
end)
|
||||
|
@ -1,20 +1,22 @@
|
||||
require("language")
|
||||
|
||||
if (game:issingleplayer()) then
|
||||
return
|
||||
return
|
||||
end
|
||||
|
||||
if (Engine.InFrontend()) then
|
||||
require("shader_dialog")
|
||||
require("gamemodes")
|
||||
require("no_mode_switch")
|
||||
require("disable_useless_things")
|
||||
require("shader_dialog")
|
||||
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))
|
||||
return Engine.Localize(Engine.TableLookup(GameTypesTable.File, GameTypesTable.Cols.Ref, GameX.GetGameMode(),
|
||||
GameTypesTable.Cols.Name))
|
||||
end
|
||||
|
||||
function NeverAllowChangeTeams()
|
||||
return false
|
||||
return false
|
||||
end
|
||||
|
97
data/cdata/ui_scripts/patches/language.lua
Normal file
97
data/cdata/ui_scripts/patches/language.lua
Normal file
@ -0,0 +1,97 @@
|
||||
local available_languages = {"english", "english_safe", "french", "german", "italian", "polish", "portuguese",
|
||||
"russian", "spanish", "simplified_chinese", "traditional_chinese", "japanese_partial",
|
||||
"korean"}
|
||||
local current_language = "english"
|
||||
|
||||
LUI.UIButtonText.IsOffsetedLanguage = function()
|
||||
return false
|
||||
end
|
||||
|
||||
function get_current_language()
|
||||
current_language = game:getcurrentgamelanguage()
|
||||
end
|
||||
|
||||
function set_language(value)
|
||||
local file_path = "players2/default/language"
|
||||
local file = io.open(file_path, "w")
|
||||
file:write(value)
|
||||
file:close()
|
||||
end
|
||||
|
||||
function does_zone_folder_exists(language)
|
||||
return io.directoryexists("zone/" .. language)
|
||||
end
|
||||
|
||||
get_current_language()
|
||||
|
||||
LUI.addmenubutton("pc_controls", {
|
||||
index = 4,
|
||||
text = "@MENU_LANGUAGE",
|
||||
description = Engine.Localize("@LUA_MENU_CHOOSE_LANGUAGE"),
|
||||
callback = function()
|
||||
LUI.FlowManager.RequestAddMenu(nil, "choose_language_menu")
|
||||
end
|
||||
})
|
||||
|
||||
LUI.MenuBuilder.registerType("choose_language_menu", function(a1)
|
||||
local menu = LUI.MenuTemplate.new(a1, {
|
||||
menu_title = "@LUA_MENU_CHOOSE_LANGUAGE",
|
||||
menu_list_divider_top_offset = -(LUI.H1MenuTab.tabChangeHoldingElementHeight + H1MenuDims.spacing),
|
||||
uppercase_title = true
|
||||
})
|
||||
|
||||
function createdivider(menu, text)
|
||||
local element = LUI.UIElement.new({
|
||||
leftAnchor = true,
|
||||
rightAnchor = false,
|
||||
left = 10,
|
||||
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
|
||||
|
||||
createdivider(menu, "^2" .. Engine.Localize("@LUA_MENU_DOWNLOAD") .. ": ^7https://docs.h1.gg/languages")
|
||||
|
||||
for i = 1, #available_languages do
|
||||
if does_zone_folder_exists(available_languages[i]) then
|
||||
menu:AddButton(Engine.Localize(string.format("MENU_%s", available_languages[i])), function()
|
||||
LUI.yesnopopup({
|
||||
title = Engine.Localize("@MENU_NOTICE"),
|
||||
text = Engine.Localize("MENU_" .. current_language) .. " → " ..
|
||||
Engine.Localize("MENU_" .. available_languages[i]) .. "\n\n" ..
|
||||
Engine.Localize("@LUA_MENU_CONFIRM_LANGUAGE") .. " " ..
|
||||
Engine.Localize("@MENU_APPLY_LANGUAGE_SETTINGS"),
|
||||
callback = function(result)
|
||||
if (result) then
|
||||
set_language(available_languages[i])
|
||||
updater.relaunch()
|
||||
else
|
||||
LUI.FlowManager.RequestLeaveMenu(popup)
|
||||
end
|
||||
end
|
||||
})
|
||||
end, available_languages[i] == current_language, true, nil, {
|
||||
desc_text = Engine.Localize("LOCALE_" .. (available_languages[i]))
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
LUI.Options.InitScrollingList(menu.list, nil, {
|
||||
rows = 12
|
||||
})
|
||||
|
||||
LUI.Options.AddOptionTextInfo(menu)
|
||||
menu:AddBackButton()
|
||||
|
||||
return menu
|
||||
end)
|
@ -1,25 +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
|
||||
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
|
||||
})
|
||||
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
|
||||
|
@ -2,257 +2,251 @@ local Lobby = luiglobals.Lobby
|
||||
local SystemLinkJoinMenu = LUI.mp_menus.SystemLinkJoinMenu
|
||||
|
||||
if (not SystemLinkJoinMenu) then
|
||||
return
|
||||
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
|
||||
}
|
||||
}
|
||||
local columns = {{
|
||||
offset = 40,
|
||||
text = "@MENU_HOST_NAME",
|
||||
dataindex = 0
|
||||
}, {
|
||||
offset = 500,
|
||||
text = "@MENU_MAP",
|
||||
dataindex = 1
|
||||
}, {
|
||||
offset = 725,
|
||||
text = "@MENU_TYPE1",
|
||||
dataindex = 3
|
||||
}, {
|
||||
offset = 920,
|
||||
text = "@MENU_NUMPLAYERS",
|
||||
dataindex = 2
|
||||
}, {
|
||||
offset = 1070,
|
||||
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
|
||||
local _, _, width = luiglobals.GetTextDimensions(text, font, height)
|
||||
return width
|
||||
end
|
||||
|
||||
function trimtext(text, font, height, maxwidth)
|
||||
if (maxwidth < 0) then
|
||||
return text
|
||||
end
|
||||
if (maxwidth < 0) then
|
||||
return text
|
||||
end
|
||||
|
||||
while (textlength(text, font, height) > maxwidth) do
|
||||
text = text:sub(1, #text - 1)
|
||||
end
|
||||
while (textlength(text, font, height) > maxwidth) do
|
||||
text = text:sub(1, #text - 1)
|
||||
end
|
||||
|
||||
return text
|
||||
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)
|
||||
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: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 = {}
|
||||
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
|
||||
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)
|
||||
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 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 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
|
||||
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 (maxlength < 0) then
|
||||
maxlength = columns[i].offset - end_
|
||||
end
|
||||
|
||||
if (not islast) then
|
||||
maxlength = maxlength - 50
|
||||
end
|
||||
if (not islast) then
|
||||
maxlength = maxlength - 50
|
||||
end
|
||||
|
||||
return trimtext(text, CoD.TextSettings.TitleFontSmall.Font, 14, maxlength)
|
||||
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
|
||||
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
|
||||
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 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
|
||||
})
|
||||
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("focused", function(element, event)
|
||||
element:animateToState("focused", 0)
|
||||
end)
|
||||
|
||||
el:registerEventHandler("unfocused", function(element, event)
|
||||
element:animateToState("default", 0)
|
||||
end)
|
||||
el:registerEventHandler("unfocused", function(element, event)
|
||||
element:animateToState("default", 0)
|
||||
end)
|
||||
|
||||
el:setText(text)
|
||||
menu:addElement(el)
|
||||
el:setText(text)
|
||||
menu:addElement(el)
|
||||
|
||||
return el
|
||||
return el
|
||||
end
|
||||
|
||||
function menu_systemlink_join(f19_arg0, f19_arg1)
|
||||
local width = 1145
|
||||
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
|
||||
})
|
||||
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())
|
||||
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 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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
SystemLinkJoinMenu.UpdateGameList(menu)
|
||||
menu:registerEventHandler("updateGameList", SystemLinkJoinMenu.UpdateGameList)
|
||||
|
||||
LUI.ButtonHelperText.ClearHelperTextObjects(menu.help, {
|
||||
side = "all"
|
||||
})
|
||||
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_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: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()
|
||||
menu:AddBackButton()
|
||||
|
||||
Lobby.RefreshServerList(Engine.GetFirstActiveController())
|
||||
Lobby.RefreshServerList(Engine.GetFirstActiveController())
|
||||
|
||||
return menu
|
||||
return menu
|
||||
end
|
||||
|
||||
LUI.MenuBuilder.m_types_build["menu_systemlink_join"] = menu_systemlink_join
|
||||
|
@ -1,145 +1,145 @@
|
||||
if (game:issingleplayer() or not Engine.InFrontend()) then
|
||||
return
|
||||
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
|
||||
})
|
||||
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))
|
||||
}))
|
||||
element.scrollingToNext = true
|
||||
element:addElement(LUI.MenuBuilder.BuildRegisteredType("h1_option_menu_titlebar", {
|
||||
title_bar_text = Engine.ToUpperCase(Engine.Localize(text))
|
||||
}))
|
||||
|
||||
menu.list:addElement(element)
|
||||
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)
|
||||
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
|
||||
})
|
||||
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")
|
||||
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_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_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)
|
||||
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")
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
Engine.SetPlayerData(0, CoD.StatsGroup.Ranked, "experience", experience)
|
||||
end)
|
||||
|
||||
LUI.Options.InitScrollingList(menu.list, nil)
|
||||
LUI.Options.AddOptionTextInfo(menu)
|
||||
LUI.Options.InitScrollingList(menu.list, nil)
|
||||
LUI.Options.AddOptionTextInfo(menu)
|
||||
|
||||
menu:AddBackButton()
|
||||
menu:AddBackButton()
|
||||
|
||||
return menu
|
||||
return menu
|
||||
end)
|
||||
|
||||
function prestigeeditbutton(menu, callback)
|
||||
local options = {}
|
||||
local max = Lobby.GetMaxPrestigeLevel()
|
||||
local prestige = Engine.GetPlayerData(0, CoD.StatsGroup.Ranked, "prestige") or 0
|
||||
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 .. "")
|
||||
for i = 0, max do
|
||||
game:addlocalizedstring("LUA_MENU_" .. i, i .. "")
|
||||
|
||||
table.insert(options, {
|
||||
text = "@" .. i,
|
||||
value = i .. ""
|
||||
})
|
||||
end
|
||||
table.insert(options, {
|
||||
text = "@" .. i,
|
||||
value = i .. ""
|
||||
})
|
||||
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,
|
||||
nil, nil, callback)
|
||||
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 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()
|
||||
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 .. "")
|
||||
for i = 0, max do
|
||||
game:addlocalizedstring("LUA_MENU_" .. i, i .. "")
|
||||
|
||||
table.insert(options, {
|
||||
text = "@" .. (i + 1),
|
||||
value = i .. ""
|
||||
})
|
||||
end
|
||||
table.insert(options, {
|
||||
text = "@" .. (i + 1),
|
||||
value = i .. ""
|
||||
})
|
||||
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,
|
||||
nil, callback)
|
||||
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
|
||||
if (Engine.GetDvarBool("cg_unlockall_classes")) then
|
||||
return false
|
||||
end
|
||||
|
||||
return isclasslocked(...)
|
||||
return isclasslocked(...)
|
||||
end
|
||||
|
Reference in New Issue
Block a user