Advertisement
Guest User

Yanfly Ace Message System

a guest
Apr 5th, 2014
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.02 KB | None | 0 0
  1. # ▼ Yanfly Engine Ace - Ace Message System v1.05
  2. # -- Last Updated: 2012.01.13
  3. # -- Level: Normal
  4. # -- Requires: n/a
  5. #
  6. #==============================================================================
  7.  
  8. $imported = {} if $imported.nil?
  9. $imported["YEA-MessageSystem"] = true
  10.  
  11. #==============================================================================
  12. # ▼ Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2012.07.21 - Fixed REGEXP error at line 824
  15. # 2012.01.13 - Bug Fixed: Negative tags didn't display other party members.
  16. # 2012.01.12 - Compatibility Update: Message Actor Codes
  17. # 2012.01.10 - Added Feature: \pic[x] text code.
  18. # 2012.01.04 - Bug Fixed: \ic tag was \ii. No longer the case.
  19. # - Added: Scroll Text window now uses message window font.
  20. # 2011.12.31 - Started Script and Finished.
  21. #
  22. #==============================================================================
  23. # ▼ Introduction
  24. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  25. # While RPG Maker VX Ace certainly improved the message system a whole lot, it
  26. # wouldn't hurt to add in a few more features, such as name windows, converting
  27. # textcodes to write out the icons and/or names of items, weapons, armours, and
  28. # more in quicker fashion. This script also gives the developer the ability to
  29. # adjust the size of the message window during the game, give it a separate
  30. # font, and to give the player a text fast-forward feature.
  31. #
  32. #==============================================================================
  33. # ▼ Instructions
  34. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  35. # To install this script, open up your script editor and copy/paste this script
  36. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  37. #
  38. # -----------------------------------------------------------------------------
  39. # Message Window text Codes - These go inside of your message window.
  40. # -----------------------------------------------------------------------------
  41. # Default: Effect:
  42. # \v[x] - Writes variable x's value.
  43. # \n[x] - Writes actor x's name.
  44. # \p[x] - Writes party member x's name.
  45. # \g - Writes gold currency name.
  46. # \c[x] - Changes the colour of the text to x.
  47. # \i[x] - Draws icon x at position of the text.
  48. # \{ - Makes text bigger by 8 points.
  49. # \} - Makes text smaller by 8 points.
  50. # \$ - Opens gold window.
  51. # \. - Waits 15 frames (quarter second).
  52. # \| - Waits 60 frames (a full second).
  53. # \! - Waits until key is pressed.
  54. # \> - Following text is instant.
  55. # \< - Following text is no longer instant.
  56. # \^ - Skips to the next message.
  57. # \\ - Writes a "\" in the window.
  58. #
  59. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  60. #
  61. # Wait: Effect:
  62. # \w[x] - Waits x frames (60 frames = 1 second). Message window only.
  63. #
  64. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  65. #
  66. # NameWindow: Effect:
  67. # \n<x> - Creates a name box with x string. Left side. *Note
  68. # \nc<x> - Creates a name box with x string. Centered. *Note
  69. # \nr<x> - Creates a name box with x string. Right side. *Note
  70. #
  71. # *Note: Works for message window only.
  72. #
  73. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  74. #
  75. # Position: Effect:
  76. # \px[x] - Sets x position of text to x.
  77. # \py[x] - Sets y position of text to y.
  78. #
  79. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  80. #
  81. # Picture: Effect:
  82. # \pic[x] - Draws picture x from the Graphics\Pictures folder.
  83. #
  84. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  85. #
  86. # Outline: Effect:
  87. # \oc[x] - Sets outline colour to x.
  88. # \oo[x] - Sets outline opacity to x.
  89. #
  90. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  91. #
  92. # Font: Effect:
  93. # \fr - Resets all font changes.
  94. # \fz[x] - Changes font size to x.
  95. # \fn[x] - Changes font name to x.
  96. # \fb - Toggles font boldness.
  97. # \fi - Toggles font italic.
  98. # \fo - Toggles font outline.
  99. # \fs - Toggles font shadow.
  100. #
  101. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  102. #
  103. # Actor: Effect:
  104. # \af[x] - Shows face of actor x. *Note
  105. # \ac[x] - Writes out actor's class name. *Note
  106. # \as[x] - Writes out actor's subclass name. Req: Class System. *Note
  107. # \an[x] - Writes out actor's nickname. *Note
  108. #
  109. # *Note: If x is 0 or negative, it will show the respective
  110. # party member's face instead.
  111. # 0 - Party Leader
  112. # -1 - 1st non-leader member.
  113. # -2 - 2nd non-leader member. So on.
  114. #
  115. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  116. #
  117. # Names: Effect:
  118. # \nc[x] - Writes out class x's name.
  119. # \ni[x] - Writes out item x's name.
  120. # \nw[x] - Writes out weapon x's name.
  121. # \na[x] - Writes out armour x's name.
  122. # \ns[x] - Writes out skill x's name.
  123. # \nt[x] - Writes out state x's name.
  124. #
  125. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  126. #
  127. # Icon Names: Effect:
  128. # \ic[x] - Writes out class x's name including icon. *
  129. # \ii[x] - Writes out item x's name including icon.
  130. # \iw[x] - Writes out weapon x's name including icon.
  131. # \ia[x] - Writes out armour x's name including icon.
  132. # \is[x] - Writes out skill x's name including icon.
  133. # \it[x] - Writes out state x's name including icon.
  134. #
  135. # *Note: Requires YEA - Class System
  136. #
  137. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  138. #
  139. # And those are the text codes added with this script. Keep in mind that some
  140. # of these text codes only work for the Message Window. Otherwise, they'll work
  141. # for help descriptions, actor biographies, and others.
  142. #
  143. #==============================================================================
  144. # ▼ Compatibility
  145. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  146. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  147. # it will run with RPG Maker VX without adjusting.
  148. #
  149. #==============================================================================
  150.  
  151. module YEA
  152. module MESSAGE
  153.  
  154. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  155. # - General Message Settings -
  156. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  157. # The following below will adjust the basic settings and that will affect
  158. # the majority of the script. Adjust them as you see fit.
  159. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  160. # This button is the button used to make message windows instantly skip
  161. # forward. Hold down for the effect. Note that when held down, this will
  162. # speed up the messages, but still wait for the pauses. However, it will
  163. # automatically go to the next page when prompted.
  164. TEXT_SKIP = :A # Input::A is the shift button on keyboard.
  165.  
  166. # This variable adjusts the number of visible rows shown in the message
  167. # window. If you do not wish to use this feature, set this constant to 0.
  168. # If the row value is 0 or below, it will automatically default to 4 rows.
  169. VARIABLE_ROWS = 0
  170.  
  171. # This variable adjusts the width of the message window shown. If you do
  172. # not wish to use this feature, set this constant to 0. If the width value
  173. # is 0 or below, it will automatically default to the screen width.
  174. VARIABLE_WIDTH = 01
  175.  
  176. # This is the amount of space that the message window will indent whenever
  177. # a face is used. Default: 112
  178. FACE_INDENT_X = 112
  179.  
  180. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  181. # - Name Window Settings -
  182. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  183. # The name window is a window that appears outside of the main message
  184. # window box to display whatever text is placed inside of it like a name.
  185. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  186. NAME_WINDOW_X_BUFFER = -20 # Buffer x position of the name window.
  187. NAME_WINDOW_Y_BUFFER = 0 # Buffer y position of the name window.
  188. NAME_WINDOW_PADDING = 20 # Padding added to the horizontal position.
  189. NAME_WINDOW_OPACITY = 255 # Opacity of the name window.
  190. NAME_WINDOW_COLOUR = 6 # Text colour used by default for names.
  191.  
  192. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  193. # - Message Font Settings -
  194. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  195. # Ace Message System separates the in-game system font form the message
  196. # font. Adjust the settings here for your fonts.
  197. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  198. # This array constant determines the fonts used. If the first font does not
  199. # exist on the player's computer, the next font in question will be used
  200. # in place instead and so on.
  201. MESSAGE_WINDOW_FONT_NAME = ["Castamere Sans", "Verdana", "Courier New"]
  202.  
  203. # These adjust the other settings regarding the way the game font appears
  204. # including the font size, whether or not the font is bolded by default,
  205. # italic by default, etc.
  206. MESSAGE_WINDOW_FONT_SIZE = 20 # Font size.
  207. MESSAGE_WINDOW_FONT_BOLD = true # Default bold?
  208. MESSAGE_WINDOW_FONT_ITALIC = false # Default italic?
  209. MESSAGE_WINDOW_FONT_OUTLINE = true # Default outline?
  210. MESSAGE_WINDOW_FONT_SHADOW = false # Default shadow?
  211.  
  212. end # MESSAGE
  213. end # YEA
  214.  
  215. #==============================================================================
  216. # ▼ Editting anything past this point may potentially result in causing
  217. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  218. # halitosis so edit at your own risk.
  219. #==============================================================================
  220.  
  221. #==============================================================================
  222. # ■ Variable
  223. #==============================================================================
  224.  
  225. module Variable
  226.  
  227. #--------------------------------------------------------------------------
  228. # self.message_rows
  229. #--------------------------------------------------------------------------
  230. def self.message_rows
  231. return 4 if YEA::MESSAGE::VARIABLE_ROWS <= 0
  232. return 4 if $game_variables[YEA::MESSAGE::VARIABLE_ROWS] <= 0
  233. return $game_variables[YEA::MESSAGE::VARIABLE_ROWS]
  234. end
  235.  
  236. #--------------------------------------------------------------------------
  237. # self.message_width
  238. #--------------------------------------------------------------------------
  239. def self.message_width
  240. return Graphics.width if YEA::MESSAGE::VARIABLE_WIDTH <= 0
  241. return Graphics.width if $game_variables[YEA::MESSAGE::VARIABLE_WIDTH] <= 0
  242. return $game_variables[YEA::MESSAGE::VARIABLE_WIDTH]
  243. end
  244.  
  245. end # Variable
  246.  
  247. #==============================================================================
  248. # ■ Game_Interpreter
  249. #==============================================================================
  250.  
  251. class Game_Interpreter
  252.  
  253. #--------------------------------------------------------------------------
  254. # overwrite method: command_101
  255. #--------------------------------------------------------------------------
  256. def command_101
  257. wait_for_message
  258. $game_message.face_name = @params[0]
  259. $game_message.face_index = @params[1]
  260. $game_message.background = @params[2]
  261. $game_message.position = @params[3]
  262. while continue_message_string?
  263. @index += 1
  264. if @list[@index].code == 401
  265. $game_message.add(@list[@index].parameters[0])
  266. end
  267. break if $game_message.texts.size >= Variable.message_rows
  268. end
  269. case next_event_code
  270. when 102
  271. @index += 1
  272. setup_choices(@list[@index].parameters)
  273. when 103
  274. @index += 1
  275. setup_num_input(@list[@index].parameters)
  276. when 104
  277. @index += 1
  278. setup_item_choice(@list[@index].parameters)
  279. end
  280. wait_for_message
  281. end
  282.  
  283. #--------------------------------------------------------------------------
  284. # new method: continue_message_string?
  285. #--------------------------------------------------------------------------
  286. def continue_message_string?
  287. return true if next_event_code == 101 && Variable.message_rows > 4
  288. return next_event_code == 401
  289. end
  290.  
  291. end # Game_Interpreter
  292.  
  293. #==============================================================================
  294. # ■ Window_Base
  295. #==============================================================================
  296.  
  297. class Window_Base < Window
  298.  
  299. #--------------------------------------------------------------------------
  300. # new method: setup_message_font
  301. #--------------------------------------------------------------------------
  302. def setup_message_font
  303. @message_font = true
  304. change_color(normal_color)
  305. contents.font.out_color = Font.default_out_color
  306. contents.font.name = YEA::MESSAGE::MESSAGE_WINDOW_FONT_NAME
  307. contents.font.size = YEA::MESSAGE::MESSAGE_WINDOW_FONT_SIZE
  308. contents.font.bold = YEA::MESSAGE::MESSAGE_WINDOW_FONT_BOLD
  309. contents.font.italic = YEA::MESSAGE::MESSAGE_WINDOW_FONT_ITALIC
  310. contents.font.outline = YEA::MESSAGE::MESSAGE_WINDOW_FONT_OUTLINE
  311. contents.font.shadow = YEA::MESSAGE::MESSAGE_WINDOW_FONT_SHADOW
  312. end
  313.  
  314. #--------------------------------------------------------------------------
  315. # alias method: reset_font_settings
  316. #--------------------------------------------------------------------------
  317. alias window_base_reset_font_settings_ams reset_font_settings
  318. def reset_font_settings
  319. if @message_font
  320. setup_message_font
  321. else
  322. window_base_reset_font_settings_ams
  323. contents.font.out_color = Font.default_out_color
  324. contents.font.outline = Font.default_outline
  325. contents.font.shadow = Font.default_shadow
  326. end
  327. end
  328.  
  329. #--------------------------------------------------------------------------
  330. # alias method: convert_escape_characters
  331. #--------------------------------------------------------------------------
  332. alias window_base_convert_escape_characters_ams convert_escape_characters
  333. def convert_escape_characters(text)
  334. result = window_base_convert_escape_characters_ams(text)
  335. result = convert_ace_message_system_new_escape_characters(result)
  336. return result
  337. end
  338.  
  339. #--------------------------------------------------------------------------
  340. # new method: convert_ace_message_system_new_escape_characters
  341. #--------------------------------------------------------------------------
  342. def convert_ace_message_system_new_escape_characters(result)
  343. #---
  344. result.gsub!(/\eFR/i) { "\eAMSF[0]" }
  345. result.gsub!(/\eFB/i) { "\eAMSF[1]" }
  346. result.gsub!(/\eFI/i) { "\eAMSF[2]" }
  347. result.gsub!(/\eFO/i) { "\eAMSF[3]" }
  348. result.gsub!(/\eFS/i) { "\eAMSF[4]" }
  349. #---
  350. result.gsub!(/\eAC\[([-+]?\d+)\]/i) { escape_actor_class_name($1.to_i) }
  351. result.gsub!(/\eAS\[([-+]?\d+)\]/i) { escape_actor_subclass_name($1.to_i) }
  352. result.gsub!(/\eAN\[([-+]?\d+)\]/i) { escape_actor_nickname($1.to_i) }
  353. #---
  354. result.gsub!(/\eNC\[(\d+)\]/i) { $data_classes[$1.to_i].name }
  355. result.gsub!(/\eNI\[(\d+)\]/i) { $data_items[$1.to_i].name }
  356. result.gsub!(/\eNW\[(\d+)\]/i) { $data_weapons[$1.to_i].name }
  357. result.gsub!(/\eNA\[(\d+)\]/i) { $data_armors[$1.to_i].name }
  358. result.gsub!(/\eNS\[(\d+)\]/i) { $data_skills[$1.to_i].name }
  359. result.gsub!(/\eNT\[(\d+)\]/i) { $data_states[$1.to_i].name }
  360. #---
  361. result.gsub!(/\eIC\[(\d+)\]/i) { escape_icon_item($1.to_i, :class) }
  362. result.gsub!(/\eII\[(\d+)\]/i) { escape_icon_item($1.to_i, :item) }
  363. result.gsub!(/\eIW\[(\d+)\]/i) { escape_icon_item($1.to_i, :weapon) }
  364. result.gsub!(/\eIA\[(\d+)\]/i) { escape_icon_item($1.to_i, :armour) }
  365. result.gsub!(/\eIS\[(\d+)\]/i) { escape_icon_item($1.to_i, :skill) }
  366. result.gsub!(/\eIT\[(\d+)\]/i) { escape_icon_item($1.to_i, :state) }
  367. #---
  368. return result
  369. end
  370.  
  371. #--------------------------------------------------------------------------
  372. # new method: escape_actor_class_name
  373. #--------------------------------------------------------------------------
  374. def escape_actor_class_name(actor_id)
  375. actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0
  376. actor = $game_actors[actor_id]
  377. return "" if actor.nil?
  378. return actor.class.name
  379. end
  380.  
  381. #--------------------------------------------------------------------------
  382. # new method: actor_subclass_name
  383. #--------------------------------------------------------------------------
  384. def escape_actor_subclass_name(actor_id)
  385. return "" unless $imported["YEA-ClassSystem"]
  386. actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0
  387. actor = $game_actors[actor_id]
  388. return "" if actor.nil?
  389. return "" if actor.subclass.nil?
  390. return actor.subclass.name
  391. end
  392.  
  393. #--------------------------------------------------------------------------
  394. # new method: escape_actor_nickname
  395. #--------------------------------------------------------------------------
  396. def escape_actor_nickname(actor_id)
  397. actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0
  398. actor = $game_actors[actor_id]
  399. return "" if actor.nil?
  400. return actor.nickname
  401. end
  402.  
  403. #--------------------------------------------------------------------------
  404. # new method: escape_icon_item
  405. #--------------------------------------------------------------------------
  406. def escape_icon_item(data_id, type)
  407. case type
  408. when :class
  409. return "" unless $imported["YEA-ClassSystem"]
  410. icon = $data_classes[data_id].icon_index
  411. name = $data_items[data_id].name
  412. when :item
  413. icon = $data_items[data_id].icon_index
  414. name = $data_items[data_id].name
  415. when :weapon
  416. icon = $data_weapons[data_id].icon_index
  417. name = $data_weapons[data_id].name
  418. when :armour
  419. icon = $data_armors[data_id].icon_index
  420. name = $data_armors[data_id].name
  421. when :skill
  422. icon = $data_skills[data_id].icon_index
  423. name = $data_skills[data_id].name
  424. when :state
  425. icon = $data_states[data_id].icon_index
  426. name = $data_states[data_id].name
  427. else; return ""
  428. end
  429. text = "\eI[#{icon}]" + name
  430. return text
  431. end
  432.  
  433. #--------------------------------------------------------------------------
  434. # alias method: process_escape_character
  435. #--------------------------------------------------------------------------
  436. alias window_base_process_escape_character_ams process_escape_character
  437. def process_escape_character(code, text, pos)
  438. case code.upcase
  439. #---
  440. when 'FZ'
  441. contents.font.size = obtain_escape_param(text)
  442. when 'FN'
  443. text.sub!(/\[(.*?)\]/, "")
  444. font_name = $1.to_s
  445. font_name = Font.default_name if font_name.nil?
  446. contents.font.name = font_name.to_s
  447. #---
  448. when 'OC'
  449. colour = text_color(obtain_escape_param(text))
  450. contents.font.out_color = colour
  451. when 'OO'
  452. contents.font.out_color.alpha = obtain_escape_param(text)
  453. #---
  454. when 'AMSF'
  455. case obtain_escape_param(text)
  456. when 0; reset_font_settings
  457. when 1; contents.font.bold = !contents.font.bold
  458. when 2; contents.font.italic = !contents.font.italic
  459. when 3; contents.font.outline = !contents.font.outline
  460. when 4; contents.font.shadow = !contents.font.shadow
  461. end
  462. #---
  463. when 'PX'
  464. pos[:x] = obtain_escape_param(text)
  465. when 'PY'
  466. pos[:y] = obtain_escape_param(text)
  467. #---
  468. when 'PIC'
  469. text.sub!(/\[(.*?)\]/, "")
  470. bmp = Cache.picture($1.to_s)
  471. rect = Rect.new(0, 0, bmp.width, bmp.height)
  472. contents.blt(pos[:x], pos[:y], bmp, rect)
  473. #---
  474. else
  475. window_base_process_escape_character_ams(code, text, pos)
  476. end
  477. end
  478.  
  479. end # Window_Base
  480.  
  481. #==============================================================================
  482. # ■ Window_ChoiceList
  483. #==============================================================================
  484.  
  485. class Window_ChoiceList < Window_Command
  486.  
  487. #--------------------------------------------------------------------------
  488. # alias method: initialize
  489. #--------------------------------------------------------------------------
  490. alias window_choicelist_initialize_ams initialize
  491. def initialize(message_window)
  492. window_choicelist_initialize_ams(message_window)
  493. setup_message_font
  494. end
  495.  
  496. end # Window_ChoiceList
  497.  
  498. #==============================================================================
  499. # ■ Window_ScrollText
  500. #==============================================================================
  501.  
  502. class Window_ScrollText < Window_Base
  503.  
  504. #--------------------------------------------------------------------------
  505. # alias method: initialize
  506. #--------------------------------------------------------------------------
  507. alias window_scrolltext_initialize_ams initialize
  508. def initialize
  509. window_scrolltext_initialize_ams
  510. setup_message_font
  511. end
  512.  
  513. end # Window_ScrollText
  514.  
  515. #==============================================================================
  516. # ■ Window_NameMessage
  517. #==============================================================================
  518.  
  519. class Window_NameMessage < Window_Base
  520.  
  521. #--------------------------------------------------------------------------
  522. # initialize
  523. #--------------------------------------------------------------------------
  524. def initialize(message_window)
  525. @message_window = message_window
  526. super(0, 0, Graphics.width, fitting_height(1))
  527. self.opacity = YEA::MESSAGE::NAME_WINDOW_OPACITY
  528. self.z = @message_window.z + 1
  529. self.openness = 0
  530. setup_message_font
  531. @close_counter = 0
  532. deactivate
  533. end
  534.  
  535. #--------------------------------------------------------------------------
  536. # update
  537. #--------------------------------------------------------------------------
  538. def update
  539. super
  540. return if self.active
  541. return if self.openness == 0
  542. return if @closing
  543. @close_counter -= 1
  544. return if @close_counter > 0
  545. close
  546. end
  547.  
  548. #--------------------------------------------------------------------------
  549. # start_close
  550. #--------------------------------------------------------------------------
  551. def start_close
  552. @close_counter = 4
  553. deactivate
  554. end
  555.  
  556. #--------------------------------------------------------------------------
  557. # force_close
  558. #--------------------------------------------------------------------------
  559. def force_close
  560. @close_counter = 0
  561. deactivate
  562. close
  563. end
  564.  
  565. #--------------------------------------------------------------------------
  566. # start
  567. #--------------------------------------------------------------------------
  568. def start(text, x_position)
  569. @text = text.clone
  570. set_width
  571. create_contents
  572. set_x_position(x_position)
  573. set_y_position
  574. refresh
  575. activate
  576. open
  577. end
  578.  
  579. #--------------------------------------------------------------------------
  580. # set_width
  581. #--------------------------------------------------------------------------
  582. def set_width
  583. text = @text.clone
  584. dw = standard_padding * 2 + text_size(text).width
  585. dw += YEA::MESSAGE::NAME_WINDOW_PADDING * 2
  586. dw += calculate_size(text.slice!(0, 1), text) until text.empty?
  587. self.width = dw
  588. end
  589.  
  590. #--------------------------------------------------------------------------
  591. # calculate_size
  592. #--------------------------------------------------------------------------
  593. def calculate_size(code, text)
  594. case code
  595. when "\e"
  596. return calculate_escape_code_width(obtain_escape_code(text), text)
  597. else
  598. return 0
  599. end
  600. end
  601.  
  602. #--------------------------------------------------------------------------
  603. # calculate_escape_code_width
  604. #--------------------------------------------------------------------------
  605. def calculate_escape_code_width(code, text)
  606. dw = -text_size("\e").width - text_size(code).width
  607. case code.upcase
  608. when 'C', 'OC', 'OO'
  609. dw += -text_size("[" + obtain_escape_param(text).to_s + "]").width
  610. return dw
  611. when 'I'
  612. dw += -text_size("[" + obtain_escape_param(text).to_s + "]").width
  613. dw += 24
  614. return dw
  615. when '{'
  616. make_font_bigger
  617. when '}'
  618. make_font_smaller
  619. when 'FZ'
  620. contents.font.size = obtain_escape_param(text)
  621. when 'FN'
  622. text.sub!(/\[(.*?)\]/, "")
  623. font_name = $1.to_s
  624. font_name = Font.default_name if font_name.nil?
  625. contents.font.name = font_name.to_s
  626. when 'AMSF'
  627. case obtain_escape_param(text)
  628. when 0; reset_font_settings
  629. when 1; contents.font.bold = !contents.font.bold
  630. when 2; contents.font.italic = !contents.font.italic
  631. when 3; contents.font.outline = !contents.font.outline
  632. when 4; contents.font.shadow = !contents.font.shadow
  633. end
  634. else
  635. return dw
  636. end
  637. end
  638.  
  639. #--------------------------------------------------------------------------
  640. # set_y_position
  641. #--------------------------------------------------------------------------
  642. def set_x_position(x_position)
  643. case x_position
  644. when 1 # Left
  645. self.x = @message_window.x
  646. self.x += YEA::MESSAGE::NAME_WINDOW_X_BUFFER
  647. when 2 # 3/10
  648. self.x = @message_window.x
  649. self.x += @message_window.width * 3 / 10
  650. self.x -= self.width / 2
  651. when 3 # Center
  652. self.x = @message_window.x
  653. self.x += @message_window.width / 2
  654. self.x -= self.width / 2
  655. when 4 # 7/10
  656. self.x = @message_window.x
  657. self.x += @message_window.width * 7 / 10
  658. self.x -= self.width / 2
  659. when 5 # Right
  660. self.x = @message_window.x + @message_window.width
  661. self.x -= self.width
  662. self.x -= YEA::MESSAGE::NAME_WINDOW_X_BUFFER
  663. end
  664. self.x = [[self.x, Graphics.width - self.width].min, 0].max
  665. end
  666.  
  667. #--------------------------------------------------------------------------
  668. # set_y_position
  669. #--------------------------------------------------------------------------
  670. def set_y_position
  671. case $game_message.position
  672. when 0
  673. self.y = @message_window.height
  674. self.y -= YEA::MESSAGE::NAME_WINDOW_Y_BUFFER
  675. else
  676. self.y = @message_window.y - self.height
  677. self.y += YEA::MESSAGE::NAME_WINDOW_Y_BUFFER
  678. end
  679. end
  680.  
  681. #--------------------------------------------------------------------------
  682. # refresh
  683. #--------------------------------------------------------------------------
  684. def refresh
  685. contents.clear
  686. reset_font_settings
  687. @text = sprintf("\eC[%d]%s", YEA::MESSAGE::NAME_WINDOW_COLOUR, @text)
  688. draw_text_ex(YEA::MESSAGE::NAME_WINDOW_PADDING, 0, @text)
  689. end
  690.  
  691. end # Window_NameMessage
  692.  
  693. #==============================================================================
  694. # ■ Window_Message
  695. #==============================================================================
  696.  
  697. class Window_Message < Window_Base
  698.  
  699. #--------------------------------------------------------------------------
  700. # alias method: initialize
  701. #--------------------------------------------------------------------------
  702. alias window_message_initialize_ams initialize
  703. def initialize
  704. window_message_initialize_ams
  705. setup_message_font
  706. end
  707.  
  708. #--------------------------------------------------------------------------
  709. # overwrite method: window_width
  710. #--------------------------------------------------------------------------
  711. def window_width
  712. return Variable.message_width
  713. end
  714.  
  715. #--------------------------------------------------------------------------
  716. # overwrite method: window_height
  717. #--------------------------------------------------------------------------
  718. def window_height
  719. return fitting_height(Variable.message_rows)
  720. end
  721.  
  722. #--------------------------------------------------------------------------
  723. # alias method: create_all_windows
  724. #--------------------------------------------------------------------------
  725. alias window_message_create_all_windows_ams create_all_windows
  726. def create_all_windows
  727. window_message_create_all_windows_ams
  728. @name_window = Window_NameMessage.new(self)
  729. end
  730.  
  731. #--------------------------------------------------------------------------
  732. # overwrite method: create_back_bitmap
  733. #--------------------------------------------------------------------------
  734. def create_back_bitmap
  735. @back_bitmap = Bitmap.new(width, height)
  736. rect1 = Rect.new(0, 0, Graphics.width, 12)
  737. rect2 = Rect.new(0, 12, Graphics.width, fitting_height(4) - 24)
  738. rect3 = Rect.new(0, fitting_height(4) - 12, Graphics.width, 12)
  739. @back_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true)
  740. @back_bitmap.fill_rect(rect2, back_color1)
  741. @back_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true)
  742. end
  743.  
  744. #--------------------------------------------------------------------------
  745. # alias method: dispose_all_windows
  746. #--------------------------------------------------------------------------
  747. alias window_message_dispose_all_windows_ams dispose_all_windows
  748. def dispose_all_windows
  749. window_message_dispose_all_windows_ams
  750. @name_window.dispose
  751. end
  752.  
  753. #--------------------------------------------------------------------------
  754. # alias method: update_all_windows
  755. #--------------------------------------------------------------------------
  756. alias window_message_update_all_windows_ams update_all_windows
  757. def update_all_windows
  758. window_message_update_all_windows_ams
  759. @name_window.update
  760. @name_window.back_opacity = self.back_opacity
  761. @name_window.opacity = self.opacity
  762. end
  763.  
  764. #--------------------------------------------------------------------------
  765. # alias method: update_show_fast
  766. #--------------------------------------------------------------------------
  767. alias window_message_update_show_fast_ams update_show_fast
  768. def update_show_fast
  769. @show_fast = true if Input.press?(YEA::MESSAGE::TEXT_SKIP)
  770. window_message_update_show_fast_ams
  771. end
  772.  
  773. #--------------------------------------------------------------------------
  774. # overwrite method: input_pause
  775. #--------------------------------------------------------------------------
  776. def input_pause
  777. self.pause = true
  778. wait(10)
  779. Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C) ||
  780. Input.press?(YEA::MESSAGE::TEXT_SKIP)
  781. Input.update
  782. self.pause = false
  783. end
  784.  
  785. #--------------------------------------------------------------------------
  786. # overwrite method: convert_escape_characters
  787. #--------------------------------------------------------------------------
  788. def convert_escape_characters(text)
  789. result = super(text.to_s.clone)
  790. result = namebox_escape_characters(result)
  791. result = message_escape_characters(result)
  792. return result
  793. end
  794.  
  795. #--------------------------------------------------------------------------
  796. # new method: namebox_escape_characters
  797. #--------------------------------------------------------------------------
  798. def namebox_escape_characters(result)
  799. result.gsub!(/\eN\<(.+?)\>/i) { namewindow($1, 1) }
  800. result.gsub!(/\eN1\<(.+?)\>/i) { namewindow($1, 1) }
  801. result.gsub!(/\eN2\<(.+?)\>/i) { namewindow($1, 2) }
  802. result.gsub!(/\eNC\<(.+?)\>/i) { namewindow($1, 3) }
  803. result.gsub!(/\eN3\<(.+?)\>/i) { namewindow($1, 3) }
  804. result.gsub!(/\eN4\<(.+?)\>/i) { namewindow($1, 4) }
  805. result.gsub!(/\eN5\<(.+?)\>/i) { namewindow($1, 5) }
  806. result.gsub!(/\eNR\<(.+?)\>/i) { namewindow($1, 5) }
  807. return result
  808. end
  809.  
  810. #--------------------------------------------------------------------------
  811. # new method: namebox
  812. #--------------------------------------------------------------------------
  813. def namewindow(text, position)
  814. @name_text = text
  815. @name_position = position
  816. return ""
  817. end
  818.  
  819. #--------------------------------------------------------------------------
  820. # new method: message_escape_characters
  821. #--------------------------------------------------------------------------
  822. def message_escape_characters(result)
  823. result.gsub!(/\eAF\[(-?\d+)]/i) { change_face($1.to_i) }
  824. return result
  825. end
  826.  
  827. #--------------------------------------------------------------------------
  828. # new method: change_face
  829. #--------------------------------------------------------------------------
  830. def change_face(actor_id)
  831. actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0
  832. actor = $game_actors[actor_id]
  833. return "" if actor.nil?
  834. $game_message.face_name = actor.face_name
  835. $game_message.face_index = actor.face_index
  836. return ""
  837. end
  838.  
  839. #--------------------------------------------------------------------------
  840. # alias method: new_page
  841. #--------------------------------------------------------------------------
  842. alias window_message_new_page_ams new_page
  843. def new_page(text, pos)
  844. adjust_message_window_size
  845. window_message_new_page_ams(text, pos)
  846. end
  847.  
  848. #--------------------------------------------------------------------------
  849. # overwrite method: new_line_x
  850. #--------------------------------------------------------------------------
  851. def new_line_x
  852. return $game_message.face_name.empty? ? 0 : YEA::MESSAGE::FACE_INDENT_X
  853. end
  854.  
  855. #--------------------------------------------------------------------------
  856. # new method: adjust_message_window_size
  857. #--------------------------------------------------------------------------
  858. def adjust_message_window_size
  859. self.height = window_height
  860. self.width = window_width
  861. create_contents
  862. update_placement
  863. self.x = (Graphics.width - self.width) / 2
  864. start_name_window
  865. end
  866.  
  867. #--------------------------------------------------------------------------
  868. # new method: clear_name_window
  869. #--------------------------------------------------------------------------
  870. def clear_name_window
  871. @name_text = ""
  872. @name_position = 0
  873. end
  874.  
  875. #--------------------------------------------------------------------------
  876. # new method: start_name_window
  877. #--------------------------------------------------------------------------
  878. def start_name_window
  879. return if @name_text == ""
  880. @name_window.start(@name_text, @name_position)
  881. end
  882.  
  883. #--------------------------------------------------------------------------
  884. # overwrite method: fiber_main
  885. #--------------------------------------------------------------------------
  886. def fiber_main
  887. $game_message.visible = true
  888. update_background
  889. update_placement
  890. loop do
  891. process_all_text if $game_message.has_text?
  892. process_input
  893. $game_message.clear
  894. @gold_window.close
  895. @name_window.start_close
  896. Fiber.yield
  897. break unless text_continue?
  898. end
  899. close_and_wait
  900. $game_message.visible = false
  901. @fiber = nil
  902. end
  903.  
  904. #--------------------------------------------------------------------------
  905. # alias method: open_and_wait
  906. #--------------------------------------------------------------------------
  907. alias window_message_open_and_wait_ams open_and_wait
  908. def open_and_wait
  909. clear_name_window
  910. adjust_message_window_size
  911. window_message_open_and_wait_ams
  912. end
  913.  
  914. #--------------------------------------------------------------------------
  915. # alias method: close_and_wait
  916. #--------------------------------------------------------------------------
  917. alias window_message_close_and_wait_ams close_and_wait
  918. def close_and_wait
  919. @name_window.force_close
  920. window_message_close_and_wait_ams
  921. end
  922.  
  923. #--------------------------------------------------------------------------
  924. # alias method: all_close?
  925. #--------------------------------------------------------------------------
  926. alias window_message_all_close_ams all_close?
  927. def all_close?
  928. return window_message_all_close_ams && @name_window.close?
  929. end
  930.  
  931. #--------------------------------------------------------------------------
  932. # alias method: process_escape_character
  933. #--------------------------------------------------------------------------
  934. alias window_message_process_escape_character_ams process_escape_character
  935. def process_escape_character(code, text, pos)
  936. case code.upcase
  937. when 'W' # Wait
  938. wait(obtain_escape_param(text))
  939. else
  940. window_message_process_escape_character_ams(code, text, pos)
  941. end
  942. end
  943.  
  944. end # Window_Message
  945.  
  946. #==============================================================================
  947. #
  948. # ▼ End of File
  949. #
  950. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement