mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
touch ui bugfixes and improves
This commit is contained in:
parent
f3cc59066a
commit
bf41bb576e
8 changed files with 94 additions and 10 deletions
|
|
@ -222,6 +222,7 @@ class MarbleGame {
|
|||
paused = false;
|
||||
var pmg = new PlayMissionGui();
|
||||
PlayMissionGui.currentSelectionStatic = world.mission.index;
|
||||
PlayMissionGui.currentGameStatic = world.mission.game;
|
||||
if (world.isRecording) {
|
||||
world.saveReplay();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,8 +177,8 @@ class ResourceLoader {
|
|||
|
||||
static function preloadMusic(onFinish:Void->Void) {
|
||||
var worker = new ResourceLoaderWorker(onFinish);
|
||||
worker.loadFile("sound/shell.ogg");
|
||||
worker.loadFile("sound/pianoforte.ogg");
|
||||
worker.loadFile("sound/music/shell.ogg");
|
||||
worker.loadFile("sound/music/pianoforte.ogg");
|
||||
worker.run();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package gui;
|
||||
|
||||
import h3d.Vector;
|
||||
import src.Settings;
|
||||
import gui.GuiControl.MouseState;
|
||||
import h2d.Interactive;
|
||||
import h2d.Scene;
|
||||
|
|
@ -27,6 +29,7 @@ class GuiScrollCtrl extends GuiControl {
|
|||
|
||||
var pressed:Bool = false;
|
||||
var dirty:Bool = true;
|
||||
var prevMousePos:Vector;
|
||||
|
||||
public function new(scrollBar:Tile) {
|
||||
super();
|
||||
|
|
@ -158,6 +161,35 @@ class GuiScrollCtrl extends GuiControl {
|
|||
}
|
||||
}
|
||||
|
||||
public override function onMousePress(mouseState:MouseState) {
|
||||
if (Util.isTouchDevice()) {
|
||||
this.pressed = true;
|
||||
this.dirty = true;
|
||||
this.updateScrollVisual();
|
||||
this.prevMousePos = mouseState.position;
|
||||
}
|
||||
}
|
||||
|
||||
public override function onMouseRelease(mouseState:MouseState) {
|
||||
if (Util.isTouchDevice()) {
|
||||
this.pressed = false;
|
||||
this.dirty = true;
|
||||
this.updateScrollVisual();
|
||||
}
|
||||
}
|
||||
|
||||
public override function onMouseMove(mouseState:MouseState) {
|
||||
if (Util.isTouchDevice()) {
|
||||
super.onMouseMove(mouseState);
|
||||
if (this.pressed) {
|
||||
var dy = mouseState.position.y - this.prevMousePos.y;
|
||||
this.scrollY -= dy;
|
||||
this.prevMousePos = mouseState.position;
|
||||
this.updateScrollVisual();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// public override function onMouseDown(mouseState:MouseState) {
|
||||
// var renderRect = this.getHitTestRect();
|
||||
// if (mouseState.position.x >= renderRect.position.x + renderRect.extent.x - 10) {
|
||||
|
|
|
|||
|
|
@ -66,7 +66,8 @@ class GuiTextInput extends GuiControl {
|
|||
|
||||
#if js
|
||||
if (Util.isTouchDevice()) {
|
||||
text.text = js.Browser.window.prompt("Enter your name", text.text);
|
||||
text.text = js.Browser.window.prompt("Enter your input", text.text);
|
||||
onTextChange(this.text.text);
|
||||
var canvas = js.Browser.document.querySelector("#webgl");
|
||||
// canvas.focus();
|
||||
// js.Browser.document.documentElement.requestFullscreen();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import h3d.Vector;
|
|||
import src.ResourceLoader;
|
||||
import src.Settings;
|
||||
import src.Util;
|
||||
import src.Replay;
|
||||
|
||||
class MainMenuGui extends GuiImage {
|
||||
public function new() {
|
||||
|
|
@ -86,7 +87,36 @@ class MainMenuGui extends GuiImage {
|
|||
replButton.vertSizing = Top;
|
||||
replButton.position = new Vector(552, 536);
|
||||
replButton.extent = new Vector(191, 141);
|
||||
replButton.pressedAction = (sender) -> {};
|
||||
replButton.pressedAction = (sender) -> {
|
||||
hxd.File.browse((replayToLoad) -> {
|
||||
replayToLoad.load((replayData) -> {
|
||||
var replay = new Replay("");
|
||||
if (!replay.read(replayData)) {
|
||||
cast(this.parent, Canvas).pushDialog(new MessageBoxOkDlg("Cannot load replay."));
|
||||
// Idk do something to notify the user here
|
||||
} else {
|
||||
var repmis = replay.mission;
|
||||
#if js
|
||||
repmis = StringTools.replace(repmis, "data/", "");
|
||||
#end
|
||||
var playMis = MissionList.missions.get(repmis);
|
||||
if (playMis != null) {
|
||||
cast(this.parent, Canvas).marbleGame.watchMissionReplay(playMis, replay);
|
||||
} else {
|
||||
cast(this.parent, Canvas).pushDialog(new MessageBoxOkDlg("Cannot load replay."));
|
||||
}
|
||||
}
|
||||
});
|
||||
}, {
|
||||
title: "Select replay file",
|
||||
fileTypes: [
|
||||
{
|
||||
name: "Replay (*.mbr)",
|
||||
extensions: ["mbr"]
|
||||
}
|
||||
],
|
||||
});
|
||||
};
|
||||
mainMenuContent.addChild(replButton);
|
||||
|
||||
var helpButton = new GuiButton(loadButtonImages("data/ui/menu/help"));
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class MessageBoxOkDlg extends GuiControl {
|
|||
|
||||
var okButton = new GuiButton(loadButtonImages("data/ui/common/ok"));
|
||||
okButton.position = new Vector(117, 85);
|
||||
okButton.extent = new Vector(78, 59);
|
||||
okButton.extent = new Vector(88, 41);
|
||||
okButton.vertSizing = Top;
|
||||
okButton.pressedAction = (sender) -> {
|
||||
MarbleGame.canvas.popDialog(this);
|
||||
|
|
|
|||
|
|
@ -376,6 +376,25 @@ class OptionsDlg extends GuiImage {
|
|||
makeRemapOption("Respawn:", 278, Util.getKeyForButton2(Settings.controlsSettings.respawn), (key) -> Settings.controlsSettings.respawn = key,
|
||||
hotkeysPanel, true);
|
||||
|
||||
if (Util.isTouchDevice()) {
|
||||
var textObj = new GuiText(markerFelt32);
|
||||
textObj.position = new Vector(5, 326);
|
||||
textObj.extent = new Vector(212, 14);
|
||||
textObj.text.text = "Touch Controls";
|
||||
textObj.text.textColor = 0xFFFFFF;
|
||||
textObj.text.filter = new DropShadow(1.414, 0.785, 0x0000000F, 1, 0, 0.4, 1, true);
|
||||
hotkeysPanel.addChild(textObj);
|
||||
|
||||
var remapBtn = new GuiButtonText(loadButtonImages("data/ui/options/bind"), markerFelt24);
|
||||
remapBtn.position = new Vector(203, 323);
|
||||
remapBtn.txtCtrl.text.text = "Edit";
|
||||
remapBtn.setExtent(new Vector(152, 49));
|
||||
remapBtn.pressedAction = (sender) -> {
|
||||
MarbleGame.canvas.setContent(new TouchCtrlsEditGui());
|
||||
}
|
||||
hotkeysPanel.addChild(remapBtn);
|
||||
}
|
||||
|
||||
generalBtn.pressedAction = (e) -> {
|
||||
if (currentTab != "general") {
|
||||
currentTab = "general";
|
||||
|
|
|
|||
|
|
@ -8,10 +8,11 @@ import h3d.Vector;
|
|||
import src.ResourceLoader;
|
||||
import src.MarbleGame;
|
||||
import src.Settings;
|
||||
import src.Util;
|
||||
|
||||
class TouchCtrlsEditGui extends GuiImage {
|
||||
public function new() {
|
||||
var img = ResourceLoader.getImage("data/ui/background.jpg");
|
||||
var img = Math.random() >= 0.7 ? ResourceLoader.getImage('data/ui/backgrounds/platinum/${cast (Math.floor(Util.lerp(1, 28, Math.random())), Int)}.jpg') : ResourceLoader.getImage('data/ui/backgrounds/gold/${cast (Math.floor(Util.lerp(1, 12, Math.random())), Int)}.jpg');
|
||||
super(img.resource.toTile());
|
||||
this.horizSizing = Width;
|
||||
this.vertSizing = Height;
|
||||
|
|
@ -30,11 +31,11 @@ class TouchCtrlsEditGui extends GuiImage {
|
|||
@:privateAccess domcasual32b.loader = ResourceLoader.loader;
|
||||
var domcasual32 = domcasual32b.toSdfFont(cast 26 * Settings.uiScale, MultiChannel);
|
||||
|
||||
var mainMenuButton = new GuiButton(loadButtonImages("data/ui/options/mainm"));
|
||||
mainMenuButton.position = new Vector(500, 400);
|
||||
mainMenuButton.extent = new Vector(121, 53);
|
||||
var mainMenuButton = new GuiButton(loadButtonImages("data/ui/menu/options"));
|
||||
mainMenuButton.position = new Vector(380, 15);
|
||||
mainMenuButton.extent = new Vector(247, 164);
|
||||
mainMenuButton.horizSizing = Left;
|
||||
mainMenuButton.vertSizing = Top;
|
||||
mainMenuButton.vertSizing = Bottom;
|
||||
mainMenuButton.pressedAction = (sender) -> {
|
||||
MarbleGame.canvas.setContent(new OptionsDlg());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue