2022-03-30 17:40:39 +02:00
|
|
|
local Dim = require("common.dimensions")
|
2021-12-10 04:07:09 +01:00
|
|
|
|
2022-03-30 17:40:39 +02:00
|
|
|
local BAR_ALPHA = 191
|
2021-12-10 04:07:09 +01:00
|
|
|
|
|
|
|
local HEADER_HEIGHT = 100
|
|
|
|
|
2022-03-30 17:40:39 +02:00
|
|
|
local animationHeaderGlowScale = 0
|
|
|
|
local animationHeaderGlowAlpha = 0
|
2021-12-10 04:07:09 +01:00
|
|
|
|
|
|
|
-- Images
|
|
|
|
local headerTitleImage = gfx.CreateSkinImage("challenge_select/skill_analyzer.png", gfx.IMAGE_GENERATE_MIPMAPS)
|
|
|
|
|
2022-03-30 17:40:39 +02:00
|
|
|
local function drawHeader()
|
|
|
|
gfx.BeginPath()
|
|
|
|
gfx.FillColor(0, 0, 0, BAR_ALPHA)
|
|
|
|
gfx.Rect(0, 0, Dim.design.width, HEADER_HEIGHT)
|
|
|
|
gfx.Fill()
|
2021-12-10 04:07:09 +01:00
|
|
|
gfx.ClosePath()
|
|
|
|
|
|
|
|
local headerImageWidth, headerImageHeight = gfx.ImageSize(headerTitleImage)
|
2022-03-30 17:40:39 +02:00
|
|
|
gfx.ImageRect((Dim.design.width - headerImageWidth) / 2, (HEADER_HEIGHT - headerImageHeight) / 2 - 12, -- asset png is not centered on the y axis
|
|
|
|
headerImageWidth, headerImageHeight, headerTitleImage, 1, 0)
|
2021-12-10 04:07:09 +01:00
|
|
|
end
|
|
|
|
|
2022-03-30 17:40:39 +02:00
|
|
|
local function progressTransitions(deltatime)
|
2021-12-10 04:07:09 +01:00
|
|
|
-- HEADER GLOW ANIMATION
|
|
|
|
if animationHeaderGlowScale < 1 then
|
|
|
|
animationHeaderGlowScale = animationHeaderGlowScale + deltatime / 1 -- transition should last for that time in seconds
|
|
|
|
else
|
|
|
|
animationHeaderGlowScale = 0
|
|
|
|
end
|
|
|
|
|
|
|
|
if animationHeaderGlowScale < 0.5 then
|
2022-03-30 17:40:39 +02:00
|
|
|
animationHeaderGlowAlpha = animationHeaderGlowScale * 2
|
2021-12-10 04:07:09 +01:00
|
|
|
else
|
2022-03-30 17:40:39 +02:00
|
|
|
animationHeaderGlowAlpha = 1 - ((animationHeaderGlowScale - 0.5) * 2)
|
2021-12-10 04:07:09 +01:00
|
|
|
end
|
2022-03-30 17:40:39 +02:00
|
|
|
animationHeaderGlowAlpha = animationHeaderGlowAlpha * 0.4
|
2021-12-10 04:07:09 +01:00
|
|
|
end
|
|
|
|
|
2022-03-30 17:40:39 +02:00
|
|
|
local function draw(deltatime)
|
2021-12-10 04:07:09 +01:00
|
|
|
gfx.Save()
|
|
|
|
|
2022-03-30 17:40:39 +02:00
|
|
|
gfx.ResetTransform()
|
|
|
|
|
|
|
|
Dim.updateResolution()
|
|
|
|
|
|
|
|
Dim.transformToScreenSpace()
|
|
|
|
|
|
|
|
gfx.LoadSkinFont("NotoSans-Regular.ttf")
|
|
|
|
|
|
|
|
drawHeader()
|
|
|
|
|
|
|
|
progressTransitions(deltatime)
|
2021-12-10 04:07:09 +01:00
|
|
|
|
|
|
|
gfx.Restore()
|
|
|
|
end
|
|
|
|
|
2022-03-30 17:40:39 +02:00
|
|
|
return {draw = draw}
|