+ proper transition to sortwheel
This commit is contained in:
parent
52b2c02ed2
commit
d576a1ce2c
|
@ -1,8 +1,12 @@
|
||||||
|
require('common')
|
||||||
|
local Easing = require('common.easings');
|
||||||
|
|
||||||
-- IMAGES
|
-- IMAGES
|
||||||
local panelBgImage = gfx.CreateSkinImage('song_select/sort_wheel/bg.png', 0)
|
local panelBgImage = gfx.CreateSkinImage('song_select/sort_wheel/bg.png', 0)
|
||||||
local activeItemBgImage = gfx.CreateSkinImage(
|
local activeItemBgImage = gfx.CreateSkinImage(
|
||||||
'song_select/sort_wheel/active_bg.png', 0)
|
'song_select/sort_wheel/active_bg.png', 0)
|
||||||
local titleTextImage = gfx.CreateSkinImage('song_select/sort_wheel/title.png', 0)
|
local titleTextImage =
|
||||||
|
gfx.CreateSkinImage('song_select/sort_wheel/title.png', 0)
|
||||||
|
|
||||||
resx, resy = game.GetResolution()
|
resx, resy = game.GetResolution()
|
||||||
local desw, desh = 1080, 1920;
|
local desw, desh = 1080, 1920;
|
||||||
|
@ -21,33 +25,22 @@ local SORT_ORDER_LABEL_TEXTS = {
|
||||||
label = 'Title',
|
label = 'Title',
|
||||||
asc = '# to A to Z to かな to 漢字',
|
asc = '# to A to Z to かな to 漢字',
|
||||||
dsc = '漢字 to かな to Z to A to #'
|
dsc = '漢字 to かな to Z to A to #'
|
||||||
},
|
}, {label = 'Score', asc = 'Worst to best', dsc = 'Best to worst'},
|
||||||
{
|
{label = 'Date', asc = 'Oldest to newest', dsc = 'Newest to oldest'},
|
||||||
label = 'Score',
|
{label = 'Badge', asc = 'None to D to S', dsc = 'S to D to None'}, {
|
||||||
asc = 'Worst to best',
|
|
||||||
dsc = 'Best to worst'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label = 'Date',
|
|
||||||
asc = 'Oldest to newest',
|
|
||||||
dsc = 'Newest to oldest'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label = 'Badge',
|
|
||||||
asc = 'None to D to S',
|
|
||||||
dsc = 'S to D to None'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label = 'Artist',
|
label = 'Artist',
|
||||||
asc = '# to A to Z to かな to 漢字',
|
asc = '# to A to Z to かな to 漢字',
|
||||||
dsc = '漢字 to かな to Z to A to #'
|
dsc = '漢字 to かな to Z to A to #'
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
label = 'Effector',
|
label = 'Effector',
|
||||||
asc = '# to A to Z to かな to 漢字',
|
asc = '# to A to Z to かな to 漢字',
|
||||||
dsc = '漢字 to かな to Z to A to #'
|
dsc = '漢字 to かな to Z to A to #'
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
local transitionEnterReverse = false;
|
||||||
|
local transitionEnterScale = 0;
|
||||||
|
local transitionEnterOffsetX = 0;
|
||||||
|
|
||||||
function resetLayoutInformation()
|
function resetLayoutInformation()
|
||||||
resx, resy = game.GetResolution()
|
resx, resy = game.GetResolution()
|
||||||
|
@ -55,9 +48,7 @@ function resetLayoutInformation()
|
||||||
end
|
end
|
||||||
|
|
||||||
function tableContains(table, value)
|
function tableContains(table, value)
|
||||||
for i,v in ipairs(table) do
|
for i, v in ipairs(table) do if v == value then return true end end
|
||||||
if v==value then return true end
|
|
||||||
end
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
end
|
end
|
||||||
|
@ -66,9 +57,7 @@ function drawButton(i,f,x,y)
|
||||||
local spaceAfter = (FONT_SIZE + MARGIN)
|
local spaceAfter = (FONT_SIZE + MARGIN)
|
||||||
|
|
||||||
local sortOrder = 'asc';
|
local sortOrder = 'asc';
|
||||||
if (string.find(f, 'v')) then
|
if (string.find(f, 'v')) then sortOrder = 'dsc' end
|
||||||
sortOrder = 'dsc'
|
|
||||||
end
|
|
||||||
|
|
||||||
local label = f:gsub(' ^', '')
|
local label = f:gsub(' ^', '')
|
||||||
label = label:gsub(' v', '')
|
label = label:gsub(' v', '')
|
||||||
|
@ -78,9 +67,7 @@ function drawButton(i,f,x,y)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
-- If there is no active button with this label, if one with a label was already rendered, don't render this one
|
-- If there is no active button with this label, if one with a label was already rendered, don't render this one
|
||||||
if (tableContains(renderedButtonLabels, label)) then
|
if (tableContains(renderedButtonLabels, label)) then return 0; end
|
||||||
return 0;
|
|
||||||
end
|
|
||||||
table.insert(renderedButtonLabels, label);
|
table.insert(renderedButtonLabels, label);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -100,18 +87,21 @@ function drawButton(i,f,x,y)
|
||||||
|
|
||||||
gfx.BeginPath()
|
gfx.BeginPath()
|
||||||
if sortOrder == 'asc' then
|
if sortOrder == 'asc' then
|
||||||
gfx.ImageRect(x-150, y+FONT_SIZE+SUB_MARGIN*2-31, 300, 67, activeItemBgImage, 1, 0)
|
gfx.ImageRect(x - 150, y + FONT_SIZE + SUB_MARGIN * 2 - 31, 300, 67,
|
||||||
|
activeItemBgImage, 1, 0)
|
||||||
elseif sortOrder == 'dsc' then
|
elseif sortOrder == 'dsc' then
|
||||||
gfx.ImageRect(x-150, y+FONT_SIZE+SUB_MARGIN*2+SUB_FONT_SIZE+SUB_MARGIN-31, 300, 67, activeItemBgImage, 1, 0)
|
gfx.ImageRect(x - 150, y + FONT_SIZE + SUB_MARGIN * 2 +
|
||||||
|
SUB_FONT_SIZE + SUB_MARGIN - 31, 300, 67,
|
||||||
|
activeItemBgImage, 1, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
gfx.Save()
|
gfx.Save()
|
||||||
gfx.FontSize(SUB_FONT_SIZE)
|
gfx.FontSize(SUB_FONT_SIZE)
|
||||||
gfx.Text(ascLabelText, x, y + FONT_SIZE + SUB_MARGIN * 2);
|
gfx.Text(ascLabelText, x, y + FONT_SIZE + SUB_MARGIN * 2);
|
||||||
gfx.Text(dscLabelText, x, y+FONT_SIZE+SUB_MARGIN*2+SUB_FONT_SIZE+SUB_MARGIN);
|
gfx.Text(dscLabelText, x,
|
||||||
|
y + FONT_SIZE + SUB_MARGIN * 2 + SUB_FONT_SIZE + SUB_MARGIN);
|
||||||
gfx.Restore()
|
gfx.Restore()
|
||||||
|
|
||||||
|
|
||||||
spaceAfter = spaceAfter + SUB_FONT_SIZE * 2 + SUB_MARGIN * 4;
|
spaceAfter = spaceAfter + SUB_FONT_SIZE * 2 + SUB_MARGIN * 4;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -121,32 +111,46 @@ function drawButton(i,f,x,y)
|
||||||
return spaceAfter;
|
return spaceAfter;
|
||||||
end
|
end
|
||||||
|
|
||||||
function render(deltaTime, shown)
|
function tickTransitions(deltaTime)
|
||||||
if not shown then return end
|
-- ENTRY TRANSITION
|
||||||
gfx.Save()
|
if transitionEnterReverse then
|
||||||
gfx.ResetTransform()
|
if transitionEnterScale > 0 then
|
||||||
|
transitionEnterScale = transitionEnterScale - deltaTime / 0.25 -- transition should last for that time in seconds
|
||||||
|
else
|
||||||
|
transitionEnterScale = 0
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if transitionEnterScale < 1 then
|
||||||
|
transitionEnterScale = transitionEnterScale + deltaTime / 0.25 -- transition should last for that time in seconds
|
||||||
|
else
|
||||||
|
transitionEnterScale = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
renderedButtonLabels = {};
|
transitionEnterOffsetX = Easing.inOutQuad(1 - transitionEnterScale) * 416
|
||||||
resetLayoutInformation()
|
end
|
||||||
gfx.Scale(scale, scale)
|
|
||||||
|
|
||||||
|
function drawSortWheel(deltaTime)
|
||||||
-- Draw the dark overlay above song wheel
|
-- Draw the dark overlay above song wheel
|
||||||
gfx.BeginPath();
|
gfx.BeginPath();
|
||||||
gfx.FillColor(0, 0, 0, 192);
|
gfx.FillColor(0, 0, 0, math.floor(transitionEnterScale * 192));
|
||||||
gfx.Rect(0, 0, desw, desh);
|
gfx.Rect(0, 0, desw, desh);
|
||||||
gfx.Fill();
|
gfx.Fill();
|
||||||
|
|
||||||
-- Draw the panel background
|
-- Draw the panel background
|
||||||
gfx.BeginPath()
|
gfx.BeginPath()
|
||||||
gfx.ImageRect(desw - 416, 0, 416, desh, panelBgImage, 1, 0)
|
gfx.ImageRect(desw - 416 + transitionEnterOffsetX, 0, 416, desh,
|
||||||
|
panelBgImage, 1, 0)
|
||||||
|
|
||||||
gfx.LoadSkinFont("Digital-Serial-Bold.ttf");
|
gfx.LoadSkinFont("Digital-Serial-Bold.ttf");
|
||||||
gfx.FontSize(FONT_SIZE);
|
gfx.FontSize(FONT_SIZE);
|
||||||
gfx.FillColor(255, 255, 255, 255);
|
gfx.FillColor(255, 255, 255, 255);
|
||||||
gfx.TextAlign(gfx.TEXT_ALIGN_CENTER + gfx.TEXT_ALIGN_MIDDLE);
|
gfx.TextAlign(gfx.TEXT_ALIGN_CENTER + gfx.TEXT_ALIGN_MIDDLE);
|
||||||
|
|
||||||
|
gfx.GlobalAlpha(transitionEnterScale)
|
||||||
|
|
||||||
-- Starting position of the first sort option
|
-- Starting position of the first sort option
|
||||||
local x = 889;
|
local x = 889 + transitionEnterOffsetX;
|
||||||
local y = desh / 2 - -- Center point
|
local y = desh / 2 - -- Center point
|
||||||
(#sorts / 2 / 2) * (FONT_SIZE + MARGIN) - -- Space taken up by half the sort options (we remove the duplicate one)
|
(#sorts / 2 / 2) * (FONT_SIZE + MARGIN) - -- Space taken up by half the sort options (we remove the duplicate one)
|
||||||
((SUB_FONT_SIZE * 2 + SUB_MARGIN * 4) / 2); -- Space for taken by order options
|
((SUB_FONT_SIZE * 2 + SUB_MARGIN * 4) / 2); -- Space for taken by order options
|
||||||
|
@ -161,6 +165,24 @@ function render(deltaTime, shown)
|
||||||
local spaceAfter = drawButton(i, f, x, y);
|
local spaceAfter = drawButton(i, f, x, y);
|
||||||
y = y + spaceAfter;
|
y = y + spaceAfter;
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function render(deltaTime, shown)
|
||||||
|
gfx.Save()
|
||||||
|
gfx.ResetTransform()
|
||||||
|
if not shown then
|
||||||
|
transitionEnterReverse = true
|
||||||
|
if (transitionEnterScale > 0) then drawSortWheel(deltaTime) end
|
||||||
|
else
|
||||||
|
transitionEnterReverse = false
|
||||||
|
drawSortWheel(deltaTime)
|
||||||
|
end
|
||||||
|
tickTransitions(deltaTime)
|
||||||
|
|
||||||
|
renderedButtonLabels = {};
|
||||||
|
resetLayoutInformation()
|
||||||
|
gfx.Scale(scale, scale)
|
||||||
|
|
||||||
gfx.Restore()
|
gfx.Restore()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue