+ letterboxing to titlescreen and songwheel

This commit is contained in:
FajsiEx 2021-11-22 20:23:34 +01:00
parent d96cd0a013
commit 2260528bf5
2 changed files with 104 additions and 25 deletions

View File

@ -5,6 +5,8 @@ local common = require('common.common')
local VolforceCalc = require('components.volforceCalc'); local VolforceCalc = require('components.volforceCalc');
local backgroundImage = gfx.CreateSkinImage("bg_pattern.png", gfx.IMAGE_REPEATX | gfx.IMAGE_REPEATY)
local dataPanelImage = gfx.CreateSkinImage("song_select/data_bg_overlay.png", 1) local dataPanelImage = gfx.CreateSkinImage("song_select/data_bg_overlay.png", 1)
local dataGlowOverlayImage = gfx.CreateSkinImage("song_select/data_panel/data_glow_overlay.png", 1) local dataGlowOverlayImage = gfx.CreateSkinImage("song_select/data_panel/data_glow_overlay.png", 1)
local gradeBgImage = gfx.CreateSkinImage("song_select/data_panel/grade_bg.png", 1) local gradeBgImage = gfx.CreateSkinImage("song_select/data_panel/grade_bg.png", 1)
@ -143,10 +145,28 @@ local transitionLeaveScale = 0;
local transitionLeaveReappearTimer = 0; local transitionLeaveReappearTimer = 0;
local TRANSITION_LEAVE_DURATION = 0.1; local TRANSITION_LEAVE_DURATION = 0.1;
-- Window variables
local resX, resY
-- Aspect Ratios
local landscapeWidescreenRatio = 16 / 9
local landscapeStandardRatio = 4 / 3
local portraitWidescreenRatio = 9 / 16
-- Portrait sizes
local fullX, fullY
local desw = 1080
local desh = 1920
local resolutionChange = function(x, y)
resX = x
resY = y
fullX = portraitWidescreenRatio * y
fullY = y
end
function resetLayoutInformation() function resetLayoutInformation()
resx, resy = game.GetResolution() resx, resy = game.GetResolution()
desw = 1080
desh = 1920
scale = resx / desw scale = resx / desw
end end
@ -744,19 +764,10 @@ function tickTransitions(deltaTime)
end end
end end
draw_songwheel = function(x,y,w,h, deltaTime)
render = function (deltaTime) gfx.Scissor(x,y,w,h);
resetLayoutInformation(); gfx.Translate(x,y);
tickTransitions(deltaTime); gfx.Scale(w/1080, h/1920);
gfx.Scale(scale, scale);
game.SetSkinSetting('_currentScreen', 'songwheel')
common.stopMusic();
if not difficultyNumbers then
difficultyNumbers = load_number_image('diff_num')
end
drawBackground(deltaTime); drawBackground(deltaTime);
@ -777,6 +788,36 @@ render = function (deltaTime)
local debugScrollingUp= "FALSE" local debugScrollingUp= "FALSE"
if scrollingUp then debugScrollingUp = "TRUE" end; if scrollingUp then debugScrollingUp = "TRUE" end;
-- gfx.Text('S_I: ' .. selectedIndex .. ' // S_D: ' .. selectedDifficulty .. ' // S_UP: ' .. debugScrollingUp .. ' // AC_TS: ' .. transitionAfterscrollScale .. ' // L_TS: ' .. transitionLeaveScale, 8, 8); -- gfx.Text('S_I: ' .. selectedIndex .. ' // S_D: ' .. selectedDifficulty .. ' // S_UP: ' .. debugScrollingUp .. ' // AC_TS: ' .. transitionAfterscrollScale .. ' // L_TS: ' .. transitionLeaveScale, 8, 8);
gfx.ResetTransform();
end
render = function (deltaTime)
tickTransitions(deltaTime);
game.SetSkinSetting('_currentScreen', 'songwheel')
common.stopMusic();
if not difficultyNumbers then
difficultyNumbers = load_number_image('diff_num')
end
game.SetSkinSetting('_currentScreen', 'title')
-- detect resolution change
local resx, resy = game.GetResolution();
if resx ~= resX or resy ~= resY then
resolutionChange(resx, resy)
end
gfx.BeginPath()
bgImageWidth, bgImageHeight = gfx.ImageSize(backgroundImage)
gfx.Rect(0, 0, resX, resY)
gfx.FillPaint(gfx.ImagePattern(0, 0, bgImageWidth, bgImageHeight, 0, backgroundImage, 0.2))
gfx.Fill()
draw_songwheel((resX - fullX) / 2, 0, fullX, fullY, deltaTime);
end end
songs_changed = function (withAll) songs_changed = function (withAll)

View File

@ -19,7 +19,7 @@ local desw = 1080
local desh = 1920 local desh = 1920
local scale; local scale;
local bgImage = gfx.CreateSkinImage('titlescreen/bg.png', 0); local backgroundImage = gfx.CreateSkinImage("bg_pattern.png", gfx.IMAGE_REPEATX | gfx.IMAGE_REPEATY)
local headerTitleImage = gfx.CreateSkinImage('titlescreen/title.png', 0); local headerTitleImage = gfx.CreateSkinImage('titlescreen/title.png', 0);
local selectorBgImage = gfx.CreateSkinImage('titlescreen/selector_bg.png', 0); local selectorBgImage = gfx.CreateSkinImage('titlescreen/selector_bg.png', 0);
local selectorArrowsImage = gfx.CreateSkinImage( local selectorArrowsImage = gfx.CreateSkinImage(
@ -66,6 +66,24 @@ local oldCursorIndex = 3;
local scrollingUp = false; local scrollingUp = false;
local playedBgm = false; local playedBgm = false;
-- Window variables
local resX, resY
-- Aspect Ratios
local landscapeWidescreenRatio = 16 / 9
local landscapeStandardRatio = 4 / 3
local portraitWidescreenRatio = 9 / 16
-- Portrait sizes
local fullX, fullY
local resolutionChange = function(x, y)
resX = x
resY = y
fullX = portraitWidescreenRatio * y
fullY = y
end
function resetLayoutInformation() function resetLayoutInformation()
resx, resy = game.GetResolution() resx, resy = game.GetResolution()
desw = 1080 desw = 1080
@ -327,16 +345,11 @@ function handle_controller()
end end
end end
render = function(deltaTime) draw_titlescreen = function (x, y, w, h, deltaTime)
if not playedBgm then gfx.Scissor(x,y,w,h);
game.PlaySample('titlescreen/bgm.wav', true); gfx.Translate(x,y);
playedBgm = true; gfx.Scale(w/1080, h/1920);
end
game.SetSkinSetting('_currentScreen', 'title')
resetLayoutInformation();
gfx.Scale(scale, scale);
gfx.LoadSkinFont("segoeui.ttf") gfx.LoadSkinFont("segoeui.ttf")
-- Draw background -- Draw background
@ -378,6 +391,31 @@ render = function(deltaTime)
drawHeader(); drawHeader();
Footer.draw(deltaTime); Footer.draw(deltaTime);
gfx.ResetTransform();
end
render = function(deltaTime)
if not playedBgm then
game.PlaySample('titlescreen/bgm.wav', true);
playedBgm = true;
end
game.SetSkinSetting('_currentScreen', 'title')
-- detect resolution change
local resx, resy = game.GetResolution();
if resx ~= resX or resy ~= resY then
resolutionChange(resx, resy)
end
gfx.BeginPath()
bgImageWidth, bgImageHeight = gfx.ImageSize(backgroundImage)
gfx.Rect(0, 0, resX, resY)
gfx.FillPaint(gfx.ImagePattern(0, 0, bgImageWidth, bgImageHeight, 0, backgroundImage, 0.2))
gfx.Fill()
draw_titlescreen((resX - fullX) / 2, 0, fullX, fullY, deltaTime);
handle_controller() handle_controller()
scrollTransitionScale = scrollTransitionScale + 1 / 60 * 5; scrollTransitionScale = scrollTransitionScale + 1 / 60 * 5;