Add motd & featured tab + fixes
This commit is contained in:
@ -1,2 +1 @@
|
||||
require("credits")
|
||||
require("mainmenu")
|
||||
|
@ -1,4 +0,0 @@
|
||||
LUI.onmenuopen("main_campaign", function(menu)
|
||||
local headertext = menu:getFirstDescendentById("header_text")
|
||||
headertext:setText("H2-MOD")
|
||||
end)
|
2
data/cdata/ui_scripts/motd/__init__.lua
Normal file
2
data/cdata/ui_scripts/motd/__init__.lua
Normal file
@ -0,0 +1,2 @@
|
||||
require("motd")
|
||||
require("featured")
|
493
data/cdata/ui_scripts/motd/featured.lua
Normal file
493
data/cdata/ui_scripts/motd/featured.lua
Normal file
@ -0,0 +1,493 @@
|
||||
motd.getfeaturedtabtitle = function(index)
|
||||
return motd.getfeaturedtab(index).tab_title or ""
|
||||
end
|
||||
|
||||
local animmsfull = 150
|
||||
local animms = animmsfull / 2
|
||||
|
||||
LUI.onmenuopen("main_campaign", function(menu)
|
||||
if (mods.getloaded() ~= nil or motd.getnumfeaturedtabs() <= 0) then
|
||||
return
|
||||
end
|
||||
|
||||
local left = 866
|
||||
local featuredcontainer = LUI.UIElement.new({
|
||||
leftAnchor = true,
|
||||
topAnchor = true,
|
||||
left = left,
|
||||
top = 420,
|
||||
})
|
||||
|
||||
featuredcontainer:registerAnimationState("hide", {
|
||||
leftAnchor = true,
|
||||
topAnchor = true,
|
||||
left = left,
|
||||
top = 570,
|
||||
})
|
||||
|
||||
featuredcontainer:registerAnimationState("show", {
|
||||
leftAnchor = true,
|
||||
topAnchor = true,
|
||||
left = left,
|
||||
top = 420,
|
||||
})
|
||||
|
||||
local featuredstencil = LUI.UIStencilText.new({
|
||||
leftAnchor = true,
|
||||
topAnchor = true,
|
||||
height = 200,
|
||||
width = GenericMenuDims.menu_width_standard + (10 + 12) * 2,
|
||||
})
|
||||
|
||||
local featured = LUI.UIElement.new({
|
||||
left = 20,
|
||||
leftAnchor = true,
|
||||
topAnchor = true,
|
||||
bottomAnchor = true,
|
||||
rightAnchor = true
|
||||
})
|
||||
|
||||
local arrowcontainer = LUI.UIElement.new({
|
||||
leftAnchor = true,
|
||||
topAnchor = true,
|
||||
bottomAnchor = true,
|
||||
rightAnchor = true
|
||||
})
|
||||
|
||||
arrowcontainer:registerAnimationState("hide", {
|
||||
alpha = 0
|
||||
})
|
||||
|
||||
arrowcontainer:registerAnimationState("show", {
|
||||
alpha = 1
|
||||
})
|
||||
|
||||
featured:addElement(arrowcontainer)
|
||||
|
||||
featuredstencil:registerAnimationState("hide", {
|
||||
leftAnchor = true,
|
||||
topAnchor = true,
|
||||
height = GenericButtonSettings.Styles.FlatButton.height + 2,
|
||||
width = GenericMenuDims.menu_width_standard + (10 + 12) * 2,
|
||||
})
|
||||
|
||||
local istopmost = function()
|
||||
return LUI.FlowManager.IsMenuTopmost(Engine.GetLuiRoot(), "main_campaign")
|
||||
end
|
||||
|
||||
featuredstencil:registerAnimationState("show", {
|
||||
leftAnchor = true,
|
||||
topAnchor = true,
|
||||
height = 200,
|
||||
width = GenericMenuDims.menu_width_standard + (10 + 12) * 2,
|
||||
})
|
||||
|
||||
local hoverelem = LUI.UIElement.new({
|
||||
leftAnchor = true,
|
||||
topAnchor = true,
|
||||
top = -10,
|
||||
height = 150 + GenericButtonSettings.Styles.FlatButton.height + 2 + 10,
|
||||
width = GenericMenuDims.menu_width_standard + 50,
|
||||
left = -25
|
||||
})
|
||||
|
||||
local header = LUI.UIElement.new({
|
||||
topAnchor = true,
|
||||
leftAnchor = true,
|
||||
width = GenericMenuDims.menu_width_standard,
|
||||
height = GenericButtonSettings.Styles.FlatButton.height,
|
||||
})
|
||||
|
||||
local headerbg = LUI.UIImage.new({
|
||||
topAnchor = true,
|
||||
leftAnchor = true,
|
||||
bottomAnchor = true,
|
||||
rightAnchor = true,
|
||||
alpha = 0.55,
|
||||
color = Colors.grey_14,
|
||||
material = RegisterMaterial("white")
|
||||
})
|
||||
|
||||
local headerbutton = LUI.UIImage.new({
|
||||
leftAnchor = true,
|
||||
topAnchor = true,
|
||||
height = 10,
|
||||
width = 10,
|
||||
top = 10.5,
|
||||
left = 10,
|
||||
zRot = -90,
|
||||
color = {
|
||||
r = 0.6,
|
||||
g = 0.6,
|
||||
b = 0.6,
|
||||
},
|
||||
material = RegisterMaterial("widg_lobby_arrow")
|
||||
})
|
||||
|
||||
headerbutton:registerEventHandler("mouseenter", function()
|
||||
if (not istopmost()) then
|
||||
return
|
||||
end
|
||||
|
||||
Engine.PlaySound(CoD.SFX.MouseOver)
|
||||
headerbutton:animateToState("focused")
|
||||
end)
|
||||
|
||||
headerbutton:registerEventHandler("mouseleave", function()
|
||||
headerbutton:animateToState("unfocused")
|
||||
end)
|
||||
|
||||
headerbutton:registerAnimationState("down", {
|
||||
zRot = -90
|
||||
})
|
||||
|
||||
headerbutton:registerAnimationState("right", {
|
||||
zRot = 0
|
||||
})
|
||||
|
||||
headerbutton:registerAnimationState("focused", {
|
||||
color = Colors.h2.yellow
|
||||
})
|
||||
|
||||
headerbutton:registerAnimationState("unfocused", {
|
||||
color = {
|
||||
r = 0.6,
|
||||
g = 0.6,
|
||||
b = 0.6,
|
||||
}
|
||||
})
|
||||
|
||||
local tabcount = motd.getnumfeaturedtabs()
|
||||
|
||||
headerbutton:setHandleMouse(true)
|
||||
local minimized = false
|
||||
headerbutton:registerEventHandler("leftmousedown", function()
|
||||
minimized = not minimized
|
||||
|
||||
if (minimized) then
|
||||
featuredstencil:animateToState("hide", animms)
|
||||
featuredcontainer:animateToState("hide", animms)
|
||||
headerbutton:animateToState("right", animms)
|
||||
arrowcontainer:animateToState("hide", animms)
|
||||
else
|
||||
featuredstencil:animateToState("show", animms)
|
||||
featuredcontainer:animateToState("show", animms)
|
||||
headerbutton:animateToState("down", animms)
|
||||
|
||||
if (tabcount > 1) then
|
||||
arrowcontainer:animateToState("show", animms)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
header:addElement(headerbg)
|
||||
header:addElement(headerbutton)
|
||||
|
||||
local headertext = LUI.UIText.new({
|
||||
leftAnchor = true,
|
||||
left = GenericButtonSettings.Styles.FlatButton.text_padding_with_content + 10,
|
||||
top = -CoD.TextSettings.Font19.Height / 2 + 1.5,
|
||||
font = CoD.TextSettings.Font19.Font,
|
||||
height = CoD.TextSettings.Font19.Height
|
||||
})
|
||||
|
||||
local rightoffset = -15
|
||||
local pips = {}
|
||||
|
||||
for i = 1, tabcount do
|
||||
local pipmat = RegisterMaterial("h1_ui_featured_pip_unfocused")
|
||||
local ratio = Engine.GetMaterialAspectRatio(pipmat)
|
||||
local height = 14
|
||||
|
||||
local pip = LUI.UIImage.new({
|
||||
topAnchor = true,
|
||||
rightAnchor = true,
|
||||
top = GenericButtonSettings.Styles.FlatButton.height / 2 - height / 2,
|
||||
width = ratio * height,
|
||||
height = height,
|
||||
material = RegisterMaterial("h1_ui_featured_pip_unfocused"),
|
||||
right = rightoffset
|
||||
})
|
||||
|
||||
pip:setHandleMouse(true)
|
||||
pip:registerEventHandler("mouseenter", function()
|
||||
if (not istopmost()) then
|
||||
return
|
||||
end
|
||||
|
||||
Engine.PlaySound(CoD.SFX.MouseOver)
|
||||
end)
|
||||
|
||||
pip:registerAnimationState("focused", {
|
||||
material = RegisterMaterial("h2_ui_featured_pip_focused"),
|
||||
})
|
||||
|
||||
pip:registerAnimationState("unfocused", {
|
||||
material = RegisterMaterial("h1_ui_featured_pip_unfocused"),
|
||||
})
|
||||
|
||||
table.insert(pips, pip)
|
||||
header:addElement(pip)
|
||||
rightoffset = rightoffset - height
|
||||
end
|
||||
|
||||
pips[#pips]:animateToState("focused")
|
||||
|
||||
headertext:setText(Engine.ToUpperCase(Engine.Localize("@LUA_MENU_FEATURED")))
|
||||
|
||||
local content = LUI.UIElement.new({
|
||||
topAnchor = true,
|
||||
leftAnchor = true,
|
||||
top = GenericButtonSettings.Styles.FlatButton.height + 3,
|
||||
width = GenericMenuDims.menu_width_standard,
|
||||
height = 150,
|
||||
})
|
||||
|
||||
local stencil = LUI.UIStencilText.new({
|
||||
topAnchor = true,
|
||||
leftAnchor = true,
|
||||
bottomAnchor = true,
|
||||
rightAnchor = true,
|
||||
left = 1,
|
||||
})
|
||||
|
||||
local imagelist = LUI.UIHorizontalList.new( {
|
||||
left = 0,
|
||||
leftAnchor = true,
|
||||
width = (GenericMenuDims.menu_width_standard) * tabcount,
|
||||
height = 150,
|
||||
spacing = 0
|
||||
} )
|
||||
|
||||
stencil:addElement(imagelist)
|
||||
|
||||
local contentborder = LUI.UIImage.new({
|
||||
topAnchor = true,
|
||||
leftAnchor = true,
|
||||
bottomAnchor = true,
|
||||
rightAnchor = true,
|
||||
alpha = 0,
|
||||
material = RegisterMaterial("h2_ui_btn_focused_stroke_square")
|
||||
})
|
||||
|
||||
contentborder:registerAnimationState("unfocused", {
|
||||
alpha = 0
|
||||
})
|
||||
|
||||
contentborder:registerAnimationState("focused", {
|
||||
alpha = 1
|
||||
})
|
||||
|
||||
contentborder:setup9SliceImage()
|
||||
|
||||
for i = 1, tabcount do
|
||||
local panel = LUI.UIElement.new({
|
||||
topAnchor = true,
|
||||
leftAnchor = true,
|
||||
bottomAnchor = true,
|
||||
width = GenericMenuDims.menu_width_standard,
|
||||
})
|
||||
|
||||
local text = LUI.UIText.new({
|
||||
bottomAnchor = true,
|
||||
leftAnchor = true,
|
||||
rightAnchor = true,
|
||||
alignment = LUI.Alignment.Center,
|
||||
bottom = (-CoD.TextSettings.Font21.Height / 2) + 2,
|
||||
height = CoD.TextSettings.Font21.Height,
|
||||
font = CoD.TextSettings.Font21.Font,
|
||||
})
|
||||
|
||||
local textbg = LUI.UIImage.new({
|
||||
bottomAnchor = true,
|
||||
leftAnchor = true,
|
||||
rightAnchor = true,
|
||||
height = CoD.TextSettings.Font21.Height * 2,
|
||||
alpha = 0.75,
|
||||
material = RegisterMaterial("black")
|
||||
})
|
||||
|
||||
text:setText(motd.getfeaturedtabtitle(i - 1))
|
||||
|
||||
local material = RegisterMaterial("featured_panel_thumbnail_" .. i)
|
||||
local ratio = Engine.GetMaterialAspectRatio(material)
|
||||
local width = GenericMenuDims.menu_width_standard
|
||||
local height = width / ratio
|
||||
|
||||
local contentimage = LUI.UIImage.new({
|
||||
topAnchor = true,
|
||||
leftAnchor = true,
|
||||
width = width,
|
||||
height = height,
|
||||
material = material,
|
||||
})
|
||||
|
||||
panel:addElement(contentimage)
|
||||
panel:addElement(textbg)
|
||||
panel:addElement(text)
|
||||
imagelist:addElement(panel)
|
||||
end
|
||||
|
||||
local focusindex = 0
|
||||
local shiftright = function()
|
||||
local prevfocus = focusindex
|
||||
focusindex = (focusindex + 1) % tabcount
|
||||
|
||||
pips[#pips - (prevfocus)]:animateToState("unfocused")
|
||||
pips[#pips - (focusindex)]:animateToState("focused")
|
||||
|
||||
imagelist:registerAnimationState("move", {
|
||||
leftAnchor = true,
|
||||
left = (focusindex) * -GenericMenuDims.menu_width_standard
|
||||
})
|
||||
|
||||
imagelist:animateToState("move", animmsfull)
|
||||
end
|
||||
|
||||
local shiftleft = function()
|
||||
local prevfocus = focusindex
|
||||
focusindex = (focusindex - 1) % tabcount
|
||||
|
||||
pips[#pips - (prevfocus)]:animateToState("unfocused")
|
||||
pips[#pips - (focusindex)]:animateToState("focused")
|
||||
|
||||
imagelist:registerAnimationState("move", {
|
||||
leftAnchor = true,
|
||||
left = (focusindex) * -GenericMenuDims.menu_width_standard
|
||||
})
|
||||
|
||||
imagelist:animateToState("move", animmsfull)
|
||||
end
|
||||
|
||||
local autoscrolltimer = LUI.UITimer.new(3000, "autoscroll")
|
||||
featured:addElement(autoscrolltimer)
|
||||
featured:registerEventHandler("autoscroll", function()
|
||||
if (not minimized) then
|
||||
shiftright()
|
||||
end
|
||||
end)
|
||||
|
||||
local addarrows = function()
|
||||
local arrowmat = RegisterMaterial("h1_prestige_leftright_arrow")
|
||||
local arrowratio = Engine.GetMaterialAspectRatio(arrowmat)
|
||||
local height = 20
|
||||
local width = arrowratio * height
|
||||
|
||||
local arrowleft = LUI.UIImage.new({
|
||||
leftAnchor = true,
|
||||
left = -width - 10,
|
||||
top = -10,
|
||||
height = height,
|
||||
width = width,
|
||||
alpha = 0,
|
||||
material = RegisterMaterial("h1_prestige_leftright_arrow")
|
||||
})
|
||||
|
||||
local arrowright = LUI.UIImage.new({
|
||||
rightAnchor = true,
|
||||
right = 0,
|
||||
top = -10,
|
||||
height = height,
|
||||
width = width,
|
||||
zRot = 180,
|
||||
alpha = 0,
|
||||
material = RegisterMaterial("h1_prestige_leftright_arrow")
|
||||
})
|
||||
|
||||
arrowleft:registerAnimationState("focused", {
|
||||
alpha = 1
|
||||
})
|
||||
|
||||
arrowleft:registerAnimationState("unfocused", {
|
||||
alpha = 0
|
||||
})
|
||||
|
||||
arrowright:registerAnimationState("focused", {
|
||||
alpha = 1
|
||||
})
|
||||
|
||||
arrowright:registerAnimationState("unfocused", {
|
||||
alpha = 0
|
||||
})
|
||||
|
||||
arrowleft:setHandleMouse(true)
|
||||
arrowright:setHandleMouse(true)
|
||||
|
||||
arrowleft:registerEventHandler("leftmousedown", shiftleft)
|
||||
arrowright:registerEventHandler("leftmousedown", shiftright)
|
||||
|
||||
arrowcontainer:addElement(arrowleft)
|
||||
arrowcontainer:addElement(arrowright)
|
||||
|
||||
featured.arrowleft = arrowleft
|
||||
featured.arrowright = arrowright
|
||||
end
|
||||
|
||||
addarrows()
|
||||
|
||||
if (tabcount <= 1) then
|
||||
arrowcontainer:animateToState("hide")
|
||||
end
|
||||
|
||||
featured:registerEventHandler("focused", function()
|
||||
contentborder:animateToState("focused", animms)
|
||||
featured.arrowleft:animateToState("focused", animms)
|
||||
featured.arrowright:animateToState("focused", animms)
|
||||
LUI.UITimer.Stop(autoscrolltimer)
|
||||
end)
|
||||
|
||||
|
||||
featured:registerEventHandler("unfocused", function()
|
||||
contentborder:animateToState("unfocused", animms)
|
||||
featured.arrowleft:animateToState("unfocused", animms)
|
||||
featured.arrowright:animateToState("unfocused", animms)
|
||||
LUI.UITimer.Reset(autoscrolltimer)
|
||||
end)
|
||||
|
||||
hoverelem:setHandleMouseMove(true)
|
||||
|
||||
hoverelem:registerEventHandler("mouseenter", function()
|
||||
if (not istopmost()) then
|
||||
return
|
||||
end
|
||||
|
||||
featured:processEvent({
|
||||
name = "focused",
|
||||
dispatchChildren = true
|
||||
})
|
||||
end)
|
||||
|
||||
hoverelem:registerEventHandler("mouseleave", function()
|
||||
featured:processEvent({
|
||||
name = "unfocused",
|
||||
dispatchChildren = true
|
||||
})
|
||||
end)
|
||||
|
||||
header:addElement(headertext)
|
||||
header:addElement(LUI.DecoFrame.new(nil, LUI.DecoFrame.Grey))
|
||||
|
||||
featured:addElement(header)
|
||||
|
||||
content:addElement(stencil)
|
||||
content:addElement(LUI.DecoFrame.new(nil, LUI.DecoFrame.Grey))
|
||||
content:addElement(contentborder)
|
||||
|
||||
content:setHandleMouse(true)
|
||||
content:registerEventHandler("leftmousedown", function()
|
||||
local data = motd.getfeaturedtab(focusindex)
|
||||
data.popup_image = "featured_panel_" .. (focusindex + 1)
|
||||
LUI.FlowManager.RequestPopupMenu( nil, "motd_main", true, nil, false, {
|
||||
popupDataQueue = {data}
|
||||
})
|
||||
end)
|
||||
|
||||
featured:addElement(content)
|
||||
featured:addElement(hoverelem)
|
||||
|
||||
featuredstencil:addElement(featured)
|
||||
featuredcontainer:addElement(featuredstencil)
|
||||
|
||||
menu:addElement(featuredcontainer)
|
||||
end)
|
||||
|
76
data/cdata/ui_scripts/motd/motd.lua
Normal file
76
data/cdata/ui_scripts/motd/motd.lua
Normal file
@ -0,0 +1,76 @@
|
||||
require("LUI.common_menus.MarketingComms")
|
||||
require("LUI.common_menus.MarketingPopup")
|
||||
LUI.CustomMarketingPopups = {ShowDepotOnboardingPopupIfPossible = function() end}
|
||||
|
||||
LUI.onmenuopen("main_campaign", function(menu)
|
||||
if (not motd.hasseentoday()) then
|
||||
motd.sethasseentoday()
|
||||
local data = motd.getmotd()
|
||||
LUI.FlowManager.RequestPopupMenu( self, "motd_main", true, nil, false, {
|
||||
popupDataQueue = {data}
|
||||
})
|
||||
end
|
||||
end)
|
||||
|
||||
local function makelink(element, link)
|
||||
element:setHandleMouseMove(true)
|
||||
element:setHandleMouseButton(true)
|
||||
element:registerAnimationState("focused", {
|
||||
color = {
|
||||
r = 1,
|
||||
g = 1,
|
||||
b = 1
|
||||
}
|
||||
})
|
||||
|
||||
local entered = false
|
||||
element:registerEventHandler("mouseenter", function()
|
||||
if (not entered) then
|
||||
Engine.PlaySound(CoD.SFX.MouseOver)
|
||||
entered = true
|
||||
end
|
||||
|
||||
element:animateToState("focused")
|
||||
end)
|
||||
|
||||
element:registerEventHandler("mouseleave", function()
|
||||
entered = false
|
||||
element:animateToState("default")
|
||||
end)
|
||||
|
||||
element:registerEventHandler("leftmousedown", function()
|
||||
Engine.PlaySound(CoD.SFX.MouseClick)
|
||||
game:openlink(link)
|
||||
end)
|
||||
end
|
||||
|
||||
local marketingbase = LUI.MarketingPopup.Base
|
||||
LUI.MarketingPopup.Base = function(a1, data, a3)
|
||||
local element = marketingbase(a1, data, a3)
|
||||
|
||||
local blur = element:getFirstDescendentById("generic_popup_screen_overlay_blur"):getNextSibling()
|
||||
local parent = blur:getFirstChild():getNextSibling():getNextSibling():getNextSibling()
|
||||
local image = parent:getFirstChild()
|
||||
image:close()
|
||||
|
||||
local state = LUI.DeepCopy(image:getAnimationStateInC("default"))
|
||||
local imagecontainer = LUI.UIStencilText.new(state)
|
||||
local material = RegisterMaterial(data.image)
|
||||
|
||||
local ratio = Engine.GetMaterialAspectRatio(material)
|
||||
local width = 525
|
||||
local height = width / ratio
|
||||
|
||||
local image = LUI.UIImage.new({
|
||||
leftAnchor = true,
|
||||
topAnchor = true,
|
||||
width = width,
|
||||
height = height,
|
||||
material = material
|
||||
})
|
||||
|
||||
imagecontainer:addElement(image)
|
||||
parent:addElement(imagecontainer)
|
||||
|
||||
return element
|
||||
end
|
Reference in New Issue
Block a user