+ proper sortwheel & / footer scaling breaking on force portrait

This commit is contained in:
FajsiEx 2021-08-13 20:39:37 +02:00
parent 9677cc2398
commit 52b2c02ed2
6 changed files with 169 additions and 45 deletions

View File

@ -1,14 +1,13 @@
local resx, resy = game.GetResolution(); local resx, resy = game.GetResolution()
local desw = 1080; local desw, desh = 1080,1920;
local desh = 1920;
local scale = 1; local scale = 1;
local BAR_ALPHA = 191; local BAR_ALPHA = 191;
local FOOTER_HEIGHT = 128 local FOOTER_HEIGHT = 128
local footerY = desh; local footerY = desh - FOOTER_HEIGHT;
-- Images -- Images
local footerRightImage = gfx.CreateSkinImage("components/bars/footer_right.png", 0); local footerRightImage = gfx.CreateSkinImage("components/bars/footer_right.png", 0);
@ -42,7 +41,7 @@ end
local drawFooter = function () local drawFooter = function ()
gfx.BeginPath(); gfx.BeginPath();
gfx.FillColor(0,0,0,BAR_ALPHA); gfx.FillColor(0,0,0,BAR_ALPHA);
gfx.Rect(0,footerY,resx, FOOTER_HEIGHT); gfx.Rect(0,footerY,desw, FOOTER_HEIGHT);
gfx.Fill(); gfx.Fill();
@ -57,7 +56,7 @@ local progressTransitions = function ()
end end
entryTransitionFooterYOffset = FOOTER_HEIGHT*(1-entryTransitionScale) entryTransitionFooterYOffset = FOOTER_HEIGHT*(1-entryTransitionScale)
footerY = resy-FOOTER_HEIGHT+entryTransitionFooterYOffset; footerY = desh-FOOTER_HEIGHT+entryTransitionFooterYOffset;
end end
local draw = function (params) local draw = function (params)

View File

@ -300,7 +300,7 @@ render = function(deltatime, shown)
game.SetSkinSetting('_songWheelActiveSubFolderLabel', getFolderData(filters.level[selectedLevel]).label); game.SetSkinSetting('_songWheelActiveSubFolderLabel', getFolderData(filters.level[selectedLevel]).label);
SongSelectHeader.draw(deltatime); SongSelectHeader.draw(deltatime);
Footer.draw({noEnterTransition = true}); Footer.draw();
-- Debug text -- Debug text
gfx.BeginPath(); gfx.BeginPath();

View File

