查看: 2358|回复: 2

[已经解决] Yanfly-Ace Message 与 Yami-Pop Message 联用后的弹错!

[复制链接]
梦石
0
星屑
2585
在线时间
273 小时
注册时间
2017-9-27
回帖
29
发表于 2017-12-17 14:07:49 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 银河拱门 于 2017-12-16 22:12 编辑

同时使用了 Yanfly 的 Ace Message 和 Yami 的 Pop Message。
测试时发现,如果我写一句普通的窗口居下的字幕,运行时便会弹错说明:
BUG1.png

后来反复测试后又发现,如果我每次打开游戏后,第一条显示文章的指令是气泡框的话,之后的普通的窗口居下字幕就不会报错;
但是每一次读取新的存档之后这个状态就会被重置,所以我想这个问题不得不想个办法解决...
我试过搜索,不过都没有解决的办法...
下面是脚本:
Yanfly Ace Message
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Ace Message System v1.05
  4. # -- Last Updated: 2012.01.13
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================

  9. $imported = {} if $imported.nil?
  10. $imported["YEA-MessageSystem"] = true

  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. module YEA
  151. module MESSAGE

  152. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  153. # - General Message Settings -
  154. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  155. # The following below will adjust the basic settings and that will affect
  156. # the majority of the script. Adjust them as you see fit.
  157. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  158. # This button is the button used to make message windows instantly skip
  159. # forward. Hold down for the effect. Note that when held down, this will
  160. # speed up the messages, but still wait for the pauses. However, it will
  161. # automatically go to the next page when prompted.
  162. TEXT_SKIP = :A # Input::A is the shift button on keyboard.

  163. # This variable adjusts the number of visible rows shown in the message
  164. # window. If you do not wish to use this feature, set this constant to 0.
  165. # If the row value is 0 or below, it will automatically default to 4 rows.
  166. VARIABLE_ROWS = 21

  167. # This variable adjusts the width of the message window shown. If you do
  168. # not wish to use this feature, set this constant to 0. If the width value
  169. # is 0 or below, it will automatically default to the screen width.
  170. VARIABLE_WIDTH = 22

  171. # This is the amount of space that the message window will indent whenever
  172. # a face is used. Default: 112
  173. FACE_INDENT_X = 112

  174. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  175. # - Name Window Settings -
  176. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  177. # The name window is a window that appears outside of the main message
  178. # window box to display whatever text is placed inside of it like a name.
  179. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  180. NAME_WINDOW_X_BUFFER = -20 # Buffer x position of the name window.
  181. NAME_WINDOW_Y_BUFFER = 0 # Buffer y position of the name window.
  182. NAME_WINDOW_PADDING = 20 # Padding added to the horizontal position.
  183. NAME_WINDOW_OPACITY = 255 # Opacity of the name window.
  184. NAME_WINDOW_COLOUR = 6 # Text colour used by default for names.

  185. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  186. # - Message Font Settings -
  187. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  188. # Ace Message System separates the in-game system font form the message
  189. # font. Adjust the settings here for your fonts.
  190. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  191. # This array constant determines the fonts used. If the first font does not
  192. # exist on the player's computer, the next font in question will be used
  193. # in place instead and so on.
  194. MESSAGE_WINDOW_FONT_NAME = ["SimHei"]

  195. # These adjust the other settings regarding the way the game font appears
  196. # including the font size, whether or not the font is bolded by default,
  197. # italic by default, etc.
  198. MESSAGE_WINDOW_FONT_SIZE = 18 # Font size.
  199. MESSAGE_WINDOW_FONT_BOLD = false # Default bold?
  200. MESSAGE_WINDOW_FONT_ITALIC = false # Default italic?
  201. MESSAGE_WINDOW_FONT_OUTLINE = true # Default outline?
  202. MESSAGE_WINDOW_FONT_SHADOW = false # Default shadow?

  203. end # MESSAGE
  204. end # YEA

  205. #==============================================================================
  206. # ▼ Editting anything past this point may potentially result in causing
  207. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  208. # halitosis so edit at your own risk.
  209. #==============================================================================

  210. #==============================================================================
  211. # ■ Variable
  212. #==============================================================================

  213. module Variable

  214. #--------------------------------------------------------------------------
  215. # self.message_rows
  216. #--------------------------------------------------------------------------
  217. def self.message_rows
  218. return 4 if YEA::MESSAGE::VARIABLE_ROWS <= 0
  219. return 4 if $game_variables[YEA::MESSAGE::VARIABLE_ROWS] <= 0
  220. return $game_variables[YEA::MESSAGE::VARIABLE_ROWS]
  221. end

  222. #--------------------------------------------------------------------------
  223. # self.message_width
  224. #--------------------------------------------------------------------------
  225. def self.message_width
  226. return Graphics.width if YEA::MESSAGE::VARIABLE_WIDTH <= 0
  227. return Graphics.width if $game_variables[YEA::MESSAGE::VARIABLE_WIDTH] <= 0
  228. return $game_variables[YEA::MESSAGE::VARIABLE_WIDTH]
  229. end

  230. end # Variable

  231. #==============================================================================
  232. # ■ Game_Interpreter
  233. #==============================================================================

  234. class Game_Interpreter

  235. #--------------------------------------------------------------------------
  236. # overwrite method: command_101
  237. #--------------------------------------------------------------------------
  238. def command_101
  239. wait_for_message
  240. $game_message.face_name = @params[0]
  241. $game_message.face_index = @params[1]
  242. $game_message.background = @params[2]
  243. $game_message.position = @params[3]
  244. while continue_message_string?
  245. @index += 1
  246. if @list[@index].code == 401
  247. $game_message.add(@list[@index].parameters[0])
  248. end
  249. break if $game_message.texts.size >= Variable.message_rows
  250. end
  251. case next_event_code
  252. when 102
  253. @index += 1
  254. setup_choices(@list[@index].parameters)
  255. when 103
  256. @index += 1
  257. setup_num_input(@list[@index].parameters)
  258. when 104
  259. @index += 1
  260. setup_item_choice(@list[@index].parameters)
  261. end
  262. wait_for_message
  263. end

  264. #--------------------------------------------------------------------------
  265. # new method: continue_message_string?
  266. #--------------------------------------------------------------------------
  267. def continue_message_string?
  268. return true if next_event_code == 101 && Variable.message_rows > 4
  269. return next_event_code == 401
  270. end

  271. end # Game_Interpreter

  272. #==============================================================================
  273. # ■ Window_Base
  274. #==============================================================================

  275. class Window_Base < Window

  276. #--------------------------------------------------------------------------
  277. # new method: setup_message_font
  278. #--------------------------------------------------------------------------
  279. def setup_message_font
  280. @message_font = true
  281. change_color(normal_color)
  282. contents.font.out_color = Font.default_out_color
  283. contents.font.name = YEA::MESSAGE::MESSAGE_WINDOW_FONT_NAME
  284. contents.font.size = YEA::MESSAGE::MESSAGE_WINDOW_FONT_SIZE
  285. contents.font.bold = YEA::MESSAGE::MESSAGE_WINDOW_FONT_BOLD
  286. contents.font.italic = YEA::MESSAGE::MESSAGE_WINDOW_FONT_ITALIC
  287. contents.font.outline = YEA::MESSAGE::MESSAGE_WINDOW_FONT_OUTLINE
  288. contents.font.shadow = YEA::MESSAGE::MESSAGE_WINDOW_FONT_SHADOW
  289. end

  290. #--------------------------------------------------------------------------
  291. # alias method: reset_font_settings
  292. #--------------------------------------------------------------------------
  293. alias window_base_reset_font_settings_ams reset_font_settings
  294. def reset_font_settings
  295. if @message_font
  296. setup_message_font
  297. else
  298. window_base_reset_font_settings_ams
  299. contents.font.out_color = Font.default_out_color
  300. contents.font.outline = Font.default_outline
  301. contents.font.shadow = Font.default_shadow
  302. end
  303. end

  304. #--------------------------------------------------------------------------
  305. # alias method: convert_escape_characters
  306. #--------------------------------------------------------------------------
  307. alias window_base_convert_escape_characters_ams convert_escape_characters
  308. def convert_escape_characters(text)
  309. result = window_base_convert_escape_characters_ams(text)
  310. result = convert_ace_message_system_new_escape_characters(result)
  311. return result
  312. end

  313. #--------------------------------------------------------------------------
  314. # new method: convert_ace_message_system_new_escape_characters
  315. #--------------------------------------------------------------------------
  316. def convert_ace_message_system_new_escape_characters(result)
  317. #---
  318. result.gsub!(/\eFR/i) { "\eAMSF[0]" }
  319. result.gsub!(/\eFB/i) { "\eAMSF[1]" }
  320. result.gsub!(/\eFI/i) { "\eAMSF[2]" }
  321. result.gsub!(/\eFO/i) { "\eAMSF[3]" }
  322. result.gsub!(/\eFS/i) { "\eAMSF[4]" }
  323. #---
  324. result.gsub!(/\eAC\[([-+]?\d+)\]/i) { escape_actor_class_name($1.to_i) }
  325. result.gsub!(/\eAS\[([-+]?\d+)\]/i) { escape_actor_subclass_name($1.to_i) }
  326. result.gsub!(/\eAN\[([-+]?\d+)\]/i) { escape_actor_nickname($1.to_i) }
  327. #---
  328. result.gsub!(/\eNC\[(\d+)\]/i) { $data_classes[$1.to_i].name }
  329. result.gsub!(/\eNI\[(\d+)\]/i) { $data_items[$1.to_i].name }
  330. result.gsub!(/\eNW\[(\d+)\]/i) { $data_weapons[$1.to_i].name }
  331. result.gsub!(/\eNA\[(\d+)\]/i) { $data_armors[$1.to_i].name }
  332. result.gsub!(/\eNS\[(\d+)\]/i) { $data_skills[$1.to_i].name }
  333. result.gsub!(/\eNT\[(\d+)\]/i) { $data_states[$1.to_i].name }
  334. #---
  335. result.gsub!(/\eIC\[(\d+)\]/i) { escape_icon_item($1.to_i, :class) }
  336. result.gsub!(/\eII\[(\d+)\]/i) { escape_icon_item($1.to_i, :item) }
  337. result.gsub!(/\eIW\[(\d+)\]/i) { escape_icon_item($1.to_i, :weapon) }
  338. result.gsub!(/\eIA\[(\d+)\]/i) { escape_icon_item($1.to_i, :armour) }
  339. result.gsub!(/\eIS\[(\d+)\]/i) { escape_icon_item($1.to_i, :skill) }
  340. result.gsub!(/\eIT\[(\d+)\]/i) { escape_icon_item($1.to_i, :state) }
  341. #---
  342. return result
  343. end

  344. #--------------------------------------------------------------------------
  345. # new method: escape_actor_class_name
  346. #--------------------------------------------------------------------------
  347. def escape_actor_class_name(actor_id)
  348. actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0
  349. actor = $game_actors[actor_id]
  350. return "" if actor.nil?
  351. return actor.class.name
  352. end

  353. #--------------------------------------------------------------------------
  354. # new method: actor_subclass_name
  355. #--------------------------------------------------------------------------
  356. def escape_actor_subclass_name(actor_id)
  357. return "" unless $imported["YEA-ClassSystem"]
  358. actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0
  359. actor = $game_actors[actor_id]
  360. return "" if actor.nil?
  361. return "" if actor.subclass.nil?
  362. return actor.subclass.name
  363. end

  364. #--------------------------------------------------------------------------
  365. # new method: escape_actor_nickname
  366. #--------------------------------------------------------------------------
  367. def escape_actor_nickname(actor_id)
  368. actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0
  369. actor = $game_actors[actor_id]
  370. return "" if actor.nil?
  371. return actor.nickname
  372. end

  373. #--------------------------------------------------------------------------
  374. # new method: escape_icon_item
  375. #--------------------------------------------------------------------------
  376. def escape_icon_item(data_id, type)
  377. case type
  378. when :class
  379. return "" unless $imported["YEA-ClassSystem"]
  380. icon = $data_classes[data_id].icon_index
  381. name = $data_items[data_id].name
  382. when :item
  383. icon = $data_items[data_id].icon_index
  384. name = $data_items[data_id].name
  385. when :weapon
  386. icon = $data_weapons[data_id].icon_index
  387. name = $data_weapons[data_id].name
  388. when :armour
  389. icon = $data_armors[data_id].icon_index
  390. name = $data_armors[data_id].name
  391. when :skill
  392. icon = $data_skills[data_id].icon_index
  393. name = $data_skills[data_id].name
  394. when :state
  395. icon = $data_states[data_id].icon_index
  396. name = $data_states[data_id].name
  397. else; return ""
  398. end
  399. text = "\eI[#{icon}]" + name
  400. return text
  401. end

  402. #--------------------------------------------------------------------------
  403. # alias method: process_escape_character
  404. #--------------------------------------------------------------------------
  405. alias window_base_process_escape_character_ams process_escape_character
  406. def process_escape_character(code, text, pos)
  407. case code.upcase
  408. #---
  409. when 'FZ'
  410. contents.font.size = obtain_escape_param(text)
  411. when 'FN'
  412. text.sub!(/\[(.*?)\]/, "")
  413. font_name = $1.to_s
  414. font_name = Font.default_name if font_name.nil?
  415. contents.font.name = font_name.to_s
  416. #---
  417. when 'OC'
  418. colour = text_color(obtain_escape_param(text))
  419. contents.font.out_color = colour
  420. when 'OO'
  421. contents.font.out_color.alpha = obtain_escape_param(text)
  422. #---
  423. when 'AMSF'
  424. case obtain_escape_param(text)
  425. when 0; reset_font_settings
  426. when 1; contents.font.bold = !contents.font.bold
  427. when 2; contents.font.italic = !contents.font.italic
  428. when 3; contents.font.outline = !contents.font.outline
  429. when 4; contents.font.shadow = !contents.font.shadow
  430. end
  431. #---
  432. when 'PX'
  433. pos[:x] = obtain_escape_param(text)
  434. when 'PY'
  435. pos[:y] = obtain_escape_param(text)
  436. #---
  437. when 'PIC'
  438. text.sub!(/\[(.*?)\]/, "")
  439. bmp = Cache.picture($1.to_s)
  440. rect = Rect.new(0, 0, bmp.width, bmp.height)
  441. contents.blt(pos[:x], pos[:y], bmp, rect)
  442. #---
  443. else
  444. window_base_process_escape_character_ams(code, text, pos)
  445. end
  446. end

  447. end # Window_Base

  448. #==============================================================================
  449. # ■ Window_ChoiceList
  450. #==============================================================================

  451. class Window_ChoiceList < Window_Command

  452. #--------------------------------------------------------------------------
  453. # alias method: initialize
  454. #--------------------------------------------------------------------------
  455. alias window_choicelist_initialize_ams initialize
  456. def initialize(message_window)
  457. window_choicelist_initialize_ams(message_window)
  458. setup_message_font
  459. end

  460. end # Window_ChoiceList

  461. #==============================================================================
  462. # ■ Window_ScrollText
  463. #==============================================================================

  464. class Window_ScrollText < Window_Base

  465. #--------------------------------------------------------------------------
  466. # alias method: initialize
  467. #--------------------------------------------------------------------------
  468. alias window_scrolltext_initialize_ams initialize
  469. def initialize
  470. window_scrolltext_initialize_ams
  471. setup_message_font
  472. end

  473. end # Window_ScrollText

  474. #==============================================================================
  475. # ■ Window_NameMessage
  476. #==============================================================================

  477. class Window_NameMessage < Window_Base

  478. #--------------------------------------------------------------------------
  479. # initialize
  480. #--------------------------------------------------------------------------
  481. def initialize(message_window)
  482. @message_window = message_window
  483. super(0, 0, Graphics.width, fitting_height(1))
  484. self.opacity = YEA::MESSAGE::NAME_WINDOW_OPACITY
  485. self.z = @message_window.z + 1
  486. self.openness = 0
  487. setup_message_font
  488. @close_counter = 0
  489. deactivate
  490. end

  491. #--------------------------------------------------------------------------
  492. # update
  493. #--------------------------------------------------------------------------
  494. def update
  495. super
  496. return if self.active
  497. return if self.openness == 0
  498. return if @closing
  499. @close_counter -= 1
  500. return if @close_counter > 0
  501. close
  502. end

  503. #--------------------------------------------------------------------------
  504. # start_close
  505. #--------------------------------------------------------------------------
  506. def start_close
  507. @close_counter = 4
  508. deactivate
  509. end

  510. #--------------------------------------------------------------------------
  511. # force_close
  512. #--------------------------------------------------------------------------
  513. def force_close
  514. @close_counter = 0
  515. deactivate
  516. close
  517. end

  518. #--------------------------------------------------------------------------
  519. # start
  520. #--------------------------------------------------------------------------
  521. def start(text, x_position)
  522. @text = text.clone
  523. set_width
  524. create_contents
  525. set_x_position(x_position)
  526. set_y_position
  527. refresh
  528. activate
  529. open
  530. end

  531. #--------------------------------------------------------------------------
  532. # set_width
  533. #--------------------------------------------------------------------------
  534. def set_width
  535. text = @text.clone
  536. dw = standard_padding * 2 + text_size(text).width
  537. dw += YEA::MESSAGE::NAME_WINDOW_PADDING * 2
  538. dw += calculate_size(text.slice!(0, 1), text) until text.empty?
  539. self.width = dw
  540. end

  541. #--------------------------------------------------------------------------
  542. # calculate_size
  543. #--------------------------------------------------------------------------
  544. def calculate_size(code, text)
  545. case code
  546. when "\e"
  547. return calculate_escape_code_width(obtain_escape_code(text), text)
  548. else
  549. return 0
  550. end
  551. end

  552. #--------------------------------------------------------------------------
  553. # calculate_escape_code_width
  554. #--------------------------------------------------------------------------
  555. def calculate_escape_code_width(code, text)
  556. dw = -text_size("\e").width - text_size(code).width
  557. case code.upcase
  558. when 'C', 'OC', 'OO'
  559. dw += -text_size("[" + obtain_escape_param(text).to_s + "]").width
  560. return dw
  561. when 'I'
  562. dw += -text_size("[" + obtain_escape_param(text).to_s + "]").width
  563. dw += 24
  564. return dw
  565. when '{'
  566. make_font_bigger
  567. when '}'
  568. make_font_smaller
  569. when 'FZ'
  570. contents.font.size = obtain_escape_param(text)
  571. when 'FN'
  572. text.sub!(/\[(.*?)\]/, "")
  573. font_name = $1.to_s
  574. font_name = Font.default_name if font_name.nil?
  575. contents.font.name = font_name.to_s
  576. when 'AMSF'
  577. case obtain_escape_param(text)
  578. when 0; reset_font_settings
  579. when 1; contents.font.bold = !contents.font.bold
  580. when 2; contents.font.italic = !contents.font.italic
  581. when 3; contents.font.outline = !contents.font.outline
  582. when 4; contents.font.shadow = !contents.font.shadow
  583. end
  584. else
  585. return dw
  586. end
  587. end

  588. #--------------------------------------------------------------------------
  589. # set_y_position
  590. #--------------------------------------------------------------------------
  591. def set_x_position(x_position)
  592. case x_position
  593. when 1 # Left
  594. self.x = @message_window.x
  595. self.x += YEA::MESSAGE::NAME_WINDOW_X_BUFFER
  596. when 2 # 3/10
  597. self.x = @message_window.x
  598. self.x += @message_window.width * 3 / 10
  599. self.x -= self.width / 2
  600. when 3 # Center
  601. self.x = @message_window.x
  602. self.x += @message_window.width / 2
  603. self.x -= self.width / 2
  604. when 4 # 7/10
  605. self.x = @message_window.x
  606. self.x += @message_window.width * 7 / 10
  607. self.x -= self.width / 2
  608. when 5 # Right
  609. self.x = @message_window.x + @message_window.width
  610. self.x -= self.width
  611. self.x -= YEA::MESSAGE::NAME_WINDOW_X_BUFFER
  612. end
  613. self.x = [[self.x, Graphics.width - self.width].min, 0].max
  614. end

  615. #--------------------------------------------------------------------------
  616. # set_y_position
  617. #--------------------------------------------------------------------------
  618. def set_y_position
  619. case $game_message.position
  620. when 0
  621. self.y = @message_window.height
  622. self.y -= YEA::MESSAGE::NAME_WINDOW_Y_BUFFER
  623. else
  624. self.y = @message_window.y - self.height
  625. self.y += YEA::MESSAGE::NAME_WINDOW_Y_BUFFER
  626. end
  627. end

  628. #--------------------------------------------------------------------------
  629. # refresh
  630. #--------------------------------------------------------------------------
  631. def refresh
  632. contents.clear
  633. reset_font_settings
  634. @text = sprintf("\eC[%d]%s", YEA::MESSAGE::NAME_WINDOW_COLOUR, @text)
  635. draw_text_ex(YEA::MESSAGE::NAME_WINDOW_PADDING, 0, @text)
  636. end

  637. end # Window_NameMessage

  638. #==============================================================================
  639. # ■ Window_Message
  640. #==============================================================================

  641. class Window_Message < Window_Base

  642. #--------------------------------------------------------------------------
  643. # alias method: initialize
  644. #--------------------------------------------------------------------------
  645. alias window_message_initialize_ams initialize
  646. def initialize
  647. window_message_initialize_ams
  648. setup_message_font
  649. end

  650. #--------------------------------------------------------------------------
  651. # overwrite method: window_width
  652. #--------------------------------------------------------------------------
  653. def window_width
  654. return Variable.message_width
  655. end

  656. #--------------------------------------------------------------------------
  657. # overwrite method: window_height
  658. #--------------------------------------------------------------------------
  659. def window_height
  660. return fitting_height(Variable.message_rows)
  661. end

  662. #--------------------------------------------------------------------------
  663. # alias method: create_all_windows
  664. #--------------------------------------------------------------------------
  665. alias window_message_create_all_windows_ams create_all_windows
  666. def create_all_windows
  667. window_message_create_all_windows_ams
  668. @name_window = Window_NameMessage.new(self)
  669. end

  670. #--------------------------------------------------------------------------
  671. # overwrite method: create_back_bitmap
  672. #--------------------------------------------------------------------------
  673. def create_back_bitmap
  674. @back_bitmap = Bitmap.new(width, height)
  675. rect1 = Rect.new(0, 0, Graphics.width, 12)
  676. rect2 = Rect.new(0, 12, Graphics.width, fitting_height(4) - 24)
  677. rect3 = Rect.new(0, fitting_height(4) - 12, Graphics.width, 12)
  678. @back_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true)
  679. @back_bitmap.fill_rect(rect2, back_color1)
  680. @back_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true)
  681. end

  682. #--------------------------------------------------------------------------
  683. # alias method: dispose_all_windows
  684. #--------------------------------------------------------------------------
  685. alias window_message_dispose_all_windows_ams dispose_all_windows
  686. def dispose_all_windows
  687. window_message_dispose_all_windows_ams
  688. @name_window.dispose
  689. end

  690. #--------------------------------------------------------------------------
  691. # alias method: update_all_windows
  692. #--------------------------------------------------------------------------
  693. alias window_message_update_all_windows_ams update_all_windows
  694. def update_all_windows
  695. window_message_update_all_windows_ams
  696. @name_window.update
  697. @name_window.back_opacity = self.back_opacity
  698. @name_window.opacity = self.opacity
  699. end

  700. #--------------------------------------------------------------------------
  701. # alias method: update_show_fast
  702. #--------------------------------------------------------------------------
  703. alias window_message_update_show_fast_ams update_show_fast
  704. def update_show_fast
  705. @show_fast = true if Input.press?(YEA::MESSAGE::TEXT_SKIP)
  706. window_message_update_show_fast_ams
  707. end

  708. #--------------------------------------------------------------------------
  709. # overwrite method: input_pause
  710. #--------------------------------------------------------------------------
  711. def input_pause
  712. self.pause = true
  713. wait(10)
  714. Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C) ||
  715. Input.press?(YEA::MESSAGE::TEXT_SKIP)
  716. Input.update
  717. self.pause = false
  718. end

  719. #--------------------------------------------------------------------------
  720. # overwrite method: convert_escape_characters
  721. #--------------------------------------------------------------------------
  722. def convert_escape_characters(text)
  723. result = super(text.to_s.clone)
  724. result = namebox_escape_characters(result)
  725. result = message_escape_characters(result)
  726. return result
  727. end

  728. #--------------------------------------------------------------------------
  729. # new method: namebox_escape_characters
  730. #--------------------------------------------------------------------------
  731. def namebox_escape_characters(result)
  732. result.gsub!(/\eN\<(.+?)\>/i) { namewindow($1, 1) }
  733. result.gsub!(/\eN1\<(.+?)\>/i) { namewindow($1, 1) }
  734. result.gsub!(/\eN2\<(.+?)\>/i) { namewindow($1, 2) }
  735. result.gsub!(/\eNC\<(.+?)\>/i) { namewindow($1, 3) }
  736. result.gsub!(/\eN3\<(.+?)\>/i) { namewindow($1, 3) }
  737. result.gsub!(/\eN4\<(.+?)\>/i) { namewindow($1, 4) }
  738. result.gsub!(/\eN5\<(.+?)\>/i) { namewindow($1, 5) }
  739. result.gsub!(/\eNR\<(.+?)\>/i) { namewindow($1, 5) }
  740. return result
  741. end

  742. #--------------------------------------------------------------------------
  743. # new method: namebox
  744. #--------------------------------------------------------------------------
  745. def namewindow(text, position)
  746. @name_text = text
  747. @name_position = position
  748. return ""
  749. end

  750. #--------------------------------------------------------------------------
  751. # new method: message_escape_characters
  752. #--------------------------------------------------------------------------
  753. def message_escape_characters(result)
  754. result.gsub!(/\eAF\[(-?\d+)]/i) { change_face($1.to_i) }
  755. return result
  756. end

  757. #--------------------------------------------------------------------------
  758. # new method: change_face
  759. #--------------------------------------------------------------------------
  760. def change_face(actor_id)
  761. actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0
  762. actor = $game_actors[actor_id]
  763. return "" if actor.nil?
  764. $game_message.face_name = actor.face_name
  765. $game_message.face_index = actor.face_index
  766. return ""
  767. end

  768. #--------------------------------------------------------------------------
  769. # alias method: new_page
  770. #--------------------------------------------------------------------------
  771. alias window_message_new_page_ams new_page
  772. def new_page(text, pos)
  773. adjust_message_window_size
  774. window_message_new_page_ams(text, pos)
  775. end

  776. #--------------------------------------------------------------------------
  777. # overwrite method: new_line_x
  778. #--------------------------------------------------------------------------
  779. def new_line_x
  780. return $game_message.face_name.empty? ? 0 : YEA::MESSAGE::FACE_INDENT_X
  781. end

  782. #--------------------------------------------------------------------------
  783. # new method: adjust_message_window_size
  784. #--------------------------------------------------------------------------
  785. def adjust_message_window_size
  786. self.height = window_height
  787. self.width = window_width
  788. create_contents
  789. update_placement
  790. self.x = (Graphics.width - self.width) / 2
  791. start_name_window
  792. end

  793. #--------------------------------------------------------------------------
  794. # new method: clear_name_window
  795. #--------------------------------------------------------------------------
  796. def clear_name_window
  797. @name_text = ""
  798. @name_position = 0
  799. end

  800. #--------------------------------------------------------------------------
  801. # new method: start_name_window
  802. #--------------------------------------------------------------------------
  803. def start_name_window
  804. return if @name_text == ""
  805. @name_window.start(@name_text, @name_position)
  806. end

  807. #--------------------------------------------------------------------------
  808. # overwrite method: fiber_main
  809. #--------------------------------------------------------------------------
  810. def fiber_main
  811. $game_message.visible = true
  812. update_background
  813. update_placement
  814. loop do
  815. process_all_text if $game_message.has_text?
  816. process_input
  817. $game_message.clear
  818. @gold_window.close
  819. @name_window.start_close
  820. Fiber.yield
  821. break unless text_continue?
  822. end
  823. close_and_wait
  824. $game_message.visible = false
  825. @fiber = nil
  826. end

  827. #--------------------------------------------------------------------------
  828. # alias method: open_and_wait
  829. #--------------------------------------------------------------------------
  830. alias window_message_open_and_wait_ams open_and_wait
  831. def open_and_wait
  832. clear_name_window
  833. adjust_message_window_size
  834. window_message_open_and_wait_ams
  835. end

  836. #--------------------------------------------------------------------------
  837. # alias method: close_and_wait
  838. #--------------------------------------------------------------------------
  839. alias window_message_close_and_wait_ams close_and_wait
  840. def close_and_wait
  841. @name_window.force_close
  842. window_message_close_and_wait_ams
  843. end

  844. #--------------------------------------------------------------------------
  845. # alias method: all_close?
  846. #--------------------------------------------------------------------------
  847. alias window_message_all_close_ams all_close?
  848. def all_close?
  849. return window_message_all_close_ams && @name_window.close?
  850. end

  851. #--------------------------------------------------------------------------
  852. # alias method: process_escape_character
  853. #--------------------------------------------------------------------------
  854. alias window_message_process_escape_character_ams process_escape_character
  855. def process_escape_character(code, text, pos)
  856. case code.upcase
  857. when 'W' # Wait
  858. wait(obtain_escape_param(text))
  859. else
  860. window_message_process_escape_character_ams(code, text, pos)
  861. end
  862. end

  863. end # Window_Message

  864. #==============================================================================
  865. #
  866. # ▼ End of File
  867. #
  868. #==============================================================================
