From c7bc3ca2d8f35d4bd93ba410fa32ef2d5f1867cf Mon Sep 17 00:00:00 2001 From: FajsiEx Date: Fri, 27 Aug 2021 20:18:55 +0200 Subject: [PATCH] * move the scrollbar and cursor drawing from songwheel to filterwheel to prevent z-index clashing --- scripts/songselect/filterwheel.lua | 38 +++++++++++++++++++-- scripts/songselect/songwheel.lua | 54 +++++++++++------------------- 2 files changed, 54 insertions(+), 38 deletions(-) diff --git a/scripts/songselect/filterwheel.lua b/scripts/songselect/filterwheel.lua index 4549d9e..b189bc2 100644 --- a/scripts/songselect/filterwheel.lua +++ b/scripts/songselect/filterwheel.lua @@ -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 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 = { gfx.CreateSkinImage("song_select/cursor.png", 1), -- Effective rate or fallback 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) 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) if transitionScrollScale < 1 then transitionScrollScale = transitionScrollScale + deltaTime / 0.1 -- transition should last for that time in seconds @@ -280,8 +306,6 @@ function drawFilterWheel(deltatime) gfx.Scale(scale, scale); drawFolderList() - - drawCursor() end render = function(deltatime, shown) @@ -289,16 +313,24 @@ render = function(deltatime, shown) game.SetSkinSetting('_songWheelOverlayActive', 0); transitionEnterReverse = true - if (transitionEnterScale > 0) then drawFilterWheel(deltatime) end + if (transitionEnterScale > 0) then + drawFilterWheel(deltatime) + else + game.SetSkinSetting('_songWheelDespawnSelectorElements', 0); + end else transitionEnterReverse = false game.SetSkinSetting('_songWheelOverlayActive', 1); + game.SetSkinSetting('_songWheelDespawnSelectorElements', 1); drawFilterWheel(deltatime) end game.SetSkinSetting('_songWheelActiveFolderLabel', getFolderData(filters.folder[selectedFolder]).label); game.SetSkinSetting('_songWheelActiveSubFolderLabel', getFolderData(filters.level[selectedLevel]).label); + drawCursor() + drawScrollbar() + SongSelectHeader.draw(deltatime); Footer.draw(deltatime); diff --git a/scripts/songselect/songwheel.lua b/scripts/songselect/songwheel.lua index 2d9083a..338c270 100644 --- a/scripts/songselect/songwheel.lua +++ b/scripts/songselect/songwheel.lua @@ -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 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 top50OverlayImage = gfx.CreateSkinImage("song_select/top50.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 filterInfoBgImage = gfx.CreateSkinImage("song_select/filter_info_bg.png", 1) @@ -382,34 +372,21 @@ function drawSongList() end; end -function drawCursor() - gfx.BeginPath() +-- function drawCursor() +-- -- 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') - local cursorImage = cursorImages[cursorImageIndex or 1]; +-- gfx.BeginPath() - gfx.ImageRect(desw/2-14, desh/2-213/2, 555, 213, cursorImage, 1, 0) -end +-- local cursorImageIndex = game.GetSkinSetting('_gaugeType') +-- local cursorImage = cursorImages[cursorImageIndex or 1]; -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(desw/2-14, desh/2-213/2, 555, 213, cursorImage, 1, 0) +-- end - 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"); function drawData() -- Draws the song data on the left panel @@ -713,8 +690,8 @@ render = function (deltaTime) drawBackground(deltaTime); drawSongList() - drawCursor() - drawScrollbar() + -- drawCursor() + -- drawScrollbar() drawData() @@ -739,6 +716,9 @@ end songs_changed = function (withAll) if not withAll then return end + game.SetSkinSetting('_songWheelScrollbarTotal', #songwheel.songs) + game.SetSkinSetting('_songWheelScrollbarIndex', selectedIndex) + local diffs = {} for i = 1, #songwheel.allSongs do local song = songwheel.allSongs[i] @@ -767,6 +747,10 @@ set_index = function(newIndex) transitionAfterscrollScale = 0; transitionJacketBgScrollScale = 0; + + game.SetSkinSetting('_songWheelScrollbarTotal', #songwheel.songs) + game.SetSkinSetting('_songWheelScrollbarIndex', newIndex) + scrollingUp = false; if ((newIndex > selectedIndex and not (newIndex == #songwheel.songs and selectedIndex == 1)) or (newIndex == 1 and selectedIndex == #songwheel.songs)) then scrollingUp = true;