feature/TASK-4-Search-Bar-Rework #3

Merged
Kuenaimaku merged 3 commits from feature/TASK-4-Search-Bar-Rework into master 2022-03-12 23:48:51 +01:00
4 changed files with 114 additions and 9 deletions

View File

@ -57,6 +57,12 @@
"default": false "default": false
}, },
"gameplay_showSearchControls": {
"label": "Show song select controls when searching",
"type": "bool",
"default": true
},
"separator_f": {}, "separator_f": {},
"Debug": { "type": "label" }, "Debug": { "type": "label" },

View File

@ -30,9 +30,13 @@ local filterInfoBgImage = gfx.CreateSkinImage("song_select/filter_info_bg.png",
local sortInfoBgImage = gfx.CreateSkinImage("song_select/sort_info_bg.png", 1) local sortInfoBgImage = gfx.CreateSkinImage("song_select/sort_info_bg.png", 1)
local searchBgImage = gfx.CreateSkinImage("song_select/search_bg.png", 1) local searchBgImage = gfx.CreateSkinImage("song_select/search_bg.png", 1)
local searchActiveImage = gfx.CreateSkinImage("song_select/search_active.png", 1)
local searchInfoPanelImage = gfx.CreateSkinImage("song_select/search_info_panel.png", 1)
local defaultJacketImage = gfx.CreateSkinImage("song_select/loading.png", 0) local defaultJacketImage = gfx.CreateSkinImage("song_select/loading.png", 0)
local difficultyLabelImages = { local difficultyLabelImages = {
gfx.CreateSkinImage("song_select/plate/difficulty_labels/novice.png", 1), gfx.CreateSkinImage("song_select/plate/difficulty_labels/novice.png", 1),
gfx.CreateSkinImage("song_select/plate/difficulty_labels/advanced.png", 1), gfx.CreateSkinImage("song_select/plate/difficulty_labels/advanced.png", 1),
@ -140,6 +144,15 @@ local transitionJacketBgScrollScale = 0;
local transitionJacketBgScrollAlpha = 0; local transitionJacketBgScrollAlpha = 0;
local transitionJacketBgScrollPosX = 0; local transitionJacketBgScrollPosX = 0;
--search
local searchPreviousActiveState = false;
local searchInfoPreviousActiveState = false;
local transitionSearchEnterScale = 0;
local transitionSearchInfoEnterScale = 0;
local transitionSearchBackgroundAlpha = 0;
local transitionSearchbarOffsetY = 0;
local transitionSearchInfoOffsetY = 0;
local transitionLaserScale = 0; local transitionLaserScale = 0;
local transitionLaserY = 0; local transitionLaserY = 0;
@ -624,7 +637,7 @@ function drawFilterInfo(deltatime)
gfx.LoadSkinFont('NotoSans-Regular.ttf') gfx.LoadSkinFont('NotoSans-Regular.ttf')
if (songwheel.searchInputActive) then if (songwheel.searchInputActive) then
return; --return;
end end
gfx.BeginPath() gfx.BeginPath()
@ -662,22 +675,73 @@ function drawCursor()
end end
function drawSearch() function drawSearch()
if (not songwheel.searchInputActive) then if (not songwheel.searchInputActive and searchPreviousActiveState) then
searchPreviousActiveState = false;
game.PlaySample('sort_wheel/enter.wav');
elseif (songwheel.searchInputActive and not searchPreviousActiveState) then
searchPreviousActiveState = true;
game.PlaySample('sort_wheel/leave.wav');
end
if (songwheel.searchText ~= '' and searchInfoPreviousActiveState == true) then
searchInfoPreviousActiveState = false;
elseif (songwheel.searchText == '' and searchInfoPreviousActiveState == false) then
searchInfoPreviousActiveState = true;
end
if (transitionSearchEnterScale == 0) then
return; return;
end end
-- Draw dark overlay over Songwheel
gfx.BeginPath(); gfx.BeginPath();
local tw, th = gfx.ImageSize(searchBgImage) gfx.FillColor(0, 0, 0, math.floor(transitionSearchBackgroundAlpha * 192));
local xPos = desw-tw/2; gfx.Rect(0, 0, 1080, 1920);
local yPos = 90; gfx.Fill();
gfx.ImageRect(xPos, yPos, tw/2, th/2, searchBgImage, 1, 0) -- Draw search info panel
gfx.BeginPath();
local infoResize = 0.855;
local sw, sh = gfx.ImageSize(searchInfoPanelImage)
sw = sw * infoResize;
sh = sh * infoResize;
local infoXPos = 0;
local infoYStartPos = desh - sh - 772 + 242;
local infoYPos = infoYStartPos + transitionSearchInfoOffsetY;
gfx.FontSize(32); if (game.GetSkinSetting('gameplay_showSearchControls')) then
gfx.ImageRect(infoXPos, infoYPos, sw, sh, searchInfoPanelImage, transitionSearchBackgroundInfoAlpha, 0)
end
-- Draw Search is Active text
gfx.BeginPath();
local activeResize = 0.855;
local activew, activeh = gfx.ImageSize(searchActiveImage)
activew = activew * activeResize;
activeh = activeh * activeResize;
local activeXPos = 0;
local activeYStartPos = desh - sh - 722;
local activeYPos = activeYStartPos + transitionSearchInfoOffsetY;
gfx.ImageRect(activeXPos, activeYPos, activew, activeh, searchActiveImage, 1, 0);
-- Draw Searchbox
gfx.BeginPath();
local searchResize = 0.8;
local tw, th = gfx.ImageSize(searchBgImage);
tw = tw * searchResize;
th = th * searchResize;
local xPos = (desw-tw)/2;
local yStartPos = 170;
local yPos = yStartPos - transitionSearchbarOffsetY
gfx.ImageRect(xPos, yPos, tw, th, searchBgImage, 1, 0)
gfx.FontSize(48);
gfx.LoadSkinFont('Digital-Serial-Bold.ttf') gfx.LoadSkinFont('Digital-Serial-Bold.ttf')
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE) gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE)
gfx.Text(songwheel.searchText, xPos+100, yPos+52); gfx.Text(songwheel.searchText, xPos + 160, yPos + 83.2);
end end
function refreshIrLeaderboard(deltaTime) function refreshIrLeaderboard(deltaTime)
@ -786,6 +850,41 @@ function tickTransitions(deltaTime)
transitionAfterscrollDataOverlayAlpha = 1; transitionAfterscrollDataOverlayAlpha = 1;
end end
-- Searchbar offsets and alpha
if not searchPreviousActiveState then
if transitionSearchEnterScale > 0 then
transitionSearchEnterScale = transitionSearchEnterScale - deltaTime / 0.5 -- transition should last for that time in seconds
else
transitionSearchEnterScale = 0
end
else
if transitionSearchEnterScale < 1 then
transitionSearchEnterScale = transitionSearchEnterScale + deltaTime / 0.5 -- transition should last for that time in seconds
else
transitionSearchEnterScale = 1
end
end
transitionSearchInfoOffsetY = Easing.inOutQuad(1 - transitionSearchEnterScale) * 1680
transitionSearchbarOffsetY = Easing.inOutQuad(1 - transitionSearchEnterScale) * 300
transitionSearchBackgroundAlpha = Easing.inOutQuad(transitionSearchEnterScale)
if not searchInfoPreviousActiveState then
if transitionSearchInfoEnterScale > 0 then
transitionSearchInfoEnterScale = transitionSearchInfoEnterScale - deltaTime / 0.25 -- transition should last for that time in seconds
else
transitionSearchInfoEnterScale = 0
end
else
if transitionSearchInfoEnterScale < 1 then
transitionSearchInfoEnterScale = transitionSearchInfoEnterScale + deltaTime / 0.25 -- transition should last for that time in seconds
else
transitionSearchInfoEnterScale = 1
end
end
transitionSearchBackgroundInfoAlpha = Easing.inOutQuad(transitionSearchInfoEnterScale)
-- Grade alpha -- Grade alpha
if transitionAfterscrollScale >= 0.03 and transitionAfterscrollScale < 0.033 then if transitionAfterscrollScale >= 0.03 and transitionAfterscrollScale < 0.033 then
transitionAfterscrollGradeAlpha = 0.5; transitionAfterscrollGradeAlpha = 0.5;

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 KiB

After

Width:  |  Height:  |  Size: 1.1 MiB