mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
mobile fixes
This commit is contained in:
parent
8e86779267
commit
9bd33c2994
6 changed files with 33 additions and 58 deletions
Binary file not shown.
|
|
@ -39,7 +39,7 @@ class Main extends hxd.App {
|
|||
super.init();
|
||||
|
||||
s3d.renderer = new Renderer();
|
||||
s3d.checkPasses = false;
|
||||
// s3d.checkPasses = false;
|
||||
|
||||
#if (hl && !android)
|
||||
hl.UI.closeConsole();
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue