Advertisement
MakerSystems

RPG Maker VX Ace - Scrolling Help Descriptions

Jun 5th, 2015
1,102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.50 KB | None | 0 0
  1. %Q(
  2. ╔════╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═════╗
  3. ║ ╔══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╗ ║
  4. ╠─╣ Scrolling Help Descriptions. ╠─╣
  5. ╠─╣ by RPG Maker Source. ╠─╣
  6. ╠─╣ www.rpgmakersource.com ╠─╣
  7. ║ ╚══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╝ ║
  8. ╠════╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═╤═╩═════╣
  9. ║ ┌────┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴─────┐ ║
  10. ╠─┤ Version 1.0.1 01/07/15 DD/MM/YY ├─╣
  11. ║ └────┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬─────┘ ║
  12. ╠══════╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══╧═══════╣
  13. ║ ║
  14. ║ This work is protected by the following license: ║
  15. ║ ╔══════════════════════════════════════════════════════════════════╗ ║
  16. ║ │ │ ║
  17. ║ │ Copyright © 2014 Maker Systems. │ ║
  18. ║ │ │ ║
  19. ║ │ This software is provided 'as-is', without any kind of │ ║
  20. ║ │ warranty. Under no circumstances will the author be held │ ║
  21. ║ │ liable for any damages arising from the use of this software. │ ║
  22. ║ │ │ ║
  23. ║ │ Permission is granted to anyone to use this software on their │ ║
  24. ║ │ free or commercial games made with a legal copy of RPG Maker │ ║
  25. ║ │ VX Ace, as long as Maker Systems - RPG Maker Source is │ ║
  26. ║ │ credited within the game. │ ║
  27. ║ │ │ ║
  28. ║ │ Selling this code or any portions of it 'as-is' or as part of │ ║
  29. ║ │ another code, is not allowed. │ ║
  30. ║ │ │ ║
  31. ║ │ The original header, which includes this copyright notice, │ ║
  32. ║ │ must not be edited or removed from any verbatim copy of the │ ║
  33. ║ │ sotware nor from any edited version. │ ║
  34. ║ │ │ ║
  35. ║ ╚══════════════════════════════════════════════════════════════════╝ ║
  36. ║ ║
  37. ║ ║
  38. ╠══════════════════════════════════════════════════════════════════════════════╣
  39. ║ 1. VERSION HISTORY. ▼ ║
  40. ╠══════════════════════════════════════════════════════════════════════════════╣
  41. ║ ║
  42. ║ • Version 1.0.0, 05/06/15 - (DD/MM/YY). ║
  43. ║ ║
  44. ║ • Version 1.0.1, 01/07/15 - (DD/MM/YY). ║
  45. ║ - Properly matches the visibility and opacity of the window. ║
  46. ║ ║
  47. ╠══════════════════════════════════════════════════════════════════════════════╣
  48. ╠══════════════════════════════════════════════════════════════════════════════╣
  49. ║ 2. USER MANUAL. ▼ ║
  50. ╠══════════════════════════════════════════════════════════════════════════════╣
  51. ║ ║
  52. ║ ┌──────────────────────────────────────────────────────────────────────────┐ ║
  53. ║ │ ■ Introduction. │ ║
  54. ║ └┬┬┬┬──────────────────────────────────────────────────────────────────┬┬┬┬┘ ║
  55. ║ ║
  56. ║ Hello there! This script is "plug and play", you can simply insert it into ║
  57. ║ your project and it will perform flawlessly. ║
  58. ║ ║
  59. ║ This script makes the second description line displayed in Help windows ║
  60. ║ scroll if the line is wider than the window. ║
  61. ║ By default, the text is shrinked to fit it into the window, but using ║
  62. ║ this script, the text will be kept in its perfect dimensions and instead, ║
  63. ║ the line will cycle horizontally at the desired speed. ║
  64. ║ ║
  65. ║ We hope you enjoy it. ║
  66. ║ ║
  67. ║ Thanks for choosing our products. ║
  68. ║ ║
  69. ║ ┌──────────────────────────────────────────────────────────────────────────┐ ║
  70. ║ │ ■ Configuration. │ ║
  71. ║ └┬┬┬┬──────────────────────────────────────────────────────────────────┬┬┬┬┘ ║
  72. ║ ║
  73. ║ "How do I change the speed of the scrolling?" ║
  74. ║ Right click anywhere in the script editor and select "Find" (or CTRL + F) ║
  75. ║ search for "SPEED" (without quotation marks). ║
  76. ║ ║
  77. ║ You will see something like "SPEED = 0.8" ║
  78. ║ ║
  79. ║ Set the number after the equality sign to any numer you like, bigger ║
  80. ║ than 0. The bigger the number, the faster the scrolling will seem, and ║
  81. ║ the smaller the number, the slower. ║
  82. ║ ║
  83. ╠══════════════════════════════════════════════════════════════════════════════╣
  84. ╠══════════════════════════════════════════════════════════════════════════════╣
  85. ║ 3. NOTES. ▼ ║
  86. ╠══════════════════════════════════════════════════════════════════════════════╣
  87. ║ ║
  88. ║ Have fun and enjoy! ║
  89. ║ ║
  90. ╠══════════════════════════════════════════════════════════════════════════════╣
  91. ╠══════════════════════════════════════════════════════════════════════════════╣
  92. ║ 4. CONTACT. ▼ ║
  93. ╠══════════════════════════════════════════════════════════════════════════════╣
  94. ║ ║
  95. ║ Keep in touch with us and be the first to know about new releases: ║
  96. ║ ║
  97. ║ www.rpgmakersource.com ║
  98. ║ www.facebook.com/RPGMakerSource ║
  99. ║ www.twitter.com/RPGMakerSource ║
  100. ║ www.youtube.com/user/RPGMakerSource ║
  101. ║ ║
  102. ║ Get involved! Have an idea for a system? Let us know. ║
  103. ║ ║
  104. ║ Spread the word and help us reach more people so we can continue creating ║
  105. ║ awesome resources for you! ║
  106. ║ ║
  107. ╚══════════════════════════════════════════════════════════════════════════════╝)
  108.  
  109. #==============================================================================
  110. # ** MakerSystems
  111. #------------------------------------------------------------------------------
  112. # Module for our scripts.
  113. #==============================================================================
  114.  
  115. module MakerSystems
  116.  
  117. #============================================================================
  118. # ** MessagePauseAnimation
  119. #----------------------------------------------------------------------------
  120. # This module is used to easily change the behavior of the script.
  121. #============================================================================
  122.  
  123. module ScrollingHelpDescriptions
  124.  
  125. #------------------------------------------------------------------------
  126. # * Scrolling Speed.
  127. #------------------------------------------------------------------------
  128. # Bigger numbers mean faster scrolling. Default is 0.8
  129. #------------------------------------------------------------------------
  130. SPEED = 0.8
  131.  
  132. end
  133.  
  134. end
  135.  
  136. #==============================================================================
  137. # ** Window_Help
  138. #------------------------------------------------------------------------------
  139. # This window shows skill and item explanations along with actor status.
  140. #==============================================================================
  141.  
  142. class Window_Help < Window_Base
  143.  
  144. #--------------------------------------------------------------------------
  145. # * Update. [MOD]
  146. #--------------------------------------------------------------------------
  147. def update
  148. # Original method.
  149. super
  150. @ms_scrolling_help_speed ||= MakerSystems::ScrollingHelpDescriptions::SPEED
  151. # Scrolling line?
  152. if @ms_scrolling_help_line
  153. text = contents_opacity
  154. help = opacity
  155. @ms_scrolling_help_line.visible = visible
  156. @ms_scrolling_help_line.opacity = text < help ? text : help
  157. # Advance the step value.
  158. @ms_scrolling_help_step += @ms_scrolling_help_speed
  159. # If step value is greater than 1, scroll the line.
  160. if @ms_scrolling_help_step > 1.0
  161. # Reset step value.
  162. @ms_scrolling_help_step = 0.0
  163. # Change the offset X to scroll.
  164. @ms_scrolling_help_line.ox += 1
  165. end
  166. end
  167. end
  168.  
  169. #--------------------------------------------------------------------------
  170. # * Set Text. [REP]
  171. #--------------------------------------------------------------------------
  172. def set_text(text)
  173. # New text?
  174. if text != @text
  175. # Get each line of the description.
  176. lines = text.split(/\r\n/)
  177. # Dispose the Scrolling Help objects if needed.
  178. ms_scrolling_help_dispose if @ms_scrolling_help_line
  179. # Is there a second line that exceeds the window width?
  180. if lines[1] && (line_width = contents.text_size(lines[1]).width) > width
  181. # Then assign the first line as the "normal" text.
  182. @text = lines[0]
  183. # ...and draw the second line as a scrolling line.
  184. ms_scrolling_help_create(lines[1], line_width)
  185. else
  186. # Normal method.
  187. @text = text
  188. end
  189. # Draws stuff on thangs.
  190. refresh
  191. end
  192. end
  193.  
  194. #--------------------------------------------------------------------------
  195. # * Scrolling Help Create. [NEW]
  196. #--------------------------------------------------------------------------
  197. def ms_scrolling_help_create(line, width)
  198. # Create a Bitmap instance to draw the text into it.
  199. line_bitmap = Bitmap.new(width, calc_line_height(line))
  200. # Save current Window's Bitmap.
  201. original_contents = contents
  202. # Set the recently created Bitmap as the Window's Bitmap.
  203. self.contents = line_bitmap
  204. # Use the default method to draw the text into it.
  205. draw_text_ex(4, 0, line)
  206. # Reset back the Window's Bitmap to the original one.
  207. self.contents = original_contents
  208. # Viewport for the Scrolling Line.
  209. @ms_scrolling_help_view = Viewport.new(
  210. x + standard_padding,
  211. y + standard_padding + calc_line_height(line),
  212. contents.width,
  213. line_bitmap.height
  214. )
  215. # Put the recently created Viewport on top of this Window.
  216. @ms_scrolling_help_view.z = viewport ? viewport.z + 1 : z + 1
  217. # Create a Plane instance for the scrolling effect.
  218. @ms_scrolling_help_line = Plane.new(@ms_scrolling_help_view)
  219. # Assign the recently created Bitmap (where the line is drawn) to it.
  220. @ms_scrolling_help_line.bitmap = line_bitmap
  221. # Initial step value for timing the scrolling according to certain "speed".
  222. @ms_scrolling_help_step = 0.0
  223. end
  224.  
  225. #--------------------------------------------------------------------------
  226. # * Scrolling Help Dispose. [NEW]
  227. #--------------------------------------------------------------------------
  228. def ms_scrolling_help_dispose
  229. # Disposes Bitmap, Plane and Viewport.
  230. @ms_scrolling_help_line.bitmap.dispose
  231. @ms_scrolling_help_line.dispose
  232. @ms_scrolling_help_view.dispose
  233. # Prevents executing this method when the Plane (or Viewport) is disposed.
  234. @ms_scrolling_help_view = nil
  235. @ms_scrolling_help_line = nil
  236. end
  237.  
  238. #--------------------------------------------------------------------------
  239. # * Dispose. [MOD]
  240. #--------------------------------------------------------------------------
  241. def dispose
  242. # Dispose Scrolling Help objects if needed.
  243. ms_scrolling_help_dispose if @ms_scrolling_help_line
  244. # Original method.
  245. super
  246. end
  247.  
  248. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement