Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=======================================================================
- // Map/Compass HUD (RMMV) v1.0
- //=======================================================================
- // * The Map/Compass HUD displays a window on the map showing the map
- // name and player coordinates.
- //
- // This was originally created for the first "Paranormality" game for
- // RMXP, which was then ported over to RMVX (mainly to see if I could
- // do it). When development on "Otherworld" officially transferred to
- // RMVXA, the script was also converted to RGSS3.
- //
- // After the decision to migrate "Otherworld" to RMMV was made, it
- // naturally followed that the main scripts would also need to be
- // converted to JGSS.
- //
- // * © 2014-2016, Companion Wulf
- //
- //========================================================================
- // CW_MapCompassHud.js
- //========================================================================
- var Imported = Imported || {}; Imported.CW_MapCompassHud = true;
- var CWT = CWT || {}; CWT.MapHud = CWT.MapHud || {};
- CWT.Version = 1.0;
- CWT.Build = 11.7;
- CWT.Copyright = '© 2014-2016, Companion Wulf';
- /*:
- @plugindesc Displays a window on the map with map name and player coordinates.
- @author Companion Wulf
- @param Map HUD Default
- @desc Automatically show/hide the map/compass HUD by default.
- @default Show
- @param Map HUD Toggle
- @desc Toggles the map/compass HUD on/off.
- @default On
- @param Map HUD Position
- @desc Sets the map/compass HUD position. TR = Top right; BR = Bottom right; TL = Top left; BL = Bottom left.
- @default TR
- @param Map HUD Opacity
- @desc Sets the opacity of the map/compass HUD.
- @default 160
- @param Show Location
- @desc Show/hide map location. True/false.
- @default true
- @param Unknown Location
- @desc Text to show if map display name is not defined.
- @default Unknown
- @param Show Coordinates
- @desc Show/hide player coordinates on the map.
- @default true
- @param Show Compass Points
- @desc Show/hide compass cardinal points.
- @default true
- @param Show Compass Icons
- @desc Show/hide icons for compass points.
- @default true
- @param Compass Icon Filename
- @desc The name of the iconset to use for the compass icons.
- @default CompassIconSet
- @help
- --------------------------------------------------------------
- Compass Icons
- --------------------------------------------------------------
- The Map/Compass HUD plugin uses a separate iconset, rather than
- modify the default system one.
- In this case, it's named "CompassIconSet", but you can create
- your own with the four compass points. If you do use your own,
- be sure to change the "Compass Icon Filename" parameter and
- place your file in the "img/system" folder.
- The example iconset I've used can be downloaded here:
- https://goo.gl/qe3Gdn
- --------------------------------------------------------------
- Plugin Commands
- --------------------------------------------------------------
- In the event Plugin Command, use HUD followed by:
- show - Show the map/compass window on the map.
- hide - Hide the map/compass window on the map.
- --------------------------------------------------------------
- Terms & Conditions of Use
- --------------------------------------------------------------
- This plugin is free to use under CC BY-SA 4.0, but please refer to the
- RPG Maker Times blogsite for other details, including commercial use.
- Credit "Companion Wulf" or "RPG Maker Times" if using this plugin in
- your projects.
- */
- /*
- ** STILL TO DO **
- --Add meta map/compass HUD toggle plugin commands
- --Add diagonal directions
- --Dynamic window sizing for disabled elements
- */
- (function() {
- //-----------------------------------------------------------------------------
- // ** System Variables **
- //-----------------------------------------------------------------------------
- // * Version/Copyright
- CWT.MapHud.releaseVersion = function() { return Number(CWT.Version).toFixed(1); };
- CWT.MapHud.buildVersion = function() { return Number(CWT.Build).toFixed(2); };
- CWT.MapHud.copyright = function() { return String(CWT.Copyright); };
- // * Icons Dimensions
- CWT.MapHud.iconWidth = 32;
- CWT.MapHud.iconHeight = 32;
- //-----------------------------------------------------------------------------
- // ** Parameters **
- //-----------------------------------------------------------------------------
- CWT.parameters = PluginManager.parameters('CW_MapCompassHud');
- CWT.mapHudDefault = String(CWT.parameters['Map HUD Default'] || 'Show');
- CWT.mapHudToggle = String(CWT.parameters['Map HUD Toggle'] || 'On');
- CWT.mapHudPosition = String(CWT.parameters['Map HUD Position'] || 'TR');
- CWT.mapHudOpacity = Number(CWT.parameters['Map HUD Opacity'] || 160);
- CWT.showMapLocation = String(CWT.parameters['Show Location'] || 'True');
- CWT.unknownLocation = String(CWT.parameters['Unknown Location'] || 'Unknown');
- CWT.showCoordinates = String(CWT.parameters['Show Coordinates'] || 'True');
- CWT.showCompass = String(CWT.parameters['Show Coordinates'] || 'True');
- CWT.showCompassIcons = String(CWT.parameters['Show Compass Icons'] || 'True');
- CWT.compassIconsFiles = String(CWT.parameters['Compass Icon Filename'] || 'CompassIconSet');
- //-----------------------------------------------------------------------------
- // ** Parameters Variables **
- //-----------------------------------------------------------------------------
- // * Map Variables
- CWT.MapHud._mapHudWindowShow = CWT.mapHudDefault;
- //-----------------------------------------------------------------------------
- // ** Plugin Manager **
- //-----------------------------------------------------------------------------
- CWT.MapHud.GameInterpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
- Game_Interpreter.prototype.pluginCommand = function(command, args) {
- CWT.MapHud.GameInterpreter_pluginCommand.apply(this);
- if (command.toUpperCase() === 'HUD') {
- switch(args[0]) {
- case 'show':
- CWT.MapHud._mapHudWindowShow = true;
- break;
- case 'hide':
- CWT.MapHud._mapHudWindowShow = false;
- break;
- }
- }
- };
- //-----------------------------------------------------------------------------
- // ** Scene_Map **
- //-----------------------------------------------------------------------------
- // * Initialize
- CWT.MapHud.CW_SceneMap_start = Scene_Map.prototype.start;
- Scene_Map.prototype.start = function() {
- CWT.MapHud.CW_SceneMap_start.call(this);
- this.createHudWindow();
- };
- // * Update
- CWT.MapHud.CW_SceneMap_update = Scene_Map.prototype.update;
- Scene_Map.prototype.update = function() {
- CWT.MapHud.CW_SceneMap_update.call(this);
- CWT.MapHud._mapHudWindowShow ? this._mapHudWindow.show() : this._mapHudWindow.hide();
- this._mapHudWindow.refresh();
- };
- // * Create Hud Window
- Scene_Map.prototype.createHudWindow = function() {
- switch (CWT.mapHudPosition.toUpperCase()) {
- case 'TL': var x = 5; var y = 5; break;
- case 'BL': var x = 5; var y = 476; break;
- case 'TR': var x = 631; var y = 5; break;
- case 'BR': var x = 631; var y = 476; break;
- };
- this._mapHudWindow = new Window_MapHud(x, y);
- this._mapHudWindow.opacity = CWT.mapHudOpacity;
- this.addChild(this._mapHudWindow);
- };
- //-----------------------------------------------------------------------------
- // ** Window_MapHud **
- //-----------------------------------------------------------------------------
- function Window_MapHud() {
- this.initialize.apply(this, arguments);
- }
- Window_MapHud.prototype = Object.create(Window_Base.prototype);
- Window_MapHud.prototype.constructor = Window_MapHud;
- // * Initialize
- Window_MapHud.prototype.initialize = function(x, y) {
- var width = this.windowWidth();
- var height = this.windowHeight();
- Window_Base.prototype.initialize.call(this, x, y, width, height);
- this.opacity = CWT.mapHudOpacity;
- this.refresh();
- };
- // * Window Width
- Window_MapHud.prototype.windowWidth = function() {
- return 180;
- };
- // * Window Height
- Window_MapHud.prototype.windowHeight = function() {
- return this.fittingHeight(3);
- };
- // * Window Refresh
- Window_MapHud.prototype.refresh = function() {
- if (!$gamePlayer.isMoving()) $gameMap.refreshIfNeeded();
- this.contents.fontSize = 13;
- var x = this.textPadding(); var y = 0;
- var lh = this.lineHeight()/2;
- var width = this.windowWidth - (this.contents.width - this.textPadding() * 2);
- var height = this.windowHeight - this.contents.height;
- this.contents.clear();
- // * Show Map Location
- if (CWT.showMapLocation.toUpperCase() == 'TRUE') {
- this.drawText('Location:', x, y, width, height);
- this.changeTextColor('lightblue');
- this.drawText($gameMap.displayName() || CWT.unknownLocation, x+60, y, width, height);
- this.resetTextColor();
- var y = y + lh * 2;
- };
- // * Show Compass Points
- if (CWT.showCompass.toUpperCase() == 'TRUE') {
- var _iconIndex = 0;
- switch($gamePlayer._direction) {
- case 2:
- var direction = 'South';
- var _iconIndex = 4;
- break;
- case 4:
- var direction = 'West';
- var _iconIndex = 3;
- break;
- case 6:
- var direction = 'East';
- var _iconIndex = 2;
- break;
- case 8:
- var direction = 'North';
- var _iconIndex = 1;
- break;
- };
- this.drawCompassIcon(_iconIndex, 0, 32);
- this.drawText(direction, x+50, y, width, height);
- var y = y + lh * 2;
- };
- // * Show Coordinates
- if (CWT.showCoordinates.toUpperCase() == 'TRUE') {
- this.drawText('X:', x, y, width, height);
- this.drawText('Y:', x+60, y, width, height);
- this.changeTextColor('lightblue');
- this.drawText($gamePlayer.x, x+16, y, width, height);
- this.drawText($gamePlayer.y, x+76, y, width, height);
- this.resetTextColor();
- };
- };
- Window_MapHud.prototype.drawCompassIcon = function(iconIndex, x, y) {
- var bitmap = ImageManager.loadSystem(CWT.compassIconsFiles);
- var iw = CWT.MapHud.iconWidth;
- var ih = CWT.MapHud.iconHeight;
- var ix = iconIndex % 16 * iw;
- var iy = Math.floor(iconIndex / 16) * ih;
- this.contents.blt(bitmap, ix, iy, iw, ih, x, y);
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement