diff --git a/scripts/songtransition.lua b/scripts/songtransition.lua index fe7bd03..7bd7a4a 100644 --- a/scripts/songtransition.lua +++ b/scripts/songtransition.lua @@ -3,6 +3,9 @@ game.LoadSkinSample('song_transition_screen/transition_enter.wav'); local bgImage = gfx.CreateSkinImage("songtransition/bg.png", 0) + +local difficultyNumbers; + local difficultyLabelImages = { gfx.CreateSkinImage("songtransition/difficulty_labels/nov.png", 0), gfx.CreateSkinImage("songtransition/difficulty_labels/adv.png", 0), @@ -33,11 +36,43 @@ function resetLayoutInformation() scale = resx / desw 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) if not wasEnterSfxPlayed then game.PlaySample('song_transition_screen/transition_enter.wav'); wasEnterSfxPlayed = true; end + if not difficultyNumbers then + difficultyNumbers = load_number_image('diff_num') + end resetLayoutInformation() gfx.ResetTransform(); @@ -110,6 +145,11 @@ function render_screen(progress) gfx.Text(song.effector, desw/2+70 , EFFECTOR_LABEL_Y-1) 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(); local diffLabelImage = difficultyLabelImages[song.difficulty+1]; local diffLabelW, diffLabelH = gfx.ImageSize(diffLabelImage);