/*:
* @plugindesc v2.0.1 Creates buttons on the screen for touch input
* @author Aloe Guvner
*
*
* @param dPadSettings
* @text D-Pad Settings
* @type struct<dpad>
* @desc Settings for the D-Pad.
*
* @param keyButtonSettings
* @text Key Button Settings
* @type struct<keyButton>[]
* @desc Settings for on-screen buttons that simulate key presses.
*
* @param controlButtonSettings
* @text Control Button Settings
* @type struct<controlButton>
* @desc A "toggle" button that allows players to turn the UI
* on and off.
*
* @param fadeDuration
* @text Fade Duration
* @desc Duration of hiding the buttons (number of frames)
* for the buttons to fade and un-fade.
* @default 20
* @type number
*
* @param fadeDelay
* @text Fade Delay
* @desc Delay before hiding and unhiding buttons (number
* of frames)
* @default 1
* @type number
*
* @param disableTouchWindows
* @text Disable Touch Selectable Windows
* @type text[]
* @desc Disable the touch input for selectable windows
* in these scenes.
* @default ["Scene_Menu"]
*
* @param disableTouchMovement
* @text Disable Touch Movement
* @type boolean
* @desc Disable touch movement on the map when a DPad is active.
* @default false
*
* @param enableDiagonalInput
* @text Enable Diagonal Input
* @type boolean
* @desc If the player touches in the corners of the D-Pad, both
* direction inputs are recorded. See info in help file.
* @default false
*
* @param hideButtonsDuringDialogue
* @text Hide Buttons During Dialogue
* @type boolean
* @desc Hide the virtual buttons during event dialogue.
* @default true
*
* @param enableDPadDebugWindow
* @text Enable DPad Debug Window
* @type boolean
* @desc Shows a window with the current D-Pad state. For
* plugin debugging only.
* @default false
*
* @help
*
* //=============================================================================
* // Background:
* //=============================================================================
* This plugin focuses on improving the user interface for mobile games created
* in RPG Maker MV. This plugin allows the developer to have virtual buttons
* on the screen that interact with touch input.
*
* This plugin allows maximum flexibility for the developer, you can add
* as many or as few buttons as you want to the screen, and you can add these buttons
* on whichever screens you would like (i.e. map, menu, credits, title, etc.).
*
* //=============================================================================
* // Functionality:
* //=============================================================================
*
* This plugin can create 3 different types of buttons:
* -Directional Pad
* --A single picture which is used for up, left, right, and down movement.
* --The picture is divided into 9 sections. The top 3 sections trigger the "up"
* input, the left 3 sections trigger the "left" input, the right 3 sections
* trigger the "right" input, and the bottom 3 section triggers the "down" input.
* --The middle section does not trigger any input.
* --The scenes that this button appears in can be defined.
* --This button is not mandatory.
*
* -Key buttons
* --These buttons can be used to represent any key. Common keys to use would be
* "ok" , "escape", "pagedown", "pageup".
* --However, these can be any key, and there can be as many or as few as the developer
* would like.
* --Additionally, the scenes that these buttons appear in can be controlled individually.
*
*
* -Control button
* --The control button, if pressed, will collapse and hide other buttons on the screen.
* --If pressed again, it will expand and show other buttons on the screen.
* --You can configure which other buttons are affected. This can allow you to create
* a dynamic menu where pressing this button opens other buttons for "Items", "Save",
* etc., while leaving the DPad or any other button active all of the time.
* --The scenes that this button appears in can be defined.
* --This button is not mandatory.
*
* //=============================================================================
* // Touch Input Methods:
* //=============================================================================
*
* The following methods can be chosen for any of the key buttons. The default
* method is "triggered".
*
* Triggered:
* This input method occurs when the button is just pressed down. It occurs only
* once, in the same frame that the button was pressed.
*
* Pressed:
* This input method occurs every frame while the button is pressed down. Any action
* that this button is doing will execute every frame (60 frames per second)
*
* Repeated:
* This input method occurs after 24 frames from when the button is pressed, and
* then occurs every 6 frames while the button is still pressed.
*
* Long Pressed:
* This input method occurs after 24 frames from when the button is pressed, and
* then occurs every frame while the button is still pressed.
*
* Released:
* This input method occurs when the button is no longer being pressed.
*
* //=============================================================================
* // Setup:
* //=============================================================================
* This plugin requires a new folder to be created within the project "img" folder.
* The folder must be titled "VirtualButtons".
* Place all UI button images into this folder, and they can be accessed from the
* plugin parameters.
*
* //=============================================================================
* // Vibrate Parameter
* //=============================================================================
* Buttons can trigger a vibrate on the mobile device when pressed, controlled by
* a parameter.
* This parameter follows a pattern of vibrate,pause,vibrate,pause, etc.
* Separate each time interval by a comma.
* Examples:
* 200 --> vibrate for 200ms
* 100,30,100,30,100,30 --> vibrate for 100ms, pause for 30ms; repeat 2 more times
*
* Note that most devices support the Vibration API, but not all.
* Additionally, this may not work in all methods of deployment.
*
* //=============================================================================
* // Plugin Commands:
* //=============================================================================
* All plugin commands begin with VirtualButtons or MobileUI (for backwards compatibility).
* All plugin commands are not case sensitive
* (i.e. virtualbuttons is the same as VirtualButtons)
* (i.e. DPad is the same as dpad)
*
* //=============================================================================
* hide: hides the specified button
* //=============================================================================
* Allowed first arguments:
* -all
* -DPad
* -Control
* -Any key button defined in the parameters
*
* Allowed second arguments:
* -instant (optional, this will hide the button instantly)
*
* Examples:
* MobileUI hide DPad
* mobileui hide Ok instant
* MobileUI hide PageDown
* virtualbuttons hide all
*
* //=============================================================================
* show: shows the specified button
* //=============================================================================
* Allowed first arguments:
* -all
* -DPad
* -Control
* -Any key button defined in the parameters
*
* Allowed second arguments:
* -instant (optional, this will show the button instantly)
*
* Examples:
* MobileUI show dpad
* mobileui show ok
* MobileUI show PageUp instant
* virtualbuttons show all
*
* //=============================================================================
* opacity: changes the opacity of the specified button
* //=============================================================================
*
* Allowed first arguments:
* -all
* -DPad
* -Control
* -Any key button defined in the parameters
*
* Allowed second arguments:
* -A number between 0 and 255 corresponding to the new opacity for the button
*
* Examples:
* virtualbuttons opacity dpad 100
* VirtualButtons opacity menu 200 (assuming 'menu' is a key button)
* virtualbuttons opacity all 150
*
* //=============================================================================
* Diagonal Movement Parameter
* //=============================================================================
*
* There is a parameter that controls whether diagonal input is recorded from the
* D-Pad. This is not a diagonal movement plugin! This parameter merely controls
* whether touching on the top left will add the input values of both "top" and
* "left" to the input state. Other diagonal movement plugins would consume these
* input values to move the character diagonally.
*
* If your game uses diagonal movement, this parameter must be on. If your game
* does not use diagonal movement, it is recommended to turn this parameter off.
*
* //=============================================================================
* Terms of Use:
* //=============================================================================
* Free for use in commercial or non-commercial projects.
* Credits required to: Aloe Guvner
*
* //=============================================================================
* Version History:
* //=============================================================================
* v2.0.1 (May 13 2019)
* --Fix bug where DPad got stuck in menus
* v2.0.0 (May 4 2019)
* --Clears input state on transfer to mitigate stuck DPad input bug
* --Improves clearing of input state each frame to mitigate bug
* --Fix bug where the DPad would not clear the direction after a parallel event
* checking for a input direction triggered a Show Choices event command
* --Add plugin parameter to toggle whether the buttons are hidden during dialogue
* --Plugin command to change button opacity
* --Plugin command option to hide all buttons
* --Plugin command option to show all buttons
* --Delay parameter to fade-in
* --Option to use a "hot" image that shows when the button is pressed
* --Key buttons can trigger common events
* --Buttons hidden via plugin command will stay hidden until the show plugin command
* v1.4.0 (December 13 2018)
* --Added ability to configure which buttons are affected by the "control" button
* Can be used to create dynamic menus.
* v1.3.1 (October 30 2018)
* --Added a parameter to control whether diagonal movement is detected as a
* possible fix for a hard to reproduce movement bug.
* v1.3.0 (September 27 2018)
* --Added a parameter to choose to disable the normal touch input on any chosen
* scene. The only touch input enabled on these scenes is the mobile UI.
* v1.2.3 (September 27 2018)
* --Fixed a bug where buttons that the player had chosen to hide would reappear
* after a game message.
* v1.2.2 (September 27 2018)
* --Fixed a bug where buttons could be pressed before they were fully visible
* v1.2.1 (September 27 2018)
* --Added an "instant" feature to hide/show for smoother cutscene transitions
* v1.2.0 (August 26 2018)
* --Added ability to vibrate when button is pressed
* v1.1.0 (June 27 2018)
* --Fixed bug with awkward player movement on the DPad
* --Added ability to specify the type of touch input on key buttons
* v1.0.3 (May 14 2018)
* --Added ability to run custom code when a key button is pressed
* v1.0.2 (May 9 2018)
* --Added ability to play a sound effect when a button is pressed
* --Fixed a bug where the parameters weren't read correctly due to plugin name change
* --Fixed a bug where the control button didn't hide the dpad properly
* v1.0.1 (May 8 2018)
* --Added a version compatible with MV earlier than 1.6.0 using Babel.js
* v1.0.0 (April 17 2018)
* --Initial release
*
* //=============================================================================
* End of Help File
* //=============================================================================
*/
/*~struct~dpad:
* @param image
* @text Image
* @type file
* @dir img/VirtualButtons
* @desc File path for the D-Pad image
* @require 1
*
* @param hotImage
* @text Hot Image
* @type file
* @dir img/VirtualButtons
* @desc File path for the "Hot" button image
* This image shows while the dpad is being pressed
* @require 1
*
* @param activeScenes
* @text Scenes to show the D-Pad
* @type text[]
* @desc A list of scenes where the D-Pad will be active.
* Ex. Scene_Map, Scene_Title, etc.
* @default ["Scene_Title","Scene_Map"]
*
* @param x
* @text X
* @desc X position of the D-Pad. Formulas are allowed.
* (ex. Graphics.width - 96)
* @type text
* @default 0
*
* @param y
* @text Y
* @desc Y position of the D-Pad. Formulas are allowed.
* (ex. Graphics.height - 96)
* @type text
* @default 0
*
* @param soundEffect
* @text Sound Effect
* @type struct<soundEffect>
* @desc Sound Effect to play when button is pressed.
* Depending on scenario, SE might already play. Test first.
*
*/
/*~struct~keyButton:
* @param name
* @text Name
* @type text
* @desc The name of the button
*
* @param inputMethod
* @text Input Method
* @type select
* @option Triggered
* @value 0
* @option Pressed
* @value 1
* @option Repeated
* @value 2
* @option Long Pressed
* @value 3
* @option Released
* @value 4
* @desc The type of touch input that will trigger the button.
* See the help file for full descriptions of the options.
* @default 0
*
* @param inputTrigger
* @text Input Code
* @type text
* @desc The input code triggered when the button is pressed.
* ex. ok / escape / pagedown / pageup
*
* @param image
* @text Image
* @type file
* @dir img/VirtualButtons
* @desc File path for the button image
* @require 1
*
* @param hotImage
* @text Hot Image
* @type file
* @dir img/VirtualButtons
* @desc File path for the "Hot" button image
* This image shows while the button is being pressed
* @require 1
*
* @param activeScenes
* @text Scenes to show the button
* @type text[]
* @desc A list of scenes where the button will be active.
* Ex. Scene_Map, Scene_Title, etc.
* @default ["Scene_Title","Scene_Map"]
*
* @param x
* @text X
* @type text
* @desc X position of the button. Formulas are allowed.
* (ex. Graphics.width - 96)
* @default 0
*
* @param y
* @text Y
* @type text
* @desc Y position of the button. Formulas are allowed.
* (ex. Graphics.height - 96)
* @default 0
*
* @param soundEffect
* @text Sound Effect
* @type struct<soundEffect>
* @desc Sound Effect to play when button is pressed.
* Depending on scenario, SE might already play. Test first.
*
* @param commonEvent
* @text Common Event
* @type number
* @desc Common Event to trigger when the button is pressed.
* @default 0
* @min 0
*
* @param customCode
* @text Custom Code
* @type note
* @desc Custom Javascript code to run on button press.
* Use the 'this' keyword to refer to the current scene.
*
* @param vibratePattern
* @text Vibrate Pattern
* @type text
* @default 0
* @desc Pattern of miliseconds to vibrate on press.
* Use 0 for no vibration. See help for more info.
*/
/*~struct~controlButton:
* @param image
* @text Image
* @type file
* @dir img/VirtualButtons
* @desc File path for the button image
* @require 1
*
* @param activeScenes
* @text Scenes to show the control button
* @type text[]
* @desc A list of scenes where the button will be active.
* Ex. Scene_Map, Scene_Title, etc.
* @default ["Scene_Title","Scene_Map"]
*
* @param x
* @text X
* @type text
* @desc X position of the button. Formulas are allowed.
* (ex. Graphics.width - 96)
* @default 0
*
* @param y
* @text Y
* @type text
* @desc Y position of the button. Formulas are allowed.
* (ex. Graphics.height - 96)
* @default 0
*
* @param soundEffect
* @text Sound Effect
* @type struct<soundEffect>
* @desc Sound Effect to play when button is pressed.
* Depending on scenario, SE might already play. Test first.
*
* @param buttonsToHide
* @text Buttons To Show / Hide
* @type text[]
* @desc A list of the Key Buttons to show and hide when
* this button is pressed. Leave empty to hide all.
* @default []
*
* @param hideDPad
* @text Show / Hide DPad?
* @type boolean
* @desc Controls whether the DPad is affected when
* this button is pressed.
* @default true
*
*/
/*~struct~soundEffect:
* @param name
* @text Sound Effect Name
* @type file
* @dir audio/se
* @desc Sound effect to play when the button is pressed.
* @default
* @require 1
*
* @param volume
* @text Volume
* @type number
* @min 0
* @max 100
* @desc Volume of the sound effect, in %
* Allowed values: 0% - 100%
* @default 90
*
* @param pitch
* @text Pitch
* @type number
* @min 50
* @max 150
* @desc Pitch of the sound effect, in %
* Allowed values: 50% - 150%
* @default 100
*
* @param pan
* @text Pan
* @type number
* @min -100
* @max 100
* @desc Pan of the sound effect
* Allowed values: -100 - 100
* @default 0
*
*/
var ALOE = ALOE || {};
(function () {
"use strict";
var Alias = {};
var Parameters = {}; //=============================================================================
// Utils
//=============================================================================
// Create a utility function to parse complex parameters.
//=============================================================================
ALOE.recursiveParse = function (param) {
try {
return JSON.parse(param, function (key, value) {
try {
return this.recursiveParse(value);
} catch (e) {
return value;
}
}.bind(this));
} catch (e) {
return param;
}
}; //=============================================================================
// Parameters
//=============================================================================
// Read and parse parameters into a locally scoped Parameters object.
//=============================================================================
Sprite_ControlButton.prototype.showAllButtons = function () {
var _this = this;
var params = Parameters["controlButtonSettings"];
if (params.buttonsToHide.length > 0) {
params.buttonsToHide.forEach(function (buttonName) {
if (!_this._keyButtons[buttonName]) {
console.error("".concat(buttonName, " is not a key button, check your Mobile UI plugin configuration."));
return;
}
if (params.hideDPad && this._directionalPad) {
this._directionalPad.show();
this._directionalPad.expand();
}
this._buttonsHidden = false;
};
Sprite_ControlButton.prototype.hideAllButtons = function () {
var _this2 = this;
var params = Parameters["controlButtonSettings"];
if (params.buttonsToHide.length > 0) {
params.buttonsToHide.forEach(function (buttonName) {
if (!_this2._keyButtons[buttonName]) {
console.error("".concat(buttonName, " is not a key button, check your Mobile UI plugin configuration."));
return;
}
if (params.hideDPad && this._directionalPad) {
this._directionalPad.hide();
this._directionalPad.collapse(this.x, this.y);
}
this._buttonsHidden = true;
}; //=============================================================================
// Scene_Base
//=============================================================================
// Methods to create the buttons in any scene.
//=============================================================================
Scene_Base.prototype.start = function () {
Alias.Scene_Base_start.call(this);
this.createDirPad();
this.createKeyButtons();
this.createControlButton();
};
Scene_Base.prototype.createDirPad = function () {
var params = Parameters["dPadSettings"];
if (params) {
if (params.activeScenes.length > 0 && params.activeScenes.contains(this.constructor)) {
var x = params.x;
var y = params.y;
var image = params.image || "";
var hotImage = params.hotImage || "";
var soundEffect = params.soundEffect;
this._directionalPad = new Sprite_DirectionalPad(x, y, image, hotImage, soundEffect);
this.addChild(this._directionalPad);
}
}
};
Scene_Base.prototype.createKeyButtons = function () {
var params = Parameters["keyButtonSettings"];
if (params) {
if (params.length > 0) {
this._keyButtons = {};
for (var i = 0; i < params.length; i++) {
if (params.activeScenes.length > 0 && params.activeScenes.contains(this.constructor)) {
var a = params;
this._keyButtons[a.name.toLowerCase()] = new Sprite_KeyButton(a.x, a.y, a.image, a.hotImage, a.soundEffect, a.inputTrigger.toLowerCase(), a.customCode, a.vibratePattern, a.inputMethod, a.commonEvent);
this.addChild(this._keyButtons[a.name.toLowerCase()]);
}
}
}
}
};
Scene_Base.prototype.createControlButton = function () {
var params = Parameters["controlButtonSettings"];
if (params) {
if (params.activeScenes.length > 0 && params.activeScenes.contains(this.constructor)) {
var x = params.x;
var y = params.y;
var image = params.image || "";
var soundEffect = params.soundEffect;
this._controlButton = new Sprite_ControlButton(x, y, image, soundEffect);
this.addChild(this._controlButton);
this._controlButton._keyButtons = this._keyButtons;
this._controlButton._directionalPad = this._directionalPad;
}
}
};
Scene_Base.prototype.hideVirtualButtons = function () {
var _this3 = this;
if (this._directionalPad) {
this._directionalPad.hide();
}
if (this._keyButtons) {
Object.keys(this._keyButtons).forEach(function (a) {
return _this3._keyButtons[a].hide();
});
}
if (this._controlButton) {
this._controlButton.hide();
}
};
Scene_Base.prototype.showVirtualButtons = function () {
var _this4 = this;
if (this._directionalPad && !this._directionalPad._pluginHidden) {
this._directionalPad.show();
}
if (this._keyButtons) {
Object.keys(this._keyButtons).forEach(function (button) {
if (!_this4._keyButtons[button]._pluginHidden) _this4._keyButtons[button].show();
});
}
if (this._controlButton && !this._controlButton._pluginHidden) {
this._controlButton.show();
}
};
Scene_Base.prototype.terminate = function () {
var _this5 = this;
Alias.Scene_Base_terminate.call(this);
if (this._directionalPad) {
this.removeChild(this._directionalPad);
}
if (this._keyButtons) {
Object.keys(this._keyButtons).forEach(function (a) {
return _this5.removeChild(_this5._keyButtons[a]);
});
}
if (this._controlButton) {
this.removeChild(this._controlButton);
}
}; //=============================================================================
// Scene_Map
//=============================================================================
// If map movement is disabled from the parameters, return.
// If an active button is pressed, don't do the usual map movement.
//=============================================================================
Scene_Map.prototype.processMapTouch = function () {
var _this6 = this;
if (Parameters['disableTouchMovement'] && this._directionalPad && this._directionalPad.active) {
return;
}
if (TouchInput.isTriggered()) {
var point = new Point(TouchInput.x, TouchInput.y);
if (!!this._controlButton) {
if (this._controlButton.containsPoint(point)) {
return;
}
}
if (this._directionalPad) {
if (this._directionalPad.active && this._directionalPad.containsPoint(point)) {
return;
}
}
if (this._keyButtons) {
if (Object.keys(this._keyButtons).some(function (a) {
return _this6._keyButtons[a].containsPoint(point);
})) {
return;
}
}
}
Alias.Scene_Map_processMapTouch.call(this);
}; //=============================================================================
// Window_Selectable
//=============================================================================
// Disable Touch Input on selectable windows if configured in the parameters.
//=============================================================================
Window_Selectable.prototype.processTouch = function () {
if (Parameters['disableTouchWindows'].contains(SceneManager._scene.constructor.name)) {
return;
}
Alias.Window_Selectable_processTouch.call(this);
}; //=============================================================================
// Window_Message
//=============================================================================
// Control UI visibility when the dialogue window is activated.
//=============================================================================
if (Parameters.hideButtonsDuringDialogue) {
Alias.Window_Message_startMessage = Window_Message.prototype.startMessage;
Window_Message.prototype.startMessage = function () {
SceneManager._scene.hideVirtualButtons();
if (Parameters.enableDPadDebugWindow) {
//=============================================================================
// Window_TouchInputTest
//=============================================================================
// The window to test what inputs are currently pressed on the D-Pad
//=============================================================================
var Window_TouchInputTest = function Window_TouchInputTest() {
this.initialize.apply(this, arguments);
};
var Scene_Map_createMapNameWindow = Scene_Map.prototype.createMapNameWindow;
Scene_Map.prototype.createMapNameWindow = function () {
this._touchInputTestWindow = new Window_TouchInputTest();
this.addChild(this._touchInputTestWindow);
Scene_Map_createMapNameWindow.call(this);
};
} // end if Parameters.enableDPadDebugWindow
//=============================================================================
// Game_Player
//=============================================================================
// Help solve bug with stuck movement by clearing input on map transfer.
//=============================================================================
var Game_Player_performTransfer = Game_Player.prototype.performTransfer;
Game_Player.prototype.performTransfer = function () {
if (this.isTransferring()) {
Game_Player_performTransfer.call(this);
ALOE.clearDpadInput();
}
};
ALOE.clearDpadInput = function () {
delete Input._currentState["left"];
delete Input._currentState["right"];
delete Input._currentState["up"];
delete Input._currentState["down"];
}; //==============================================================================
// Array.prototype.includes
// Array.prototype.find
//==============================================================================
// Polyfill for old versions of MV (1.5 and earlier)
//==============================================================================
// https://tc39.github.io/ecma262/#sec-array.prototype.includes
if (!Array.prototype.includes) {
Object.defineProperty(Array.prototype, 'includes', {
value: function value(valueToFind, fromIndex) {
if (this == null) {
throw new TypeError('"this" is null or not defined');
} // 1. Let O be ? ToObject(this value).
var o = Object(this); // 2. Let len be ? ToLength(? Get(O, "length")).
var len = o.length >>> 0; // 3. If len is 0, return false.
if (len === 0) {
return false;
} // 4. Let n be ? ToInteger(fromIndex).
// (If fromIndex is undefined, this step produces the value 0.)
var n = fromIndex | 0; // 5. If n ≥ 0, then
// a. Let k be n.
// 6. Else n < 0,
// a. Let k be len + n.
// b. If k < 0, let k be 0.
var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
function sameValueZero(x, y) {
return x === y || typeof x === 'number' && typeof y === 'number' && isNaN(x) && isNaN(y);
} // 7. Repeat, while k < len
while (k < len) {
// a. Let elementK be the result of ? Get(O, ! ToString(k)).
// b. If SameValueZero(valueToFind, elementK) is true, return true.
if (sameValueZero(o[k], valueToFind)) {
return true;
} // c. Increase k by 1.
if (!Array.prototype.find) {
Object.defineProperty(Array.prototype, 'find', {
value: function value(predicate) {
// 1. Let O be ? ToObject(this value).
if (this == null) {
throw new TypeError('"this" is null or not defined');
}
var o = Object(this); // 2. Let len be ? ToLength(? Get(O, "length")).
var len = o.length >>> 0; // 3. If IsCallable(predicate) is false, throw a TypeError exception.
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
} // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
var thisArg = arguments[1]; // 5. Let k be 0.
var k = 0; // 6. Repeat, while k < len
while (k < len) {
// a. Let Pk be ! ToString(k).
// b. Let kValue be ? Get(O, Pk).
// c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
// d. If testResult is true, return kValue.
var kValue = o[k];
if (predicate.call(thisArg, kValue, k, o)) {
return kValue;
} // e. Increase k by 1.
k++;
} // 7. Return undefined.
return undefined;
},
configurable: true,
writable: true
});
} //==============================================================================
// Swap Plugin Parameters
//==============================================================================
// If both ALOE_MobileUI (old name) and ALOE_VirtualButtons (new name) are ON,
// then copy the plugin parameters over. Also copy images from img/mobileui to
// img/VirtualButtons.
//==============================================================================
if (!Utils.isOptionValid('test') && PluginManager._scripts.includes("ALOE_MobileUI")) {
console.error("Conflicting version of ALOE_VirtualButtons (ALOE_MobileUI) found.");
}
if (Utils.isOptionValid('test') && PluginManager._scripts.includes("ALOE_MobileUI")) {
nw.Window.get().showDevTools();
var fs = require('fs');
console.log("Both ALOE_VirtualButtons and ALOE_MobileUI are activated.");
console.log("Initiating procedure to copy plugin parameters and images...");
console.log("Copying plugin parameters...");
var pluginsjs = fs.readFileSync('js/plugins.js', 'utf-8');
var grabParametersRegex = /ALOE_MobileUI.+"parameters":(.+)},?$/m;
var match = pluginsjs.match(grabParametersRegex);
if (match && match[1]) {
var mobileUIParameters = match[1];
var replaceParametersRegex = /(ALOE_VirtualButtons.+"parameters":)(.+)(},?$)/m;
var trailingComma = ','; // If it's the last plugin in the list, no trailing comma
if (!fs.existsSync('img/VirtualButtons')) {
fs.mkdirSync('img/VirtualButtons');
}
if (fs.existsSync('img/mobileUI')) {
fs.readdirSync('img/mobileUI').forEach(function (image) {
return fs.copyFileSync("img/mobileUI/".concat(image), "img/VirtualButtons/".concat(image));
});
} else {
console.error('Unable to copy from img/mobileUI to img/VirtualButtons. img/mobileUI does not exist');
}
console.log("Plugin parameters and images copy successfully completed!");
console.log("============ Instructions ============\n");
console.log("1. Close the MV editor. If you press 'save' or open the Plugin Manager, it will undo the copying of the plugin parameters.");
console.log("2. Verify the images were copied from img/mobileUI to img/VirtualButtons then you can remove the img/mobileUI folder");
console.log("3. Open the MV editor again, go to the Plugin Manager, right-click on ALOE_VirtualButtons and press \"Refresh\".");
console.log("4. Verify the plugin parameters were copied over and then you can remove ALOE_MobileUI.");
}作者: sh2288 时间: 2021-9-16 15:00
大佬们,这个插件好像需要自己放置图片,图片好说,但我该怎么命名啊作者: sh2288 时间: 2021-9-16 15:02
哦,装上插件后明白了,白问了