+ score and grades to results

This commit is contained in:
FajsiEx 2021-07-28 16:35:34 +02:00
parent 5f42a0e336
commit d0042a11ad
1 changed files with 54 additions and 0 deletions

View File

@ -15,6 +15,19 @@ local bottomPanelImage = gfx.CreateSkinImage("result/panels/bottom.png", 0);
local jacketImage = gfx.CreateSkinImage("result/default_jacket.png", 0); local jacketImage = gfx.CreateSkinImage("result/default_jacket.png", 0);
local gradeImages = {
S = gfx.CreateSkinImage("score/S.png", 0),
AAA_P = gfx.CreateSkinImage("score/AAA+.png", 0),
AAA = gfx.CreateSkinImage("score/AAA.png", 0),
AA_P = gfx.CreateSkinImage("score/AA+.png", 0),
AA = gfx.CreateSkinImage("score/AA.png", 0),
A_P = gfx.CreateSkinImage("score/A+.png", 0),
A = gfx.CreateSkinImage("score/A.png", 0),
B = gfx.CreateSkinImage("score/B.png", 0),
C = gfx.CreateSkinImage("score/C.png", 0),
D = gfx.CreateSkinImage("score/D.png", 0),
}
-- ANIMS -- ANIMS
local idolAnimation = gfx.LoadSkinAnimation('idol', 1/30, 0, false); local idolAnimation = gfx.LoadSkinAnimation('idol', 1/30, 0, false);
@ -80,6 +93,35 @@ function drawTimingBar(y, value, max, type)
gfx.ClosePath(); gfx.ClosePath();
end end
function load_number_image(path)
local images = {}
for i = 0, 9 do
images[i + 1] = gfx.CreateSkinImage(string.format("%s/%d.png", path, i), 0)
end
return images
end
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
if is_dim and num < mul then
a = 0.4
end
gfx.BeginPath()
gfx.ImageRect(x, y, tw, th, images[digit + 1], a, 0)
x = x - (tw * kern)
end
end
local drawIdol = function (deltaTime) local drawIdol = function (deltaTime)
local idolAnimTickRes = gfx.TickAnimation(idolAnimation, deltaTime); local idolAnimTickRes = gfx.TickAnimation(idolAnimation, deltaTime);
if idolAnimTickRes == 1 then if idolAnimTickRes == 1 then
@ -110,6 +152,8 @@ local drawRightPanel = function()
Easing.outQuad(transitionEnterScale), 0); Easing.outQuad(transitionEnterScale), 0);
end end
local scoreNumber = load_number_image("score_num");
local drawRightPanelContent = function() local drawRightPanelContent = function()
-- Draw song name and artist -- Draw song name and artist
@ -118,6 +162,16 @@ local drawRightPanelContent = function()
gfx.Text(result.realTitle, rightPanelX + 435, rightPanelY + 108); gfx.Text(result.realTitle, rightPanelX + 435, rightPanelY + 108);
gfx.Text(result.artist, rightPanelX + 435, rightPanelY + 143); gfx.Text(result.artist, rightPanelX + 435, rightPanelY + 143);
-- Draw score
draw_number(rightPanelX+580, rightPanelY+192, 1.0, math.floor(result.score / 10000), 4, scoreNumber, true, 0.42, 1.12)
draw_number(rightPanelX+768, rightPanelY+202, 1.0, result.score, 4, scoreNumber, true, 0.25, 1.12)
-- Draw grade
local gradeImageKey = string.gsub(result.grade, '+', '_P');
local gradeImage = gradeImages[gradeImageKey] or gradeImages.D
gfx.BeginPath();
gfx.ImageRect(rightPanelX+890, rightPanelY+130, 85, 85, gradeImage, 1, 0);
-- Draw err/early/critical/late/err texts -- Draw err/early/critical/late/err texts
gfx.FontSize(24) gfx.FontSize(24)
gfx.TextAlign(gfx.TEXT_ALIGN_RIGHT + gfx.TEXT_ALIGN_MIDDLE) gfx.TextAlign(gfx.TEXT_ALIGN_RIGHT + gfx.TEXT_ALIGN_MIDDLE)