PIXI Controls: Fix defautls restoration
This commit is contained in:
parent
57ffea9478
commit
18e9ef4914
1 changed files with 36 additions and 27 deletions
|
@ -335,11 +335,7 @@ ONSControls.clearInteractive = function() {
|
||||||
elem.removeAllListeners();
|
elem.removeAllListeners();
|
||||||
}
|
}
|
||||||
// Clear status of VirtualGamepad
|
// Clear status of VirtualGamepad
|
||||||
for (button of VirtualGamepad.gamepad.buttons) {
|
VirtualGamepad.clearState();
|
||||||
button.pressed = false;
|
|
||||||
button.touched = false;
|
|
||||||
button.value = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// * Setup drag'n drop events for element
|
// * Setup drag'n drop events for element
|
||||||
|
@ -492,6 +488,16 @@ VirtualGamepad.disconnect = function () {
|
||||||
//VirtualGamepad.originalNavigator.getGamepads.call();
|
//VirtualGamepad.originalNavigator.getGamepads.call();
|
||||||
console.log(`ONSControls: Virtual gamepad disconnected with index ${this.gamepad.index}`);
|
console.log(`ONSControls: Virtual gamepad disconnected with index ${this.gamepad.index}`);
|
||||||
}
|
}
|
||||||
|
//=============================================================================
|
||||||
|
// * Clear state of all buttons
|
||||||
|
//=============================================================================
|
||||||
|
VirtualGamepad.clearState = function() {
|
||||||
|
for (button of VirtualGamepad.gamepad.buttons) {
|
||||||
|
button.pressed = false;
|
||||||
|
button.touched = false;
|
||||||
|
button.value = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -532,32 +538,35 @@ ConfigManager.ONSConfig.showY ||= ONSControls._controlsCanvas.screen.height - (C
|
||||||
var _ConfigManager_restoreDefaultConfig = ConfigManager.restoreDefaultConfig;
|
var _ConfigManager_restoreDefaultConfig = ConfigManager.restoreDefaultConfig;
|
||||||
ConfigManager.restoreDefaultConfig = function () {
|
ConfigManager.restoreDefaultConfig = function () {
|
||||||
_ConfigManager_restoreDefaultConfig.apply(this, arguments);
|
_ConfigManager_restoreDefaultConfig.apply(this, arguments);
|
||||||
const fs = require("fs");j
|
const fs = require("fs");
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
var base = path.dirname(process.mainModule.filename);
|
var base = path.dirname(process.mainModule.filename);
|
||||||
base = path.join(base, 'save/');
|
base = path.join(base, 'save/');
|
||||||
if (fs.existsSync(base + "config.rpgsave")) { fs.unlinkSync(base + "config.rpgsave"); }
|
if (fs.existsSync(base + "config.rpgsave")) { fs.unlinkSync(base + "config.rpgsave"); }
|
||||||
ConfigManager.ONSConfig.buttonsScale = this.options.buttonsScale;
|
this.ONSConfig.buttonsScale = ONSControls.options.buttonsScale;
|
||||||
ConfigManager.ONSConfig.buttonsOpacity = this.options.buttonsOpacity;
|
this.ONSConfig.buttonsOpacity = ONSControls.options.buttonsOpacity;
|
||||||
ConfigManager.ONSConfig.safeArea = ONSControls._controlsCanvas.vh(0.032);
|
this.ONSConfig.safeArea = ONSControls._controlsCanvas.vh(0.032);
|
||||||
ConfigManager.ONSConfig.buttonsSize = ONSControls._controlsCanvas.vh(0.18) * ConfigManager.ONSConfig.buttonsScale;
|
this.ONSConfig.buttonsSize = ONSControls._controlsCanvas.vh(0.18) * this.ONSConfig.buttonsScale;
|
||||||
ConfigManager.ONSConfig.buttonsX = ONSControls._controlsCanvas.screen.width - (ConfigManager.ONSConfig.buttonsSize + ConfigManager.ONSConfig.safeArea);
|
this.ONSConfig.buttonsX = ONSControls._controlsCanvas.screen.width - (this.ONSConfig.buttonsSize + this.ONSConfig.safeArea);
|
||||||
ConfigManager.ONSConfig.buttonsY = ONSControls._controlsCanvas.screen.height - (ConfigManager.ONSConfig.buttonsSize + ConfigManager.ONSConfig.safeArea);
|
this.ONSConfig.buttonsY = ONSControls._controlsCanvas.screen.height - (this.ONSConfig.buttonsSize + this.ONSConfig.safeArea);
|
||||||
ConfigManager.ONSConfig.dPadSize = ONSControls._controlsCanvas.vh(0.36) * ConfigManager.ONSConfig.buttonsScale;
|
this.ONSConfig.dPadSize = ONSControls._controlsCanvas.vh(0.36) * this.ONSConfig.buttonsScale;
|
||||||
ConfigManager.ONSConfig.dPadX = ConfigManager.ONSConfig.dPadSize / 2 + ConfigManager.ONSConfig.safeArea;
|
this.ONSConfig.dPadX = this.ONSConfig.dPadSize / 2 + this.ONSConfig.safeArea;
|
||||||
ConfigManager.ONSConfig.dPadY = ONSControls._controlsCanvas.screen.height - (ConfigManager.ONSConfig.dPadSize / 2 + ConfigManager.ONSConfig.safeArea);
|
this.ONSConfig.dPadY = ONSControls._controlsCanvas.screen.height - (this.ONSConfig.dPadSize / 2 + this.ONSConfig.safeArea);
|
||||||
ConfigManager.ONSConfig.bumpersOffsetX = 16;
|
this.ONSConfig.bumpersOffsetX = 16;
|
||||||
ConfigManager.ONSConfig.bumpersOffsetY = ONSControls._controlsCanvas.vh(0.30);
|
this.ONSConfig.bumpersOffsetY = ONSControls._controlsCanvas.vh(0.30);
|
||||||
ConfigManager.ONSConfig.bumpersWidth = ONSControls._controlsCanvas.vh(0.188) * ConfigManager.ONSConfig.buttonsScale;
|
this.ONSConfig.bumpersWidth = ONSControls._controlsCanvas.vh(0.188) * this.ONSConfig.buttonsScale;
|
||||||
ConfigManager.ONSConfig.bumpersHeight = ONSControls._controlsCanvas.vh(0.12) * ConfigManager.ONSConfig.buttonsScale;
|
this.ONSConfig.bumpersHeight = ONSControls._controlsCanvas.vh(0.12) * this.ONSConfig.buttonsScale;
|
||||||
ConfigManager.ONSConfig.LBX = ConfigManager.ONSConfig.bumpersOffsetX + ConfigManager.ONSConfig.safeArea + ConfigManager.ONSConfig.bumpersWidth / 2;
|
this.ONSConfig.LBX = this.ONSConfig.bumpersOffsetX + this.ONSConfig.safeArea + this.ONSConfig.bumpersWidth / 2;
|
||||||
ConfigManager.ONSConfig.LBY = (ConfigManager.ONSConfig.bumpersOffsetY + ConfigManager.ONSConfig.safeArea + ConfigManager.ONSConfig.bumpersHeight / 2);
|
this.ONSConfig.LBY = (this.ONSConfig.bumpersOffsetY + this.ONSConfig.safeArea + this.ONSConfig.bumpersHeight / 2);
|
||||||
ConfigManager.ONSConfig.RBX = ONSControls._controlsCanvas.screen.width - (ConfigManager.ONSConfig.safeArea + ConfigManager.ONSConfig.bumpersOffsetX + ConfigManager.ONSConfig.bumpersWidth / 2);
|
this.ONSConfig.RBX = ONSControls._controlsCanvas.screen.width - (this.ONSConfig.safeArea + this.ONSConfig.bumpersOffsetX + this.ONSConfig.bumpersWidth / 2);
|
||||||
ConfigManager.ONSConfig.RBY = (ConfigManager.ONSConfig.bumpersOffsetY + ConfigManager.ONSConfig.safeArea + ConfigManager.ONSConfig.bumpersHeight / 2);ConfigManager.ONSConfig.additionalOffset = ONSControls._controlsCanvas.vh(0.03);
|
this.ONSConfig.RBY = (this.ONSConfig.bumpersOffsetY + this.ONSConfig.safeArea + this.ONSConfig.bumpersHeight / 2);
|
||||||
ConfigManager.ONSConfig.additonalSize = ONSControls._controlsCanvas.vh(0.06) * ConfigManager.ONSConfig.buttonsScale;
|
this.ONSConfig.additionalOffset = ONSControls._controlsCanvas.vh(0.03);
|
||||||
ConfigManager.ONSConfig.showX = ONSControls._controlsCanvas.screen.width - (ConfigManager.ONSConfig.additonalSize / 2 + ConfigManager.ONSConfig.safeArea);
|
this.ONSConfig.additonalSize = ONSControls._controlsCanvas.vh(0.06) * this.ONSConfig.buttonsScale;
|
||||||
ConfigManager.ONSConfig.showY = ONSControls._controlsCanvas.screen.height - (ConfigManager.ONSConfig.additonalSize / 2 + ConfigManager.ONSConfig.safeArea);
|
this.ONSConfig.showX = ONSControls._controlsCanvas.screen.width - (this.ONSConfig.additonalSize / 2 + this.ONSConfig.safeArea);
|
||||||
ConfigManager.applyData(ConfigManager);
|
this.ONSConfig.showY = ONSControls._controlsCanvas.screen.height - (this.ONSConfig.additonalSize / 2 + this.ONSConfig.safeArea);
|
||||||
|
this.applyData(ConfigManager);
|
||||||
|
this.ONSConfig.updateData();
|
||||||
|
VirtualGamepad.clearState();
|
||||||
let needsRestore = confirm(LanguageManager.languageData().text.System.plugins.optionsMenu.alertMessages["restoreGeneral"]);
|
let needsRestore = confirm(LanguageManager.languageData().text.System.plugins.optionsMenu.alertMessages["restoreGeneral"]);
|
||||||
if (!!needsRestore) { DataManager._restoreGlobalInfo(); }
|
if (!!needsRestore) { DataManager._restoreGlobalInfo(); }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue