* move the scrollbar and cursor drawing from songwheel to filterwheel to prevent z-index clashing

This commit is contained in:
FajsiEx 2021-08-27 20:18:55 +02:00
parent 58bff25db5
commit c7bc3ca2d8
2 changed files with 54 additions and 38 deletions

View File

@ -7,6 +7,9 @@ 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 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
gfx.CreateSkinImage("song_select/cursor_exc.png", 1), -- Excessive rate gfx.CreateSkinImage("song_select/cursor_exc.png", 1), -- Excessive rate
@ -238,6 +241,29 @@ function drawCursor()
gfx.ImageRect(desw / 2 - 14, desh / 2 - 213 / 2, 555, 213, cursorImage, 1, 0) gfx.ImageRect(desw / 2 - 14, desh / 2 - 213 / 2, 555, 213, cursorImage, 1, 0)
end end
function drawScrollbar()
gfx.BeginPath()
local bgW = 13*0.85;
local bgH = 1282*0.85;
local scrollPosX = desw-20
local scrollPosY = desh/2-bgH/2
gfx.ImageRect(scrollPosX, scrollPosY, bgW, bgH, scrollbarBgImage, 1, 0)
local total = game.GetSkinSetting('_songWheelScrollbarTotal')
local index = game.GetSkinSetting('_songWheelScrollbarIndex')
gfx.BeginPath()
local fillW = 27*0.85
local fillH = 65*0.85
local fillPosOffsetY = (bgH-fillH)*(
(index-1) /
math.max(1,total-1)
)
gfx.ImageRect(scrollPosX-6, scrollPosY+fillPosOffsetY, fillW, fillH, scrollbarFillImage, 1, 0)
end
function tickTransitions(deltaTime) function tickTransitions(deltaTime)
if transitionScrollScale < 1 then if transitionScrollScale < 1 then
transitionScrollScale = transitionScrollScale + deltaTime / 0.1 -- transition should last for that time in seconds transitionScrollScale = transitionScrollScale + deltaTime / 0.1 -- transition should last for that time in seconds
@ -280,8 +306,6 @@ function drawFilterWheel(deltatime)
gfx.Scale(scale, scale); gfx.Scale(scale, scale);
drawFolderList() drawFolderList()
drawCursor()
end end
render = function(deltatime, shown) render = function(deltatime, shown)
@ -289,16 +313,24 @@ render = function(deltatime, shown)
game.SetSkinSetting('_songWheelOverlayActive', 0); game.SetSkinSetting('_songWheelOverlayActive', 0);
transitionEnterReverse = true transitionEnterReverse = true
if (transitionEnterScale > 0) then drawFilterWheel(deltatime) end if (transitionEnterScale > 0) then
drawFilterWheel(deltatime)
else
game.SetSkinSetting('_songWheelDespawnSelectorElements', 0);
end
else else
transitionEnterReverse = false transitionEnterReverse = false
game.SetSkinSetting('_songWheelOverlayActive', 1); game.SetSkinSetting('_songWheelOverlayActive', 1);
game.SetSkinSetting('_songWheelDespawnSelectorElements', 1);
drawFilterWheel(deltatime) drawFilterWheel(deltatime)
end end
game.SetSkinSetting('_songWheelActiveFolderLabel', getFolderData(filters.folder[selectedFolder]).label); game.SetSkinSetting('_songWheelActiveFolderLabel', getFolderData(filters.folder[selectedFolder]).label);
game.SetSkinSetting('_songWheelActiveSubFolderLabel', getFolderData(filters.level[selectedLevel]).label); game.SetSkinSetting('_songWheelActiveSubFolderLabel', getFolderData(filters.level[selectedLevel]).label);
drawCursor()
drawScrollbar()
SongSelectHeader.draw(deltatime); SongSelectHeader.draw(deltatime);
Footer.draw(deltatime); Footer.draw(deltatime);

View File