@ -1,42 +1,167 @@
resx,resy = game.GetResolution() -- IMAGES
local wheelY = -resy local panelBgImage = gfx.CreateSkinImage('song_select/sort_wheel/bg.png', 0)
local bgFade = 0 local activeItemBgImage = gfx.CreateSkinImage(
local yoff = 0 'song_select/sort_wheel/active_bg.png', 0)
local lastSelected = 0 local titleTextImage = gfx.CreateSkinImage('song_select/sort_wheel/title.png', 0)
local selection = 1
local sortLabels = {} resx, resy = game.GetResolution()
local desw, desh = 1080, 1920;
local scale = 1;
local selection = 1;
local renderedButtonLabels = {}
local FONT_SIZE = 32;
local MARGIN = 16;
local SUB_FONT_SIZE = 26;
local SUB_MARGIN = 8;
local SORT_ORDER_LABEL_TEXTS = {
{
label = 'Title',
asc = '# to A to Z to かな 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 = 'Badge',
asc = 'None to D to S',
dsc = 'S to D to None'
},
{
label = 'Artist',
asc = '# to A to Z to かな to 漢字',
dsc = '漢字 to かな to Z to A to #'
},
{
label = 'Effector',
asc = '# to A to Z to かな to 漢字',
dsc = '漢字 to かな to Z to A to #'
},
}
function resetLayoutInformation()
resx, resy = game.GetResolution()
scale = resx / desw
end
function tableContains(table, value)
for i,v in ipairs(table) do
if v==value then return true end
end
return false;
end
function drawButton(i,f,x,y)
local spaceAfter = (FONT_SIZE + MARGIN)
local sortOrder = 'asc';
if (string.find(f, 'v')) then
sortOrder = 'dsc'
end
local label = f:gsub(' ^', '')
label = label:gsub(' v', '')
if (string.find(sorts[selection], label) and sorts[selection] ~= f) then
-- If there is a button active with the same label, but different sort order, don't render this one
return 0;
else
-- 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
return 0;
end
table.insert(renderedButtonLabels, label);
end
if (i == selection) then
local ascLabelText = 'Ascending'
local dscLabelText = 'Descending'
for i,obj in ipairs(SORT_ORDER_LABEL_TEXTS) do
if (obj.label == label) then
ascLabelText = obj.asc;
dscLabelText = obj.dsc;
end
end
gfx.BeginPath()
gfx.ImageRect(x-182, y-38, 365, 82, activeItemBgImage, 1, 0)
gfx.BeginPath()
if sortOrder == 'asc' then
gfx.ImageRect(x-150, y+FONT_SIZE+SUB_MARGIN*2-31, 300, 67, activeItemBgImage, 1, 0)
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)
end
gfx.Save()
gfx.FontSize(SUB_FONT_SIZE)
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.Restore()
spaceAfter = spaceAfter + SUB_FONT_SIZE*2 + SUB_MARGIN*4;
end
gfx.BeginPath();
gfx.Text(label, x, y);
return spaceAfter;
end
function render(deltaTime, shown) function render(deltaTime, shown)
if not shown then if not shown then return end
return
end
gfx.Save() gfx.Save()
gfx.ResetTransform() gfx.ResetTransform()
resx,resy = game.GetResolution();
gfx.FillColor(0,0,0,200) renderedButtonLabels = {};
gfx.FastRect(0,0,resx,resy) resetLayoutInformation()
gfx.Scale(scale, scale)
-- Draw the dark overlay above song wheel
gfx.BeginPath(); gfx.BeginPath();
gfx.LoadSkinFont("segoeui.ttf"); gfx.FillColor(0, 0, 0, 192);
gfx.TextAlign(gfx.TEXT_ALIGN_RIGHT + gfx.TEXT_ALIGN_MIDDLE); gfx.Rect(0, 0, desw, desh);
gfx.FontSize(40); gfx.Fill();
for i,f in ipairs(sorts) do
if not sortLabels[i] then -- Draw the panel background
sortLabels[i] = gfx.CreateLabel(f, 40, 0) gfx.BeginPath()
end gfx.ImageRect(desw - 416, 0, 416, desh, panelBgImage, 1, 0)
if i == selection then
gfx.FillColor(255,255,255,255) gfx.LoadSkinFont("Digital-Serial-Bold.ttf");
else gfx.FontSize(FONT_SIZE);
gfx.FillColor(255,255,255,128) gfx.FillColor(255, 255, 255, 255);
end gfx.TextAlign(gfx.TEXT_ALIGN_CENTER + gfx.TEXT_ALIGN_MIDDLE);
local xpos = resx - 100 + ((i - selection - yoff) ^ 2) * 1
local ypos = resy/2 + 50 * (i - selection - yoff) -- Starting position of the first sort option
gfx.DrawLabel(sortLabels[i], xpos, ypos); local x = 889;
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)
((SUB_FONT_SIZE*2 + SUB_MARGIN*4) / 2); -- Space for taken by order options
-- Draw the title image
gfx.BeginPath()
gfx.ImageRect(x-72, y-27, 144, 54, titleTextImage, 1, 0)
y = y + (54 + MARGIN)
-- Draw all the sorting options
for i, f in ipairs(sorts) do
local spaceAfter = drawButton(i,f,x,y);
y = y + spaceAfter;
end end
gfx.Restore() gfx.Restore()
yoff = yoff * 0.7
end end
function set_selection(index) selection = index end
function set_selection(index)
selection = index
end

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB