From a3fa6350c10ed63f3324bfb281acb82679f7137e Mon Sep 17 00:00:00 2001 From: Kyle Humphrey Date: Wed, 16 Mar 2022 02:24:02 -0500 Subject: [PATCH] add letter on scrollbar in SongWheel --- README.md | 1 + scripts/common/common.lua | 7 ++++++- scripts/songselect/songwheel.lua | 15 ++++++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a6ba0f5..21d672e 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Project Starter: GSK Bladez - Hoshikara - GSK Bladez - Local +- Kuenaimaku ## Graphics - GSK Bladez diff --git a/scripts/common/common.lua b/scripts/common/common.lua index 4fa8d9f..137f190 100644 --- a/scripts/common/common.lua +++ b/scripts/common/common.lua @@ -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 } \ No newline at end of file diff --git a/scripts/songselect/songwheel.lua b/scripts/songselect/songwheel.lua index c4cd5c9..3efcb8d 100644 --- a/scripts/songselect/songwheel.lua +++ b/scripts/songselect/songwheel.lua @@ -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 -- 2.40.1