From 9bd33c2994cac8a7560d8f761570bef5b235c165 Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Fri, 7 Jul 2023 00:29:59 +0530 Subject: [PATCH] mobile fixes --- data/tmp/font/Arial Bold.bfnt | Bin 2162 -> 2159 bytes src/Main.hx | 2 +- src/MarbleGame.hx | 1 - src/gui/Canvas.hx | 2 +- src/gui/GuiMLTextListCtrl.hx | 78 ++++++++++++---------------------- src/gui/PlayGui.hx | 8 ++-- 6 files changed, 33 insertions(+), 58 deletions(-) diff --git a/data/tmp/font/Arial Bold.bfnt b/data/tmp/font/Arial Bold.bfnt index 105b3fb49691f67947bae22596c398748a89391f..5ec0dfc6bc444d74955fda33f309c9c68c8c7d21 100644 GIT binary patch delta 940 zcmYLIO-NKx7(MU3nNhS+uMSsd?r1Zk_z=y?MHwlk*^i6Vh=ii7Kn!tE6E_h-6ts!7 z>4PxZ6troRXp0D1MbM%}U`5a(EGTHz4-vF!I`_?kF5EZYJ@>o!p6{G*e%5@exsgc3 z(LX>UNLf`c%~!GVV~*T8YkH)!T6hrdM+sQ~Tb_Xp7i zqD7+h@}$hjrofv8Pxt96E09(dn~BPp2EHW&HtBNUQxz*PZzFg+2(2gG!rJV zfjBCtvx_ROfdiaF{AL0UF0yisQf?u-)wzpm<^px7k`>RWVaBhq82D#hZIZZa)M29C zSf@0tjO-1kBF67${Fuh&LdiskFdzfNJ2ik*D+JHiPQgpfYtqJSwvI@T7@`X~B<3!t>7c?co z$ff>&SY-?2&CG5<8?SMw^e)#F*0k(!v?SOOgG_jUH8h5Fo1~vI93`5=0%frJTN!po zjjTtsn&8eAw1kGT!R4f5m^sKBh2ax&s#ESS!G9d(cBMOetTLrJgsa; rEU-69UEq@2b=o=1N5;6binnyE^e;-wN5`Zt60K%i)P|B+6-(nEtWTc6 literal 2162 zcmZXVOKenC7{~wT)&w1d>C4!eR_wG`ZGqxjlwxhg0zRk;J_{&_U`qwWielA;hMkd> zN@7gh85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d.App { super.init(); s3d.renderer = new Renderer(); - s3d.checkPasses = false; + // s3d.checkPasses = false; #if (hl && !android) hl.UI.closeConsole(); diff --git a/src/MarbleGame.hx b/src/MarbleGame.hx index 87e7be9e..303e9e51 100644 --- a/src/MarbleGame.hx +++ b/src/MarbleGame.hx @@ -213,7 +213,6 @@ class MarbleGame { var mouseState:MouseState = { position: new Vector(canvas.scene2d.mouseX, canvas.scene2d.mouseY), - wheel: _mouseWheelDelta, handled: false } ProfilerUI.measure("canvasUpdate"); diff --git a/src/gui/Canvas.hx b/src/gui/Canvas.hx index f598955c..8a67f2f8 100644 --- a/src/gui/Canvas.hx +++ b/src/gui/Canvas.hx @@ -36,7 +36,7 @@ class Canvas extends GuiControl { public function pushDialog(content:GuiControl) { this.addChild(content); - content.render(scene2d, @:privateAccess this._flow); + content.render(scene2d); // this.render(scene2d); } diff --git a/src/gui/GuiMLTextListCtrl.hx b/src/gui/GuiMLTextListCtrl.hx index d4a1d6f0..85055b6d 100644 --- a/src/gui/GuiMLTextListCtrl.hx +++ b/src/gui/GuiMLTextListCtrl.hx @@ -40,7 +40,6 @@ class GuiMLTextListCtrl extends GuiControl { super(); this.font = font; this.texts = texts; - this._manualScroll = true; this.textObjs = []; this._imageLoader = imageLoader; for (text in texts) { @@ -87,8 +86,7 @@ class GuiMLTextListCtrl extends GuiControl { for (i in 0...textObjs.length) { var text = textObjs[i]; text.setPosition(Math.floor((!scrollable ? renderRect.position.x : 0) + 5), - Math.floor((!scrollable ? renderRect.position.y : 0) - + (i * (text.font.size + 4 * Settings.uiScale) + (5 + textYOffset) * Settings.uiScale - this.scroll))); + Math.floor((!scrollable ? renderRect.position.y : 0) + (i * (text.font.size + 4) + 5 + textYOffset * Settings.uiScale - this.scroll))); if (_prevSelected == i) { text.textColor = selectedColor; @@ -96,20 +94,14 @@ class GuiMLTextListCtrl extends GuiControl { } } - public override function render(scene2d:Scene, ?parent:h2d.Flow) { + public override function render(scene2d:Scene) { var renderRect = this.getRenderRectangle(); - var htr = this.getHitTestRect(false); + var htr = this.getHitTestRect(); - if (parent != null) { - if (parent.contains(g)) - parent.removeChild(g); - parent.addChild(g); - - var off = this.getOffsetFromParent(); - parent.getProperties(g).isAbsolute = true; - - g.setPosition(off.x, off.y - this.scroll); - } + if (scene2d.contains(g)) + scene2d.removeChild(g); + scene2d.addChild(g); + g.setPosition(renderRect.position.x, renderRect.position.y - this.scroll); if (scrollable) { this.flow = new Flow(); @@ -119,18 +111,12 @@ class GuiMLTextListCtrl extends GuiControl { this.flow.multiline = true; this.flow.layout = Stack; this.flow.overflow = FlowOverflow.Hidden; + if (scene2d.contains(this.flow)) + scene2d.removeChild(this.flow); - if (parent != null) { - if (parent.contains(this.flow)) { - parent.removeChild(this.flow); - } - parent.addChild(this.flow); - var off = this.getOffsetFromParent(); - var props = parent.getProperties(this.flow); - props.isAbsolute = true; + scene2d.addChild(this.flow); - this.flow.setPosition(off.x, off.y); - } + this.flow.setPosition(htr.position.x, htr.position.y); } for (i in 0...textObjs.length) { @@ -148,8 +134,7 @@ class GuiMLTextListCtrl extends GuiControl { } text.setPosition(Math.floor((!scrollable ? renderRect.position.x : 0) + 5), - Math.floor((!scrollable ? renderRect.position.y : 0) - + (i * (text.font.size + 4 * Settings.uiScale) + (5 + textYOffset) * Settings.uiScale - this.scroll))); + Math.floor((!scrollable ? renderRect.position.y : 0) + (i * (text.font.size + 4) + 5 + textYOffset * Settings.uiScale - this.scroll))); if (_prevSelected == i) { text.textColor = selectedColor; @@ -157,11 +142,11 @@ class GuiMLTextListCtrl extends GuiControl { } redrawSelectionRect(htr); - super.render(scene2d, parent); + super.render(scene2d); } public function calculateFullHeight() { - return (this.texts.length * (font.size + 4 * Settings.uiScale)); + return (this.texts.length * (font.size + 4)); } public override function dispose() { @@ -181,11 +166,9 @@ class GuiMLTextListCtrl extends GuiControl { if (MarbleGame.canvas.scene2d.contains(text)) { MarbleGame.canvas.scene2d.removeChild(text); // Refresh "layer" } - text.remove(); } if (MarbleGame.canvas.scene2d.contains(g)) MarbleGame.canvas.scene2d.removeChild(g); - g.remove(); } public override function onMouseMove(mouseState:MouseState) { @@ -193,7 +176,7 @@ class GuiMLTextListCtrl extends GuiControl { var renderRect = this.getRenderRectangle(); var yStart = renderRect.position.y; var dy = mousePos.y - yStart; - var hoverIndex = Math.floor(dy / (font.size + 4 * Settings.uiScale)); + var hoverIndex = Math.floor((dy + this.scroll) / (font.size + 4)); if (hoverIndex >= this.texts.length) { hoverIndex = -1; } @@ -225,7 +208,7 @@ class GuiMLTextListCtrl extends GuiControl { var renderRect = this.getRenderRectangle(); var yStart = renderRect.position.y; var dy = mousePos.y - yStart; - var selectedIndex = Math.floor((dy + this.scroll) / (font.size + 4 * Settings.uiScale)); + var selectedIndex = Math.floor((dy + this.scroll) / (font.size + 4)); if (selectedIndex >= this.texts.length) { selectedIndex = -1; } @@ -245,31 +228,26 @@ class GuiMLTextListCtrl extends GuiControl { g.clear(); g.beginFill(selectedFillColor); - var off = this.getOffsetFromParent(); // Check if we are between the top and bottom, render normally in that case - var topY = 2 * Settings.uiScale + (_prevSelected * (font.size + 4 * Settings.uiScale)) + g.y; - var bottomY = 2 * Settings.uiScale + (_prevSelected * (font.size + 4 * Settings.uiScale)) + g.y + font.size + 4 * Settings.uiScale; - var topRectY = off.y; - var bottomRectY = off.y + renderRect.extent.y; + var topY = 2 + (_prevSelected * (font.size + 4)) + g.y; + var bottomY = 2 + (_prevSelected * (font.size + 4)) + g.y + font.size + 4; + var topRectY = renderRect.position.y; + var bottomRectY = renderRect.position.y + renderRect.extent.y; if (topY >= topRectY && bottomY <= bottomRectY) - g.drawRect(0, 5 * Settings.uiScale - + (_prevSelected * (font.size + 4 * Settings.uiScale)) - - 3 * Settings.uiScale, renderRect.extent.x, - font.size - + 4 * Settings.uiScale); + g.drawRect(0, 5 + (_prevSelected * (font.size + 4)) - 3, renderRect.extent.x, font.size + 4); // We need to do math the draw the partially visible top selected if (topY <= topRectY && bottomY >= topRectY) { - g.drawRect(0, this.scroll, renderRect.extent.x, topY + font.size + 4 * Settings.uiScale - off.y); + g.drawRect(0, this.scroll, renderRect.extent.x, topY + font.size + 4 - renderRect.position.y); } // Same for the bottom if (topY <= bottomRectY && bottomY >= bottomRectY) { g.drawRect(0, this.scroll + renderRect.extent.y - font.size - - 4 * Settings.uiScale - + (topY + font.size + 4 * Settings.uiScale - bottomRectY), - renderRect.extent.x, off.y + - 4 + + (topY + font.size + 4 - bottomRectY), renderRect.extent.x, + renderRect.position.y + renderRect.extent.y - (topY)); } @@ -284,11 +262,11 @@ class GuiMLTextListCtrl extends GuiControl { var renderRect = this.getRenderRectangle(); this.scroll = scrollY; - var hittestrect = this.getHitTestRect(false); + var hittestrect = this.getHitTestRect(); for (i in 0...textObjs.length) { var text = textObjs[i]; - text.y = Math.floor((i * (text.font.size + 4 * Settings.uiScale) + (5 + textYOffset) * Settings.uiScale - scrollY)); - g.y = -scrollY; + text.y = Math.floor((i * (text.font.size + 4) + 5 + textYOffset * Settings.uiScale - scrollY)); + g.y = renderRect.position.y - scrollY; } redrawSelectionRect(hittestrect); } diff --git a/src/gui/PlayGui.hx b/src/gui/PlayGui.hx index d16c1275..306dc908 100644 --- a/src/gui/PlayGui.hx +++ b/src/gui/PlayGui.hx @@ -159,8 +159,6 @@ class PlayGui { }; Window.getInstance().addResizeEvent(resizeEv); - - onFinish(); } public function initTimer() { @@ -627,7 +625,7 @@ class PlayGui { gemCountSlash.position.x = 25; gemHUD.position.x = 59; } - gemHUD.parent.render(scene2d, @:privateAccess gemHUD.parent.parent._flow); + gemHUD.parent.render(scene2d); } public function resizeGemHuntCounter(total:Int) { @@ -660,7 +658,7 @@ class PlayGui { gemCountNumbers[2].position.x = 56; } gemHUD.position.x = 74; - gemHUD.parent.render(scene2d, @:privateAccess gemHUD.parent.parent._flow); + gemHUD.parent.render(scene2d); } public function formatGemCounter(collected:Int, total:Int) { @@ -787,7 +785,7 @@ class PlayGui { middleMsg.text.textColor = color; middleMsg.text.filter = new h2d.filter.DropShadow(1.414, 0.785, 0x000000, 1, 0, 0.4, 1, true); this.playGuiCtrl.addChild(middleMsg); - middleMsg.render(scene2d, @:privateAccess this.playGuiCtrl._flow); + middleMsg.render(scene2d); middleMsg.text.y -= (25 / playGuiCtrl.extent.y) * scene2d.height; this.middleMessages.push({ctrl: middleMsg, age: 0, yPos: middleMsg.text.y});