+ difficulty level number to song transition

This commit is contained in:
FajsiEx 2021-07-29 19:00:31 +02:00
parent 829bc1896b
commit eabb5c9943
1 changed files with 40 additions and 0 deletions

View File

@ -3,6 +3,9 @@ game.LoadSkinSample('song_transition_screen/transition_enter.wav');
local bgImage = gfx.CreateSkinImage("songtransition/bg.png", 0) local bgImage = gfx.CreateSkinImage("songtransition/bg.png", 0)
local difficultyNumbers;
local difficultyLabelImages = { local difficultyLabelImages = {
gfx.CreateSkinImage("songtransition/difficulty_labels/nov.png", 0), gfx.CreateSkinImage("songtransition/difficulty_labels/nov.png", 0),
gfx.CreateSkinImage("songtransition/difficulty_labels/adv.png", 0), gfx.CreateSkinImage("songtransition/difficulty_labels/adv.png", 0),
@ -33,11 +36,43 @@ function resetLayoutInformation()
scale = resx / desw scale = resx / desw
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
function render(deltaTime) function render(deltaTime)
if not wasEnterSfxPlayed then if not wasEnterSfxPlayed then
game.PlaySample('song_transition_screen/transition_enter.wav'); game.PlaySample('song_transition_screen/transition_enter.wav');
wasEnterSfxPlayed = true; wasEnterSfxPlayed = true;
end end
if not difficultyNumbers then
difficultyNumbers = load_number_image('diff_num')
end
resetLayoutInformation() resetLayoutInformation()
gfx.ResetTransform(); gfx.ResetTransform();
@ -110,6 +145,11 @@ function render_screen(progress)
gfx.Text(song.effector, desw/2+70 , EFFECTOR_LABEL_Y-1) gfx.Text(song.effector, desw/2+70 , EFFECTOR_LABEL_Y-1)
gfx.Text(song.illustrator, desw/2+70 , ILLUSTRATOR_LABEL_Y-3) gfx.Text(song.illustrator, desw/2+70 , ILLUSTRATOR_LABEL_Y-3)
-- Draw song diff level
gfx.BeginPath();
draw_number(933, 1140, 1.0, song.level, 2, difficultyNumbers, false, 1, 1)
-- Draw song diff label (NOV/ADV/EXH/MXM/etc.)
gfx.BeginPath(); gfx.BeginPath();
local diffLabelImage = difficultyLabelImages[song.difficulty+1]; local diffLabelImage = difficultyLabelImages[song.difficulty+1];
local diffLabelW, diffLabelH = gfx.ImageSize(diffLabelImage); local diffLabelW, diffLabelH = gfx.ImageSize(diffLabelImage);