mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-05-10 19:41:39 +00:00
add key rebinding ui
This commit is contained in:
parent
0f1be7359b
commit
68ce996c4c
6 changed files with 313 additions and 71 deletions
|
|
@ -998,23 +998,23 @@ class MarbleWorld extends Scheduler {
|
||||||
ProfilerUI.measure("updateTimer");
|
ProfilerUI.measure("updateTimer");
|
||||||
this.updateTimer(dt);
|
this.updateTimer(dt);
|
||||||
|
|
||||||
if ((Key.isPressed(Settings.controlsSettings.respawn) || Gamepad.isPressed(Settings.gamepadSettings.respawn))
|
// if ((Key.isPressed(Settings.controlsSettings.respawn) || Gamepad.isPressed(Settings.gamepadSettings.respawn))
|
||||||
&& this.finishTime == null) {
|
// && this.finishTime == null) {
|
||||||
performRestart();
|
// performRestart();
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if ((Key.isDown(Settings.controlsSettings.respawn)
|
// if ((Key.isDown(Settings.controlsSettings.respawn)
|
||||||
|| MarbleGame.instance.touchInput.restartButton.pressed
|
// || MarbleGame.instance.touchInput.restartButton.pressed
|
||||||
|| Gamepad.isDown(Settings.gamepadSettings.respawn))
|
// || Gamepad.isDown(Settings.gamepadSettings.respawn))
|
||||||
&& !this.isWatching
|
// && !this.isWatching
|
||||||
&& this.finishTime == null) {
|
// && this.finishTime == null) {
|
||||||
if (timeState.timeSinceLoad - this.respawnPressedTime > 1.5) {
|
// if (timeState.timeSinceLoad - this.respawnPressedTime > 1.5) {
|
||||||
this.restart(true);
|
// this.restart(true);
|
||||||
this.respawnPressedTime = Math.POSITIVE_INFINITY;
|
// this.respawnPressedTime = Math.POSITIVE_INFINITY;
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
this.tickSchedule(timeState.currentAttemptTime);
|
this.tickSchedule(timeState.currentAttemptTime);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,5 +16,6 @@ class GuiXboxList extends GuiControl {
|
||||||
btn.pressedAction = func;
|
btn.pressedAction = func;
|
||||||
this.addChild(btn);
|
this.addChild(btn);
|
||||||
currentOffset += 60 + addOffset;
|
currentOffset += 60 + addOffset;
|
||||||
|
return btn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
207
src/gui/KeyBindingsGui.hx
Normal file
207
src/gui/KeyBindingsGui.hx
Normal file
|
|
@ -0,0 +1,207 @@
|
||||||
|
package gui;
|
||||||
|
|
||||||
|
import hxd.Key;
|
||||||
|
import src.MarbleGame;
|
||||||
|
import hxd.res.BitmapFont;
|
||||||
|
import h3d.Vector;
|
||||||
|
import src.ResourceLoader;
|
||||||
|
import src.Settings;
|
||||||
|
import src.Util;
|
||||||
|
|
||||||
|
class KeyBindingsGui extends GuiImage {
|
||||||
|
var innerCtrl:GuiControl;
|
||||||
|
var btnListLeft:GuiXboxList;
|
||||||
|
var btnListRight:GuiXboxList;
|
||||||
|
|
||||||
|
public function new(pauseGui:Bool = false) {
|
||||||
|
var res = ResourceLoader.getImage("data/ui/xbox/BG_fadeOutSoftEdge.png").resource.toTile();
|
||||||
|
super(res);
|
||||||
|
var domcasual32fontdata = ResourceLoader.getFileEntry("data/font/DomCasualD.fnt");
|
||||||
|
var domcasual32b = new BitmapFont(domcasual32fontdata.entry);
|
||||||
|
@:privateAccess domcasual32b.loader = ResourceLoader.loader;
|
||||||
|
var domcasual32 = domcasual32b.toSdfFont(cast 42 * Settings.uiScale, MultiChannel);
|
||||||
|
|
||||||
|
this.horizSizing = Width;
|
||||||
|
this.vertSizing = Height;
|
||||||
|
this.position = new Vector();
|
||||||
|
this.extent = new Vector(640, 480);
|
||||||
|
|
||||||
|
function getConflictingBinding(bindingName:String, key:Int) {
|
||||||
|
if (Settings.controlsSettings.forward == key && bindingName != "Move Forward")
|
||||||
|
return "Move Forward";
|
||||||
|
if (Settings.controlsSettings.backward == key && bindingName != "Move Backward")
|
||||||
|
return "Move Backward";
|
||||||
|
if (Settings.controlsSettings.left == key && bindingName != "Move Left")
|
||||||
|
return "Move Left";
|
||||||
|
if (Settings.controlsSettings.right == key && bindingName != "Move Right")
|
||||||
|
return "Move Right";
|
||||||
|
if (Settings.controlsSettings.camForward == key && bindingName != "Rotate Camera Up")
|
||||||
|
return "Rotate Camera Up";
|
||||||
|
if (Settings.controlsSettings.camBackward == key && bindingName != "Rotate Camera Down")
|
||||||
|
return "Rotate Camera Down";
|
||||||
|
if (Settings.controlsSettings.camLeft == key && bindingName != "Rotate Camera Left")
|
||||||
|
return "Rotate Camera Left";
|
||||||
|
if (Settings.controlsSettings.camRight == key && bindingName != "Rotate Camera Right")
|
||||||
|
return "Rotate Camera Right";
|
||||||
|
if (Settings.controlsSettings.jump == key && bindingName != "Jump")
|
||||||
|
return "Jump";
|
||||||
|
if (Settings.controlsSettings.powerup == key && bindingName != "Use PowerUp")
|
||||||
|
return "Use PowerUp";
|
||||||
|
if (Settings.controlsSettings.freelook == key && bindingName != "Free Look")
|
||||||
|
return "Free Look";
|
||||||
|
if (Settings.controlsSettings.rewind == key && bindingName != "Rewind")
|
||||||
|
return "Rewind";
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function remapFunc(bindingName:String, bindingFunc:Int->Void, ctrl:GuiXboxListButton) {
|
||||||
|
var remapDlg = new RemapDlg(bindingName);
|
||||||
|
MarbleGame.canvas.pushDialog(remapDlg);
|
||||||
|
remapDlg.remapCallback = (key) -> {
|
||||||
|
MarbleGame.canvas.popDialog(remapDlg);
|
||||||
|
|
||||||
|
if (key == Key.ESCAPE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var conflicting = getConflictingBinding(bindingName, key);
|
||||||
|
if (conflicting == null) {
|
||||||
|
ctrl.buttonText.text.text = '${bindingName}: ${Util.getKeyForButton2(key)}';
|
||||||
|
bindingFunc(key);
|
||||||
|
} else {
|
||||||
|
var yesNoDlg = new MessageBoxYesNoDlg('"${Util.getKeyForButton2(key)}" is already bound to "${conflicting}"!<br/>Do you want to undo this mapping?',
|
||||||
|
() -> {
|
||||||
|
ctrl.buttonText.text.text = '${bindingName}: ${Util.getKeyForButton2(key)}';
|
||||||
|
bindingFunc(key);
|
||||||
|
}, () -> {});
|
||||||
|
MarbleGame.canvas.pushDialog(yesNoDlg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var scene2d = MarbleGame.canvas.scene2d;
|
||||||
|
|
||||||
|
var offsetX = (scene2d.width - 1280) / 2;
|
||||||
|
var offsetY = (scene2d.height - 720) / 2;
|
||||||
|
|
||||||
|
var subX = 640 - (scene2d.width - offsetX) * 640 / scene2d.width;
|
||||||
|
var subY = 480 - (scene2d.height - offsetY) * 480 / scene2d.height;
|
||||||
|
|
||||||
|
innerCtrl = new GuiControl();
|
||||||
|
innerCtrl.position = new Vector(offsetX, offsetY);
|
||||||
|
innerCtrl.extent = new Vector(640 - subX, 480 - subY);
|
||||||
|
innerCtrl.horizSizing = Width;
|
||||||
|
innerCtrl.vertSizing = Height;
|
||||||
|
this.addChild(innerCtrl);
|
||||||
|
|
||||||
|
var coliseumfontdata = ResourceLoader.getFileEntry("data/font/ColiseumRR.fnt");
|
||||||
|
var coliseumb = new BitmapFont(coliseumfontdata.entry);
|
||||||
|
@:privateAccess coliseumb.loader = ResourceLoader.loader;
|
||||||
|
var coliseum = coliseumb.toSdfFont(cast 44 * Settings.uiScale, MultiChannel);
|
||||||
|
|
||||||
|
var rootTitle = new GuiText(coliseum);
|
||||||
|
rootTitle.position = new Vector(100, 30);
|
||||||
|
rootTitle.extent = new Vector(1120, 80);
|
||||||
|
rootTitle.text.textColor = 0xFFFFFF;
|
||||||
|
rootTitle.text.text = "KEY BINDINGS";
|
||||||
|
rootTitle.text.alpha = 0.5;
|
||||||
|
innerCtrl.addChild(rootTitle);
|
||||||
|
|
||||||
|
btnListLeft = new GuiXboxList();
|
||||||
|
btnListLeft.position = new Vector(70 - offsetX, 135);
|
||||||
|
btnListLeft.horizSizing = Left;
|
||||||
|
btnListLeft.extent = new Vector(502, 500);
|
||||||
|
innerCtrl.addChild(btnListLeft);
|
||||||
|
|
||||||
|
btnListRight = new GuiXboxList();
|
||||||
|
btnListRight.position = new Vector(-400 - offsetX, 135);
|
||||||
|
btnListRight.horizSizing = Left;
|
||||||
|
btnListRight.extent = new Vector(502, 500);
|
||||||
|
innerCtrl.addChild(btnListRight);
|
||||||
|
|
||||||
|
var b1 = btnListRight.addButton(0, 'Move Forward: ${Util.getKeyForButton2(Settings.controlsSettings.forward)}', (e) -> {});
|
||||||
|
b1.pressedAction = (e) -> {
|
||||||
|
remapFunc("Move Forward", (key) -> Settings.controlsSettings.forward = key, b1);
|
||||||
|
};
|
||||||
|
|
||||||
|
var b2 = btnListRight.addButton(0, 'Move Backward: ${Util.getKeyForButton2(Settings.controlsSettings.backward)}', (e) -> {});
|
||||||
|
b2.pressedAction = (e) -> {
|
||||||
|
remapFunc("Move Backward", (key) -> Settings.controlsSettings.backward = key, b2);
|
||||||
|
};
|
||||||
|
var b3 = btnListRight.addButton(0, 'Move Left: ${Util.getKeyForButton2(Settings.controlsSettings.left)}', (e) -> {});
|
||||||
|
b3.pressedAction = (e) -> {
|
||||||
|
remapFunc("Move Left", (key) -> Settings.controlsSettings.left = key, b3);
|
||||||
|
};
|
||||||
|
var b4 = btnListRight.addButton(0, 'Move Right: ${Util.getKeyForButton2(Settings.controlsSettings.right)}', (e) -> {});
|
||||||
|
b4.pressedAction = (e) -> {
|
||||||
|
remapFunc("Move Right", (key) -> Settings.controlsSettings.right = key, b4);
|
||||||
|
}
|
||||||
|
var b5 = btnListRight.addButton(0, 'Jump: ${Util.getKeyForButton2(Settings.controlsSettings.jump)}', (e) -> {});
|
||||||
|
b5.pressedAction = (e) -> {
|
||||||
|
remapFunc("Jump", (key) -> Settings.controlsSettings.jump = key, b5);
|
||||||
|
};
|
||||||
|
var b6 = btnListRight.addButton(0, 'Blast: ${Util.getKeyForButton2(Settings.controlsSettings.blast)}', (e) -> {});
|
||||||
|
b6.pressedAction = (e) -> {
|
||||||
|
remapFunc("Blast", (key) -> Settings.controlsSettings.blast = key, b6);
|
||||||
|
}
|
||||||
|
var b7 = btnListLeft.addButton(0, 'Look Up: ${Util.getKeyForButton2(Settings.controlsSettings.camForward)}', (e) -> {});
|
||||||
|
b7.pressedAction = (e) -> {
|
||||||
|
remapFunc("Look Up", (key) -> Settings.controlsSettings.camForward = key, b7);
|
||||||
|
}
|
||||||
|
var b8 = btnListLeft.addButton(0, 'Look Down: ${Util.getKeyForButton2(Settings.controlsSettings.camBackward)}', (e) -> {});
|
||||||
|
b8.pressedAction = (e) -> {
|
||||||
|
remapFunc("Look Down", (key) -> Settings.controlsSettings.camBackward = key, b8);
|
||||||
|
}
|
||||||
|
var b9 = btnListLeft.addButton(0, 'Look Left: ${Util.getKeyForButton2(Settings.controlsSettings.camLeft)}', (e) -> {});
|
||||||
|
b9.pressedAction = (e) -> {
|
||||||
|
remapFunc("Look Left", (key) -> Settings.controlsSettings.camLeft = key, b9);
|
||||||
|
}
|
||||||
|
var b10 = btnListLeft.addButton(0, 'Look Right: ${Util.getKeyForButton2(Settings.controlsSettings.camRight)}', (e) -> {});
|
||||||
|
b10.pressedAction = (e) -> {
|
||||||
|
remapFunc("Look Right", (key) -> Settings.controlsSettings.camRight = key, b10);
|
||||||
|
}
|
||||||
|
var b11 = btnListLeft.addButton(0, 'Use Powerup: ${Util.getKeyForButton2(Settings.controlsSettings.powerup)}', (e) -> {});
|
||||||
|
b11.pressedAction = (e) -> {
|
||||||
|
remapFunc("Use Powerup", (key) -> Settings.controlsSettings.powerup = key, b11);
|
||||||
|
}
|
||||||
|
var b12 = btnListLeft.addButton(0, 'Rewind: ${Util.getKeyForButton2(Settings.controlsSettings.rewind)}', (e) -> {});
|
||||||
|
b12.pressedAction = (e) -> {
|
||||||
|
remapFunc("Rewind", (key) -> Settings.controlsSettings.rewind = key, b12);
|
||||||
|
}
|
||||||
|
|
||||||
|
var bottomBar = new GuiControl();
|
||||||
|
bottomBar.position = new Vector(0, 590);
|
||||||
|
bottomBar.extent = new Vector(640, 200);
|
||||||
|
bottomBar.horizSizing = Width;
|
||||||
|
bottomBar.vertSizing = Bottom;
|
||||||
|
innerCtrl.addChild(bottomBar);
|
||||||
|
|
||||||
|
var backButton = new GuiXboxButton("Back", 160);
|
||||||
|
backButton.position = new Vector(400, 0);
|
||||||
|
backButton.vertSizing = Bottom;
|
||||||
|
backButton.horizSizing = Right;
|
||||||
|
backButton.gamepadAccelerator = ["B"];
|
||||||
|
if (pauseGui)
|
||||||
|
backButton.pressedAction = (e) -> {
|
||||||
|
MarbleGame.canvas.popDialog(this);
|
||||||
|
MarbleGame.canvas.pushDialog(new OptionsListGui(true));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
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);
|
||||||
|
btnListLeft.position = new Vector(70 - offsetX, 135);
|
||||||
|
btnListLeft.position = new Vector(-400 - offsetX, 135);
|
||||||
|
|
||||||
|
super.onResize(width, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,7 @@ import hxd.res.BitmapFont;
|
||||||
import h3d.Vector;
|
import h3d.Vector;
|
||||||
import src.ResourceLoader;
|
import src.ResourceLoader;
|
||||||
import src.Settings;
|
import src.Settings;
|
||||||
|
import src.Util;
|
||||||
|
|
||||||
class OptionsListGui extends GuiImage {
|
class OptionsListGui extends GuiImage {
|
||||||
var innerCtrl:GuiControl;
|
var innerCtrl:GuiControl;
|
||||||
|
|
@ -64,6 +65,17 @@ class OptionsListGui extends GuiImage {
|
||||||
btnList.addButton(3, 'Input and Sound Options', (e) -> {
|
btnList.addButton(3, 'Input and Sound Options', (e) -> {
|
||||||
MarbleGame.canvas.setContent(new InputOptionsGui(pauseGui));
|
MarbleGame.canvas.setContent(new InputOptionsGui(pauseGui));
|
||||||
});
|
});
|
||||||
|
if (Util.isTouchDevice()) {
|
||||||
|
if (!pauseGui) {
|
||||||
|
btnList.addButton(3, 'Touch Controls', (e) -> {
|
||||||
|
MarbleGame.canvas.setContent(new TouchCtrlsEditGui(pauseGui));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
btnList.addButton(3, 'Key Bindings', (e) -> {
|
||||||
|
MarbleGame.canvas.setContent(new KeyBindingsGui(pauseGui));
|
||||||
|
});
|
||||||
|
}
|
||||||
btnList.addButton(3, 'Video Options', (e) -> {
|
btnList.addButton(3, 'Video Options', (e) -> {
|
||||||
MarbleGame.canvas.setContent(new VideoOptionsGui(pauseGui));
|
MarbleGame.canvas.setContent(new VideoOptionsGui(pauseGui));
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -7,35 +7,33 @@ import h3d.Vector;
|
||||||
import src.ResourceLoader;
|
import src.ResourceLoader;
|
||||||
import src.Settings;
|
import src.Settings;
|
||||||
|
|
||||||
class RemapDlg extends GuiControl {
|
class RemapDlg extends GuiImage {
|
||||||
var remapCallback:Int->Void;
|
var remapCallback:Int->Void;
|
||||||
|
|
||||||
public function new(bindingName:String) {
|
public function new(bindingName:String) {
|
||||||
super();
|
var res = ResourceLoader.getImage("data/ui/xbox/roundedBG.png").resource.toTile();
|
||||||
|
super(res);
|
||||||
this.horizSizing = Width;
|
this.horizSizing = Width;
|
||||||
this.vertSizing = Height;
|
this.vertSizing = Height;
|
||||||
this.position = new Vector();
|
this.position = new Vector();
|
||||||
this.extent = new Vector(640, 480);
|
this.extent = new Vector(640, 480);
|
||||||
|
|
||||||
var remapDlg = new GuiImage(ResourceLoader.getResource("data/ui/common/dialog.png", ResourceLoader.getImage, this.imageResources).toTile());
|
var arial14fontdata = ResourceLoader.getFileEntry("data/font/Arial Bold.fnt");
|
||||||
|
var arial14b = new BitmapFont(arial14fontdata.entry);
|
||||||
|
@:privateAccess arial14b.loader = ResourceLoader.loader;
|
||||||
|
var arial14 = arial14b.toSdfFont(cast 21 * Settings.uiScale, h2d.Font.SDFChannel.MultiChannel);
|
||||||
|
|
||||||
|
var remapDlg = new GuiImage(ResourceLoader.getResource("data/ui/xbox/popupGUI.png", ResourceLoader.getImage, this.imageResources).toTile());
|
||||||
remapDlg.horizSizing = Center;
|
remapDlg.horizSizing = Center;
|
||||||
remapDlg.vertSizing = Center;
|
remapDlg.vertSizing = Center;
|
||||||
remapDlg.position = new Vector(170, 159);
|
remapDlg.position = new Vector(70, 30);
|
||||||
remapDlg.extent = new Vector(300, 161);
|
remapDlg.extent = new Vector(512, 400);
|
||||||
this.addChild(remapDlg);
|
this.addChild(remapDlg);
|
||||||
|
|
||||||
var domcasual24fontdata = ResourceLoader.getFileEntry("data/font/DomCasualD.fnt");
|
var remapText = new GuiMLText(arial14, null);
|
||||||
var domcasual24b = new BitmapFont(domcasual24fontdata.entry);
|
remapText.position = new Vector(103, 85);
|
||||||
@:privateAccess domcasual24b.loader = ResourceLoader.loader;
|
remapText.extent = new Vector(313, 186);
|
||||||
|
remapText.text.textColor = 0xEBEBEB;
|
||||||
var domcasual24 = domcasual24b.toSdfFont(cast 20 * Settings.uiScale, MultiChannel);
|
|
||||||
|
|
||||||
var remapText = new GuiMLText(domcasual24, null);
|
|
||||||
remapText.horizSizing = Center;
|
|
||||||
remapText.vertSizing = Bottom;
|
|
||||||
remapText.position = new Vector(46, 60);
|
|
||||||
remapText.extent = new Vector(213, 23);
|
|
||||||
remapText.text.textColor = 0;
|
|
||||||
remapText.text.text = '<p align="center">Press a new key or button for <br/>"${bindingName}"</p>';
|
remapText.text.text = '<p align="center">Press a new key or button for <br/>"${bindingName}"</p>';
|
||||||
remapDlg.addChild(remapText);
|
remapDlg.addChild(remapText);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,50 +11,64 @@ import src.Settings;
|
||||||
import src.Util;
|
import src.Util;
|
||||||
|
|
||||||
class TouchCtrlsEditGui extends GuiImage {
|
class TouchCtrlsEditGui extends GuiImage {
|
||||||
public function new() {
|
var innerCtrl:GuiControl;
|
||||||
function chooseBg() {
|
|
||||||
var rand = Math.random();
|
public function new(paused:Bool) {
|
||||||
if (rand >= 0 && rand <= 0.244)
|
var res = ResourceLoader.getImage("data/ui/xbox/BG_fadeOutSoftEdge.png").resource.toTile();
|
||||||
return ResourceLoader.getImage('data/ui/backgrounds/gold/${cast (Math.floor(Util.lerp(1, 12, Math.random())), Int)}.jpg');
|
super(res);
|
||||||
if (rand > 0.244 && rand <= 0.816)
|
|
||||||
return ResourceLoader.getImage('data/ui/backgrounds/platinum/${cast (Math.floor(Util.lerp(1, 28, Math.random())), Int)}.jpg');
|
|
||||||
return ResourceLoader.getImage('data/ui/backgrounds/ultra/${cast (Math.floor(Util.lerp(1, 9, Math.random())), Int)}.jpg');
|
|
||||||
}
|
|
||||||
var img = chooseBg();
|
|
||||||
super(img.resource.toTile());
|
|
||||||
this.horizSizing = Width;
|
this.horizSizing = Width;
|
||||||
this.vertSizing = Height;
|
this.vertSizing = Height;
|
||||||
this.position = new Vector();
|
this.position = new Vector();
|
||||||
this.extent = new Vector(640, 480);
|
this.extent = new Vector(640, 480);
|
||||||
|
|
||||||
function loadButtonImages(path:String) {
|
var scene2d = MarbleGame.canvas.scene2d;
|
||||||
var normal = ResourceLoader.getResource('${path}_n.png', ResourceLoader.getImage, this.imageResources).toTile();
|
|
||||||
var hover = ResourceLoader.getResource('${path}_h.png', ResourceLoader.getImage, this.imageResources).toTile();
|
|
||||||
var pressed = ResourceLoader.getResource('${path}_d.png', ResourceLoader.getImage, this.imageResources).toTile();
|
|
||||||
return [normal, hover, pressed];
|
|
||||||
}
|
|
||||||
|
|
||||||
var domcasual32fontdata = ResourceLoader.getFileEntry("data/font/DomCasualD.fnt");
|
var offsetX = (scene2d.width - 1280) / 2;
|
||||||
var domcasual32b = new BitmapFont(domcasual32fontdata.entry);
|
var offsetY = (scene2d.height - 720) / 2;
|
||||||
@:privateAccess domcasual32b.loader = ResourceLoader.loader;
|
|
||||||
var domcasual32 = domcasual32b.toSdfFont(cast 26 * Settings.uiScale, MultiChannel);
|
|
||||||
|
|
||||||
var mainMenuButton = new GuiButton(loadButtonImages("data/ui/menu/options"));
|
var subX = 640 - (scene2d.width - offsetX) * 640 / scene2d.width;
|
||||||
mainMenuButton.position = new Vector(380, 15);
|
var subY = 480 - (scene2d.height - offsetY) * 480 / scene2d.height;
|
||||||
mainMenuButton.extent = new Vector(247, 164);
|
|
||||||
mainMenuButton.horizSizing = Left;
|
|
||||||
mainMenuButton.vertSizing = Bottom;
|
|
||||||
mainMenuButton.pressedAction = (sender) -> {
|
|
||||||
MarbleGame.canvas.setContent(new OptionsDlg());
|
|
||||||
}
|
|
||||||
|
|
||||||
var touchControlsTxt = new GuiText(domcasual32);
|
innerCtrl = new GuiControl();
|
||||||
touchControlsTxt.position = new Vector(350, 415);
|
innerCtrl.position = new Vector(offsetX, offsetY);
|
||||||
touchControlsTxt.extent = new Vector(121, 53);
|
innerCtrl.extent = new Vector(640 - subX, 480 - subY);
|
||||||
touchControlsTxt.text.text = "Edit Touch Controls";
|
innerCtrl.horizSizing = Width;
|
||||||
touchControlsTxt.horizSizing = Center;
|
innerCtrl.vertSizing = Height;
|
||||||
touchControlsTxt.vertSizing = Top;
|
this.addChild(innerCtrl);
|
||||||
touchControlsTxt.text.textColor = 0;
|
|
||||||
|
var coliseumfontdata = ResourceLoader.getFileEntry("data/font/ColiseumRR.fnt");
|
||||||
|
var coliseumb = new BitmapFont(coliseumfontdata.entry);
|
||||||
|
@:privateAccess coliseumb.loader = ResourceLoader.loader;
|
||||||
|
var coliseum = coliseumb.toSdfFont(cast 44 * Settings.uiScale, MultiChannel);
|
||||||
|
|
||||||
|
var rootTitle = new GuiText(coliseum);
|
||||||
|
rootTitle.position = new Vector(100, 30);
|
||||||
|
rootTitle.extent = new Vector(1120, 80);
|
||||||
|
rootTitle.text.textColor = 0xFFFFFF;
|
||||||
|
rootTitle.text.text = "TOUCH CONTROLS";
|
||||||
|
rootTitle.text.alpha = 0.5;
|
||||||
|
innerCtrl.addChild(rootTitle);
|
||||||
|
|
||||||
|
var bottomBar = new GuiControl();
|
||||||
|
bottomBar.position = new Vector(0, 590);
|
||||||
|
bottomBar.extent = new Vector(640, 200);
|
||||||
|
bottomBar.horizSizing = Width;
|
||||||
|
bottomBar.vertSizing = Bottom;
|
||||||
|
innerCtrl.addChild(bottomBar);
|
||||||
|
|
||||||
|
var nextButton = new GuiXboxButton("Save", 160);
|
||||||
|
nextButton.position = new Vector(960, 100);
|
||||||
|
nextButton.vertSizing = Bottom;
|
||||||
|
nextButton.horizSizing = Right;
|
||||||
|
nextButton.pressedAction = (e) -> {
|
||||||
|
if (paused) {
|
||||||
|
MarbleGame.canvas.popDialog(this);
|
||||||
|
MarbleGame.canvas.pushDialog(new OptionsListGui(true));
|
||||||
|
} else {
|
||||||
|
MarbleGame.canvas.setContent(new OptionsListGui());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
innerCtrl.addChild(nextButton);
|
||||||
|
|
||||||
var joystick = new MovementInputEdit();
|
var joystick = new MovementInputEdit();
|
||||||
|
|
||||||
|
|
@ -135,12 +149,22 @@ class TouchCtrlsEditGui extends GuiImage {
|
||||||
Settings.touchSettings.joystickSize = rvalue;
|
Settings.touchSettings.joystickSize = rvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addChild(mainMenuButton);
|
|
||||||
this.addChild(touchControlsTxt);
|
|
||||||
this.addChild(joystick);
|
this.addChild(joystick);
|
||||||
this.addChild(jumpBtn);
|
this.addChild(jumpBtn);
|
||||||
this.addChild(powerupBtn);
|
this.addChild(powerupBtn);
|
||||||
this.addChild(blastBtn);
|
this.addChild(blastBtn);
|
||||||
this.addChild(rewindBtn);
|
this.addChild(rewindBtn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue