2021-07-25 20:10:06 +02:00
|
|
|
|
2021-11-21 17:27:37 +01:00
|
|
|
local common = require('common.common');
|
2021-12-10 04:07:09 +01:00
|
|
|
local Numbers = require('common.numbers')
|
2021-11-21 17:27:37 +01:00
|
|
|
|
2021-07-25 20:10:06 +02:00
|
|
|
game.LoadSkinSample('song_transition_screen/transition_enter.wav');
|
|
|
|
|
2021-12-02 03:41:12 +01:00
|
|
|
local backgroundImage = gfx.CreateSkinImage("bg_pattern.png", gfx.IMAGE_REPEATX | gfx.IMAGE_REPEATY)
|
2021-08-25 19:11:15 +02:00
|
|
|
|
2021-07-26 22:20:37 +02:00
|
|
|
local bgImage = gfx.CreateSkinImage("songtransition/bg.png", 0)
|
2021-08-25 19:11:15 +02:00
|
|
|
local glowOverlayImage = gfx.CreateSkinImage("songtransition/glowy.png", 0)
|
2021-10-23 00:17:31 +02:00
|
|
|
local frameOverlayImage = gfx.CreateSkinImage("songtransition/frames.png", 0)
|
2021-07-26 22:20:37 +02:00
|
|
|
|
2021-10-23 00:17:31 +02:00
|
|
|
local albumBgImage = gfx.CreateSkinImage("songtransition/album_crop.png", 0)
|
|
|
|
local infoOverlayPanel = gfx.CreateSkinImage("songtransition/info_panels_crop.png", 0)
|
2021-07-29 19:00:31 +02:00
|
|
|
|
|
|
|
local difficultyNumbers;
|
|
|
|
|
2021-07-26 22:20:37 +02:00
|
|
|
local difficultyLabelImages = {
|
|
|
|
gfx.CreateSkinImage("songtransition/difficulty_labels/nov.png", 0),
|
|
|
|
gfx.CreateSkinImage("songtransition/difficulty_labels/adv.png", 0),
|
|
|
|
gfx.CreateSkinImage("songtransition/difficulty_labels/exh.png", 0),
|
|
|
|
gfx.CreateSkinImage("songtransition/difficulty_labels/mxm.png", 0),
|
2021-07-31 22:53:05 +02:00
|
|
|
gfx.CreateSkinImage("songtransition/difficulty_labels/inf.png", 0),
|
|
|
|
gfx.CreateSkinImage("songtransition/difficulty_labels/grv.png", 0),
|
|
|
|
gfx.CreateSkinImage("songtransition/difficulty_labels/hvn.png", 0),
|
|
|
|
gfx.CreateSkinImage("songtransition/difficulty_labels/vvd.png", 0),
|
2021-07-26 22:20:37 +02:00
|
|
|
}
|
|
|
|
|
2021-07-27 19:41:26 +02:00
|
|
|
local transitionTimer = 0;
|
|
|
|
local outTimer = 0
|
|
|
|
|
2021-12-02 03:41:12 +01:00
|
|
|
-- Window variables
|
|
|
|
local resX, resY = game.GetResolution()
|
|
|
|
|
|
|
|
-- Aspect Ratios
|
|
|
|
local landscapeWidescreenRatio = 16 / 9
|
|
|
|
local landscapeStandardRatio = 4 / 3
|
|
|
|
local portraitWidescreenRatio = 9 / 16
|
|
|
|
|
|
|
|
-- Portrait sizes
|
|
|
|
local fullX, fullY
|
|
|
|
local desw = 1080
|
|
|
|
local desh = 1920
|
2021-07-27 19:41:26 +02:00
|
|
|
|
2021-07-25 20:10:06 +02:00
|
|
|
local noJacket = gfx.CreateSkinImage("song_select/loading.png", 0)
|
|
|
|
|
|
|
|
local wasEnterSfxPlayed = false;
|
|
|
|
|
2021-07-27 19:41:26 +02:00
|
|
|
function resetLayoutInformation()
|
|
|
|
resx, resy = game.GetResolution()
|
|
|
|
scale = resx / desw
|
|
|
|
end
|
|
|
|
|
2021-07-25 20:10:06 +02:00
|
|
|
function render(deltaTime)
|
|
|
|
if not wasEnterSfxPlayed then
|
2021-11-21 17:27:37 +01:00
|
|
|
common.stopMusic();
|
2021-07-25 20:10:06 +02:00
|
|
|
game.PlaySample('song_transition_screen/transition_enter.wav');
|
|
|
|
wasEnterSfxPlayed = true;
|
|
|
|
end
|
2021-07-29 19:00:31 +02:00
|
|
|
if not difficultyNumbers then
|
2021-12-10 04:07:09 +01:00
|
|
|
difficultyNumbers = Numbers.load_number_image('diff_num')
|
2021-07-29 19:00:31 +02:00
|
|
|
end
|
2021-07-25 20:10:06 +02:00
|
|
|
|
2021-12-02 03:41:12 +01:00
|
|
|
local x_offset = (resX - fullX) / 2
|
|
|
|
local y_offset = 0
|
|
|
|
|
|
|
|
gfx.BeginPath()
|
|
|
|
local bgImageWidth, bgImageHeight = gfx.ImageSize(backgroundImage)
|
|
|
|
gfx.Rect(0, 0, resX, resY)
|
|
|
|
gfx.FillPaint(gfx.ImagePattern(0, 0, bgImageWidth, bgImageHeight, 0, backgroundImage, 0.2))
|
|
|
|
gfx.Fill()
|
|
|
|
|
|
|
|
gfx.Translate(x_offset, y_offset);
|
|
|
|
gfx.Scale(fullX / 1080, fullY / 1920);
|
|
|
|
gfx.Scissor(0, 0, 1080, 1920);
|
2021-07-27 19:41:26 +02:00
|
|
|
|
|
|
|
render_screen(transitionTimer);
|
2021-12-02 03:41:12 +01:00
|
|
|
|
2021-07-27 19:41:26 +02:00
|
|
|
transitionTimer = transitionTimer + deltaTime * 0.2
|
2021-07-25 20:10:06 +02:00
|
|
|
transitionTimer = math.min(transitionTimer,1)
|
2021-07-27 19:41:26 +02:00
|
|
|
|
|
|
|
if transitionTimer < 0.25 then
|
|
|
|
local whiteAlpha = math.max(0, (1-transitionTimer/0.25))
|
|
|
|
|
|
|
|
gfx.BeginPath();
|
|
|
|
gfx.FillColor(255,255,255,math.floor(255*whiteAlpha));
|
|
|
|
gfx.Rect(0,0,desw,desh);
|
|
|
|
gfx.Fill();
|
|
|
|
gfx.ClosePath();
|
|
|
|
end
|
|
|
|
|
|
|
|
if transitionTimer > 0.85 then
|
|
|
|
local blackAlpha = math.min(1, ((transitionTimer-0.85)/0.15))
|
|
|
|
|
|
|
|
gfx.BeginPath();
|
|
|
|
gfx.FillColor(0,0,0,math.floor(255*blackAlpha));
|
|
|
|
gfx.Rect(0,0,desw,desh);
|
|
|
|
gfx.Fill();
|
|
|
|
gfx.ClosePath();
|
|
|
|
end
|
|
|
|
|
2021-07-26 22:24:54 +02:00
|
|
|
return transitionTimer >= 1
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function render_out(deltaTime)
|
2021-07-27 19:41:26 +02:00
|
|
|
outTimer = outTimer + deltaTime * 0.2
|
|
|
|
outTimer = math.min(outTimer, 1)
|
|
|
|
|
2021-07-26 22:24:54 +02:00
|
|
|
return outTimer >= 1;
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function sign(x)
|
|
|
|
return x>0 and 1 or x<0 and -1 or 0
|
|
|
|
end
|
|
|
|
|
|
|
|
function render_screen(progress)
|
2021-08-25 19:11:15 +02:00
|
|
|
gfx.BeginPath()
|
2021-07-27 19:41:26 +02:00
|
|
|
gfx.ImageRect(0, 0, 1080, 1920, bgImage,1,0);
|
2021-08-25 19:11:15 +02:00
|
|
|
gfx.BeginPath()
|
2021-10-23 00:17:31 +02:00
|
|
|
gfx.ImageRect(0,0,1080,1920,frameOverlayImage,1,0);
|
|
|
|
gfx.BeginPath()
|
2021-08-25 19:11:15 +02:00
|
|
|
gfx.ImageRect(0, 0, 1080, 1920, glowOverlayImage,1,0);
|
|
|
|
gfx.BeginPath()
|
2021-10-23 23:20:57 +02:00
|
|
|
gfx.ImageRect(37.5, 1074, 1180*0.85, 343*0.85, infoOverlayPanel,1,0);
|
2021-08-25 19:11:15 +02:00
|
|
|
|
2021-11-21 17:05:35 +01:00
|
|
|
gfx.BeginPath()
|
|
|
|
gfx.ImageRect(10, 195.5, 1060, 1015, albumBgImage,1,0);
|
|
|
|
|
2021-07-25 20:10:06 +02:00
|
|
|
local jacket = song.jacket == 0 and noJacket or song.jacket
|
2021-07-26 22:20:37 +02:00
|
|
|
gfx.BeginPath();
|
|
|
|
gfx.ImageRect(235, 385, 608, 608, jacket, 1, 0)
|
|
|
|
gfx.ClosePath();
|
|
|
|
|
|
|
|
gfx.TextAlign(gfx.TEXT_ALIGN_CENTER + gfx.TEXT_ALIGN_MIDDLE)
|
|
|
|
|
2021-07-25 20:10:06 +02:00
|
|
|
gfx.FontSize(55)
|
2021-07-27 19:41:26 +02:00
|
|
|
gfx.Text(song.title,desw/2, 1114)
|
2021-07-26 22:20:37 +02:00
|
|
|
|
|
|
|
gfx.FontSize(30)
|
2021-07-27 19:41:26 +02:00
|
|
|
gfx.Text(song.artist, desw/2 , 1182)
|
2021-07-26 22:20:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
local EFFECTOR_LABEL_Y = 1288
|
|
|
|
local ILLUSTRATOR_LABEL_Y = 1347
|
|
|
|
|
|
|
|
gfx.FontSize(22)
|
|
|
|
|
2021-07-27 19:41:26 +02:00
|
|
|
gfx.Text(song.effector, desw/2+70 , EFFECTOR_LABEL_Y-1)
|
|
|
|
gfx.Text(song.illustrator, desw/2+70 , ILLUSTRATOR_LABEL_Y-3)
|
2021-07-26 22:20:37 +02:00
|
|
|
|
2021-07-29 19:00:31 +02:00
|
|
|
-- Draw song diff level
|
|
|
|
gfx.BeginPath();
|
2021-12-10 04:07:09 +01:00
|
|
|
Numbers.draw_number(933, 1140, 1.0, song.level, 2, difficultyNumbers, false, 1, 1)
|
2021-07-29 19:00:31 +02:00
|
|
|
|
|
|
|
-- Draw song diff label (NOV/ADV/EXH/MXM/etc.)
|
2021-07-26 22:20:37 +02:00
|
|
|
gfx.BeginPath();
|
|
|
|
local diffLabelImage = difficultyLabelImages[song.difficulty+1];
|
|
|
|
local diffLabelW, diffLabelH = gfx.ImageSize(diffLabelImage);
|
|
|
|
gfx.ImageRect(952-diffLabelW/2, 1154-diffLabelH/2, diffLabelW, diffLabelH, diffLabelImage,1,0);
|
|
|
|
gfx.ClosePath();
|
|
|
|
|
|
|
|
gfx.Save();
|
|
|
|
gfx.FontSize(24)
|
|
|
|
gfx.LoadSkinFont('Digital-Serial-Bold.ttf')
|
|
|
|
gfx.TextAlign(gfx.TEXT_ALIGN_CENTER + gfx.TEXT_ALIGN_MIDDLE)
|
|
|
|
gfx.BeginPath();
|
|
|
|
|
|
|
|
gfx.Text('BPM', 127, 1140)
|
|
|
|
gfx.Text(song.bpm, 127, 1167)
|
|
|
|
|
2021-08-25 19:11:15 +02:00
|
|
|
-- temp ref overlay
|
|
|
|
-- gfx.BeginPath()
|
|
|
|
-- gfx.ImageRect(0, 0, 1080, 1920, refBgImage,0.5,0);
|
|
|
|
|
2021-07-26 22:20:37 +02:00
|
|
|
gfx.ClosePath();
|
|
|
|
gfx.Restore();
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function reset()
|
|
|
|
transitionTimer = 0
|
2021-12-02 03:41:12 +01:00
|
|
|
resX, resY = game.GetResolution()
|
|
|
|
fullX = portraitWidescreenRatio * resY
|
|
|
|
fullY = resY
|
2021-07-27 19:41:26 +02:00
|
|
|
outTimer = 0
|
2021-07-25 20:10:06 +02:00
|
|
|
wasEnterSfxPlayed = false;
|
|
|
|
end
|