ExperimentalGear/scripts/gameplay/user_panel.lua

202 lines
4.4 KiB
Lua
Raw Normal View History

2021-10-09 22:09:25 +02:00
local VolforceWindow = require('components.volforceWindow');
2022-06-24 22:09:19 +02:00
local dancheck = require("components.dancheck");
local volforceAmount = game.GetSkinSetting('_volforce');
2021-10-09 22:09:25 +02:00
local desw = 1080;
local desh = 1920;
2021-11-25 19:38:59 +01:00
local isLandscape = false;
2021-10-09 22:09:25 +02:00
local bgImage = gfx.CreateSkinImage("gameplay/user_panel/bg.png", 0);
2022-07-05 20:44:14 +02:00
2021-10-25 21:39:16 +02:00
local appealCardImage = gfx.CreateSkinImage("crew/appeal_card.png", 0);
local idolFrameImage = gfx.CreateSkinImage("crew/frame.png", 0);
2021-10-09 22:14:24 +02:00
2021-10-09 22:09:25 +02:00
local username = game.GetSkinSetting('username') or '';
2021-11-25 19:38:59 +01:00
local drawBestDiff = function (deltaTime, score, bestReplay, y)
2021-10-28 18:28:49 +02:00
if not bestReplay then return end
-- Calculate the difference between current and best play
local difference = score - bestReplay.currentScore
local prefix = "=" -- used to properly display negative values
gfx.BeginPath()
gfx.FontSize(26)
gfx.FillColor(255, 255, 255)
if difference < 0 then
-- If we're behind the best score, separate the minus sign and change the color
gfx.FillColor(255, 90, 70)
difference = math.abs(difference)
prefix = "-"
elseif difference > 0 then
gfx.FillColor(120, 146, 218)
difference = math.abs(difference)
prefix = "+"
end
gfx.LoadSkinFont("Digital-Serial-Bold.ttf")
gfx.FontSize(26)
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE)
2021-11-25 19:38:59 +01:00
gfx.Text(prefix, 130, y+177)
gfx.Text(string.format("%04d", math.floor(difference/10000)), 150, y+177)
2021-10-28 18:28:49 +02:00
local lastFourDigits = ((difference / 10000) - math.floor(difference / 10000))*10000
gfx.FontSize(22)
2021-11-25 19:38:59 +01:00
gfx.Text(string.format("%04d", math.floor(lastFourDigits)), 208, y+178)
2021-10-28 18:28:49 +02:00
end
2021-10-09 22:09:25 +02:00
local tickTransitions = function (deltaTime)
end
2021-10-28 18:28:49 +02:00
local render = function (deltaTime, score, bestReplay)
2021-12-02 21:53:30 +01:00
gfx.ResetTransform()
2021-11-25 19:38:59 +01:00
local resx, resy = game.GetResolution();
isLandscape = resx > resy;
if (isLandscape) then
desw = 1920;
desh = 1080;
else
desw = 1080;
desh = 1920;
end
local x = 0;
local y = desh*0.35; -- Approx. pos of the user panel against the height of the screen is 0.35
2021-10-09 22:09:25 +02:00
tickTransitions(deltaTime)
local scale = resy / desh
gfx.Scale(scale, scale)
2022-06-24 22:09:19 +02:00
if not gameplay.demoMode then
2021-10-25 21:39:16 +02:00
gfx.BeginPath();
gfx.ImageRect(
0,
2022-05-06 00:05:20 +02:00
y,
2021-10-25 21:39:16 +02:00
449*0.85,
336*0.85,
idolFrameImage,
1,
0
);
2021-10-09 22:09:25 +02:00
gfx.BeginPath();
gfx.ImageRect(
0,
2022-05-06 00:05:20 +02:00
y,
2021-10-09 22:09:25 +02:00
449*0.85,
336*0.85,
bgImage,
1,
0
);
-- Draw appeal card
gfx.BeginPath();
gfx.ImageRect(
10,
2022-05-06 00:05:20 +02:00
y+117,
150*0.62,
192*0.62,
appealCardImage,
1,
0
);
-- Draw username
gfx.LoadSkinFont('Digital-Serial-Bold.ttf')
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE)
gfx.FontSize(26)
2022-06-24 22:09:19 +02:00
gfx.Text(string.upper(username), 150, y+152);
2021-10-28 18:28:49 +02:00
-- Draw best score diff
2021-11-25 19:38:59 +01:00
drawBestDiff(deltaTime, score, bestReplay, y);
2021-10-28 18:28:49 +02:00
2021-10-09 22:14:24 +02:00
-- Draw dan badge & volforce
gfx.BeginPath();
gfx.ImageRect(
117,
2022-05-06 00:05:20 +02:00
y+206,
294*0.32, -- what are these whacky measurements
84*0.32,
2022-06-24 22:09:19 +02:00
dancheck(false),
1,
0
);
VolforceWindow.render(deltaTime, 220, y+197,42,true,volforceAmount)
else
2022-07-05 20:44:14 +02:00
appealCardImage = gfx.CreateSkinImage("gameplay/user_panel/appeal_card.png", 0);
idolFrameImage = gfx.CreateSkinImage("gameplay/user_panel/frame.png", 0);
2022-06-24 22:09:19 +02:00
gfx.BeginPath();
gfx.ImageRect(
0,
y,
449*0.85,
336*0.85,
idolFrameImage,
1,
0
);
gfx.BeginPath();
gfx.ImageRect(
0,
y,
449*0.85,
336*0.85,
bgImage,
1,
0
);
-- Draw appeal card
gfx.BeginPath();
gfx.ImageRect(
10,
y+117,
150*0.62,
192*0.62,
appealCardImage,
1,
0
);
-- Draw username
gfx.LoadSkinFont('Digital-Serial-Bold.ttf')
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE)
gfx.FontSize(26)
gfx.Text(string.upper("Guest"), 150, y+152);
-- Draw dan badge & volforce
gfx.BeginPath();
gfx.ImageRect(
117,
y+206,
294*0.32, -- what are these whacky measurements
84*0.32,
dancheck(true),
2021-10-09 22:14:24 +02:00
1,
0
);
2022-06-24 22:09:19 +02:00
VolforceWindow.render(deltaTime, 220, y+197,42,true,0)
2022-06-24 22:09:19 +02:00
end
gfx.ResetTransform()
2021-10-09 22:09:25 +02:00
end
return {
render=render
}