2023-04-09 13:11:54 -04:00
|
|
|
LUI.MenuBuilder.registerType("achievements_menu", function(root, controller)
|
2023-09-11 12:05:22 -04:00
|
|
|
local menuwidth = 500
|
2023-04-09 13:11:54 -04:00
|
|
|
local menu = LUI.MenuTemplate.new(root, {
|
|
|
|
menu_title = "@LUA_MENU_ACHIEVEMENTS",
|
|
|
|
exclusiveController = 0,
|
|
|
|
menu_width = menuwidth,
|
|
|
|
menu_top_indent = LUI.MenuTemplate.spMenuOffset,
|
|
|
|
showTopRightSmallBar = true,
|
|
|
|
uppercase_title = true
|
|
|
|
})
|
|
|
|
|
2023-09-11 12:05:22 -04:00
|
|
|
local black_state = CoD.CreateState(nil, nil, nil, nil, CoD.AnchorTypes.All)
|
|
|
|
black_state.red = 0
|
|
|
|
black_state.blue = 0
|
|
|
|
black_state.green = 0
|
|
|
|
black_state.alpha = 0
|
|
|
|
black_state.left = -100
|
|
|
|
black_state.right = 100
|
|
|
|
black_state.top = -100
|
|
|
|
black_state.bottom = 100
|
|
|
|
|
|
|
|
local black = LUI.UIImage.new(black_state)
|
|
|
|
black:setPriority(-1000)
|
|
|
|
|
|
|
|
black:registerAnimationState("BlackScreen", {
|
|
|
|
alpha = 1
|
|
|
|
})
|
|
|
|
|
|
|
|
black:registerAnimationState("Faded", {
|
|
|
|
alpha = 0
|
|
|
|
})
|
|
|
|
|
|
|
|
menu:addElement(black)
|
|
|
|
|
|
|
|
local currentbackground = nil
|
|
|
|
local changebackground = function(background, isvideobg)
|
|
|
|
if (currentbackground == background) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
currentbackground = background
|
|
|
|
|
|
|
|
if (isvideobg) then
|
|
|
|
PersistentBackground.ChangeBackground(nil, background)
|
|
|
|
else
|
|
|
|
PersistentBackground.ChangeBackground(background, "")
|
|
|
|
PersistentBackground.ChangeBackground(background, nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
black:animateInSequence( {
|
|
|
|
{
|
|
|
|
"BlackScreen",
|
|
|
|
0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Faded",
|
|
|
|
500
|
|
|
|
}
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
local itemheight = 80
|
|
|
|
local itemwidth = menuwidth
|
2023-04-09 13:11:54 -04:00
|
|
|
local itemspacing = 10
|
|
|
|
local maxrowelements = 1
|
|
|
|
|
|
|
|
local rowelements = 0
|
|
|
|
local newrow = function()
|
|
|
|
local currentrow = LUI.UIElement.new({
|
|
|
|
topAnchor = true,
|
|
|
|
leftAnchor = true,
|
2023-09-11 12:05:22 -04:00
|
|
|
width = itemheight * maxrowelements,
|
|
|
|
height = itemheight,
|
2023-04-09 13:11:54 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
menu.list.currentrow = currentrow
|
|
|
|
menu.list:addElement(currentrow)
|
|
|
|
menu.list.currentrow:makeFocusable()
|
|
|
|
end
|
|
|
|
|
|
|
|
newrow()
|
|
|
|
|
|
|
|
local addelement = function(element)
|
|
|
|
local container = LUI.UIElement.new({
|
|
|
|
topAnchor = true,
|
|
|
|
leftAnchor = true,
|
2023-09-11 12:05:22 -04:00
|
|
|
width = itemheight,
|
|
|
|
height = itemheight,
|
|
|
|
left = rowelements * (itemheight + itemspacing)
|
2023-04-09 13:11:54 -04:00
|
|
|
})
|
|
|
|
container:addElement(element)
|
|
|
|
container:makeFocusable()
|
|
|
|
menu.list.currentrow:addElement(container)
|
|
|
|
rowelements = rowelements + 1
|
|
|
|
if (rowelements == maxrowelements) then
|
|
|
|
newrow()
|
|
|
|
rowelements = 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local achievementtable = achievements.table()
|
|
|
|
local unlockcount = 0
|
|
|
|
for i = 0, #achievementtable do
|
|
|
|
if (achievementtable[i]) then
|
|
|
|
unlockcount = unlockcount + 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for i = 0, achievements.count() - 1 do
|
2023-04-10 21:20:27 -04:00
|
|
|
local btnbg = LUI.UIImage.new({
|
2023-04-09 13:11:54 -04:00
|
|
|
topAnchor = true,
|
|
|
|
leftAnchor = true,
|
2023-09-11 12:05:22 -04:00
|
|
|
width = itemwidth,
|
|
|
|
height = itemheight,
|
2023-04-09 13:11:54 -04:00
|
|
|
material = RegisterMaterial("h2_btn_unfocused")
|
|
|
|
})
|
|
|
|
|
2023-04-10 21:20:27 -04:00
|
|
|
btnbg:setup9SliceImage()
|
2023-04-09 13:11:54 -04:00
|
|
|
|
2023-04-10 21:20:27 -04:00
|
|
|
btnbg:registerAnimationState("locked", {
|
2023-04-09 13:11:54 -04:00
|
|
|
material = RegisterMaterial("h2_btn_unfocused_locked")
|
|
|
|
})
|
|
|
|
|
2023-04-10 21:20:27 -04:00
|
|
|
local raritynames = {
|
|
|
|
"common",
|
|
|
|
"rare",
|
|
|
|
"legendary",
|
|
|
|
"epic",
|
|
|
|
}
|
|
|
|
|
|
|
|
local rarityname = raritynames[achievements.getrarity(i) + 1]
|
|
|
|
|
|
|
|
local raritystrip = LUI.UIImage.new({
|
2023-04-09 13:11:54 -04:00
|
|
|
topAnchor = true,
|
|
|
|
leftAnchor = true,
|
2023-04-10 21:20:27 -04:00
|
|
|
width = 10,
|
2023-09-11 12:05:22 -04:00
|
|
|
height = itemheight,
|
2023-04-10 21:20:27 -04:00
|
|
|
material = RegisterMaterial("depot_button_rarity_strip_" .. rarityname)
|
2023-04-09 13:11:54 -04:00
|
|
|
})
|
|
|
|
|
2023-04-10 21:20:27 -04:00
|
|
|
raritystrip:registerAnimationState("hide", {
|
2023-04-09 13:11:54 -04:00
|
|
|
alpha = 0
|
|
|
|
})
|
|
|
|
|
2023-04-10 21:20:27 -04:00
|
|
|
raritystrip:registerAnimationState("show", {
|
2023-04-09 13:11:54 -04:00
|
|
|
alpha = 1
|
|
|
|
})
|
|
|
|
|
2023-04-10 21:20:27 -04:00
|
|
|
raritystrip:setup9SliceImage()
|
2023-04-09 13:11:54 -04:00
|
|
|
|
|
|
|
local glow = LUI.UIImage.new({
|
|
|
|
topAnchor = true,
|
|
|
|
leftAnchor = true,
|
2023-09-11 12:05:22 -04:00
|
|
|
width = itemwidth,
|
|
|
|
height = itemheight,
|
2023-04-10 21:20:27 -04:00
|
|
|
material = RegisterMaterial("depot_button_rarity_glow_" .. rarityname)
|
2023-04-09 13:11:54 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
glow:registerAnimationState("hide", {
|
|
|
|
alpha = 0
|
|
|
|
})
|
|
|
|
|
|
|
|
glow:registerAnimationState("show", {
|
|
|
|
alpha = 1
|
|
|
|
})
|
|
|
|
|
2023-04-10 21:20:27 -04:00
|
|
|
local glow2 = LUI.UIImage.new({
|
2023-04-09 13:11:54 -04:00
|
|
|
topAnchor = true,
|
|
|
|
leftAnchor = true,
|
2023-09-11 12:05:22 -04:00
|
|
|
width = itemwidth,
|
|
|
|
height = itemheight,
|
2023-04-10 21:20:27 -04:00
|
|
|
material = RegisterMaterial("depot_button_rarity_glow_" .. rarityname)
|
2023-04-09 13:11:54 -04:00
|
|
|
})
|
|
|
|
|
2023-04-10 21:20:27 -04:00
|
|
|
glow2:registerAnimationState("hide", {
|
2023-04-09 13:11:54 -04:00
|
|
|
alpha = 0
|
|
|
|
})
|
|
|
|
|
2023-04-10 21:20:27 -04:00
|
|
|
glow2:registerAnimationState("show", {
|
2023-04-09 13:11:54 -04:00
|
|
|
alpha = 1
|
|
|
|
})
|
|
|
|
|
|
|
|
glow:animateToState("hide")
|
2023-04-10 21:20:27 -04:00
|
|
|
glow2:animateToState("hide")
|
2023-04-09 13:11:54 -04:00
|
|
|
|
|
|
|
local achievementcontainer = LUI.UIElement.new({
|
|
|
|
topAnchor = true,
|
|
|
|
leftAnchor = true,
|
2023-09-11 12:05:22 -04:00
|
|
|
width = itemwidth,
|
|
|
|
height = itemheight,
|
2023-04-09 13:11:54 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
local image = LUI.UIImage.new({
|
|
|
|
topAnchor = true,
|
|
|
|
leftAnchor = true,
|
|
|
|
top = itemspacing / 2,
|
2023-04-10 21:20:27 -04:00
|
|
|
left = itemspacing / 2 + 10,
|
2023-09-11 12:05:22 -04:00
|
|
|
width = itemheight - itemspacing,
|
|
|
|
height = itemheight - itemspacing,
|
2023-04-09 13:11:54 -04:00
|
|
|
material = RegisterMaterial("trophy_" .. i)
|
|
|
|
})
|
|
|
|
|
|
|
|
image:registerAnimationState("locked", {
|
|
|
|
topAnchor = true,
|
|
|
|
leftAnchor = true,
|
|
|
|
top = itemspacing / 2 + 15,
|
2023-04-10 21:20:27 -04:00
|
|
|
left = itemspacing / 2 + 15 + 10,
|
2023-09-11 12:05:22 -04:00
|
|
|
width = itemheight - itemspacing - 30,
|
|
|
|
height = itemheight - itemspacing - 30,
|
2023-04-09 13:11:54 -04:00
|
|
|
material = RegisterMaterial("icon_lock_mini")
|
|
|
|
})
|
|
|
|
|
2023-09-11 12:05:22 -04:00
|
|
|
local textwidth = itemwidth - itemheight - itemspacing * 2
|
2023-04-09 13:11:54 -04:00
|
|
|
local title = LUI.UIText.new({
|
|
|
|
topAnchor = true,
|
|
|
|
leftAnchor = true,
|
|
|
|
top = itemspacing + 5,
|
2023-09-11 12:05:22 -04:00
|
|
|
left = itemheight + 5 + 10,
|
2023-04-09 13:11:54 -04:00
|
|
|
color = {
|
|
|
|
r = 0.7,
|
|
|
|
g = 0.7,
|
|
|
|
b = 0.7,
|
|
|
|
},
|
|
|
|
width = textwidth,
|
|
|
|
font = CoD.TextSettings.Font23.Font,
|
|
|
|
height = CoD.TextSettings.Font23.Height
|
|
|
|
})
|
|
|
|
|
|
|
|
local desc = LUI.UIText.new({
|
|
|
|
topAnchor = true,
|
|
|
|
leftAnchor = true,
|
|
|
|
top = itemspacing + CoD.TextSettings.Font23.Height + 10,
|
2023-09-11 12:05:22 -04:00
|
|
|
left = itemheight + 5 + 10,
|
2023-04-09 13:11:54 -04:00
|
|
|
width = textwidth,
|
|
|
|
alignment = LUI.Alignment.Left,
|
|
|
|
color = {
|
|
|
|
r = 0.7,
|
|
|
|
g = 0.7,
|
|
|
|
b = 0.7,
|
|
|
|
},
|
|
|
|
font = CoD.TextSettings.Font21.Font,
|
|
|
|
height = CoD.TextSettings.Font21.Height
|
|
|
|
})
|
|
|
|
|
|
|
|
local focusedtext = {
|
|
|
|
color = {r = 1, g = 1, b = 1}
|
|
|
|
}
|
|
|
|
desc:registerAnimationState("focused", focusedtext)
|
|
|
|
title:registerAnimationState("focused", focusedtext)
|
|
|
|
|
|
|
|
title:setText(Engine.ToUpperCase(Engine.Localize(achievements.getname(i))))
|
|
|
|
desc:setText(Engine.Localize(achievements.getdetails(i)))
|
|
|
|
|
|
|
|
achievementcontainer:setHandleMouse(true)
|
|
|
|
local locked = not achievementtable[i]
|
|
|
|
|
2023-04-10 21:20:27 -04:00
|
|
|
if (locked) then
|
|
|
|
raritystrip:animateToState("hide")
|
|
|
|
end
|
|
|
|
|
2023-09-11 12:05:22 -04:00
|
|
|
local background = achievements.getbackground(i)
|
2023-04-09 13:11:54 -04:00
|
|
|
achievementcontainer:registerEventHandler("mouseenter", function()
|
|
|
|
Engine.PlaySound(CoD.SFX.MouseOver)
|
|
|
|
|
2023-09-11 15:36:41 -04:00
|
|
|
if (background ~= nil and achievementtable[i]) then
|
2023-09-11 12:05:22 -04:00
|
|
|
changebackground(background, false)
|
|
|
|
else
|
|
|
|
changebackground("sp_menus_bg_regular", true)
|
|
|
|
end
|
|
|
|
|
2023-04-09 13:11:54 -04:00
|
|
|
if (locked) then
|
2023-04-10 21:20:27 -04:00
|
|
|
btnbg:setImage(RegisterMaterial("h2_btn_focused_locked"))
|
2023-04-09 13:11:54 -04:00
|
|
|
else
|
2023-04-10 21:20:27 -04:00
|
|
|
raritystrip:animateToState("show")
|
2023-04-09 13:11:54 -04:00
|
|
|
title:animateToState("focused")
|
|
|
|
desc:animateToState("focused")
|
|
|
|
glow:animateToState("show")
|
2023-04-10 21:20:27 -04:00
|
|
|
glow2:animateToState("show")
|
2023-04-09 13:11:54 -04:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
achievementcontainer:registerEventHandler("mouseleave", function()
|
|
|
|
if (locked) then
|
2023-04-10 21:20:27 -04:00
|
|
|
btnbg:setImage(RegisterMaterial("h2_btn_unfocused_locked"))
|
2023-04-09 13:11:54 -04:00
|
|
|
else
|
|
|
|
title:animateToState("default")
|
|
|
|
desc:animateToState("default")
|
|
|
|
glow:animateToState("hide")
|
2023-04-10 21:20:27 -04:00
|
|
|
glow2:animateToState("hide")
|
2023-04-09 13:11:54 -04:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2023-04-10 21:20:27 -04:00
|
|
|
achievementcontainer:addElement(btnbg)
|
2023-04-09 13:11:54 -04:00
|
|
|
achievementcontainer:addElement(glow)
|
2023-04-10 21:20:27 -04:00
|
|
|
achievementcontainer:addElement(glow2)
|
|
|
|
achievementcontainer:addElement(raritystrip)
|
2023-04-09 13:11:54 -04:00
|
|
|
achievementcontainer:addElement(image)
|
|
|
|
achievementcontainer:addElement(title)
|
|
|
|
achievementcontainer:addElement(desc)
|
|
|
|
|
|
|
|
if (locked) then
|
2023-04-10 21:20:27 -04:00
|
|
|
btnbg:animateToState("locked")
|
2023-04-09 13:11:54 -04:00
|
|
|
image:animateToState("locked")
|
|
|
|
desc:setText("")
|
|
|
|
end
|
|
|
|
|
|
|
|
addelement(achievementcontainer)
|
|
|
|
end
|
|
|
|
|
|
|
|
if (rowelements == 0) then
|
|
|
|
menu.list.currentrow:close()
|
|
|
|
end
|
|
|
|
|
|
|
|
LUI.Options.InitScrollingList(menu.list, nil, {
|
|
|
|
rows = 5
|
|
|
|
})
|
|
|
|
|
|
|
|
local createprogressbar = function()
|
2023-09-11 12:05:22 -04:00
|
|
|
local barwidth = itemwidth + 17
|
2023-04-09 13:11:54 -04:00
|
|
|
local progressbar = LUI.UIElement.new({
|
|
|
|
bottomAnchor = true,
|
|
|
|
leftAnchor = true,
|
|
|
|
width = barwidth,
|
|
|
|
bottom = -90,
|
|
|
|
height = 15
|
|
|
|
})
|
|
|
|
|
|
|
|
local bg = LUI.UIImage.new({
|
|
|
|
topAnchor = true,
|
|
|
|
leftAnchor = true,
|
|
|
|
rightAnchor = true,
|
|
|
|
bottomAnchor = true,
|
|
|
|
alpha = 0.55,
|
|
|
|
color = Colors.grey_14,
|
|
|
|
})
|
|
|
|
|
|
|
|
local bar = LUI.UIImage.new({
|
|
|
|
topAnchor = true,
|
|
|
|
leftAnchor = true,
|
|
|
|
bottomAnchor = true,
|
|
|
|
width = 0,
|
|
|
|
material = RegisterMaterial("h1_ui_progressbar_green")
|
|
|
|
})
|
|
|
|
|
|
|
|
progressbar.setprogress = function(fraction)
|
|
|
|
bar:registerAnimationState("progress", {
|
|
|
|
topAnchor = true,
|
|
|
|
leftAnchor = true,
|
|
|
|
bottomAnchor = true,
|
|
|
|
width = fraction * (barwidth),
|
|
|
|
})
|
|
|
|
|
|
|
|
bar:animateToState("progress", 300)
|
|
|
|
end
|
|
|
|
|
|
|
|
progressbar.setprogress(unlockcount / achievements.count())
|
|
|
|
|
|
|
|
progressbar:addElement(bg)
|
|
|
|
progressbar:addElement(bar)
|
|
|
|
progressbar:addElement(LUI.DecoFrame.new(nil, LUI.DecoFrame.Grey))
|
|
|
|
|
|
|
|
return progressbar
|
|
|
|
end
|
|
|
|
|
|
|
|
menu:addElement(createprogressbar())
|
|
|
|
menu:AddBackButton()
|
|
|
|
|
|
|
|
return menu
|
|
|
|
end)
|