Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // GS_mapaMundi.js v1.22
- //=============================================================================
- /*:
- * @plugindesc v1.22 - Allows developers to create mapa-mundi in games.
- * @author GuilhermeSantos
- *
- * @param Map-Info
- * @desc Set the settings of the maps.
- * @type struct<MapaInfo>[]
- * @default ["{\"Keyboard (open)\":\"true\",\"KeyName (open)\":\"pageup\",\"KeyName (open) (Advanced)\":\"My Advanced keyName\",\"Keyboard (close)\":\"true\",\"KeyName (close)\":\"pagedown\",\"KeyName (close) (Advanced)\":\"My Advanced keyName\",\"Zoom\":\"true\",\"Distance\":\"1.5\",\"Restore (Type)\":\"automatic\",\"Restore\":\"1\",\"Frames\":\"30\",\"Map-Id\":\"1\"}"]
- *
- * @param Map-Icons
- * @desc Set the icons on the mapa-mundi.
- * @type struct<MapaIcons>[]
- * @default ["{\"Icon\":\"system/\",\"Extension of the Icon\":\"png\",\"Map-Id\":\"1\",\"TileX\":\"1\",\"TileY\":\"1\",\"Hue\":\"1\",\"ScaleX\":\"1.5\",\"ScaleY\":\"1.5\",\"Text Icon\":\"txt\",\"Text\":\"My Icon\",\"fontSize\":\"16\",\"TextScaleX\":\"1.5\",\"TextScaleY\":\"1.5\",\"textX\":\"-56.00\",\"textY\":\"0.00\",\"Animation\":\"true\",\"animFrames\":\"60\",\"animFrames2\":\"60\",\"Opacity\":\"true\",\"StartOpacity\":\"0\",\"Delay\":\"60\"}"]
- *
- * @param Map-ConfigMove
- * @desc Set the config of the mapa-mundi movement.
- * @type struct<ConfigMove>[]
- * @default ["{\"Move Camera\":\"automatic\",\"Limit (Y+)\":\"1\",\"Limit (Y-)\":\"1\",\"Limit (X+)\":\"1\",\"Limit (X-)\":\"1\",\"Speed\":\"2.0\",\"Map-Id\":\"1\"}"]
- *
- * @param Map-ZoomPrivate
- * @desc Set the privates locations of zoom (disabled).
- * @type struct<ZoomPrivate>[]
- * @default ["{\"Private Type\":\"Disabled\",\"Region ID\":\"1\",\"Point (X)\":\"1\",\"Point End (X)\":\"1\",\"Point (Y)\":\"1\",\"Point End (Y)\":\"1\",\"Map-Id\":\"1\"}"]
- *
- * @help
- * ============================================================================
- * Introduction
- * ============================================================================
- *
- * This plugin lets you create the mapa-mundi.
- *
- * ============================================================================
- * Dependencies (2)
- * ============================================================================
- * SRD_CameraCore (SumRndmDde)
- * Need: - Effect of zooming.
- * - Move of camera
- * Get: http://bit.ly/2sAhKJc
- * --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
- * YEP_StopMapMovement (Yanfly Engine Plugins)
- * Need: - To stop the movement of the player.
- * - To stop the movement of the events
- * Get: http://bit.ly/2swXN53
- * ============================================================================
- * Plugin Commands (2)
- * ============================================================================
- *
- * If you would like to shut off the mapa-mundi or turn it on,
- * you can use the following plugin commands:
- *
- * Plugin Command:
- *
- * HideMapaMundi
- * Hide the mapa-mundi.
- *
- * ShowMapaMundi
- * Show the mapa-mundi.
- *
- * ============================================================================
- * Changelog (8)
- * ============================================================================
- *
- * Version 1.22:
- * - Added new function to clear icons.
- * - Added new function to opacity of the icons.
- * - Added new parameters.
- *
- * Version 1.21:
- * - Added new function to open/close mapa-mundi.
- * - Added new parameters.
- *
- * Version 1.20:
- * - Added new function to zoom-map.
- * - Added new function to private locations of the zoom-map (disabled).
- * - Fixed bug of the camera movement.
- * - Added new parameters.
- *
- * Version 1.18:
- * - Added new function to save menu access.
- * - Bugs Fix.
- *
- * Version 1.15:
- * - Added new movement of camera of the mapa-mundi.
- * - Added new parameters.
- *
- * Version 1.12:
- * - Added new animation of icons and improvements.
- * - Added new draw text for icons.
- *
- * Version 1.10:
- * - Added new features and improvements.
- * - The system must implement and not lock for lack of dependencies.
- *
- * Version 1.00:
- * - Finished Plugin!
- */
- /*~struct~MapaInfo:
- * @param Keyboard (open)
- * @desc Key to open mapa-mundi.
- * @type boolean
- * @default true
- * @on Enable
- * @off Disable
- *
- * @param KeyName (open)
- * @parent Keyboard (open)
- * @type select
- * @desc Which key opens the world map?
- * @default pageup
- * @option tab
- * @value tab
- * @option ok
- * @value ok
- * @option shift
- * @value shift
- * @option control
- * @value control
- * @option escape
- * @value escape
- * @option pageup
- * @value pageup
- * @option pagedown
- * @value pagedown
- * @option left
- * @value left
- * @option up
- * @value up
- * @option right
- * @value right
- * @option down
- * @value down
- * @option advanced
- * @value advanced
- *
- * @param KeyName (open) (Advanced)
- * @parent Keyboard (open)
- * @desc Advanced keyName.
- * @type string
- * @default My Advanced keyName
- *
- * @param Keyboard (close)
- * @desc Key to close mapa-mundi.
- * @type boolean
- * @default true
- * @on Enable
- * @off Disable
- *
- * @param KeyName (close)
- * @parent Keyboard (close)
- * @type select
- * @desc Which key close the world map?
- * @default pagedown
- * @option tab
- * @value tab
- * @option ok
- * @value ok
- * @option shift
- * @value shift
- * @option control
- * @value control
- * @option escape
- * @value escape
- * @option pageup
- * @value pageup
- * @option pagedown
- * @value pagedown
- * @option left
- * @value left
- * @option up
- * @value up
- * @option right
- * @value right
- * @option down
- * @value down
- * @option advanced
- * @value advanced
- *
- * @param KeyName (close) (Advanced)
- * @parent Keyboard (close)
- * @desc Advanced keyName.
- * @type string
- * @default My Advanced keyName
- *
- * @param Zoom
- * @desc Effect of zoom when the world map is opened.
- * @type boolean
- * @default true
- * @on Enable
- * @off Disable
- *
- * @param Distance
- * @parent Zoom
- * @desc Distance of the zoom(out).
- * @type number
- * @max 2
- * @min 1
- * @decimals 1
- * @default 1.5
- *
- * @param Restore (Type)
- * @parent Zoom
- * @type select
- * @desc What is the restore type?
- * @default automatic
- * @option number
- * @value number
- * @option automatic
- * @value automatic
- *
- * @param Restore
- * @parent Restore (Type)
- * @desc Distance of the zoom(in).
- * @type number
- * @max 2
- * @min 1
- * @decimals 1
- * @default 1
- *
- * @param Frames
- * @parent Zoom
- * @desc Execution Time of the zoom(out/in).
- * @type number
- * @max 300
- * @min 30
- * @default 30
- *
- * @param Map-Id
- * @desc ID of Map.
- * @type number
- * @min 1
- * @default 1
- */
- /*~struct~MapaIcons:
- * @param Icon
- * @desc The image of the icon.
- * @require 1
- * @dir img
- * @type file
- * @default system/
- *
- * @param Extension of the Icon
- * @type select
- * @desc What is the image file format?
- * @default png
- * @option png
- * @value png
- * @option jpg
- * @value jpg
- *
- * @param Map-Id
- * @desc ID of Map.
- * @type number
- * @min 1
- * @default 1
- *
- * @param TileX
- * @desc Tile x of icon.
- * @type number
- * @min 1
- * @default 1
- *
- * @param TileY
- * @desc Tile y of icon.
- * @type number
- * @min 1
- * @default 1
- *
- * @param Hue
- * @parent Zoom
- * @desc The hue offset in 360 degrees.
- * @type number
- * @max 360
- * @min -360
- * @default 1
- *
- * @param ScaleX
- * @desc Scale x of icon.
- * @type number
- * @max 4
- * @min -2
- * @decimals 1
- * @default 1.5
- *
- * @param ScaleY
- * @desc Scale y of icon.
- * @type number
- * @max 4
- * @min -2
- * @decimals 1
- * @default 1.5
- *
- * @param Text Icon
- * @type select
- * @desc What is the type of format text?
- * @default txt
- * @option txt
- * @value txt
- * @option command
- * @value command
- * @option disabled
- * @value disabled
- *
- * @param Text
- * @parent Text Icon
- * @desc Text of icon.
- * @type string
- * @default My Icon
- *
- * @param fontSize
- * @parent Text Icon
- * @desc Size of font.
- * @type number
- * @max 72
- * @min 6
- * @default 16
- *
- * @param TextScaleX
- * @parent Text Icon
- * @desc Scale y of text icon.
- * @type number
- * @max 4
- * @min -2
- * @decimals 1
- * @default 1.5
- *
- * @param TextScaleY
- * @parent Text Icon
- * @desc Scale y of text icon.
- * @type number
- * @max 4
- * @min -2
- * @decimals 1
- * @default 1.5
- *
- * @param textX
- * @parent Text Icon
- * @desc Position x of font.
- * @type number
- * @max 100
- * @min -100
- * @decimals 2
- * @default -56.00
- *
- * @param textY
- * @parent Text Icon
- * @desc Position y of font.
- * @type number
- * @max 100
- * @min -100
- * @decimals 2
- * @default 0.00
- *
- * @param Animation
- * @parent Zoom
- * @desc Effect of zoom-in and zoom-out of icon.
- * @type boolean
- * @default true
- * @on Enable
- * @off Disable
- *
- * @param animFrames
- * @parent Animation
- * @desc Execution Time of the scale(in) icon.
- * @type number
- * @max 999
- * @min 30
- * @default 60
- *
- * @param animFrames2
- * @parent Animation
- * @desc Execution Time of the scale(out) icon.
- * @type number
- * @max 999
- * @min 30
- * @default 60
- *
- * @param Opacity
- * @parent Zoom
- * @desc Effect of opacity-in and opacity-out of icon.
- * @type boolean
- * @default true
- * @on Enable
- * @off Disable
- *
- * @param StartOpacity
- * @parent Opacity
- * @desc Opacity initial of effect.
- * @type number
- * @max 999
- * @min 0
- * @default 0
- *
- * @param Delay
- * @parent Opacity
- * @desc Delay to start the effect.
- * @type number
- * @max 999
- * @min 0
- * @default 60
- */
- /*~struct~ConfigMove:
- * @param Move Camera
- * @type select
- * @desc What is the limit type?
- * @default automatic
- * @option number
- * @value number
- * @option automatic
- * @value automatic
- *
- * @param Limit (Y+)
- * @parent Move Camera
- * @desc Value of limit to down.
- * @type number
- * @min 0
- * @default 1
- *
- * @param Limit (Y-)
- * @parent Move Camera
- * @desc Value of limit to up.
- * @type number
- * @min 0
- * @default 1
- *
- * @param Limit (X+)
- * @parent Move Camera
- * @desc Value of limit to right.
- * @type number
- * @min 0
- * @default 1
- *
- * @param Limit (X-)
- * @parent Move Camera
- * @desc Value of limit to left.
- * @type number
- * @min 0
- * @default 1
- *
- * @param Speed
- * @parent Move Camera
- * @desc Value of speed of the movement.
- * @type Number
- * @min 1
- * @decimals 1
- * @default 2.0
- *
- * @param Map-Id
- * @parent Zoom
- * @desc ID of Map.
- * @type number
- * @min 1
- * @default 1
- */
- /*~struct~ZoomPrivate:
- * @param Private Type
- * @type select
- * @desc What is the value type?
- * @default Disabled
- * @option PointToPoint
- * @value PointToPoint
- * @option Region
- * @value Region
- * @option Disabled
- * @value Disabled
- *
- * @param Region ID
- * @parent Private Type
- * @desc Value of region.
- * @type number
- * @min 1
- * @max 255
- * @default 1
- *
- * @param Point (X)
- * @parent Private Type
- * @desc Value of tile map x to point.
- * @type number
- * @min 0
- * @default 1
- *
- * @param Point End (X)
- * @parent Private Type
- * @desc Value of tile map x to end point.
- * @type number
- * @min 0
- * @default 1
- *
- * @param Point (Y)
- * @parent Private Type
- * @desc Value of tile map y to point.
- * @type number
- * @min 0
- * @default 1
- *
- * @param Point End (Y)
- * @parent Private Type
- * @desc Value of tile map y to end point.
- * @type number
- * @min 0
- * @default 1
- *
- * @param Map-Id
- * @parent Zoom
- * @desc ID of Map.
- * @type number
- * @min 1
- * @default 1
- */
- var GS = GS || {};
- GS.mapaMundi = GS.mapaMundi || {};
- var Imported = Imported || {};
- Imported["GS_mapaMundi"] = 1.22;
- (function (_) {
- "use strict";
- //-----------------------------------------------------------------------------
- // Methods
- //
- _.localPath = function (p) {
- if (p.substring(0, 1) === '/') p = p.substring(1);
- var path = require('path');
- var base = path.dirname(process.mainModule.filename);
- return path.join(base, p);
- };
- _.reloadDev = function () {
- if (Utils.isNwjs()) {
- var window = require('nw.gui').Window.get();
- window.reloadDev();
- }
- };
- _.progressBar = function (value) {
- if (Utils.isNwjs()) {
- var window = require('nw.gui').Window.get();
- window.setProgressBar(value);
- }
- };
- Graphics.printIconError = function (url) {
- if (this._errorPrinter && !this._errorShowed) {
- this._errorPrinter.innerHTML = this._makeErrorHtml('Loading Error', 'Failed to load: ' + url);
- var button = document.createElement('button');
- button.innerHTML = 'Retry';
- button.style.fontSize = '24px';
- button.style.color = '#ffffff';
- button.style.backgroundColor = '#000000';
- button.onmousedown = button.ontouchstart = function (event) {
- ResourceHandler.retry();
- event.stopPropagation();
- var fs = require('fs');
- if (fs.existsSync(url)) {
- Graphics.eraseLoadingError();
- Graphics.printIconRestart(url);
- };
- };
- this._errorPrinter.appendChild(button);
- this._loadingCount = -Infinity;
- }
- };
- Graphics.printIconRestart = function (url) {
- if (this._errorPrinter && !this._errorShowed) {
- this._errorPrinter.innerHTML = this._makeErrorHtml('Loading Complete', 'Complete to load: ' + url);
- var button = document.createElement('button');
- button.innerHTML = 'Restart';
- button.style.fontSize = '24px';
- button.style.color = '#ffffff';
- button.style.backgroundColor = '#000000';
- button.onmousedown = button.ontouchstart = function (event) {
- ResourceHandler.retry();
- event.stopPropagation();
- _.progressBar(0);
- _.reloadDev();
- };
- this._errorPrinter.appendChild(button);
- this._loadingCount = -Infinity;
- }
- };
- //-----------------------------------------------------------------------------
- // Dependencies
- //
- var SRD_CameraCore = Imported['SumRndmDde Camera Core'] || false;
- var YEP_StopMapMovement = Imported['YEP_StopMapMovement'] || false;
- //-----------------------------------------------------------------------------
- // Parameters
- //
- var params = PluginManager.parameters('GS_mapaMundi');
- var MapInfo = JSON.parse(params['Map-Info']);
- var MapIcons = JSON.parse(params['Map-Icons']);
- var MapConfigMove = JSON.parse(params['Map-ConfigMove']);
- var mapPrivateZoom = JSON.parse(params['Map-ZoomPrivate']);
- //-----------------------------------------------------------------------------
- // Game_Player
- //
- // The game object class for the player. It contains event starting
- // determinants and map scrolling functions.
- var Game_PlayerclearTransferInfo = Game_Player.prototype.clearTransferInfo;
- Game_Player.prototype.clearTransferInfo = function () {
- Game_PlayerclearTransferInfo.call(this);
- $gameSystem.resetAllMapaMundi();
- var mapId = $gameMap.mapId();
- var length = MapInfo.length;
- for (let i = 0; i < length; i++) {
- let info = JSON.parse(MapInfo[i]);
- let infoId = JSON.parse(info['Map-Id']);
- if (infoId == mapId) {
- $gameSystem.mapZoomSet('Zoom', JSON.parse(info['Zoom']));
- $gameSystem.mapZoomSet('Distance', JSON.parse(info['Distance']));
- $gameSystem.mapZoomSet('Frames', JSON.parse(info['Frames']));
- $gameSystem.mapZoomSet('Map-Id', JSON.parse(info['Map-Id']));
- $gameSystem.mapZoomSet('Restore (Type)', info['Restore (Type)']);
- $gameSystem.mapZoomSet('Restore', JSON.parse(info['Restore']));
- $gameSystem.mapZoomSet('Keyboard (open)', JSON.parse(info['Keyboard (open)']));
- $gameSystem.mapZoomSet('KeyName (open)', info['KeyName (open)']);
- $gameSystem.mapZoomSet('KeyName (open) (Advanced)', info['KeyName (open) (Advanced)']);
- $gameSystem.mapZoomSet('Keyboard (close)', JSON.parse(info['Keyboard (close)']));
- $gameSystem.mapZoomSet('KeyName (close)', info['KeyName (close)']);
- $gameSystem.mapZoomSet('KeyName (close) (Advanced)', info['KeyName (close) (Advanced)']);
- break;
- }
- }
- length = MapIcons.length;
- for (let i = 0; i < length; i++) {
- let info = JSON.parse(MapIcons[i]);
- let infoId = JSON.parse(info['Map-Id']);
- if (infoId == mapId) {
- $gameSystem.mapIconsSet(
- info['Icon'],
- info['Extension of the Icon'],
- JSON.parse(info['TileX']),
- JSON.parse(info['TileY']),
- JSON.parse(info['Hue']),
- JSON.parse(info['ScaleX']),
- JSON.parse(info['ScaleY']),
- $gameSystem.getTextIcon(
- info['Text Icon'],
- info['Text']
- ),
- JSON.parse(info['fontSize']),
- JSON.parse(info['TextScaleX']),
- JSON.parse(info['TextScaleY']),
- JSON.parse(info['textX']),
- JSON.parse(info['textY']),
- JSON.parse(info['animFrames']),
- JSON.parse(info['animFrames2']),
- JSON.parse(info['ScaleX']),
- JSON.parse(info['ScaleY']),
- JSON.parse(info['Animation']),
- $gameSystem.setOpacityIconsMapaMundi(
- JSON.parse(info['Opacity']),
- JSON.parse(info['StartOpacity']),
- JSON.parse(info['Delay'])
- )
- );
- }
- }
- length = MapConfigMove.length;
- for (let i = 0; i < length; i++) {
- let info = JSON.parse(MapConfigMove[i]);
- let infoId = JSON.parse(info['Map-Id']);
- if (infoId == mapId) {
- $gameSystem.mapMoveSet('Move Camera', info['Move Camera']);
- $gameSystem.mapMoveSet('Limit (Y+)', JSON.parse(info['Limit (Y+)']));
- $gameSystem.mapMoveSet('Limit (Y-)', JSON.parse(info['Limit (Y-)']));
- $gameSystem.mapMoveSet('Limit (X+)', JSON.parse(info['Limit (X+)']));
- $gameSystem.mapMoveSet('Limit (X-)', JSON.parse(info['Limit (X-)']));
- $gameSystem.mapMoveSet('Move Speed', JSON.parse(info['Speed']));
- $gameSystem.mapMoveSet('Map-Id', JSON.parse(info['Map-Id']));
- break;
- }
- }
- length = mapPrivateZoom.length;
- for (let i = 0; i < length; i++) {
- let info = JSON.parse(mapPrivateZoom[i]);
- let infoId = JSON.parse(info['Map-Id']);
- if (infoId == mapId) {
- $gameSystem.mapPrivateZoomSet('Private Type', info['Private Type']);
- $gameSystem.mapPrivateZoomSet('Region ID', JSON.parse(info['Region ID']));
- $gameSystem.mapPrivateZoomSet('Point (X)', JSON.parse(info['Point (X)']));
- $gameSystem.mapPrivateZoomSet('Point End (X)', JSON.parse(info['Point End (X)']));
- $gameSystem.mapPrivateZoomSet('Point (Y)', JSON.parse(info['Point (Y)']));
- $gameSystem.mapPrivateZoomSet('Point End (Y)', JSON.parse(info['Point End (Y)']));
- $gameSystem.mapPrivateZoomSet('Map-Id', JSON.parse(info['Map-Id']));
- break;
- }
- }
- };
- //-----------------------------------------------------------------------------
- // Game_System
- //
- // The game object class for the system data.
- Game_System.prototype.mapaMundi = function () {
- return this._mapaMundi;
- };
- Game_System.prototype.saveZoomMap = function (zoom) {
- this._saveZoomMap = zoom;
- };
- Game_System.prototype.zoomMap = function () {
- return this._saveZoomMap;
- };
- Game_System.prototype.saveIsMenuEnabled = function () {
- this._saveMenuEnabled = this.isMenuEnabled();
- this.disableMenu();
- };
- Game_System.prototype.saveMenuEnabled = function () {
- return this._saveMenuEnabled;
- };
- Game_System.prototype.enableCallMenuMapaMundi = function () {
- this._saveMenuCallMapaMundi = true;
- };
- Game_System.prototype.disableCallMenuMapaMundi = function () {
- this._saveMenuCallMapaMundi = false;
- };
- Game_System.prototype.callMenuMapaMundi = function () {
- return this._saveMenuCallMapaMundi;
- };
- Game_System.prototype.resetAllMapaMundi = function () {
- this.mapIconsReset();
- this.mapZoomReset();
- this.mapMoveReset();
- this.mapPrivateZoomReset();
- };
- Game_System.prototype.mapPrivateZoomReset = function () {
- this._mapPrivateZoomInfo = [];
- };
- Game_System.prototype.mapPrivateZoomSet = function (object, value) {
- this._mapPrivateZoomInfo[object] = value;
- };
- Game_System.prototype.mapPrivateZoomInfo = function (object) {
- return this._mapPrivateZoomInfo[object] || false;
- };
- Game_System.prototype.mapMoveReset = function () {
- this._mapMoveInfo = [];
- };
- Game_System.prototype.mapMoveSet = function (object, value) {
- this._mapMoveInfo[object] = value;
- };
- Game_System.prototype.mapMoveInfo = function (object) {
- if (this._mapMoveInfo[object] === 0) {
- return this._mapMoveInfo[object];
- }
- return this._mapMoveInfo[object] || false;
- };
- Game_System.prototype.mapZoomReset = function () {
- this._mapZoomInfo = [];
- };
- Game_System.prototype.mapZoomSet = function (object, value) {
- this._mapZoomInfo[object] = value;
- };
- Game_System.prototype.mapZoomInfo = function (object) {
- return this._mapZoomInfo[object] || false;
- };
- Game_System.prototype.mapIconsReset = function () {
- this._mapIcons = [];
- };
- Game_System.prototype.mapIconsSet = function (path, extension, x, y, hue, scaleX, scaleY, text, fontSize, TextScaleX, TextScaleY, textX, textY, animFrames, animFrames2, minIconScaleX, minIconScaleY, Animation, Opacity) {
- this._mapIcons.push([path, extension, x, y, hue, scaleX, scaleY, text, fontSize, TextScaleX, TextScaleY, textX, textY, animFrames, animFrames2, minIconScaleX, minIconScaleY, Animation, Opacity]);
- };
- Game_System.prototype.existIcons = function () {
- var fs = require('fs');
- var mapIcons = $gameSystem._mapIcons;
- var length = mapIcons.length;
- for (var i = 0; i < length; i++) {
- var filePath = mapIcons[i][0];
- var fileExtension = mapIcons[i][1];
- var path = _.localPath('img/' + filePath + '.' + fileExtension);
- if (!fs.existsSync(path)) {
- SceneManager.stop();
- _.progressBar(2.5);
- return Graphics.printIconError(path);
- }
- }
- return true;
- };
- Game_System.prototype.startMapaMundi = function () {
- this._mapaMundi = true;
- this.saveIsMenuEnabled();
- this.startMapaMundiZoom();
- this.startMapaMundiStopPlayer();
- if (this.tileMapSpritesExist()) {
- this._cancelIconsMapaMundi = false;
- this.tileMapSpriteClear();
- }
- this.startMapaMundiIcons();
- this.startShiftValuesMapaMundi();
- };
- Game_System.prototype.startShiftValuesMapaMundi = function () {
- if (SRD_CameraCore) {
- $gameMap._shiftCameraMapaMundiY = 0;
- $gameMap._shiftCameraMapaMundiX = 0;
- }
- };
- Game_System.prototype.startMapaMundiStopPlayer = function () {
- if (YEP_StopMapMovement) {
- Game_Interpreter.prototype.pluginCommand('StopPlayerMovement', []);
- Game_Interpreter.prototype.pluginCommand('StopEventMovement', []);
- }
- };
- Game_System.prototype.startMapaMundiZoom = function () {
- var zoomEnable = $gameSystem.mapZoomInfo('Zoom');
- var zoomDistance = $gameSystem.mapZoomInfo('Distance');
- var zoomFrames = $gameSystem.mapZoomInfo('Frames');
- var zoomType = $gameSystem.mapZoomInfo('Restore (Type)');
- if (SRD_CameraCore) {
- if (zoomEnable) {
- if (zoomType === 'automatic') $gameSystem.saveZoomMap(Math.floor($gameScreen._zoomScale));
- Game_Interpreter.prototype.pluginCommand('ZoomOut', [zoomDistance.toString(), zoomFrames.toString()]);
- }
- }
- };
- Game_System.prototype.tileMapSpritesExist = function () {
- if (this._tileMapSprites instanceof Array === false) return;
- return this._tileMapSprites.length > 0;
- };
- Game_System.prototype.tileMapSpriteClear = function () {
- var length = this._tileMapSprites.length;
- for (var i = 0; i < length; i++) {
- SceneManager._scene._spriteset._tilemap.removeChild(this._tileMapSprites[i]);
- }
- };
- Game_System.prototype.startMapaMundiIcons = function () {
- if (!this.existIcons()) return;
- var mapIcons = $gameSystem._mapIcons;
- var length = mapIcons.length;
- this._tileMapSprites = [];
- this._tileMapSpritesIndex = 0;
- for (var i = 0; i < length; i++) {
- var path = mapIcons[i][0];
- var hue = mapIcons[i][4];
- var bitmap = this.loadBitmap(this.bitmapPath(path), this.bitmapFile(path), hue);
- var x = mapIcons[i][2];
- var y = mapIcons[i][3];
- var scaleX = mapIcons[i][5];
- var scaleY = mapIcons[i][6];
- var text = mapIcons[i][7];
- var fontSize = mapIcons[i][8];
- var TextScaleX = mapIcons[i][9];
- var TextScaleY = mapIcons[i][10];
- var textX = mapIcons[i][11];
- var textY = mapIcons[i][12];
- var animFrames = mapIcons[i][13];
- var animFrames2 = mapIcons[i][14];
- var minIconScaleX = mapIcons[i][15];
- var minIconScaleY = mapIcons[i][16];
- var Animation = mapIcons[i][17];
- var Opacity = mapIcons[i][18];
- this._tileMapSprites.push(new Sprite_IconsMap(bitmap, x, y, scaleX, scaleY, text, fontSize, TextScaleX, TextScaleY, textX, textY, animFrames, animFrames2, minIconScaleX, minIconScaleY, Animation, Opacity));
- SceneManager._scene._spriteset._tilemap.addChild(this._tileMapSprites[this._tileMapSpritesIndex]);
- this._tileMapSpritesIndex++;
- }
- };
- Game_System.prototype.bitmapPath = function (path) {
- var length = path.length;
- var string = '';
- for (var i = 0; i < length; i++) {
- if (path[i] != '/') string += path[i];
- if (path[i] == '/') break;
- } return string;
- };
- Game_System.prototype.bitmapFile = function (path) {
- var length = path.length;
- var string = '';
- var initString = false;
- for (var i = 0; i < length; i++) {
- if (!initString) {
- if (path[i] == '/') initString = true;
- } else {
- if (path[i] != '/') string += path[i];
- }
- } return string;
- };
- Game_System.prototype.loadBitmap = function (paste, file, hue) {
- return ImageManager.loadBitmap('img/' + paste + '/', file.toString(), hue, true) || new Bitmap(0, 0);
- };
- Game_System.prototype.getTextIcon = function (type, text) {
- switch (type) {
- case 'command':
- try {
- var command = eval(text);
- } catch (error) {
- console.error(error, text);
- return '';
- }
- return command;
- case 'txt':
- return text;
- case 'disabled':
- return 'disabled';
- }
- };
- Game_System.prototype.stopMapaMundi = function () {
- this._mapaMundi = false;
- this.stopMapaMundiZoom();
- this.stopMapaMundiStopPlayer();
- this.stopMapaMundiIcons();
- };
- Game_System.prototype.stopMapaMundiStopPlayer = function () {
- if (YEP_StopMapMovement) {
- Game_Interpreter.prototype.pluginCommand('AllowPlayerMovement', []);
- Game_Interpreter.prototype.pluginCommand('AllowEventMovement', []);
- }
- };
- Game_System.prototype.stopMapaMundiZoom = function () {
- var zoomEnable = $gameSystem.mapZoomInfo('Zoom');
- var zoomDistance = $gameSystem.mapZoomInfo('Restore');
- var zoomFrames = $gameSystem.mapZoomInfo('Frames');
- var zoomType = $gameSystem.mapZoomInfo('Restore (Type)');
- if (SRD_CameraCore) {
- if (zoomEnable) {
- if (zoomType === 'automatic') zoomDistance = $gameSystem.zoomMap();
- if (!$gameMap.playerPrivateZoomMapaMundi()) Game_Interpreter.prototype.pluginCommand('ZoomIn', [zoomDistance.toString(), zoomFrames.toString()]);
- }
- Game_Interpreter.prototype.pluginCommand('ResetFocus', [zoomFrames.toString()]);
- this.enableCallMenuMapaMundi();
- }
- };
- Game_System.prototype.stopMapaMundiIcons = function () {
- this._cancelIconsMapaMundi = true;
- };
- Game_System.prototype.cancelIconsMapaMundi = function () {
- return this._cancelIconsMapaMundi;
- };
- Game_System.prototype.setOpacityIconsMapaMundi = function (Opacity, StartOpacity, Delay) {
- return new Array(Opacity, StartOpacity, Delay);
- };
- //-----------------------------------------------------------------------------
- // Game_Interpreter
- //
- // The interpreter for running event commands.
- var gameInterpreterCommand = Game_Interpreter.prototype.pluginCommand;
- Game_Interpreter.prototype.pluginCommand = function (command, args) {
- gameInterpreterCommand.call(this, command, args);
- if (command === 'ShowMapaMundi') $gameSystem.startMapaMundi();
- if (command === 'HideMapaMundi') $gameSystem.stopMapaMundi();
- };
- //-----------------------------------------------------------------------------
- // Sprite_IconsMap
- //
- // The sprite for displaying a icons in map.
- function Sprite_IconsMap() {
- this.initialize.apply(this, arguments);
- }
- Sprite_IconsMap.prototype = Object.create(Sprite_Base.prototype);
- Sprite_IconsMap.prototype.constructor = Sprite_IconsMap;
- Sprite_IconsMap.prototype.initialize = function (bitmap, x, y, scaleX, scaleY, text, fontSize, TextScaleX, TextScaleY, textX, textY, animFrames, animFrames2, minIconScaleX, minIconScaleY, Animation, Opacity) {
- Sprite_Base.prototype.initialize.call(this);
- console.log(Opacity)
- if (Opacity[0]) {
- this.initOpacity(Opacity[1], Opacity[2]);
- }
- this.initMembers(bitmap, x, y, scaleX, scaleY, text, fontSize, TextScaleX, TextScaleY, textX, textY, animFrames, animFrames2, minIconScaleX, minIconScaleY, Animation);
- };
- Sprite_IconsMap.prototype.initOpacity = function (startOpacity, framesOpacity) {
- this.opacity = startOpacity;
- this._framesOpacity = framesOpacity;
- this.spriteOpacitySet(true);
- };
- Sprite_IconsMap.prototype.initMembers = function (bitmap, x, y, scaleX, scaleY, text, fontSize, TextScaleX, TextScaleY, textX, textY, animFrames, animFrames2, minIconScaleX, minIconScaleY, Animation) {
- this.anchor.x = 0.5;
- this.anchor.y = 1;
- this._x = x;
- this._y = y;
- this.bitmap = bitmap;
- this.scale = new Point(scaleX, scaleY);
- if (text.toString() != 'disabled') {
- this._text = new Sprite(new Bitmap(100, 40));
- this._text.bitmap.fontSize = fontSize;
- this._text.bitmap.drawText(text, 5, 5, 100, 0, 'center');
- this._text.scale = new Point(TextScaleX, TextScaleY);
- this._text.x = textX;
- this._text.y = textY;
- this.addChild(this._text);
- }
- this._framesAnimationSave = [animFrames, animFrames2];
- this._minIconScaleX = minIconScaleX;
- this._minIconScaleY = minIconScaleY;
- this._AnimationIcon = Animation;
- this.resetAllFramesAnimation();
- };
- Sprite_IconsMap.prototype.update = function () {
- Sprite_Base.prototype.update.call(this);
- this.updatePosition();
- if (this.spriteOpacity()) this.updateOpacity();
- if (this._AnimationIcon) this.updateAnimation();
- };
- Sprite_IconsMap.prototype.spriteOpacitySet = function (value) {
- this._spriteOpacity = value;
- };
- Sprite_IconsMap.prototype.spriteOpacity = function () {
- return this._spriteOpacity;
- };
- Sprite_IconsMap.prototype.updateOpacity = function () {
- if (this._framesOpacity > 0) {
- this._framesOpacity--;
- } else {
- if (this.opacity < 255) this.opacity += 2;
- }
- };
- Sprite_IconsMap.prototype.updatePosition = function () {
- this.x = this.screenX();
- this.y = this.screenY();
- this.z = this.screenZ();
- };
- Sprite_IconsMap.prototype.scrolledX = function () {
- return $gameMap.adjustX(this._x);
- };
- Sprite_IconsMap.prototype.scrolledY = function () {
- return $gameMap.adjustY(this._y);
- };
- Sprite_IconsMap.prototype.screenX = function () {
- var tw = $gameMap.tileWidth();
- return Math.round(this.scrolledX() * tw + tw / 2);
- };
- Sprite_IconsMap.prototype.screenY = function () {
- var th = $gameMap.tileHeight();
- return Math.round(this.scrolledY() * th + th - this.shiftY());
- };
- Sprite_IconsMap.prototype.shiftY = function () {
- return 6;
- };
- Sprite_IconsMap.prototype.screenZ = function () {
- return 3;
- };
- Sprite_IconsMap.prototype.resetAllFramesAnimation = function () {
- this._framesAnimation = this._framesAnimationSave[0];
- this._framesAnimation2 = this._framesAnimationSave[1];
- };
- Sprite_IconsMap.prototype.updateAnimation = function () {
- if (this._framesAnimation2 > 0) {
- this.scale.x += 0.0020;
- this.scale.y += 0.0020;
- return this._framesAnimation2--;
- }
- if (this._framesAnimation > 0) {
- if (this.scale.x > this._minIconScaleX) this.scale.x -= 0.0020;
- if (this.scale.x > this._minIconScaleX) this.scale.y -= 0.0020;
- this._framesAnimation--;
- } else {
- this.resetAllFramesAnimation();
- }
- };
- //-----------------------------------------------------------------------------
- // Game_Variables
- //
- // The game object class for variables.
- Game_Variables.prototype.getTextIcon = function (paste, json, lineVariable) {
- return GS.Language.getText(paste, json, lineVariable);
- };
- //-----------------------------------------------------------------------------
- // ImageManager
- //
- // The static class that loads images, creates bitmap objects and retains them.
- ImageManager.loadMapaMundi = function (filename, hue) {
- return this.loadBitmap('img/system/MapaMundi/', filename, hue, false);
- };
- //-----------------------------------------------------------------------------
- // Game_Map
- //
- // The game object class for a map. It contains scrolling and passage
- // determination functions.
- var gameMapUpdate = Game_Map.prototype.update;
- Game_Map.prototype.update = function (sceneActive) {
- gameMapUpdate.apply(this, arguments);
- if (SRD_CameraCore) {
- this.updateMoveMapaMundi();
- }
- this.updateMenuUser();
- this.keyBoardMapaMundi();
- this.updateCancelIconsMapaMundi();
- };
- Game_Map.prototype.updateMenuUser = function () {
- if ($gameSystem.callMenuMapaMundi()) {
- if (this._menuUserFrame === undefined) this._menuUserFrame = 0;
- if (this._menuUserFrame < 10) {
- this._menuUserFrame++;
- } else {
- this._menuUserFrame = 0;
- $gameSystem.disableCallMenuMapaMundi();
- var menu = $gameSystem.saveMenuEnabled();
- if (menu) $gameSystem.enableMenu();
- }
- }
- };
- Game_Map.prototype.updateMoveMapaMundi = function () {
- if ($gameSystem.mapaMundi()) {
- if (this._timerInputCamera > 0) {
- this._timerInputCamera--;
- } else {
- this._timerInputCamera = 5;
- if (Input.isPressed('up')) {
- this.moveMapaMundi('up');
- }
- if (Input.isPressed('down')) {
- this.moveMapaMundi('down');
- }
- if (Input.isPressed('right')) {
- this.moveMapaMundi('right');
- }
- if (Input.isPressed('left')) {
- this.moveMapaMundi('left');
- }
- }
- }
- };
- Game_Map.prototype.moveMapaMundi = function (position) {
- switch (position) {
- case 'down':
- this.moveMapaMundiExe(position, true, function () {
- let shiftCameraSpeed = $gameSystem.mapMoveInfo('Move Speed');
- $gameMap._shiftCameraMapaMundiY += Math.ceil(Math.pow(Math.log(Math.floor(shiftCameraSpeed)), shiftCameraSpeed));
- let shiftCameraVelocity = Math.floor(Math.abs(shiftCameraSpeed * $gameMap._shiftCameraMapaMundiY) * Math.floor(shiftCameraSpeed));
- $gameMap.shiftCameraPosition($gameMap._shiftCameraMapaMundiX, $gameMap._shiftCameraMapaMundiY, (shiftCameraVelocity / 2));
- });
- break;
- case 'up':
- this.moveMapaMundiExe(position, true, function () {
- let shiftCameraSpeed = $gameSystem.mapMoveInfo('Move Speed');
- $gameMap._shiftCameraMapaMundiY -= Math.ceil(Math.pow(Math.log(Math.floor(shiftCameraSpeed)), shiftCameraSpeed));
- let shiftCameraVelocity = Math.floor(Math.abs(shiftCameraSpeed * $gameMap._shiftCameraMapaMundiY) * Math.floor(shiftCameraSpeed));
- $gameMap.shiftCameraPosition($gameMap._shiftCameraMapaMundiX, $gameMap._shiftCameraMapaMundiY, (shiftCameraVelocity / 2));
- });
- break;
- case 'right':
- this.moveMapaMundiExe(position, false, function () {
- let shiftCameraSpeed = $gameSystem.mapMoveInfo('Move Speed');
- $gameMap._shiftCameraMapaMundiX += Math.ceil(Math.pow(Math.log(Math.floor(shiftCameraSpeed)), shiftCameraSpeed));
- let shiftCameraVelocity = Math.floor(Math.abs(shiftCameraSpeed * $gameMap._shiftCameraMapaMundiX) * Math.floor(shiftCameraSpeed));
- $gameMap.shiftCameraPosition($gameMap._shiftCameraMapaMundiX, $gameMap._shiftCameraMapaMundiY, (shiftCameraVelocity / 2));
- });
- break;
- case 'left':
- this.moveMapaMundiExe(position, false, function () {
- let shiftCameraSpeed = $gameSystem.mapMoveInfo('Move Speed');
- $gameMap._shiftCameraMapaMundiX -= Math.ceil(Math.pow(Math.log(Math.floor(shiftCameraSpeed)), shiftCameraSpeed));
- let shiftCameraVelocity = Math.floor(Math.abs(shiftCameraSpeed * $gameMap._shiftCameraMapaMundiX) * Math.floor(shiftCameraSpeed));
- $gameMap.shiftCameraPosition($gameMap._shiftCameraMapaMundiX, $gameMap._shiftCameraMapaMundiY, (shiftCameraVelocity / 2));
- });
- break;
- }
- };
- Game_Map.prototype.moveMapaMundiExe = function (position, Xy, callback) {
- var limit_type = $gameSystem.mapMoveInfo('Move Camera');
- if (limit_type === 'automatic') {
- if (position == 'down') var displayEnd = Math.floor($gameMap.height() - $gameMap.screenTileY());
- if (position == 'up') var displayEnd = 0;
- if (position == 'right') var displayEnd = Math.floor($gameMap.width() - $gameMap.screenTileX());
- if (position == 'left') var displayEnd = 0;
- } else if (limit_type === 'number') {
- if (position == 'down') var displayEnd = $gameSystem.mapMoveInfo('Limit (Y+)');
- if (position == 'up') var displayEnd = $gameSystem.mapMoveInfo('Limit (Y-)');
- if (position == 'right') var displayEnd = $gameSystem.mapMoveInfo('Limit (X+)');
- if (position == 'left') var displayEnd = $gameSystem.mapMoveInfo('Limit (X-)');
- }
- var limit = displayEnd;
- if (Xy) {
- var display = Math.floor(this.displayY());
- } else {
- var display = Math.floor(this.displayX());
- }
- if (position == 'down' || position == 'right') {
- if (display < limit) {
- callback();
- }
- }
- if (position == 'up' || position == 'left') {
- if (display > limit) {
- callback();
- }
- }
- };
- Game_Map.prototype.playerPrivateZoomMapaMundi = function () {
- var privateType = $gameSystem.mapPrivateZoomInfo('Private Type');
- if (privateType === 'Disabled') return;
- var playerX = $gamePlayer._realX;
- var playerY = $gamePlayer._realY;
- if (privateType === 'Region') {
- var privateRegion = $gameSystem.mapPrivateZoomInfo('Region ID');
- if (this.regionId(playerX, playerY) == privateRegion) {
- return true;
- }
- } else {
- var privateX = $gameSystem.mapPrivateZoomInfo('Point (X)');
- var privateEndX = $gameSystem.mapPrivateZoomInfo('Point End (X)');
- var privateY = $gameSystem.mapPrivateZoomInfo('Point (Y)');
- var privateEndY = $gameSystem.mapPrivateZoomInfo('Point End (Y)');
- if (playerX >= privateX && playerX <= privateEndX) {
- if (playerY >= privateY && playerY <= privateEndY) {
- return true;
- }
- }
- }
- return false;
- };
- Game_Map.prototype.keyBoardMapaMundi = function () {
- if (!$gameSystem.mapaMundi()) {
- var Keyboard = $gameSystem.mapZoomInfo('Keyboard (open)');
- var KeyName = $gameSystem.mapZoomInfo('KeyName (open)');
- var KeyName_Advanced = $gameSystem.mapZoomInfo('KeyName (open) (Advanced)');
- if (Keyboard) {
- var key;
- if (KeyName === 'advanced') {
- key = KeyName_Advanced.toString();
- } else {
- key = KeyName.toString();
- }
- if (Input.isTriggered(key)) {
- $gameSystem.startMapaMundi();
- }
- }
- } else {
- var Keyboard = $gameSystem.mapZoomInfo('Keyboard (close)');
- var KeyName = $gameSystem.mapZoomInfo('KeyName (close)');
- var KeyName_Advanced = $gameSystem.mapZoomInfo('KeyName (close) (Advanced)');
- if (Keyboard) {
- var key;
- if (KeyName === 'advanced') {
- key = KeyName_Advanced.toString();
- } else {
- key = KeyName.toString();
- }
- if (Input.isTriggered(key)) {
- $gameSystem.stopMapaMundi();
- }
- }
- }
- };
- Game_Map.prototype.updateCancelIconsMapaMundi = function () {
- if ($gameSystem.cancelIconsMapaMundi()) {
- var length = $gameSystem._tileMapSprites.length;
- for (var i = 0; i < length; i++) {
- if ($gameSystem._tileMapSprites[i].spriteOpacity()) {
- $gameSystem._tileMapSprites[i].spriteOpacitySet(false);
- }
- if ($gameSystem._tileMapSprites[i].opacity > 0) {
- $gameSystem._tileMapSprites[i].opacity -= 4;
- } else {
- SceneManager._scene._spriteset._tilemap.removeChild($gameSystem._tileMapSprites[i]);
- }
- }
- }
- };
- })(GS.mapaMundi);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement