找回密码
 注册用户
查看: 457|回复: 0

[RMVA] 【搬运】YEA-MessageSystem

[复制链接]

88

主题

7

回帖

1277

积分

资深会员

积分
1277
发表于 2024-6-26 17:06:23 | 显示全部楼层 |阅读模式
老物留档,未汉化,甚至脚本来自于 pastebin

脚本:
  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.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  154.     # - General Message Settings -
  155.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  156.     # The following below will adjust the basic settings and that will affect
  157.     # the majority of the script. Adjust them as you see fit.
  158.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  159.     # This button is the button used to make message windows instantly skip
  160.     # forward. Hold down for the effect. Note that when held down, this will
  161.     # speed up the messages, but still wait for the pauses. However, it will
  162.     # automatically go to the next page when prompted.
  163.     TEXT_SKIP = :A     # Input::A is the shift button on keyboard.
  164.    
  165.     # This variable adjusts the number of visible rows shown in the message
  166.     # window. If you do not wish to use this feature, set this constant to 0.
  167.     # If the row value is 0 or below, it will automatically default to 4 rows.
  168.     VARIABLE_ROWS  = 21
  169.    
  170.     # This variable adjusts the width of the message window shown. If you do
  171.     # not wish to use this feature, set this constant to 0. If the width value
  172.     # is 0 or below, it will automatically default to the screen width.
  173.     VARIABLE_WIDTH = 22
  174.    
  175.     # This is the amount of space that the message window will indent whenever
  176.     # a face is used. Default: 112
  177.     FACE_INDENT_X = 112
  178.    
  179.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  180.     # - Name Window Settings -
  181.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  182.     # The name window is a window that appears outside of the main message
  183.     # window box to display whatever text is placed inside of it like a name.
  184.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  185.     NAME_WINDOW_X_BUFFER = -20     # Buffer x position of the name window.
  186.     NAME_WINDOW_Y_BUFFER = 0       # Buffer y position of the name window.
  187.     NAME_WINDOW_PADDING  = 20      # Padding added to the horizontal position.
  188.     NAME_WINDOW_OPACITY  = 255     # Opacity of the name window.
  189.     NAME_WINDOW_COLOUR   = 6       # Text colour used by default for names.
  190.    
  191.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  192.     # - Message Font Settings -
  193.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  194.     # Ace Message System separates the in-game system font form the message
  195.     # font. Adjust the settings here for your fonts.
  196.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  197.     # This array constant determines the fonts used. If the first font does not
  198.     # exist on the player's computer, the next font in question will be used
  199.     # in place instead and so on.
  200.     MESSAGE_WINDOW_FONT_NAME = ["Verdana", "Arial", "Courier New"]
  201.    
  202.     # These adjust the other settings regarding the way the game font appears
  203.     # including the font size, whether or not the font is bolded by default,
  204.     # italic by default, etc.
  205.     MESSAGE_WINDOW_FONT_SIZE    = 24       # Font size.
  206.     MESSAGE_WINDOW_FONT_BOLD    = false    # Default bold?
  207.     MESSAGE_WINDOW_FONT_ITALIC  = false    # Default italic?
  208.     MESSAGE_WINDOW_FONT_OUTLINE = true     # Default outline?
  209.     MESSAGE_WINDOW_FONT_SHADOW  = false    # Default shadow?
  210.    
  211.   end # MESSAGE
  212. end # YEA

  213. #==============================================================================
  214. # ▼ Editting anything past this point may potentially result in causing
  215. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  216. # halitosis so edit at your own risk.
  217. #==============================================================================

  218. #==============================================================================
  219. # ■ Variable
  220. #==============================================================================

  221. module Variable
  222.   
  223.   #--------------------------------------------------------------------------
  224.   # self.message_rows
  225.   #--------------------------------------------------------------------------
  226.   def self.message_rows
  227.     return 4 if YEA::MESSAGE::VARIABLE_ROWS <= 0
  228.     return 4 if $game_variables[YEA::MESSAGE::VARIABLE_ROWS] <= 0
  229.     return $game_variables[YEA::MESSAGE::VARIABLE_ROWS]
  230.   end
  231.   
  232.   #--------------------------------------------------------------------------
  233.   # self.message_width
  234.   #--------------------------------------------------------------------------
  235.   def self.message_width
  236.     return Graphics.width if YEA::MESSAGE::VARIABLE_WIDTH <= 0
  237.     return Graphics.width if $game_variables[YEA::MESSAGE::VARIABLE_WIDTH] <= 0
  238.     return $game_variables[YEA::MESSAGE::VARIABLE_WIDTH]
  239.   end
  240.   
  241. end # Variable

  242. #==============================================================================
  243. # ■ Game_Interpreter
  244. #==============================================================================

  245. class Game_Interpreter
  246.   
  247.   #--------------------------------------------------------------------------
  248.   # overwrite method: command_101
  249.   #--------------------------------------------------------------------------
  250.   def command_101
  251.     wait_for_message
  252.     $game_message.face_name = @params[0]
  253.     $game_message.face_index = @params[1]
  254.     $game_message.background = @params[2]
  255.     $game_message.position = @params[3]
  256.     while continue_message_string?
  257.       @index += 1
  258.       if @list[@index].code == 401
  259.         $game_message.add(@list[@index].parameters[0])
  260.       end
  261.       break if $game_message.texts.size >= Variable.message_rows
  262.     end
  263.     case next_event_code
  264.     when 102
  265.       @index += 1
  266.       setup_choices(@list[@index].parameters)
  267.     when 103
  268.       @index += 1
  269.       setup_num_input(@list[@index].parameters)
  270.     when 104
  271.       @index += 1
  272.       setup_item_choice(@list[@index].parameters)
  273.     end
  274.     wait_for_message
  275.   end
  276.   
  277.   #--------------------------------------------------------------------------
  278.   # new method: continue_message_string?
  279.   #--------------------------------------------------------------------------
  280.   def continue_message_string?
  281.     return true if next_event_code == 101 && Variable.message_rows > 4
  282.     return next_event_code == 401
  283.   end
  284.   
  285. end # Game_Interpreter

  286. #==============================================================================
  287. # ■ Window_Base
  288. #==============================================================================

  289. class Window_Base < Window
  290.   
  291.   #--------------------------------------------------------------------------
  292.   # new method: setup_message_font
  293.   #--------------------------------------------------------------------------
  294.   def setup_message_font
  295.     @message_font = true
  296.     change_color(normal_color)
  297.     contents.font.out_color = Font.default_out_color
  298.     contents.font.name = YEA::MESSAGE::MESSAGE_WINDOW_FONT_NAME
  299.     contents.font.size = YEA::MESSAGE::MESSAGE_WINDOW_FONT_SIZE
  300.     contents.font.bold = YEA::MESSAGE::MESSAGE_WINDOW_FONT_BOLD
  301.     contents.font.italic = YEA::MESSAGE::MESSAGE_WINDOW_FONT_ITALIC
  302.     contents.font.outline = YEA::MESSAGE::MESSAGE_WINDOW_FONT_OUTLINE
  303.     contents.font.shadow = YEA::MESSAGE::MESSAGE_WINDOW_FONT_SHADOW
  304.   end
  305.   
  306.   #--------------------------------------------------------------------------
  307.   # alias method: reset_font_settings
  308.   #--------------------------------------------------------------------------
  309.   alias window_base_reset_font_settings_ams reset_font_settings
  310.   def reset_font_settings
  311.     if @message_font
  312.       setup_message_font
  313.     else
  314.       window_base_reset_font_settings_ams
  315.       contents.font.out_color = Font.default_out_color
  316.       contents.font.outline = Font.default_outline
  317.       contents.font.shadow = Font.default_shadow
  318.     end
  319.   end
  320.   
  321.   #--------------------------------------------------------------------------
  322.   # alias method: convert_escape_characters
  323.   #--------------------------------------------------------------------------
  324.   alias window_base_convert_escape_characters_ams convert_escape_characters
  325.   def convert_escape_characters(text)
  326.     result = window_base_convert_escape_characters_ams(text)
  327.     result = convert_ace_message_system_new_escape_characters(result)
  328.     return result
  329.   end
  330.   
  331.   #--------------------------------------------------------------------------
  332.   # new method: convert_ace_message_system_new_escape_characters
  333.   #--------------------------------------------------------------------------
  334.   def convert_ace_message_system_new_escape_characters(result)
  335.     #---
  336.     result.gsub!(/\eFR/i) { "\eAMSF[0]" }
  337.     result.gsub!(/\eFB/i) { "\eAMSF[1]" }
  338.     result.gsub!(/\eFI/i) { "\eAMSF[2]" }
  339.     result.gsub!(/\eFO/i) { "\eAMSF[3]" }
  340.     result.gsub!(/\eFS/i) { "\eAMSF[4]" }
  341.     #---
  342.     result.gsub!(/\eAC\[([-+]?\d+)\]/i) { escape_actor_class_name($1.to_i) }
  343.     result.gsub!(/\eAS\[([-+]?\d+)\]/i) { escape_actor_subclass_name($1.to_i) }
  344.     result.gsub!(/\eAN\[([-+]?\d+)\]/i) { escape_actor_nickname($1.to_i) }
  345.     #---
  346.     result.gsub!(/\eNC\[(\d+)\]/i) { $data_classes[$1.to_i].name }
  347.     result.gsub!(/\eNI\[(\d+)\]/i) { $data_items[$1.to_i].name }
  348.     result.gsub!(/\eNW\[(\d+)\]/i) { $data_weapons[$1.to_i].name }
  349.     result.gsub!(/\eNA\[(\d+)\]/i) { $data_armors[$1.to_i].name }
  350.     result.gsub!(/\eNS\[(\d+)\]/i) { $data_skills[$1.to_i].name }
  351.     result.gsub!(/\eNT\[(\d+)\]/i) { $data_states[$1.to_i].name }
  352.     #---
  353.     result.gsub!(/\eIC\[(\d+)\]/i) { escape_icon_item($1.to_i, :class) }
  354.     result.gsub!(/\eII\[(\d+)\]/i) { escape_icon_item($1.to_i, :item) }
  355.     result.gsub!(/\eIW\[(\d+)\]/i) { escape_icon_item($1.to_i, :weapon) }
  356.     result.gsub!(/\eIA\[(\d+)\]/i) { escape_icon_item($1.to_i, :armour) }
  357.     result.gsub!(/\eIS\[(\d+)\]/i) { escape_icon_item($1.to_i, :skill) }
  358.     result.gsub!(/\eIT\[(\d+)\]/i) { escape_icon_item($1.to_i, :state) }
  359.     #---
  360.     return result
  361.   end
  362.   
  363.   #--------------------------------------------------------------------------
  364.   # new method: escape_actor_class_name
  365.   #--------------------------------------------------------------------------
  366.   def escape_actor_class_name(actor_id)
  367.     actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0
  368.     actor = $game_actors[actor_id]
  369.     return "" if actor.nil?
  370.     return actor.class.name
  371.   end
  372.   
  373.   #--------------------------------------------------------------------------
  374.   # new method: actor_subclass_name
  375.   #--------------------------------------------------------------------------
  376.   def escape_actor_subclass_name(actor_id)
  377.     return "" unless $imported["YEA-ClassSystem"]
  378.     actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0
  379.     actor = $game_actors[actor_id]
  380.     return "" if actor.nil?
  381.     return "" if actor.subclass.nil?
  382.     return actor.subclass.name
  383.   end
  384.   
  385.   #--------------------------------------------------------------------------
  386.   # new method: escape_actor_nickname
  387.   #--------------------------------------------------------------------------
  388.   def escape_actor_nickname(actor_id)
  389.     actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0
  390.     actor = $game_actors[actor_id]
  391.     return "" if actor.nil?
  392.     return actor.nickname
  393.   end
  394.   
  395.   #--------------------------------------------------------------------------
  396.   # new method: escape_icon_item
  397.   #--------------------------------------------------------------------------
  398.   def escape_icon_item(data_id, type)
  399.     case type
  400.     when :class
  401.       return "" unless $imported["YEA-ClassSystem"]
  402.       icon = $data_classes[data_id].icon_index
  403.       name = $data_items[data_id].name
  404.     when :item
  405.       icon = $data_items[data_id].icon_index
  406.       name = $data_items[data_id].name
  407.     when :weapon
  408.       icon = $data_weapons[data_id].icon_index
  409.       name = $data_weapons[data_id].name
  410.     when :armour
  411.       icon = $data_armors[data_id].icon_index
  412.       name = $data_armors[data_id].name
  413.     when :skill
  414.       icon = $data_skills[data_id].icon_index
  415.       name = $data_skills[data_id].name
  416.     when :state
  417.       icon = $data_states[data_id].icon_index
  418.       name = $data_states[data_id].name
  419.     else; return ""
  420.     end
  421.     text = "\eI[#{icon}]" + name
  422.     return text
  423.   end
  424.   
  425.   #--------------------------------------------------------------------------
  426.   # alias method: process_escape_character
  427.   #--------------------------------------------------------------------------
  428.   alias window_base_process_escape_character_ams process_escape_character
  429.   def process_escape_character(code, text, pos)
  430.     case code.upcase
  431.     #---
  432.     when 'FZ'
  433.       contents.font.size = obtain_escape_param(text)
  434.     when 'FN'
  435.       text.sub!(/\[(.*?)\]/, "")
  436.       font_name = $1.to_s
  437.       font_name = Font.default_name if font_name.nil?
  438.       contents.font.name = font_name.to_s
  439.     #---
  440.     when 'OC'
  441.       colour = text_color(obtain_escape_param(text))
  442.       contents.font.out_color = colour
  443.     when 'OO'
  444.       contents.font.out_color.alpha = obtain_escape_param(text)
  445.     #---
  446.     when 'AMSF'
  447.       case obtain_escape_param(text)
  448.       when 0; reset_font_settings
  449.       when 1; contents.font.bold = !contents.font.bold
  450.       when 2; contents.font.italic = !contents.font.italic
  451.       when 3; contents.font.outline = !contents.font.outline
  452.       when 4; contents.font.shadow = !contents.font.shadow
  453.       end
  454.     #---
  455.     when 'PX'
  456.       pos[:x] = obtain_escape_param(text)
  457.     when 'PY'
  458.       pos[:y] = obtain_escape_param(text)
  459.     #---
  460.     when 'PIC'
  461.       text.sub!(/\[(.*?)\]/, "")
  462.       bmp = Cache.picture($1.to_s)
  463.       rect = Rect.new(0, 0, bmp.width, bmp.height)
  464.       contents.blt(pos[:x], pos[:y], bmp, rect)
  465.     #---
  466.     else
  467.       window_base_process_escape_character_ams(code, text, pos)
  468.     end
  469.   end
  470.   
  471. end # Window_Base

  472. #==============================================================================
  473. # ■ Window_ChoiceList
  474. #==============================================================================

  475. class Window_ChoiceList < Window_Command
  476.   
  477.   #--------------------------------------------------------------------------
  478.   # alias method: initialize
  479.   #--------------------------------------------------------------------------
  480.   alias window_choicelist_initialize_ams initialize
  481.   def initialize(message_window)
  482.     window_choicelist_initialize_ams(message_window)
  483.     setup_message_font
  484.   end
  485.   
  486. end # Window_ChoiceList

  487. #==============================================================================
  488. # ■ Window_ScrollText
  489. #==============================================================================

  490. class Window_ScrollText < Window_Base
  491.   
  492.   #--------------------------------------------------------------------------
  493.   # alias method: initialize
  494.   #--------------------------------------------------------------------------
  495.   alias window_scrolltext_initialize_ams initialize
  496.   def initialize
  497.     window_scrolltext_initialize_ams
  498.     setup_message_font
  499.   end
  500.   
  501. end # Window_ScrollText

  502. #==============================================================================
  503. # ■ Window_NameMessage
  504. #==============================================================================

  505. class Window_NameMessage < Window_Base
  506.   
  507.   #--------------------------------------------------------------------------
  508.   # initialize
  509.   #--------------------------------------------------------------------------
  510.   def initialize(message_window)
  511.     @message_window = message_window
  512.     super(0, 0, Graphics.width, fitting_height(1))
  513.     self.opacity = YEA::MESSAGE::NAME_WINDOW_OPACITY
  514.     self.z = @message_window.z + 1
  515.     self.openness = 0
  516.     setup_message_font
  517.     @close_counter = 0
  518.     deactivate
  519.   end
  520.   
  521.   #--------------------------------------------------------------------------
  522.   # update
  523.   #--------------------------------------------------------------------------
  524.   def update
  525.     super
  526.     return if self.active
  527.     return if self.openness == 0
  528.     return if @closing
  529.     @close_counter -= 1
  530.     return if @close_counter > 0
  531.     close
  532.   end
  533.   
  534.   #--------------------------------------------------------------------------
  535.   # start_close
  536.   #--------------------------------------------------------------------------
  537.   def start_close
  538.     @close_counter = 4
  539.     deactivate
  540.   end
  541.   
  542.   #--------------------------------------------------------------------------
  543.   # force_close
  544.   #--------------------------------------------------------------------------
  545.   def force_close
  546.     @close_counter = 0
  547.     deactivate
  548.     close
  549.   end
  550.   
  551.   #--------------------------------------------------------------------------
  552.   # start
  553.   #--------------------------------------------------------------------------
  554.   def start(text, x_position)
  555.     @text = text.clone
  556.     set_width
  557.     create_contents
  558.     set_x_position(x_position)
  559.     set_y_position
  560.     refresh
  561.     activate
  562.     open
  563.   end
  564.   
  565.   #--------------------------------------------------------------------------
  566.   # set_width
  567.   #--------------------------------------------------------------------------
  568.   def set_width
  569.     text = @text.clone
  570.     dw = standard_padding * 2 + text_size(text).width
  571.     dw += YEA::MESSAGE::NAME_WINDOW_PADDING * 2
  572.     dw += calculate_size(text.slice!(0, 1), text) until text.empty?
  573.     self.width = dw
  574.   end
  575.   
  576.   #--------------------------------------------------------------------------
  577.   # calculate_size
  578.   #--------------------------------------------------------------------------
  579.   def calculate_size(code, text)
  580.     case code
  581.     when "\e"
  582.       return calculate_escape_code_width(obtain_escape_code(text), text)
  583.     else
  584.       return 0
  585.     end
  586.   end
  587.   
  588.   #--------------------------------------------------------------------------
  589.   # calculate_escape_code_width
  590.   #--------------------------------------------------------------------------
  591.   def calculate_escape_code_width(code, text)
  592.     dw = -text_size("\e").width - text_size(code).width
  593.     case code.upcase
  594.     when 'C', 'OC', 'OO'
  595.       dw += -text_size("[" + obtain_escape_param(text).to_s + "]").width
  596.       return dw
  597.     when 'I'
  598.       dw += -text_size("[" + obtain_escape_param(text).to_s + "]").width
  599.       dw += 24
  600.       return dw
  601.     when '{'
  602.       make_font_bigger
  603.     when '}'
  604.       make_font_smaller
  605.     when 'FZ'
  606.       contents.font.size = obtain_escape_param(text)
  607.     when 'FN'
  608.       text.sub!(/\[(.*?)\]/, "")
  609.       font_name = $1.to_s
  610.       font_name = Font.default_name if font_name.nil?
  611.       contents.font.name = font_name.to_s
  612.     when 'AMSF'
  613.       case obtain_escape_param(text)
  614.       when 0; reset_font_settings
  615.       when 1; contents.font.bold = !contents.font.bold
  616.       when 2; contents.font.italic = !contents.font.italic
  617.       when 3; contents.font.outline = !contents.font.outline
  618.       when 4; contents.font.shadow = !contents.font.shadow
  619.       end
  620.     else
  621.       return dw
  622.     end
  623.   end
  624.   
  625.   #--------------------------------------------------------------------------
  626.   # set_y_position
  627.   #--------------------------------------------------------------------------
  628.   def set_x_position(x_position)
  629.     case x_position
  630.     when 1 # Left
  631.       self.x = @message_window.x
  632.       self.x += YEA::MESSAGE::NAME_WINDOW_X_BUFFER
  633.     when 2 # 3/10
  634.       self.x = @message_window.x
  635.       self.x += @message_window.width * 3 / 10
  636.       self.x -= self.width / 2
  637.     when 3 # Center
  638.       self.x = @message_window.x
  639.       self.x += @message_window.width / 2
  640.       self.x -= self.width / 2
  641.     when 4 # 7/10
  642.       self.x = @message_window.x
  643.       self.x += @message_window.width * 7 / 10
  644.       self.x -= self.width / 2
  645.     when 5 # Right
  646.       self.x = @message_window.x + @message_window.width
  647.       self.x -= self.width
  648.       self.x -= YEA::MESSAGE::NAME_WINDOW_X_BUFFER
  649.     end
  650.     self.x = [[self.x, Graphics.width - self.width].min, 0].max
  651.   end
  652.   
  653.   #--------------------------------------------------------------------------
  654.   # set_y_position
  655.   #--------------------------------------------------------------------------
  656.   def set_y_position
  657.     case $game_message.position
  658.     when 0
  659.       self.y = @message_window.height
  660.       self.y -= YEA::MESSAGE::NAME_WINDOW_Y_BUFFER
  661.     else
  662.       self.y = @message_window.y - self.height
  663.       self.y += YEA::MESSAGE::NAME_WINDOW_Y_BUFFER
  664.     end
  665.   end
  666.   
  667.   #--------------------------------------------------------------------------
  668.   # refresh
  669.   #--------------------------------------------------------------------------
  670.   def refresh
  671.     contents.clear
  672.     reset_font_settings
  673.     @text = sprintf("\eC[%d]%s", YEA::MESSAGE::NAME_WINDOW_COLOUR, @text)
  674.     draw_text_ex(YEA::MESSAGE::NAME_WINDOW_PADDING, 0, @text)
  675.   end
  676.   
  677. end # Window_NameMessage

  678. #==============================================================================
  679. # ■ Window_Message
  680. #==============================================================================

  681. class Window_Message < Window_Base
  682.   
  683.   #--------------------------------------------------------------------------
  684.   # alias method: initialize
  685.   #--------------------------------------------------------------------------
  686.   alias window_message_initialize_ams initialize
  687.   def initialize
  688.     window_message_initialize_ams
  689.     setup_message_font
  690.   end
  691.   
  692.   #--------------------------------------------------------------------------
  693.   # overwrite method: window_width
  694.   #--------------------------------------------------------------------------
  695.   def window_width
  696.     return Variable.message_width
  697.   end
  698.   
  699.   #--------------------------------------------------------------------------
  700.   # overwrite method: window_height
  701.   #--------------------------------------------------------------------------
  702.   def window_height
  703.     return fitting_height(Variable.message_rows)
  704.   end
  705.   
  706.   #--------------------------------------------------------------------------
  707.   # alias method: create_all_windows
  708.   #--------------------------------------------------------------------------
  709.   alias window_message_create_all_windows_ams create_all_windows
  710.   def create_all_windows
  711.     window_message_create_all_windows_ams
  712.     @name_window = Window_NameMessage.new(self)
  713.   end
  714.   
  715.   #--------------------------------------------------------------------------
  716.   # overwrite method: create_back_bitmap
  717.   #--------------------------------------------------------------------------
  718.   def create_back_bitmap
  719.     @back_bitmap = Bitmap.new(width, height)
  720.     rect1 = Rect.new(0, 0, Graphics.width, 12)
  721.     rect2 = Rect.new(0, 12, Graphics.width, fitting_height(4) - 24)
  722.     rect3 = Rect.new(0, fitting_height(4) - 12, Graphics.width, 12)
  723.     @back_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true)
  724.     @back_bitmap.fill_rect(rect2, back_color1)
  725.     @back_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true)
  726.   end
  727.   
  728.   #--------------------------------------------------------------------------
  729.   # alias method: dispose_all_windows
  730.   #--------------------------------------------------------------------------
  731.   alias window_message_dispose_all_windows_ams dispose_all_windows
  732.   def dispose_all_windows
  733.     window_message_dispose_all_windows_ams
  734.     @name_window.dispose
  735.   end
  736.   
  737.   #--------------------------------------------------------------------------
  738.   # alias method: update_all_windows
  739.   #--------------------------------------------------------------------------
  740.   alias window_message_update_all_windows_ams update_all_windows
  741.   def update_all_windows
  742.     window_message_update_all_windows_ams
  743.     @name_window.update
  744.     @name_window.back_opacity = self.back_opacity
  745.     @name_window.opacity = self.opacity
  746.   end
  747.   
  748.   #--------------------------------------------------------------------------
  749.   # alias method: update_show_fast
  750.   #--------------------------------------------------------------------------
  751.   alias window_message_update_show_fast_ams update_show_fast
  752.   def update_show_fast
  753.     @show_fast = true if Input.press?(YEA::MESSAGE::TEXT_SKIP)
  754.     window_message_update_show_fast_ams
  755.   end
  756.   
  757.   #--------------------------------------------------------------------------
  758.   # overwrite method: input_pause
  759.   #--------------------------------------------------------------------------
  760.   def input_pause
  761.     self.pause = true
  762.     wait(10)
  763.     Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C) ||
  764.       Input.press?(YEA::MESSAGE::TEXT_SKIP)
  765.     Input.update
  766.     self.pause = false
  767.   end
  768.   
  769.   #--------------------------------------------------------------------------
  770.   # overwrite method: convert_escape_characters
  771.   #--------------------------------------------------------------------------
  772.   def convert_escape_characters(text)
  773.     result = super(text.to_s.clone)
  774.     result = namebox_escape_characters(result)
  775.     result = message_escape_characters(result)
  776.     return result
  777.   end
  778.   
  779.   #--------------------------------------------------------------------------
  780.   # new method: namebox_escape_characters
  781.   #--------------------------------------------------------------------------
  782.   def namebox_escape_characters(result)
  783.     result.gsub!(/\eN\<(.+?)\>/i)  { namewindow($1, 1) }
  784.     result.gsub!(/\eN1\<(.+?)\>/i) { namewindow($1, 1) }
  785.     result.gsub!(/\eN2\<(.+?)\>/i) { namewindow($1, 2) }
  786.     result.gsub!(/\eNC\<(.+?)\>/i) { namewindow($1, 3) }
  787.     result.gsub!(/\eN3\<(.+?)\>/i) { namewindow($1, 3) }
  788.     result.gsub!(/\eN4\<(.+?)\>/i) { namewindow($1, 4) }
  789.     result.gsub!(/\eN5\<(.+?)\>/i) { namewindow($1, 5) }
  790.     result.gsub!(/\eNR\<(.+?)\>/i) { namewindow($1, 5) }
  791.     return result
  792.   end
  793.   
  794.   #--------------------------------------------------------------------------
  795.   # new method: namebox
  796.   #--------------------------------------------------------------------------
  797.   def namewindow(text, position)
  798.     @name_text = text
  799.     @name_position = position
  800.     return ""
  801.   end
  802.   
  803.   #--------------------------------------------------------------------------
  804.   # new method: message_escape_characters
  805.   #--------------------------------------------------------------------------
  806.   def message_escape_characters(result)
  807.     result.gsub!(/\eAF\[(-?\d+)]/i) { change_face($1.to_i) }
  808.     return result
  809.   end
  810.   
  811.   #--------------------------------------------------------------------------
  812.   # new method: change_face
  813.   #--------------------------------------------------------------------------
  814.   def change_face(actor_id)
  815.     actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0
  816.     actor = $game_actors[actor_id]
  817.     return "" if actor.nil?
  818.     $game_message.face_name = actor.face_name
  819.     $game_message.face_index = actor.face_index
  820.     return ""
  821.   end
  822.   
  823.   #--------------------------------------------------------------------------
  824.   # alias method: new_page
  825.   #--------------------------------------------------------------------------
  826.   alias window_message_new_page_ams new_page
  827.   def new_page(text, pos)
  828.     adjust_message_window_size
  829.     window_message_new_page_ams(text, pos)
  830.   end
  831.   
  832.   #--------------------------------------------------------------------------
  833.   # overwrite method: new_line_x
  834.   #--------------------------------------------------------------------------
  835.   def new_line_x
  836.     return $game_message.face_name.empty? ? 0 : YEA::MESSAGE::FACE_INDENT_X
  837.   end
  838.   
  839.   #--------------------------------------------------------------------------
  840.   # new method: adjust_message_window_size
  841.   #--------------------------------------------------------------------------
  842.   def adjust_message_window_size
  843.     self.height = window_height
  844.     self.width = window_width
  845.     create_contents
  846.     update_placement
  847.     self.x = (Graphics.width - self.width) / 2
  848.     start_name_window
  849.   end
  850.   
  851.   #--------------------------------------------------------------------------
  852.   # new method: clear_name_window
  853.   #--------------------------------------------------------------------------
  854.   def clear_name_window
  855.     @name_text = ""
  856.     @name_position = 0
  857.   end
  858.   
  859.   #--------------------------------------------------------------------------
  860.   # new method: start_name_window
  861.   #--------------------------------------------------------------------------
  862.   def start_name_window
  863.     return if @name_text == ""
  864.     @name_window.start(@name_text, @name_position)
  865.   end
  866.   
  867.   #--------------------------------------------------------------------------
  868.   # overwrite method: fiber_main
  869.   #--------------------------------------------------------------------------
  870.   def fiber_main
  871.     $game_message.visible = true
  872.     update_background
  873.     update_placement
  874.     loop do
  875.       process_all_text if $game_message.has_text?
  876.       process_input
  877.       $game_message.clear
  878.       @gold_window.close
  879.       @name_window.start_close
  880.       Fiber.yield
  881.       break unless text_continue?
  882.     end
  883.     close_and_wait
  884.     $game_message.visible = false
  885.     @fiber = nil
  886.   end
  887.   
  888.   #--------------------------------------------------------------------------
  889.   # alias method: open_and_wait
  890.   #--------------------------------------------------------------------------
  891.   alias window_message_open_and_wait_ams open_and_wait
  892.   def open_and_wait
  893.     clear_name_window
  894.     adjust_message_window_size
  895.     window_message_open_and_wait_ams
  896.   end
  897.   
  898.   #--------------------------------------------------------------------------
  899.   # alias method: close_and_wait
  900.   #--------------------------------------------------------------------------
  901.   alias window_message_close_and_wait_ams close_and_wait
  902.   def close_and_wait
  903.     @name_window.force_close
  904.     window_message_close_and_wait_ams
  905.   end
  906.   
  907.   #--------------------------------------------------------------------------
  908.   # alias method: all_close?
  909.   #--------------------------------------------------------------------------
  910.   alias window_message_all_close_ams all_close?
  911.   def all_close?
  912.     return window_message_all_close_ams && @name_window.close?
  913.   end
  914.   
  915.   #--------------------------------------------------------------------------
  916.   # alias method: process_escape_character
  917.   #--------------------------------------------------------------------------
  918.   alias window_message_process_escape_character_ams process_escape_character
  919.   def process_escape_character(code, text, pos)
  920.     case code.upcase
  921.     when 'W' # Wait
  922.       wait(obtain_escape_param(text))
  923.     else
  924.       window_message_process_escape_character_ams(code, text, pos)
  925.     end
  926.   end
  927.   
  928. end # Window_Message

  929. #==============================================================================
  930. #
  931. # ▼ End of File
  932. #
  933. #==============================================================================
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册用户

本版积分规则

Archiver|QQ群: 48625831|爱上RPG|哈库纳玛塔塔 |网站地图 Clicky

GMT+8, 2024-11-21 15:08 , Processed in 0.090206 second(s), 18 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表