2021-11-17 22:28:26 +01:00
|
|
|
local Easing = require("common.easings");
|
|
|
|
local Footer = require("components.footer");
|
2021-07-25 20:10:06 +02:00
|
|
|
|
2021-11-17 22:28:26 +01:00
|
|
|
local VolforceWindow = require("components.volforceWindow")
|
2021-07-25 20:10:06 +02:00
|
|
|
|
2021-08-18 17:29:54 +02:00
|
|
|
local resx, resy = game.GetResolution()
|
|
|
|
local desw = 1080
|
|
|
|
local desh = 1920
|
2021-07-25 20:10:06 +02:00
|
|
|
local scale = 1
|
|
|
|
|
2021-10-23 01:27:44 +02:00
|
|
|
local bgSfxPlayed = false;
|
|
|
|
|
2021-08-18 17:29:54 +02:00
|
|
|
local BAR_ALPHA = 191;
|
|
|
|
local HEADER_HEIGHT = 100
|
2021-07-25 20:10:06 +02:00
|
|
|
|
2021-08-18 17:29:54 +02:00
|
|
|
local backgroundImage = gfx.CreateSkinImage("challenge_result/bg.png", 0);
|
|
|
|
local playerInfoOverlayBgImage = gfx.CreateSkinImage("challenge_result/player_info_overlay_bg.png", 0);
|
2021-07-25 20:10:06 +02:00
|
|
|
|
2021-08-18 19:05:37 +02:00
|
|
|
local headerTitleImage = gfx.CreateSkinImage("challenge_result/header/title.png", 0);
|
|
|
|
|
2021-11-17 22:28:26 +01:00
|
|
|
local username = game.GetSkinSetting("username");
|
2021-10-25 21:39:16 +02:00
|
|
|
local appealCardImage = gfx.CreateSkinImage("crew/appeal_card.png", 0);
|
2021-08-18 19:05:37 +02:00
|
|
|
local danBadgeImage = gfx.CreateSkinImage("dan/inf.png", 0);
|
2021-10-25 09:53:50 +02:00
|
|
|
local crewImage = gfx.CreateSkinImage("crew/portrait.png", 0);
|
2021-08-18 19:05:37 +02:00
|
|
|
|
2021-08-18 20:22:57 +02:00
|
|
|
local irHeartbeatRequested = false;
|
2021-11-17 22:28:26 +01:00
|
|
|
local IRserverName = "";
|
2021-07-25 20:10:06 +02:00
|
|
|
|
2021-10-23 01:27:44 +02:00
|
|
|
-- AUDIO
|
|
|
|
game.LoadSkinSample("challenge_result.wav")
|
|
|
|
|
2021-08-18 17:29:54 +02:00
|
|
|
function resetLayoutInformation()
|
|
|
|
resx, resy = game.GetResolution()
|
|
|
|
desw = 1080
|
|
|
|
desh = 1920
|
|
|
|
scale = resx / desw
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
|
2021-10-23 01:27:44 +02:00
|
|
|
local function handleSfx()
|
|
|
|
if not bgSfxPlayed then
|
|
|
|
game.PlaySample("challenge_result.wav", true)
|
|
|
|
bgSfxPlayed = true
|
|
|
|
end
|
2021-11-17 22:28:26 +01:00
|
|
|
if game.GetButton(game.BUTTON_STA) then
|
|
|
|
game.StopSample("challenge_result.wav")
|
|
|
|
end
|
|
|
|
if game.GetButton(game.BUTTON_BCK) then
|
|
|
|
game.StopSample("challenge_result.wav")
|
|
|
|
end
|
2021-10-23 01:27:44 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local function load_number_image(path)
|
|
|
|
local images = {}
|
|
|
|
for i = 0, 9 do
|
2021-11-17 22:28:26 +01:00
|
|
|
images[i + 1] = gfx.CreateSkinImage(string.format("%s/%d.png", path, i), 0)
|
2021-10-23 01:27:44 +02:00
|
|
|
end
|
|
|
|
return images
|
|
|
|
end
|
|
|
|
|
|
|
|
local function draw_number(x, y, alpha, num, digits, images, is_dim, scale, kern)
|
|
|
|
scale = scale or 1;
|
|
|
|
kern = kern or 1;
|
|
|
|
local tw, th = gfx.ImageSize(images[1])
|
|
|
|
tw = tw * scale;
|
|
|
|
th = th * scale;
|
|
|
|
x = x + (tw * (digits - 1)) / 2
|
|
|
|
y = y - th / 2
|
|
|
|
for i = 1, digits do
|
|
|
|
local mul = 10 ^ (i - 1)
|
|
|
|
local digit = math.floor(num / mul) % 10
|
|
|
|
local a = alpha
|
2021-11-17 22:28:26 +01:00
|
|
|
if is_dim and num < mul then
|
|
|
|
a = 0.4
|
|
|
|
end
|
2021-10-23 01:27:44 +02:00
|
|
|
gfx.BeginPath()
|
|
|
|
gfx.ImageRect(x, y, tw, th, images[digit + 1], a, 0)
|
|
|
|
x = x - (tw * kern)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-08-18 17:29:54 +02:00
|
|
|
function drawBackground()
|
2021-07-25 20:10:06 +02:00
|
|
|
gfx.BeginPath()
|
2021-08-18 17:29:54 +02:00
|
|
|
gfx.ImageRect(0, 0, desw, desh, backgroundImage, 1, 0);
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
|
2021-08-18 17:29:54 +02:00
|
|
|
function drawHeader()
|
|
|
|
gfx.BeginPath();
|
|
|
|
gfx.FillColor(0, 0, 0, BAR_ALPHA);
|
|
|
|
gfx.Rect(0, 0, desw, HEADER_HEIGHT);
|
|
|
|
gfx.Fill();
|
|
|
|
gfx.ClosePath()
|
2021-07-25 20:10:06 +02:00
|
|
|
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.ImageRect(desw / 2 - 209, HEADER_HEIGHT / 2 - 52, 419, 105, headerTitleImage, 1, 0)
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
|
2021-08-18 17:29:54 +02:00
|
|
|
function drawPlayerInfo()
|
2021-08-18 20:22:57 +02:00
|
|
|
-- Draw crew
|
|
|
|
gfx.BeginPath()
|
|
|
|
gfx.ImageRect(460, 215, 522, 362, crewImage, 1, 0);
|
|
|
|
|
2021-08-18 19:05:37 +02:00
|
|
|
-- Draw the info bg
|
2021-07-25 20:10:06 +02:00
|
|
|
gfx.BeginPath()
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.ImageRect(300, 352, 374 * 0.85, 222 * 0.85, playerInfoOverlayBgImage, 1, 0);
|
2021-08-18 19:05:37 +02:00
|
|
|
|
|
|
|
-- Draw appeal card
|
|
|
|
gfx.BeginPath();
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.ImageRect(145, 364, 103 * 1.25, 132 * 1.25, appealCardImage, 1, 0);
|
2021-08-18 19:05:37 +02:00
|
|
|
|
|
|
|
-- Draw description
|
|
|
|
gfx.FontSize(28)
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.LoadSkinFont("Digital-Serial-Bold.ttf")
|
2021-08-18 19:05:37 +02:00
|
|
|
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE)
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.Text("Hellooooooo", 310, 370);
|
2021-08-18 19:05:37 +02:00
|
|
|
|
|
|
|
-- Draw username
|
|
|
|
gfx.FontSize(40)
|
|
|
|
gfx.Text(username, 310, 413);
|
|
|
|
|
2021-08-18 20:22:57 +02:00
|
|
|
-- Draw IR server name
|
|
|
|
gfx.FontSize(28)
|
|
|
|
gfx.Text(IRserverName, 310, 453);
|
|
|
|
|
2021-08-18 19:05:37 +02:00
|
|
|
-- Draw dan badge
|
|
|
|
gfx.BeginPath();
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.ImageRect(311, 490, 107 * 1.25, 29 * 1.25, danBadgeImage, 1, 0);
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
|
2021-10-23 01:27:44 +02:00
|
|
|
local scoreNumber = load_number_image("score_num");
|
|
|
|
|
|
|
|
function drawScorePanelContent()
|
2021-11-17 22:28:26 +01:00
|
|
|
game.Log("Drawing scores...", game.LOGGER_INFO) -- debug
|
|
|
|
for i, chart in ipairs(result.charts) do
|
2021-10-23 01:27:44 +02:00
|
|
|
if chart.score == nil then
|
|
|
|
game.Log("Score does not exist? Quitting loop...", game.LOGGER_WARNING)
|
|
|
|
break
|
|
|
|
end
|
2021-11-17 22:28:26 +01:00
|
|
|
game.Log("#" .. i .. " chart.score: " .. chart.score, game.LOGGER_INFO) -- debug
|
2021-10-23 01:27:44 +02:00
|
|
|
-- Draw score
|
2021-11-17 22:28:26 +01:00
|
|
|
draw_number(250, 150, 1.0, math.floor(chart.score / 10000), 4, scoreNumber, true, 0.40, 1.12)
|
|
|
|
-- still not sure how ui scaling/layers works in this game, still figuring it out :p
|
2021-10-23 01:27:44 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2021-08-18 20:22:57 +02:00
|
|
|
local IR_HeartbeatResponse = function(res)
|
|
|
|
if res.statusCode == IRData.States.Success then
|
2021-11-17 22:28:26 +01:00
|
|
|
IRserverName = res.body.serverName .. " " .. res.body.irVersion;
|
2021-08-18 20:22:57 +02:00
|
|
|
else
|
|
|
|
game.Log("Can't connect to IR!", game.LOGGER_WARNING)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local IR_Handle = function()
|
|
|
|
if not irHeartbeatRequested then
|
|
|
|
IR.Heartbeat(IR_HeartbeatResponse)
|
|
|
|
irHeartbeatRequested = true;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-08-18 17:29:54 +02:00
|
|
|
function render(deltaTime)
|
|
|
|
gfx.ResetTransform();
|
|
|
|
resetLayoutInformation();
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.Scale(scale, scale);
|
2021-07-25 20:10:06 +02:00
|
|
|
|
2021-10-23 01:27:44 +02:00
|
|
|
handleSfx()
|
2021-08-18 20:22:57 +02:00
|
|
|
IR_Handle()
|
|
|
|
|
2021-08-18 17:29:54 +02:00
|
|
|
drawBackground()
|
2021-07-25 20:10:06 +02:00
|
|
|
|
2021-08-18 17:29:54 +02:00
|
|
|
drawPlayerInfo()
|
2021-07-25 20:10:06 +02:00
|
|
|
|
2021-10-23 01:27:44 +02:00
|
|
|
drawScorePanelContent()
|
|
|
|
|
2021-08-18 17:29:54 +02:00
|
|
|
drawHeader()
|
|
|
|
Footer.draw(deltaTime);
|
2021-11-17 22:28:26 +01:00
|
|
|
end
|