From 2ceeb6ddb53323132312430b37b983a2fd6a893c Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Wed, 28 Jun 2023 22:29:05 +0530 Subject: [PATCH] make everything properly resizable --- src/MarbleGame.hx | 1 - src/Renderer.hx | 16 +++++++++++++++- src/gui/AboutMenuOptionsGui.hx | 20 ++++++++++++++++++-- src/gui/Canvas.hx | 5 +++++ src/gui/DifficultySelectGui.hx | 20 ++++++++++++++++++-- src/gui/EndGameGui.hx | 19 +++++++++++++++++-- src/gui/ExitGameDlg.hx | 20 ++++++++++++++++++-- src/gui/GuiControl.hx | 6 ++++++ src/gui/HelpCreditsGui.hx | 16 +++++++++++++++- src/gui/InputOptionsGui.hx | 16 +++++++++++++++- src/gui/LevelSelectGui.hx | 16 +++++++++++++++- src/gui/MainMenuGui.hx | 20 ++++++++++++++++++-- src/gui/MarblePickerGui.hx | 16 +++++++++++++++- src/gui/MiscOptionsGui.hx | 16 +++++++++++++++- src/gui/OptionsListGui.hx | 16 +++++++++++++++- src/gui/VideoOptionsGui.hx | 16 +++++++++++++++- 16 files changed, 220 insertions(+), 19 deletions(-) diff --git a/src/MarbleGame.hx b/src/MarbleGame.hx index 58b684ef..e1c5e59c 100644 --- a/src/MarbleGame.hx +++ b/src/MarbleGame.hx @@ -171,7 +171,6 @@ class MarbleGame { JSPlatform.initFullscreenEnforcer(); Window.getInstance().removeEventTarget(@:privateAccess Key.onEvent); - Window.getInstance().addResizeEvent(() -> {}); #end } diff --git a/src/Renderer.hx b/src/Renderer.hx index f02a5519..763cd642 100644 --- a/src/Renderer.hx +++ b/src/Renderer.hx @@ -1,5 +1,6 @@ package src; +import hxd.Window; import src.ResourceLoader; import shaders.GammaRamp; import h3d.mat.Texture; @@ -32,6 +33,7 @@ class Renderer extends h3d.scene.Renderer { blurShader = new ScreenFx(new Blur()); copyPass = new h3d.pass.Copy(); sfxBuffer = new Texture(512, 512, [Target]); + Window.getInstance().addResizeEvent(() -> onResize()); } public inline static function getSfxBuffer() { @@ -46,6 +48,17 @@ class Renderer extends h3d.scene.Renderer { p.draw(passes, sort); } + function onResize() { + if (backBuffer != null) { + backBuffer.dispose(); + backBuffer = null; + } + if (glowBuffer != null) { + glowBuffer.dispose(); + glowBuffer = null; + } + } + override function getPassByName(name:String):h3d.pass.Base { if (name == "alpha" || name == "additive" @@ -73,8 +86,9 @@ class Renderer extends h3d.scene.Renderer { if (has("normal")) renderPass(normal, get("normal")); - if (growBufferTemps == null) { + if (glowBuffer == null) glowBuffer = ctx.textures.allocTarget("glowBuffer", ctx.engine.width, ctx.engine.height); + if (growBufferTemps == null) { growBufferTemps = [ ctx.textures.allocTarget("gb1", 320, 320, false), ctx.textures.allocTarget("gb2", 320, 320, false), diff --git a/src/gui/AboutMenuOptionsGui.hx b/src/gui/AboutMenuOptionsGui.hx index 5c7a3223..c25d1f5b 100644 --- a/src/gui/AboutMenuOptionsGui.hx +++ b/src/gui/AboutMenuOptionsGui.hx @@ -7,6 +7,9 @@ import src.ResourceLoader; import src.Settings; class AboutMenuOptionsGui extends GuiImage { + var innerCtrl:GuiControl; + var btnList:GuiXboxList; + public function new(pauseGui:Bool = false) { var res = ResourceLoader.getImage("data/ui/xbox/BG_fadeOutSoftEdge.png").resource.toTile(); super(res); @@ -28,7 +31,7 @@ class AboutMenuOptionsGui extends GuiImage { var subX = 640 - (scene2d.width - offsetX) * 640 / scene2d.width; var subY = 480 - (scene2d.height - offsetY) * 480 / scene2d.height; - var innerCtrl = new GuiControl(); + innerCtrl = new GuiControl(); innerCtrl.position = new Vector(offsetX, offsetY); innerCtrl.extent = new Vector(640 - subX, 480 - subY); innerCtrl.horizSizing = Width; @@ -48,7 +51,7 @@ class AboutMenuOptionsGui extends GuiImage { rootTitle.text.alpha = 0.5; innerCtrl.addChild(rootTitle); - var btnList = new GuiXboxList(); + btnList = new GuiXboxList(); btnList.position = new Vector(70 - offsetX, 165); btnList.horizSizing = Left; btnList.extent = new Vector(502, 500); @@ -114,4 +117,17 @@ class AboutMenuOptionsGui extends GuiImage { backButton.pressedAction = (e) -> MarbleGame.canvas.setContent(new OptionsListGui()); bottomBar.addChild(backButton); } + + override function onResize(width:Int, height:Int) { + var offsetX = (width - 1280) / 2; + var offsetY = (height - 720) / 2; + + var subX = 640 - (width - offsetX) * 640 / width; + var subY = 480 - (height - offsetY) * 480 / height; + innerCtrl.position = new Vector(offsetX, offsetY); + innerCtrl.extent = new Vector(640 - subX, 480 - subY); + btnList.position = new Vector(70 - offsetX, 165); + + super.onResize(width, height); + } } diff --git a/src/gui/Canvas.hx b/src/gui/Canvas.hx index 9414e126..8cb5401d 100644 --- a/src/gui/Canvas.hx +++ b/src/gui/Canvas.hx @@ -1,5 +1,6 @@ package gui; +import hxd.Window; import src.Console; import src.MarbleGame; import h3d.Vector; @@ -21,6 +22,10 @@ class Canvas extends GuiControl { this.extent = new Vector(640, 480); this.horizSizing = Width; this.vertSizing = Height; + Window.getInstance().addResizeEvent(() -> { + var wnd = Window.getInstance(); + onResize(wnd.width, wnd.height); + }); } public function setContent(content:GuiControl) { diff --git a/src/gui/DifficultySelectGui.hx b/src/gui/DifficultySelectGui.hx index e4f9a9d6..db75291b 100644 --- a/src/gui/DifficultySelectGui.hx +++ b/src/gui/DifficultySelectGui.hx @@ -9,6 +9,9 @@ import src.ResourceLoader; import src.Settings; class DifficultySelectGui extends GuiImage { + var innerCtrl:GuiControl; + var btnList:GuiXboxList; + public function new() { var res = ResourceLoader.getImage("data/ui/xbox/BG_fadeOutSoftEdge.png").resource.toTile(); super(res); @@ -30,7 +33,7 @@ class DifficultySelectGui extends GuiImage { var subX = 640 - (scene2d.width - offsetX) * 640 / scene2d.width; var subY = 480 - (scene2d.height - offsetY) * 480 / scene2d.height; - var innerCtrl = new GuiControl(); + innerCtrl = new GuiControl(); innerCtrl.position = new Vector(offsetX, offsetY); innerCtrl.extent = new Vector(640 - subX, 480 - subY); innerCtrl.horizSizing = Width; @@ -50,7 +53,7 @@ class DifficultySelectGui extends GuiImage { rootTitle.text.alpha = 0.5; innerCtrl.addChild(rootTitle); - var btnList = new GuiXboxList(); + btnList = new GuiXboxList(); btnList.position = new Vector(70 - offsetX, 165); btnList.horizSizing = Left; btnList.extent = new Vector(502, 500); @@ -84,4 +87,17 @@ class DifficultySelectGui extends GuiImage { backButton.pressedAction = (e) -> MarbleGame.canvas.setContent(new MainMenuGui()); bottomBar.addChild(backButton); } + + override function onResize(width:Int, height:Int) { + var offsetX = (width - 1280) / 2; + var offsetY = (height - 720) / 2; + + var subX = 640 - (width - offsetX) * 640 / width; + var subY = 480 - (height - offsetY) * 480 / height; + innerCtrl.position = new Vector(offsetX, offsetY); + innerCtrl.extent = new Vector(640 - subX, 480 - subY); + btnList.position = new Vector(70 - offsetX, 165); + + super.onResize(width, height); + } } diff --git a/src/gui/EndGameGui.hx b/src/gui/EndGameGui.hx index a8a5b86e..7a3566e7 100644 --- a/src/gui/EndGameGui.hx +++ b/src/gui/EndGameGui.hx @@ -16,6 +16,8 @@ import src.Util; class EndGameGui extends GuiImage { var mission:Mission; + var innerCtrl:GuiControl; + var endGameWnd:GuiImage; var scoreSubmitted:Bool = false; @@ -43,7 +45,7 @@ class EndGameGui extends GuiImage { var subX = 640 - (scene2d.width - offsetX) * 640 / scene2d.width; var subY = 480 - (scene2d.height - offsetY) * 480 / scene2d.height; - var innerCtrl = new GuiControl(); + innerCtrl = new GuiControl(); innerCtrl.position = new Vector(offsetX, offsetY); innerCtrl.extent = new Vector(640 - subX, 480 - subY); innerCtrl.horizSizing = Width; @@ -63,7 +65,7 @@ class EndGameGui extends GuiImage { rootTitle.text.alpha = 0.5; innerCtrl.addChild(rootTitle); - var endGameWnd = new GuiImage(ResourceLoader.getResource("data/ui/xbox/endGameWindow.png", ResourceLoader.getImage, this.imageResources).toTile()); + endGameWnd = new GuiImage(ResourceLoader.getResource("data/ui/xbox/endGameWindow.png", ResourceLoader.getImage, this.imageResources).toTile()); endGameWnd.horizSizing = Left; endGameWnd.vertSizing = Top; endGameWnd.position = new Vector(80 - offsetX, 170 - offsetY); @@ -157,4 +159,17 @@ class EndGameGui extends GuiImage { nextButton.pressedAction = (e) -> continueFunc(nextButton); bottomBar.addChild(nextButton); } + + override function onResize(width:Int, height:Int) { + var offsetX = (width - 1280) / 2; + var offsetY = (height - 720) / 2; + + var subX = 640 - (width - offsetX) * 640 / width; + var subY = 480 - (height - offsetY) * 480 / height; + innerCtrl.position = new Vector(offsetX, offsetY); + innerCtrl.extent = new Vector(640 - subX, 480 - subY); + endGameWnd.position = new Vector(80 - offsetX, 170 - offsetY); + + super.onResize(width, height); + } } diff --git a/src/gui/ExitGameDlg.hx b/src/gui/ExitGameDlg.hx index 7bf1a192..d6f6b795 100644 --- a/src/gui/ExitGameDlg.hx +++ b/src/gui/ExitGameDlg.hx @@ -8,6 +8,9 @@ import src.ResourceLoader; import src.Settings; class ExitGameDlg extends GuiImage { + var innerCtrl:GuiControl; + var btnList:GuiXboxList; + public function new(yesFunc:GuiControl->Void, noFunc:GuiControl->Void, restartFunc:GuiControl->Void) { var res = ResourceLoader.getImage("data/ui/xbox/BG_fadeOutSoftEdge.png").resource.toTile(); super(res); @@ -31,7 +34,7 @@ class ExitGameDlg extends GuiImage { var offsetX = (scene2d.width - 1280) / 2; var offsetY = (scene2d.height - 720) / 2; - var innerCtrl = new GuiControl(); + innerCtrl = new GuiControl(); innerCtrl.position = new Vector(offsetX, offsetY); // innerCtrl.extent = new Vector(640, 480); @@ -64,7 +67,7 @@ class ExitGameDlg extends GuiImage { levelTitle.text.text = 'Level ${MarbleGame.instance.world.mission.index + 1}'; innerCtrl.addChild(levelTitle); - var btnList = new GuiXboxList(); + btnList = new GuiXboxList(); btnList.position = new Vector(70 - offsetX / 2, 95); btnList.horizSizing = Left; btnList.extent = new Vector(502, 500); @@ -84,4 +87,17 @@ class ExitGameDlg extends GuiImage { MarbleGame.canvas.setContent(new MainMenuGui()); }); } + + override function onResize(width:Int, height:Int) { + var offsetX = (width - 1280) / 2; + var offsetY = (height - 720) / 2; + + var subX = 640 - (width - offsetX) * 640 / width; + var subY = 480 - (height - offsetY) * 480 / height; + innerCtrl.position = new Vector(offsetX, offsetY); + innerCtrl.extent = new Vector(640 - subX, 480 - subY); + btnList.position = new Vector(70 - offsetX / 2, 95); + + super.onResize(width, height); + } } diff --git a/src/gui/GuiControl.hx b/src/gui/GuiControl.hx index 0ca5645d..7a65cb1e 100644 --- a/src/gui/GuiControl.hx +++ b/src/gui/GuiControl.hx @@ -311,4 +311,10 @@ class GuiControl { c.renderEngine(engine); } } + + public function onResize(width:Int, height:Int) { + for (c in this.children) { + c.onResize(width, height); + } + } } diff --git a/src/gui/HelpCreditsGui.hx b/src/gui/HelpCreditsGui.hx index aedcaec0..a3d07344 100644 --- a/src/gui/HelpCreditsGui.hx +++ b/src/gui/HelpCreditsGui.hx @@ -18,6 +18,8 @@ class HelpCreditsGui extends GuiImage { var curScroll:Float = -50; var doScroll = false; + var innerCtrl:GuiControl; + public function new(index:Int, pauseGui:Bool = false) { var res = ResourceLoader.getImage("data/ui/xbox/BG_fadeOutSoftEdge.png").resource.toTile(); super(res); @@ -39,7 +41,7 @@ class HelpCreditsGui extends GuiImage { var subX = 640 - (scene2d.width - offsetX) * 640 / scene2d.width; var subY = 480 - (scene2d.height - offsetY) * 480 / scene2d.height; - var innerCtrl = new GuiControl(); + innerCtrl = new GuiControl(); innerCtrl.position = new Vector(offsetX, offsetY); innerCtrl.extent = new Vector(640 - subX, 480 - subY); innerCtrl.horizSizing = Width; @@ -173,4 +175,16 @@ class HelpCreditsGui extends GuiImage { wndTxtBg.onScroll(0, realScroll); } } + + override function onResize(width:Int, height:Int) { + var offsetX = (width - 1280) / 2; + var offsetY = (height - 720) / 2; + + var subX = 640 - (width - offsetX) * 640 / width; + var subY = 480 - (height - offsetY) * 480 / height; + innerCtrl.position = new Vector(offsetX, offsetY); + innerCtrl.extent = new Vector(640 - subX, 480 - subY); + + super.onResize(width, height); + } } diff --git a/src/gui/InputOptionsGui.hx b/src/gui/InputOptionsGui.hx index 47e8190e..9da80bf0 100644 --- a/src/gui/InputOptionsGui.hx +++ b/src/gui/InputOptionsGui.hx @@ -8,6 +8,8 @@ import src.Settings; import src.Util; class InputOptionsGui extends GuiImage { + var innerCtrl:GuiControl; + public function new(pauseGui:Bool = false) { var res = ResourceLoader.getImage("data/ui/xbox/BG_fadeOutSoftEdge.png").resource.toTile(); super(res); @@ -29,7 +31,7 @@ class InputOptionsGui extends GuiImage { var subX = 640 - (scene2d.width - offsetX) * 640 / scene2d.width; var subY = 480 - (scene2d.height - offsetY) * 480 / scene2d.height; - var innerCtrl = new GuiControl(); + innerCtrl = new GuiControl(); innerCtrl.position = new Vector(offsetX, offsetY); innerCtrl.extent = new Vector(640 - subX, 480 - subY); innerCtrl.horizSizing = Width; @@ -155,4 +157,16 @@ class InputOptionsGui extends GuiImage { }; bottomBar.addChild(backButton); } + + override function onResize(width:Int, height:Int) { + var offsetX = (width - 1280) / 2; + var offsetY = (height - 720) / 2; + + var subX = 640 - (width - offsetX) * 640 / width; + var subY = 480 - (height - offsetY) * 480 / height; + innerCtrl.position = new Vector(offsetX, offsetY); + innerCtrl.extent = new Vector(640 - subX, 480 - subY); + + super.onResize(width, height); + } } diff --git a/src/gui/LevelSelectGui.hx b/src/gui/LevelSelectGui.hx index c3e304a6..c2be5855 100644 --- a/src/gui/LevelSelectGui.hx +++ b/src/gui/LevelSelectGui.hx @@ -15,6 +15,8 @@ class LevelSelectGui extends GuiImage { static var currentSelectionStatic:Int = 0; static var currentDifficultyStatic:String = "beginner"; + var innerCtrl:GuiControl; + public function new(difficulty:String) { var res = ResourceLoader.getImage("data/ui/game/CloudBG.jpg").resource.toTile(); super(res); @@ -100,7 +102,7 @@ class LevelSelectGui extends GuiImage { var subX = 640 - (scene2d.width - offsetX) * 640 / scene2d.width; var subY = 480 - (scene2d.height - offsetY) * 480 / scene2d.height; - var innerCtrl = new GuiControl(); + innerCtrl = new GuiControl(); innerCtrl.position = new Vector(offsetX, offsetY); innerCtrl.extent = new Vector(640 - subX, 480 - subY); @@ -238,4 +240,16 @@ class LevelSelectGui extends GuiImage { setLevel(currentSelectionStatic); innerCtrl.addChild(levelSelectOpts); } + + override function onResize(width:Int, height:Int) { + var offsetX = (width - 1280) / 2; + var offsetY = (height - 720) / 2; + + var subX = 640 - (width - offsetX) * 640 / width; + var subY = 480 - (height - offsetY) * 480 / height; + innerCtrl.position = new Vector(offsetX, offsetY); + innerCtrl.extent = new Vector(640 - subX, 480 - subY); + + super.onResize(width, height); + } } diff --git a/src/gui/MainMenuGui.hx b/src/gui/MainMenuGui.hx index 3a5d8122..3a3fd710 100644 --- a/src/gui/MainMenuGui.hx +++ b/src/gui/MainMenuGui.hx @@ -13,6 +13,9 @@ import src.Marbleland; import src.MissionList; class MainMenuGui extends GuiImage { + var innerCtrl:GuiControl; + var btnList:GuiXboxList; + public function new() { var res = ResourceLoader.getImage("data/ui/xbox/BG_fadeOutSoftEdge.png").resource.toTile(); super(res); @@ -34,7 +37,7 @@ class MainMenuGui extends GuiImage { var subX = 640 - (scene2d.width - offsetX) * 640 / scene2d.width; var subY = 480 - (scene2d.height - offsetY) * 480 / scene2d.height; - var innerCtrl = new GuiControl(); + innerCtrl = new GuiControl(); innerCtrl.position = new Vector(offsetX, offsetY); innerCtrl.extent = new Vector(640 - subX, 480 - subY); innerCtrl.horizSizing = Width; @@ -51,7 +54,7 @@ class MainMenuGui extends GuiImage { glogo.extent = new Vector(128, 128); innerCtrl.addChild(glogo); - var btnList = new GuiXboxList(); + btnList = new GuiXboxList(); btnList.position = new Vector(70 - offsetX, 95); btnList.horizSizing = Left; btnList.extent = new Vector(502, 500); @@ -151,4 +154,17 @@ class MainMenuGui extends GuiImage { this.addChild(kofi); #end } + + override function onResize(width:Int, height:Int) { + var offsetX = (width - 1280) / 2; + var offsetY = (height - 720) / 2; + + var subX = 640 - (width - offsetX) * 640 / width; + var subY = 480 - (height - offsetY) * 480 / height; + innerCtrl.position = new Vector(offsetX, offsetY); + innerCtrl.extent = new Vector(640 - subX, 480 - subY); + btnList.position = new Vector(70 - offsetX, 95); + + super.onResize(width, height); + } } diff --git a/src/gui/MarblePickerGui.hx b/src/gui/MarblePickerGui.hx index 4c774191..ed108671 100644 --- a/src/gui/MarblePickerGui.hx +++ b/src/gui/MarblePickerGui.hx @@ -9,6 +9,8 @@ import src.ResourceLoader; import src.Settings; class MarblePickerGui extends GuiImage { + var innerCtrl:GuiControl; + public function new() { var marbleData = [ { @@ -251,7 +253,7 @@ class MarblePickerGui extends GuiImage { var subX = 640 - (scene2d.width - offsetX) * 640 / scene2d.width; var subY = 480 - (scene2d.height - offsetY) * 480 / scene2d.height; - var innerCtrl = new GuiControl(); + innerCtrl = new GuiControl(); innerCtrl.position = new Vector(offsetX, offsetY); innerCtrl.extent = new Vector(640 - subX, 480 - subY); innerCtrl.horizSizing = Width; @@ -338,4 +340,16 @@ class MarblePickerGui extends GuiImage { bottomBar.addChild(backButton); } + + override function onResize(width:Int, height:Int) { + var offsetX = (width - 1280) / 2; + var offsetY = (height - 720) / 2; + + var subX = 640 - (width - offsetX) * 640 / width; + var subY = 480 - (height - offsetY) * 480 / height; + innerCtrl.position = new Vector(offsetX, offsetY); + innerCtrl.extent = new Vector(640 - subX, 480 - subY); + + super.onResize(width, height); + } } diff --git a/src/gui/MiscOptionsGui.hx b/src/gui/MiscOptionsGui.hx index b83e2c07..a7be3bf8 100644 --- a/src/gui/MiscOptionsGui.hx +++ b/src/gui/MiscOptionsGui.hx @@ -8,6 +8,8 @@ import src.Settings; import src.Util; class MiscOptionsGui extends GuiImage { + var innerCtrl:GuiControl; + public function new(pauseGui:Bool = false) { var res = ResourceLoader.getImage("data/ui/xbox/BG_fadeOutSoftEdge.png").resource.toTile(); super(res); @@ -29,7 +31,7 @@ class MiscOptionsGui extends GuiImage { var subX = 640 - (scene2d.width - offsetX) * 640 / scene2d.width; var subY = 480 - (scene2d.height - offsetY) * 480 / scene2d.height; - var innerCtrl = new GuiControl(); + innerCtrl = new GuiControl(); innerCtrl.position = new Vector(offsetX, offsetY); innerCtrl.extent = new Vector(640 - subX, 480 - subY); innerCtrl.horizSizing = Width; @@ -114,4 +116,16 @@ class MiscOptionsGui extends GuiImage { }; bottomBar.addChild(backButton); } + + override function onResize(width:Int, height:Int) { + var offsetX = (width - 1280) / 2; + var offsetY = (height - 720) / 2; + + var subX = 640 - (width - offsetX) * 640 / width; + var subY = 480 - (height - offsetY) * 480 / height; + innerCtrl.position = new Vector(offsetX, offsetY); + innerCtrl.extent = new Vector(640 - subX, 480 - subY); + + super.onResize(width, height); + } } diff --git a/src/gui/OptionsListGui.hx b/src/gui/OptionsListGui.hx index 4cc9fac3..efb945e7 100644 --- a/src/gui/OptionsListGui.hx +++ b/src/gui/OptionsListGui.hx @@ -7,6 +7,8 @@ import src.ResourceLoader; import src.Settings; class OptionsListGui extends GuiImage { + var innerCtrl:GuiControl; + public function new(pauseGui:Bool = false) { var res = ResourceLoader.getImage("data/ui/xbox/BG_fadeOutSoftEdge.png").resource.toTile(); super(res); @@ -28,7 +30,7 @@ class OptionsListGui extends GuiImage { var subX = 640 - (scene2d.width - offsetX) * 640 / scene2d.width; var subY = 480 - (scene2d.height - offsetY) * 480 / scene2d.height; - var innerCtrl = new GuiControl(); + innerCtrl = new GuiControl(); innerCtrl.position = new Vector(offsetX, offsetY); innerCtrl.extent = new Vector(640 - subX, 480 - subY); innerCtrl.horizSizing = Width; @@ -98,4 +100,16 @@ class OptionsListGui extends GuiImage { backButton.pressedAction = (e) -> MarbleGame.canvas.setContent(new MainMenuGui()); bottomBar.addChild(backButton); } + + override function onResize(width:Int, height:Int) { + var offsetX = (width - 1280) / 2; + var offsetY = (height - 720) / 2; + + var subX = 640 - (width - offsetX) * 640 / width; + var subY = 480 - (height - offsetY) * 480 / height; + innerCtrl.position = new Vector(offsetX, offsetY); + innerCtrl.extent = new Vector(640 - subX, 480 - subY); + + super.onResize(width, height); + } } diff --git a/src/gui/VideoOptionsGui.hx b/src/gui/VideoOptionsGui.hx index c0da73ef..ae1aab69 100644 --- a/src/gui/VideoOptionsGui.hx +++ b/src/gui/VideoOptionsGui.hx @@ -8,6 +8,8 @@ import src.Settings; import src.Util; class VideoOptionsGui extends GuiImage { + var innerCtrl:GuiControl; + public function new(pauseGui:Bool = false) { var res = ResourceLoader.getImage("data/ui/xbox/BG_fadeOutSoftEdge.png").resource.toTile(); super(res); @@ -29,7 +31,7 @@ class VideoOptionsGui extends GuiImage { var subX = 640 - (scene2d.width - offsetX) * 640 / scene2d.width; var subY = 480 - (scene2d.height - offsetY) * 480 / scene2d.height; - var innerCtrl = new GuiControl(); + innerCtrl = new GuiControl(); innerCtrl.position = new Vector(offsetX, offsetY); innerCtrl.extent = new Vector(640 - subX, 480 - subY); innerCtrl.horizSizing = Width; @@ -176,4 +178,16 @@ class VideoOptionsGui extends GuiImage { }; bottomBar.addChild(backButton); } + + override function onResize(width:Int, height:Int) { + var offsetX = (width - 1280) / 2; + var offsetY = (height - 720) / 2; + + var subX = 640 - (width - offsetX) * 640 / width; + var subY = 480 - (height - offsetY) * 480 / height; + innerCtrl.position = new Vector(offsetX, offsetY); + innerCtrl.extent = new Vector(640 - subX, 480 - subY); + + super.onResize(width, height); + } }