* scale titlescreen

This commit is contained in:
FajsiEx 2021-07-28 19:34:34 +02:00
parent c85e47b92b
commit e830467ff6
1 changed files with 33 additions and 21 deletions

View File

@ -7,7 +7,10 @@ local buttonHeight = 128 + 16;
local SELECTOR_BAR_OFFSET_FROM_CENTER = 128; local SELECTOR_BAR_OFFSET_FROM_CENTER = 128;
local buttons = nil local buttons = nil
local resx, resy = game.GetResolution(); local resx, resy = game.GetResolution()
local desw = 1080
local desh = 1920
local scale;
local bgImage = gfx.CreateSkinImage('titlescreen/bg.png', 0); local bgImage = gfx.CreateSkinImage('titlescreen/bg.png', 0);
local selectorBgImage = gfx.CreateSkinImage('titlescreen/selector_bg.png', 0); local selectorBgImage = gfx.CreateSkinImage('titlescreen/selector_bg.png', 0);
@ -47,6 +50,13 @@ local oldCursorIndex = 3;
local scrollingUp = false; local scrollingUp = false;
local playedBgm = false; local playedBgm = false;
function resetLayoutInformation()
resx, resy = game.GetResolution()
desw = 1080
desh = 1920
scale = resx / desw
end
draw_button = function(button, x, y, selected, index) draw_button = function(button, x, y, selected, index)
local labelImage = button[1]; local labelImage = button[1];
local labelWidth = button[2]; local labelWidth = button[2];
@ -108,32 +118,32 @@ draw_buttons = function()
getCorrectedButtonIndex(cursorIndex, 2), getCorrectedButtonIndex(cursorIndex, 2),
} }
local yBase = resy/2 + SELECTOR_BAR_OFFSET_FROM_CENTER; local yBase = desh/2 + SELECTOR_BAR_OFFSET_FROM_CENTER;
centerButtonY = yBase - buttonHeight/2 - 28; -- to fit with the selector bg centerButtonY = yBase - buttonHeight/2 - 28; -- to fit with the selector bg
marginFromResYCenter = 128; marginFromDesHCenter = 128;
if scrollingUp then if scrollingUp then
draw_button(buttons[indexes[5]], resx - 512, yBase - marginFromResYCenter - buttonHeight*3, false, 0); -- Placeholder for fadeout transition draw_button(buttons[indexes[5]], desw - 512, yBase - marginFromDesHCenter - buttonHeight*3, false, 0); -- Placeholder for fadeout transition
end end
draw_button(buttons[indexes[1]], resx - 512, yBase - marginFromResYCenter - buttonHeight*2, false, 1); draw_button(buttons[indexes[1]], desw - 512, yBase - marginFromDesHCenter - buttonHeight*2, false, 1);
draw_button(buttons[indexes[2]], resx - 512, yBase - marginFromResYCenter- buttonHeight, false, 2); draw_button(buttons[indexes[2]], desw - 512, yBase - marginFromDesHCenter- buttonHeight, false, 2);
draw_button(buttons[indexes[3]], resx - 512, centerButtonY, true); -- The main selected center button draw_button(buttons[indexes[3]], desw - 512, centerButtonY, true); -- The main selected center button
if scrollingUp then if scrollingUp then
draw_button(buttons[indexes[3]], resx - 512, yBase + marginFromResYCenter - buttonHeight, false, 3); -- Placeholder for transition that goes to the bottom draw_button(buttons[indexes[3]], desw - 512, yBase + marginFromDesHCenter - buttonHeight, false, 3); -- Placeholder for transition that goes to the bottom
else else
draw_button(buttons[indexes[3]], resx - 512, centerButtonY, false, 3); -- Placeholder for transition that goes to the top draw_button(buttons[indexes[3]], desw - 512, centerButtonY, false, 3); -- Placeholder for transition that goes to the top
end end
draw_button(buttons[indexes[4]], resx - 512, yBase + marginFromResYCenter, false, 4); draw_button(buttons[indexes[4]], desw - 512, yBase + marginFromDesHCenter, false, 4);
draw_button(buttons[indexes[5]], resx - 512, yBase + marginFromResYCenter + buttonHeight, false, 5); draw_button(buttons[indexes[5]], desw - 512, yBase + marginFromDesHCenter + buttonHeight, false, 5);
if not scrollingUp then if not scrollingUp then
draw_button(buttons[indexes[1]], resx - 512, yBase + marginFromResYCenter + buttonHeight*2, false, 6); draw_button(buttons[indexes[1]], desw - 512, yBase + marginFromDesHCenter + buttonHeight*2, false, 6);
end end
end; end;
@ -166,13 +176,13 @@ function drawTexts()
-- Description -- Description
gfx.FillColor(255,255,255,math.floor(scrollTransitionScale*255)); gfx.FillColor(255,255,255,math.floor(scrollTransitionScale*255));
gfx.DrawLabel(selectorDescriptionLabel, 64, resy/2 + SELECTOR_BAR_OFFSET_FROM_CENTER - 52); gfx.DrawLabel(selectorDescriptionLabel, 64, desh/2 + SELECTOR_BAR_OFFSET_FROM_CENTER - 52);
-- Legend on the selector -- Legend on the selector
gfx.FillColor(217,177,126); gfx.FillColor(217,177,126);
gfx.DrawLabel(selectorLegendScrollLabel, 118, resy/2 + SELECTOR_BAR_OFFSET_FROM_CENTER + 56); gfx.DrawLabel(selectorLegendScrollLabel, 118, desh/2 + SELECTOR_BAR_OFFSET_FROM_CENTER + 56);
gfx.DrawLabel(selectorLegendSelectLabel, 360, resy/2 + SELECTOR_BAR_OFFSET_FROM_CENTER + 56); gfx.DrawLabel(selectorLegendSelectLabel, 360, desh/2 + SELECTOR_BAR_OFFSET_FROM_CENTER + 56);
gfx.FillColor(255,255,255); gfx.FillColor(255,255,255);
end; end;
@ -243,8 +253,11 @@ render = function(deltaTime)
playedBgm = true; playedBgm = true;
end end
resetLayoutInformation();
gfx.Scale(scale, scale);
-- Draw background -- Draw background
gfx.ImageRect(0, 0, resx, resy, bgImage, 1, 0); gfx.ImageRect(0, 0, desw, desh, bgImage, 1, 0);
local idolAnimTickRes = gfx.TickAnimation(idolAnimation, deltaTime); local idolAnimTickRes = gfx.TickAnimation(idolAnimation, deltaTime);
if idolAnimTickRes == 1 then if idolAnimTickRes == 1 then
@ -255,23 +268,22 @@ render = function(deltaTime)
idolAnimTransitionScale = 1; idolAnimTransitionScale = 1;
end end
gfx.ImageRect(0, 0, resx, resy, idolAnimation, 1, 0); gfx.ImageRect(0, 0, desw, desh, idolAnimation, 1, 0);
gfx.GlobalAlpha(1); gfx.GlobalAlpha(1);
end end
-- Draw selector background -- Draw selector background
gfx.ImageRect(0, (resy/2 + SELECTOR_BAR_OFFSET_FROM_CENTER) - 280/2, 1079, 280, selectorBgImage, 1, 0); gfx.ImageRect(0, (desh/2 + SELECTOR_BAR_OFFSET_FROM_CENTER) - 280/2, 1079, 280, selectorBgImage, 1, 0);
setButtons() setButtons()
resx,resy = game.GetResolution();
buttonY = (resy / 2) - 2 * (257 + 5); buttonY = (desh / 2) - 2 * (257 + 5);
draw_buttons(); draw_buttons();
drawTexts(); drawTexts();
-- Draw the arrows around the selected button -- Draw the arrows around the selected button
gfx.ImageRect(resx-512, resy/2 + SELECTOR_BAR_OFFSET_FROM_CENTER - buttonHeight, 501, 277, selectorArrowsImage, 1, 0); gfx.ImageRect(desw-512, desh/2 + SELECTOR_BAR_OFFSET_FROM_CENTER - buttonHeight, 501, 277, selectorArrowsImage, 1, 0);
-- Draw top and bottom bars -- Draw top and bottom bars
--Bars.draw(); --Bars.draw();