复制代码

Yami Basic Module
  1. #==============================================================================
  2. #
  3. # ¥ Yami Engine Ace - Basic Module
  4. # -- Last Updated: 2012.04.27
  5. # -- Level: Nothing
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================

  9. $imported = {} if $imported.nil?
  10. $imported["YSE-BasicModule"] = true

  11. #==============================================================================
  12. # ¥ Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2012.04.27 - Added Notetags Initializer.
  15. # 2012.03.24 - Added Parse Range Keys.
  16. # 2012.03.17 - Updated Load Data Method.
  17. # 2012.03.13 - Remove requirements mechanic.
  18. # 2012.03.11 - Change in requirements mechanic.
  19. # 2012.03.02 - Added Message Box.
  20. # 2012.03.01 - Started and Finished Script.
  21. #
  22. #==============================================================================
  23. # ¥ Introduction
  24. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  25. # This script provides many methods for Yami Engine Ace.
  26. #
  27. #==============================================================================
  28. # ¥ Instructions
  29. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  30. # To install this script, open up your script editor and copy/paste this script
  31. # to an open slot below ¥ Materials/‘fÞ but above ¥ Main. Remember to save.
  32. #
  33. #==============================================================================
  34. # ¥ Compatibility
  35. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  36. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  37. # it will run with RPG Maker VX without adjusting.
  38. #
  39. #==============================================================================

  40. #==============================================================================
  41. # ¥ Configuration
  42. #==============================================================================

  43. module YSE
  44.   
  45.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  46.   # - External Data Configuration -
  47.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  48.   DATA_CONFIGURATION = { # Start here.
  49.     :ext        =>  "rvdata2",   # Data File Extension.
  50.     :salt       =>  "cl",        # Salt. Make an unique two-character phrase.
  51.                                  # Must be 2 characters.
  52.     :unique     =>  "z8x8273ac", # Unique phrase. Must be at least 1 character.                          
  53.     :comp_level =>  9,           # Level from 1 to 9. Best Speed at 1, Best
  54.                                  # Compress at 9.
  55.   } # Do not delete this.
  56.   
  57. end

  58. #==============================================================================
  59. # ¥ Editting anything past this point may potentially result in causing
  60. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  61. # halitosis so edit at your own risk.
  62. #==============================================================================

  63. #==============================================================================
  64. # ¡ YSE - Basic Module
  65. #==============================================================================

  66. module YSE
  67.   
  68.   #--------------------------------------------------------------------------
  69.   # message_box
  70.   #--------------------------------------------------------------------------
  71.   def self.message_box(title, message)
  72.     api = Win32API.new('user32','MessageBox',['L', 'P', 'P', 'L'],'I')  
  73.     api.call(0,message,title,0)  
  74.   end
  75.   
  76.   #--------------------------------------------------------------------------
  77.   # charset
  78.   #--------------------------------------------------------------------------
  79.   def self.charset
  80.     result = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789"
  81.     result
  82.   end
  83.   
  84.   #--------------------------------------------------------------------------
  85.   # make_random_string
  86.   #--------------------------------------------------------------------------
  87.   def self.make_random_string(length = 6)
  88.     result = ""
  89.     while result.size < length
  90.       result << charset[rand(charset.size)]
  91.     end
  92.     result
  93.   end
  94.   
  95.   #--------------------------------------------------------------------------
  96.   # make_filename
  97.   #--------------------------------------------------------------------------
  98.   def self.make_filename(filename, dir = "")
  99.     ext = DATA_CONFIGURATION[:ext]
  100.     result = "#{dir}/#{filename}.#{ext}"
  101.     result
  102.   end
  103.   
  104.   #--------------------------------------------------------------------------
  105.   # compress_data
  106.   #--------------------------------------------------------------------------
  107.   def self.compress_data(data, comp_level = nil)
  108.     compress_level = comp_level.nil? ? DATA_CONFIGURATION[:comp_level] : comp_level
  109.     result = Zlib::Deflate.deflate(Marshal.dump(data), compress_level)
  110.     result
  111.   end
  112.   
  113.   #--------------------------------------------------------------------------
  114.   # decompress_data
  115.   #--------------------------------------------------------------------------
  116.   def self.decompress_data(data)
  117.     result = Zlib::Inflate.inflate(Marshal.load(data))
  118.     result
  119.   end
  120.   
  121.   #--------------------------------------------------------------------------
  122.   # make_hash
  123.   #--------------------------------------------------------------------------
  124.   def self.make_hash(string = "")
  125.     salt = DATA_CONFIGURATION[:salt]
  126.     result = string.crypt(salt)
  127.     result = result + DATA_CONFIGURATION[:unique]
  128.     result
  129.   end
  130.   
  131.   #--------------------------------------------------------------------------
  132.   # save_data
  133.   #--------------------------------------------------------------------------
  134.   def self.save_data(filename, data_hash)
  135.     File.open(filename, "wb") do |file|
  136.       Marshal.dump(compress_data(data_hash), file)
  137.     end
  138.     return true
  139.   end
  140.   
  141.   #--------------------------------------------------------------------------
  142.   # save_data
  143.   #--------------------------------------------------------------------------
  144.   def self.load_data(filename, method, index = 0, ext = nil)
  145.     File.open(filename, "rb") do |file|
  146.       index.times { Marshal.load(file) }
  147.       if ext
  148.         case ext
  149.         when :mtime
  150.           method.call(Marshal.load(decompress_data(file)), file.mtime)
  151.         end
  152.       else
  153.         method.call(Marshal.load(decompress_data(file)))
  154.       end
  155.     end
  156.     return true
  157.   end
  158.   
  159.   #--------------------------------------------------------------------------
  160.   # parse_range
  161.   #--------------------------------------------------------------------------
  162.   def self.parse_range(hash)
  163.     result = {}
  164.     hash.each { |key, value|
  165.       if key.is_a?(Range)
  166.         key.each { |id| result[id] = value }
  167.       else
  168.         result[key] = value
  169.       end
  170.     }
  171.     result
  172.   end
  173.   
  174.   #--------------------------------------------------------------------------
  175.   # patch_start
  176.   #--------------------------------------------------------------------------
  177.   def self.patch_start
  178.     return unless $imported["YSE-PatchSystem"]
  179.     SceneManager.call(Scene_Patch_YSE)
  180.   end
  181.   
  182. end # YSE - Basic Module

  183. #==============================================================================
  184. # ¡ DataManager
  185. #==============================================================================

  186. module DataManager
  187.   
  188.   #--------------------------------------------------------------------------
  189.   # alias method: load_database
  190.   #--------------------------------------------------------------------------
  191.   class <<self; alias load_database_yebm load_database; end
  192.   def self.load_database
  193.     load_database_yebm
  194.     load_notetags_ye
  195.   end
  196.   
  197.   #--------------------------------------------------------------------------
  198.   # new method: load_notetags_ye
  199.   #--------------------------------------------------------------------------
  200.   def self.load_notetags_ye
  201.     groups = [$data_actors, $data_classes, $data_skills, $data_items, $data_weapons,
  202.               $data_armors, $data_enemies, $data_states]
  203.     groups.each { |group|
  204.       group.each { |obj|
  205.         next if obj.nil?
  206.         obj.notetags_initialize
  207.       }
  208.     }
  209.   end
  210.   
  211. end # DataManager

  212. #==============================================================================
  213. # ¡ RPG::BaseItem
  214. #==============================================================================

  215. class RPG::BaseItem
  216.   
  217.   #--------------------------------------------------------------------------
  218.   # new method: notetags_initialize
  219.   #--------------------------------------------------------------------------
  220.   def notetags_initialize
  221.     @notelines = []
  222.     #---
  223.     self.note.split(/[\r\n]+/).each { |line|
  224.       @notelines.push(line)
  225.     } # self.note.split
  226.     #---
  227.     notetags_reader
  228.   end
  229.   
  230.   #--------------------------------------------------------------------------
  231.   # new method: notetags_reader
  232.   #--------------------------------------------------------------------------
  233.   def notetags_reader
  234.     # Reading Notetags.
  235.   end
  236.   
  237. end # RPG::BaseItem

  238. #==============================================================================
  239. # ¡ System Errors
  240. #==============================================================================

  241. if YSE::DATA_CONFIGURATION[:salt].size < 2
  242.   YSE.message_box("YSE - Basic Module", "Salt must have at least 2 characters.")
  243.   exit
  244. end

  245. if YSE::DATA_CONFIGURATION[:unique].size < 1
  246.   YSE.message_box("YSE - Basic Module", "Unique phrase must have at least 1 character.")
  247.   exit
  248. end

  249. #==============================================================================
  250. #
  251. # ¥ End of File
  252. #
  253. #==============================================================================
