local backgroundImage = gfx.CreateSkinImage("song_select/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 difficultyLabelImages = { gfx.CreateSkinImage("song_select/plate/difficulty_labels/novice.png", 1), gfx.CreateSkinImage("song_select/plate/difficulty_labels/advanced.png", 1), gfx.CreateSkinImage("song_select/plate/difficulty_labels/exhaust.png", 1), gfx.CreateSkinImage("song_select/plate/difficulty_labels/maximum.png", 1), gfx.CreateSkinImage("song_select/plate/difficulty_labels/infinite.png", 1), gfx.CreateSkinImage("song_select/plate/difficulty_labels/gravity.png", 1), gfx.CreateSkinImage("song_select/plate/difficulty_labels/heavenly.png", 1), gfx.CreateSkinImage("song_select/plate/difficulty_labels/vivid.png", 1), } local difficultyNumbers; local resx, resy = game.GetResolution() local desw, desh; local scale; local selectedIndex = 1; local selectedDifficulty = 1; local jacketCache = {} function resetLayoutInformation() resx, resy = game.GetResolution() desw = 1080 desh = 1920 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 getJacketImage(song) if not jacketCache[song.id] then jacketCache[song.id] = gfx.CreateImage(song.difficulties[1].jacketPath, 0) end return jacketCache[song.id]; end function drawBackground() gfx.BeginPath() gfx.ImageRect(0, 0, desw, desh, backgroundImage, 1, 0) end function drawSong(song, y) local songX = desw/2+28 -- Draw the bg for the song plate gfx.BeginPath() gfx.ImageRect(songX, y, 603/1.17, 201/1.17, songPlateBg, 1, 0) -- Draw jacket local jacketImage = getJacketImage(song); gfx.BeginPath() gfx.ImageRect(songX+4, y+4, 163, 163, jacketImage, 1, 0) -- Draw the overlay for the song plate (that bottom black bar) gfx.BeginPath() gfx.ImageRect(songX, y, 603/1.17, 201/1.17, songPlateBottomBarOverlayImage, 1, 0) -- Draw the difficulty notch background gfx.BeginPath() gfx.ImageRect(songX, y+95, 97/1.17, 86/1.17, difficultyLabelImages[song.difficulties[selectedDifficulty].difficulty+1], 1, 0) -- Draw the difficulty level number gfx.BeginPath() draw_number(songX+30, y+125, 1.0, song.difficulties[selectedDifficulty].level, 2, difficultyNumbers, false, 0.65, 1) end function drawSongList() drawSong(songwheel.songs[selectedIndex], 1200) end render = function (deltaTime) resetLayoutInformation(); gfx.Scale(scale, scale); if not difficultyNumbers then difficultyNumbers = load_number_image('diff_num') end drawBackground(); drawSongList() gfx.BeginPath(); gfx.FontSize(18) gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_TOP) gfx.Text('DELTA: ' .. deltaTime .. ' // SELECTED_INDEX: ' .. selectedIndex .. ' // SELECTED_DIFF: ' .. selectedDifficulty .. ' // #JACKET_CACHE: ' .. #jacketCache, 8, 8); end set_index = function(newIndex) selectedIndex = newIndex; end; set_diff = function(newDiff) selectedDifficulty = newDiff; end;