From 09dc795ee65407be17e5d27bbf2184b325653658 Mon Sep 17 00:00:00 2001 From: FajsiEx Date: Thu, 25 Nov 2021 18:49:50 +0100 Subject: [PATCH] + landscape support to song panel --- scripts/gameplay/banner.lua | 5 +++++ scripts/gameplay/console.lua | 5 +++++ scripts/gameplay/song_panel.lua | 25 +++++++++++++++++++------ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/scripts/gameplay/banner.lua b/scripts/gameplay/banner.lua index 4d42dcc..cd95a1c 100644 --- a/scripts/gameplay/banner.lua +++ b/scripts/gameplay/banner.lua @@ -6,6 +6,11 @@ local BANNER_H = 368; local render = function (deltaTime) + local resx, resy = game.GetResolution(); + if (resx > resy) then + return + end + -- Get the banner downscaled in whatever resolution it is, while maintaining the aspect ratio local tw,th = gfx.ImageSize(bannerBaseImage); BANNER_H = th * (1080/tw); diff --git a/scripts/gameplay/console.lua b/scripts/gameplay/console.lua index 54a18f0..0cfe8f1 100644 --- a/scripts/gameplay/console.lua +++ b/scripts/gameplay/console.lua @@ -19,6 +19,11 @@ end local render = function (deltaTime, critLineCenterX, critLineCenterY, critLineRotation) + local resx, resy = game.GetResolution(); + if (resx > resy) then + return + end + setUpTransforms( critLineCenterX, critLineCenterY, diff --git a/scripts/gameplay/song_panel.lua b/scripts/gameplay/song_panel.lua index fc2f83d..2751b76 100644 --- a/scripts/gameplay/song_panel.lua +++ b/scripts/gameplay/song_panel.lua @@ -4,6 +4,8 @@ local DiffRectangle = require('components.diff_rectangle'); local desw = 1080; local desh = 1920; +local isLandscape = false; + local bgLeftImage = gfx.CreateSkinImage("gameplay/song_panel/bg_left.png", 0); local bgRightImage = gfx.CreateSkinImage("gameplay/song_panel/bg_right.png", 0); @@ -37,6 +39,15 @@ local tickTransitions = function (deltaTime) end local render = function (deltaTime, bpm, laneSpeed, jacketPath, diff, level, progress, songTitle, songArtist) + gfx.Save(); + + local resx, resy = game.GetResolution(); + isLandscape = resx > resy; + + if (isLandscape) then + gfx.Scale(0.7, 0.7); + end + if (not loadedJacketImage and jacketPath) then loadJacketImage(jacketPath) end @@ -44,7 +55,7 @@ local render = function (deltaTime, bpm, laneSpeed, jacketPath, diff, level, pro tickTransitions(deltaTime) - local y = 210; + local y = isLandscape and 0 or 210; gfx.BeginPath(); gfx.ImageRect( @@ -72,7 +83,7 @@ local render = function (deltaTime, bpm, laneSpeed, jacketPath, diff, level, pro gfx.BeginPath(); gfx.ImageRect( 32, - 241.25, -- why does this need to be here? + y+31.25, -- why does this need to be here? 105, 105, jacketImage, @@ -81,7 +92,7 @@ local render = function (deltaTime, bpm, laneSpeed, jacketPath, diff, level, pro ); -- Draw diff rectangle - DiffRectangle.render(deltaTime, 31, 350, 0.84, diff, level); + DiffRectangle.render(deltaTime, 31, y+140, 0.84, diff, level); gfx.FontSize(30); gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE) @@ -97,13 +108,13 @@ local render = function (deltaTime, bpm, laneSpeed, jacketPath, diff, level, pro -- Draw progress gfx.BeginPath() gfx.FillColor(244, 204, 101) - gfx.Rect(222, 291, 622 * progress, 3) + gfx.Rect(222, y+81, 622 * progress, 3) gfx.Fill() gfx.BeginPath(); gfx.ImageRect( 208 + 622 * progress + ((1-progress) * 8), - 288.5, + y+78.5, 24*0.85, 10*0.85, progressDotImage, @@ -115,7 +126,9 @@ local render = function (deltaTime, bpm, laneSpeed, jacketPath, diff, level, pro gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE) gfx.FontSize(22) - gfx.Text(songTitle .. ' / ' .. songArtist, 385, 270); + gfx.Text(songTitle .. ' / ' .. songArtist, 385, y+60); + + gfx.Restore(); end return {