Advertisement
WCouillard

RGSS3: Custom Map Name Display v1.04 [RMVXA]

Sep 13th, 2013
872
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 27.58 KB | None | 0 0
  1. # ╔══════════════════════════════════════════════════════╤═══════╤════════════╗
  2. # ║ Custom Map Name Display                              │ v1.04 │ (05/14/15) ║
  3. # ╠══════════════════════════════════════════════════════╧═══════╧════════════╣
  4. # ║ Author:  William Couillard                                                ║
  5. # ║ E-Mail:  cooliebk18@yahoo.com                                             ║
  6. # ╠═══════════════════════════════════════════════════════════════════════════╣
  7. # ║ ABOUT                                                                     ║
  8. # ╠═══════════════════════════════════════════════════════════════════════════╣
  9. # ║ This script gives you options on how to display map names.                ║
  10. # ╠═══════════════════════════════════════════════════════════════════════════╣
  11. # ║ TERMS OF USE                                                              ║
  12. # ╠═══════════════════════════════════════════════════════════════════════════╣
  13. # ║ ► Do not edit the script's header or comments.                            ║
  14. # ║ ► Free to use in commercial projects as long as proper credit is given to ║
  15. # ║   ALL the names in the above header.                                      ║
  16. # ╠═══════════════════════════════════════════════════════════════════════════╣
  17. # ║ FEATURES                                                                  ║
  18. # ╠═══════════════════════════════════════════════════════════════════════════╣
  19. # ║ ► Various customizations for Window_MapName to change how map names are   ║
  20. # ║   displayed.                                                              ║
  21. # ╠═══════════════════════════════════════════════════════════════════════════╣
  22. # ║ CHANGE LOG                                                                ║
  23. # ╠═══════════════════════════════════════════════════════════════════╤═══════╣
  24. # ║ ■ May 14, 2015       : Window height option added, back opacity   │ v1.04 ║
  25. # ║                        limit option added.                        │       ║
  26. # ╟───────────────────────────────────────────────────────────────────┼───────╢
  27. # ║ ■ May 13, 2015       : Bugfixes.                                  │ v1.03 ║
  28. # ╟───────────────────────────────────────────────────────────────────┼───────╢
  29. # ║ ■ November 22, 2013  : Fixed bug with window mode.                │ v1.02 ║
  30. # ╟───────────────────────────────────────────────────────────────────┼───────╢
  31. # ║ ■ November 22, 2013  : Fixed bug with alignment.                  │ v1.01 ║
  32. # ╟───────────────────────────────────────────────────────────────────┼───────╢
  33. # ║ ■ September 13, 2013 : Initial release.                           │ v1.00 ║
  34. # ╠═══════════════════════════════════════════════════════════════════╧═══════╣
  35. # ║ NEXT VERSION                                                              ║
  36. # ╠═══════════════════════════════════════════════════════════════════════════╣
  37. # ║ ■ Possible update to allow more customization options.                    ║
  38. # ╠═══════════════════════════════════════════════════════════════════════════╣
  39. # ║ METHOD OVERWRITES                                                         ║
  40. # ╠═══════════════════════════════════════════════════════════════════════════╣
  41. # ║ ► This script overwrites several methods in Window_MapName.               ║
  42. # ╟───────────────────────────────────────────────────────────────────────────╢
  43. # ║ ■ class Window_MapName < Window_Base                                      ║
  44. # ║    ► def initialize                                                       ║
  45. # ║    ► def window_width                                                     ║
  46. # ║    ► def window_height                                                    ║
  47. # ║    ► def update                                                           ║
  48. # ║    ► def update_fadein                                                    ║
  49. # ║    ► def update_fadeout                                                   ║
  50. # ║    ► def open                                                             ║
  51. # ║    ► def close                                                            ║
  52. # ║    ► def refresh                                                          ║
  53. # ║    ► def draw_background                                                  ║
  54. # ║    ► def back_color1                                                      ║
  55. # ║    ► def back_color2                                                      ║
  56. # ╠═══════════════════════════════════════════════════════════════════════════╣
  57. # ║ NEW METHODS                                                               ║
  58. # ╠═══════════════════════════════════════════════════════════════════════════╣
  59. # ║   This script creates one new method in Window_MapName.                   ║
  60. # ╟───────────────────────────────────────────────────────────────────────────╢
  61. # ║ ■ class Window_MapName < Window_Base                                      ║
  62. # ║    ► def y_pos                                                            ║
  63. # ╠═══════════════════════════════════════════════════════════════════════════╣
  64. # ║ INSTRUCTIONS                                                              ║
  65. # ╠═══════════════════════════════════════════════════════════════════════════╣
  66. # ║ Simply paste this script anywhere above the Main script and below the     ║
  67. # ║ Window_MapName script.                                                    ║
  68. # ╠═══════════════════════════════════════════════════════════════════════════╣
  69. # ║ IMPORT SETTING                                                            ║
  70. # ╚═══════════════════════════════════════════════════════════════════════════╝
  71. $imported = {} if $imported.nil?
  72. $imported[:wc_custom_map_name_display] = true
  73. # ╔═══════════════════════════════════════════════════════════════════════════╗
  74. # ║ Coolie's Custom Map Name Display Module                                   ║
  75. # ╟───────────────────────────────────────────────────────────────────────────╢
  76. # ║ This module manages this script's settings.                               ║
  77. # ╚═══════════════════════════════════════════════════════════════════════════╝
  78. module COOLIE
  79.   module MAPNAME
  80. # ╔═══════════════════════════════════════════════════════════════════════════╗
  81. # ║ Use Window or Transparency? (true/false)                                  ║
  82. # ╚═══════════════════════════════════════════════════════════════════════════╝
  83.     MAPNAME_WINDOWMODE    = true
  84. # ╔═══════════════════════════════════════════════════════════════════════════╗
  85. # ║ No. of Frames to Show Map Name (60 frames = 1 second)                     ║
  86. # ╚═══════════════════════════════════════════════════════════════════════════╝
  87.     MAPNAME_SHOW_COUNT    = 180
  88. # ╔═══════════════════════════════════════════════════════════════════════════╗
  89. # ║ Y Offset of Map Name Window                                               ║
  90. # ╚═══════════════════════════════════════════════════════════════════════════╝
  91.     MAPNAME_Y             = 0
  92. # ╔═══════════════════════════════════════════════════════════════════════════╗
  93. # ║ Width of Map Name Window                                                  ║
  94. # ╚═══════════════════════════════════════════════════════════════════════════╝
  95.     MAPNAME_WIDTH         = 544
  96. # ╔═══════════════════════════════════════════════════════════════════════════╗
  97. # ║ Height of Map Name Window                                                 ║
  98. # ╚═══════════════════════════════════════════════════════════════════════════╝
  99.     MAPNAME_HEIGHT        = 48
  100. # ╔═══════════════════════════════════════════════════════════════════════════╗
  101. # ║ Alignment of Map Name Window Text [0:Left, 1: Center, 2: Right]           ║
  102. # ╚═══════════════════════════════════════════════════════════════════════════╝
  103.     MAPNAME_ALIGN         = 1
  104. # ╔═══════════════════════════════════════════════════════════════════════════╗
  105. # ║ Alignment of Map Name Window [0:Left, 1: Center, 2: Right]                ║
  106. # ╚═══════════════════════════════════════════════════════════════════════════╝
  107.     MAPNAME_W_ALIGN       = 1
  108. # ╔═══════════════════════════════════════════════════════════════════════════╗
  109. # ║ Opacity Limit (Window opacity won't go higher than this value / 0-255)    ║
  110. # ╚═══════════════════════════════════════════════════════════════════════════╝
  111.     MAPNAME_OPACITY_LIMIT = 255
  112. # ╔═══════════════════════════════════════════════════════════════════════════╗
  113. # ║ Map Color 1 (Used for gradient / 0-255) [R, G, B, Alpha]                  ║
  114. # ╚═══════════════════════════════════════════════════════════════════════════╝
  115.     MAPNAME_COLOR1        = Color.new(0, 0, 0, 160)
  116. # ╔═══════════════════════════════════════════════════════════════════════════╗
  117. # ║ Map Color 2 (Used for gradient / 0-255) [R, G, B, Alpha]                  ║
  118. # ╚═══════════════════════════════════════════════════════════════════════════╝
  119.     MAPNAME_COLOR2        = Color.new(0, 0, 0, 128)
  120.   end
  121. end
  122. # ╔═══════════════════════════════════════════════════════════════════════════╗
  123. # ║ Window_MapName                                                            ║
  124. # ╟───────────────────────────────────────────────────────────────────────────╢
  125. # ║ This window displays the map name.                                        ║
  126. # ╚═══════════════════════════════════════════════════════════════════════════╝
  127. class Window_MapName < Window_Base
  128. # ╔═══════════════════════════════════════════════════════════════════════════╗
  129. # ║ Object Initialization                                                     ║
  130. # ╚═══════════════════════════════════════════════════════════════════════════╝
  131.   def initialize
  132.     case COOLIE::MAPNAME::MAPNAME_W_ALIGN
  133.      when 0
  134.        super(0, y_pos, window_width, window_height)
  135.      when 1
  136.        super(Graphics.width / 2 - window_width / 2, y_pos, window_width,
  137.              window_height)
  138.      when 2
  139.        super(Graphics.width - window_width, y_pos, window_width, window_height)
  140.     end
  141.     self.opacity = 0
  142.     self.back_opacity = 0
  143.     self.contents_opacity = 0
  144.     @show_count = 0
  145.     refresh
  146.   end
  147. # ╔═══════════════════════════════════════════════════════════════════════════╗
  148. # ║ Method: y_pos                                                             ║
  149. # ╚═══════════════════════════════════════════════════════════════════════════╝
  150.   def y_pos
  151.     return COOLIE::MAPNAME::MAPNAME_Y
  152.   end
  153. # ╔═══════════════════════════════════════════════════════════════════════════╗
  154. # ║ Method: window_width                                                      ║
  155. # ╚═══════════════════════════════════════════════════════════════════════════╝
  156.   def window_width
  157.     return COOLIE::MAPNAME::MAPNAME_WIDTH
  158.   end
  159. # ╔═══════════════════════════════════════════════════════════════════════════╗
  160. # ║ Method: window_height                                                     ║
  161. # ╚═══════════════════════════════════════════════════════════════════════════╝
  162.   def window_height
  163.     return COOLIE::MAPNAME::MAPNAME_HEIGHT
  164.   end
  165. # ╔═══════════════════════════════════════════════════════════════════════════╗
  166. # ║ Method: update                                                            ║
  167. # ╚═══════════════════════════════════════════════════════════════════════════╝
  168.   def update
  169.     super
  170.     if @show_count > 0 && $game_map.name_display
  171.       update_fadein
  172.       @show_count -= 1
  173.       self.opacity = COOLIE::MAPNAME::MAPNAME_OPACITY_LIMIT if self.opacity >=
  174.                       COOLIE::MAPNAME::MAPNAME_OPACITY_LIMIT
  175.     else
  176.       update_fadeout
  177.     end
  178.   end
  179. # ╔═══════════════════════════════════════════════════════════════════════════╗
  180. # ║ Method: update_fadein                                                     ║
  181. # ╚═══════════════════════════════════════════════════════════════════════════╝
  182.   def update_fadein
  183.     if COOLIE::MAPNAME::MAPNAME_WINDOWMODE == false
  184.       self.opacity += 0 unless $game_map.display_name.empty?
  185.       self.back_opacity += 0 unless $game_map.display_name.empty?
  186.       self.contents_opacity += 16
  187.     else
  188.       self.opacity += 16 unless $game_map.display_name.empty?
  189.       self.back_opacity += 16 unless $game_map.display_name.empty?
  190.       self.contents_opacity += 16
  191.     end
  192.   end
  193. # ╔═══════════════════════════════════════════════════════════════════════════╗
  194. # ║ Method: update_fadeout                                                    ║
  195. # ╚═══════════════════════════════════════════════════════════════════════════╝
  196.   def update_fadeout
  197.     if COOLIE::MAPNAME::MAPNAME_WINDOWMODE == false
  198.       self.opacity -= 0 unless $game_map.display_name.empty?
  199.       self.back_opacity -= 0 unless $game_map.display_name.empty?
  200.       self.contents_opacity -= 16
  201.     else
  202.       self.opacity -= 16 unless $game_map.display_name.empty?
  203.       self.back_opacity -= 16 unless $game_map.display_name.empty?
  204.       self.contents_opacity -= 16
  205.     end
  206.   end
  207. # ╔═══════════════════════════════════════════════════════════════════════════╗
  208. # ║ Method: open                                                              ║
  209. # ╚═══════════════════════════════════════════════════════════════════════════╝
  210.   def open
  211.     refresh
  212.     @show_count = COOLIE::MAPNAME::MAPNAME_SHOW_COUNT
  213.     self.opacity = 0
  214.     self.back_opacity = 0
  215.     self.contents_opacity = 0
  216.     self
  217.   end
  218. # ╔═══════════════════════════════════════════════════════════════════════════╗
  219. # ║ Method: close                                                             ║
  220. # ╚═══════════════════════════════════════════════════════════════════════════╝
  221.   def close
  222.     @show_count = 0
  223.     self
  224.   end
  225. # ╔═══════════════════════════════════════════════════════════════════════════╗
  226. # ║ Method: refresh                                                           ║
  227. # ╚═══════════════════════════════════════════════════════════════════════════╝
  228.   def refresh
  229.     contents.clear
  230.     unless $game_map.display_name.empty?
  231.       draw_background(contents.rect) if COOLIE::MAPNAME::MAPNAME_WINDOWMODE == false
  232.       draw_text(contents.rect, $game_map.display_name, COOLIE::MAPNAME::MAPNAME_ALIGN)
  233.     end
  234.   end
  235. # ╔═══════════════════════════════════════════════════════════════════════════╗
  236. # ║ Method: draw_background                                                   ║
  237. # ╚═══════════════════════════════════════════════════════════════════════════╝
  238.   def draw_background(rect)
  239.     temp_rect = rect.clone
  240.     temp_rect.width /= 2
  241.     contents.gradient_fill_rect(temp_rect, back_color2, back_color1)
  242.     temp_rect.x = temp_rect.width
  243.     contents.gradient_fill_rect(temp_rect, back_color1, back_color2)
  244.   end
  245. # ╔═══════════════════════════════════════════════════════════════════════════╗
  246. # ║ Method: back_color1                                                       ║
  247. # ╚═══════════════════════════════════════════════════════════════════════════╝
  248.   def back_color1
  249.     COOLIE::MAPNAME::MAPNAME_COLOR1
  250.   end
  251. # ╔═══════════════════════════════════════════════════════════════════════════╗
  252. # ║ Method: back_color2                                                       ║
  253. # ╚═══════════════════════════════════════════════════════════════════════════╝
  254.   def back_color2
  255.     COOLIE::MAPNAME::MAPNAME_COLOR2
  256.   end
  257. # ╔═══════════════════════════════════════════════════════════════════════════╗
  258. # ║ End of Script                                                             ║
  259. # ╚═══════════════════════════════════════════════════════════════════════════╝
  260. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement