Merge pull request 'reimplement scrollbar for songSelect and folderSelect' (#5) from feature/TASK-21-Scrollbar-fix into master
Reviewed-on: #5
This commit is contained in:
commit
fd39df9099
|
@ -9,8 +9,8 @@ local defaultFolderBgImage = gfx.CreateSkinImage('song_select/filter_wheel/bg.pn
|
||||||
local collectionFolderBgImage = gfx.CreateSkinImage('song_select/filter_wheel/col_bg.png', 0)
|
local collectionFolderBgImage = gfx.CreateSkinImage('song_select/filter_wheel/col_bg.png', 0)
|
||||||
local subFolderBgImage = gfx.CreateSkinImage('song_select/filter_wheel/sub_bg.png', 0)
|
local subFolderBgImage = gfx.CreateSkinImage('song_select/filter_wheel/sub_bg.png', 0)
|
||||||
|
|
||||||
local scrollbarBgImage = gfx.CreateSkinImage("song_select/scrollbar/bg.png", 1)
|
local scrollBarBackgroundImage = gfx.CreateSkinImage("song_select/scrollbar/bg.png", 1)
|
||||||
local scrollbarFillImage = gfx.CreateSkinImage("song_select/scrollbar/fill.png", 1)
|
local scrollBarFillImage = gfx.CreateSkinImage("song_select/scrollbar/fill.png", 1)
|
||||||
|
|
||||||
local cursorImages = {
|
local cursorImages = {
|
||||||
gfx.CreateSkinImage("song_select/cursor.png", 1), -- Effective rate or fallback
|
gfx.CreateSkinImage("song_select/cursor.png", 1), -- Effective rate or fallback
|
||||||
|
@ -283,27 +283,39 @@ function drawScrollbar()
|
||||||
if not isFilterWheelActive or transitionLeaveScale ~= 0 then return end
|
if not isFilterWheelActive or transitionLeaveScale ~= 0 then return end
|
||||||
|
|
||||||
gfx.BeginPath()
|
gfx.BeginPath()
|
||||||
local bgW = 13*0.85;
|
local resize = 0.85;
|
||||||
local bgH = 1282*0.85;
|
local lw, lh = gfx.ImageSize(scrollBarBackgroundImage);
|
||||||
local scrollPosX = desw-20
|
local lw = lw * resize;
|
||||||
local scrollPosY = desh/2-bgH/2
|
local lh = lh * resize;
|
||||||
|
local xPos = desw-20
|
||||||
gfx.ImageRect(scrollPosX, scrollPosY, bgW, bgH, scrollbarBgImage, 1, 0)
|
local backgroundYPos = desh/2 - lh/2
|
||||||
|
gfx.ImageRect(xPos, backgroundYPos, lw, lh, scrollBarBackgroundImage, 1, 0)
|
||||||
local total = game.GetSkinSetting('_songWheelScrollbarTotal')
|
|
||||||
local index = game.GetSkinSetting('_songWheelScrollbarIndex')
|
|
||||||
|
|
||||||
if (index == nil) then return end;
|
|
||||||
|
|
||||||
gfx.BeginPath()
|
gfx.BeginPath()
|
||||||
local fillW = 27*0.85
|
local sw, sh = gfx.ImageSize(scrollBarFillImage);
|
||||||
local fillH = 65*0.85
|
local sw = sw * resize;
|
||||||
local fillPosOffsetY = (bgH-fillH)*(
|
local sh = sh * resize;
|
||||||
(index-1) /
|
local fillXPos = xPos - 6;
|
||||||
math.max(1,total-1)
|
|
||||||
)
|
|
||||||
|
|
||||||
gfx.ImageRect(scrollPosX-6, scrollPosY+fillPosOffsetY, fillW, fillH, scrollbarFillImage, 1, 0)
|
-- figure out index and total
|
||||||
|
local index = 1;
|
||||||
|
local total = 1;
|
||||||
|
if selectionMode == 'folders' then
|
||||||
|
index = selectedFolder
|
||||||
|
total = #filters.folder;
|
||||||
|
else
|
||||||
|
index = selectedLevel
|
||||||
|
total = #filters.level;
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local minScrollYPos = backgroundYPos;
|
||||||
|
local maxScrollYPos = backgroundYPos + lh - sh;
|
||||||
|
local scrollStep = (maxScrollYPos - minScrollYPos) / (total - 1);
|
||||||
|
local scrollbarYOffset = (index - 1) * scrollStep;
|
||||||
|
local scrollbarYPos = minScrollYPos + scrollbarYOffset;
|
||||||
|
|
||||||
|
gfx.ImageRect(fillXPos, scrollbarYPos, sw, sh, scrollBarFillImage, 1, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
function tickTransitions(deltaTime)
|
function tickTransitions(deltaTime)
|
||||||
|
|
|
@ -26,6 +26,9 @@ local top50JacketOverlayImage = gfx.CreateSkinImage("song_select/top50_jacket.pn
|
||||||
|
|
||||||
local diffCursorImage = gfx.CreateSkinImage("song_select/level_cursor.png", 1)
|
local diffCursorImage = gfx.CreateSkinImage("song_select/level_cursor.png", 1)
|
||||||
|
|
||||||
|
local scrollBarBackgroundImage = gfx.CreateSkinImage("song_select/scrollbar/bg.png", 1)
|
||||||
|
local scrollBarFillImage = gfx.CreateSkinImage("song_select/scrollbar/fill.png", 1)
|
||||||
|
|
||||||
local filterInfoBgImage = gfx.CreateSkinImage("song_select/filter_info_bg.png", 1)
|
local filterInfoBgImage = gfx.CreateSkinImage("song_select/filter_info_bg.png", 1)
|
||||||
local sortInfoBgImage = gfx.CreateSkinImage("song_select/sort_info_bg.png", 1)
|
local sortInfoBgImage = gfx.CreateSkinImage("song_select/sort_info_bg.png", 1)
|
||||||
|
|
||||||
|
@ -744,6 +747,34 @@ function drawSearch()
|
||||||
gfx.Text(songwheel.searchText, xPos + 160, yPos + 83.2);
|
gfx.Text(songwheel.searchText, xPos + 160, yPos + 83.2);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function drawScrollbar()
|
||||||
|
if isFilterWheelActive or transitionLeaveScale ~= 0 then return end
|
||||||
|
|
||||||
|
gfx.BeginPath()
|
||||||
|
local resize = 0.85;
|
||||||
|
local lw, lh = gfx.ImageSize(scrollBarBackgroundImage);
|
||||||
|
local lw = lw * resize;
|
||||||
|
local lh = lh * resize;
|
||||||
|
local xPos = desw-20
|
||||||
|
local backgroundYPos = desh/2 - lh/2
|
||||||
|
gfx.ImageRect(xPos, backgroundYPos, lw, lh, scrollBarBackgroundImage, 1, 0)
|
||||||
|
|
||||||
|
gfx.BeginPath()
|
||||||
|
local sw, sh = gfx.ImageSize(scrollBarFillImage);
|
||||||
|
local sw = sw * resize;
|
||||||
|
local sh = sh * resize;
|
||||||
|
local fillXPos = xPos - 6;
|
||||||
|
|
||||||
|
local minScrollYPos = backgroundYPos;
|
||||||
|
local maxScrollYPos = backgroundYPos + lh - sh;
|
||||||
|
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)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
function refreshIrLeaderboard(deltaTime)
|
function refreshIrLeaderboard(deltaTime)
|
||||||
if not IRData.Active then
|
if not IRData.Active then
|
||||||
return;
|
return;
|
||||||
|
@ -1030,6 +1061,8 @@ draw_songwheel = function(x,y,w,h, deltaTime)
|
||||||
|
|
||||||
drawSearch();
|
drawSearch();
|
||||||
|
|
||||||
|
drawScrollbar();
|
||||||
|
|
||||||
gfx.BeginPath();
|
gfx.BeginPath();
|
||||||
gfx.FontSize(18)
|
gfx.FontSize(18)
|
||||||
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_TOP)
|
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_TOP)
|
||||||
|
|
Loading…
Reference in New Issue