* 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 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 selectorBgImage = gfx.CreateSkinImage('titlescreen/selector_bg.png', 0);
@ -47,6 +50,13 @@ local oldCursorIndex = 3;
local scrollingUp = 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)
local labelImage = button[1];
local labelWidth = button[2];
@ -108,32 +118,32 @@ draw_buttons = function()
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
marginFromResYCenter = 128;
marginFromDesHCenter = 128;
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
draw_button(buttons[indexes[1]], resx - 512, yBase - marginFromResYCenter - buttonHeight*2, false, 1);
draw_button(buttons[indexes[2]], resx - 512, yBase - marginFromResYCenter- buttonHeight, false, 2);
draw_button(buttons[indexes[1]], desw - 512, yBase - marginFromDesHCenter - buttonHeight*2, false, 1);
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
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
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
draw_button(buttons[indexes[4]], resx - 512, yBase + marginFromResYCenter, false, 4);
draw_button(buttons[indexes[5]], resx - 512, yBase + marginFromResYCenter + buttonHeight, false, 5);
draw_button(buttons[indexes[4]], desw - 512, yBase + marginFromDesHCenter, false, 4);
draw_button(buttons[indexes[5]], desw - 512, yBase + marginFromDesHCenter + buttonHeight, false, 5);
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;
@ -166,13 +176,13 @@ function drawTexts()
-- Description
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
gfx.FillColor(217,177,126);
gfx.DrawLabel(selectorLegendScrollLabel, 118, resy/2 + SELECTOR_BAR_OFFSET_FROM_CENTER + 56);
gfx.DrawLabel(selectorLegendSelectLabel, 360, resy/2 + SELECTOR_BAR_OFFSET_FROM_CENTER + 56);
gfx.DrawLabel(selectorLegendScrollLabel, 118, desh/2 + SELECTOR_BAR_OFFSET_FROM_CENTER + 56);
gfx.DrawLabel(selectorLegendSelectLabel, 360, desh/2 + SELECTOR_BAR_OFFSET_FROM_CENTER + 56);
gfx.FillColor(255,255,255);
end;
@ -243,8 +253,11 @@ render = function(deltaTime)
playedBgm = true;
end
resetLayoutInformation();
gfx.Scale(scale, scale);
-- 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);
if idolAnimTickRes == 1 then
@ -255,23 +268,22 @@ render = function(deltaTime)
idolAnimTransitionScale = 1;
end
gfx.ImageRect(0, 0, resx, resy, idolAnimation, 1, 0);
gfx.ImageRect(0, 0, desw, desh, idolAnimation, 1, 0);
gfx.GlobalAlpha(1);
end
-- 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()
resx,resy = game.GetResolution();
buttonY = (resy / 2) - 2 * (257 + 5);
buttonY = (desh / 2) - 2 * (257 + 5);
draw_buttons();
drawTexts();
-- 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
--Bars.draw();