SHARE
TWEET

Yanfly Engine Ace - Ace Message System v1.05

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