复制代码

Yami Pop Message
  1. #==============================================================================
  2. #
  3. # ¥ Yami Engine Ace - Pop Message
  4. # -- Last Updated: 2012.06.07
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================

  9. $imported = {} if $imported.nil?
  10. $imported["YSE-PopMessage"] = true

  11. #==============================================================================
  12. # ¥ Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2012.06.07 - Fixed Compatible: YEA - Ace Message System.
  15. # 2012.05.11 - Fixed Message Position.
  16. #            - Remove Requirement: YSE - Fix Events Order.
  17. # 2012.05.07 - Fixed Face position.
  18. #            - Added Requirement: YSE - Fix Events Order.
  19. # 2012.04.06 - You can change Bubble Tag filename.
  20. # 2012.03.28 - Fixed Default Message Position and Sizes.
  21. # 2012.03.27 - Fixed Default Message.
  22. # 2012.03.27 - Added Bubble Tag.
  23. # 2012.03.25 - Fixed Escape Message.
  24. # 2012.03.24 - Fixed Battle Message.
  25. # 2012.03.24 - Rewrote script.
  26. #
  27. #==============================================================================
  28. # ¥ Instructions
  29. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  30. # To install this script, open up your script editor and copy/paste this script
  31. # to an open slot below ¥ Materials/‘fÞ but above ¥ Main. Remember to save.
  32. #
  33. # -----------------------------------------------------------------------------
  34. # Message Window text Codes - These go inside of your message window.
  35. # -----------------------------------------------------------------------------
  36. #  Position:   Effect:
  37. #    \bm[x]    - Sets Message Window position to event x. *Note
  38. #    \cbm      - Cancel bubble message.
  39. #
  40. #              *Note: Set to 0 to sets position to Game Player.
  41. #
  42. #==============================================================================
  43. # ¥ Compatibility
  44. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  45. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  46. # it will run with RPG Maker VX without adjusting.
  47. #
  48. #==============================================================================

  49. module YSE
  50.   module POP_MESSAGE
  51.    
  52.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  53.     # - Visual Settings -
  54.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  55.     LIMIT = { # Start.
  56.       :limit_width    =>  0,  # Set to 0 to disable limit.
  57.       :limit_line     =>  6,  # Set to 0 to disable limit.
  58.     } # End.
  59.    
  60.     POSITION = { # Start.
  61.       :x_buffer       =>  0,
  62.       :y_buffer       =>  -36,
  63.       :face_x_buffer  =>  8,
  64.       :face_y_buffer  =>  24,
  65.       :tag_y_buffer   =>  -6,
  66.       :name_x_buffer  =>  112, # Require YEA - Message System.
  67.     } # End.
  68.    
  69.     EFFECT = { # Start.
  70.       :fade_face       =>  true,
  71.       :move_face       =>  true,
  72.       :use_bubble_tag  =>  true,
  73.       :bubble_tag_name => "BubbleTag",
  74.     } # End.
  75.    
  76.   end
  77. end

  78. #==============================================================================
  79. # ¥ Editting anything past this point may potentially result in causing
  80. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  81. # halitosis so edit at your own risk.
  82. #==============================================================================

  83. #==============================================================================
  84. # ¡ Spriteset_Map
  85. #==============================================================================

  86. class Spriteset_Map
  87.   
  88.   #--------------------------------------------------------------------------
  89.   # public instance variables
  90.   #--------------------------------------------------------------------------
  91.   attr_accessor :character_sprites
  92.   
  93. end # Spriteset_Map

  94. #==============================================================================
  95. # ¡ Window_Message_Face
  96. #==============================================================================

  97. class Window_Message_Face < Window_Base
  98.   
  99.   #--------------------------------------------------------------------------
  100.   # initialize
  101.   #--------------------------------------------------------------------------
  102.   def initialize
  103.     super(0, 0, 120, 120)
  104.     self.opacity = 0
  105.     @face_name = ""
  106.     @face_index = 0
  107.     @move_x = 0
  108.     close
  109.   end
  110.   
  111.   #--------------------------------------------------------------------------
  112.   # message_window=
  113.   #--------------------------------------------------------------------------
  114.   def message_window=(window)
  115.     @message_window = window
  116.   end
  117.   
  118.   #--------------------------------------------------------------------------
  119.   # set_face
  120.   #--------------------------------------------------------------------------
  121.   def set_face
  122.     contents.clear
  123.     return unless @message_window
  124.     if !$game_message.face_name.empty?
  125.       draw_face($game_message.face_name, $game_message.face_index, 0, 0)
  126.       set_position
  127.       show_face
  128.     else
  129.       hide_face
  130.     end
  131.   end
  132.   
  133.   #--------------------------------------------------------------------------
  134.   # set_position
  135.   #--------------------------------------------------------------------------
  136.   def set_position
  137.     return unless @message_window
  138.     self.x = @message_window.x
  139.     self.y = @message_window.y - 96
  140.     self.x += YSE::POP_MESSAGE::POSITION[:face_x_buffer]
  141.     self.y += YSE::POP_MESSAGE::POSITION[:face_y_buffer]
  142.     self.y += (@message_window.real_lines - 1) * 24
  143.     self.z = @message_window.z + 1
  144.     if (@face_name != $game_message.face_name || @face_index != $game_message.face_index)
  145.       if YSE::POP_MESSAGE::EFFECT[:move_face]
  146.         @move_x = 30
  147.         self.x -= 30
  148.       end
  149.       @face_name = $game_message.face_name
  150.       @face_index = $game_message.face_index
  151.       self.contents_opacity = 0 if YSE::POP_MESSAGE::EFFECT[:fade_face]
  152.     end
  153.   end
  154.   
  155.   #--------------------------------------------------------------------------
  156.   # show_face
  157.   #--------------------------------------------------------------------------
  158.   def show_face
  159.     open
  160.   end
  161.   
  162.   #--------------------------------------------------------------------------
  163.   # hide_face
  164.   #--------------------------------------------------------------------------
  165.   def hide_face
  166.     contents.clear
  167.     close
  168.   end
  169.   
  170.   #--------------------------------------------------------------------------
  171.   # update
  172.   #--------------------------------------------------------------------------
  173.   def update
  174.     super
  175.     self.contents_opacity += 15 if self.contents_opacity < 255
  176.     unless @move_x <= 0
  177.       self.x += 2
  178.       @move_x -= 2
  179.     end
  180.   end
  181.   
  182. end # Sprite_Message_Face

  183. #==============================================================================
  184. # ¡ Window_Message
  185. #==============================================================================

  186. class Window_Message < Window_Base
  187.   
  188.   #--------------------------------------------------------------------------
  189.   # new method: face_window=
  190.   #--------------------------------------------------------------------------
  191.   def face_window=(window)
  192.     @face_window = window
  193.   end
  194.   
  195.   #--------------------------------------------------------------------------
  196.   # new method: bubble_tag=
  197.   #--------------------------------------------------------------------------
  198.   def bubble_tag=(sprite)
  199.     @bubble_tag = sprite
  200.   end
  201.   
  202.   #--------------------------------------------------------------------------
  203.   # new method: message_escape_characters_pop_message
  204.   #--------------------------------------------------------------------------
  205.   def message_escape_characters_pop_message(result)
  206.     result.gsub!(/\eBM\[(\d+)\]/i) { event_pop_message_setup($1.to_i, false) }
  207.     result.gsub!(/\eBMF\[(\d+)\]/i) { event_pop_message_setup($1.to_i, true) }
  208.     result.gsub!(/\eCBM/i) { event_pop_message_setup(nil, false) }
  209.     result
  210.   end
  211.   
  212.   #--------------------------------------------------------------------------
  213.   # alias method: convert_escape_characters
  214.   #--------------------------------------------------------------------------
  215.   alias yse_convert_escape_characters_pm convert_escape_characters
  216.   def convert_escape_characters(text)
  217.     result = yse_convert_escape_characters_pm(text)
  218.     result = message_escape_characters_pop_message(result)
  219.     result
  220.   end
  221.   
  222.   #--------------------------------------------------------------------------
  223.   # new method: event_pop_message_setup
  224.   #--------------------------------------------------------------------------
  225.   def event_pop_message_setup(event_id, follower = false)
  226.     if follower && $game_player.followers[event_id].nil?
  227.       @event_pop_id = nil
  228.       @event_pop_follower = false
  229.       return ""
  230.     end
  231.     @event_pop_follower = follower
  232.     @event_pop_id = event_id
  233.     return ""
  234.   end
  235.   
  236.   #--------------------------------------------------------------------------
  237.   # new method: set_face_position
  238.   #--------------------------------------------------------------------------
  239.   def set_face_position
  240.     return unless SceneManager.scene_is?(Scene_Map)
  241.     return unless @event_pop_id
  242.     return unless @face_window
  243.     contents.clear
  244.     @face_window.set_face
  245.     return unless $imported["YEA-MessageSystem"]
  246.     return if @face_window.close?
  247.     #@name_window.x = self.x + YSE::POP_MESSAGE::POSITION[:face_x_buffer] + YSE::POP_MESSAGE::POSITION[:name_x_buffer] if (@name_position == 1 || @name_position == 2)
  248.   end
  249.   
  250.   #--------------------------------------------------------------------------
  251.   # alias method: new_page
  252.   #--------------------------------------------------------------------------
  253.   alias window_message_new_page_pm_yse new_page
  254.   def new_page(text, pos)
  255.     window_message_new_page_pm_yse(text, pos)
  256.     set_face_position
  257.   end
  258.   
  259.   #--------------------------------------------------------------------------
  260.   # alias method: close
  261.   #--------------------------------------------------------------------------
  262.   alias pop_message_close close
  263.   def close
  264.     pop_message_close
  265.     return unless SceneManager.scene_is?(Scene_Map)
  266.     return unless @event_pop_id
  267.     @event_pop_id = nil
  268.     @event_pop_follower = false
  269.     @face_window.hide_face
  270.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  271.     @bubble_tag.visible = false if @bubble_tag
  272.   end
  273.   
  274.   #--------------------------------------------------------------------------
  275.   # alias method: open_and_wait
  276.   #--------------------------------------------------------------------------
  277.   alias pop_message_open_and_wait open_and_wait
  278.   def open_and_wait
  279.     pop_message_open_and_wait
  280.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  281.     @bubble_tag.visible = true if @event_pop_id && @bubble_tag
  282.   end
  283.   
  284.   #--------------------------------------------------------------------------
  285.   # alias method: process_all_text
  286.   #--------------------------------------------------------------------------
  287.   alias pop_message_process_all_text process_all_text
  288.   def process_all_text
  289.     @event_pop_id = nil
  290.     convert_escape_characters($game_message.all_text)
  291.     update_placement
  292.     adjust_pop_message($game_message.all_text)
  293.     pop_message_process_all_text
  294.   end

  295.   #--------------------------------------------------------------------------
  296.   # alias method: update_placement
  297.   #--------------------------------------------------------------------------
  298.   alias event_pop_message_update_placement update_placement
  299.   def update_placement
  300.     if SceneManager.scene_is?(Scene_Map)
  301.       if @event_pop_id.nil?
  302.         fix_default_message
  303.         event_pop_message_update_placement
  304.       elsif @event_pop_id == 0
  305.         character = $game_player
  306.         self.y = character.screen_y - self.height + YSE::POP_MESSAGE::POSITION[:y_buffer]
  307.         self.x = character.screen_x - self.width / 2 + YSE::POP_MESSAGE::POSITION[:x_buffer]
  308.         fix_position_bubble(character)
  309.         set_bubble_tag(character)
  310.       elsif @event_pop_id > 0
  311.         hash = @event_pop_follower ? $game_player.followers : $game_map.events
  312.         character = hash[@event_pop_id]
  313.         self.y = character.screen_y - self.height + YSE::POP_MESSAGE::POSITION[:y_buffer]
  314.         self.x = character.screen_x - self.width / 2 + YSE::POP_MESSAGE::POSITION[:x_buffer]
  315.         fix_position_bubble(character)
  316.         set_bubble_tag(character)
  317.       end
  318.     else
  319.       event_pop_message_update_placement
  320.     end
  321.   end
  322.   
  323.   #--------------------------------------------------------------------------
  324.   # new method: fix_default_message
  325.   #--------------------------------------------------------------------------
  326.   def fix_default_message
  327.     self.width = window_width
  328.     self.height = window_height
  329.     self.x = 0
  330.     @face_window.hide_face if @face_window
  331.     create_contents
  332.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  333.     @bubble_tag.visible = false if @bubble_tag
  334.   end
  335.   
  336.   #--------------------------------------------------------------------------
  337.   # new method: fix_position_bubble
  338.   #--------------------------------------------------------------------------
  339.   def fix_position_bubble(character)
  340.     end_x = self.x + self.width
  341.     end_y = self.y + self.height
  342.     self.x = 0 if self.x < 0
  343.     self.y = character.screen_y if self.y < 0
  344.     self.x = Graphics.width - self.width if end_x > Graphics.width
  345.     self.y = Graphics.height - self.height if end_y > Graphics.height
  346.   end
  347.   
  348.   #--------------------------------------------------------------------------
  349.   # new method: set_bubble_tag
  350.   #--------------------------------------------------------------------------
  351.   def set_bubble_tag(character)
  352.     return unless YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  353.     return unless @bubble_tag
  354.     up = self.y == character.screen_y
  355.     self.y += up ? @bubble_tag.height / 2 : -@bubble_tag.height / 2
  356.     @bubble_tag.x = character.screen_x - @bubble_tag.width / 2
  357.     if up
  358.       @bubble_tag.src_rect.set(0, @bubble_tag.height, @bubble_tag.width, @bubble_tag.height)
  359.       @bubble_tag.y = self.y - @bubble_tag.height - YSE::POP_MESSAGE::POSITION[:tag_y_buffer]
  360.     else
  361.       @bubble_tag.src_rect.set(0, 0, @bubble_tag.width, @bubble_tag.height)
  362.       @bubble_tag.y = self.y + self.height + YSE::POP_MESSAGE::POSITION[:tag_y_buffer]
  363.     end
  364.   end
  365.   
  366.   #--------------------------------------------------------------------------
  367.   # new method: cal_number_line
  368.   #--------------------------------------------------------------------------
  369.   def cal_number_line(text)
  370.     result = 0
  371.     text.each_line { result += 1 }
  372.     return result
  373.   end
  374.   
  375.   #--------------------------------------------------------------------------
  376.   # new method: cal_width_line
  377.   #--------------------------------------------------------------------------
  378.   def cal_width_line(text)
  379.     result = 0
  380.     text.each_line { |line|
  381.       result = text_size(line).width if result < text_size(line).width
  382.     }
  383.     return result
  384.   end

  385.   #--------------------------------------------------------------------------
  386.   # alias method: adjust_message_window_size
  387.   #--------------------------------------------------------------------------
  388.   if $imported["YEA-MessageSystem"]
  389.   alias yse_pop_message_adjust_message_window_size adjust_message_window_size
  390.   def adjust_message_window_size
  391.     start_name_window if @event_pop_id
  392.     return if @event_pop_id
  393.     yse_pop_message_adjust_message_window_size
  394.   end
  395.   end
  396.   
  397. #--------------------------------------------------------------------------
  398.   # new method: adjust_pop_message
  399.   #--------------------------------------------------------------------------
  400. def adjust_pop_message(text = " ")
  401.     return unless SceneManager.scene_is?(Scene_Map)
  402.     unless @event_pop_id
  403.       if $imported["YEA-MessageSystem"]
  404.         adjust_message_window_size
  405.       end
  406.       return
  407.     end
  408.     n_line = cal_number_line(text)
  409.     text = text.split("\n").each{|s| s.gsub!(/\\\w*\[\w*\]|\n/i,'')}.sort_by!{|s| s.length}.pop
  410.     n_line = YSE::POP_MESSAGE::LIMIT[:limit_line] if YSE::POP_MESSAGE::LIMIT[:limit_line] > 0 && cal_number_line(text) > YSE::POP_MESSAGE::LIMIT[:limit_line]
  411.     @real_lines = n_line
  412.     self.height = fitting_height(n_line)
  413.     self.width = cal_width_line(text) + 24 #<- 增加这个数字来调整后面的距离(如果不顺眼)
  414.     self.width += new_line_x
  415.     if self.width > YSE::POP_MESSAGE::LIMIT[:limit_width] && YSE::POP_MESSAGE::LIMIT[:limit_width] > 0
  416.       self.width = YSE::POP_MESSAGE::LIMIT[:limit_width]
  417.     end
  418.     create_contents
  419.     update_placement
  420.   end
  421.   
  422.   #--------------------------------------------------------------------------
  423.   # overwrite method: new_line_x
  424.   #--------------------------------------------------------------------------
  425.   def new_line_x
  426.     if $game_message.face_name.empty?
  427.       return 0
  428.     else
  429.       result = YSE::POP_MESSAGE::POSITION[:face_x_buffer]
  430.       p_x = $imported["YEA-MessageSystem"] ? YEA::MESSAGE::FACE_INDENT_X : 112
  431.       result += p_x
  432.       return result
  433.     end
  434.   end
  435.   
  436.   #--------------------------------------------------------------------------
  437.   # new method: real_lines
  438.   #--------------------------------------------------------------------------
  439.   def real_lines
  440.     @real_lines
  441.   end
  442.   
  443. end # Window_Message

  444. #==============================================================================
  445. # ¡ Scene_Map
  446. #==============================================================================

  447. class Scene_Map < Scene_Base
  448.   
  449.   #--------------------------------------------------------------------------
  450.   # alias method: create_message_window
  451.   #--------------------------------------------------------------------------
  452.   alias yse_pm_create_message_window create_message_window
  453.   def create_message_window
  454.     yse_pm_create_message_window
  455.     @face_window = Window_Message_Face.new
  456.     @face_window.message_window = @message_window
  457.     if YSE::POP_MESSAGE::EFFECT[:use_bubble_tag]
  458.       @bubble_tag_sprite = Sprite.new
  459.       @bubble_tag_sprite.visible = false
  460.       @bubble_tag_sprite.bitmap = Cache.system(YSE::POP_MESSAGE::EFFECT[:bubble_tag_name])
  461.       @bubble_tag_sprite.src_rect.set(0, 0, @bubble_tag_sprite.width, @bubble_tag_sprite.height / 2)
  462.       @message_window.bubble_tag = @bubble_tag_sprite
  463.     end
  464.     @message_window.face_window = @face_window
  465.   end
  466.   
  467.   #--------------------------------------------------------------------------
  468.   # alias method: dispose_spriteset
  469.   #--------------------------------------------------------------------------
  470.   alias pop_message_dispose_spriteset dispose_spriteset
  471.   def dispose_spriteset
  472.     pop_message_dispose_spriteset
  473.     return unless @bubble_tag_sprite
  474.     @bubble_tag_sprite.dispose
  475.   end
  476.   
  477. end # Scene_Map

  478. #==============================================================================
  479. #
  480. # ¥ End of File
  481. #
  482. #==============================================================================
复制代码



梦石
0
星屑
6891
在线时间
7027 小时
注册时间
2013-11-2
回帖
1263

开拓者剧作品鉴家

发表于 2017-12-17 15:29:53 | 显示全部楼层
880行和881行之间增加:
@name_text ||= ""

注:||= 这个符号的意思是“如果变量为空值,就设置默认值”。

回复

使用道具 举报

梦石
0
星屑
2585
在线时间
273 小时
注册时间
2017-9-27
回帖
29
 楼主| 发表于 2017-12-17 15:40:23 | 显示全部楼层
RaidenInfinity 发表于 2017-12-16 23:29
880行和881行之间增加:
@name_text ||= ""

啊,问题顺利地解决了!
谢谢!我们非常地感激!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部