Merge pull request 'add letter on scrollbar in SongWheel' (#6) from feature/TASK-21-Scrollbar-fix into master

Reviewed-on: #6
This commit is contained in:
Kuenaimaku 2022-03-16 07:25:03 +00:00
commit 90421885f5
3 changed files with 21 additions and 2 deletions

View File

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

View File

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

View File

@ -750,6 +750,7 @@ end
function drawScrollbar() function drawScrollbar()
if isFilterWheelActive or transitionLeaveScale ~= 0 then return end if isFilterWheelActive or transitionLeaveScale ~= 0 then return end
-- Scrollbar Background
gfx.BeginPath() gfx.BeginPath()
local resize = 0.85; local resize = 0.85;
local lw, lh = gfx.ImageSize(scrollBarBackgroundImage); local lw, lh = gfx.ImageSize(scrollBarBackgroundImage);
@ -759,6 +760,7 @@ function drawScrollbar()
local backgroundYPos = desh/2 - lh/2 local backgroundYPos = desh/2 - lh/2
gfx.ImageRect(xPos, backgroundYPos, lw, lh, scrollBarBackgroundImage, 1, 0) gfx.ImageRect(xPos, backgroundYPos, lw, lh, scrollBarBackgroundImage, 1, 0)
-- Scrollbar Fill
gfx.BeginPath() gfx.BeginPath()
local sw, sh = gfx.ImageSize(scrollBarFillImage); local sw, sh = gfx.ImageSize(scrollBarFillImage);
local sw = sw * resize; local sw = sw * resize;
@ -770,8 +772,19 @@ function drawScrollbar()
local scrollStep = (maxScrollYPos - minScrollYPos) / (#songwheel.songs - 1); local scrollStep = (maxScrollYPos - minScrollYPos) / (#songwheel.songs - 1);
local scrollbarYOffset = (selectedIndex - 1) * scrollStep; local scrollbarYOffset = (selectedIndex - 1) * scrollStep;
local scrollbarYPos = minScrollYPos + scrollbarYOffset; 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 end