Advertisement
Guest User

Untitled

a guest
Dec 30th, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // SilvMinimap.js
  3. // Version: 1.10
  4. // Requires plugin: SilvKeys (place this one below it)
  5. //=============================================================================
  6. /*:
  7.  * @plugindesc v1.10 Minimap. <SilvMinimap>
  8.  * @author Silver
  9.  * @param -- General --
  10.  *
  11.  * @param Map Style
  12.  * @desc Is the minimap scaled to fit? Or does it zoom and scroll? Autofit/Scroll
  13.  * @default Scroll
  14.  *
  15.  * @param Global Map Zoom
  16.  * @desc Only applies if MapStyle is set to: Scroll. Determines the default zoom level for all maps. A value of 1 means 1:1.
  17.  * @default 0.25
  18.  *
  19.  * @param Minimap Opacity
  20.  * @desc 0 = invisible, 255 = fully opaque.
  21.  * @default 255
  22.  *
  23.  * @param -- Positioning & Size --
  24.  *
  25.  * @param X
  26.  * @desc x-location of minimap window. If window-alignment is set to Right, this will act as an offset value instead
  27.  * @default -2
  28.  *
  29.  * @param Y
  30.  * @desc y-location of minimap window. If window-alignment is set to Top, this will act as an offset value instead
  31.  * @default 2
  32.  *
  33.  * @param Horizontal Alignment
  34.  * @desc Left/Right
  35.  * @default Right
  36.  *
  37.  * @param Vertical Alignment
  38.  * @desc Top/Bottom
  39.  * @default Bottom
  40.  *
  41.  * @param Width
  42.  * @desc width of the minimap
  43.  * @default 320
  44.  *
  45.  * @param Height
  46.  * @desc height of the minimap
  47.  * @default 320
  48.  *
  49.  * @param Border Width
  50.  * @desc Border width of the minimap
  51.  * @default 12
  52.  *
  53.  * @param Border Height
  54.  * @desc Border height of the minimap
  55.  * @default 12
  56.  *
  57.  * @param -- Player Blip --
  58.  *
  59.  * @param Render Player Blip
  60.  * @desc Render the player blip in the minimap (=usually the center icon)? true/false
  61.  * @default true
  62.  *
  63.  * @param Player Blip Graphic
  64.  * @desc Name of the image (in /img/minimap/) to use as the blip. or use :player to use the realtime-player-graphic.
  65.  * @default :player
  66.  *
  67.  * @param Player Icon Width
  68.  * @desc Standard Window Padding
  69.  * @default 16
  70.  *
  71.  * @param Player Icon Height
  72.  * @desc Standard Window Padding
  73.  * @default 16
  74.  *
  75.  * @param Player Blink Delay
  76.  * @desc Blinks the player icon (in frames). Set to 0 to disable. Does nothing if "Draw Player Icon" is set to false
  77.  * @default 0
  78.  *
  79.  * @param -- Menu --
  80.  *
  81.  * @param Menu Key
  82.  * @desc The key used to show the map-menu. Use none to disable.
  83.  * @default m
  84.  *
  85.  * @param Menu Player Description
  86.  * @desc The description of the player marker in the menu. Spaces are allowed.
  87.  * @default You
  88.  *
  89.  * @param Menu Zoom
  90.  * @desc Map Zoomlevel for the menu
  91.  * @default 0.3. A value of 1 means 1:1
  92.  *
  93.  * @param Menu Left Window Width
  94.  * @desc Width of the left window
  95.  * @default 240
  96.  *
  97.  * @param Menu Topright Window Height
  98.  * @desc Height of the topright window
  99.  * @default 510
  100.  *
  101.  * @param Menu Event Render Size
  102.  * @desc How big the events are that are drawn onto the menu map
  103.  * @default 24
  104.  *
  105.  * @param Menu Player Icon Size
  106.  * @desc How big the player is drawn onto the menu map
  107.  * @default 64
  108.  *
  109.  * @param Menu Min Manual Zoom
  110.  * @desc How far the player can zoom out
  111.  * @default 0.20
  112.  *
  113.  * @param Menu Max Manual Zoom
  114.  * @desc How far the player can zoom in
  115.  * @default 10.0
  116.  *
  117.  * @param Menu Zoomin Key
  118.  * @desc Key for zooming in. 33 = pageup
  119.  * @default pageup
  120.  *
  121.  * @param Menu Zoomout Key
  122.  * @desc Key for zooming out. 34 = pagedown
  123.  * @default pagedown
  124.  *
  125.  * @param Menu Reset Zoom Key
  126.  * @desc Key for resetting the zoom. 36 = home
  127.  * @default home
  128.  *
  129.  * @param Menu Reset Scroll Key
  130.  * @desc Key to reset the mapscroll
  131.  * @default end
  132.  *
  133.  * @param -- Passability Map --
  134.  *
  135.  * @param Passability Overlay Opacity
  136.  * @desc 0 = invisible, 255 = fully opaque. 0-255
  137.  * @default 128
  138.  *
  139.  * @param Passability Color
  140.  * @desc Color for walkable tiles
  141.  * @default #6B8E23
  142.  *
  143.  * @param Impassability Color
  144.  * @desc Color for unwalkable tiles
  145.  * @default #FF0000
  146.  *
  147.  * @param -- Map Generator --
  148.  *
  149.  * @param Map Gen Tag Colors
  150.  * @desc 0-7, use a ####### value to ignore that terrain-tag. Default: lightgreen, blue, brown, darkgreen, lightbrown
  151.  * @default #6B8E23 #00008B #8B4513 #006400 #F4A460 ####### ####### #FFFFFF
  152.  *
  153.  * @param Overworld Gen Tag Colors
  154.  * @desc 0-7, use a ####### value to ignore that terrain-tag. Default: lightgreen, blue, brown, darkgreen, lightbrown
  155.  * @default #6B8E23 #00008B #8B4513 #006400 #F4A460 ####### ####### #FFFFFF
  156.  *
  157.  * @param -- The rest --
  158.  *
  159.  * @param Allow Teleportation
  160.  * @desc By default, allow teleportation to events/poi's that support it? true/false
  161.  * @default true
  162.  *
  163.  * @param Standard Padding
  164.  * @desc Standard Window Padding. Best to leave at 0
  165.  * @default 0
  166.  *
  167.  * @param Window Skin
  168.  * @desc Name of the window skin to use for this window
  169.  * @default Window_Minimap
  170.  *
  171.  * @param Fill Color
  172.  * @desc Color to fill the background of the minimap with for 'odd aspect ratios'. Use 0 0 0 0 to disable. R G B A.
  173.  * @default 0 0 0 255
  174.  *
  175.  * @param Maintain Aspect Ratio
  176.  * @desc Maintains minimap aspect ratio if set to true. true/false
  177.  * @default true
  178.  *
  179.  * @param Fadeout Speed
  180.  * @desc How fast the minimap fades out
  181.  * @default 3
  182.  *
  183.  * @param Global Required Item
  184.  * @desc Item ID of the item that the player must have in their INVENTORY for any map to be displayed. Requires map to be reloaded if item is acquired or call the plugin command "Minimap Refresh" (w/o quotes). A value of 0 disables this
  185.  * @default 0
  186.  *
  187.  * @param Event Render Size
  188.  * @desc How big the events are that are drawn onto the minimap
  189.  * @default 16
  190.  *
  191.  * @param Auto Clear POI
  192.  * @desc Automatically clear POI's between map transfers? true/false
  193.  * @default false
  194.  *
  195.  * @param Render Minimap Overlay
  196.  * @desc If enabled, add the image: /img/Minimap/Overlay.png and it will be drawn on top of the minimap. true/false
  197.  * @default true
  198.  *
  199.  * @param -- Manual Scrolling --
  200.  *
  201.  * @param Allow Manual Scrolling
  202.  * @desc true/false
  203.  * @default true
  204.  *
  205.  * @param Manual Scrollspeed
  206.  * @desc How fast the map is scrolled
  207.  * @default 24
  208.  *
  209.  * @param Manual Scroll Key Up
  210.  * @desc Key for scrolling the map upwards. Default: u  http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes
  211.  * @default u
  212.  *
  213.  * @param Manual Scroll Key Right
  214.  * @desc Key for scrolling the map upwards. Default: k
  215.  * @default k
  216.  *
  217.  * @param Manual Scroll Key Down
  218.  * @desc Key for scrolling the map upwards. Default: j
  219.  * @default j
  220.  *
  221.  * @param Manual Scroll Key Left
  222.  * @desc Key for scrolling the map upwards. Default: h
  223.  * @default h
  224.  *
  225.  * @param -- Advanced & Debug --
  226.  *
  227.  * @param Player Sprite Sourceframe Width
  228.  * @desc Width of the playersprite sourceframe
  229.  * @default 48
  230.  *
  231.  * @param Player Sprite Sourceframe Height
  232.  * @desc Heigth of the playersprite sourceframe
  233.  * @default 48
  234.  *
  235.  * @param Frame Skip
  236.  * @desc Skips some minimap calculations&rendering if set to value > 0 to safe performance. The value equals the amount of frames skipped.
  237.  * @default 0
  238.  *
  239.  * @param Mapshot Filename Length
  240.  * @desc Length of the mapshot filenames. A value of 3 would equal to: 001.png, 002.png, 016.png, etc. And a value of 2 would equal: 01.png, etc. A value of 0 disables it
  241.  * @default 3
  242.  *
  243.  * @param Debug Mode
  244.  * @desc Prints extra info if set to true. true/false
  245.  * @default false
  246.  *
  247.  * @param Render Debug Grid
  248.  * @desc Draws a debug grid. Requires "/img/Minimap/DebugGrid.png" which is 48x48 in size. Drains a lot of performance!
  249.  * @default false
  250.  *
  251.  * @param Debug Grid Image
  252.  * @desc Name of the debug-grid image
  253.  * @default DebugGrid01
  254.  *
  255.  * @help
  256.  * 1. Make a mapshot of your map. You may use http://forums.rpgmakerweb.com/index.php?/topic/49711-orange-mapshot/
  257.  * 2. Install this script: http://pastebin.com/FF6jh3S0 and make sure to put it above the minimap script.
  258.  * 3. Copy the files to:
  259.  * 4. /img/minimap/Overlay.png
  260.  * 5. /img/minimap/DebugGrid01.png
  261.  * 6. /img/system/Window_Minimap.png
  262.  * 7. Place your mapshots in the /img/minimap/ directory and rename them 001.png, 002.png etc. (matching the id of your map)
  263.  *
  264.  * If you prefer to use automatic generated maps instead, use the map-notetags and you then obviously do not require mapshots of course.
  265.  *
  266.  *--------------------------------------
  267.  * Yanfly's Main Menu Manager Setup (optional)
  268.  *--------------------------------------
  269.  *
  270.  * 1. Download & Install YEP_MainMenuManager.js
  271.  * 2. Configure the parameters as follow:
  272.  * Menu Name: "Map"
  273.  * Menu Symbol: silvMap
  274.  * Menu Show: true
  275.  * Menu Enabled: Silv.Minimap.Menu.Enabled
  276.  * Menu Main Bind: this.commandSilvMap.bind(this)
  277.  *
  278.  *--------------------------------------
  279.  * Map notetags (most are case sensitive!)
  280.  *--------------------------------------
  281.  * <mm_req_itm:item_id1 item_id2 etc>
  282.  * Example: <mm_req_itm:1, 2, 3>
  283.  *
  284.  * <mm_mapstyle:Scroll/Autofit>
  285.  * Examples:
  286.  * <mm_mapstyle:Scroll>
  287.  * <mm_mapstyle:AutoFit>
  288.  *
  289.  * <mm_frameskip:value>
  290.  * Example: <mm_frameskip:1>
  291.  * Note: overrides the global frameskip parameter for this map
  292.  *
  293.  * <mm_mapzoom:value>
  294.  * Example: <mm_mapzoom:0.15>
  295.  * Note: overrides the global mapzoom parameter for this map
  296.  *
  297.  * <mm_allowmanualscroll:value>
  298.  * Example: <mm_allowmanualscroll:false>
  299.  * Allowed values: true/false
  300.  * Note: overrides the global "Allow Manual Scrolling" parameter for this map
  301.  *
  302.  * <mm_menuzoom:value>
  303.  * Example: <mm_menuzoom:0.75>
  304.  * Note: overrides the global "Menu Zoom" parameter for this map
  305.  *
  306.  * <mm_size:x y>
  307.  * Example: <mm_size:128 128>
  308.  * Note: overrides the global "Width" and "Height" parameters for this map
  309.  *
  310.  * Allow/disallow teleportation.
  311.  * <mm_tp_allow:value>
  312.  * Example: <mm_tp_allow:false>
  313.  * Note: overrides the global "Allow Teleportation" parameter for this map
  314.  *
  315.  * Generate a worldmap-minimap if there is no image (does increase load-time, the first time, for the map)
  316.  * <mm_generate_worldmap>
  317.  * <mm_generate_overworld>
  318.  *
  319.  * Generate regular map (same as mm_generate_overworld but uses a different parameter-color-generator-tag)
  320.  * <mm_generate_map>
  321.  *
  322.  * Generate and overlay a generated passability-map on top of the minimap
  323.  * <mm_generate_passability_overlay>
  324.  *
  325.  * Change the player-blip
  326.  * <mm_player_blip:value>
  327.  * Example to use the realtime player graphic:
  328.  * <mm_player_blip::player>
  329.  * Example to use a custom blip graphic:
  330.  * <mm_player_blip:myCustomPlayerBlip>
  331.  * Note that in the above example, the game requires the image /img/minimap/myCustomPlayerBlip.png"
  332.  *
  333.  * Use another map's mapshot (handy for duplicate maps)
  334.  * <mm_mapshot:map_id>
  335.  * Example: <mm_mapshot:2>
  336.  * Note: leading zero's are optional but not required.
  337.  *
  338.  * To use a different map-image for the map-scene:
  339.  * <mm_menu_bg:imageName>
  340.  * Example: <mm_menu_bg:myFantasticMap>
  341.  * Note1: Must be in png-format
  342.  * Note2: Must be placed in the same folder that also stores the mapshots
  343.  * Note3: If the size differs from the real mapshot (or generated map) then positioning of objects like the player-location may occur. So respect the original size!
  344.  *
  345.  *--------------------------------------
  346.  * Event notetags (not case sensitive)
  347.  *--------------------------------------
  348.  * mm_show
  349.  *
  350.  *--------------------------------------
  351.  * Plugin Commands (not case-sensitive)
  352.  *--------------------------------------
  353.  * Minimap Hide
  354.  * Minimap Show
  355.  * Minimap FadeOut
  356.  * Minimap FadeReset
  357.  * Minimap Refresh
  358.  * Minimap RefreshEvents
  359.  * Minimap IncreaseScroll <x> <y>
  360.  * Minimap SetScroll <x> <y>
  361.  * Minimap DeletePOI <poi_id>
  362.  * Minimap Generate_Passability_Overlay <true/false>
  363.  * Minimap Gen_Pass_Ov <true/false>
  364.  * Minimap ShowMapMenu
  365.  * Minimap SetPlayerBlip <filename/:player>
  366.  *
  367.  * Minimap SetFollowTarget <type> <value>
  368.  * Minimap setcamera <type> <value>
  369.  * Allowed types: player, event, coordinate
  370.  * Note: the player-type has no value parameter.
  371.  * Examples:
  372.  * Minimap SetFollowTarget player
  373.  * Minimap SetFollowTarget event 1
  374.  * Minimap SetFollowTarget coordinate 10 20
  375.  *
  376.  * Minimap POIDesc <description>
  377.  * Example: Minimap POIDesc An Awesome City!
  378.  *
  379.  * Minimap POI_TP <poi_id x_offset y_offset direction fadeType>
  380.  * Example: Minimap POI_TP 1 1 0 0 0
  381.  * Note that teleporting with both offsets set to 0, will teleport the player straight into the center of the poi.
  382.  *
  383.  * Adding POI's (advanced plugin command!):
  384.  * Minimap AddPOI unique_poi_id, name, real_x, real_y, bitmap folder, bitmap filename, s_x, s_y, s_w, s_h, draw_w, draw_h
  385.  * Example that draws Actor1_3 on tile 10,10:
  386.  * Minimap AddPOI 1 A_Friend 10 10 img/enemies/ Actor1_3 0 0 254 225 64 64
  387.  * Note:
  388.  * - The real_x & real_y are in maptiles and not in coordinates. 0,0 is in the upper left corner.
  389.  * - name-value replaces underscores _  with spaces.
  390.  *
  391.  
  392.  *
  393.  *--------------------------------------
  394.  * Event comment-tags (case sentitive!)
  395.  *--------------------------------------
  396.  * To show an event on the minimap:
  397.  * <mm_show>
  398.  *
  399.  * To add a description to an event (for the minimap-scene)
  400.  * <mm_desc>
  401.  *
  402.  * To add teleport to the event:
  403.  * <mm_tp:offset_x offset_y direction fadeType>
  404.  * Example: <mm_tp:1 0 2 0>
  405.  * Notes:
  406.  *        - Offset is the offset in tiles with the event-location itself being 0 0
  407.  *        - Possible direction values: 2 (down), 4 (left), 6 (right), 8 (up). Or use a value of 0 to maintain the current player-facing-direction
  408.  *        - Possible fadeType values: 0 (black), 1 (white), 2 (none)
  409.  *
  410.  *
  411.  * Note to other scripters: You can access the variable that contains the window through this: "Silv.Minimap.Window" w/o the quotes.
  412.  *
  413.  *
  414.  *--------------------------------------
  415.  * #Version History:
  416.  *--------------------------------------
  417.  * v 1.10 (30 December 2015)
  418.  *   - Added the requested option to use a custom map-scene-image that is different from the actual map displayed in the minimap.
  419.  *   - Added a new mapnotetag: <mm_menu_bg:customImageName>
  420.  *
  421.  * v.1.09 (27 December 2015)
  422.  *   - Fixed a crash that occurred when events (other than the last one) were deleted (in the map-editor) leaving behind null-values in the $dataMap.
  423.  *   - Renamed the plugin-command alias (before, there was a possible compatibility issue with some of my other scripts).
  424.  *   - Minor refactoring again and applied my new coding standards. Aliases are now stored outside of the anonymous function in a single variable.
  425.  *
  426.  * v.1.08 (22 December 2015)
  427.  *   - Fixed a crash when getting onto a vehicle in the overworld when no minimap was active (line 1099) and when getting off a vehicle.
  428.  *   - Improved error reporting
  429.  *   - Switched to the Imported-variable. Thus this plugin now requires Silvers Key plugin 1.02!
  430.  *
  431.  * v.1.07 (12 December 2015)
  432.  *   - New feature: Automatically shows vehicles on the minimap as the playerblip when entering a vehicle. Only applies if "Player Blip Graphic" is set to :player .
  433.  *   - Fixed a crash when generating an overworld map without a minimap-image and with the passability-overlay enabled.
  434.  *   - Is now compatible with dynamic map/dungeon generators. You can now recreate the minimap by calling: Silv.Minimap.setup(); after generating your random map.
  435.  *
  436.  * v.1.06 (06 December 2015)
  437.  *   - This plugin is now compatible with Yanfly's "Main Menu Manager" plugin. It also automatically disables (or even hides if you want) the map-menu-command if
  438.  *     you do not have an active minimap or simply do not possess the required items.
  439.  *   - Added a new mapnotetag: <mm_mapshot:map_id>. This one is used to display a mapshot from a different map in the current map. Handy in case you have duplicate maps
  440.  *     to prevent ending up with duplicate minimap images in your project folder.
  441.  *   - Removed a console.log() that I forgot to remove in 1.05 before release.
  442.  *
  443.  * v.1.05 (30 November 2015)
  444.  *   - I accidentally had some global variables declared above the window-initialization, I made them local now to save memory and to prevent incompatibility issues with other scripts.
  445.  *   - Fixed a crash when fading the scene without an active minimap.
  446.  *
  447.  * v.1.04 (27 November 2015) [Updated Parameters]
  448.  *   - Disabled strict-mode (Either Javascript or RPG Maker seems not to support this fully...).
  449.  *   - Fixed a typo that caused the minimap to not resize in height.
  450.  *   - Grouped the player-blink parameters together and removed the unused "Draw Player Icon" parameter (v.1.03 only removed it partially).
  451.  *   - New feature: focus the minimap-camera onto (moving-)events, coordinates or the player.
  452.  *   - Minor refactoring.
  453.  *
  454.  * v.1.03 (26 November 2015) [Updated Parameters]
  455.  *   - New feature: Use custom player blip.
  456.  *     - 2 new parameters: "Render Player Blip" & "Player Blip Graphic" and new mapnotetag: <mm_player_blip::player> and a new plugin parameter "Minimap setplayerblip <value>".
  457.  *     - Removed parameter "Draw Player Icon".
  458.  *   - Added a parameter to change minimap-opacity.
  459.  *   - Added plugin commands and map-notetags to switch between AutoScroll and Autofit map-modes, <mm_mapstyle:Scroll/Autofit>
  460.  *
  461.  * v.1.02 (25 November 2015) [Updated Parameters]
  462.  *   - Enabled strict mode.
  463.  *   - Added the 'Minimap ShowMapMenu' plugin-command.
  464.  *   - New feature: can now generate overworld-minimaps (w/o requiring mapshots) with the map-notetag: <mm_generate_worldmap> or <mm_generate_overworld> or <mm_generate_map>].
  465.  *   - New feature: generate passability overlay. Also comes with new map-notetag & plugin command. Supports 4-direction-passability.
  466.  *   - New feature: You can now (optional) open the minimap-menu through a keybinding and also close it with that same keybinding (if the left-menu is active).
  467.  *   - Fixed the minimap-visibility again (it was still not properly fixed in v1.01).
  468.  *   - Now requires Silvers Keybinding script 1.01 instead of 1.00.
  469.  *
  470.  * v.1.01 (24 November 2015) [Updated Parameters]
  471.  *   - Fixed the player-blip becoming invisible when walking on grass. Because of this I had to add 2 more advanced parameters.
  472.  *   - Fixed: The minimap no longer automatically shows itself again when it was manually hidden after opening a menu.
  473.  *   - Updated the version number to 1.01 (it was still 0.91) in the plugin description.
  474.  *   - Cleaned up some more out-commented code.
  475.  *   - Fixed: minimap can now hide again when it contains POI's.
  476.  *   - Fixed a bug that would not 'dispose' the minimap-window when getting rid of a minimap within a scene because the Scene_Map still had a references in it's children to the map. This also increases performance.
  477.  *
  478.  * v1.00 (23 November 2015)
  479.  *   - First release.
  480.  *
  481.  * v0.90-0.92 (November 2015)
  482.  *   - First alpha release.
  483.  *
  484.  */
  485. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  486. // Script start
  487. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  488. // Imported
  489. var Imported = Imported || {};
  490. Imported.SILV_Minimap = 1.10;
  491.  
  492. // Dependency check
  493. if (!('SILV_Keys' in Imported) || Imported.SILV_Keys < 1.02) { throw new Error('ERROR: Silvers Minimap requires Silvers KeyMapper v1.02 or higher. It must be placed above the minimap script.'); }
  494.  
  495. // Get Plugin #Parameters
  496. var Silv = Silv || {};
  497. Silv.Parameters = $plugins.filter(function(p) { return p.description.contains('<SilvMinimap>'); })[0].parameters;
  498. Silv.Minimap = Silv.Minimap || {};
  499. Silv.Minimap.Menu = Silv.Minimap.Menu || {};
  500. Silv.Minimap.Generator = Silv.Minimap.Generator || {};
  501. // Non-parameters
  502. Silv.Minimap.Window = null;
  503. Silv.Minimap.POI = {};
  504. Silv.Minimap.Events = []; // Is an array of objects [{ Game_Event, Sprite_Character }]. USe .event and .sprite to retrieve the values.
  505. Silv.Minimap.ScreenIsFading = false;
  506. Silv.Minimap.Menu.Bmp = null;
  507. Silv.Minimap.Menu.Markers = [];
  508. Silv.Minimap.Menu.Enabled = false;
  509. Silv.Minimap.WasLoadedFromSave = false;
  510. Silv.Minimap.LastMapID = -1; // To detect when a different map is loaded. Because loading the menu-scene for example will reload the entire map again and also recreate the minimap, but we don't want to erase the POI's and such then.
  511. Silv.Minimap.TP_Dest = null;
  512. Silv.Minimap.CreateFunctionIsLocked = false;
  513. Silv.Minimap.Visible = true;
  514. // General
  515. Silv.Minimap.MapStyle = Silv.Parameters['Map Style'].toLowerCase();
  516. Silv.Minimap.GlobalMapZoom = parseFloat(Silv.Parameters['Global Map Zoom']);
  517. Silv.Minimap.Window_Opacity = parseInt(Silv.Parameters['Minimap Opacity']);
  518. // Positioning & Size
  519. Silv.Minimap.Window_X = parseInt(Silv.Parameters['X']);
  520. Silv.Minimap.Window_Y = parseInt(Silv.Parameters['Y']);
  521. Silv.Minimap.WindowWidth = parseInt(Silv.Parameters['Width']);
  522. Silv.Minimap.WindowHeight = parseInt(Silv.Parameters['Height']);
  523. Silv.Minimap.BorderWidth = parseInt(Silv.Parameters['Border Width']);
  524. Silv.Minimap.BorderHeight = parseInt(Silv.Parameters['Border Height']);
  525. Silv.Minimap.WindowHorizontalAlignment = Silv.Parameters['Horizontal Alignment'].toLowerCase();
  526. Silv.Minimap.WindowVerticalAlignment = Silv.Parameters['Vertical Alignment'].toLowerCase();
  527. // Player Blip
  528. Silv.Minimap.PlayerBlipEnabled = Silv.Parameters['Render Player Blip'].toLowerCase() === 'true';
  529. Silv.Minimap.PlayerBlipGraphic = Silv.Parameters['Player Blip Graphic'].toLowerCase();
  530. Silv.Minimap.PlayerIconWidth = parseInt(Silv.Parameters['Player Icon Width']);
  531. Silv.Minimap.PlayerIconHeight = parseInt(Silv.Parameters['Player Icon Height']);
  532. Silv.Minimap.PlayerBlinks = parseInt(Silv.Parameters['Player Blink Delay']) > 0; // note: is not directly a parameter but uses one to calculate the value instead
  533. Silv.Minimap.PlayerBlinkDelay = parseInt(Silv.Parameters['Player Blink Delay']);
  534. // Menu
  535. Silv.Minimap.Menu.MenuKey = Silv.Keys.fromStringParam(Silv.Parameters['Menu Key']);
  536. Silv.Minimap.Menu.PlayerDesc = Silv.Parameters['Menu Player Description'];
  537. Silv.Minimap.Menu.Zoom = parseFloat(Silv.Parameters['Menu Zoom']);
  538. Silv.Minimap.Menu.WindowWidth_Left = parseInt(Silv.Parameters['Menu Left Window Width']);
  539. Silv.Minimap.Menu.WindowHeight_MapSection = parseInt(Silv.Parameters['Menu Topright Window Height']);
  540. Silv.Minimap.Menu.EventRenderSize = parseInt(Silv.Parameters['Menu Event Render Size']);
  541. Silv.Minimap.Menu.PlayerIconSize = parseInt(Silv.Parameters['Menu Player Icon Size']);
  542. Silv.Minimap.Menu.ManualZoom_Min = parseFloat(Silv.Parameters['Menu Min Manual Zoom']);
  543. Silv.Minimap.Menu.ManualZoom_Max = parseFloat(Silv.Parameters['Menu Max Manual Zoom']);
  544. Silv.Minimap.Menu.ManualZoomKey_In = Silv.Keys.fromStringParam(Silv.Parameters['Menu Zoomin Key']);
  545. Silv.Minimap.Menu.ManualZoomKey_Out = Silv.Keys.fromStringParam(Silv.Parameters['Menu Zoomout Key']);
  546. Silv.Minimap.Menu.ManualZoomKey_Reset = Silv.Keys.fromStringParam(Silv.Parameters['Menu Reset Zoom Key']);
  547. Silv.Minimap.Menu.ManualScrollKey_Reset = Silv.Keys.fromStringParam(Silv.Parameters['Menu Reset Scroll Key']);
  548. // Passability Map
  549. Silv.Minimap.PassabilityOverlayOpacity = parseInt(Silv.Parameters['Passability Overlay Opacity']);
  550. Silv.Minimap.PassabilityColor = Silv.Parameters['Passability Color'];
  551. Silv.Minimap.ImpassabilityColor = Silv.Parameters['Impassability Color'];
  552. // Generator
  553. Silv.Minimap.Generator.MapColors = Silv.Parameters['Map Gen Tag Colors'].split(' ');
  554. Silv.Minimap.Generator.OverworldColors = Silv.Parameters['Overworld Gen Tag Colors'].split(' ');
  555. // The Rest
  556. Silv.Minimap.AllowTeleportation = Silv.Parameters['Allow Teleportation'].toLowerCase() === 'true';
  557. Silv.Minimap.StandardPadding = parseInt(Silv.Parameters['Standard Padding']);
  558. Silv.Minimap.WindowSkin = Silv.Parameters['Window Skin'];
  559. Silv.Minimap.MapBGFillColor = Silv.Parameters['Fill Color'].split(' ');
  560. Silv.Minimap.MaintainAspectRatio = Silv.Parameters['Maintain Aspect Ratio'].toLowerCase() === 'true';
  561. Silv.Minimap.FadeoutSpeed = parseInt(Silv.Parameters['Fadeout Speed']);
  562. Silv.Minimap.GlobalRequiredItem = parseInt(Silv.Parameters['Global Required Item']);
  563. Silv.Minimap.EventRenderSize = parseInt(Silv.Parameters['Event Render Size']);
  564. Silv.Minimap.AutoClearPOI = Silv.Parameters['Auto Clear POI'].toLowerCase() === 'true';
  565. Silv.Minimap.DrawOverlay = Silv.Parameters['Render Minimap Overlay'].toLowerCase() === 'true';
  566. // Manual Scrolling
  567. Silv.Minimap.AllowManualScrolling = Silv.Parameters['Allow Manual Scrolling'].toLowerCase() === 'true';
  568. Silv.Minimap.ManualScrollspeed = parseFloat(Silv.Parameters['Manual Scrollspeed']);
  569. Silv.Minimap.ManualScrollKeyUp = Silv.Keys.fromStringParam(Silv.Parameters['Manual Scroll Key Up']);
  570. Silv.Minimap.ManualScrollKeyRight = Silv.Keys.fromStringParam(Silv.Parameters['Manual Scroll Key Right']);
  571. Silv.Minimap.ManualScrollKeyDown = Silv.Keys.fromStringParam(Silv.Parameters['Manual Scroll Key Down']);
  572. Silv.Minimap.ManualScrollKeyLeft = Silv.Keys.fromStringParam(Silv.Parameters['Manual Scroll Key Left']);
  573. // Advanced & Debug
  574. Silv.Minimap.PlayerSpriteSrcFrame_Width = parseInt(Silv.Parameters['Player Sprite Sourceframe Width']);
  575. Silv.Minimap.PlayerSpriteSrcFrame_Height = parseInt(Silv.Parameters['Player Sprite Sourceframe Height']);
  576. Silv.Minimap.FrameSkip = parseInt(Silv.Parameters['Frame Skip']);
  577. Silv.Minimap.MapFilenameLength = parseInt(Silv.Parameters['Mapshot Filename Length']);
  578. Silv.Minimap.DebugMode = Silv.Parameters['Debug Mode'].toLowerCase() === 'true';
  579. Silv.Minimap.DrawDebugGrid = Silv.Parameters['Render Debug Grid'].toLowerCase() === 'true';
  580. Silv.Minimap.DebugGridImage = Silv.Parameters['Debug Grid Image'];
  581.  
  582. // Alias
  583. Silv.Alias = Silv.Alias || {};
  584. if (!Silv.AddAlias)
  585. {
  586.     Silv.AddAlias = function(alias, original_method)
  587.     {
  588.         if (Silv.Alias[alias]) { throw new Error('Alias already exists: ' + alias); }
  589.         Silv.Alias[alias] = original_method;
  590.     };
  591. }
  592.  
  593. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  594. (function()
  595. {
  596. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  597. // #Utilities & Misc
  598. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  599. // Example: lpad('2', '0') // result: '002'
  600. function lpad_mapname(word, padStr)
  601. {
  602.     word = String(word);
  603.     while (word.length < Silv.Minimap.MapFilenameLength) word = padStr + word;
  604.     return word;
  605. }
  606.  
  607. function minimapFolderPath()
  608. {
  609.     var path = window.location.pathname.replace(/(\/www|)\/[^\/]*$/, "/img/minimap/");
  610.     if (path.match(/^\/([A-Z]\:)/)) { path = path.slice(1); }
  611.     path = decodeURIComponent(path);
  612.     return path;
  613. }
  614.  
  615. function getFullMinimapPath(filename)
  616. {
  617.     return minimapFolderPath() + filename;
  618. }
  619.  
  620. // filename example: '002.png'
  621. function minimapImageExists(filename)
  622. {
  623.     var fs = require('fs');
  624.     return fs.existsSync(getFullMinimapPath(filename));
  625. }
  626.  
  627. function dataMapGetEventByID(ev_id)
  628. {
  629.     for(var i=1; i< $dataMap.events.length; i++)
  630.     {
  631.         // $dataMap.events may contain null-values when placing several events in the editor and then deleting an even (other than the last one). Therefore the ($dataMap.events[i] !== null) check is required.
  632.         if (($dataMap.events[i] !== null) && $dataMap.events[i].id == ev_id) { return $dataMap.events[i]; }
  633.     }
  634.     return null;
  635. }
  636.  
  637. ImageManager.loadMinimap = function(filename, hue)
  638. {
  639.     return this.loadBitmap('img/minimap/', filename, hue, false);
  640. };
  641.  
  642. // Do not just show the minimap on top of a faded-out screen.
  643. Silv.AddAlias('mm_Game_Screen_updateFadeOut', Game_Screen.prototype.updateFadeOut);
  644. Game_Screen.prototype.updateFadeOut = function()
  645. {
  646.     Silv.Alias.mm_Game_Screen_updateFadeOut.apply(this, arguments);
  647.    
  648.     if (this._brightness < 255) // (this._fadeOutDuration > 0)
  649.     {
  650.         Silv.Minimap.ScreenIsFading = true;
  651.         if (Silv.Minimap.Window !== null)
  652.         {
  653.             Silv.Minimap.Window.opacity = this._brightness;
  654.             Silv.Minimap.Window.contents.paintOpacity  = this._brightness;
  655.         }
  656.     }
  657.     else
  658.     {
  659.         Silv.Minimap.ScreenIsFading = false;
  660.     }
  661. };
  662. //------------------------------------------------------------------------------------------------------------------------------------
  663. // Store a reference to the player graphic.
  664. //------------------------------------------------------------------------------------------------------------------------------------
  665. Silv.AddAlias('mm_Spriteset_Map_createCharacters', Spriteset_Map.prototype.createCharacters);
  666. Spriteset_Map.prototype.createCharacters = function()
  667. {
  668.     Silv.Alias.mm_Spriteset_Map_createCharacters.apply(this, arguments);
  669.    
  670.     for (var i = this._characterSprites.length - 1; i >= 0; i--)
  671.     {
  672.         if (this._characterSprites[i]._character == $gamePlayer)
  673.         {
  674.             Spriteset_Map.prototype.playerSprite = this._characterSprites[i];
  675.             break;
  676.         }  
  677.     }
  678. };
  679. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  680. // Automatically create a event-Notetag from event-comments on the active page
  681. // Example usage: console.log($gameMap.event(1).event.silvNote);
  682. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  683. Silv.AddAlias('mm_Game_Event_setupPage',  Game_Event.prototype.setupPage);
  684. Game_Event.prototype.setupPage = function()
  685. {
  686.     Silv.Alias.mm_Game_Event_setupPage.apply(this, arguments);
  687.     this.silvCreateNote();
  688. };
  689.  
  690. Game_Event.prototype.silvCreateNote = function()
  691. {
  692.     this.silvNote = '';
  693.     if (typeof this.page() === 'undefined') { return; }
  694.    
  695.     var list = this.list();
  696.     var str = null;
  697.     for (var commandProperty in list)
  698.     {
  699.         if (list.hasOwnProperty(commandProperty))
  700.         {
  701.             var command = list[commandProperty];
  702.             var commandCode = command.code;
  703.             if (commandCode == 108) // 108: new comment-item, always the first line.
  704.             {
  705.                 if (str !== null) { this.silvNote += str; }
  706.                 str = command.parameters[0];
  707.             }
  708.             else if (commandCode == 408) // 408: comment-line, but not the first one.
  709.             {
  710.                 this.silvNote += command.parameters[0];
  711.             }
  712.             else if (str) // It's not a comment-code, so add the previous str (if any) to the note.
  713.             {
  714.                 this.silvNote += str;
  715.                 str = null;
  716.             }
  717.         }
  718.     }
  719.     if (this.silvNote !== '') { this.extractSilvMetadata(); }
  720. };
  721.  
  722. // <mm_tp:1> will result in: '1'
  723. // <mm_tp:1> will result in: ['1', '0'];
  724. Game_Event.prototype.extractSilvMetadata = function() {
  725.     var re = /<([^<>:]+)(:?)([^>]*)>/g;
  726.     this.meta = {};
  727.     for (;;)
  728.     {
  729.         var match = re.exec(this.silvNote);
  730.         if (match)
  731.         {
  732.             if (match[2] === ':')
  733.             {
  734.                 var value = match[3];
  735.                 if (match[3].indexOf(' ') >= 0) { value = match[3].split(' '); }
  736.                
  737.                 this[match[1]] = value;
  738.             }
  739.             else
  740.             {
  741.                 this[match[1]] = true;
  742.             }
  743.         }
  744.         else
  745.         {
  746.             break;
  747.         }
  748.     }
  749. };
  750. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  751. // Minimap Window
  752. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  753. function Window_Minimap() { this.initialize.apply(this, arguments); }
  754. // Inherit from base window
  755. Window_Minimap.prototype = Object.create(Window_Base.prototype);
  756. // Set Constructor
  757. Window_Minimap.prototype.constructor = Window_Minimap;
  758.  
  759. Window_Minimap.prototype.loadWindowskin = function() { this.windowskin = ImageManager.loadSystem(Silv.Minimap.WindowSkin); };
  760. Window_Minimap.prototype.standardPadding = function() { return Silv.Minimap.StandardPadding; };
  761. //Window_Minimap.prototype.standardFontSize = function() { return Silv.Minimap.FontSize; }
  762.  
  763. // #Initialization
  764. Window_Minimap.prototype.initialize = function(x, y, width, height, mapName, minimapType)
  765. {
  766.     this.mapName = mapName;
  767.     this.minimapType = minimapType;
  768.     if ('mm_size' in $dataMap.meta)
  769.     {
  770.         var newSize = $dataMap.meta.mm_size.split(' ');
  771.         this.width = parseInt(newSize[0]);
  772.         this.height = parseInt(newSize[1]);
  773.     }
  774.    
  775.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  776.     this._helpWindow = null;
  777.     this._handlers = {};
  778.     this._touching = false;
  779.     this.deactivate();
  780.    
  781.     this.originalMapBmp = null;
  782.     this.passabilityBmp = null;
  783.     this.drawPassabilityOverlay = false;
  784.     this.isFadingOut = false;
  785.     this.isFadedOut = false;
  786.     this.setDrawMapBmp();
  787.     this.overlayBmp = ImageManager.loadMinimap('Overlay');
  788.     this.drawAreaWidth = this.contents.width - Silv.Minimap.BorderWidth * 2;
  789.     this.drawAreaHeight = this.contents.height - Silv.Minimap.BorderHeight * 2;
  790.     this.mapWidth = parseFloat($gameMap.width());
  791.     this.mapHeight = parseFloat($gameMap.height());
  792.     this.setAspectRatio();
  793.     this.playerBlinkCnt = Silv.Minimap.PlayerBlinkDelay;
  794.     this.playerBlink_IsVisible = true;
  795.     this.frameSkip = Silv.Minimap.FrameSkip;
  796.     this.frameSkipCnt = 0;
  797.     Silv.Minimap.Menu.Enabled = true;
  798.     this.mapZoom = ('mm_mapzoom' in $dataMap.meta) ? parseFloat($dataMap.meta.mm_mapzoom) : Silv.Minimap.GlobalMapZoom;
  799.     this.mapZoomInverse = 1 / this.mapZoom;
  800.     this.isFirstProcessedUpdate = true;
  801.     this.requiresDrawing = true; // as in AFTER isReady().
  802.     this.isManualScrolling = false;
  803.     this.allowManualScroll = ('mm_allowmanualscroll' in $dataMap.meta) ? $dataMap.meta.mm_allowmanualscroll.toLowerCase() === 'true' : Silv.Minimap.AllowManualScrolling;
  804.     this.mapScroll = {x: 0, y: 0, adjustment_x: 0, adjustment_y: 0};
  805.     this.lastPlayerLoc = {x: $gamePlayer._realX, y: $gamePlayer._realY};
  806.     this.menuZoom = ('mm_menuzoom' in $dataMap.meta) ? $dataMap.meta.mm_menuzoom.toLowerCase() === 'true' : Silv.Minimap.Menu.Zoom;
  807.     this.allowTeleportation = ('mm_tp_allow' in $dataMap.meta) ? $dataMap.meta.mm_tp_allow.toLowerCase() === 'true' : Silv.Minimap.AllowTeleportation;
  808.     this.playerFrame = { x:0, y:0, width:Silv.Minimap.PlayerSpriteSrcFrame_Width, height:Silv.Minimap.PlayerSpriteSrcFrame_Height };
  809.     this.mapStyle = ('mm_mapstyle' in $dataMap.meta) ? $dataMap.meta.mm_mapstyle.toLowerCase() : Silv.Minimap.MapStyle;
  810.     this.cameraFocusType = 'player'; // player / event / coordinate
  811.     this.cameraFocusObject = null; // null / reference to event / {x:real_x, y:real_y}
  812.     this.vehicleCharSprite = null;
  813.     this.menuBG = ('mm_menu_bg' in $dataMap.meta) ? ImageManager.loadMinimap($dataMap.meta.mm_menu_bg) : null;
  814.    
  815.     this.initPlayerBlip();
  816.    
  817.     this.loadEvents();
  818.     this.debugGridBmp = ImageManager.loadMinimap(Silv.Minimap.DebugGridImage);
  819.        
  820.     // The update must be called AFTER all the initialization code.
  821.     this.update();
  822. };
  823.  
  824. Window_Minimap.prototype.setOpacity = function()
  825. {
  826.     this.opacity = Silv.Minimap.Window_Opacity;
  827. };
  828.  
  829. Window_Minimap.prototype.initPlayerBlip = function()
  830. {
  831.     this.playerBlipEnabled = Silv.Minimap.PlayerBlipEnabled;
  832.     this.playerBlipGfx = Silv.Minimap.PlayerBlipGraphic;
  833.     this.playerBlipBmp = null;
  834.    
  835.     if ('mm_player_blip' in $dataMap.meta) { this.setPlayerBlip($dataMap.meta.mm_player_blip); }
  836.     else { this.setPlayerBlip(Silv.Minimap.PlayerBlipGraphic); }
  837. };
  838. //----------------------------------------------------------------------------------------------------
  839. // Set Drawing Bitmaps
  840. //----------------------------------------------------------------------------------------------------
  841. Window_Minimap.prototype.setDrawMapBmp = function()
  842. {
  843.     switch (this.minimapType)
  844.     {
  845.         case 'regular':
  846.             if (this.originalMapBmp === null)
  847.             {
  848.                 this.originalMapBmp = ImageManager.loadMinimap(this.mapName);
  849.                 this.mapBmp = ImageManager.loadMinimap(this.mapName);
  850.             }
  851.             else if (this.originalMapBmp.isReady())
  852.             {
  853.                 this.mapBmp = new Bitmap(this.originalMapBmp.width, this.originalMapBmp.height);
  854.                 this.mapBmp.blt(this.originalMapBmp, 0, 0, this.originalMapBmp.width, this.originalMapBmp.height, 0, 0); // Because nobody knows how to clone a bitmap, we do it like this...
  855.                 this.requiresDrawing = false;
  856.             }
  857.             break;
  858.         case 'generate_map':
  859.             this.mapBmp  = this.generateMap(Silv.Minimap.Generator.MapColors);
  860.             this.originalMapBmp = this.generateMap(Silv.Minimap.Generator.MapColors);
  861.             this.requiresDrawing = false;
  862.             break;
  863.         case 'generate_overworld':
  864.             this.mapBmp = this.generateMap(Silv.Minimap.Generator.OverworldColors);
  865.             this.originalMapBmp = this.generateMap(Silv.Minimap.Generator.OverworldColors);
  866.             this.requiresDrawing = false;
  867.             break;
  868.         default:
  869.             throw new Error('Window_Minimap.prototype.GetMapBmp has invalid switch-value: ' + this.minimapType);
  870.     }
  871.    
  872.     if (this.drawPassabilityOverlay)
  873.     {
  874.         if (this.originalMapBmp.isReady()) { this.bltPassabilityOverlay(); }
  875.         else { this.passabilityRequiresRedraw = true; }
  876.     }
  877. };
  878. //----------------------------------------------------------------------------------------------------
  879. // #Show & #Hide
  880. //----------------------------------------------------------------------------------------------------
  881. Window_Minimap.prototype.hide = function()
  882. {
  883.     Window_Base.prototype.hide.apply(this, arguments);
  884.     Silv.Minimap.Visible = false;
  885. };
  886.  
  887. Window_Minimap.prototype.show = function()
  888. {
  889.     Window_Base.prototype.show.apply(this, arguments);
  890.     Silv.Minimap.Visible = true;
  891. };
  892. //----------------------------------------------------------------------------------------------------
  893. // #Passability #Overlay
  894. //----------------------------------------------------------------------------------------------------
  895. Window_Minimap.prototype.bltPassabilityOverlay = function()
  896. {
  897.     // Generate the bitmap if it wasn't done already
  898.     if (this.passabilityBmp === null) { this.passabilityBmp = this.generatePassabilityBmp(); }
  899.    
  900.     // Blt the overlay on top of the this.mapBmp
  901.     this.mapBmp.blt(this.passabilityBmp, 0, 0, this.passabilityBmp.width, this.passabilityBmp.height, 0, 0);
  902.    
  903.     this.passabilityRequiresRedraw = false;
  904. };
  905.  
  906. Window_Minimap.prototype.setPassabilityOverlay = function(enabled)
  907. {
  908.     this.drawPassabilityOverlay = enabled;
  909.     this.setDrawMapBmp();
  910. };
  911.  
  912. // Dev note: this method can be severely optimized by replacing it with a modified version of the $GameMap.checkPassage(). Calling gameMap.isPassable() 4x per tile is not effective because internally it starts looping through them 4x instead of 1.
  913. Window_Minimap.prototype.generatePassabilityBmp = function()
  914. {
  915.     var tile_w = $gameMap.tileWidth();
  916.     var tile_h = $gameMap.tileHeight();
  917.     var bmp = new Bitmap($gameMap.width() * tile_w, $gameMap.height() * tile_h);
  918.     bmp.paintOpacity = Silv.Minimap.PassabilityOverlayOpacity;
  919.     var borderTickness = 8;
  920.    
  921.     for (var y=0; y<$dataMap.height; y++)
  922.     {
  923.         for (var x=0; x<$dataMap.width; x++)
  924.         {
  925.             var passability = {2:$gameMap.isPassable(x, y, 2), 4:$gameMap.isPassable(x, y, 4), 6:$gameMap.isPassable(x, y, 6), 8:$gameMap.isPassable(x, y, 8)};
  926.            
  927.             if (!passability[2] && !passability[4] && !passability[6] && !passability[8])
  928.             {
  929.                 bmp.fillRect(x * tile_w, y * tile_h, tile_w, tile_h, Silv.Minimap.ImpassabilityColor);
  930.             }
  931.             else
  932.             {
  933.                 bmp.paintOpacity = 255;
  934.                 if (!passability[8]) { bmp.fillRect(x * tile_w, y * tile_h, tile_w, borderTickness, Silv.Minimap.ImpassabilityColor); } // top
  935.                 if (!passability[6]) { bmp.fillRect(x * tile_w + tile_w - borderTickness, y * tile_h, borderTickness, tile_h, Silv.Minimap.ImpassabilityColor); } // right
  936.                 if (!passability[2]) { bmp.fillRect(x * tile_w, y * tile_h + tile_h - borderTickness, tile_w, borderTickness, Silv.Minimap.ImpassabilityColor); } // bottom
  937.                 if (!passability[4]) { bmp.fillRect(x * tile_w, y * tile_h, borderTickness, tile_h, Silv.Minimap.ImpassabilityColor); } // left
  938.                 bmp.paintOpacity = Silv.Minimap.PassabilityOverlayOpacity;
  939.                
  940.                 bmp.fillRect(x * tile_w, y * tile_h, tile_w, tile_h, Silv.Minimap.PassabilityColor);
  941.             }
  942.         }
  943.     }
  944.     return bmp;
  945. };
  946.  
  947. //----------------------------------------------------------------------------------------------------
  948. // #Generate Maps
  949. //----------------------------------------------------------------------------------------------------
  950. Window_Minimap.prototype.generateMap = function(colors)
  951. {
  952.     var tile_w = $gameMap.tileWidth();
  953.     var tile_h = $gameMap.tileHeight();
  954.     var bmp = new Bitmap($gameMap.width() * tile_w, $gameMap.height() * tile_h);
  955.    
  956.     for (var y=0; y<$dataMap.height; y++)
  957.     {
  958.         for (var x=0; x<$dataMap.width; x++)
  959.         {
  960.             bmp.fillRect(x * tile_w, y * tile_h, tile_w, tile_h, colors[$gameMap.terrainTag(x, y)]); // Default: lightgreen, blue, brown, darkgreen, lightbrown
  961.         }
  962.     }
  963.     return bmp;
  964. };
  965.  
  966. //----------------------------------------------------------------------------------------------------
  967. // <Asorted>
  968. //----------------------------------------------------------------------------------------------------
  969. Window_Minimap.prototype.showMapMenuScene = function()
  970. {
  971.     Silv.Minimap.Window.pushMapScene();
  972. };
  973.  
  974. Window_Minimap.prototype.clamp = function(value, min, max)
  975. {
  976.     return Math.min(Math.max(value, min), max);
  977. };
  978.    
  979. // This function requires this.mapBmp to be fully initialized.
  980. // #Aspect #Ratio #AspectRatio
  981. Window_Minimap.prototype.setAspectRatio = function()
  982. {
  983.     // this.mapAspRatInfo.scaleDelta_x is the difference in size between the mapwidth (in pixels, NOT in tiles) and the minimap (render)width.
  984.     this.mapAspRatInfo = { w: 0.0, h: 0.0, offset_x: 0.0, offset_y: 0.0, scaleDelta_x: 0.0, scaleDelta_y: 0.0 };
  985.     var w = $gameMap.width();
  986.     var h = $gameMap.height();
  987.    
  988.     // Map Aspect Ratio
  989.     if (!Silv.Minimap.MaintainAspectRatio || (w == h))
  990.     {
  991.         this.mapAspRatInfo.w = 1.0;
  992.         this.mapAspRatInfo.h = 1.0;
  993.     }
  994.     else if (w > h)
  995.     {
  996.         this.mapAspRatInfo.w = 1.0;
  997.         this.mapAspRatInfo.h = h / parseFloat(w);
  998.     }
  999.     else // if (h > w)
  1000.     {
  1001.         this.mapAspRatInfo.w = w / parseFloat(h);
  1002.         this.mapAspRatInfo.h = 1.0;
  1003.     }
  1004.    
  1005.     this.mapAspRatInfo.scaleDelta_x = this.drawAreaWidth / parseFloat($gameMap.width() * $gameMap.tileWidth());
  1006.     this.mapAspRatInfo.scaleDelta_y = this.drawAreaHeight / parseFloat($gameMap.height() * $gameMap.tileHeight());
  1007. };
  1008.  
  1009. // #Events
  1010. Window_Minimap.prototype.loadEvents = function()
  1011. {
  1012.     Silv.Minimap.Events = [];
  1013.     for (var ev_idx = 1; ev_idx < $dataMap.events.length; ev_idx++) // Note: start at 1. Because the first one is always null.
  1014.     {
  1015.         if ($dataMap.events[ev_idx] !== null)
  1016.         {
  1017.             var ev = $gameMap.event(ev_idx);
  1018.            
  1019.             // Check Event Note
  1020.             if ($dataMap.events[ev_idx].note != '' || ('mm_show' in ev))
  1021.             {
  1022.                 var cmds = $dataMap.events[ev_idx].note.toLowerCase().split(' ');
  1023.                 if ((cmds.indexOf('mm_show') > -1) ||  ('mm_show' in ev))
  1024.                 {
  1025.                     var new_ev = {event: ev, sprite: this.getEventCharacterSprite(ev.eventId())};
  1026.                     Silv.Minimap.Events.push(new_ev); // Add event to the array so we can render it on the minimap
  1027.                 }
  1028.             }
  1029.         }
  1030.     }
  1031.     if (Silv.Minimap.DebugMode) { console.log('Loaded Events:'); console.log(Silv.Minimap.Events); }
  1032. };
  1033.  
  1034. Window_Minimap.prototype.getEventCharacterSprite = function(ev_id)
  1035. {
  1036.     for (var i=0; i < SceneManager._scene._spriteset._characterSprites.length; i++)
  1037.     {
  1038.         var eventSprite = SceneManager._scene._spriteset._characterSprites[i];
  1039.         if (eventSprite._character.eventId() == ev_id)
  1040.         {
  1041.             return eventSprite;
  1042.         }
  1043.     }
  1044.     throw new Error('getEventCharacterSprite() did not find a match for ev_id: ' + ev_id);
  1045. };
  1046.    
  1047. // #update
  1048. Window_Minimap.prototype.update = function()
  1049. {
  1050.     if (!this.skipFrame() && (this.originalMapBmp === null || this.originalMapBmp.isReady()))
  1051.     {
  1052.         Window_Base.prototype.update.call(this);
  1053.         this.updateFadeOut();
  1054.         this.updateInput();
  1055.         if (Silv.Minimap.PlayerBlinks) { this.updatePlayerBlink(); }
  1056.         this.updateMapScroll(this.isFirstProcessedUpdate);
  1057.         this.playerInfo = this.getPlayerBitmap();
  1058.         if (this.requiresDrawing) { this.setDrawMapBmp(); }
  1059.         this.drawMinimap();
  1060.         this.lastPlayerLoc.x  = $gamePlayer._realX;
  1061.         this.lastPlayerLoc.y  = $gamePlayer._realY;
  1062.         this.isFirstProcessedUpdate = false;
  1063.        
  1064.         // Teleport
  1065.         if (Silv.Minimap.TP_Dest !== null)
  1066.         {
  1067.             this.teleport(Silv.Minimap.TP_Dest);
  1068.             Silv.Minimap.TP_Dest = null;
  1069.         }
  1070.        
  1071.         if (this.passabilityRequiresRedraw && this.originalMapBmp.isReady()) { this.bltPassabilityOverlay(); }
  1072.     }
  1073.    
  1074.     if (Input.isTriggered(Silv.Minimap.Menu.MenuKey)) { this.showMapMenuScene(); }
  1075. };
  1076.  
  1077. //----------------------------------------------------------------------------------------------------
  1078. // Get #Player #Blip Bitmap
  1079. //----------------------------------------------------------------------------------------------------
  1080. Window_Minimap.prototype.getPlayerBitmap = function()
  1081. {
  1082.     if (this.vehicleCharSprite === null)
  1083.     {
  1084.         var playerSpr = Spriteset_Map.prototype.playerSprite;
  1085.         // Player is not in bush, so return the regular player-graphic
  1086.         if (playerSpr._bushDepth == 0 || playerSpr._lowerBody === null)
  1087.         {
  1088.             return { bmp:playerSpr._bitmap, src:playerSpr._frame };
  1089.         }
  1090.  
  1091.         // Create Bush graphic (which is divided into 2 graphics by the RM-code..)
  1092.         var playerBmp = new Bitmap(Silv.Minimap.PlayerSpriteSrcFrame_Width, Silv.Minimap.PlayerSpriteSrcFrame_Height);
  1093.         playerBmp.blt(Spriteset_Map.prototype.playerSprite._lowerBody._bitmap, Spriteset_Map.prototype.playerSprite._lowerBody._frame.x, Spriteset_Map.prototype.playerSprite._lowerBody._frame.y, Spriteset_Map.prototype.playerSprite._lowerBody._frame.width, Spriteset_Map.prototype.playerSprite._lowerBody._frame.height,
  1094.                       0, Silv.Minimap.PlayerSpriteSrcFrame_Height - playerSpr._bushDepth, Silv.Minimap.PlayerIconSize, Silv.Minimap.PlayerIconSize);
  1095.         playerBmp.blt(Spriteset_Map.prototype.playerSprite._upperBody._bitmap, Spriteset_Map.prototype.playerSprite._upperBody._frame.x, Spriteset_Map.prototype.playerSprite._upperBody._frame.y, Spriteset_Map.prototype.playerSprite._upperBody._frame.width, Spriteset_Map.prototype.playerSprite._upperBody._frame.height,
  1096.                       0, 0, Silv.Minimap.PlayerIconSize, Silv.Minimap.PlayerIconSize);
  1097.        
  1098.         return {bmp:playerBmp, src:this.playerFrame};
  1099.     }
  1100.     else // return vehicle instead
  1101.     {
  1102.         return { bmp:this.vehicleCharSprite._bitmap, src:this.vehicleCharSprite._frame };
  1103.     }
  1104. };
  1105. //----------------------------------------------------------------------------------------------------
  1106. // #Vehicle Compatibility for Player Blip Bitmap
  1107. //----------------------------------------------------------------------------------------------------
  1108. Silv.AddAlias('mm_Game_Vehicle_getOnVehicle', Game_Vehicle.prototype.getOn);
  1109. Game_Vehicle.prototype.getOn = function()
  1110. {
  1111.     Silv.Alias.mm_Game_Vehicle_getOnVehicle.apply(this, arguments);
  1112.    
  1113.     if (Silv.Minimap.Window)
  1114.     {
  1115.         var charSprites = SceneManager._scene._spriteset._characterSprites;
  1116.         for (var i = charSprites.length - 1; i >= 0; i--)
  1117.         {
  1118.             if (charSprites[i]._character == this)
  1119.             {
  1120.                 Silv.Minimap.Window.vehicleCharSprite = charSprites[i];
  1121.                 break;
  1122.             }
  1123.         }
  1124.        
  1125.         if (Silv.Minimap.Window.vehicleCharSprite === null)
  1126.         {
  1127.             console.log("ERROR: can't find vehicle sprite for:");
  1128.             console.log(this);
  1129.             throw new Error("ERROR: Couldn't find vehicle sprite.");
  1130.         }
  1131.     }
  1132. };
  1133.  
  1134. Silv.AddAlias('mm_Game_Vehicle_getOffVehicle', Game_Vehicle.prototype.getOff);
  1135. Game_Vehicle.prototype.getOff = function()
  1136. {
  1137.     Silv.Alias.mm_Game_Vehicle_getOffVehicle.apply(this, arguments);
  1138.     if (Silv.Minimap.Window) { Silv.Minimap.Window.vehicleCharSprite = null; }
  1139. };
  1140. //----------------------------------------------------------------------------------------------------
  1141. Window_Minimap.prototype.updateInput = function()
  1142. {
  1143.     if (Input.isPressed(Silv.Minimap.ManualScrollKeyUp))    { Silv.Minimap.Window.manualScroll(Silv.Minimap.Window.mapScroll.x, Silv.Minimap.Window.mapScroll.y - Silv.Minimap.ManualScrollspeed); }
  1144.     if (Input.isPressed(Silv.Minimap.ManualScrollKeyRight)) { Silv.Minimap.Window.manualScroll(Silv.Minimap.Window.mapScroll.x + Silv.Minimap.ManualScrollspeed, Silv.Minimap.Window.mapScroll.y); }
  1145.     if (Input.isPressed(Silv.Minimap.ManualScrollKeyDown))  { Silv.Minimap.Window.manualScroll(Silv.Minimap.Window.mapScroll.x, Silv.Minimap.Window.mapScroll.y + Silv.Minimap.ManualScrollspeed); }
  1146.     if (Input.isPressed(Silv.Minimap.ManualScrollKeyLeft))  { Silv.Minimap.Window.manualScroll(Silv.Minimap.Window.mapScroll.x - Silv.Minimap.ManualScrollspeed, Silv.Minimap.Window.mapScroll.y); }
  1147. };
  1148.  
  1149. Window_Minimap.prototype.teleport = function(tp_info)
  1150. {
  1151.     var direction = $gamePlayer._direction;
  1152.     if (tp_info[2] != 0) { direction = parseInt(tp_info[2]); }
  1153.  
  1154.     $gamePlayer.reserveTransfer($gameMap._mapId, tp_info[0], tp_info[1], direction, parseInt(tp_info[3]));
  1155. };
  1156.  
  1157. Window_Minimap.prototype.playerLocChanged = function()
  1158. {
  1159.     return this.lastPlayerLoc.x != $gamePlayer._realX || this.lastPlayerLoc.y != $gamePlayer._realY;
  1160. };
  1161.  
  1162. //----------------------------------------------------------------------------------------------------
  1163. // #Scroll
  1164. //----------------------------------------------------------------------------------------------------
  1165. Window_Minimap.prototype.updateMapScroll = function(force)
  1166. {
  1167.     switch (this.cameraFocusType)
  1168.     {
  1169.         case 'player':
  1170.             if (this.playerLocChanged() || force) // Only update mapscroll if the player changed location. This way manual-scrolling is made possible.
  1171.             {
  1172.                 this.isManualScrolling = false;
  1173.                 this.scrollToMapObject($gamePlayer._realX, $gamePlayer._realY);
  1174.             }
  1175.             break;
  1176.         case 'event':
  1177.             this.isManualScrolling = false;
  1178.             this.scrollToMapObject(this.cameraFocusObject._realX, this.cameraFocusObject._realY);
  1179.             break;
  1180.         case 'coordinate':
  1181.             this.isManualScrolling = false;
  1182.             this.scrollToMapObject(this.cameraFocusObject.x, this.cameraFocusObject.y);
  1183.             break;
  1184.         default:
  1185.             throw new Error('Invalid switch-value in updateMapScroll(). Value: ' + this.cameraFocusType);
  1186.     }
  1187. };
  1188.  
  1189. Window_Minimap.prototype.setCameraFollowTarget = function(followType, value)
  1190. {
  1191.     this.cameraFocusType = followType; // Must be set before calling updateMapScroll()
  1192.     switch (followType)
  1193.     {
  1194.         case 'player':
  1195.             this.cameraFocusObject = null;
  1196.             this.updateMapScroll(true); // refresh the camera to focus on the player. Because he may not be moving when this was called.
  1197.             break;
  1198.         case 'event':
  1199.             this.cameraFocusObject = $gameMap.event(parseInt(value));
  1200.             if (typeof this.cameraFocusObject === 'undefined') { throw 'setCameraFollowTarget() invalid event-id: ' + value; }
  1201.             break;
  1202.         case 'coordinate':
  1203.             if (Object.prototype.toString.call( value ) !== '[object Array]') { throw 'setCameraFollowTarget() value-param must be an array. Received type: ' + typeof value; }
  1204.             this.cameraFocusObject = { x:value[0], y:value[1] };
  1205.             break;
  1206.         default:
  1207.             throw new Error('Invalid switch-value in setCameraFollowTarget(). Value: ' + followType);
  1208.     }
  1209.    
  1210. };
  1211.  
  1212. Window_Minimap.prototype.scrollToMapObject = function(real_x, real_y)
  1213. {
  1214.     this.setMapScroll(real_x * $gameMap.tileWidth() - (this.drawAreaWidth / 2 * this.mapZoomInverse), real_y * $gameMap.tileHeight() - (this.drawAreaHeight / 2 * this.mapZoomInverse));
  1215. };
  1216.  
  1217. Window_Minimap.prototype.setMapScroll = function(scroll_x, scroll_y)
  1218. {
  1219.     var old_x = this.mapScroll.x = scroll_x;
  1220.     var source_w = this.drawAreaWidth * this.mapZoomInverse;
  1221.     this.mapScroll.x = this.clamp(this.mapScroll.x, 0, this.mapBmp.width - source_w);
  1222.     this.mapScroll.adjustment_x = old_x - this.mapScroll.x; // clamp difference
  1223.    
  1224.     var old_y = this.mapScroll.y = scroll_y;
  1225.     var source_h = this.drawAreaHeight * this.mapZoomInverse;
  1226.     this.mapScroll.y = this.clamp(this.mapScroll.y, 0, this.mapBmp.height - source_h);
  1227.     this.mapScroll.adjustment_y = old_y - this.mapScroll.y; // clamp difference
  1228. };
  1229. //----------------------------------------------------------------------------------------------------
  1230.  
  1231. Window_Minimap.prototype.manualScroll = function(scroll_x, scroll_y)
  1232. {
  1233.     this.setMapScroll(scroll_x, scroll_y);
  1234.     this.isManualScrolling = true;
  1235. };
  1236.  
  1237. // Skips frame (returns true) if frameSkipCnt > frameSkip
  1238. Window_Minimap.prototype.skipFrame = function()
  1239. {
  1240.     if (this.frameSkip == 0) { return false; } // process frame
  1241.    
  1242.     this.frameSkipCnt++;
  1243.     if (this.frameSkipCnt < this.frameSkip)
  1244.     {
  1245.         return true; // skip frame
  1246.     }
  1247.     else
  1248.     {
  1249.         this.frameSkipCnt = 0;
  1250.         return false; // process frame
  1251.     }
  1252. };
  1253.  
  1254. Window_Minimap.prototype.updatePlayerBlink = function()
  1255. {
  1256.     this.playerBlinkCnt--;
  1257.     if (this.playerBlinkCnt <= 0)      
  1258.     {  
  1259.         this.playerBlinkCnt = Silv.Minimap.PlayerBlinkDelay;
  1260.         this.playerBlink_IsVisible = !this.playerBlink_IsVisible;
  1261.     }
  1262. };
  1263.  
  1264. //----------------------------------------------------------------------------------------------------
  1265. // Window Fading
  1266. //----------------------------------------------------------------------------------------------------
  1267. Window_Minimap.prototype.updateFadeOut = function()
  1268. {
  1269.     if (this.isFadedOut || Silv.Minimap.ScreenIsFading) { return; } // Do nothing if the minimap is already completely faded out or if the screen itself is being faded in/out.
  1270.     if (this.isFadingOut) { this.fadeOut(); }
  1271. };
  1272.  
  1273. Window_Minimap.prototype.fadeOut = function()
  1274. {
  1275.     this.opacity = this.contentsOpacity -= Silv.Minimap.FadeoutSpeed;
  1276.     this.isFadedOut = (this.opacity <= 0);
  1277. };
  1278.  
  1279. Window_Minimap.prototype.resetFade = function()
  1280. {
  1281.     this.isFadingOut = false;
  1282.     this.fadeOutCnt = 0;
  1283.     this.opacity = this.contentsOpacity  = 255;
  1284.     this.isFadedOut = false;
  1285. };
  1286.  
  1287. Window_Minimap.prototype.fadeOutInstantly = function()
  1288. {
  1289.     this.opacity = this.contentsOpacity = 0;
  1290.     this.isFadedOut = true;
  1291. };
  1292.  
  1293. //----------------------------------------------------------------------------------------------------
  1294. // #Menu
  1295. //----------------------------------------------------------------------------------------------------
  1296. // This method is required for compatibility with Yanfly's Main Menu Manager.
  1297. Scene_Menu.prototype.commandSilvMap = function()
  1298. {
  1299.     Silv.Minimap.Window.pushMapScene();
  1300. };
  1301.  
  1302. Silv.AddAlias('mm_Scene_Map_callMenu', Scene_Map.prototype.callMenu);
  1303. Scene_Map.prototype.callMenu = function()
  1304. {
  1305.     if (Silv.Minimap.Menu.Enabled) { Silv.Minimap.Window.createMenuData(); }
  1306.     Silv.Alias.mm_Scene_Map_callMenu.apply(this, arguments);
  1307. };
  1308.  
  1309. Window_Minimap.prototype.createMenuData = function()
  1310. {
  1311.     this.createMenuBmp();
  1312.     this.createMenuMarkers();
  1313. };
  1314.  
  1315. Window_Minimap.prototype.pushMapScene = function()
  1316. {
  1317.     this.createMenuData();
  1318.     if (Silv.Minimap.Menu.Enabled)
  1319.     {
  1320.         if (Silv.Minimap.Menu.Bmp !== null) { SceneManager.push(Scene_MiniMap); }
  1321.         else { throw new Error('pushMapScene() was called, the minimap-menu was enabled BUT Silv.Minimap.Menu.Bmp equals null?'); }
  1322.     }
  1323.     else
  1324.     {
  1325.         throw new Error('pushMapScene() was called but the Minimap (menu) was not enabled.');
  1326.     }
  1327. };
  1328. //----------------------------------------------------------------------------------------------------
  1329. // Create #Menu Bitmap
  1330. //----------------------------------------------------------------------------------------------------
  1331. Window_Minimap.prototype.createMenuBmp = function()
  1332. {
  1333.     Silv.Minimap.Menu.Bmp = new Bitmap(this.mapBmp.width * this.menuZoom, this.mapBmp.height * this.menuZoom);
  1334.    
  1335.     this.tileInfo = {
  1336.             w: $gameMap.tileWidth(), hw: $gameMap.tileWidth() / 2.0, zhw: ($gameMap.tileWidth() / 2.0) * this.menuZoom,
  1337.             h: $gameMap.tileHeight(), hh: $gameMap.tileHeight() / 2.0, zhh: ($gameMap.tileHeight() / 2.0) * this.menuZoom
  1338.         };
  1339.    
  1340.     // Draw Map
  1341.     var backgroundBmp = (this.menuBG) ? this.menuBG : this.mapBmp;
  1342.     Silv.Minimap.Menu.Bmp.blt(backgroundBmp, 0, 0, backgroundBmp.width, backgroundBmp.height, 0, 0, Silv.Minimap.Menu.Bmp.width, Silv.Minimap.Menu.Bmp.height);
  1343.    
  1344.     // Draw Debug Grid
  1345.     if (Silv.Minimap.DrawDebugGrid)
  1346.     {
  1347.         for (var i=0; i < $gameMap.width(); i++)
  1348.         {
  1349.             for (var j=0; j < $gameMap.height(); j++)
  1350.             {
  1351.                 var debugTileLoc = this.translateLocationMenu(this, i, j, this.tileInfo.w * this.menuZoom, this.tileInfo.h * this.menuZoom);
  1352.                 Silv.Minimap.Menu.Bmp.blt(this.debugGridBmp, 0, 0, this.tileInfo.w, this.tileInfo.h, debugTileLoc.x, debugTileLoc.y, this.tileInfo.w * this.menuZoom, this.tileInfo.h * this.menuZoom);
  1353.             }
  1354.         }
  1355.     }
  1356.    
  1357.     // Draw POI's
  1358.     for (var i = 0; i < this.getAllPOI().length; i++)
  1359.     {
  1360.         var poi = this.getPOIByIdx(i);
  1361.         var poiLoc = this.translateLocationMenu(this, poi.real_x, poi.real_y, poi.destSize.w, poi.destSize.h);
  1362.         Silv.Minimap.Menu.Bmp.blt(poi.bmp, poi.src.x, poi.src.y, poi.src.w, poi.src.h,
  1363.                                   poiLoc.x, poiLoc.y, poi.destSize.w, poi.destSize.h);
  1364.     }
  1365.    
  1366.     // Draw Events
  1367.     for (var i=0; i < Silv.Minimap.Events.length; i++)
  1368.     {
  1369.         var ev = Silv.Minimap.Events[i].event;
  1370.         var ev_sprite = Silv.Minimap.Events[i].sprite;
  1371.         var evMapLoc = this.translateLocationMenu(this, ev._realX, ev._realY, Silv.Minimap.Menu.EventRenderSize, Silv.Minimap.Menu.EventRenderSize);
  1372.         Silv.Minimap.Menu.Bmp.blt(ev_sprite._bitmap, ev_sprite._frame.x, ev_sprite._frame.y, ev_sprite._frame.width, ev_sprite._frame.height, evMapLoc.x, evMapLoc.y, Silv.Minimap.Menu.EventRenderSize, Silv.Minimap.Menu.EventRenderSize);
  1373.     }
  1374.    
  1375.     // Draw Player
  1376.     if (this.playerBlipEnabled)
  1377.     {
  1378.         this.drawPlayerBlip(Silv.Minimap.Menu.Bmp, this.translateLocationMenu, this.playerInfo.src.x, this.playerInfo.src.y, this.playerInfo.src.width, this.playerInfo.src.height,
  1379.                             Silv.Minimap.Menu.PlayerIconSize, Silv.Minimap.Menu.PlayerIconSize);
  1380.     }
  1381. };
  1382. //----------------------------------------------------------------------------------------------------
  1383. // Menu Create #Markers
  1384. //----------------------------------------------------------------------------------------------------
  1385. Window_Minimap.prototype.createMenuMarkers = function()
  1386. {
  1387.     Silv.Minimap.Menu.Markers = [];
  1388.    
  1389.     // Player
  1390.     var playerMapLoc = this.translateLocationMenu(this, $gamePlayer._realX, $gamePlayer._realY, Silv.Minimap.Menu.PlayerIconSize, Silv.Minimap.Menu.PlayerIconSize);
  1391.     Silv.Minimap.Menu.Markers.push({text:'Player', map_x:playerMapLoc.x, map_y:playerMapLoc.y, w:Silv.Minimap.Menu.PlayerIconSize, h:Silv.Minimap.Menu.PlayerIconSize, desc:Silv.Minimap.Menu.PlayerDesc, tp:null});
  1392.    
  1393.     // POI's
  1394.     for (var i = 0; i < this.getAllPOI().length; i++)
  1395.     {
  1396.         var poi = this.getPOIByIdx(i);
  1397.         var poiLoc = this.translateLocationMenu(this, poi.real_x, poi.real_y, poi.destSize.w, poi.destSize.h);
  1398.        
  1399.         var tp = poi.tp.slice(0); // slice(0) clones it
  1400.         if (this.allowTeleportation && (poi.tp !== null))
  1401.         {
  1402.             tp[0] = parseInt(tp[0]) + parseInt(poi.real_x);
  1403.             tp[1] = parseInt(tp[1]) + parseInt(poi.real_y);
  1404.         }
  1405.        
  1406.         Silv.Minimap.Menu.Markers.push({text:poi.name, map_x:poiLoc.x, map_y:poiLoc.y, w:poi.destSize.w, h:poi.destSize.h, desc:poi.desc, tp:tp});
  1407.     }
  1408.    
  1409.     // Events
  1410.     for (var i=0; i < Silv.Minimap.Events.length; i++)
  1411.     {
  1412.         var ev = Silv.Minimap.Events[i].event;
  1413.         var dataMapEvent = dataMapGetEventByID(ev._eventId);
  1414.         if (dataMapEvent)
  1415.         {
  1416.             var evMapLoc = this.translateLocationMenu(this, ev._realX, ev._realY, Silv.Minimap.Menu.EventRenderSize, Silv.Minimap.Menu.EventRenderSize);
  1417.            
  1418.             var desc = '';
  1419.             if ('mm_desc' in ev) { desc = ev.mm_desc.join(' '); }
  1420.            
  1421.             var tp = null;
  1422.             if (this.allowTeleportation && ('mm_tp' in ev))
  1423.             {
  1424.                 tp = ev.mm_tp.slice(0); // slice(0) clones it
  1425.                 tp[0] = parseInt(tp[0]) + parseInt(ev._x);
  1426.                 tp[1] = parseInt(tp[1]) + parseInt(ev._y);
  1427.             }
  1428.  
  1429.             Silv.Minimap.Menu.Markers.push({ text:dataMapEvent.name, map_x:evMapLoc.x, map_y:evMapLoc.y, w:Silv.Minimap.Menu.EventRenderSize, h:Silv.Minimap.Menu.EventRenderSize, desc:desc, tp:tp });
  1430.         }
  1431.     }
  1432. };
  1433. //----------------------------------------------------------------------------------------------------
  1434. // #Rendering #Drawing
  1435. //----------------------------------------------------------------------------------------------------
  1436. Window_Minimap.prototype.setPlayerBlip = function(filename)
  1437. {
  1438.     this.usePlayerBlipGfx = (filename == ':player');
  1439.     if (this.usePlayerBlipGfx) { this.playerBlipBmp = null; }
  1440.     else { this.playerBlipBmp = ImageManager.loadMinimap(filename); }
  1441. };
  1442.  
  1443. Window_Minimap.prototype.drawPlayerBlip = function(destBmp, translateFunc, src_x, src_y, src_w, src_h, dest_w, dest_h)
  1444. {
  1445.     var playerMapLoc = translateFunc(this, $gamePlayer._realX, $gamePlayer._realY, dest_w, dest_h);
  1446.     if (this.usePlayerBlipGfx)
  1447.     {
  1448.         destBmp.blt(this.playerInfo.bmp, src_x, src_y, src_w, src_h, playerMapLoc.x, playerMapLoc.y, dest_w, dest_h);
  1449.     }
  1450.     else
  1451.     {
  1452.         // Use custom player blip graphic
  1453.         if (this.playerBlipBmp.isReady())
  1454.         {
  1455.             destBmp.blt(this.playerBlipBmp, 0, 0, this.playerBlipBmp.width, this.playerBlipBmp.height, playerMapLoc.x, playerMapLoc.y, dest_w, dest_h);
  1456.         }
  1457.     }
  1458. };
  1459.  
  1460. Window_Minimap.prototype.drawMinimap = function()
  1461. {
  1462.     this.contents.clear();
  1463.    
  1464.     // BG fill colour, if applicable
  1465.     this.contents.fillRect(Silv.Minimap.BorderWidth, Silv.Minimap.BorderHeight, this.drawAreaWidth, this.drawAreaHeight, Silv.Minimap.MapBGFillColor);
  1466.    
  1467.     switch(this.mapStyle)
  1468.     {
  1469.         case 'autofit':
  1470.             this.drawstyleAutofit();
  1471.             break;
  1472.         case 'scroll':
  1473.             this.drawstyleScroll();
  1474.             break; 
  1475.         default:
  1476.             throw new Error('Window_Minimap.prototype.drawMinimap invalid switch value: ' + this.mapStyle);
  1477.     }
  1478. };
  1479.  
  1480. Window_Minimap.prototype.drawstyleAutofit = function()
  1481. {
  1482.     // Opacity
  1483.     this.contents.paintOpacity = this.opacity = Silv.Minimap.Window_Opacity;
  1484.    
  1485.     var destination_w = this.drawAreaWidth  * this.mapAspRatInfo.w;
  1486.     var destination_h = this.drawAreaHeight * this.mapAspRatInfo.h;
  1487.    
  1488.     // Calculate the aspect ratio offsets
  1489.     this.mapAspRatInfo.offset_x = 0.0; // to center the map
  1490.     this.mapAspRatInfo.offset_y = 0.0; // to center the map
  1491.     if (this.mapAspRatInfo.w < 1.0) { this.mapAspRatInfo.offset_x = (this.drawAreaWidth  - destination_w) / 2.0; }
  1492.     if (this.mapAspRatInfo.h < 1.0) { this.mapAspRatInfo.offset_y = (this.drawAreaHeight - destination_h) / 2.0; }
  1493.    
  1494.     // This variable saves on calculations further down the road during this update
  1495.     // w = width, hw=  half width, zhw = zoomed half width
  1496.     this.tileInfo = {
  1497.             w: $gameMap.tileWidth(), hw: $gameMap.tileWidth() / 2.0, zhw: ($gameMap.tileWidth() / 2.0) * this.mapAspRatInfo.w,
  1498.             h: $gameMap.tileHeight(), hh: $gameMap.tileHeight() / 2.0, zhh: ($gameMap.tileHeight() / 2.0) * this.mapAspRatInfo.h
  1499.         };
  1500.    
  1501.     // Draw Map
  1502.     this.contents.blt(this.mapBmp, 0, 0, this.mapBmp.width, this.mapBmp.height, Silv.Minimap.BorderWidth + this.mapAspRatInfo.offset_x, Silv.Minimap.BorderHeight + this.mapAspRatInfo.offset_y, destination_w, destination_h);
  1503.  
  1504.     // Debug Grid (if applicable)
  1505.     if (Silv.Minimap.DrawDebugGrid)
  1506.     {
  1507.         for (var i=0; i < $gameMap.width(); i++)
  1508.         {
  1509.             for (var j=0; j < $gameMap.height(); j++)
  1510.             {
  1511.                 var debugTileLoc = this.translateLocationAutofit(this, i, j, this.tileInfo.w * this.mapAspRatInfo.w, this.tileInfo.h * this.mapAspRatInfo.h);
  1512.                 this.contents.blt(this.debugGridBmp, 0, 0, this.tileInfo.w, this.tileInfo.h, debugTileLoc.x, debugTileLoc.y, this.tileInfo.w * this.mapAspRatInfo.w, this.tileInfo.h * this.mapAspRatInfo.h);
  1513.             }
  1514.         }
  1515.     }
  1516.    
  1517.     // Draw POI's
  1518.     for (var i = 0; i < this.getAllPOI().length; i++)
  1519.     {
  1520.         var poi = this.getPOIByIdx(i);
  1521.         var poiLoc = this.translateLocationAutofit(this, poi.real_x, poi.real_y, poi.destSize.w, poi.destSize.h);
  1522.         this.contents.blt(poi.bmp, poi.src.x, poi.src.y, poi.src.w, poi.src.h,
  1523.                           poiLoc.x, poiLoc.y, poi.destSize.w, poi.destSize.h);
  1524.     }
  1525.    
  1526.     // Draw Events
  1527.     for (var i=0; i < Silv.Minimap.Events.length; i++)
  1528.     {
  1529.         var ev = Silv.Minimap.Events[i].event;
  1530.         var ev_sprite = Silv.Minimap.Events[i].sprite;
  1531.         var evMapLoc = this.translateLocationAutofit(this, ev._realX, ev._realY, Silv.Minimap.EventRenderSize, Silv.Minimap.EventRenderSize);
  1532.         this.contents.blt(ev_sprite._bitmap, ev_sprite._frame.x, ev_sprite._frame.y, ev_sprite._frame.width, ev_sprite._frame.height, evMapLoc.x, evMapLoc.y, Silv.Minimap.EventRenderSize, Silv.Minimap.EventRenderSize);
  1533.     }
  1534.    
  1535.     // Draw Player
  1536.     if (this.playerBlipEnabled && this.playerBlink_IsVisible)
  1537.     {
  1538.         this.drawPlayerBlip(this.contents, this.translateLocationAutofit, this.playerInfo.src.x, this.playerInfo.src.y, this.playerInfo.src.width, this.playerInfo.src.height,
  1539.                             Silv.Minimap.PlayerIconWidth, Silv.Minimap.PlayerIconHeight);
  1540.     }
  1541.    
  1542.     // Overlay (if applicable)
  1543.     if (Silv.Minimap.DrawOverlay) { this.drawOverlay(); }
  1544. };
  1545.  
  1546. Window_Minimap.prototype.drawstyleScroll = function()
  1547. {
  1548.     // Opacity
  1549.     this.contents.paintOpacity = this.opacity = Silv.Minimap.Window_Opacity;
  1550.    
  1551.     // The minimap is so large it would require a source-map that is bigger. Because of this the entire map fits onto the minimap anyway so might as well switch to autofit instead of displaying a black image
  1552.     if (this.mapScroll.x < 0 || this.drawAreaWidth  * this.mapZoomInverse > this.mapBmp.width ||
  1553.         this.mapScroll.y < 0 || this.drawAreaHeight * this.mapZoomInverse > this.mapBmp.height)
  1554.         {
  1555.             this.drawstyleAutofit();
  1556.             return;
  1557.         }
  1558.    
  1559.     // This variable saves on calculations further down the road during this update
  1560.     // w = width, hw=  half width, zhw = zoomed half width
  1561.     this.tileInfo = {
  1562.             w: $gameMap.tileWidth(), hw: $gameMap.tileWidth() / 2.0, zhw: ($gameMap.tileWidth() / 2.0) * this.mapZoom,
  1563.             h: $gameMap.tileHeight(), hh: $gameMap.tileHeight() / 2.0, zhh: ($gameMap.tileHeight() / 2.0) * this.mapZoom
  1564.         };
  1565.    
  1566.     // Draw Map
  1567.     var map_src_rect = { x:0.0, y:0.0, w:0.0, h:0.0};
  1568.     map_src_rect.x = this.mapScroll.x;
  1569.     map_src_rect.y = this.mapScroll.y;
  1570.     map_src_rect.w = this.drawAreaWidth * this.mapZoomInverse;
  1571.     map_src_rect.h = this.drawAreaHeight * this.mapZoomInverse;
  1572.    
  1573.     this.contents.blt(this.mapBmp, this.mapScroll.x, this.mapScroll.y, this.drawAreaWidth * this.mapZoomInverse, this.drawAreaHeight * this.mapZoomInverse, Silv.Minimap.BorderWidth, Silv.Minimap.BorderHeight, this.drawAreaWidth, this.drawAreaHeight);
  1574.    
  1575.     // Debug Grid (if applicable)
  1576.     if (Silv.Minimap.DrawDebugGrid)
  1577.     {
  1578.         for (var i=0; i < $gameMap.width(); i++)
  1579.         {
  1580.             for (var j=0; j < $gameMap.height(); j++)
  1581.             {
  1582.                 var debugTileLoc = this.translateLocationScroll(this, i, j, this.tileInfo.w * this.mapZoom, this.tileInfo.h * this.mapZoom);
  1583.                 this.contents.blt(this.debugGridBmp, 0, 0, this.tileInfo.w, this.tileInfo.h, debugTileLoc.x, debugTileLoc.y, this.tileInfo.w * this.mapZoom, this.tileInfo.h * this.mapZoom);
  1584.             }
  1585.         }
  1586.     }
  1587.    
  1588.     // Draw POI's
  1589.     for (var i = 0; i < this.getAllPOI().length; i++)
  1590.     {
  1591.         var poi = this.getPOIByIdx(i);
  1592.         var poiLoc = this.translateLocationScroll(this, poi.real_x, poi.real_y, poi.destSize.w, poi.destSize.h);
  1593.         this.contents.blt(poi.bmp, poi.src.x, poi.src.y, poi.src.w, poi.src.h,
  1594.                           poiLoc.x, poiLoc.y, poi.destSize.w, poi.destSize.h);
  1595.     }
  1596.  
  1597.     // Draw Events
  1598.     for (var i=0; i < Silv.Minimap.Events.length; i++)
  1599.     {
  1600.         var ev = Silv.Minimap.Events[i].event;
  1601.         var ev_sprite = Silv.Minimap.Events[i].sprite;
  1602.         var evMapLoc = this.translateLocationScroll(this, ev._realX, ev._realY, Silv.Minimap.EventRenderSize, Silv.Minimap.EventRenderSize);
  1603.         this.contents.blt(ev_sprite._bitmap, ev_sprite._frame.x, ev_sprite._frame.y, ev_sprite._frame.width, ev_sprite._frame.height, evMapLoc.x, evMapLoc.y, Silv.Minimap.EventRenderSize, Silv.Minimap.EventRenderSize);
  1604.     }
  1605.    
  1606.     // Draw Player
  1607.     if (this.playerBlipEnabled && this.playerBlink_IsVisible)
  1608.     {
  1609.         this.drawPlayerBlip(this.contents, this.translateLocationScroll, this.playerInfo.src.x, this.playerInfo.src.y, this.playerInfo.src.width, this.playerInfo.src.height,
  1610.                             Silv.Minimap.PlayerIconWidth, Silv.Minimap.PlayerIconHeight);
  1611.     }
  1612.    
  1613.     // Overlay (if applicable)
  1614.     if (Silv.Minimap.DrawOverlay) { this.drawOverlay(); }
  1615. };
  1616.  
  1617. Window_Minimap.prototype.drawOverlay = function()
  1618. {
  1619.     this.contents.blt(this.overlayBmp, 0, 0, this.overlayBmp.width, this.overlayBmp.height, 0, 0, this.width, this.height);
  1620. };
  1621. //----------------------------------------------------------------------------------------------------
  1622. // #Translate functions
  1623. // Important: Because the translate functions are assigned to a variable, the this-keyword will be undefined! Therefore this can not be used and that's why I used "that" as a parameter :P. Also Silv.Minim.Window may be null so it must be a parameter.
  1624. // For more info see: http://stackoverflow.com/questions/4011793/this-is-undefined-in-javascript-class-methods
  1625. //----------------------------------------------------------------------------------------------------
  1626. // returns {x, y}
  1627. Window_Minimap.prototype.translateLocationScroll = function(that, obj_real_x, obj_real_y, obj_w, obj_h)
  1628. {
  1629.     var obj_x = (obj_real_x * that.tileInfo.w + that.tileInfo.hw) * that.mapZoom - that.mapScroll.x * that.mapZoom - obj_w / 2.0 + Silv.Minimap.BorderWidth;
  1630.     var obj_y = (obj_real_y * that.tileInfo.h + that.tileInfo.hh) * that.mapZoom - that.mapScroll.y * that.mapZoom - obj_h / 2.0 + Silv.Minimap.BorderHeight;
  1631.     return {x: obj_x, y: obj_y};
  1632. };
  1633.  
  1634. // returns {x, y}
  1635. Window_Minimap.prototype.translateLocationAutofit = function(that, obj_real_x, obj_real_y, obj_w, obj_h)
  1636. {
  1637.     var obj_x = (obj_real_x * that.tileInfo.w + that.tileInfo.hw) * that.mapAspRatInfo.scaleDelta_x * that.mapAspRatInfo.w - obj_w / 2.0 + that.mapAspRatInfo.offset_x + Silv.Minimap.BorderWidth;
  1638.     var obj_y = (obj_real_y * that.tileInfo.h + that.tileInfo.hh) * that.mapAspRatInfo.scaleDelta_y * that.mapAspRatInfo.h - obj_h / 2.0 + that.mapAspRatInfo.offset_y + Silv.Minimap.BorderHeight;
  1639.     return {x: obj_x, y: obj_y};
  1640. };
  1641.  
  1642. // returns {x, y}
  1643. Window_Minimap.prototype.translateLocationMenu = function(that, obj_real_x, obj_real_y, obj_w, obj_h)
  1644. {
  1645.     var obj_x = (obj_real_x * that.tileInfo.w + that.tileInfo.hw) * that.menuZoom - obj_w / 2.0;
  1646.     var obj_y = (obj_real_y * that.tileInfo.h + that.tileInfo.hh) * that.menuZoom - obj_h / 2.0;
  1647.     return {x: obj_x, y: obj_y};
  1648. };
  1649. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1650. // #POI
  1651. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1652. function MM_POI() { this.initialize.apply(this, arguments); }
  1653. // Set Constructor
  1654. MM_POI.prototype.constructor = MM_POI;
  1655.  
  1656. // Initialization
  1657. // real_x & real_y are in tiles
  1658. MM_POI.prototype.initialize = function(poi_id, name, desc, real_x, real_y, folderPath, filename, source_x, source_y, source_w, source_h, draw_w, draw_h)
  1659. {
  1660.   this.id = poi_id;
  1661.   this.name = name;
  1662.   this.desc = desc;
  1663.   this.real_x = real_x;
  1664.   this.real_y = real_y;
  1665.   this.folderPath = folderPath; // Required for saving&loading
  1666.   this.filename = filename; // Required for saving&loading
  1667.   this.bmp = ImageManager.loadBitmap(folderPath, filename, 0, false);
  1668.   this.src = { x:source_x, y:source_y, w:source_w, h:source_h };
  1669.   this.destSize = { w:draw_w, h:draw_h };
  1670.   this.tp = null;
  1671. };
  1672.  
  1673. // Note: Does not include the Bitmap
  1674. MM_POI.prototype.makeSaveContents = function()
  1675. {
  1676.     return  { id:this.id, name:this.name, desc:this.desc, real_x:this.real_x, real_y:this.real_y, src:this.src, destSize:this.destSize, folderPath:this.folderPath, filename:this.filename, tp:this.tp };
  1677. };
  1678.  
  1679. // Retrieves all the POI's for the current active $gameMap
  1680. Window_Minimap.prototype.getAllPOI = function()
  1681. {
  1682.     return Silv.Minimap.POI[$gameMap._mapId];
  1683. };
  1684.  
  1685. // Retrieves the specified POI by index for the current active $gameMap. Note this is NOT by POI id, this is by index.
  1686. Window_Minimap.prototype.getPOIByIdx = function(index)
  1687. {
  1688.     return Silv.Minimap.POI[$gameMap._mapId][index];
  1689. };
  1690.  
  1691. Window_Minimap.prototype.getPOIByID = function(id)
  1692. {
  1693.     for (var i=0; i<Silv.Minimap.POI[$gameMap._mapId].length; i++)
  1694.     {
  1695.         if (Silv.Minimap.POI[$gameMap._mapId][i].id == id) { return Silv.Minimap.POI[$gameMap._mapId][i]; }
  1696.     }
  1697.     throw new Error('getPOIByID(' + id + ') not found.');
  1698. };
  1699. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1700. // #Create the Minimap window
  1701. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1702. //----------------------------------------------------------------------------------------------------
  1703. // Scene Map (alias): Create Display Objects
  1704. //----------------------------------------------------------------------------------------------------
  1705. Silv.AddAlias('mm_Scene_Map_createDisplayObjects', Scene_Map.prototype.createDisplayObjects);
  1706. Scene_Map.prototype.createDisplayObjects = function()
  1707. {
  1708.     Silv.Alias.mm_Scene_Map_createDisplayObjects.apply(this, arguments);
  1709.     Silv.Minimap.setup();
  1710. };
  1711. //----------------------------------------------------------------------------------------------------
  1712. // Setup Minimap
  1713. // Call this method to create or re-create the minimap, if required. It does only create a minimap
  1714. // if it passes all the checks.
  1715. // Example: Silv.Minimap.setup();
  1716. //----------------------------------------------------------------------------------------------------
  1717. Silv.Minimap.setup = function()
  1718. {
  1719.     var didMapChange = $gameMap._mapId != this.LastMapID;
  1720.     if (didMapChange)
  1721.     {
  1722.         if (this.WasLoadedFromSave)
  1723.         {
  1724.             this.WasLoadedFromSave = false;
  1725.         }
  1726.         else
  1727.         {
  1728.             if (this.AutoClearPOI) { this.POI[$gameMap._mapId] = []; }
  1729.         }
  1730.     }
  1731.    
  1732.     // Create empty POI array if it's not defined yet for this map
  1733.     if (typeof this.POI[$gameMap._mapId] === 'undefined') { this.POI[$gameMap._mapId] = []; }
  1734.  
  1735.     SceneManager._scene.attemptToCreateMinimap();
  1736.     this.LastMapID = $gameMap._mapId;
  1737. }
  1738. //----------------------------------------------------------------------------------------------------
  1739. // Attempt To Create Minimap
  1740. //----------------------------------------------------------------------------------------------------
  1741. Scene_Map.prototype.attemptToCreateMinimap = function()
  1742. {
  1743.     var mapName = lpad_mapname($gameMap._mapId, '0') + '.png';
  1744.     if ('mm_mapshot' in $dataMap.meta)
  1745.     {
  1746.         if (Silv.Minimap.DebugMode) { console.log('A mapshot-notetag was found:' + $dataMap.meta.mm_mapshot + '.'); }
  1747.         mapName = lpad_mapname($dataMap.meta.mm_mapshot, '0') + '.png';
  1748.     }
  1749.    
  1750.     var createMinimap = false;
  1751.     var minimapType = null;
  1752.     var hasRequiredItems = this.MinimapHasRequiredItems();
  1753.    
  1754.     if (Silv.Minimap.Window !== null)
  1755.     {
  1756.         // #Dispose
  1757.         // This is required for values like "Silv.Minimap.Window.visible" to get 'reset' properly. Otherwise they keep the values from an old map which can lead to nasty bugs.
  1758.         this.removeWindow(Silv.Minimap.Window); // Required because the Scene_Map still holds a reference to the old minimap, effectively creating 2 or more minimaps if this method creates another one now...
  1759.         Silv.Minimap.Window = null;
  1760.         Silv.Minimap.Menu.Enabled = false;
  1761.         Silv.Minimap.Menu.Bmp = null;
  1762.         Silv.Minimap.Menu.Markers = [];
  1763.     }
  1764.    
  1765.     var windowWasVisible = Silv.Minimap.Visible;
  1766.     if (minimapImageExists(mapName))
  1767.     {
  1768.         if (hasRequiredItems)
  1769.         {
  1770.             createMinimap = true;
  1771.             minimapType = 'regular';
  1772.         }
  1773.     }
  1774.     else
  1775.     {
  1776.         if (Silv.Minimap.DebugMode) { console.log('No minimap \'' + mapName + '\' found for map with map-id: ' + $gameMap._mapId + '.'); }
  1777.        
  1778.         if (hasRequiredItems)
  1779.         {
  1780.             if (('mm_generate_worldmap' in $dataMap.meta) || ('mm_generate_overworld' in $dataMap.meta))
  1781.             {
  1782.                 if (Silv.Minimap.DebugMode && !$gameMap.isOverworld()) { console.log('Current map is NOT an overworld map but the minimap is set to treat it like a regular one.'); }
  1783.                 createMinimap = true;
  1784.                 minimapType = 'generate_overworld';
  1785.             } else if ('mm_generate_map' in $dataMap.meta)
  1786.             {
  1787.                 if (Silv.Minimap.DebugMode && $gameMap.isOverworld()) { console.log('Current map is an overworld map but the minimap is set to treat it like an overworld map.'); }
  1788.                 createMinimap = true;
  1789.                 minimapType = 'generate_map';
  1790.             }
  1791.         }
  1792.     }
  1793.    
  1794.     if (createMinimap)
  1795.     {
  1796.         this.createMinimapWindow(mapName.replace('.png', ''), minimapType);
  1797.         if (!windowWasVisible) { Silv.Minimap.Window.hide(); } // This is to prevent the minimap from showing itself again after opening a menu or when recreating the minimap while staying on the same map.
  1798.         if ('mm_generate_passability_overlay' in $dataMap.meta) { Silv.Minimap.Window.setPassabilityOverlay(true); }
  1799.     }
  1800.     // else
  1801.     // {
  1802.         //'Dispose'
  1803.         //This is required for values like "Silv.Minimap.Window.visible" to get 'reset' properly. Otherwise they keep the values from an old map which can lead to nasty bugs.
  1804.         // Silv.Minimap.Window = null;
  1805.     // }
  1806. };
  1807. //----------------------------------------------------------------------------------------------------
  1808. // Scene_Base: Remove Window
  1809. //----------------------------------------------------------------------------------------------------
  1810. // Omg why does RPG Maker not have this method by default...
  1811. Scene_Base.prototype.removeWindow = function(window)
  1812. {
  1813.     var index = this.children.indexOf(window);
  1814.     if (index > -1) { this.children.splice(index, 1); }
  1815. };
  1816. //----------------------------------------------------------------------------------------------------
  1817. // Create Minimap Window
  1818. //----------------------------------------------------------------------------------------------------
  1819. Scene_Map.prototype.createMinimapWindow = function(mapname, minimapType)
  1820. {
  1821.     var x = 0;
  1822.     if (Silv.Minimap.WindowHorizontalAlignment == 'right') { x = Graphics.width - Silv.Minimap.WindowWidth; }
  1823.     var y = 0;
  1824.     if (Silv.Minimap.WindowVerticalAlignment == 'bottom') { y = Graphics.height - Silv.Minimap.WindowHeight; }
  1825.    
  1826.     Silv.Minimap.Window = new Window_Minimap(x + Silv.Minimap.Window_X, y + Silv.Minimap.Window_Y, Silv.Minimap.WindowWidth, Silv.Minimap.WindowHeight, mapname, minimapType);
  1827.     Silv.Minimap.Window.resetFade();
  1828.    
  1829.     // override frameskip (map-specific frameskip)
  1830.     if ('mm_frameskip' in $dataMap.meta)
  1831.     {
  1832.         Silv.Minimap.Window.frameSkip = parseInt($dataMap.meta.mm_frameskip);
  1833.         if (Silv.Minimap.DebugMode) { console.log('Global frameskip: ' + Silv.Minimap.FrameSkip + ' was overriden by the map-specific frameskip of: ' + $dataMap.meta.mm_frameskip + '.'); }
  1834.     }
  1835.    
  1836.     this.addChildAt(Silv.Minimap.Window, 1);
  1837. };
  1838. //----------------------------------------------------------------------------------------------------
  1839. // Has Required Items
  1840. //----------------------------------------------------------------------------------------------------
  1841. Scene_Map.prototype.MinimapHasRequiredItems = function()
  1842. {
  1843.     // Check global item
  1844.     if (Silv.Minimap.GlobalRequiredItem > 0)
  1845.     {
  1846.         if (!$gameParty.hasItem($dataItems[Silv.Minimap.GlobalRequiredItem], false))
  1847.         {
  1848.             if (Silv.Minimap.DebugMode) { console.log('Minimap (or mapshot-notetag) was found but party does not possess the required global item: ' + $dataItems[Silv.Minimap.GlobalRequiredItem].name); }
  1849.             return false;
  1850.         }
  1851.     }
  1852.    
  1853.     // Check map-specific items
  1854.     if ('mm_req_itm' in $dataMap.meta)
  1855.     {
  1856.         var req_item_ids = $dataMap.meta.mm_req_itm.split(' ').filter(Boolean); // .filter(Boolean) removes empty strings from array
  1857.         for (var i = 0; i < req_item_ids.length; i++)
  1858.         {
  1859.             if (!$gameParty.hasItem($dataItems[req_item_ids[i]], false))
  1860.             {
  1861.                 if (Silv.Minimap.DebugMode) { console.log('Minimap was found but party does not possess the required map-specific item: ' + $dataItems[req_item_ids[i]].name); }
  1862.                 return false;
  1863.             }
  1864.         }
  1865.     }
  1866.    
  1867.     return true;
  1868. };
  1869. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1870. // Saving & Loading #Save #Saving #Loading
  1871. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1872. Silv.AddAlias('mm_DataManager_makeSaveContents', DataManager.makeSaveContents);
  1873. DataManager.makeSaveContents = function()
  1874. {
  1875.     contents = Silv.Alias.mm_DataManager_makeSaveContents.apply(this, arguments);
  1876.    
  1877.     contents.minimap = {};
  1878.     contents.minimap.poi = {};
  1879.    
  1880.     // POI
  1881.     for (var mapID in Silv.Minimap.POI)
  1882.     {
  1883.         if (Silv.Minimap.POI.hasOwnProperty(mapID))
  1884.         {
  1885.             if(Silv.Minimap.POI[mapID].length > 0) { contents.minimap.poi[mapID] = []; }
  1886.             for(var poi_idx=0; poi_idx<Silv.Minimap.POI[mapID].length; poi_idx++)
  1887.             {
  1888.                 contents.minimap.poi[mapID].push(Silv.Minimap.Window.getPOIByIdx(poi_idx).makeSaveContents());
  1889.             }
  1890.         }
  1891.     }
  1892.     return contents;
  1893. };
  1894.  
  1895. Silv.AddAlias('mm_DataManager_extractSaveContents', DataManager.extractSaveContents);
  1896. DataManager.extractSaveContents = function(contents)
  1897. {
  1898.     Silv.Alias.mm_DataManager_extractSaveContents.apply(this, arguments);
  1899.  
  1900.     // POI
  1901.     Silv.Minimap.POI = {};
  1902.     for (var mapID in contents.minimap.poi)
  1903.     {
  1904.         if (contents.minimap.poi.hasOwnProperty(mapID))
  1905.         {
  1906.             if(contents.minimap.poi[mapID].length > 0) { Silv.Minimap.POI[mapID] = []; }
  1907.             for(var poi_idx=0; poi_idx<contents.minimap.poi[mapID].length; poi_idx++)
  1908.             {
  1909.                 var poi = contents.minimap.poi[mapID][poi_idx];
  1910.                 var newPOI = new MM_POI(poi.id, poi.name, poi.desc, poi.real_x, poi.real_y, poi.folderPath, poi.filename, poi.src.x, poi.src.y, poi.src.w, poi.src.h, poi.destSize.w, poi.destSize.h);
  1911.                 newPOI.tp = poi.tp;
  1912.                 Silv.Minimap.POI[mapID].push(newPOI);
  1913.             }
  1914.         }
  1915.     }
  1916.    
  1917.     // Prevent the minimap from autoclearing it's POI's (if AutoClearPOI is enabled) when loading a savegame
  1918.     Silv.Minimap.WasLoadedFromSave = true;
  1919. };
  1920. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1921. // #Plugin Command
  1922. // Note: The items are separated by spaces. The command is the first word and any following words are args. args is an array.
  1923. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1924. Silv.AddAlias('mm_Game_Interpreter_pluginCommand', Game_Interpreter.prototype.pluginCommand);
  1925. Game_Interpreter.prototype.pluginCommand = function(command, args)
  1926. {
  1927.     Silv.Alias.mm_Game_Interpreter_pluginCommand.apply(this, arguments);
  1928.     if (command.toLowerCase() == 'minimap') { PluginCommand(command, args); }
  1929. };
  1930.  
  1931. function PluginCommand(cmd, args)
  1932. {
  1933.     if (Silv.Minimap.Window === null) { throw new Error('Minimap Plugin Commands can not be used when there is no active minimap. Either create one from a mapshot or generate one automatically'); }
  1934.    
  1935.     switch(args[0].toLowerCase())
  1936.     {
  1937.         case 'hide':
  1938.             Silv.Minimap.Window.hide();
  1939.             break;
  1940.         case 'show':
  1941.             Silv.Minimap.Window.show();
  1942.             break;
  1943.         case 'fadeout':
  1944.             Silv.Minimap.Window.isFadingOut = true;
  1945.             break;
  1946.         case 'fadereset':
  1947.             Silv.Minimap.Window.resetFade();
  1948.             break;
  1949.         case 'refresh':
  1950.             SceneManager._scene.attemptToCreateMinimap(false);
  1951.             break;
  1952.         case 'addpoi': // addpoi id, name, desc, real_x, real_y, bitmap folder, bitmap filename, s_x, s_y, s_w, s_h, draw_w, draw_h
  1953.             Silv.Minimap.POI[$gameMap._mapId].push(new MM_POI(args[1], args[2].replace('_', ' '), '', parseFloat(args[3]), parseFloat(args[4]), args[5], args[6], parseInt(args[7]), parseInt(args[8]), parseInt(args[9]), parseInt(args[10]), parseInt(args[11]), parseInt(args[12])));
  1954.             SceneManager._scene.attemptToCreateMinimap(false);
  1955.             break;
  1956.         case 'deletepoi':
  1957.             Silv.Minimap.POI[$gameMap._mapId] = Silv.Minimap.POI[$gameMap._mapId].filter(function(poi) { return poi.id != args[1]; });
  1958.             break;
  1959.         case 'poidesc':
  1960.               Silv.Minimap.Window.getPOIByID(parseInt(args[1])).desc = args.join(' ').substr(2 + args[0].length + args[1].length);
  1961.             break;
  1962.         case 'poi_tp': // POI_TP <poi_id x_offset, y_offset, direction, fadeType>
  1963.             Silv.Minimap.Window.getPOIByID(parseInt(args[1])).tp = [parseInt(args[2]), parseInt(args[3]), parseInt(args[4]), parseInt(args[5])];
  1964.             break;
  1965.         case 'refreshevents':
  1966.             Silv.Minimap.Window.loadEvents();
  1967.             break;
  1968.         case 'increasescroll':
  1969.             Silv.Minimap.Window.manualScroll(Silv.Minimap.Window.mapScroll.x + parseFloat(args[1]), Silv.Minimap.Window.mapScroll.y + parseFloat(args[2]));
  1970.             break;
  1971.         case 'setscroll':
  1972.             Silv.Minimap.Window.manualScroll(parseFloat(args[1]), parseFloat(args[2]));
  1973.             break;
  1974.         case 'generate_passability_overlay':
  1975.         case 'gen_pass_ov':
  1976.             Silv.Minimap.setPassabilityOverlay(args[1].toLowerCase() == 'true');
  1977.             break;
  1978.         case 'showmapmenu':
  1979.             Silv.Minimap.Window.showMapMenuScene();
  1980.             break;
  1981.         case 'setplayerblip':
  1982.             Silv.Minimap.Window.setPlayerBlip(args[1]);
  1983.             break;
  1984.         case 'setmapstyle':
  1985.             Silv.Minimap.Window.mapStyle = args[1].toLowerCase();
  1986.             break;
  1987.         case 'setfollowtarget':
  1988.         case 'setcamera':
  1989.             var followType = args[1].toLowerCase();
  1990.             if (followType == 'coordinate')
  1991.             {
  1992.                 Silv.Minimap.Window.setCameraFollowTarget(followType, [parseInt(args[2]), parseInt(args[3])]);
  1993.             }
  1994.             else
  1995.             {
  1996.                 Silv.Minimap.Window.setCameraFollowTarget(followType, args[2]);
  1997.             }
  1998.             break;
  1999.         default:
  2000.             throw new Error('Minimap, unknown Plugin Command: ' + args[0]);
  2001.     }
  2002. }
  2003. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2004. })();
  2005. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2006. // Map Menu #Scene
  2007. // Note: Must be placed outside of the })();
  2008. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2009. function Scene_MiniMap() { this.initialize.apply(this, arguments); }
  2010.  
  2011. Scene_MiniMap.prototype = Object.create(Scene_MenuBase.prototype);
  2012. Scene_MiniMap.prototype.constructor = Scene_MiniMap;
  2013.  
  2014. Scene_MiniMap.prototype.initialize = function()
  2015. {
  2016.     Scene_MenuBase.prototype.initialize.call(this);
  2017.     SoundManager.playOk();
  2018. };
  2019.  
  2020. Scene_MiniMap.prototype.create = function()
  2021. {
  2022.     Scene_MenuBase.prototype.create.call(this);
  2023.     this.createLeftWindow();
  2024.     this.createMapSectionWindow();
  2025.     this.createMapHelpWindow();
  2026.     this.refreshHelpWindow();
  2027. };
  2028.  
  2029. Scene_MiniMap.prototype.createLeftWindow = function()
  2030. {
  2031.     this._window_left = new Window_MinimapMenuLeft(0, 0);
  2032.     this._window_left.setHandler('ok',     this.onRangeOk.bind(this));
  2033.     this._window_left.setHandler('cancel', this.popScene.bind(this));
  2034.     this._window_left.setHandler('index_changed', this.index_changed.bind(this));
  2035.     this.addWindow(this._window_left);
  2036. };
  2037.  
  2038. Scene_MiniMap.prototype.createMapSectionWindow = function()
  2039. {
  2040.     var wx = this._window_left.width;
  2041.     var ww = Graphics.boxWidth - wx;
  2042.     this._mapSectionWindow = new Window_MapSection(wx, 0, ww);
  2043.     this._mapSectionWindow.setHandler('cancel', this.onEditCancel.bind(this));
  2044.     this._window_left.setMapWindow(this._mapSectionWindow);
  2045.     this.addWindow(this._mapSectionWindow);
  2046. };
  2047.  
  2048. Scene_MiniMap.prototype.createMapHelpWindow = function()
  2049. {
  2050.     var wx = this._mapSectionWindow.x;
  2051.     var wy = this._mapSectionWindow.height;
  2052.     var ww = this._mapSectionWindow.width;
  2053.     var wh = Graphics.boxHeight - wy;
  2054.     this._mapHelpWindow = new Window_Base(wx, wy, ww, wh);
  2055.     this.addWindow(this._mapHelpWindow);
  2056. };
  2057.  
  2058. Scene_MiniMap.prototype.index_changed = function()
  2059. {
  2060.     this.refreshHelpWindow();
  2061. };
  2062.  
  2063. Scene_MiniMap.prototype.onRangeOk = function()
  2064. {
  2065.     this._mapSectionWindow.activate();
  2066.     this._mapSectionWindow.select(0);
  2067.     this.refreshHelpWindow();
  2068. };
  2069.  
  2070. Scene_MiniMap.prototype.onEditCancel = function()
  2071. {
  2072.     this._window_left.activate();
  2073.     this._mapSectionWindow.deselect();
  2074.     this.refreshHelpWindow();
  2075. };
  2076.  
  2077. Scene_MiniMap.prototype.refreshHelpWindow = function()
  2078. {
  2079.     this._mapHelpWindow.contents.clear();
  2080.     this._mapHelpWindow.drawTextEx(this.helpText(), 4, 0);
  2081. };
  2082.  
  2083. Scene_MiniMap.prototype.helpText = function()
  2084. {
  2085.     var marker = this._window_left.marker();
  2086.     var tp_text = '';
  2087.     if (marker.tp !== null) { tp_text = '\nTeleports you to: ' + marker.tp[0] + ',' + marker.tp[1]; }
  2088.     return this._window_left.marker().desc + tp_text;
  2089. };
  2090. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2091. // Left Window #leftwindow
  2092. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2093. function Window_MinimapMenuLeft() { this.initialize.apply(this, arguments); }
  2094.  
  2095. Window_MinimapMenuLeft.prototype = Object.create(Window_Selectable.prototype);
  2096. Window_MinimapMenuLeft.prototype.constructor = Window_MinimapMenuLeft;
  2097.  
  2098. Window_MinimapMenuLeft.lastTopRow = 0;
  2099. Window_MinimapMenuLeft.lastIndex  = 0;
  2100.  
  2101. Window_MinimapMenuLeft.prototype.initialize = function(x, y)
  2102. {
  2103.     var width = this.windowWidth();
  2104.     var height = this.windowHeight();
  2105.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  2106.     this.refresh();
  2107.     this.setTopRow(Window_MinimapMenuLeft.lastTopRow);
  2108.     this.select(Window_MinimapMenuLeft.lastIndex);
  2109.     this.activate();
  2110. };
  2111.  
  2112. Window_MinimapMenuLeft.prototype.windowWidth = function()
  2113. {
  2114.     return Silv.Minimap.Menu.WindowWidth_Left;
  2115. };
  2116.  
  2117. Window_MinimapMenuLeft.prototype.windowHeight = function()
  2118. {
  2119.     return Graphics.boxHeight;
  2120. };
  2121.  
  2122. Window_MinimapMenuLeft.prototype.maxItems = function()
  2123. {
  2124.     return Silv.Minimap.Menu.Markers.length;
  2125. };
  2126.  
  2127. Window_MinimapMenuLeft.prototype.update = function()
  2128. {
  2129.     Window_Selectable.prototype.update.call(this);
  2130.     if (this._mapWindow) { this._mapWindow.setMarker(this.marker()); }
  2131.     if (this.index() != Window_MinimapMenuLeft.lastIndex)
  2132.     {
  2133.         Window_MinimapMenuLeft.lastIndex = this.index();
  2134.         this.callHandler('index_changed');
  2135.     }
  2136.    
  2137.     if (Input.isTriggered('ok'))
  2138.     {
  2139.         var marker = this.marker();
  2140.         if(marker.tp !== null)
  2141.         {
  2142.             // Add the teleport location to the minimap and dequeue this scene to return to the previous scene
  2143.             SoundManager.playOk();
  2144.             Silv.Minimap.TP_Dest = marker.tp;
  2145.             SceneManager.pop();
  2146.         }
  2147.     }
  2148.    
  2149.     if (Input.isTriggered(Silv.Minimap.Menu.MenuKey))
  2150.     {
  2151.         SoundManager.playCancel();
  2152.         SceneManager.pop();
  2153.     }
  2154. };
  2155.  
  2156. Window_MinimapMenuLeft.prototype.marker = function()
  2157. {
  2158.     return Silv.Minimap.Menu.Markers[this.index()];
  2159. };
  2160.  
  2161. Window_MinimapMenuLeft.prototype.refresh = function()
  2162. {
  2163.     this.createContents();
  2164.     this.drawAllItems();
  2165. };
  2166.  
  2167. Window_MinimapMenuLeft.prototype.drawItem = function(index)
  2168. {
  2169.     var rect = this.itemRectForText(index);
  2170.     var text = Silv.Minimap.Menu.Markers[index].text;
  2171.     this.drawText(text, rect.x, rect.y, rect.width);
  2172. };
  2173.  
  2174. Window_MinimapMenuLeft.prototype.isCancelTriggered = function()
  2175. {
  2176.     return (Window_Selectable.prototype.isCancelTriggered());
  2177. };
  2178.  
  2179. Window_MinimapMenuLeft.prototype.processCancel = function()
  2180. {
  2181.     Window_Selectable.prototype.processCancel.call(this);
  2182.     Window_MinimapMenuLeft.lastTopRow = this.topRow();
  2183.     Window_MinimapMenuLeft.lastIndex = this.index();
  2184. };
  2185.  
  2186. Window_MinimapMenuLeft.prototype.setMapWindow = function(mapWindow)
  2187. {
  2188.     this._mapWindow = mapWindow;
  2189.     this.update();
  2190. };
  2191. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2192. // Map Section Window
  2193. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2194. function Window_MapSection() { this.initialize.apply(this, arguments); }
  2195.  
  2196. Window_MapSection.prototype = Object.create(Window_Selectable.prototype);
  2197. Window_MapSection.prototype.constructor = Window_MapSection;
  2198.  
  2199. Window_MapSection.prototype.initialize = function(x, y, width)
  2200. {
  2201.     var height = Silv.Minimap.Menu.WindowHeight_MapSection;
  2202.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  2203.     this._marker = 1;
  2204.     this.mapScroll = {x:0, y:0};
  2205.     this.mapZoom = 1.0;
  2206.     this.centerLoc = {x:width / 2.0, y: height / 2.0};
  2207.     this.refresh();
  2208. };
  2209.  
  2210. // Hide the cursor
  2211. Window_MapSection.prototype.updateCursor = function()
  2212. {
  2213.     this.setCursorRect(0, 0, 0, 0);
  2214. };
  2215.  
  2216. Window_MapSection.prototype.maxItems = function() { return 0; };
  2217.  
  2218. Window_MapSection.prototype.refresh = function()
  2219. {
  2220.     this.contents.clear();
  2221.     this.drawMap();
  2222. };
  2223.  
  2224. // Prevent anything from being drawn in the base-class
  2225. Window_MapSection.prototype.drawAllItems = function(){};
  2226.  
  2227. Window_MapSection.prototype.drawMap = function()
  2228. {
  2229.     this.contents.blt(Silv.Minimap.Menu.Bmp, 0, 0, Silv.Minimap.Menu.Bmp.width, Silv.Minimap.Menu.Bmp.height, this.mapScroll.x, this.mapScroll.y, Silv.Minimap.Menu.Bmp.width * this.mapZoom, Silv.Minimap.Menu.Bmp.height * this.mapZoom);
  2230. };
  2231.  
  2232. Window_MapSection.prototype.centerOnMarker = function(marker)
  2233. {
  2234.     this.mapScroll.x = this.centerLoc.x - marker.map_x - marker.w / 2.0;
  2235.     this.mapScroll.y = this.centerLoc.y - marker.map_y - marker.h / 2.0;
  2236.     this.refresh();
  2237. };
  2238.  
  2239. Window_MapSection.prototype.setMarker = function(marker)
  2240. {
  2241.     if (this._marker !== marker)
  2242.     {
  2243.         this._marker = marker;
  2244.         this.centerOnMarker(marker);
  2245.     }
  2246. };
  2247.  
  2248. Window_MapSection.prototype.update = function()
  2249. {
  2250.     Window_Selectable.prototype.update.call(this);
  2251.     if (this.active) {
  2252.         if (Input.isPressed('up')) { this.mapScroll.y += 10; this.refresh(); }
  2253.         if (Input.isPressed('right')) { this.mapScroll.x -= 10; this.refresh(); }
  2254.         if (Input.isPressed('down')) { this.mapScroll.y -= 10; this.refresh(); }
  2255.         if (Input.isPressed('left')) { this.mapScroll.x += 10; this.refresh(); }
  2256.         if (Input.isPressed(Silv.Minimap.Menu.ManualScrollKey_Reset)) { this.mapScroll.x = 0; this.mapScroll.y = 0; this.refresh(); }
  2257.        
  2258.         if (Input.isPressed(Silv.Minimap.Menu.ManualZoomKey_In))
  2259.         {
  2260.             this.mapZoom += 0.05;
  2261.             if (this.mapZoom > Silv.Minimap.Menu.ManualZoom_Max) { this.mapZoom = Silv.Minimap.Menu.ManualZoom_Max; }
  2262.             this.refresh();
  2263.         }
  2264.         if (Input.isPressed(Silv.Minimap.Menu.ManualZoomKey_Out))
  2265.         {
  2266.             this.mapZoom -= 0.05;
  2267.             if (this.mapZoom < Silv.Minimap.Menu.ManualZoom_Min) { this.mapZoom = Silv.Minimap.Menu.ManualZoom_Min; }
  2268.             this.refresh();
  2269.         }
  2270.         if  (Input.isPressed(Silv.Minimap.Menu.ManualZoomKey_Reset)) { this.mapZoom = 1.0; this.refresh(); }
  2271.     }
  2272. };
  2273. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2274. // This is the end of this awesome script! Why did you even read this line ;)
  2275. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement