Advertisement
Kyriaki

Yanfly Engine RD - Custom Message System

Apr 27th, 2011
1,374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 29.88 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Yanfly Engine RD - Custom Message System
  4. # Last Date Updated: 2009.06.14
  5. # Level: Easy, Lunatic
  6. #
  7. # This is by no means a complex message system like Modern Algebra's ATS or
  8. # Woratana's Neo Message System. If you want a message system with a lot of
  9. # features, I highly recommend that you take a look at those. This message
  10. # system here will supply the most basic functions and needs without adding
  11. # too many extra features.
  12. #
  13. # What this script has to offer is basic functionality for new tags, a namebox
  14. # window, and drawn items, weapons, and armours along with their icons. There
  15. # also exists a Lunatic Mode to create quick and easy custom shortcuts. For
  16. # the most part, this script is plug and play.
  17. #
  18. #===============================================================================
  19. # Updates:
  20. # ----------------------------------------------------------------------------
  21. # o 2009.06.14 - Started script and finished.
  22. #===============================================================================
  23. # Instructions
  24. #===============================================================================
  25. #
  26. # Scroll down and bind ROW_VARIABLE to the desired variable. This variable will
  27. # let you adjust how many rows can be viewed at once. If the rows are set to 0,
  28. # it will display the default row amount of 4 rows.
  29. #
  30. # The following are codes you may use when typing out your messages. Replace
  31. # x, y with numbers unless specified otherwise.
  32. #
  33. # Code:       Effect:
  34. # \v[x]       Writes variable x's value.
  35. # \n[x]       Writes actor x's name.
  36. # \c[x]       Changes the colour of the text to x.
  37. # \g          Displays the gold window.
  38. # \.          Waits 15 frames (quarter second).
  39. # \|          Waits 60 frames (a full second).
  40. # \!          Waits until key is pressed.
  41. # \>          Following text is instant.
  42. # \<          Following text is no longer instant.
  43. # \^          Skips to the next message.
  44. # \\          Writes a "\" in the window.
  45. #
  46. # \w[x]       Waits x frames (60 frames = 1 second).
  47. #
  48. # \nb[x]      Creates a name window with x. Left side.
  49. # \nbl[x]     Creates a name window with x. Locks the namebox. Left side.
  50. # \nbu[x]     Creates a name window with x. Unlocks the namebox. Left side.
  51. # \rnb[x]     Creates a name window with x. Right side.
  52. # \rnbl[x]    Creates a name window with x. Locks the namebox. Right side.
  53. # \rnbu[x]    Creates a name window with x. Unlocks the namebox. Right side.
  54. # \nbu        Closes name window. Unlocks the namebox.
  55. #
  56. # \fn[x]      Changes the font name to x. Set to 0 to reset font name.
  57. # \fs[x]      Changes the font size to x. Set to 0 to reset font size.
  58. # \fb         Changes the font to bold and back.
  59. # \fi         Changes the font to italic
  60. # \fh         Changes the font to shadowed and back.
  61. #
  62. # \ac[x]      Writes actor x's class name.
  63. # \as[x]      Writes actor x's subclass name. Requires Subclass System.
  64. # \ax[x]      Writes actor x's combination class name. Requires Subclass System.
  65. # \af[x]      Replaces face with actor x's face.
  66. # \af[x:y]    Replaces face with actor x's face name but uses expression y.
  67. #
  68. # \pn[x]      Writes ally's name in party slot x.
  69. # \pc[x]      Writes ally's class name in party slot x.
  70. # \ps[x]      Writes ally's subclass name in party slot x.
  71. # \px[x]      Writes ally's combination class name in party slot x.
  72. # \pf[x]      Replaces face with ally's face in party slot x.
  73. # \pf[x:y]    Replaces face with ally's face name but uses expression y.
  74. #
  75. # \nc[x]      Writes class ID x's name.
  76. # \ni[x]      Writes item ID x's name.
  77. # \nw[x]      Writes weapon ID x's name.
  78. # \na[x]      Writes armour ID x's name.
  79. # \ns[x]      Writes skill ID x's name.
  80. # \nt[x]      Writes state ID x's name.
  81. #
  82. # \i[x]       Draws icon ID x into the message window.
  83. # \ii[x]      Writes item ID x's name with icon included.
  84. # \iw[x]      Writes weapon ID x's name with icon included.
  85. # \ia[x]      Writes armour ID x's name with icon included.
  86. # \is[x]      Writes skill ID x's name with icon included.
  87. # \it[x]      Writes state ID x's name with icon included.
  88. #
  89. #===============================================================================
  90. #
  91. # Compatibility
  92. # - Incompatible: Any other message systems obviously.
  93. # - Alias: Window_Message: initialize, update, dispose, new_page
  94. # - Overwrites: Game_Interpreter: command_101, setup_choices
  95. # - Overwrites: Window_Message: convert_special_characters, update_message
  96. #
  97. #===============================================================================
  98. # Credits:
  99. # Woratana for reference on stringing multiple message text.
  100. # Modern Algebra for reference on a few misc methods.
  101. #===============================================================================
  102.  
  103. $imported = {} if $imported == nil
  104. $imported["CustomMessageSystem"] = true
  105.  
  106. module YE
  107.   module MESSAGE
  108.    
  109.     # This adjusts how many rows are shown. On screen. If it's 0 or under, a
  110.     # maximum of 4 rows will be shown. If it's above, it will show that many
  111.     # rows and texts following it immediately after will also display that many
  112.     # extra rows.
  113.     ROW_VARIABLE = 1
  114.    
  115.     # This adjusts the icon width. Used mostly for monospaced fonts so that
  116.     # icons will not break the alignment.
  117.     ICON_WIDTH = 24
  118.    
  119.     # This determines where you would like the namebox window to appear relative
  120.     # to the message window. Adjust the following accordingly.
  121.     NAME_WINDOW_X = 0        # Adjusts X position offset from Message Window.
  122.     NAME_WINDOW_Y = 40       # Adjusts Y position offset from Message Window.
  123.     NAME_WINDOW_W = 20       # Adjusts extra width added to the Name Window.
  124.     NAME_WINDOW_H = 40       # Adjusts the height of the Name Window.
  125.     NAME_COLOUR   = 0        # Default colour used for name box.
  126.    
  127.     # The following lets you adjust whether or not you would like to see the
  128.     # back of the name window.
  129.     NAME_WINDOW_SHOW_BACK = true
  130.    
  131.     # The following allows you to adjust the font defaults for ALL text in the
  132.     # game. This includes the text outside of the message window and includes
  133.     # the text within the menu windows.
  134.     FONT_NAME = ["Verdana", "Arial", "Courier New"]
  135.     FONT_SIZE = 20
  136.     FONT_BOLD = false
  137.     FONT_ITALIC = false
  138.     FONT_SHADOW = true
  139.    
  140.    
  141.   end # MESSAGE
  142. end # YE
  143.  
  144. #===============================================================================
  145. # How to Use: Lunatic Mode
  146. #===============================================================================
  147. #
  148. # This portion is for those who know how to script.
  149. #
  150. # \X[x] or \X[x:y] or \X[x:y:z]
  151. # These let you create your own custom tags. If you use the first tag, there is
  152. # one case for the "custom_convert" definition to return. If you use the second
  153. # tag, there will be two cases for you to select from. And likewise, if there's
  154. # three tags, then the z case will also be taken into account of.
  155. #
  156. #===============================================================================
  157.  
  158. class Window_Message < Window_Selectable
  159.  
  160.   def custom_convert(x_case, y_case = 0, z_case = 0)
  161.     text = ""
  162.     case x_case
  163.     #---------------------------------------------------------------------------
  164.     # //////////////////////////////////////////////////////////////////////////
  165.     # This is where you begin adding in your own custom converted tags.
  166.     #---------------------------------------------------------------------------
  167.     when 1 # Show the full name of the actor.
  168.       case y_case # This is the extra case for the actor.
  169.       when 1
  170.         text = "\\n[1] von Xiguel"
  171.       when 2
  172.         text = "Michelle \\n[2]"
  173.       when 3
  174.         text = "\\n[3] Manfred"
  175.       when 4
  176.         text = "\\n[4] Fernaeus"
  177.       end
  178.      
  179.     when 2 # Show how much gold the party has.
  180.       text = $game_party.gold
  181.      
  182.     when 3 # Show party's max level
  183.       text = $game_party.max_level
  184.      
  185.     #---------------------------------------------------------------------------
  186.     # This is the part you guys shouldn't touch afterwards.
  187.     # //////////////////////////////////////////////////////////////////////////
  188.     #---------------------------------------------------------------------------""
  189.     end
  190.     return text
  191.   end
  192.  
  193. end # Window_Message
  194.  
  195. #===============================================================================
  196. # Editting anything past this point may potentially result in causing computer
  197. # damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
  198. # Therefore, edit at your own risk.
  199. #===============================================================================
  200.  
  201. Font.default_size = YE::MESSAGE::FONT_SIZE
  202. Font.default_name = YE::MESSAGE::FONT_NAME
  203. Font.default_bold = YE::MESSAGE::FONT_BOLD
  204. Font.default_italic = YE::MESSAGE::FONT_ITALIC
  205. Font.default_shadow = YE::MESSAGE::FONT_SHADOW
  206.  
  207. #===============================================================================
  208. # Window_Message
  209. #===============================================================================
  210.  
  211. class Window_Message < Window_Selectable
  212.  
  213.   #--------------------------------------------------------------------------
  214.   # alias initialize
  215.   #--------------------------------------------------------------------------
  216.   alias initialize_cms initialize unless $@
  217.   def initialize
  218.     initialize_cms
  219.     var = $game_variables[YE::MESSAGE::ROW_VARIABLE]
  220.     @max_rows = (var <= 0) ? 4 : var
  221.     nheight = YE::MESSAGE::NAME_WINDOW_H
  222.     @name_window = Window_Base.new(YE::MESSAGE::NAME_WINDOW_X, 0, 100, nheight)
  223.     @name_text = Window_Base.new(YE::MESSAGE::NAME_WINDOW_X, 0, 100, 56)
  224.     @name_window.openness = 0
  225.     @name_text.openness = 0
  226.     @name_text.opacity = 0
  227.     @name_window.z = self.z + 1
  228.     @name_text.z = @name_window.z + 1
  229.     @name_window_lock = false
  230.   end
  231.  
  232.   #--------------------------------------------------------------------------
  233.   # alias dispose
  234.   #--------------------------------------------------------------------------
  235.   alias dispose_cms dispose unless $@
  236.   def dispose
  237.     dispose_cms
  238.     @name_window.dispose if @name_window != nil
  239.     @name_text.dispose if @name_text != nil
  240.   end
  241.  
  242.   #--------------------------------------------------------------------------
  243.   # close
  244.   #--------------------------------------------------------------------------
  245.   def close
  246.     super
  247.     @name_window.close
  248.     @name_text.close
  249.     @name_window_lock = false
  250.   end
  251.  
  252.   #--------------------------------------------------------------------------
  253.   # alias update
  254.   #--------------------------------------------------------------------------
  255.   alias update_cms update unless $@
  256.   def update
  257.     @name_window.update
  258.     @name_text.update
  259.     refresh_size
  260.     update_cms
  261.   end
  262.  
  263.   #--------------------------------------------------------------------------
  264.   # refresh_size
  265.   #--------------------------------------------------------------------------
  266.   def refresh_size
  267.     var = $game_variables[YE::MESSAGE::ROW_VARIABLE]
  268.     @max_rows = (var <= 0) ? 4 : var
  269.     calc_height = @max_rows * 24 + 32
  270.     if self.height != calc_height
  271.       self.height = calc_height
  272.       create_contents
  273.     end
  274.   end
  275.  
  276.   #--------------------------------------------------------------------------
  277.   # overwrite reset_window
  278.   #--------------------------------------------------------------------------
  279.   def reset_window
  280.     var = $game_variables[YE::MESSAGE::ROW_VARIABLE]
  281.     wheight = var <= 0 ? 4 * 24 + 32 : var * 24 + 32
  282.     @background = $game_message.background
  283.     @position = $game_message.position
  284.     self.opacity = (@background == 0) ? 255 : 0
  285.     case @position
  286.     when 0  # Top
  287.       self.y = 0
  288.       @gold_window.y = 360
  289.     when 1  # Middle
  290.       self.y = (Graphics.height - wheight) / 2
  291.       @gold_window.y = 0
  292.     when 2  # Bottom
  293.       self.y = (Graphics.height - wheight)
  294.       @gold_window.y = 0
  295.     end
  296.   end
  297.  
  298.   #--------------------------------------------------------------------------
  299.   # overwrite convert_special_characters
  300.   #--------------------------------------------------------------------------
  301.   def convert_special_characters
  302.     @name_window_open = false
  303.     #-------------------------------------------------------------
  304.     # Lunatic REGEXP Conversions
  305.     #-------------------------------------------------------------
  306.     @text.gsub!(/\\X\[(\d+)\]/i) {
  307.       custom_convert($1.to_i) }
  308.     @text.gsub!(/\\X\[(\d+):(\d+)\]/i) {
  309.       custom_convert($1.to_i, $2.to_i) }
  310.     @text.gsub!(/\\X\[(\d+):(\d+):(\d+)\]/i) {
  311.       custom_convert($1.to_i, $2.to_i, $3.to_i) }
  312.    
  313.     #-------------------------------------------------------------
  314.     # Default REGEXP Conversions
  315.     #-------------------------------------------------------------
  316.     @text.gsub!(/\\V\[(\d+)\]/i)    { $game_variables[$1.to_i] }
  317.     @text.gsub!(/\\V\[(\d+)\]/i)    { $game_variables[$1.to_i] }
  318.     @text.gsub!(/\\N\[(\d+)\]/i)    { $game_actors[$1.to_i].name }
  319.     @text.gsub!(/\\C\[(\d+)\]/i)    { "\x01{#{$1}}" }
  320.     @text.gsub!(/\\G/i)             { "\x02" }
  321.     @text.gsub!(/\\\./)             { "\x03" }
  322.     @text.gsub!(/\\\|/)             { "\x04" }
  323.     @text.gsub!(/\\!/)              { "\x05" }
  324.     @text.gsub!(/\\>/)              { "\x06" }
  325.     @text.gsub!(/\\</)              { "\x07" }
  326.     @text.gsub!(/\\\^/)             { "\x08" }
  327.     @text.gsub!(/\\\\/)             { "\\" }
  328.    
  329.     #-------------------------------------------------------------
  330.     # New REGEXP Conversions
  331.     #-------------------------------------------------------------
  332.     @text.gsub!(/\\W\[(\d+)\]/i)    { "\x09{#{$1}}" }
  333.     @text.gsub!(/\\I\[(\d+)\]/i)    { "\x10{#{$1}}" }
  334.     @text.gsub!(/\\FS\[(\d+)\]/i)   { "\x11{#{$1}}" }
  335.     @text.gsub!(/\\FN\[(.*?)\]/i)   { "\x12{#{$1}}" }
  336.     @text.gsub!(/\\FB/i)            { "\x13" }
  337.     @text.gsub!(/\\FI/i)            { "\x14" }
  338.     @text.gsub!(/\\FH/i)            { "\x15" }
  339.    
  340.     #-------------------------------------------------------------
  341.     # Automatic Actor REGEXP Conversions
  342.     #-------------------------------------------------------------
  343.     @text.gsub!(/\\AN\[(\d+)\]/i) {
  344.       if $game_actors[$1.to_i] != nil
  345.         $game_actors[$1.to_i].name
  346.       else
  347.         ""
  348.       end }
  349.     @text.gsub!(/\\AC\[(\d+)\]/i) {
  350.       if $game_actors[$1.to_i] != nil
  351.         $game_actors[$1.to_i].class.name
  352.       else
  353.         ""
  354.       end }
  355.     @text.gsub!(/\\AS\[(\d+)\]/i) {
  356.       if $imported["SubclassSelectionSystem"] and
  357.       $game_actors[$1.to_i] != nil and
  358.       $game_actors[$1.to_i].subclass != nil
  359.         $game_actors[$1.to_i].subclass.name
  360.       else
  361.         ""
  362.       end }
  363.     @text.gsub!(/\\AX\[(\d+)\]/i) {
  364.       combination_class($game_actors[$1.to_i]) }
  365.     @text.gsub!(/\\AF\[(\d+)\]/i) {
  366.       if $game_actors[$1.to_i] != nil
  367.         $game_message.face_name = $game_actors[$1.to_i].face_name
  368.         $game_message.face_index = $game_actors[$1.to_i].face_index
  369.       end
  370.       "" }
  371.     @text.gsub!(/\\AF\[(\d+):(\d+)\]/i) {
  372.       if $game_actors[$1.to_i] != nil
  373.         $game_message.face_name = $game_actors[$1.to_i].face_name
  374.         $game_message.face_index = $2.to_i
  375.       end
  376.       "" }
  377.    
  378.     #-------------------------------------------------------------
  379.     # Automatic Party REGEXP Conversions
  380.     #-------------------------------------------------------------
  381.     @text.gsub!(/\\PN\[(\d+)\]/i) {
  382.       if $game_party.members[$1.to_i] != nil
  383.         $game_party.members[$1.to_i].name
  384.       else
  385.         ""
  386.       end }
  387.     @text.gsub!(/\\PC\[(\d+)\]/i) {
  388.       if $game_party.members[$1.to_i] != nil
  389.         $game_party.members[$1.to_i].class.name
  390.       else
  391.         ""
  392.       end }
  393.     @text.gsub!(/\\PS\[(\d+)\]/i) {
  394.       if $imported["SubclassSelectionSystem"] and
  395.       $game_party.members[$1.to_i] != nil and
  396.       $game_party.members[$1.to_i].subclass != nil
  397.         $game_party.members[$1.to_i].subclass.name
  398.       else
  399.         ""
  400.       end }
  401.     @text.gsub!(/\\PX\[(\d+)\]/i) {
  402.       combination_class($game_party.members[$1.to_i]) }
  403.     @text.gsub!(/\\PF\[(\d+)\]/i) {
  404.       if $game_party.members[$1.to_i] != nil
  405.         $game_message.face_name = $game_party.members[$1.to_i].face_name
  406.         $game_message.face_index = $game_party.members[$1.to_i].face_index
  407.       end
  408.       "" }
  409.     @text.gsub!(/\\PF\[(\d+):(\d+)\]/i) {
  410.       if $game_party.members[$1.to_i] != nil
  411.         $game_message.face_name = $game_party.members[$1.to_i].face_name
  412.         $game_message.face_index = $2.to_i
  413.       end
  414.       "" }
  415.    
  416.     #-------------------------------------------------------------
  417.     # Auto Class, Item, Weapon, and Armour REGEXP Conversions
  418.     #-------------------------------------------------------------
  419.     @text.gsub!(/\\NC\[(\d+)\]/i) {
  420.       $data_classes[$1.to_i].name }
  421.     @text.gsub!(/\\NI\[(\d+)\]/i) {
  422.       $data_items[$1.to_i].name }
  423.     @text.gsub!(/\\NW\[(\d+)\]/i) {
  424.       $data_weapons[$1.to_i].name }
  425.     @text.gsub!(/\\NA\[(\d+)\]/i) {
  426.       $data_armors[$1.to_i].name }
  427.     @text.gsub!(/\\NS\[(\d+)\]/i) {
  428.       $data_skills[$1.to_i].name }
  429.     @text.gsub!(/\\NT\[(\d+)\]/i) {
  430.       $data_states[$1.to_i].name }
  431.     @text.gsub!(/\\II\[(\d+)\]/i) {
  432.       "\x10{#{$data_items[$1.to_i].icon_index}}" +
  433.       "#{$data_items[$1.to_i].name}"}
  434.     @text.gsub!(/\\IW\[(\d+)\]/i) {
  435.       "\x10{#{$data_weapons[$1.to_i].icon_index}}" +
  436.       "#{$data_weapons[$1.to_i].name}"}
  437.     @text.gsub!(/\\IA\[(\d+)\]/i) {
  438.       "\x10{#{$data_armors[$1.to_i].icon_index}}" +
  439.       "#{$data_armors[$1.to_i].name}"}
  440.     @text.gsub!(/\\IS\[(\d+)\]/i) {
  441.       "\x10{#{$data_skills[$1.to_i].icon_index}}" +
  442.       "#{$data_skills[$1.to_i].name}"}
  443.     @text.gsub!(/\\IT\[(\d+)\]/i) {
  444.       "\x10{#{$data_states[$1.to_i].icon_index}}" +
  445.       "#{$data_states[$1.to_i].name}"}
  446.      
  447.     #-------------------------------------------------------------
  448.     # Name box REGEXP Conversions
  449.     #-------------------------------------------------------------
  450.     @text.gsub!(/\\NB\[(.*?)\]/i) {
  451.       if $1.to_s != nil
  452.         refresh_name_box($1.to_s)
  453.       end
  454.       "" }
  455.     @text.gsub!(/\\NBL\[(.*?)\]/i) {
  456.       if $1.to_s != nil
  457.         refresh_name_box($1.to_s)
  458.         @name_window_lock = true
  459.       end
  460.       "" }
  461.     @text.gsub!(/\\NBU\[(.*?)\]/i) {
  462.       if $1.to_s != nil
  463.         refresh_name_box($1.to_s)
  464.         @name_window_lock = false
  465.       end
  466.       "" }
  467.     @text.gsub!(/\\NBU/i) {
  468.       @name_window.close
  469.       @name_text.close
  470.       @name_window_lock = false
  471.       "" }
  472.     @text.gsub!(/\\RNB\[(.*?)\]/i) {
  473.       if $1.to_s != nil
  474.         refresh_name_box($1.to_s, 1)
  475.       end
  476.       "" }
  477.     @text.gsub!(/\\RNBL\[(.*?)\]/i) {
  478.       if $1.to_s != nil
  479.         refresh_name_box($1.to_s, 1)
  480.         @name_window_lock = true
  481.       end
  482.       "" }
  483.     @text.gsub!(/\\RNBU\[(.*?)\]/i) {
  484.       if $1.to_s != nil
  485.         refresh_name_box($1.to_s, 1)
  486.         @name_window_lock = false
  487.       end
  488.       "" }
  489.      
  490.     # Close the Name Window
  491.     unless @name_window_lock
  492.       @name_window.close if !@name_window_open
  493.       @name_text.close if !@name_window_open
  494.     end
  495.   end
  496.  
  497.   #--------------------------------------------------------------------------
  498.   # overwrite update_message
  499.   #--------------------------------------------------------------------------
  500.   def update_message
  501.     loop do
  502.       text_height = [contents.font.size + (contents.font.size / 5), WLH].max
  503.       c = @text.slice!(/./m)            # Get next text character
  504.       case c
  505.       #----------------------------------------------------------------------
  506.       # Default Cases
  507.       #----------------------------------------------------------------------
  508.       when nil    # There is no text that must be drawn
  509.         finish_message                  # Finish update
  510.         break
  511.       when "\x00" # New line
  512.         new_line
  513.         if @line_count >= @max_rows     # If line count is maximum
  514.           unless @text.empty?           # If there is more
  515.             self.pause = true           # Insert number input
  516.             break
  517.           end
  518.         end
  519.       when "\x01" # \C[n]  (text character color change)
  520.         @text.sub!(/\{(\d+)\}/, "")
  521.         contents.font.color = text_color($1.to_i)
  522.         next
  523.       when "\x02" # \G  (gold display)
  524.         @gold_window.refresh
  525.         @gold_window.open
  526.       when "\x03" # \.  (wait 1/4 second)
  527.         @wait_count = 15
  528.         break
  529.       when "\x04" # \|  (wait 1 second)
  530.         @wait_count = 60
  531.         break
  532.       when "\x05" # \!  (Wait for input)
  533.         self.pause = true
  534.         break
  535.       when "\x06" # \>  (Fast display ON)
  536.         @line_show_fast = true
  537.       when "\x07" # \<  (Fast display OFF)
  538.         @line_show_fast = false
  539.       when "\x08" # \^  (No wait for input)
  540.         @pause_skip = true
  541.        
  542.       #----------------------------------------------------------------------
  543.       # New Cases
  544.       #----------------------------------------------------------------------
  545.       when "\x09" # \|  Wait x frames
  546.         @text.sub!(/\{(\d+)\}/, "")
  547.         @wait_count = $1.to_i
  548.         break
  549.       when "\x10" # \i  Draws icon ID x
  550.         @text.sub!(/\{(\d+)\}/, "")
  551.         icon = $1.to_i
  552.         icon_width = (24 - YE::MESSAGE::ICON_WIDTH) / 2
  553.         draw_icon(icon, @contents_x - icon_width, @contents_y)
  554.         @contents_x += YE::MESSAGE::ICON_WIDTH
  555.       when "\x11" # \fs Font Size Change
  556.         @text.sub!(/\{(\d+)\}/, "")
  557.         size = $1.to_i
  558.         if size <= 0 # If 0, revert back to the default font size.
  559.           size = Font.default_size
  560.         end
  561.         contents.font.size = size
  562.         text_height = [size + (size / 5), WLH].max
  563.       when "\x12" # \fs Font Name Change
  564.         @text.sub!(/\{(.*?)\}/, "")
  565.         name = $1.to_s
  566.         if name == "0" # If 0, revert back to the default font.
  567.           name = Font.default_name
  568.         end
  569.         contents.font.name = name
  570.       when "\x13" # \fb Font bold
  571.         contents.font.bold = contents.font.bold ? false : true
  572.       when "\x14" # \fi Font italic
  573.         contents.font.italic = contents.font.italic ? false : true
  574.       when "\x15" # \fi Font shadowed
  575.         contents.font.shadow = contents.font.shadow ? false : true
  576.        
  577.       #----------------------------------------------------------------------
  578.       # Finish Up
  579.       #----------------------------------------------------------------------
  580.       else                              # Normal text character
  581.         contents.draw_text(@contents_x, @contents_y, 40, text_height, c)
  582.         c_width = contents.text_size(c).width
  583.         @contents_x += c_width
  584.       end
  585.       break unless @show_fast or @line_show_fast
  586.     end
  587.   end
  588.  
  589.   #--------------------------------------------------------------------------
  590.   # alias new_page
  591.   #--------------------------------------------------------------------------
  592.   alias new_page_cms new_page unless $@
  593.   def new_page
  594.     new_page_cms
  595.     contents.font.name = Font.default_name
  596.     contents.font.size = Font.default_size
  597.     contents.font.bold = Font.default_bold
  598.     contents.font.italic = Font.default_italic
  599.     contents.font.shadow = Font.default_shadow
  600.   end
  601.  
  602.   #--------------------------------------------------------------------------
  603.   # combination_class
  604.   #--------------------------------------------------------------------------
  605.   def combination_class(actor)
  606.     return "" if actor == nil
  607.     class1 = actor.class.name
  608.     return class1 unless $imported["SubclassSelectionSystem"]
  609.     return class1 if actor.subclass == nil
  610.     class2 = actor.subclass.name
  611.     text = sprintf(YE::SUBCLASS::DISPLAY_FORMAT, class1, class2)
  612.     return text unless YE::SUBCLASS::USE_COMPLEX_CLASS_NAMES
  613.     if YE::SUBCLASS::COMPLEX_CLASS_NAMES_FULL.include?(text)
  614.       text = YE::SUBCLASS::COMPLEX_CLASS_NAMES_FULL[text]
  615.     end
  616.     return text
  617.   end
  618.  
  619.   #--------------------------------------------------------------------------
  620.   # refresh_name_box
  621.   #--------------------------------------------------------------------------
  622.   def refresh_name_box(name, side = 0)
  623.     return if $game_temp.in_battle
  624.     font_colour = YE::MESSAGE::NAME_COLOUR
  625.     font_name = Font.default_name
  626.     font_size = Font.default_size
  627.     font_bold = Font.default_bold
  628.     font_italic = Font.default_italic
  629.     font_shadow = Font.default_shadow
  630.     icon = 0
  631.     name_width = 0
  632.     #---Convert Special Characters
  633.     name = name.gsub(/\x01\{(\d+)\}/i) {
  634.       font_colour = $1.to_i
  635.       ""}
  636.     name = name.gsub(/\x09\{(\d+)\}/i) {""}
  637.     name = name.gsub(/\x10\{(\d+)\}/i) {
  638.       icon = $1.to_i
  639.       name_width += YE::MESSAGE::ICON_WIDTH
  640.       ""}
  641.     name = name.gsub(/\x11\{(\d+)\}/i) {
  642.       font_size = $1.to_i
  643.       ""}
  644.     name = name.gsub(/\x12\{(.*?)\}/i) {
  645.       font_name = $1.to_s
  646.       ""}
  647.     name = name.gsub(/\x13/i) {
  648.       font_bold = true
  649.       ""}
  650.     name = name.gsub(/\x14/i) {
  651.       font_italic = true
  652.       ""}
  653.     name = name.gsub(/\x15/i) {
  654.       font_shadow = true
  655.       ""}
  656.     #---Convert Special Characters
  657.     @name_text.contents.font.name = font_name
  658.     @name_text.contents.font.size = font_size
  659.     @name_text.contents.font.bold = font_bold
  660.     @name_text.contents.font.italic = font_italic
  661.     @name_text.contents.font.shadow = font_shadow
  662.     name_width += @name_text.contents.text_size(name).width
  663.     name_width += YE::MESSAGE::NAME_WINDOW_W
  664.     @name_window.width = name_width + 40
  665.     @name_text.width = @name_window.width
  666.     var = $game_variables[YE::MESSAGE::ROW_VARIABLE]
  667.     wheight = var <= 0 ? 4 * 24 + 32 : var * 24 + 32
  668.     position = $game_message.position
  669.     case position
  670.     when 0
  671.       @name_window.y = self.height - YE::MESSAGE::NAME_WINDOW_H
  672.       @name_window.y += YE::MESSAGE::NAME_WINDOW_Y
  673.     when 1
  674.       @name_window.y = (Graphics.height - wheight) / 2
  675.       @name_window.y -= YE::MESSAGE::NAME_WINDOW_Y
  676.     when 2
  677.       @name_window.y = (Graphics.height - wheight)
  678.       @name_window.y -= YE::MESSAGE::NAME_WINDOW_Y
  679.     end
  680.     offset = (@name_text.height - @name_window.height) / 2
  681.     @name_text.y = @name_window.y - offset
  682.     if YE::MESSAGE::NAME_WINDOW_SHOW_BACK and $game_message.background == 0
  683.       @name_window.opacity = 255
  684.     else
  685.       @name_window.opacity = 0
  686.     end
  687.     if side == 0
  688.       @name_window.x = YE::MESSAGE::NAME_WINDOW_X
  689.     else
  690.       @name_window.x = Graphics.width - YE::MESSAGE::NAME_WINDOW_X
  691.       @name_window.x -= @name_window.width
  692.     end
  693.     @name_text.x = @name_window.x
  694.     @name_window.create_contents
  695.     @name_text.create_contents
  696.     txh = [font_size + (font_size / 5), WLH].max
  697.     @name_text.contents.font.color = text_color(font_colour)
  698.     @name_text.contents.font.name = font_name
  699.     @name_text.contents.font.size = font_size
  700.     @name_text.contents.font.bold = font_bold
  701.     @name_text.contents.font.italic = font_italic
  702.     @name_text.contents.font.shadow = font_shadow
  703.     if icon > 0
  704.       iw = YE::MESSAGE::ICON_WIDTH
  705.       @name_text.draw_icon(icon, YE::MESSAGE::NAME_WINDOW_W / 2, 0)
  706.       @name_text.contents.draw_text(iw, 0, name_width + 8 - iw, txh, name, 1)
  707.     else
  708.       @name_text.contents.draw_text(0, 0, name_width + 8, txh, name, 1)
  709.     end
  710.     @name_window.open
  711.     @name_text.open
  712.     @name_window_open = true
  713.   end
  714.  
  715. end # Window_Message
  716.  
  717. #===============================================================================
  718. # Game_Interpreter
  719. #===============================================================================
  720.  
  721. class Game_Interpreter
  722.  
  723.   #--------------------------------------------------------------------------
  724.   # overwrite Show Text
  725.   #--------------------------------------------------------------------------
  726.   def command_101
  727.     unless $game_message.busy
  728.       $game_message.face_name = @params[0]
  729.       $game_message.face_index = @params[1]
  730.       $game_message.background = @params[2]
  731.       $game_message.position = @params[3]
  732.       flow = true
  733.       loop {
  734.         if @list[@index].code == 101 and meet_stringing_conditions and flow
  735.           @index += 1
  736.         else
  737.           break
  738.         end
  739.         flow = @row_check
  740.         while @list[@index].code == 401 and meet_stringing_conditions
  741.           $game_message.texts.push(@list[@index].parameters[0])
  742.           @index += 1
  743.         end }
  744.       if @list[@index].code == 102 # Show choices
  745.         setup_choices(@list[@index].parameters)
  746.       elsif @list[@index].code == 103 # Number input processing
  747.         setup_num_input(@list[@index].parameters)
  748.       end
  749.       set_message_waiting # Set to message wait state
  750.     end
  751.     return false
  752.   end
  753.  
  754.   #--------------------------------------------------------------------------
  755.   # overwrite setup_choices
  756.   #--------------------------------------------------------------------------
  757.   def setup_choices(params)
  758.     var = $game_variables[YE::MESSAGE::ROW_VARIABLE]
  759.     rows = (var <= 0) ? 4 : var
  760.     if $game_message.texts.size <= rows - params[0].size
  761.       $game_message.choice_start = $game_message.texts.size
  762.       $game_message.choice_max = params[0].size
  763.       for s in params[0]
  764.         $game_message.texts.push(s)
  765.       end
  766.       $game_message.choice_cancel_type = params[1]
  767.       $game_message.choice_proc = Proc.new { |n| @branch[@indent] = n }
  768.       @index += 1
  769.     end
  770.   end
  771.  
  772.   #--------------------------------------------------------------------------
  773.   # meet_stringing_conditions
  774.   #--------------------------------------------------------------------------
  775.   def meet_stringing_conditions
  776.     var = $game_variables[YE::MESSAGE::ROW_VARIABLE]
  777.     rows = (var <= 0) ? 4 : var
  778.     @row_check = (rows > 4) ? true : false
  779.     return true if rows > $game_message.texts.size
  780.     return false
  781.   end
  782.  
  783. end # Game_Interpreter
  784.  
  785. #===============================================================================
  786. #
  787. # END OF FILE
  788. #
  789. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement