diff --git a/scripts/titlescreen.lua b/scripts/titlescreen.lua index 48d6a85..d73afde 100644 --- a/scripts/titlescreen.lua +++ b/scripts/titlescreen.lua @@ -4,6 +4,8 @@ local Bars = require('components/bars'); local cursorIndex = 3; local buttonHeight = 128 + 16; +local SELECTOR_BAR_OFFSET_FROM_CENTER = 128; + local buttons = nil local resx, resy = game.GetResolution(); @@ -106,30 +108,32 @@ draw_buttons = function() getCorrectedButtonIndex(cursorIndex, 2), } - centerButtonY = resy/2 - buttonHeight/2 - 28; -- to fit with the selector bg + local yBase = resy/2 + SELECTOR_BAR_OFFSET_FROM_CENTER; + + centerButtonY = yBase - buttonHeight/2 - 28; -- to fit with the selector bg marginFromResYCenter = 128; if scrollingUp then - draw_button(buttons[indexes[5]], resx - 512, resy/2 - marginFromResYCenter - buttonHeight*3, false, 0); -- Placeholder for fadeout transition + draw_button(buttons[indexes[5]], resx - 512, yBase - marginFromResYCenter - buttonHeight*3, false, 0); -- Placeholder for fadeout transition end - draw_button(buttons[indexes[1]], resx - 512, resy/2 - marginFromResYCenter - buttonHeight*2, false, 1); - draw_button(buttons[indexes[2]], resx - 512, resy/2 - marginFromResYCenter- buttonHeight, false, 2); + 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[3]], resx - 512, centerButtonY, true); -- The main selected center button if scrollingUp then - draw_button(buttons[indexes[3]], resx - 512, resy/2 + marginFromResYCenter - buttonHeight, false, 3); -- Placeholder for transition that goes to the bottom + draw_button(buttons[indexes[3]], resx - 512, yBase + marginFromResYCenter - 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 end - draw_button(buttons[indexes[4]], resx - 512, resy/2 + marginFromResYCenter, false, 4); - draw_button(buttons[indexes[5]], resx - 512, resy/2 + marginFromResYCenter + buttonHeight, false, 5); + draw_button(buttons[indexes[4]], resx - 512, yBase + marginFromResYCenter, false, 4); + draw_button(buttons[indexes[5]], resx - 512, yBase + marginFromResYCenter + buttonHeight, false, 5); if not scrollingUp then - draw_button(buttons[indexes[1]], resx - 512, resy/2 + marginFromResYCenter + buttonHeight*2, false, 6); + draw_button(buttons[indexes[1]], resx - 512, yBase + marginFromResYCenter + buttonHeight*2, false, 6); end end; @@ -162,13 +166,13 @@ function drawTexts() -- Description gfx.FillColor(255,255,255,math.floor(scrollTransitionScale*255)); - gfx.DrawLabel(selectorDescriptionLabel, 64, resy/2 - 52); + gfx.DrawLabel(selectorDescriptionLabel, 64, resy/2 + SELECTOR_BAR_OFFSET_FROM_CENTER - 52); -- Legend on the selector gfx.FillColor(217,177,126); - gfx.DrawLabel(selectorLegendScrollLabel, 118, resy/2 + 56); - gfx.DrawLabel(selectorLegendSelectLabel, 360, resy/2 + 56); + 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.FillColor(255,255,255); end; @@ -256,7 +260,7 @@ render = function(deltaTime) end -- Draw selector background - gfx.ImageRect(0, (resy/2) - 280/2, 1079, 280, selectorBgImage, 1, 0); + gfx.ImageRect(0, (resy/2 + SELECTOR_BAR_OFFSET_FROM_CENTER) - 280/2, 1079, 280, selectorBgImage, 1, 0); setButtons() resx,resy = game.GetResolution(); @@ -267,7 +271,7 @@ render = function(deltaTime) drawTexts(); -- Draw the arrows around the selected button - gfx.ImageRect(resx-512, resy/2 - buttonHeight, 501, 277, selectorArrowsImage, 1, 0); + gfx.ImageRect(resx-512, resy/2 + SELECTOR_BAR_OFFSET_FROM_CENTER - buttonHeight, 501, 277, selectorArrowsImage, 1, 0); -- Draw top and bottom bars --Bars.draw();