accelerator keys

This commit is contained in:
RandomityGuy 2022-12-17 14:24:51 +05:30
parent 375d22650f
commit 57175a413c
7 changed files with 17 additions and 0 deletions

View file

@ -44,6 +44,7 @@ class EndGameGui extends GuiControl {
continueButton.vertSizing = Bottom;
continueButton.position = new Vector(460, 307);
continueButton.extent = new Vector(104, 54);
continueButton.accelerator = hxd.Key.ENTER;
continueButton.pressedAction = (e) -> continueFunc(continueButton);
var restartButton = new GuiButton(loadButtonImages("data/ui/endgame/replay"));

View file

@ -40,6 +40,7 @@ class ExitGameDlg extends GuiControl {
yesButton.extent = new Vector(86, 40);
yesButton.vertSizing = Top;
yesButton.horizSizing = Right;
yesButton.accelerator = hxd.Key.ENTER;
yesButton.pressedAction = (sender) -> yesFunc(yesButton);
var noButton = new GuiButton(loadButtonImages("data/ui/common/no"));
@ -47,6 +48,7 @@ class ExitGameDlg extends GuiControl {
noButton.extent = new Vector(86, 40);
noButton.vertSizing = Top;
noButton.horizSizing = Right;
noButton.accelerator = hxd.Key.ESCAPE;
noButton.pressedAction = (sender) -> noFunc(noButton);
var restartButton = new GuiButton(loadButtonImages("data/ui/common/restart"));

View file

@ -27,6 +27,8 @@ class GuiButton extends GuiAnim {
public var buttonSounds:Bool = true;
public var accelerator:Int = 0;
public function new(anim:Array<Tile>) {
super(anim);
}
@ -67,6 +69,11 @@ class GuiButton extends GuiAnim {
}
}
}
if (!disabled && accelerator != 0 && hxd.Key.isReleased(accelerator)) {
if (this.pressedAction != null) {
this.pressedAction(new GuiEvent(this));
}
}
super.update(dt, mouseState);
}

View file

@ -47,6 +47,7 @@ class HelpCreditsGui extends GuiImage {
var homeButton = new GuiButton(loadButtonImages("data/ui/manual/home"));
homeButton.position = new Vector(274, 385);
homeButton.extent = new Vector(94, 46);
homeButton.accelerator = hxd.Key.ESCAPE;
homeButton.pressedAction = (sender) -> {
MarbleGame.canvas.setContent(new MainMenuGui());
}

View file

@ -46,6 +46,7 @@ class MessageBoxOkDlg extends GuiControl {
okButton.position = new Vector(117, 85);
okButton.extent = new Vector(88, 41);
okButton.vertSizing = Top;
okButton.accelerator = hxd.Key.ENTER;
okButton.pressedAction = (sender) -> {
MarbleGame.canvas.popDialog(this);
}

View file

@ -46,6 +46,7 @@ class MessageBoxYesNoDlg extends GuiControl {
yesButton.position = new Vector(44, 94);
yesButton.extent = new Vector(82, 35);
yesButton.vertSizing = Top;
yesButton.accelerator = hxd.Key.ENTER;
yesButton.pressedAction = (sender) -> {
MarbleGame.canvas.popDialog(this);
yesFunc();
@ -56,6 +57,7 @@ class MessageBoxYesNoDlg extends GuiControl {
noButton.position = new Vector(151, 94);
noButton.extent = new Vector(75, 35);
noButton.vertSizing = Top;
noButton.accelerator = hxd.Key.ESCAPE;
noButton.pressedAction = (sender) -> {
MarbleGame.canvas.popDialog(this);
noFunc();

View file

@ -173,6 +173,7 @@ class PlayMissionGui extends GuiImage {
var pmMenuButton = new GuiButton(loadButtonImages("data/ui/play/menu"));
pmMenuButton.position = new Vector(119, 325);
pmMenuButton.extent = new Vector(92, 43);
pmMenuButton.accelerator = hxd.Key.ESCAPE;
pmMenuButton.pressedAction = (sender) -> {
cast(this.parent, Canvas).setContent(new MainMenuGui());
};
@ -199,6 +200,7 @@ class PlayMissionGui extends GuiImage {
var pmPrev = new GuiButton(loadButtonImages("data/ui/play/prev"));
pmPrev.position = new Vector(436, 325);
pmPrev.extent = new Vector(72, 43);
pmPrev.accelerator = hxd.Key.LEFT;
pmPrev.pressedAction = (sender) -> {
setSelectedFunc(currentSelection - 1);
}
@ -220,6 +222,7 @@ class PlayMissionGui extends GuiImage {
var pmNext = new GuiButton(loadButtonImages("data/ui/play/next"));
pmNext.position = new Vector(604, 325);
pmNext.extent = new Vector(72, 43);
pmNext.accelerator = hxd.Key.RIGHT;
pmNext.pressedAction = (sender) -> {
setSelectedFunc(currentSelection + 1);
}