mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-16 13:22:18 +02:00
fix device specific ui
This commit is contained in:
parent
34f19cec04
commit
f9b953ef93
@ -85,37 +85,9 @@ export default abstract class AbstractBindingUiHandler extends UiHandler {
|
|||||||
this.optionSelectBg.setOrigin(0.5);
|
this.optionSelectBg.setOrigin(0.5);
|
||||||
this.optionSelectContainer.add(this.optionSelectBg);
|
this.optionSelectContainer.add(this.optionSelectBg);
|
||||||
|
|
||||||
// New button icon setup.
|
|
||||||
this.newButtonIcon = this.scene.add.sprite(0, 0, 'keyboard');
|
|
||||||
this.newButtonIcon.setScale(0.15);
|
|
||||||
this.newButtonIcon.setPositionRelative(this.optionSelectBg, 78, 16);
|
|
||||||
this.newButtonIcon.setOrigin(0.5);
|
|
||||||
this.newButtonIcon.setVisible(false);
|
|
||||||
|
|
||||||
this.swapText = addTextObject(this.scene, 0, 0, 'will swap with', TextStyle.WINDOW);
|
|
||||||
this.swapText.setOrigin(0.5);
|
|
||||||
this.swapText.setPositionRelative(this.optionSelectBg, this.optionSelectBg.width / 2 - 2, this.optionSelectBg.height / 2 - 2);
|
|
||||||
this.swapText.setVisible(false);
|
|
||||||
|
|
||||||
this.targetButtonIcon = this.scene.add.sprite(0, 0, 'keyboard');
|
|
||||||
this.targetButtonIcon.setScale(0.15);
|
|
||||||
this.targetButtonIcon.setPositionRelative(this.optionSelectBg, 78, 48);
|
|
||||||
this.targetButtonIcon.setOrigin(0.5);
|
|
||||||
this.targetButtonIcon.setVisible(false);
|
|
||||||
|
|
||||||
this.cancelLabel = addTextObject(this.scene, 0, 0, 'Cancel', TextStyle.SETTINGS_LABEL);
|
this.cancelLabel = addTextObject(this.scene, 0, 0, 'Cancel', TextStyle.SETTINGS_LABEL);
|
||||||
this.cancelLabel.setOrigin(0, 0.5);
|
this.cancelLabel.setOrigin(0, 0.5);
|
||||||
this.cancelLabel.setPositionRelative(this.actionBg, 10, this.actionBg.height / 2);
|
this.cancelLabel.setPositionRelative(this.actionBg, 10, this.actionBg.height / 2);
|
||||||
|
|
||||||
this.actionLabel = addTextObject(this.scene, 0, 0, this.confirmText, TextStyle.SETTINGS_LABEL);
|
|
||||||
this.actionLabel.setOrigin(0, 0.5);
|
|
||||||
this.actionLabel.setPositionRelative(this.actionBg, this.actionBg.width - 75, this.actionBg.height / 2);
|
|
||||||
|
|
||||||
// Add swap and cancel labels to the containers.
|
|
||||||
this.optionSelectContainer.add(this.newButtonIcon);
|
|
||||||
this.optionSelectContainer.add(this.swapText);
|
|
||||||
this.optionSelectContainer.add(this.targetButtonIcon);
|
|
||||||
this.actionsContainer.add(this.actionLabel);
|
|
||||||
this.actionsContainer.add(this.cancelLabel);
|
this.actionsContainer.add(this.cancelLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,8 +200,6 @@ export default abstract class AbstractBindingUiHandler extends UiHandler {
|
|||||||
this.optionSelectContainer.setVisible(false);
|
this.optionSelectContainer.setVisible(false);
|
||||||
this.actionsContainer.setVisible(false);
|
this.actionsContainer.setVisible(false);
|
||||||
this.newButtonIcon.setVisible(false);
|
this.newButtonIcon.setVisible(false);
|
||||||
this.targetButtonIcon.setVisible(false);
|
|
||||||
this.swapText.setVisible(false);
|
|
||||||
this.buttonPressed = null;
|
this.buttonPressed = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import AbstractBindingUiHandler from "../settings/abrast-binding-ui-handler";
|
|||||||
import {Mode} from "../ui";
|
import {Mode} from "../ui";
|
||||||
import {Device} from "#app/enums/devices";
|
import {Device} from "#app/enums/devices";
|
||||||
import {getIconWithSettingName, getKeyWithKeycode} from "#app/configs/configHandler";
|
import {getIconWithSettingName, getKeyWithKeycode} from "#app/configs/configHandler";
|
||||||
|
import {addTextObject, TextStyle} from "#app/ui/text";
|
||||||
|
|
||||||
|
|
||||||
export default class GamepadBindingUiHandler extends AbstractBindingUiHandler {
|
export default class GamepadBindingUiHandler extends AbstractBindingUiHandler {
|
||||||
@ -10,7 +11,36 @@ export default class GamepadBindingUiHandler extends AbstractBindingUiHandler {
|
|||||||
constructor(scene: BattleScene, mode: Mode) {
|
constructor(scene: BattleScene, mode: Mode) {
|
||||||
super(scene, mode);
|
super(scene, mode);
|
||||||
this.scene.input.gamepad.on('down', this.gamepadButtonDown, this);
|
this.scene.input.gamepad.on('down', this.gamepadButtonDown, this);
|
||||||
this.confirmText = "Confirm swap";
|
}
|
||||||
|
setup() {
|
||||||
|
super.setup();
|
||||||
|
|
||||||
|
// New button icon setup.
|
||||||
|
this.newButtonIcon = this.scene.add.sprite(0, 0, 'xbox');
|
||||||
|
this.newButtonIcon.setScale(0.15);
|
||||||
|
this.newButtonIcon.setPositionRelative(this.optionSelectBg, 78, 16);
|
||||||
|
this.newButtonIcon.setOrigin(0.5);
|
||||||
|
this.newButtonIcon.setVisible(false);
|
||||||
|
|
||||||
|
this.swapText = addTextObject(this.scene, 0, 0, 'will swap with', TextStyle.WINDOW);
|
||||||
|
this.swapText.setOrigin(0.5);
|
||||||
|
this.swapText.setPositionRelative(this.optionSelectBg, this.optionSelectBg.width / 2 - 2, this.optionSelectBg.height / 2 - 2);
|
||||||
|
this.swapText.setVisible(false);
|
||||||
|
|
||||||
|
this.targetButtonIcon = this.scene.add.sprite(0, 0, 'xbox');
|
||||||
|
this.targetButtonIcon.setScale(0.15);
|
||||||
|
this.targetButtonIcon.setPositionRelative(this.optionSelectBg, 78, 48);
|
||||||
|
this.targetButtonIcon.setOrigin(0.5);
|
||||||
|
this.targetButtonIcon.setVisible(false);
|
||||||
|
|
||||||
|
this.actionLabel = addTextObject(this.scene, 0, 0, "Confirm swap", TextStyle.SETTINGS_LABEL);
|
||||||
|
this.actionLabel.setOrigin(0, 0.5);
|
||||||
|
this.actionLabel.setPositionRelative(this.actionBg, this.actionBg.width - 75, this.actionBg.height / 2);
|
||||||
|
this.actionsContainer.add(this.actionLabel);
|
||||||
|
|
||||||
|
this.optionSelectContainer.add(this.newButtonIcon);
|
||||||
|
this.optionSelectContainer.add(this.swapText);
|
||||||
|
this.optionSelectContainer.add(this.targetButtonIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
getSelectedDevice() {
|
getSelectedDevice() {
|
||||||
@ -39,4 +69,13 @@ export default class GamepadBindingUiHandler extends AbstractBindingUiHandler {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the UI elements and state.
|
||||||
|
*/
|
||||||
|
clear() {
|
||||||
|
super.clear();
|
||||||
|
this.targetButtonIcon.setVisible(false);
|
||||||
|
this.swapText.setVisible(false);
|
||||||
|
}
|
||||||
}
|
}
|
@ -3,6 +3,7 @@ import AbstractBindingUiHandler from "../settings/abrast-binding-ui-handler";
|
|||||||
import {Mode} from "../ui";
|
import {Mode} from "../ui";
|
||||||
import { getIconWithSettingName, getKeyWithKeycode} from "#app/configs/configHandler";
|
import { getIconWithSettingName, getKeyWithKeycode} from "#app/configs/configHandler";
|
||||||
import {Device} from "#app/enums/devices";
|
import {Device} from "#app/enums/devices";
|
||||||
|
import {addTextObject, TextStyle} from "#app/ui/text";
|
||||||
|
|
||||||
|
|
||||||
export default class KeyboardBindingUiHandler extends AbstractBindingUiHandler {
|
export default class KeyboardBindingUiHandler extends AbstractBindingUiHandler {
|
||||||
@ -13,6 +14,23 @@ export default class KeyboardBindingUiHandler extends AbstractBindingUiHandler {
|
|||||||
scene.input.keyboard.on('keydown', this.onKeyDown, this);
|
scene.input.keyboard.on('keydown', this.onKeyDown, this);
|
||||||
this.confirmText = "Confirm";
|
this.confirmText = "Confirm";
|
||||||
}
|
}
|
||||||
|
setup() {
|
||||||
|
super.setup();
|
||||||
|
|
||||||
|
// New button icon setup.
|
||||||
|
this.newButtonIcon = this.scene.add.sprite(0, 0, 'keyboard');
|
||||||
|
this.newButtonIcon.setScale(0.15);
|
||||||
|
this.newButtonIcon.setPositionRelative(this.optionSelectBg, 78, 32);
|
||||||
|
this.newButtonIcon.setOrigin(0.5);
|
||||||
|
this.newButtonIcon.setVisible(false);
|
||||||
|
|
||||||
|
this.actionLabel = addTextObject(this.scene, 0, 0, "Assign button", TextStyle.SETTINGS_LABEL);
|
||||||
|
this.actionLabel.setOrigin(0, 0.5);
|
||||||
|
this.actionLabel.setPositionRelative(this.actionBg, this.actionBg.width - 80, this.actionBg.height / 2);
|
||||||
|
this.actionsContainer.add(this.actionLabel);
|
||||||
|
|
||||||
|
this.optionSelectContainer.add(this.newButtonIcon);
|
||||||
|
}
|
||||||
|
|
||||||
getSelectedDevice() {
|
getSelectedDevice() {
|
||||||
return this.scene.inputController?.selectedDevice[Device.KEYBOARD];
|
return this.scene.inputController?.selectedDevice[Device.KEYBOARD];
|
||||||
|
Loading…
Reference in New Issue
Block a user