mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-06 00:12:16 +02:00
remove Plugins things as it's too uncertain how it works on prod
This commit is contained in:
parent
f47b650a76
commit
e18a4f3d16
@ -84,6 +84,8 @@ export type AnySound = Phaser.Sound.WebAudioSound | Phaser.Sound.HTML5AudioSound
|
||||
|
||||
export default class BattleScene extends SceneBase {
|
||||
public rexUI: UIPlugin;
|
||||
public inputController: InputsController;
|
||||
public uiInputs: UiInputs;
|
||||
|
||||
public sessionPlayTime: integer = null;
|
||||
public masterVolume: number = 0.5;
|
||||
@ -176,7 +178,6 @@ export default class BattleScene extends SceneBase {
|
||||
|
||||
constructor() {
|
||||
super('battle');
|
||||
Phaser.Plugins.PluginCache.register('UiInputs', UiInputs, 'uiInputs');
|
||||
|
||||
initSpecies();
|
||||
initMoves();
|
||||
@ -221,6 +222,8 @@ export default class BattleScene extends SceneBase {
|
||||
|
||||
create() {
|
||||
initGameSpeed.apply(this);
|
||||
this.inputController = new InputsController(this);
|
||||
this.uiInputs = new UiInputs(this, this.inputController);
|
||||
|
||||
this.gameData = new GameData(this);
|
||||
|
||||
@ -238,6 +241,7 @@ export default class BattleScene extends SceneBase {
|
||||
}
|
||||
|
||||
update() {
|
||||
this.inputController.update();
|
||||
this.ui?.update();
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,7 @@ export enum Button {
|
||||
|
||||
const repeatInputDelayMillis = 250;
|
||||
|
||||
export class InputsController extends Phaser.Plugins.ScenePlugin {
|
||||
private game: Phaser.Game;
|
||||
export class InputsController {
|
||||
private buttonKeys: Phaser.Input.Keyboard.Key[][];
|
||||
private gamepads: Array<string> = new Array();
|
||||
private scene: Phaser.Scene;
|
||||
@ -41,9 +40,7 @@ export class InputsController extends Phaser.Plugins.ScenePlugin {
|
||||
private interactions: Map<Button, Map<string, boolean>> = new Map();
|
||||
private time: Time;
|
||||
|
||||
constructor(scene: Phaser.Scene, pluginManager: Phaser.Plugins.PluginManager, pluginKey: string) {
|
||||
super(scene, pluginManager, pluginKey);
|
||||
this.game = pluginManager.game;
|
||||
constructor(scene: Phaser.Scene) {
|
||||
this.scene = scene;
|
||||
this.time = this.scene.time;
|
||||
this.buttonKeys = [];
|
||||
@ -56,30 +53,29 @@ export class InputsController extends Phaser.Plugins.ScenePlugin {
|
||||
}
|
||||
// We don't want the menu key to be repeated
|
||||
delete this.interactions[Button.MENU];
|
||||
this.init();
|
||||
}
|
||||
|
||||
boot() {
|
||||
this.eventEmitter = this.systems.events;
|
||||
init() {
|
||||
this.events = new Phaser.Events.EventEmitter();
|
||||
this.game.events.on(Phaser.Core.Events.STEP, this.update, this);
|
||||
|
||||
if (typeof this.systems.input.gamepad !== 'undefined') {
|
||||
this.systems.input.gamepad.on('connected', function (thisGamepad) {
|
||||
if (typeof this.scene.input.gamepad !== 'undefined') {
|
||||
this.scene.input.gamepad.on('connected', function (thisGamepad) {
|
||||
this.refreshGamepads();
|
||||
this.setupGamepad(thisGamepad);
|
||||
}, this);
|
||||
|
||||
// Check to see if the gamepad has already been setup by the browser
|
||||
this.systems.input.gamepad.refreshPads();
|
||||
if (this.systems.input.gamepad.total) {
|
||||
this.scene.input.gamepad.refreshPads();
|
||||
if (this.scene.input.gamepad.total) {
|
||||
this.refreshGamepads();
|
||||
for (const thisGamepad of this.gamepads) {
|
||||
this.systems.input.gamepad.emit('connected', thisGamepad);
|
||||
this.scene.input.gamepad.emit('connected', thisGamepad);
|
||||
}
|
||||
}
|
||||
|
||||
this.systems.input.gamepad.on('down', this.gamepadButtonDown, this);
|
||||
this.systems.input.gamepad.on('up', this.gamepadButtonUp, this);
|
||||
this.scene.input.gamepad.on('down', this.gamepadButtonDown, this);
|
||||
this.scene.input.gamepad.on('up', this.gamepadButtonUp, this);
|
||||
}
|
||||
|
||||
// Keyboard
|
||||
@ -109,7 +105,7 @@ export class InputsController extends Phaser.Plugins.ScenePlugin {
|
||||
|
||||
refreshGamepads(): void {
|
||||
// Sometimes, gamepads are undefined. For some reason.
|
||||
this.gamepads = this.systems.input.gamepad.gamepads.filter(function (el) {
|
||||
this.gamepads = this.scene.input.gamepad.gamepads.filter(function (el) {
|
||||
return el != null;
|
||||
});
|
||||
|
||||
@ -191,7 +187,7 @@ export class InputsController extends Phaser.Plugins.ScenePlugin {
|
||||
const keys: Phaser.Input.Keyboard.Key[] = [];
|
||||
if (keyConfig.hasOwnProperty(b)) {
|
||||
for (let k of keyConfig[b])
|
||||
keys.push(this.systems.input.keyboard.addKey(k, false));
|
||||
keys.push(this.scene.input.keyboard.addKey(k, false));
|
||||
mobileKeyConfig[Button[b]] = keys[0];
|
||||
}
|
||||
this.buttonKeys[b] = keys;
|
||||
|
10
src/main.ts
10
src/main.ts
@ -8,8 +8,6 @@ import InputTextPlugin from 'phaser3-rex-plugins/plugins/inputtext-plugin.js';
|
||||
import BBCodeText from 'phaser3-rex-plugins/plugins/bbcodetext';
|
||||
import TransitionImagePackPlugin from 'phaser3-rex-plugins/templates/transitionimagepack/transitionimagepack-plugin.js';
|
||||
import { LoadingScene } from './loading-scene';
|
||||
import {InputsController} from "#app/inputs-controller";
|
||||
import {UiInputs} from "#app/ui-inputs";
|
||||
|
||||
|
||||
// Catch global errors and display them in an alert so users can report the issue.
|
||||
@ -54,14 +52,6 @@ const config: Phaser.Types.Core.GameConfig = {
|
||||
key: 'rexUI',
|
||||
plugin: UIPlugin,
|
||||
mapping: 'rexUI'
|
||||
}, {
|
||||
key: 'InputsController',
|
||||
plugin: InputsController,
|
||||
mapping: 'inputsController'
|
||||
}, {
|
||||
key: 'UiInputs',
|
||||
plugin: UiInputs,
|
||||
mapping: 'uiInputs'
|
||||
}]
|
||||
},
|
||||
input: {
|
||||
|
@ -1,25 +1,25 @@
|
||||
import Phaser from "phaser";
|
||||
import {Mode} from "./ui/ui";
|
||||
import {Button} from "./inputs-controller";
|
||||
import {Button, InputsController} from "./inputs-controller";
|
||||
import MessageUiHandler from "./ui/message-ui-handler";
|
||||
import StarterSelectUiHandler from "./ui/starter-select-ui-handler";
|
||||
import {Setting, settingOptions} from "./system/settings";
|
||||
import SettingsUiHandler from "./ui/settings-ui-handler";
|
||||
|
||||
|
||||
export class UiInputs extends Phaser.Plugins.ScenePlugin {
|
||||
private game: Phaser.Game;
|
||||
export class UiInputs {
|
||||
private scene: Phaser.Scene;
|
||||
private events;
|
||||
private inputsController;
|
||||
|
||||
constructor(scene: Phaser.Scene, pluginManager: Phaser.Plugins.PluginManager, pluginKey: string) {
|
||||
super(scene, pluginManager, pluginKey);
|
||||
this.game = pluginManager.game;
|
||||
constructor(scene: Phaser.Scene, inputsController: InputsController) {
|
||||
this.scene = scene;
|
||||
this.inputsController = inputsController;
|
||||
this.init();
|
||||
}
|
||||
|
||||
boot() {
|
||||
this.events = this.scene.inputsController.events;
|
||||
init() {
|
||||
this.events = this.inputsController.events;
|
||||
this.listenInputs();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user