@ -13,21 +13,11 @@ local illustratedBgImage = gfx.CreateSkinImage("song_select/data_panel/illust_bg
local songPlateBg = gfx.CreateSkinImage("song_select/plate/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 songPlateBottomBarOverlayImage = gfx.CreateSkinImage("song_select/plate/bottom_bar_overlay.png", 1)
local scrollbarBgImage = gfx.CreateSkinImage("song_select/scrollbar/bg.png", 1)
local scrollbarFillImage = gfx.CreateSkinImage("song_select/scrollbar/fill.png", 1)
local laserAnimBaseImage = gfx.CreateSkinImage("song_select/laser_anim.png", 1) local laserAnimBaseImage = gfx.CreateSkinImage("song_select/laser_anim.png", 1)
local top50OverlayImage = gfx.CreateSkinImage("song_select/top50.png", 1) local top50OverlayImage = gfx.CreateSkinImage("song_select/top50.png", 1)
local top50JacketOverlayImage = gfx.CreateSkinImage("song_select/top50_jacket.png", 1) local top50JacketOverlayImage = gfx.CreateSkinImage("song_select/top50_jacket.png", 1)
local cursorImages = {
gfx.CreateSkinImage("song_select/cursor.png", 1), -- Effective rate or fallback
gfx.CreateSkinImage("song_select/cursor_exc.png", 1), -- Excessive rate
gfx.CreateSkinImage("song_select/cursor_perm.png", 1), -- Premissive rate
gfx.CreateSkinImage("song_select/cursor_blast.png", 1), -- Blastive rate
}
local diffCursorImage = gfx.CreateSkinImage("song_select/level_cursor.png", 1) local diffCursorImage = gfx.CreateSkinImage("song_select/level_cursor.png", 1)
local filterInfoBgImage = gfx.CreateSkinImage("song_select/filter_info_bg.png", 1) local filterInfoBgImage = gfx.CreateSkinImage("song_select/filter_info_bg.png", 1)
@ -382,34 +372,21 @@ function drawSongList()
end; end;
end end
function drawCursor() -- function drawCursor()
gfx.BeginPath() -- -- If the filter wheel is active or the songwheel is in the process of leaving, don't draw the cursor and leave it up to the filter wheel
-- if (game.GetSkinSetting('_songWheelDespawnSelectorElements') == 1) then
-- return
-- end
local cursorImageIndex = game.GetSkinSetting('_gaugeType') -- gfx.BeginPath()
local cursorImage = cursorImages[cursorImageIndex or 1];
gfx.ImageRect(desw/2-14, desh/2-213/2, 555, 213, cursorImage, 1, 0) -- local cursorImageIndex = game.GetSkinSetting('_gaugeType')
end -- local cursorImage = cursorImages[cursorImageIndex or 1];
function drawScrollbar() -- gfx.ImageRect(desw/2-14, desh/2-213/2, 555, 213, cursorImage, 1, 0)
gfx.BeginPath() -- end
local bgW = 13*0.85;
local bgH = 1282*0.85;
local scrollPosX = desw-20
local scrollPosY = desh/2-bgH/2
gfx.ImageRect(scrollPosX, scrollPosY, bgW, bgH, scrollbarBgImage, 1, 0)
gfx.BeginPath()
local fillW = 27*0.85
local fillH = 65*0.85
local fillPosOffsetY = (bgH-fillH)*(
(selectedIndex-1) /
math.max(1,#songwheel.songs-1)
)
gfx.ImageRect(scrollPosX-6, scrollPosY+fillPosOffsetY, fillW, fillH, scrollbarFillImage, 1, 0)
end
local scoreNumbers = load_number_image("score_num"); local scoreNumbers = load_number_image("score_num");
function drawData() -- Draws the song data on the left panel function drawData() -- Draws the song data on the left panel
@ -713,8 +690,8 @@ render = function (deltaTime)
drawBackground(deltaTime); drawBackground(deltaTime);
drawSongList() drawSongList()
drawCursor() -- drawCursor()
drawScrollbar() -- drawScrollbar()
drawData() drawData()
@ -739,6 +716,9 @@ end
songs_changed = function (withAll) songs_changed = function (withAll)
if not withAll then return end if not withAll then return end
game.SetSkinSetting('_songWheelScrollbarTotal', #songwheel.songs)
game.SetSkinSetting('_songWheelScrollbarIndex', selectedIndex)
local diffs = {} local diffs = {}
for i = 1, #songwheel.allSongs do for i = 1, #songwheel.allSongs do
local song = songwheel.allSongs[i] local song = songwheel.allSongs[i]
@ -767,6 +747,10 @@ set_index = function(newIndex)
transitionAfterscrollScale = 0; transitionAfterscrollScale = 0;
transitionJacketBgScrollScale = 0; transitionJacketBgScrollScale = 0;
game.SetSkinSetting('_songWheelScrollbarTotal', #songwheel.songs)
game.SetSkinSetting('_songWheelScrollbarIndex', newIndex)
scrollingUp = false; scrollingUp = false;
if ((newIndex > selectedIndex and not (newIndex == #songwheel.songs and selectedIndex == 1)) or (newIndex == 1 and selectedIndex == #songwheel.songs)) then if ((newIndex > selectedIndex and not (newIndex == #songwheel.songs and selectedIndex == 1)) or (newIndex == 1 and selectedIndex == #songwheel.songs)) then
scrollingUp = true; scrollingUp = true;