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
1 changed files with 75 additions and 9 deletions
Showing only changes of commit 20e4cb4150 - Show all commits

View File

@ -30,6 +30,7 @@ local filterInfoBgImage = gfx.CreateSkinImage("song_select/filter_info_bg.png",
local sortInfoBgImage = gfx.CreateSkinImage("song_select/sort_info_bg.png", 1)
local searchBgImage = gfx.CreateSkinImage("song_select/search_bg.png", 1)
local searchInfoPanelImage = gfx.CreateSkinImage("song_select/search_info_panel.png", 1)
local defaultJacketImage = gfx.CreateSkinImage("song_select/loading.png", 0)
@ -140,6 +141,13 @@ local transitionJacketBgScrollScale = 0;
local transitionJacketBgScrollAlpha = 0;
local transitionJacketBgScrollPosX = 0;
--search
local searchPreviousActiveState = false;
local transitionSearchEnterScale = 0;
local transitionSearchBackgroundAlpha = 0;
local transitionSearchbarOffsetY = 0;
local transitionSearchInfoOffsetY = 0;
local transitionLaserScale = 0;
local transitionLaserY = 0;
@ -624,7 +632,7 @@ function drawFilterInfo(deltatime)
gfx.LoadSkinFont('NotoSans-Regular.ttf')
if (songwheel.searchInputActive) then
return;
--return;
end
gfx.BeginPath()
@ -662,22 +670,61 @@ function drawCursor()
end
function drawSearch()
if (not songwheel.searchInputActive) then
return;
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 (transitionSearchEnterScale == 0) then
return;
end
-- Draw dark overlay over Songwheel
gfx.BeginPath();
local tw, th = gfx.ImageSize(searchBgImage)
local xPos = desw-tw/2;
local yPos = 90;
gfx.FillColor(0, 0, 0, math.floor(transitionSearchBackgroundAlpha * 192));
gfx.Rect(0, 0, 1080, 1920);
gfx.Fill();
gfx.ImageRect(xPos, yPos, tw/2, th/2, searchBgImage, 1, 0)
-- Draw search info panel
gfx.BeginPath();
local infoAlpha = 0;
gfx.FontSize(32);
if (songwheel.searchText ~= '') then
infoAlpha = 0;
else
infoAlpha = 1;
end
local infoResize = 0.855;
local sw, sh = gfx.ImageSize(searchInfoPanelImage)
sw = sw * infoResize;
sh = sh * infoResize;
local infoXPos = 0;
local infoYStartPos = desh - sh - 550;
local infoYPos = infoYStartPos + transitionSearchInfoOffsetY;
gfx.ImageRect(infoXPos, infoYPos, sw, sh, searchInfoPanelImage, infoAlpha, 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.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
function refreshIrLeaderboard(deltaTime)
@ -786,6 +833,25 @@ function tickTransitions(deltaTime)
transitionAfterscrollDataOverlayAlpha = 1;
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)
-- Grade alpha
if transitionAfterscrollScale >= 0.03 and transitionAfterscrollScale < 0.033 then
transitionAfterscrollGradeAlpha = 0.5;