Advertisement
Guest User

Untitled

a guest
Mar 20th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.59 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # Yanfly 6 - Help Window Advanced
  4. # --- Last Date Updated: 2011.11.09
  5. # --- Level: Normal, Lunatic
  6. # Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported == nil
  11. $imported["Y6-HelpWindowAdvanced"] = true
  12.  
  13. #==============================================================================
  14. # Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # o 2011.11.09 - Bugfix regarding \n[x].
  17. # o 2011.11.03 - Started Script and Finished.
  18. #
  19. #==============================================================================
  20. # Introduction
  21. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  22. # This script gives you the ability to expand the help window's number of lines
  23. # up to a maximum of 4 times. You will be able to use unique text codes in your
  24. # help descriptions to change text colour, font, place in icons, and more.
  25. #
  26. # This script also contains Lunatic Mode for those who wish to have custom
  27. # descriptions that vary for items and skills.
  28. #
  29. #==============================================================================
  30. # Instructions
  31. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  32. # To install this script, open up your script editor and copy/paste this script
  33. # to an open slot below ¥ Materials but above ¥ Main. Remember to save.
  34. #
  35. # -----------------------------------------------------------------------------
  36. # Help Window REGEXP Codes - These go inside of your help description.
  37. # -----------------------------------------------------------------------------
  38. # Code: Effect:
  39. # \v[x] Writes variable x's value.
  40. # \n[x] Writes actor x's name.
  41. # \c[x] Changes the colour of the text to x.
  42. #
  43. # | Line break.
  44. #
  45. # \fn[x] Changes the font name to x. Set to 0 to reset font name.
  46. # \fs[x] Changes the font size to x. Set to 0 to reset font size.
  47. # \fb Changes the font to bold and back.
  48. # \fi Changes the font to italic
  49. # \fh Changes the font to shadowed and back.
  50. #
  51. # \i[x] Draws icon ID x into the message window.
  52. # \ii[x] Writes item ID x's name with icon included.
  53. # \iw[x] Writes weapon ID x's name with icon included.
  54. # \ia[x] Writes armour ID x's name with icon included.
  55. # \is[x] Writes skill ID x's name with icon included.
  56. # \it[x] Writes state ID x's name with icon included.
  57. #
  58. # \nc[x] Writes class ID x's name.
  59. # \ni[x] Writes item ID x's name.
  60. # \nw[x] Writes weapon ID x's name.
  61. # \na[x] Writes armour ID x's name.
  62. # \ns[x] Writes skill ID x's name.
  63. # \nt[x] Writes state ID x's name.
  64. #
  65. # \X[x] Custom conversion code used for Lunatic Mode.
  66. # \X[x:y] Custom conversion code used for Lunatic Mode.
  67. # \X[x:y:z] Custom conversion code used for Lunatic Mode.
  68. #
  69. #==============================================================================
  70. # Compatibility
  71. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  72. # Note: This script may not work with former Yanfly Engine scripts.
  73. # Use Yanfly Engine 6 scripts to work with this if available.
  74. #==============================================================================
  75.  
  76. module Y6
  77. module HELP
  78.  
  79. #--------------------------------------------------------------------------
  80. # - Help Window Settings -
  81. #--------------------------------------------------------------------------
  82. # Here, you can adjust the basic settings that govern all the help windows
  83. # found in the game such as the number of lines it has, the font size, etc.
  84. #--------------------------------------------------------------------------
  85. LINES = 2 # Maximum lines is 4. Minimum is 1.
  86. FONT_SIZE = 22 # Original default font size is 20.
  87. FONT_NAME = ["Janda Manatee Solid"]
  88.  
  89. # Depending on whether or not you have custom scene scripts, you can choose
  90. # whether or not you want certain scenes to be automatically modified via
  91. # this script.
  92. FIX_SCENE_ITEM = true
  93. FIX_SCENE_SKILL = true
  94. FIX_SCENE_EQUIP = true
  95. FIX_SCENE_FILE = true # This will revert Help_Window to 1 line.
  96.  
  97. # This part adjusts the help window for what windows use the help window
  98. # in the default battle scene. This does not adjust the windows for custom
  99. # battle scripts. For custom battle scripts, you will need to manually
  100. # adjust them to fit in an expanded help window.
  101. FIX_BATTLE_ITEM = true
  102. FIX_BATTLE_SKILL = true
  103.  
  104. # This adjusts the text that appears when \N[0] is used in a scene without
  105. # an active battler or in a scene that is unsupported by the Help Window.
  106. N0_NAME = "User"
  107.  
  108. end # HELP
  109. end # Y6
  110.  
  111. #==============================================================================
  112. # Lunatic Mode - Custom Message System
  113. #==============================================================================
  114. #
  115. # This portion is for those who know how to script and would like to use
  116. # various tags to produce easy Lunatic Mode shortcuts.
  117. #
  118. # \X[x] or \X[x:y] or \X[x:y:z]
  119. # These let you create your own custom tags. If you use the first tag, there is
  120. # one case for the "custom_convert" definition to return. If you use the second
  121. # tag, there will be two cases for you to select from. And likewise, if there's
  122. # three tags, then the z case will also be taken into account of.
  123. #
  124. #==============================================================================
  125.  
  126. class Window_Help < Window_Base
  127.  
  128. #--------------------------------------------------------------------------
  129. # new method: custom_convert
  130. #--------------------------------------------------------------------------
  131. def custom_convert(x_case, y_case = 0, z_case = 0)
  132. text = ""
  133. case x_case
  134. #----------------------------------------------------------------------
  135. # Start editting here.
  136. #----------------------------------------------------------------------
  137. when 1 # Show the full name of the actor.
  138. case y_case # This is the extra case for the actor.
  139. when 1
  140. text = "\\n[1] von Xiguel"
  141. when 2
  142. text = "Michelle \\n[2]"
  143. when 3
  144. text = "\\n[3] Manfred"
  145. when 4
  146. text = "\\n[4] Fernaeus"
  147. end
  148.  
  149. when 2 # Test
  150. actor = $data_actors[1]
  151. hp = actor.parameters[0, @level]
  152. text = actor.hp * 0.05
  153.  
  154. when 3 # Show variable 123
  155. text = $game_variables[123]
  156.  
  157. #----------------------------------------------------------------------
  158. # Stop editting past this point.
  159. #----------------------------------------------------------------------
  160. end
  161. return text
  162. end
  163.  
  164. end # Window_Help
  165.  
  166. #==============================================================================
  167. # Editting anything past this point may potentially result in causing computer
  168. # damage, incontinence, explosion of user's head, coma, death, and/or halitosis
  169. # so edit at your own risk.
  170. #==============================================================================
  171.  
  172. #==============================================================================
  173. # ** Scene_Item
  174. #==============================================================================
  175.  
  176. class Scene_Item < Scene_Base
  177.  
  178. if Y6::HELP::FIX_SCENE_ITEM
  179. #--------------------------------------------------------------------------
  180. # alias method: start
  181. #--------------------------------------------------------------------------
  182. alias scene_item_start_hwa start unless $@
  183. def start
  184. scene_item_start_hwa
  185. adjust_hwa
  186. end
  187.  
  188. #--------------------------------------------------------------------------
  189. # new method: adjust_hwa
  190. #--------------------------------------------------------------------------
  191. def adjust_hwa
  192. @item_window.height = Graphics.height - @help_window.height
  193. @item_window.y = @help_window.height + @help_window.y
  194. @item_window.refresh
  195. end
  196. end # Y6::HELP::FIX_SCENE_ITEM
  197.  
  198. end # Scene_Item
  199.  
  200. #==============================================================================
  201. # ** Scene_Skill
  202. #==============================================================================
  203.  
  204. class Scene_Skill < Scene_Base
  205.  
  206. #--------------------------------------------------------------------------
  207. # public instance variables
  208. #--------------------------------------------------------------------------
  209. attr_accessor :actor
  210.  
  211. if Y6::HELP::FIX_SCENE_SKILL
  212. #--------------------------------------------------------------------------
  213. # alias method: start
  214. #--------------------------------------------------------------------------
  215. alias scene_skill_start_hwa start unless $@
  216. def start
  217. scene_skill_start_hwa
  218. adjust_hwa
  219. end
  220.  
  221. #--------------------------------------------------------------------------
  222. # new method: adjust_hwa
  223. #--------------------------------------------------------------------------
  224. def adjust_hwa
  225. @skill_window.height = Graphics.height - @help_window.height - 56
  226. @status_window.y = @help_window.height + @help_window.y
  227. @skill_window.y = @help_window.height + @help_window.y + 56
  228. @skill_window.refresh
  229. end
  230. end # Y6::HELP::FIX_SCENE_SKILL
  231.  
  232. end # Scene_Skill
  233.  
  234. #==============================================================================
  235. # ** Scene_Equip
  236. #==============================================================================
  237.  
  238. class Scene_Equip < Scene_Base
  239.  
  240. #--------------------------------------------------------------------------
  241. # public instance variables
  242. #--------------------------------------------------------------------------
  243. attr_accessor :actor
  244.  
  245. if Y6::HELP::FIX_SCENE_EQUIP
  246. #--------------------------------------------------------------------------
  247. # alias method: start
  248. #--------------------------------------------------------------------------
  249. alias scene_equip_start_hwa start unless $@
  250. def start
  251. scene_equip_start_hwa
  252. adjust_hwa
  253. end
  254.  
  255. #--------------------------------------------------------------------------
  256. # new method: adjust_hwa
  257. #--------------------------------------------------------------------------
  258. def adjust_hwa
  259. @equip_window.y = @help_window.height + @help_window.y
  260. @status_window.y = @help_window.height + @help_window.y
  261. for i in 0...EQUIP_TYPE_MAX
  262. @item_windows[i].height = Graphics.height - @help_window.height
  263. @item_windows[i].height -= @status_window.height
  264. @item_windows[i].refresh
  265. @item_windows[i].y = @help_window.height + @help_window.y
  266. @item_windows[i].y += @equip_window.height
  267. end
  268. end
  269. end # Y6::HELP::FIX_SCENE_EQUIP
  270.  
  271. end # Scene_Skill
  272.  
  273. #==============================================================================
  274. # ** Scene_File
  275. #==============================================================================
  276.  
  277. class Scene_File < Scene_Base
  278.  
  279. if Y6::HELP::FIX_SCENE_FILE
  280. #--------------------------------------------------------------------------
  281. # alias method: start
  282. #--------------------------------------------------------------------------
  283. alias scene_file_start_hwa start unless $@
  284. def start
  285. scene_file_start_hwa
  286. adjust_hwa
  287. end
  288.  
  289. #--------------------------------------------------------------------------
  290. # new method: adjust_hwa
  291. #--------------------------------------------------------------------------
  292. def adjust_hwa
  293. @help_window.height = 56
  294. @help_window.create_contents
  295. @help_window.set_text("")
  296. if @saving
  297. @help_window.set_text(Vocab::SaveMessage)
  298. else
  299. @help_window.set_text(Vocab::LoadMessage)
  300. end
  301. end
  302. end # Y6::HELP::FIX_SCENE_FILE
  303.  
  304. end # Scene_File
  305.  
  306. #==============================================================================
  307. # ** Scene_Battle
  308. #==============================================================================
  309.  
  310. class Scene_Battle < Scene_Base
  311.  
  312. #--------------------------------------------------------------------------
  313. # public instance variables
  314. #--------------------------------------------------------------------------
  315. attr_accessor :active_battler
  316.  
  317. if Y6::HELP::FIX_BATTLE_ITEM
  318. #--------------------------------------------------------------------------
  319. # alias method: start_item_selection
  320. #--------------------------------------------------------------------------
  321. alias start_item_selection_battle_hwa start_item_selection unless $@
  322. def start_item_selection
  323. start_item_selection_battle_hwa
  324. adjust_hwa_battle_item
  325. end
  326.  
  327. #--------------------------------------------------------------------------
  328. # new method: adjust_hwa_battle_item
  329. #--------------------------------------------------------------------------
  330. def adjust_hwa_battle_item
  331. @item_window.height = Graphics.height - @help_window.height - 128
  332. @item_window.y = @help_window.height + @help_window.y
  333. @item_window.refresh
  334. end
  335. end # Y6::HELP::FIX_BATTLE_ITEM
  336.  
  337. if Y6::HELP::FIX_BATTLE_SKILL
  338. #--------------------------------------------------------------------------
  339. # alias method: start_skill_selection
  340. #--------------------------------------------------------------------------
  341. alias start_skill_selection_battle_hwa start_skill_selection unless $@
  342. def start_skill_selection
  343. start_skill_selection_battle_hwa
  344. adjust_hwa_battle_skill
  345. end
  346.  
  347. #--------------------------------------------------------------------------
  348. # new method: adjust_hwa_battle_skill
  349. #--------------------------------------------------------------------------
  350. def adjust_hwa_battle_skill
  351. @skill_window.height = Graphics.height - @help_window.height - 128
  352. @skill_window.y = @help_window.height + @help_window.y
  353. @skill_window.refresh
  354. end
  355. end # Y6::HELP::FIX_BATTLE_SKILL
  356.  
  357. end # Scene_Battle
  358.  
  359. #==============================================================================
  360. # ** Window_Help
  361. #==============================================================================
  362.  
  363. class Window_Help < Window_Base
  364.  
  365. #--------------------------------------------------------------------------
  366. # overwrite method: initialize
  367. #--------------------------------------------------------------------------
  368. def initialize
  369. dw = Graphics.width
  370. dh = 32 + WLH * [[Y6::HELP::LINES, 1].max, 4].min
  371. super(0, 0, dw, dh)
  372. end
  373.  
  374. #--------------------------------------------------------------------------
  375. # overwrite method: set_text
  376. #--------------------------------------------------------------------------
  377. def set_text(text, align = 0)
  378. test = short_convert(text.clone)
  379. return unless test != @test or align != @align
  380. @test = test
  381. text = convert_special_characters(text.clone)
  382. @text = text
  383. @align = align
  384. contents.font.size = Y6::HELP::FONT_SIZE
  385. #---
  386. contents.clear
  387. contents.font.name = Y6::HELP::FONT_NAME
  388. contents.font.color = normal_color
  389. produce_contents
  390. end
  391.  
  392. #--------------------------------------------------------------------------
  393. # new method: short_convert
  394. #--------------------------------------------------------------------------
  395. def short_convert(text)
  396. text.gsub!(/\\X\[(\d+)\]/i) {
  397. custom_convert($1.to_i) }
  398. text.gsub!(/\\X\[(\d+):(\d+)\]/i) {
  399. custom_convert($1.to_i, $2.to_i) }
  400. text.gsub!(/\\X\[(\d+):(\d+):(\d+)\]/i) {
  401. custom_convert($1.to_i, $2.to_i, $3.to_i) }
  402. text.gsub!(/\\V\[(\d+)\]/i) { $game_variables[$1.to_i] }
  403. text.gsub!(/\\V\[(\d+)\]/i) { $game_variables[$1.to_i] }
  404. text.gsub!(/\\N\[0\]/i) { current_actor }
  405. text.gsub!(/\\N\[(\d+)\]/i) { $game_actors[$1.to_i].name }
  406. return text
  407. end
  408.  
  409. #--------------------------------------------------------------------------
  410. # new method: convert_special_characters
  411. #--------------------------------------------------------------------------
  412. def convert_special_characters(text)
  413. text.gsub!(/\\X\[(\d+)\]/i) {
  414. custom_convert($1.to_i) }
  415. text.gsub!(/\\X\[(\d+):(\d+)\]/i) {
  416. custom_convert($1.to_i, $2.to_i) }
  417. text.gsub!(/\\X\[(\d+):(\d+):(\d+)\]/i) {
  418. custom_convert($1.to_i, $2.to_i, $3.to_i) }
  419. #------------------------------------------------------------------------
  420. text.gsub!(/\\V\[(\d+)\]/i) { $game_variables[$1.to_i] }
  421. text.gsub!(/\\V\[(\d+)\]/i) { $game_variables[$1.to_i] }
  422. text.gsub!(/\\N\[0\]/i) { current_actor }
  423. text.gsub!(/\\N\[(\d+)\]/i) { $game_actors[$1.to_i].name }
  424. text.gsub!(/\\C\[(\d+)\]/i) { "\x01{#{$1}}" }
  425. text.gsub!(/\\I\[(\d+)\]/i) { "\x10{#{$1}}" }
  426. #------------------------------------------------------------------------
  427. text.gsub!(/\\FS\[(\d+)\]/i) { "\x11{#{$1}}" }
  428. text.gsub!(/\\FN\[(.*?)\]/i) { "\x12{#{$1}}" }
  429. text.gsub!(/\\FB/i) { "\x13" }
  430. text.gsub!(/\\FI/i) { "\x14" }
  431. text.gsub!(/\\FH/i) { "\x15" }
  432. #------------------------------------------------------------------------
  433. text.gsub!(/\\NC\[(\d+)\]/i) {
  434. $data_classes[$1.to_i].name }
  435. text.gsub!(/\\NI\[(\d+)\]/i) {
  436. $data_items[$1.to_i].name }
  437. text.gsub!(/\\NW\[(\d+)\]/i) {
  438. $data_weapons[$1.to_i].name }
  439. text.gsub!(/\\NA\[(\d+)\]/i) {
  440. $data_armors[$1.to_i].name }
  441. text.gsub!(/\\NS\[(\d+)\]/i) {
  442. $data_skills[$1.to_i].name }
  443. text.gsub!(/\\NT\[(\d+)\]/i) {
  444. $data_states[$1.to_i].name }
  445. text.gsub!(/\\II\[(\d+)\]/i) {
  446. "\x10{#{$data_items[$1.to_i].icon_index}}" +
  447. "#{$data_items[$1.to_i].name}"}
  448. text.gsub!(/\\IW\[(\d+)\]/i) {
  449. "\x10{#{$data_weapons[$1.to_i].icon_index}}" +
  450. "#{$data_weapons[$1.to_i].name}"}
  451. text.gsub!(/\\IA\[(\d+)\]/i) {
  452. "\x10{#{$data_armors[$1.to_i].icon_index}}" +
  453. "#{$data_armors[$1.to_i].name}"}
  454. text.gsub!(/\\IS\[(\d+)\]/i) {
  455. "\x10{#{$data_skills[$1.to_i].icon_index}}" +
  456. "#{$data_skills[$1.to_i].name}"}
  457. text.gsub!(/\\IT\[(\d+)\]/i) {
  458. "\x10{#{$data_states[$1.to_i].icon_index}}" +
  459. "#{$data_states[$1.to_i].name}"}
  460. #------------------------------------------------------------------------
  461. return text
  462. end
  463.  
  464. #--------------------------------------------------------------------------
  465. # new method: current_actor
  466. #--------------------------------------------------------------------------
  467. def current_actor
  468. if $scene.is_a?(Scene_Skill) or $scene.is_a?(Scene_Equip)
  469. return $scene.actor.name
  470. elsif $scene.is_a?(Scene_Battle) and $scene.active_battler != nil
  471. return $scene.active_battler.name
  472. else
  473. return Y6::HELP::N0_NAME
  474. end
  475. end
  476.  
  477. #--------------------------------------------------------------------------
  478. # new method: produce_contents
  479. #--------------------------------------------------------------------------
  480. def produce_contents
  481. @contents_x = 0
  482. @contents_y = 0
  483. loop do
  484. c = @text.slice!(/./m)
  485. case c
  486. #----------------------------------------------------------------------
  487. # Code Settings
  488. #----------------------------------------------------------------------
  489. when nil
  490. break
  491. when "|"
  492. @contents_y += WLH
  493. @contents_x = 0
  494. when "\x01" # \C[n] (text character color change)
  495. @text.sub!(/\{(\d+)\}/, "")
  496. contents.font.color = text_color($1.to_i)
  497. when "\x10" # \i Draws icon ID x
  498. @text.sub!(/\{(\d+)\}/, "")
  499. draw_icon($1.to_i, @contents_x, @contents_y)
  500. @contents_x += 24
  501. when "\x11" # \fs Font Size Change
  502. @text.sub!(/\{(\d+)\}/, "")
  503. size = $1.to_i
  504. if size <= 0 # If 0, revert back to the default font size.
  505. size = Y6::HELP::FONT_SIZE
  506. end
  507. contents.font.size = size
  508. text_height = [size + (size / 5), WLH].max
  509. when "\x12" # \fs Font Name Change
  510. @text.sub!(/\{(.*?)\}/, "")
  511. name = $1.to_s
  512. if name == "0" # If 0, revert back to the default font.
  513. name = Y6::HELP::FONT_NAME
  514. end
  515. contents.font.name = name
  516. else
  517. contents.draw_text(@contents_x, @contents_y, 40, WLH, c)
  518. @contents_x += contents.text_size(c).width
  519. end
  520. end
  521. end
  522.  
  523. end # Window_Help
  524.  
  525. #===============================================================================
  526. #
  527. # END OF FILE
  528. #
  529. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement