diff --git a/scripts/songselect/songwheel.lua b/scripts/songselect/songwheel.lua index 7c53950..d1c6221 100644 --- a/scripts/songselect/songwheel.lua +++ b/scripts/songselect/songwheel.lua @@ -5,6 +5,8 @@ local common = require('common.common') 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 dataGlowOverlayImage = gfx.CreateSkinImage("song_select/data_panel/data_glow_overlay.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 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() resx, resy = game.GetResolution() - desw = 1080 - desh = 1920 scale = resx / desw end @@ -744,19 +764,10 @@ function tickTransitions(deltaTime) end end - -render = function (deltaTime) - resetLayoutInformation(); - tickTransitions(deltaTime); - gfx.Scale(scale, scale); - - game.SetSkinSetting('_currentScreen', 'songwheel') - - common.stopMusic(); - - if not difficultyNumbers then - difficultyNumbers = load_number_image('diff_num') - end +draw_songwheel = function(x,y,w,h, deltaTime) + gfx.Scissor(x,y,w,h); + gfx.Translate(x,y); + gfx.Scale(w/1080, h/1920); drawBackground(deltaTime); @@ -777,6 +788,36 @@ render = function (deltaTime) local debugScrollingUp= "FALSE" 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.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 songs_changed = function (withAll) diff --git a/scripts/titlescreen.lua b/scripts/titlescreen.lua index 519131d..0131a1b 100644 --- a/scripts/titlescreen.lua +++ b/scripts/titlescreen.lua @@ -19,7 +19,7 @@ local desw = 1080 local desh = 1920 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 selectorBgImage = gfx.CreateSkinImage('titlescreen/selector_bg.png', 0); local selectorArrowsImage = gfx.CreateSkinImage( @@ -66,6 +66,24 @@ local oldCursorIndex = 3; local scrollingUp = 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() resx, resy = game.GetResolution() desw = 1080 @@ -327,16 +345,11 @@ function handle_controller() end end -render = function(deltaTime) - if not playedBgm then - game.PlaySample('titlescreen/bgm.wav', true); - playedBgm = true; - end +draw_titlescreen = function (x, y, w, h, deltaTime) + gfx.Scissor(x,y,w,h); + gfx.Translate(x,y); + gfx.Scale(w/1080, h/1920); - game.SetSkinSetting('_currentScreen', 'title') - - resetLayoutInformation(); - gfx.Scale(scale, scale); gfx.LoadSkinFont("segoeui.ttf") -- Draw background @@ -378,6 +391,31 @@ render = function(deltaTime) drawHeader(); 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() scrollTransitionScale = scrollTransitionScale + 1 / 60 * 5;