+ some data to songwheel

This commit is contained in:
FajsiEx 2021-07-31 20:36:05 +02:00
parent 9fa7d7d07d
commit 8ffc12f82a
2 changed files with 64 additions and 1 deletions

View File

@ -2,6 +2,7 @@
local Easing = require('common.easings'); local Easing = require('common.easings');
local backgroundImage = gfx.CreateSkinImage("song_select/bg.png", 1) local backgroundImage = gfx.CreateSkinImage("song_select/bg.png", 1)
local dataBackgroundOverlayImage = gfx.CreateSkinImage("song_select/data_bg_overlay.png", 1)
local songPlateBg = gfx.CreateSkinImage("song_select/plate/bg.png", 1) local songPlateBg = gfx.CreateSkinImage("song_select/plate/bg.png", 1)
local songPlateBottomBarOverlayImage = gfx.CreateSkinImage("song_select/plate/bottom_bar_overlay.png", 1) local songPlateBottomBarOverlayImage = gfx.CreateSkinImage("song_select/plate/bottom_bar_overlay.png", 1)
@ -59,6 +60,7 @@ local gradeImages = {
game.LoadSkinSample('song_wheel/cursor_change.wav'); game.LoadSkinSample('song_wheel/cursor_change.wav');
local difficultyNumbers; local difficultyNumbers;
local scoreNumbers;
local resx, resy = game.GetResolution() local resx, resy = game.GetResolution()
local desw, desh; local desw, desh;
@ -130,7 +132,7 @@ end;
function getJacketImage(song) function getJacketImage(song)
if not jacketCache[song.id] or jacketCache[song.id]==defaultJacketImage then if not jacketCache[song.id] or jacketCache[song.id]==defaultJacketImage then
jacketCache[song.id] = gfx.LoadImageJob(song.difficulties[1].jacketPath, defaultJacketImage, 165, 165); jacketCache[song.id] = gfx.LoadImageJob(song.difficulties[1].jacketPath, defaultJacketImage, 400, 400);
end end
return jacketCache[song.id]; return jacketCache[song.id];
@ -154,9 +156,20 @@ end
function drawBackground() function drawBackground()
gfx.BeginPath() gfx.BeginPath()
gfx.ImageRect(0, 0, desw, desh, backgroundImage, 1, 0) gfx.ImageRect(0, 0, desw, desh, backgroundImage, 1, 0)
-- If the score for song exists
local song = songwheel.songs[selectedIndex];
local diff = song.difficulties[selectedDifficulty];
local bestScore = diff.scores[1];
if song and diff and bestScore then
gfx.BeginPath()
gfx.ImageRect(0, 0, desw, desh, dataBackgroundOverlayImage, 1, 0)
end
end end
function drawSong(song, y) function drawSong(song, y)
if (not song) then return end;
local songX = desw/2+28 local songX = desw/2+28
local selectedSongDifficulty = song.difficulties[selectedDifficulty] local selectedSongDifficulty = song.difficulties[selectedDifficulty]
@ -241,6 +254,53 @@ function drawCursor()
gfx.ImageRect(desw/2-14, desh/2-213/2, 555, 213, cursorImage, 1, 0) gfx.ImageRect(desw/2-14, desh/2-213/2, 555, 213, cursorImage, 1, 0)
end end
local scoreNumbers = load_number_image("score_num");
function drawData() -- Draws the song data on the left panel
local song = songwheel.songs[selectedIndex];
local diff = song.difficulties[selectedDifficulty];
local bestScore = diff.scores[1];
local jacketImage = getJacketImage(song);
gfx.BeginPath()
gfx.ImageRect(96, 324, 348, 348, jacketImage or defaultJacketImage, 1, 0)
if bestScore then
-- Draw best score
gfx.BeginPath()
draw_number(100, 793, 1.0, math.floor(bestScore.score / 10000), 4, scoreNumbers, true, 0.3, 1.12)
draw_number(245, 797, 1.0, bestScore.score, 4, scoreNumbers, true, 0.22, 1.12)
-- Draw grade
local gradeImage = gradeImages.none;
if bestScore then
gradeImage = getGradeImageForScore(bestScore.score)
end
gfx.BeginPath();
gfx.ImageRect(360, 773, 45, 45, gradeImage, 1, 0);
-- Draw badge
badgeImage = badgeImages[bestScore.badge+1];
gfx.BeginPath()
gfx.ImageRect(425, 724, 93/1.1, 81/1.1, badgeImage, 1, 0)
end
-- Draw BPM
gfx.FontSize(24)
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE)
gfx.Save()
gfx.LoadSkinFont('Digital-Serial-Bold.ttf')
gfx.Text(song.bpm, 85, 920);
gfx.Restore()
-- Draw song title
gfx.FontSize(28)
gfx.Text(song.title, 30, 955);
-- Draw artist
gfx.Text(song.artist, 30, 997);
end
function tickTransitions(deltaTime) function tickTransitions(deltaTime)
if transitionScrollScale < 1 then if transitionScrollScale < 1 then
transitionScrollScale = transitionScrollScale + deltaTime / 0.1 -- transition should last for that time in seconds transitionScrollScale = transitionScrollScale + deltaTime / 0.1 -- transition should last for that time in seconds
@ -255,6 +315,7 @@ function tickTransitions(deltaTime)
end end
end end
render = function (deltaTime) render = function (deltaTime)
resetLayoutInformation(); resetLayoutInformation();
tickTransitions(deltaTime); tickTransitions(deltaTime);
@ -269,6 +330,8 @@ render = function (deltaTime)
drawSongList() drawSongList()
drawCursor() drawCursor()
drawData()
gfx.BeginPath(); gfx.BeginPath();
gfx.FontSize(18) gfx.FontSize(18)

View File

Before

Width:  |  Height:  |  Size: 301 KiB

After

Width:  |  Height:  |  Size: 301 KiB