add letter on scrollbar in SongWheel

This commit is contained in:
Kyle Humphrey 2022-03-16 02:24:02 -05:00
parent 841fb1fa35
commit a3fa6350c1
3 changed files with 21 additions and 2 deletions

View File

@ -10,6 +10,7 @@ Project Starter: GSK Bladez
- Hoshikara
- GSK Bladez
- Local
- Kuenaimaku
## Graphics
- GSK Bladez

View File

@ -17,6 +17,10 @@ local function splitString(inputstr, sep)
return t
end
local function firstLetter(str)
return str:match("[%z\1-\127\194-\244][\128-\191]*")
end
local function filter(tableIn, predicate)
local out = {}
for _, val in ipairs(tableIn) do
@ -30,5 +34,6 @@ end
return {
stopMusic = stopMusic,
splitString = splitString,
filter = filter
filter = filter,
firstLetter = firstLetter
}

View File

@ -750,6 +750,7 @@ end
function drawScrollbar()
if isFilterWheelActive or transitionLeaveScale ~= 0 then return end
-- Scrollbar Background
gfx.BeginPath()
local resize = 0.85;
local lw, lh = gfx.ImageSize(scrollBarBackgroundImage);
@ -759,6 +760,7 @@ function drawScrollbar()
local backgroundYPos = desh/2 - lh/2
gfx.ImageRect(xPos, backgroundYPos, lw, lh, scrollBarBackgroundImage, 1, 0)
-- Scrollbar Fill
gfx.BeginPath()
local sw, sh = gfx.ImageSize(scrollBarFillImage);
local sw = sw * resize;
@ -770,8 +772,19 @@ function drawScrollbar()
local scrollStep = (maxScrollYPos - minScrollYPos) / (#songwheel.songs - 1);
local scrollbarYOffset = (selectedIndex - 1) * scrollStep;
local scrollbarYPos = minScrollYPos + scrollbarYOffset;
gfx.ImageRect(fillXPos, scrollbarYPos, sw, sh, scrollBarFillImage, 1, 0);
gfx.ImageRect(fillXPos, scrollbarYPos, sw, sh, scrollBarFillImage, 1, 0)
-- 1st letter of song title on scroll
local letter = string.upper(common.firstLetter(songwheel.songs[selectedIndex].title));
gfx.BeginPath()
gfx.FontSize(16)
gfx.LoadSkinFont('Digital-Serial-Bold.ttf')
gfx.Rect(fillXPos-18, scrollbarYPos - 5, 16, 16)
gfx.FillColor(0,0,0,170)
gfx.Fill()
gfx.FillColor(255,255,255)
gfx.TextAlign(gfx.TEXT_ALIGN_MIDDLE + gfx.TEXT_ALIGN_CENTER)
gfx.Text(letter, fillXPos-10, scrollbarYPos + 5);
end