Icons in the message box and letter by letter

Okay, so what I'm wanting now, is the ability to add icons into the message box, I know Dubealex has his UMS which does this, along with something else I'd like, which is a letter by letter function.

Here's his script for reference:
  1.  
  2. #===================================================
  3. #  ¦ AMS - Advanced Message Script - R4 [Update #2]
  4. #===================================================
  5. # For more infos and update, visit:
  6. # http://www.creationasylum.net (Creation Asylum)
  7. #
  8. # Edited, Fixed and Enhanced by: Dubealex
  9. # Original Script Core by: XRXS Scripter (Jap Dudes)
  10. # HTML Hexadecimal color feature from: Phylomorphis
  11. #
  12. # Special Thanks:
  13. # Rabu: For enabling the Show Face feature in an encrypted project
  14. # LegacyX: For adding Extra Features
  15. #
  16. # To found all my new features, search the following:   #NEW
  17. # To configure the button to skip the dialog, search:   #SKIP_TEXT_CODE
  18. #
  19. #    Edited by FF12_master :To find Edits Search for ++Edit
  20. #   -Edits-
  21. #
  22. #   -Shortened face and name box short cut-
  23. #  
  24. #   \f[i] face shortcut, were i is the file name
  25. #   \n[i] name box, were i is the decided name.
  26. #
  27. #   \oa[i]         - display the icon and name of armor i
  28. #   \oi[i]         - display the icon and name of item i
  29. #   \os[i]         - display the icon and name of skill i
  30. #   \ow[i]         - display the icon and name of weapon i
  31. #
  32. # For any extra features to be added for Personalised Games Please PM LegacyX
  33. #
  34. # 24th Febuary 2009
  35. #===================================================
  36.  
  37. LETTER_BY_LETTER_MODE = true    #Set the letter by letter mode ON/OFF
  38.  
  39. #===================================================
  40. # ? CLASS AMS Begins
  41. #===================================================
  42. class AMS
  43.  
  44. attr_accessor :name_box_x_offset
  45. attr_accessor :name_box_y_offset
  46. attr_accessor :font_type
  47. attr_accessor :name_font_type
  48. attr_accessor :font_size
  49. attr_accessor :name_font_size
  50. attr_accessor :message_box_opacity
  51. attr_accessor :name_box_skin
  52. attr_accessor :name_box_text_color
  53. attr_accessor :message_box_text_color
  54. attr_accessor :message_box_skin
  55. attr_accessor :name_box_width
  56. attr_accessor :name_box_height
  57. attr_accessor :message_width
  58. attr_accessor :message_height
  59. attr_accessor :message_x
  60. attr_accessor :message_y_bottom
  61. attr_accessor :message_y_middle
  62. attr_accessor :message_y_top
  63. attr_accessor :event_message_x_ofset
  64. attr_accessor :event_message_y_ofset
  65.  
  66. def initialize
  67.  
  68.  
  69. @name_box_x_offset = 0          #Choose the X axis offset of the name bos. default= 0
  70. @name_box_y_offset = -10       #Choose the Y axis offset of the name bos. default= -10
  71. @name_box_width = 8               #Choose the width of the Name Box. default= 8  
  72. @name_box_height = 26            #Choose the height of the Name Box. default= 26
  73.  
  74. @font_type = "Tahoma"            #Choose the Font Name (Case Sensitive) for message box
  75. @name_font_type = "Tahoma"    #Choose the Font Name (Case Sensitive) for Name Box
  76. @font_size = 21                     #Choose the default Font Size for message box text
  77. @name_font_size = 21             #Choose the deafault Font Size for Name Box text
  78. @name_box_text_color=0          #Choose the Text Color of the Name Box
  79. @message_box_text_color=0      #Choose the Text Color of the Message Box
  80.  
  81. @message_box_opacity = 240      #Choose the opacity of the message window. Default=160
  82. @message_box_skin = "Black3"   #Choose the WindowSkin for the Message Box
  83. @name_box_skin = "Black3"       #Choose the WindowSkin for the Name Box
  84.  
  85. @message_width = 440             #Choose the width size of the message box. Default=480
  86. @message_height = 160            #Choose the height size of the message box. Default=160
  87. @message_x = 80                     #Choose the X position of the message box. Default=80
  88. @message_y_bottom = 310         #Choose the Y bottom position of the message box. Default=304
  89. @message_y_middle = 160         #Choose the Y middle position of the message box. Default=160
  90. @message_y_top = 16               #Choose the Y top position of the message box. Default=16
  91.  
  92. @event_message_x_ofset = 0      #Choose the X position offset of the event message. Default=0
  93. @event_message_y_ofset = 48    #Choose the Y position offset of the event message. Default=48
  94.  
  95. end
  96. end
  97. #===================================================
  98. # ? CLASS AMS Ends
  99. #===================================================
  100.  
  101.  
  102. #===================================================
  103. # ? Class Window_Message Begins
  104. #===================================================
  105. class Window_Message < Window_Selectable  
  106.  
  107. alias xrxs9_initialize initialize
  108.  
  109. def initialize
  110.  
  111. @alex_skip = false
  112.  
  113. xrxs9_initialize
  114.  
  115. if $soundname_on_speak == nil then
  116.   $soundname_on_speak = ""
  117. end
  118.  
  119. $gaiji_file = "./Graphics/Gaiji/sample.png"
  120.          
  121. if FileTest.exist?($gaiji_file)
  122.   @gaiji_cache = Bitmap.new($gaiji_file)
  123. else
  124.   @gaigi_cache = nil
  125. end
  126. @opacity_text_buf = Bitmap.new(32, 32)
  127. end
  128.  
  129.  
  130. #--------------------------------------------------------------------------
  131.  
  132. alias xrxs9_terminate_message terminate_message
  133.  
  134. def terminate_message
  135.  
  136. if @name_window_frame != nil
  137.   @name_window_frame.dispose
  138.   @name_window_frame = nil
  139. end
  140.  
  141. if @name_window_text   != nil
  142.   @name_window_text.dispose
  143.   @name_window_text   = nil
  144. end
  145. xrxs9_terminate_message
  146. end
  147.  
  148. #--------------------------------------------------------------------------
  149.  
  150. def refresh
  151.  
  152. self.contents.clear
  153. self.contents.font.color = text_color($ams.message_box_text_color)
  154. self.contents.font.name = $ams.font_type
  155. self.contents.font.size = $ams.font_size
  156. self.windowskin = RPG::Cache.windowskin($ams.message_box_skin)
  157. @x = @y = @max_x = @max_y = @indent = @lines = 0
  158. @face_indent = 0
  159. @opacity = 255
  160. @cursor_width = 0
  161. @write_speed = 0
  162. @write_wait = 0
  163. @mid_stop = false
  164. @face_file = nil
  165. @popchar = -2
  166.  
  167. if $game_temp.choice_start == 0
  168.   @x = 8
  169. end
  170.  
  171. if $game_temp.message_text != nil
  172.   @now_text = $game_temp.message_text
  173.   if (/\A\\[Ff]\[(.+?)\]/.match(@now_text))!=nil then
  174.        @face_file ="Faces/" + $1 + ".png"
  175.        @x = @face_indent = 128
  176.      if FileTest.exist?("Graphics/Pictures/" + $1 + ".png")
  177.         self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  178.      end
  179.      @now_text.gsub!(/\\[Ff]\[(.*?)\]/) { "" }
  180.   end
  181.  
  182.   begin
  183.   last_text = @now_text.clone
  184.   @now_text.gsub!(/\\[Vv]\[([IiWwAaSs]?)([0-9]+)\]/) { convart_value($1, $2.to_i) }
  185.   end until @now_text == last_text
  186.   @now_text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  187.      $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  188.     end
  189.  
  190.   #NEW
  191.   #Dubealex's Stop Skip Text ON-OFF
  192.   @now_text.gsub!(/\\[%]/) { "\100" }
  193.   #End new command
  194.    
  195.   #NEW
  196.   #Dubealex's Show Monster Name Feature
  197.     @now_text.gsub!(/\\[Mm]\[([0-9]+)\]/) do
  198.     $data_enemies[$1.to_i] != nil ? $data_enemies[$1.to_i].name : ""
  199.     end
  200.     #End new command
  201.    
  202.   #NEW
  203.   #Dubealex's Show Item Price Feature
  204.     @now_text.gsub!(/\\[Pp]rice\[([0-9]+)\]/) do
  205.     $data_items[$1.to_i] != nil ? $data_items[$1.to_i].price : ""
  206.     end
  207.     #End new command
  208.    
  209.   #NEW
  210.   #Dubealex's Show Hero Class Name Feature
  211.     @now_text.gsub!(/\\[Cc]lass\[([0-9]+)\]/) do
  212.     $data_classes[$data_actors[$1.to_i].class_id] != nil ? $data_classes[$data_actors[$1.to_i].class_id].name : ""
  213.     end
  214.     #End new command
  215.    
  216.   #NEW
  217.   #Dubealex's Show Current Map Name Feature
  218.     @now_text.gsub!(/\\[Mm]ap/) do
  219.     $game_map.name      != nil ? $game_map.name      : ""
  220.     end
  221.     #End new command
  222.    
  223.   #New
  224.    
  225.     #New
  226.     #++Edit
  227.     #Shows Icon and Weapon/Armour and Item name use \ow[i], \oa[i], \oi[i]
  228.     # armor, items, skills, and weapons
  229.         @now_text.gsub!(/\\[Oo][Aa]\[([0-9]+)\]/) {
  230.            item = $data_armors[$1.to_i]
  231.            "\014[#{$1}]" + "   " + item.name
  232.         }
  233.         @now_text.gsub!(/\\[Oo][Ii]\[([0-9]+)\]/) {
  234.            item = $data_items[$1.to_i]
  235.            "\015[#{$1}]" + "   " + item.name
  236.         }
  237.         @now_text.gsub!(/\\[Oo][Ss]\[([0-9]+)\]/) {
  238.            item = $data_skills[$1.to_i]
  239.            "\016[#{$1}]" + "   " + item.name
  240.         }
  241.         @now_text.gsub!(/\\[Oo][Ww]\[([0-9]+)\]/) {
  242.            item = $data_weapons[$1.to_i]
  243.            "\017[#{$1}]" + "   " + item.name
  244.         }
  245.    
  246.   #NEW
  247.   #Dubealex's Choose Name Box Text Color
  248.     @now_text.gsub!(/\\[Zz]\[([0-9]+)\]/) do
  249.     $ams.name_box_text_color=$1.to_i
  250.     @now_text.sub!(/\\[Zz]\[([0-9]+)\]/) { "" }
  251.     end
  252.     #End new command
  253.    
  254.    
  255.    
  256.   name_window_set = false
  257.   if (/\\[Nn]\[(.+?)\]/.match(@now_text)) != nil
  258.      name_window_set = true
  259.      name_text = $1
  260.      @now_text.sub!(/\\[Nn]\[(.*?)\]/) { "" }
  261.   end
  262.  
  263.   if (/\\[Pp]\[([-1,0-9]+)\]/.match(@now_text))!=nil then
  264.      @popchar = $1.to_i
  265.      if @popchar == -1
  266.         @x = @indent = 48
  267.         @y = 4
  268.      end
  269.      @now_text.gsub!(/\\[Pp]\[([-1,0-9]+)\]/) { "" }
  270.   end
  271.  
  272.   @max_choice_x = 0
  273.   if @popchar >= 0
  274.      @text_save = @now_text.clone
  275.      @max_x = 0
  276.      @max_y = 4
  277.      for i in 0..3
  278.         line = @now_text.split(/\n/)[3-i]
  279.         @max_y -= 1 if line == nil and @max_y <= 4-i
  280.         next if line == nil
  281.         line.gsub!(/\\\w\[(\w+)\]/) { "" }
  282.         cx = contents.text_size(line).width
  283.         @max_x = cx if cx > @max_x
  284.         if i >= $game_temp.choice_start
  285.            @max_choice_x = cx if cx > @max_choice_x
  286.         end
  287.      end
  288.      self.width = @max_x + 32 + @face_indent
  289.      self.height = (@max_y - 1) * 32 + 64
  290.      @max_choice_x -= 68
  291.      @max_choice_x -= @face_indent*216/128
  292.   else
  293.      @max_x = self.width - 32 - @face_indent
  294.      for i in 0..3
  295.         line = @now_text.split(/\n/)[i]
  296.         next if line == nil
  297.         line.gsub!(/\\\w\[(\w+)\]/) { "" }
  298.         cx = contents.text_size(line).width
  299.         if i >= $game_temp.choice_start
  300.            @max_choice_x = cx if cx > @max_choice_x
  301.         end
  302.      end
  303.      @max_choice_x += 8
  304.   end
  305.   @cursor_width = 0
  306.   @now_text.gsub!(/\\\\/) { "\000" }
  307.   @now_text.gsub!(/\\[Cc]\[([0123456789ABCDEF#]+)\]/) { "\001[#{$1}]" }
  308.   @now_text.gsub!(/\\[Gg]/) { "\002" }
  309.   @now_text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\003[#{$1}]" }
  310.   @now_text.gsub!(/\\[Aa]\[(.*?)\]/) { "\004[#{$1}]" }
  311.  
  312.     #NEW
  313.     #Dubealex's Permanent Color Change
  314.     @now_text.gsub!(/\\[Cc]olor\[([0-9]+)\]/) do
  315.        $ams.message_box_text_color= $1.to_i
  316.      @now_text.sub!(/\\[Cc]\[([0-9]+)\]/) { "" }
  317.        end
  318.     #End of new command
  319.    
  320.     #NEW
  321.     #Dubealex's Font Change Feature
  322.      @now_text.gsub(/\\[Tt]\[(.*?)\]/) do
  323.        buftxt = $1.to_s
  324.        $ams.font_type = buftxt
  325.        @now_text.sub!(/\\[Tt]\[(.*?)\]/) { "" }
  326.        end
  327.     #End of new command
  328.    
  329.   @now_text.gsub!(/\\[.]/) { "\005" }
  330.   @now_text.gsub!(/\\[|]/) { "\006" }
  331.   @now_text.gsub!(/\\[|]/) { "\014" }
  332.   @now_text.gsub!(/\\[|]/) { "\015" }
  333.   @now_text.gsub!(/\\[|]/) { "\016" }
  334.   @now_text.gsub!(/\\[|]/) { "\017" }
  335.   @now_text.gsub!(/\\[>]/) { "\019" }
  336.   @now_text.gsub!(/\\[<]/) { "\031" }
  337.   @now_text.gsub!(/\\[!]/) { "\020" }
  338.   @now_text.gsub!(/\\[~]/) { "\021" }
  339.   @now_text.gsub!(/\\[Ee]\[([0-9]+)\]/) { "\022[#{$1}]" }
  340.   @now_text.gsub!(/\\[Ii]/) { "\023" }
  341.   @now_text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\024[#{$1}]" }
  342.   @now_text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\025[#{$1}]" }
  343.   @now_text.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\026[#{$1}]" }
  344.   @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "\027[#{$1}]" }
  345.  
  346.   reset_window
  347.  
  348.   if name_window_set
  349.      color=$ams.name_box_text_color
  350.      off_x =   $ams.name_box_x_offset
  351.      off_y =   $ams.name_box_y_offset
  352.      space = 2
  353.      x = self.x + off_x - space / 2
  354.      y = self.y + off_y - space / 2
  355.      w = self.contents.text_size(name_text).width + $ams.name_box_width + space
  356.      h = $ams.name_box_height + space
  357.      @name_window_frame = Window_Frame.new(x, y, w, h)
  358.      @name_window_frame.z = self.z + 1
  359.      x = self.x + off_x + 4
  360.      y = self.y + off_y
  361.      @name_window_text   = Air_Text.new(x, y, name_text, color)
  362.      @name_window_text.z = self.z + 2
  363.   end
  364. end
  365.  
  366. reset_window
  367.  
  368. if $game_temp.choice_max > 0
  369.   @item_max = $game_temp.choice_max
  370.   self.active = true
  371.   self.index = 0
  372. end
  373.  
  374. if $game_temp.num_input_variable_id > 0
  375.   digits_max = $game_temp.num_input_digits_max
  376.   number = $game_variables[$game_temp.num_input_variable_id]
  377.   @input_number_window = Window_InputNumber.new(digits_max)
  378.   @input_number_window.number = number
  379.   @input_number_window.x = self.x + 8
  380.   @input_number_window.y = self.y + $game_temp.num_input_start * 32
  381. end
  382. end
  383.  
  384. #--------------------------------------------------------------------------
  385.  
  386. def update
  387.  
  388. super
  389.  
  390.  
  391.    
  392. if @fade_in
  393.   self.contents_opacity += 24
  394.   if @input_number_window != nil
  395.      @input_number_window.contents_opacity += 24
  396.   end
  397.   if self.contents_opacity == 255
  398.      @fade_in = false
  399.   end
  400.   return
  401. end
  402. @now_text = nil if @now_text == ""
  403.  
  404. if @now_text != nil and @mid_stop == false
  405.   if @write_wait > 0
  406.      @write_wait -= 1
  407.      return
  408.   end
  409.   text_not_skip = LETTER_BY_LETTER_MODE
  410.   while true
  411.      @max_x = @x if @max_x < @x
  412.      @max_y = @y if @max_y < @y
  413.      if (c = @now_text.slice!(/./m)) != nil
  414.         if c == "\000"
  415.            c = "\\"
  416.         end
  417.      
  418.         if c == "\001"
  419.            @now_text.sub!(/\[([0123456789ABCDEF#]+)\]/, "")
  420.            temp_color = $1
  421.            color = temp_color.to_i
  422.            leading_x = temp_color.to_s.slice!(/./m)
  423.            if leading_x == "#"
  424.               self.contents.font.color = hex_color(temp_color)
  425.               next
  426.            end
  427.            if color >= 0 and color <= 7
  428.               self.contents.font.color = text_color(color)
  429.            end
  430.            next
  431.         end
  432.  
  433.         if c == "\002"
  434.            if @gold_window == nil and @popchar <= 0
  435.               @gold_window = Window_Gold.new
  436.               @gold_window.x = 560 - @gold_window.width
  437.               if $game_temp.in_battle
  438.                  @gold_window.y = 192
  439.               else
  440.                  @gold_window.y = self.y >= 128 ? 32 : 384
  441.               end
  442.               @gold_window.opacity = self.opacity
  443.               @gold_window.back_opacity = self.back_opacity
  444.            end
  445.            c = ""
  446.         end
  447.  
  448.         if c == "\003"
  449.            @now_text.sub!(/\[([0-9]+)\]/, "")
  450.            speed = $1.to_i
  451.            if speed >= 0 and speed <= 19
  452.               @write_speed = speed
  453.            end
  454.            c = ""
  455.         end
  456.  
  457.         if c == "\004"
  458.            @now_text.sub!(/\[(.*?)\]/, "")
  459.            buftxt = $1.dup.to_s
  460.            if buftxt.match(/\//) == nil and buftxt != "" then
  461.               $soundname_on_speak = "Audio/SE/" + buftxt
  462.            else
  463.               $soundname_on_speak = buftxt.dup
  464.            end
  465.            c = ""
  466.         elsif c == "\004"
  467.            c = ""
  468.         end
  469.      
  470.         if c == "\005"
  471.            @write_wait += 5
  472.            c = ""
  473.         end
  474.      
  475.         if c == "\006"
  476.            @write_wait += 20
  477.            c = ""
  478.         end
  479.      
  480.         if c == "\019"
  481.            text_not_skip = false
  482.            c = ""
  483.         end
  484.      
  485.         if c == "\031"
  486.            text_not_skip = true
  487.            c = ""
  488.         end
  489.      
  490.         if c == "\020"
  491.            @mid_stop = true
  492.            c = ""
  493.         end
  494.      
  495.         if c == "\021"
  496.            terminate_message
  497.            return
  498.         end
  499.      
  500.         if c == "\023"
  501.            @indent = @x
  502.            c = ""
  503.         end
  504.  
  505.         if c == "\024"
  506.            @now_text.sub!(/\[([0-9]+)\]/, "")
  507.            @opacity = $1.to_i
  508.            color = self.contents.font.color
  509.            self.contents.font.name = $ams.font_type
  510.            self.contents.font.size = $ams.font_size
  511.            self.contents.font.color = Color.new(color.red, color.green, color.blue, color.alpha * @opacity / 255)
  512.            c = ""
  513.         end
  514.  
  515.         if c == "\025"
  516.            @now_text.sub!(/\[([0-9]+)\]/, "")
  517.            self.contents.font.size = [[$1.to_i, 6].max, 32].min
  518.            c = ""
  519.         end
  520.  
  521.         if c == "\026"
  522.            @now_text.sub!(/\[([0-9]+)\]/, "")
  523.            @x += $1.to_i
  524.            c = ""
  525.         end
  526.      
  527.         if c == "\027"
  528.            @now_text.sub!(/\[(.*?)\]/, "")
  529.            @x += ruby_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), $1, @opacity)
  530.            if $soundname_on_speak != ""
  531.               Audio.se_play($soundname_on_speak)
  532.            end
  533.         c = ""
  534.         end
  535.  
  536.         if c == "\030"
  537.            @now_text.sub!(/\[(.*?)\]/, "")
  538.            self.contents.blt(@x , @y * line_height + 8, RPG::Cache.icon($1), Rect.new(0, 0, 24, 24))
  539.            if $soundname_on_speak != ""
  540.               Audio.se_play($soundname_on_speak)
  541.            end
  542.            @x += 24
  543.            c = ""
  544.         end
  545.  
  546.         if c == "\n"
  547.            @lines += 1
  548.            @y += 1
  549.            @x = 0 + @indent + @face_indent
  550.            if @lines >= $game_temp.choice_start
  551.               @x = 8 + @indent + @face_indent
  552.               @cursor_width = @max_choice_x
  553.            end
  554.            c = ""
  555.         end
  556.      
  557.         if c == "\022"
  558.            @now_text.sub!(/\[([0-9]+)\]/, "")
  559.            @x += gaiji_draw(4 + @x, @y * line_height + (line_height - self.contents.font.size), $1.to_i)
  560.            c = ""
  561.         end
  562.      
  563.         #NEW
  564.         #Dubealex's Text Skip On/OFF Command
  565.           if c == "\100"
  566.               if @alex_skip==false
  567.                    @alex_skip=true
  568.               else
  569.                  @alex_skip=false
  570.               end
  571.              c = ""
  572.           end  
  573.           #end of new command
  574.                                                    
  575.         if c != ""
  576.            self.contents.draw_text(0+@x, 32 * @y, 40, 32, c)
  577.            @x += self.contents.text_size(c).width
  578.            if $soundname_on_speak != "" then
  579.               Audio.se_play($soundname_on_speak)
  580.            end
  581.         end
  582.      
  583.   #New
  584.     #++Edit
  585.     #Shows Icon and Weapon/Armour and Item name use \ow[i], \oa[i], \oi[i]
  586.    
  587.         # If \oa[n]
  588.      if c == "\014"
  589.         @now_text.sub!(/\[([0-9]+)\]/, "")
  590.         index = $1.to_i
  591.         @now_text.sub!("   ", " ")
  592.         item = $data_armors[index]
  593.         # draw the icon
  594.         icon = RPG::Cache.icon(item.icon_name)
  595.         line = self.contents.text_size("dj").height
  596.         self.contents.blt(@x + 4, (@y * line) + 4, icon, Rect.new(0, 0, 24, 24))
  597.         @x += 24
  598.  
  599.         # go to next text
  600.         return
  601.      end
  602.      #++Edit
  603.      # If \oi[n]
  604.      if c == "\015"
  605.         @now_text.sub!(/\[([0-9]+)\]/, "")
  606.         index = $1.to_i
  607.         @now_text.sub!("   ", " ")
  608.         item = $data_items[index]
  609.         # draw the icon
  610.         icon = RPG::Cache.icon(item.icon_name)
  611.         line = self.contents.text_size("dj").height
  612.         self.contents.blt(@x + 4, (@y * line) + 4, icon, Rect.new(0, 0, 24, 24))
  613.         @x += 24
  614.  
  615.         # go to next text
  616.         return
  617.      end
  618.      #++Edit
  619.      # If \os[n]
  620.      if c == "\016"
  621.         @now_text.sub!(/\[([0-9]+)\]/, "")
  622.         index = $1.to_i
  623.         @now_text.sub!("   ", " ")
  624.         item = $data_skills[index]
  625.         # draw the icon
  626.         icon = RPG::Cache.icon(item.icon_name)
  627.         line = self.contents.text_size("dj").height
  628.         self.contents.blt(@x + 2, (@y * line) + 4, icon, Rect.new(0, 0, 24, 24))
  629.         @x += 24
  630.  
  631.         # go to next text
  632.         return
  633.      end
  634.      #++Edit
  635.      # If \ow[n]
  636.      if c == "\017"
  637.         @now_text.sub!(/\[([0-9]+)\]/, "")
  638.         index = $1.to_i
  639.         @now_text.sub!("   ", " ")
  640.         item = $data_weapons[index]
  641.         # draw the icon
  642.         icon = RPG::Cache.icon(item.icon_name)
  643.         line = self.contents.text_size("dj").height
  644.         self.contents.blt(@x + 2, (@y * line) + 4, icon, Rect.new(0, 0, 24, 24))
  645.         @x += 24
  646.      
  647.         # go to next text
  648.         return
  649.      end
  650.  
  651.      
  652. #SKIP_TEXT_CODE
  653.  
  654. # B = Escape, 0 (On The NumPad), X
  655. # C = Enter, Space Bar and C
  656. # A = Shift, Z
  657.  
  658.   if Input.press?(Input::C) # <-- Change the value on that line
  659.      if @alex_skip==false        
  660.      text_not_skip = false
  661.      end
  662.         end
  663.      else
  664.         text_not_skip = true
  665.         break
  666.      end
  667.    
  668.      if text_not_skip
  669.         break
  670.      end
  671.   end
  672.   @write_wait += @write_speed
  673.   return
  674. end
  675.  
  676. if @input_number_window != nil
  677.   @input_number_window.update
  678.   if Input.trigger?(Input::C)
  679.      $game_system.se_play($data_system.decision_se)
  680.      $game_variables[$game_temp.num_input_variable_id] =
  681.         @input_number_window.number
  682.      $game_map.need_refresh = true
  683.      @input_number_window.dispose
  684.      @input_number_window = nil
  685.      terminate_message
  686.   end
  687.   return
  688. end
  689.  
  690. if @contents_showing
  691.   if $game_temp.choice_max == 0
  692.      self.pause = true
  693.   end
  694.  
  695.   if Input.trigger?(Input::B)
  696.      if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  697.         $game_system.se_play($data_system.cancel_se)
  698.         $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  699.         terminate_message
  700.      end
  701.   end
  702.  
  703.   if Input.trigger?(Input::C)
  704.      if $game_temp.choice_max > 0
  705.         $game_system.se_play($data_system.decision_se)
  706.         $game_temp.choice_proc.call(self.index)
  707.      end
  708.      if @mid_stop
  709.         @mid_stop = false
  710.         return
  711.      else
  712.         terminate_message
  713.      end
  714.   end
  715.   return
  716. end
  717.  
  718. if @fade_out == false and $game_temp.message_text != nil
  719.   @contents_showing = true
  720.   $game_temp.message_window_showing = true
  721.   refresh
  722.   Graphics.frame_reset
  723.   self.visible = true
  724.   self.contents_opacity = 0
  725.   if @input_number_window != nil
  726.      @input_number_window.contents_opacity = 0
  727.   end
  728.   @fade_in = true
  729.   return
  730. end
  731.  
  732. if self.visible
  733.   @fade_out = true
  734.   self.opacity -= 48
  735.   if self.opacity == 0
  736.      self.visible = false
  737.      @fade_out = false
  738.      $game_temp.message_window_showing = false
  739.   end
  740.   return
  741. end
  742. end
  743.  
  744. #--------------------------------------------------------------------------
  745.  
  746. def get_character(parameter)
  747.  
  748. case parameter
  749. when 0  
  750.   return $game_player
  751. else
  752.   events = $game_map.events
  753.   return events == nil ? nil : events[parameter]
  754. end
  755. end
  756.  
  757. #--------------------------------------------------------------------------
  758.  
  759. def reset_window
  760.  
  761. #MESSAGE_SIZE
  762. #MESSAGE_POSITION
  763.  
  764. if @popchar >= 0
  765.   events = $game_map.events
  766.   if events != nil
  767.      character = get_character(@popchar)
  768.      x = [[character.screen_x -   $ams.event_message_x_ofset - self.width / 2, 4].max, 636 - self.width].min
  769.      y = [[character.screen_y - $ams.event_message_y_ofset - self.height, 4].max, 476 - self.height].min
  770.      self.x = x
  771.      self.y = y
  772.   end
  773. elsif @popchar == -1
  774.   self.x = -4
  775.   self.y = -4
  776.   self.width = 648
  777.   self.height = 488
  778. else
  779.   if $game_temp.in_battle
  780.      self.y = 16
  781.   else
  782.      case $game_system.message_position
  783.      when 0  
  784.         self.y = $ams.message_y_top
  785.      when 1  
  786.         self.y = $ams.message_y_middle
  787.      when 2  
  788.         self.y = $ams.message_y_bottom
  789.      end
  790.      self.x = $ams.message_x
  791.      if @face_file == nil
  792.         self.width = $ams.message_width
  793.         self.x = $ams.message_x
  794.      else
  795.         if self.width <= 600
  796.            self.width = 600
  797.            self.x -=60
  798.           end
  799.      end
  800.      self.height = $ams.message_height
  801.   end
  802. end
  803. self.contents = Bitmap.new(self.width - 32, self.height - 32)
  804. self.contents.font.color = text_color($ams.message_box_text_color)
  805. self.contents.font.name = $ams.font_type
  806. self.contents.font.size = $ams.font_size
  807. if @face_file != nil
  808.   self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  809. end
  810. if @popchar == -1
  811.   self.opacity = 255
  812.   self.back_opacity = 0
  813. elsif $game_system.message_frame == 0
  814.   self.opacity = 255
  815.   self.back_opacity = $ams.message_box_opacity
  816. else
  817.   self.opacity = 0
  818.   self.back_opacity = $ams.message_box_opacity
  819. end
  820. end
  821.  
  822. #--------------------------------------------------------------------------
  823.  
  824. def gaiji_draw(x, y, num)
  825.  
  826. if @gaiji_cache == nil
  827.   return 0
  828. else
  829.   if @gaiji_cache.width < num * 24
  830.      return 0
  831.   end
  832.  
  833.   if self.contents.font.size >= 20 and self.contents.font.size <= 24
  834.      size = 24
  835.   else
  836.      size = self.contents.font.size * 100 * 24 / 2200
  837.   end
  838.  
  839.   self.contents.stretch_blt(Rect.new(x, y, size, size), @gaiji_cache, Rect.new(num * 24, 0, 24, 24))
  840.  
  841.   if $soundname_on_speak != "" then
  842.      Audio.se_play($soundname_on_speak)
  843.   end
  844.   return size
  845. end
  846. end
  847.  
  848. #--------------------------------------------------------------------------
  849.  
  850. def line_height
  851. return 32
  852.  
  853. if self.contents.font.size >= 20 and self.contents.font.size <= 24
  854.   return 32
  855. else
  856.   return self.contents.font.size * 15 / 10
  857. end
  858. end
  859.  
  860. #--------------------------------------------------------------------------
  861.  
  862. def ruby_draw_text(target, x, y, str,opacity)
  863.  
  864. sizeback = target.font.size
  865. target.font.size * 3 / 2 > 32 ? rubysize = 32 - target.font.size : rubysize = target.font.size / 2
  866. rubysize = [rubysize, 6].max
  867. opacity = [[opacity, 0].max, 255].min
  868. split_s = str.split(/,/)
  869. split_s[0] == nil ? split_s[0] = "" : nil
  870. split_s[1] == nil ? split_s[1] = "" : nil
  871.  
  872. height = sizeback + rubysize
  873. width   = target.text_size(split_s[0]).width
  874.  
  875. target.font.size = rubysize
  876. ruby_width = target.text_size(split_s[1]).width
  877. target.font.size = sizeback
  878.  
  879. buf_width = [target.text_size(split_s[0]).width, ruby_width].max
  880.  
  881. width - ruby_width != 0 ? sub_x = (width - ruby_width) / 2 : sub_x = 0
  882.  
  883. if opacity == 255
  884.   target.font.size = rubysize
  885.   target.draw_text(x + sub_x, y - target.font.size, target.text_size(split_s[1]).width, target.font.size, split_s[1])
  886.   target.font.size = sizeback
  887.   target.draw_text(x, y, width, target.font.size, split_s[0])
  888.   return width
  889. else
  890.   if @opacity_text_buf.width < buf_width or @opacity_text_buf.height < height
  891.      @opacity_text_buf.dispose
  892.      @opacity_text_buf = Bitmap.new(buf_width, height)
  893.   else
  894.      @opacity_text_buf.clear
  895.   end
  896.   @opacity_text_buf.font.size = rubysize
  897.   @opacity_text_buf.draw_text(0 , 0, buf_width, rubysize, split_s[1], 1)
  898.   @opacity_text_buf.font.size = sizeback
  899.   @opacity_text_buf.draw_text(0 , rubysize, buf_width, sizeback, split_s[0], 1)
  900.   if sub_x >= 0
  901.      target.blt(x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  902.   else
  903.      target.blt(x + sub_x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  904.   end
  905.   return width
  906. end
  907. end
  908.  
  909. #--------------------------------------------------------------------------
  910.  
  911. def convart_value(option, index)
  912. option == nil ? option = "" : nil
  913. option.downcase!
  914.  
  915. case option
  916. when "i"
  917.   unless $data_items[index].name == nil
  918.      r = sprintf("\030[%s]%s", $data_items[index].icon_name, $data_items[index].name)
  919.   end
  920. when "w"
  921.   unless $data_weapons[index].name == nil
  922.      r = sprintf("\030[%s]%s", $data_weapons[index].icon_name, $data_weapons[index].name)
  923.   end
  924. when "a"
  925.   unless $data_armors[index].name == nil
  926.      r = sprintf("\030[%s]%s", $data_armors[index].icon_name, $data_armors[index].name)
  927.   end
  928. when "s"
  929.   unless $data_skills[index].name == nil
  930.      r = sprintf("\030[%s]%s", $data_skills[index].icon_name, $data_skills[index].name)
  931.   end
  932. else
  933.   r = $game_variables[index]
  934. end
  935.  
  936. r == nil ? r = "" : nil
  937. return r
  938. end
  939.  
  940. #--------------------------------------------------------------------------
  941.  
  942. def dispose
  943. terminate_message
  944.  
  945. if @gaiji_cache != nil
  946.   unless @gaiji_cache.disposed?
  947.      @gaiji_cache.dispose
  948.   end
  949. end
  950.  
  951. unless @opacity_text_buf.disposed?
  952.   @opacity_text_buf.dispose
  953. end
  954.  
  955. $game_temp.message_window_showing = false
  956. if @input_number_window != nil
  957.   @input_number_window.dispose
  958. end
  959. super
  960. end
  961.  
  962.  
  963.  
  964. #--------------------------------------------------------------------------
  965.  
  966. def update_cursor_rect
  967. if @index >= 0
  968.   n = $game_temp.choice_start + @index
  969.   self.cursor_rect.set(8 + @indent + @face_indent, n * 32, @cursor_width, 32)
  970. else
  971.   self.cursor_rect.empty
  972. end
  973. end
  974. end
  975. #=========================================
  976. # ? CLASS Window_Message Ends
  977. #=========================================
  978.  
  979.  
  980. #=========================================
  981. # ? Class Window_Frame Begins
  982. #=========================================
  983. class Window_Frame < Window_Base
  984.  
  985. def initialize(x, y, width, height)
  986. super(x, y, width, height)
  987. self.windowskin = RPG::Cache.windowskin($ams.name_box_skin)
  988. self.contents = nil
  989. end
  990.  
  991. #--------------------------------------------------------------------------
  992.  
  993. def dispose
  994. super
  995. end
  996. end
  997. #=========================================
  998. # ? CLASS Window_Frame Ends
  999. #=========================================
  1000.  
  1001.  
  1002. #=========================================
  1003. # ? CLASS Game_Map Additional Code Begins
  1004. #=========================================
  1005. class Game_Map
  1006.  
  1007. #Dubealex's Addition (from XRXS) to show Map Name on screen
  1008. def name
  1009. $map_infos[@map_id]
  1010. end
  1011. end
  1012. #=========================================
  1013. # ? CLASS Game_Map Additional Code Ends
  1014. #=========================================
  1015.  
  1016.  
  1017. #=========================================
  1018. # ? CLASS Scene_Title Additional Code Begins
  1019. #=========================================
  1020. class Scene_Title
  1021.  
  1022. #Dubealex's Addition (from XRXS) to show Map Name on screen
  1023. $map_infos = load_data("Data/MapInfos.rxdata")
  1024. for key in $map_infos.keys
  1025.     $map_infos[key] = $map_infos[key].name
  1026. end
  1027.  
  1028. #Dubealex's addition to save data from the AMS in the save files
  1029. $ams = AMS.new
  1030.  
  1031. end
  1032. #=========================================
  1033. # ? CLASS Scene_Title Additional Code Ends
  1034. #=========================================
  1035.  
  1036.  
  1037. #=========================================
  1038. # ? CLASS Window_Base Additional Code Begins
  1039. #=========================================
  1040. class Window_Base < Window
  1041.  
  1042. #Dubealex Addition (from Phylomorphis) to use HTML Hex Code Colors
  1043. def hex_color(string)
  1044.   red = 0
  1045.   green = 0
  1046.   blue = 0
  1047.   if string.size != 6
  1048.      print("Hex strings must be six characters long.")
  1049.      print("White text will be used.")
  1050.      return Color.new(255, 255, 255, 255)
  1051.   end
  1052.   for i in 1..6
  1053.      s = string.slice!(/./m)
  1054.      if s == "#"
  1055.         print("Hex color string may not contain the \"#\" character.")
  1056.         print("White text will be used.")
  1057.         return Color.new(255, 255, 255, 255)
  1058.      end
  1059.      value = hex_convert(s)
  1060.      if value == -1
  1061.         print("Error converting hex value.")
  1062.         print("White text will be used.")
  1063.         return Color.new(255, 255, 255, 255)
  1064.      end
  1065.      case i
  1066.      when 1
  1067.         red += value * 16
  1068.      when 2
  1069.         red += value
  1070.      when 3
  1071.         green += value * 16
  1072.      when 4
  1073.         green += value
  1074.      when 5
  1075.         blue += value * 16
  1076.      when 6
  1077.         blue += value
  1078.      end
  1079.   end
  1080.   return Color.new(red, green, blue, 255)
  1081. end
  1082.  
  1083. #--------------------------------------------------------------------------
  1084.  
  1085. def hex_convert(character)
  1086.   case character
  1087.     when "0"
  1088.        return 0
  1089.   when "1"
  1090.        return 1
  1091.   when "2"
  1092.        return 2
  1093.   when "3"
  1094.        return 3
  1095.   when "4"
  1096.        return 4
  1097.   when "5"
  1098.        return 5
  1099.   when "6"
  1100.        return 6
  1101.   when "7"
  1102.        return 7
  1103.   when "8"
  1104.        return 8
  1105.   when "9"
  1106.        return 9
  1107.   when "A"
  1108.        return 10
  1109.   when "B"
  1110.        return 11
  1111.   when "C"
  1112.        return 12
  1113.   when "D"
  1114.        return 13
  1115.   when "E"
  1116.        return 14
  1117.   when "F"
  1118.        return 15
  1119.     end
  1120.   return -1
  1121. end
  1122. end
  1123. #=========================================
  1124. # ? CLASS Window_Base Additional Code Ends
  1125. #=========================================
  1126.  
  1127.  
  1128. #=========================================
  1129. # ? Class Air_Text Begins
  1130. #=========================================
  1131. class Air_Text < Window_Base
  1132.  
  1133. def initialize(x, y, designate_text, color=0)
  1134.  
  1135. super(x-16, y-16, 32 + designate_text.size * 12, 56)
  1136. self.opacity         = 0
  1137. self.back_opacity = 0
  1138. self.contents = Bitmap.new(self.width - 32, self.height - 32)
  1139. w = self.contents.width
  1140. h = self.contents.height
  1141. self.contents.font.name = $ams.name_font_type
  1142. self.contents.font.size = $ams.name_font_size
  1143. self.contents.font.color = text_color(color)
  1144. self.contents.draw_text(0, 0, w, h, designate_text)
  1145. end
  1146.  
  1147. #--------------------------------------------------------------------------
  1148.  
  1149. def dispose
  1150. self.contents.clear
  1151. super
  1152. end
  1153. end
  1154. #==========================================
  1155. # ? CLASS Air_Text   Ends
  1156. #==========================================
  1157.  
  1158.  
  1159. #===================================================
  1160. # ? CLASS Scene_Save Additional Code Begins
  1161. #===================================================
  1162. class Scene_Save < Scene_File
  1163.  
  1164. alias ams_original_write_save_data write_save_data
  1165.  
  1166. def write_save_data(file)
  1167.     ams_original_write_save_data(file)
  1168.     Marshal.dump($ams, file)
  1169. end
  1170.  
  1171. end
  1172. #===================================================
  1173. # ? CLASS Scene_Save Additional Code Ends
  1174. #===================================================
  1175.  
  1176.  
  1177. #===================================================
  1178. # ? CLASS Scene_Load Additional Code Begins
  1179. #===================================================
  1180. class Scene_Load < Scene_File
  1181.  
  1182. alias ams_original_read_save_data read_save_data
  1183.  
  1184. def read_save_data(file)
  1185.     ams_original_read_save_data(file)
  1186.     $ams         = Marshal.load(file)
  1187. end
  1188.  
  1189. end
  1190.  
Expand to see the code.


I've tried editing this myself to take everything out except the letter by letter and display icons (For items, armours, weapons and skills), but I keep getting error after error, so I thought I'd let someone else take a look.

Cheers to anyone that can do this :cheers: :thumb:
I'm not too familiar with that script, but I've always used Ccoa's UMS which allows you to do both of the things you mentioned. The letter by letter text is the default I believe, and showing items is a simple command \oi[x] with "x" being the item number in the database. Here's the script if you care to try it, although there may be a newer version available by now:

  1. # *****************************************************************************
  2. # *    Universal Message System
  3. # *      v1.6.3
  4. # *      by Ccoa
  5. # *****************************************************************************
  6. # Usage:
  7. =begin
  8.  
  9. IN MESSAGE CODES
  10.   \b          - toggle bold on and off
  11.   \bopc[i]    - change the back opacity for this message to i (should be 0-255)
  12.   \c[i]       - change the text color
  13.   \c[#IIIIII] - change the text color to the hex code (temporary)
  14.   \e[i]       - place the text box over event i (0 = player, -1 no event)
  15.   \face[name] - changes the face graphic to name.png (leave empty [] for no face)
  16.   \fl         - change face justification to left
  17.   \font[name] - change the font to name, leave empty [] to return to the default font
  18.   \fr         - change face justification to right
  19.   \g          - display the gold window
  20.   \height     - height of the message window, works only in normal mode
  21.   \i          - toggle italics on and off
  22.   \ignr       - Do not write anything on this line, only process codes, must be the first thing on a line
  23.   \jc         - justify the window to the center, ignored if using \e
  24.   \jl         - justify the window to the left, ignored if using \e
  25.   \jr         - justify the window to the right, ignored if using \e
  26.   \m          - toggle mode between normal and fit window to text
  27.   \n[i]       - display the name of actor i
  28.   \nm[name]   - display the name in the name window, leave empty [] to remove the name window
  29.   \oa[i]      - display the icon and name of armor i
  30.   \oi[i]      - display the icon and name of item i
  31.   \opc[i]     - change the opacity for this message to i (should be 0-255)
  32.   \os[i]      - display the icon and name of skill i
  33.   \ow[i]      - display the icon and name of weapon i
  34.   \p[i]       - pause for i frames before writing the next character
  35.   \pt         - toggle pause display on and off
  36.   \s          - toggle shadowed text
  37.   \shk[i]     - set window shake to i, higher i is bigger shake, 0 is no shake
  38.   \skip       - toggle text skip on and off
  39.   \ta[i]      - center the window over train actor 1
  40.   \t1         - switch to the talk1 comic thingy
  41.   \t2         - switch to the talk2 comic thingy
  42.   \tc         - center the text, must be the first thing on a line
  43.   \th         - switch to the thought comic thingy
  44.   \tl         - left justify the text, must be the first thing on a line
  45.   \tr         - right justify the text, must be the first thing on a line
  46.   \v[i]       - display variable i
  47.   \width      - width of the message window, works only in normal mode
  48.   \w[i]       - wait for i frames after receiving this code, then close the window
  49.   \ws[i]      - change the write speed to i
  50.   \slv[name]  - set this window to be slave window name, or show slave window name
  51.   \inc        - include this window in the last
  52.  
  53. OUT OF MESSAGE CODES (use in a Script event command)
  54. $game_system.ums_mode = NORMAL_MODE - switch to normal mode
  55. $game_system.ums_mode = FIT_WINDOW_TO_TEXT - switch to fit window mode
  56. $game_system.text_skip = true - turn text skip on
  57. $game_system.text_skip = false
  58. true                           - turn text skip off (true is necessary)
  59. $game_system.text_mode = WRITE_FASTER - change skip mode to write faster
  60. $game_system.text_mode = WRITE_ALL - change skip mode to write all
  61. $game_system.write_speed = i - change the delay between letters to i frames
  62. $game_system.window_height = i - change the window height to i
  63. $game_system.window_width = i - change the window width to i
  64. $game_system.window_justification = RIGHT - make the window right justified
  65. $game_system.window_justification = LEFT - make the window left justified
  66. $game_system.window_justification = CENTER - make the window center justified
  67. $game_system.face_graphic = "filename" - change the face graphic to filename.png
  68. $game_system.face_graphic = "" - change the face graphic to none
  69. $game_system.face_graphic_justification = LEFT - the face graphic is on the left side
  70. $game_system.face_graphic_justification = RIGHT - the face graphic is on the right side
  71. $game_system.face_graphic_position = TOP - face graphic appears on top of window
  72. $game_system.face_graphic_position = CENTER - face graphic appears centered in window
  73. $game_system.face_graphic_position = BOTTOM - face graphic appears on the bottom of window
  74. $game_system.shadow_text = true - turn text shadowing on
  75. $game_system.shadow_text = false
  76. true                            - turn text shadowing off (true is necessary)
  77. $game_system.shadow_color = Color.new(red, blue, green, alpha) - change shadow color
  78. $game_system.message_event = what event to put the message over (0 = player, -1 = no event)
  79. $game_system.comic_enabled = false
  80. true                               - turn off comic thingy
  81. $game_system.comic_enabled = true  - turn on comic thingy (only works with message_event not -1)
  82. $game_system.comic_style = TALK1   - use the talk1.png comic thingy
  83. $game_system.comic_style = TALK2   - use the talk2.png comic thingy
  84. $game_system.comic_style = THOUGHT - use the thought.png comic thingy
  85. $game_system.name = "name" - change the text of the name window to name
  86. $game_system.name = "" - remove the name window
  87. $game_system.font = "name" - change the font to name
  88. $game_system.font = "" - return the font to the default
  89. $game_system.text_justification = CENTER - center justify the text
  90. $game_system.text_justification = LEFT - left justify the text
  91. $game_system.text_justification = RIGHT - right justify the text
  92. $game_system.show_pause = true - show pause icon when waiting for user input
  93. $game_system.show_pause = false - don't show pause icon when waiting for user input
  94. $game_system.shake = 0 - turn window shake off
  95. $game_system.shake = i - set shake to i, higher i is bigger shake
  96. $game_system.sound_effect = "" - turn off the letter-by-letter SE
  97. $game_system.sound_effect = "sename" - play the SE sename with each letter written
  98. $game_system.animated_faces = false - do not use animated faces
  99. $game_system.animated_faces = true - use animated faces
  100. $game_system.animation_pause = i - Wait i frames between each animation
  101. $game_system.face_frame_width = i - Each frame on the faceset is i pixels
  102. $game_system.resting_face = "" - Do not use a resting face
  103. $game_system.resting_face = "name" - Use a different animated face named facenamename when done talking
  104. $game_system.resting_animation_pause = i - Wait i frames between resting animations
  105. $game_system.text_mode = ONE_LETTER_AT_A_TIME - write text one letter at a time
  106. $game_system.text_mode = ALL_AT_ONCE - write text all at once
  107. $game_system.font_color = Color.new(R, G, B, A) - permanently change the font color to the RGBA color given here
  108. $game_system.font_color = nil - return the font color permanently to normal_color (white, by default)
  109. $game_system.windowskin = "windowskinname" - change the message box windowskin to windowskin
  110. $game_system.windowskin = "" - change the message box windowskin back to the one in the database
  111. $game_system.name_window = true - show the name window
  112. $game_system.name_window = false - hide the name window (just show the text)
  113. $game_system.opacity = i - change the message window back opacity to i (0-255)
  114. $game_system.window_image = "imagename" - the name of the image to show behind the window
  115. $game_system.window_image = nil - stop showing an image behind the window
  116. $game_system.train_actor = i - center the message over train actor i
  117.  
  118. =end
  119. # *****************************************************************************
  120. #  CONSTANTS
  121. # *****************************************************************************
  122.  
  123. # modes
  124. NORMAL_MODE        = 0
  125. FIT_WINDOW_TO_TEXT = 1
  126.  
  127. #text modes
  128. ONE_LETTER_AT_A_TIME = 0
  129. ALL_AT_ONCE          = 1
  130.  
  131. # skip modes
  132. WRITE_FASTER = 0
  133. WRITE_ALL    = 1
  134.  
  135. # justifications
  136. RIGHT  = 4
  137. CENTER = 1
  138. LEFT   = 6
  139.  
  140. # positions for extra objects (face graphics, choice box, etc)
  141. ABOVE  = 0  # place the object above the top of the message box
  142. CENTER = 1  # center the object vertically inside the message box
  143. BOTTOM = 2  # place the bottom of the object on the bottom of the message box
  144. SIDE   = 3  # to the side of the message box (which side depends on justification)
  145.  
  146. # comic type
  147. TALK1   = 0
  148. TALK2   = 1
  149. THOUGHT = 2
  150.  
  151. # *****************************************************************************
  152. #  Changes to Game_System.  This allows any changes made to be saved when the
  153. #     game is saved.
  154. # *****************************************************************************
  155.  
  156. class Game_System
  157.   attr_accessor :ums_mode # what mode the UMS is in
  158.   attr_accessor :text_skip # whether or not text skip is activated
  159.   attr_accessor :skip_mode # write the text faster while C is pressed, or just skip to the end
  160.   attr_accessor :write_speed # frame delay between characters
  161.  
  162.   attr_accessor :text_mode # write one letter at a time, or all at once?
  163.  
  164.   attr_accessor :window_height # default height of message window
  165.   attr_accessor :window_width # default width of message window
  166.   attr_accessor :window_justification # default justification of window
  167.  
  168.   attr_accessor :face_graphic # current face graphic
  169.   attr_accessor :face_graphic_justification # justification of face graphic
  170.   attr_accessor :face_graphic_position # position of face graphic
  171.  
  172.   attr_accessor :shadowed_text # whether or not to draw a shadow behind the text
  173.   attr_accessor :shadow_color # the shadow color
  174.  
  175.   attr_accessor :choice_justification # where the choice window is located
  176.   attr_accessor :choice_position # prefered position of choice window
  177.  
  178.   attr_accessor :message_event # what event to center the text over (0 player, -1 to not)
  179.   attr_accessor :train_actor   # what train actor to center the text over (0 player, -1 to not)
  180.  
  181.   attr_accessor :comic_enabled # using "talk" icons?
  182.   attr_accessor :comic_style   # what type of comic image to use
  183.  
  184.   attr_accessor :name # the text for the name window
  185.   attr_accessor :name_window # should the name window be visible?
  186.  
  187.   attr_accessor :font # the name of the font
  188.   attr_accessor :font_color # the name of the (permanent) font color
  189.  
  190.   attr_accessor :text_justification # the justification of the window text
  191.  
  192.   attr_accessor :show_pause # whether or not to show the pause icon
  193.  
  194.   attr_accessor :shake # the amount of shake for the window
  195.  
  196.   attr_accessor :sound_effect # SE to play with each letter
  197.  
  198.   attr_accessor :slave_windows # hash of slave windows
  199.   attr_accessor :indy_windows  # hash of independent windows
  200.  
  201.   attr_accessor :animated_faces # are the faces animated?
  202.   attr_accessor :animation_pause # how long do I wait between animation loops?
  203.   attr_accessor :face_frame_width # how many pixels wide is each face frame
  204.   attr_accessor :resting_face  # postext for waiting face graphic
  205.   attr_accessor :resting_animation_pause # how long to wait for resting graphic
  206.  
  207.   attr_accessor :windowskin # what windowskin to use for messages
  208.   attr_accessor :back_opacity # back opacity of windowskin
  209.   attr_accessor :opacity # opacity of windowskin
  210.  
  211.   attr_accessor :window_image # image used behind window
  212.  
  213.   attr_reader :shortcuts  # user-defined shortcuts
  214.  
  215.   alias ums_initialize initialize
  216.   def initialize
  217.     ums_initialize
  218.     @ums_mode = NORMAL_MODE
  219.    
  220.     @skip_mode = WRITE_ALL
  221.     @text_skip = true
  222.     @write_speed = 2
  223.    
  224.     @text_mode = ONE_LETTER_AT_A_TIME
  225.    
  226.     @window_height = 128
  227.     @window_width = 480
  228.     @window_justification = CENTER
  229.    
  230.     @face_graphic = ""
  231.     @face_graphic_justification = LEFT
  232.     @face_graphic_position = CENTER
  233.    
  234.     @shadowed_text = false
  235.     @shadow_color = Color.new(0, 0, 0, 100)
  236.    
  237.     @choice_justification = RIGHT
  238.     @choice_position = SIDE
  239.    
  240.     @message_event = -1
  241.     @train_actor   = -1
  242.    
  243.     @comic_enabled = false
  244.     @comic_style = TALK1
  245.    
  246.     @name = ""
  247.     @name_window = true
  248.    
  249.     @font = "Georgia"
  250.     @font_color = nil
  251.    
  252.     @text_justification = LEFT
  253.    
  254.     @show_pause = true
  255.    
  256.     @shake = 0
  257.    
  258.     @sound_effect = ""
  259.    
  260.     @slave_windows = {}
  261.     @indy_windows  = {}
  262.    
  263.     @animated_faces = false
  264.     @animation_pause = 80
  265.     @face_frame_width = 100
  266.     @resting_face = ""
  267.     @resting_animation_pause = 80
  268.    
  269.     @windowskin = ""
  270.     @opacity = 255
  271.     @back_opacity = 160
  272.    
  273.     @window_image = nil
  274.    
  275.     @used_codes = ['\v', '\n', '\c', '\g', '\skip', '\m', '\height', '\width',
  276.                    '\jr', '\jc', '\jl', '\face', '\fl', '\fr', '\b', '\i', '\s',
  277.                    '\e', '\t1', '\t2', '\th', '\nm', '\font', '\p', '\w', '\ws',
  278.                    '\oa', '\oi', '\os', '\ow', '\tl', '\tr', '\tc', '\ignr',
  279.                    '\shk', '\slv', '\ind', '\inc']
  280.                    
  281.     @shortcuts = {}
  282.   end
  283.  
  284.   def add_shortcut(shortcut, code)
  285.     text = shortcut.downcase
  286.     if !@used_codes.include?(text)
  287.       @shortcuts[shortcut] = code
  288.     end
  289.   end
  290.  
  291.   def open_window(name)
  292.     if $game_system.indy_windows.has_key?(name)
  293.       $game_system.indy_windows[name].show = true
  294.     end
  295.   end
  296.  
  297.   def close_window(name)
  298.     if $game_system.indy_windows.has_key?(name)
  299.       $game_system.indy_windows[name].dispose
  300.       $game_system.indy_windows.delete(name)
  301.     end
  302.   end
  303. end
  304.  
  305. #==============================================================================
  306. # ** Game_Temp
  307. #------------------------------------------------------------------------------
  308. #  This class handles temporary data that is not included with save data.
  309. #  Refer to "$game_temp" for the instance of this class.
  310. #==============================================================================
  311. class Game_Temp
  312.   attr_accessor :choices
  313.   attr_accessor :num_choices
  314.   attr_accessor :skip_next_choices
  315.  
  316.   alias old_init initialize
  317.   def initialize
  318.     old_init
  319.     @skip_next_choices = 0
  320.     @num_choices = 1
  321.   end
  322. end
  323.  
  324. class Scene_Map
  325.   alias ums_update update
  326.   def update
  327.     $game_system.slave_windows.each_value { |window| window.update }
  328.     $game_system.indy_windows.each_value { |window| window.update }
  329.     ums_update
  330.   end
  331. end
  332.  
  333. class Interpreter
  334.   #--------------------------------------------------------------------------
  335.   # * Event Command Execution
  336.   #--------------------------------------------------------------------------
  337.   def execute_command
  338.     # If last to arrive for list of event commands
  339.     if @index >= @list.size - 1
  340.       # End event
  341.       command_end
  342.       # Continue
  343.       return true
  344.     end
  345.     # Make event command parameters available for reference via @parameters
  346.     if !(@list[@index].code == 102 and $game_temp.skip_next_choices > 0)
  347.       @parameters = @list[@index].parameters.clone
  348.       if @list[@index].code == 402
  349.         @parameters[0] += @offset
  350.       end
  351.     end
  352.     # Branch by command code
  353.     case @list[@index].code
  354.     when 101  # Show Text
  355.       return command_101
  356.     when 102  # Show Choices
  357.       return command_102
  358.     when 402  # When [**]
  359.       return command_402
  360.     when 403  # When Cancel
  361.       return command_403
  362.     when 103  # Input Number
  363.       return command_103
  364.     when 104  # Change Text Options
  365.       return command_104
  366.     when 105  # Button Input Processing
  367.       return command_105
  368.     when 106  # Wait
  369.       return command_106
  370.     when 111  # Conditional Branch
  371.       return command_111
  372.     when 411  # Else
  373.       return command_411
  374.     when 112  # Loop
  375.       return command_112
  376.     when 413  # Repeat Above
  377.       return command_413
  378.     when 113  # Break Loop
  379.       return command_113
  380.     when 115  # Exit Event Processing
  381.       return command_115
  382.     when 116  # Erase Event
  383.       return command_116
  384.     when 117  # Call Common Event
  385.       return command_117
  386.     when 118  # Label
  387.       return command_118
  388.     when 119  # Jump to Label
  389.       return command_119
  390.     when 121  # Control Switches
  391.       return command_121
  392.     when 122  # Control Variables
  393.       return command_122
  394.     when 123  # Control Self Switch
  395.       return command_123
  396.     when 124  # Control Timer
  397.       return command_124
  398.     when 125  # Change Gold
  399.       return command_125
  400.     when 126  # Change Items
  401.       return command_126
  402.     when 127  # Change Weapons
  403.       return command_127
  404.     when 128  # Change Armor
  405.       return command_128
  406.     when 129  # Change Party Member
  407.       return command_129
  408.     when 131  # Change Windowskin
  409.       return command_131
  410.     when 132  # Change Battle BGM
  411.       return command_132
  412.     when 133  # Change Battle End ME
  413.       return command_133
  414.     when 134  # Change Save Access
  415.       return command_134
  416.     when 135  # Change Menu Access
  417.       return command_135
  418.     when 136  # Change Encounter
  419.       return command_136
  420.     when 201  # Transfer Player
  421.       return command_201
  422.     when 202  # Set Event Location
  423.       return command_202
  424.     when 203  # Scroll Map
  425.       return command_203
  426.     when 204  # Change Map Settings
  427.       return command_204
  428.     when 205  # Change Fog Color Tone
  429.       return command_205
  430.     when 206  # Change Fog Opacity
  431.       return command_206
  432.     when 207  # Show Animation
  433.       return command_207
  434.     when 208  # Change Transparent Flag
  435.       return command_208
  436.     when 209  # Set Move Route
  437.       return command_209
  438.     when 210  # Wait for Move's Completion
  439.       return command_210
  440.     when 221  # Prepare for Transition
  441.       return command_221
  442.     when 222  # Execute Transition
  443.       return command_222
  444.     when 223  # Change Screen Color Tone
  445.       return command_223
  446.     when 224  # Screen Flash
  447.       return command_224
  448.     when 225  # Screen Shake
  449.       return command_225
  450.     when 231  # Show Picture
  451.       return command_231
  452.     when 232  # Move Picture
  453.       return command_232
  454.     when 233  # Rotate Picture
  455.       return command_233
  456.     when 234  # Change Picture Color Tone
  457.       return command_234
  458.     when 235  # Erase Picture
  459.       return command_235
  460.     when 236  # Set Weather Effects
  461.       return command_236
  462.     when 241  # Play BGM
  463.       return command_241
  464.     when 242  # Fade Out BGM
  465.       return command_242
  466.     when 245  # Play BGS
  467.       return command_245
  468.     when 246  # Fade Out BGS
  469.       return command_246
  470.     when 247  # Memorize BGM/BGS
  471.       return command_247
  472.     when 248  # Restore BGM/BGS
  473.       return command_248
  474.     when 249  # Play ME
  475.       return command_249
  476.     when 250  # Play SE
  477.       return command_250
  478.     when 251  # Stop SE
  479.       return command_251
  480.     when 301  # Battle Processing
  481.       return command_301
  482.     when 601  # If Win
  483.       return command_601
  484.     when 602  # If Escape
  485.       return command_602
  486.     when 603  # If Lose
  487.       return command_603
  488.     when 302  # Shop Processing
  489.       return command_302
  490.     when 303  # Name Input Processing
  491.       return command_303
  492.     when 311  # Change HP
  493.       return command_311
  494.     when 312  # Change SP
  495.       return command_312
  496.     when 313  # Change State
  497.       return command_313
  498.     when 314  # Recover All
  499.       return command_314
  500.     when 315  # Change EXP
  501.       return command_315
  502.     when 316  # Change Level
  503.       return command_316
  504.     when 317  # Change Parameters
  505.       return command_317
  506.     when 318  # Change Skills
  507.       return command_318
  508.     when 319  # Change Equipment
  509.       return command_319
  510.     when 320  # Change Actor Name
  511.       return command_320
  512.     when 321  # Change Actor Class
  513.       return command_321
  514.     when 322  # Change Actor Graphic
  515.       return command_322
  516.     when 331  # Change Enemy HP
  517.       return command_331
  518.     when 332  # Change Enemy SP
  519.       return command_332
  520.     when 333  # Change Enemy State
  521.       return command_333
  522.     when 334  # Enemy Recover All
  523.       return command_334
  524.     when 335  # Enemy Appearance
  525.       return command_335
  526.     when 336  # Enemy Transform
  527.       return command_336
  528.     when 337  # Show Battle Animation
  529.       return command_337
  530.     when 338  # Deal Damage
  531.       return command_338
  532.     when 339  # Force Action
  533.       return command_339
  534.     when 340  # Abort Battle
  535.       return command_340
  536.     when 351  # Call Menu Screen
  537.       return command_351
  538.     when 352  # Call Save Screen
  539.       return command_352
  540.     when 353  # Game Over
  541.       return command_353
  542.     when 354  # Return to Title Screen
  543.       return command_354
  544.     when 355  # Script
  545.       return command_355
  546.     else      # Other
  547.       return true
  548.     end
  549.   end
  550.  
  551.   #--------------------------------------------------------------------------
  552.   # * Show Text
  553.   #--------------------------------------------------------------------------
  554.   def command_101
  555.     # If other text has been set to message_text
  556.     if $game_temp.message_text != nil
  557.       # End
  558.       return false
  559.     end
  560.     # Set message end waiting flag and callback
  561.     @message_waiting = true
  562.     $game_temp.message_proc = Proc.new { @message_waiting = false }
  563.     # Set message text on first line
  564.     $game_temp.message_text = @list[@index].parameters[0] + "\n"
  565.     line_count = 1
  566.     # Loop
  567.     loop do
  568.       # If next event command text is on the second line or after
  569.       if @list[@index + 1].code == 401
  570.         # Add the second line or after to message_text
  571.         $game_temp.message_text += @list[@index + 1].parameters[0] + "\n"
  572.         line_count += 1
  573.       # If the next event command is show text
  574.       elsif @list[@index + 1].code == 101
  575.         # If the text contains the \inc code
  576.         if @list[@index + 1].parameters[0].index(/\\[Ii][Nn][Cc]/) != nil
  577.           $game_temp.message_text += @list[@index + 1].parameters[0] + "\n"
  578.           $game_temp.message_text.sub!(/\\[Ii][Nn][Cc]/) { "" }
  579.         else
  580.           return true
  581.         end
  582.       # If event command is not on the second line or after
  583.       else
  584.         # If next event command is show choices
  585.         if @list[@index + 1].code == 102
  586.           # Advance index
  587.           @index += 1
  588.          
  589.           # skip this one, it was already shown?
  590.           if $game_temp.skip_next_choices > 0
  591.             $game_temp.skip_next_choices -= 1
  592.           else
  593.             # Choices setup
  594.             $game_temp.choice_start = line_count
  595.             setup_choices(@list[@index].parameters)
  596.           end
  597.         # If next event command is input number
  598.         elsif @list[@index + 1].code == 103
  599.           # If number input window fits on screen
  600.           if line_count < 4
  601.             # Advance index
  602.             @index += 1
  603.             # Number input setup
  604.             $game_temp.num_input_start = line_count
  605.             $game_temp.num_input_variable_id = @list[@index].parameters[0]
  606.             $game_temp.num_input_digits_max = @list[@index].parameters[1]
  607.           end
  608.         end
  609.         # Continue
  610.         return true
  611.       end
  612.       # Advance index
  613.       @index += 1
  614.     end
  615.   end
  616.   #--------------------------------------------------------------------------
  617.   # * Show Choices
  618.   #--------------------------------------------------------------------------
  619.   def command_102
  620.     # If text has been set to message_text
  621.     if $game_temp.message_text != nil
  622.       # End
  623.       return false
  624.     end
  625.    
  626.     if $game_temp.skip_next_choices > 0
  627.       # skip this one, it is part of another
  628.       $game_temp.skip_next_choices -= 1
  629.       @offset += 4
  630.       @index += 1
  631.       return false
  632.     else
  633.       @offset = 0
  634.     end
  635.     # Set message end waiting flag and callback
  636.     @message_waiting = true
  637.     $game_temp.message_proc = Proc.new { @message_waiting = false }
  638.     # Choices setup
  639.     $game_temp.message_text = ""
  640.     $game_temp.choice_start = 0
  641.     setup_choices(@parameters)
  642.     # Continue
  643.     return true
  644.   end
  645.   #--------------------------------------------------------------------------
  646.   # * Setup Choices
  647.   #--------------------------------------------------------------------------
  648.   def setup_choices(parameters)
  649.     params = parameters.clone
  650.     @offset = 0
  651.     i = @index
  652.     curr = 1
  653.     while curr < $game_temp.num_choices
  654.       i += 1
  655.       if @list[i].code == 102
  656.         params[0] += @list[i].parameters[0]
  657.         if @list[i].parameters[1] == 5
  658.           @cancel_flag = true
  659.         else
  660.           @cancel_flag = false
  661.         end
  662.         params[1] = @list[i].parameters[1] + (curr * 4)
  663.         curr += 1
  664.       end
  665.     end
  666.    
  667.     # Set choice item count to choice_max
  668.     $game_temp.choice_max = params[0].size
  669.     # Set choice to message_text
  670.     $game_temp.choices = params[0]
  671.     # Set cancel processing
  672.     $game_temp.choice_cancel_type = params[1]
  673.    
  674.     if $game_temp.num_choices != 1
  675.       $game_temp.skip_next_choices = $game_temp.num_choices - 1
  676.       $game_temp.num_choices = 1
  677.     end
  678.    
  679.     # Set callback
  680.     current_indent = @list[@index].indent
  681.     $game_temp.choice_proc = Proc.new { |n| @branch[current_indent] = n }
  682.   end
  683.  
  684.   #--------------------------------------------------------------------------
  685.   # * When [**]
  686.   #--------------------------------------------------------------------------
  687.   def command_402
  688.     # If fitting choices are selected
  689.     if @branch[@list[@index].indent] == @parameters[0]
  690.       # Delete branch data
  691.       @branch.delete(@list[@index].indent)
  692.       # Continue
  693.       return true
  694.     end
  695.     # If it doesn't meet the condition: command skip
  696.     return command_skip
  697.   end
  698.  
  699.   #--------------------------------------------------------------------------
  700.   # * When Cancel
  701.   #--------------------------------------------------------------------------
  702.   def command_403
  703.     # If choices are cancelled
  704.     if @cancel_flag
  705.       # Delete branch data
  706.       @branch.delete(@list[@index].indent)
  707.       # Continue
  708.       return true
  709.     end
  710.     # If it doen't meet the condition: command skip
  711.     return command_skip
  712.   end
  713.  
  714.   #--------------------------------------------------------------------------
  715.   # * Input Number
  716.   #--------------------------------------------------------------------------
  717.   def command_103
  718.     # If text has been set to message_text
  719.     if $game_temp.message_text != nil
  720.       # End
  721.       return false
  722.     end
  723.     # Set message end waiting flag and callback
  724.     @message_waiting = true
  725.     $game_temp.message_proc = Proc.new { @message_waiting = false }
  726.     # Number input setup
  727.     $game_temp.message_text = ""
  728.     $game_temp.num_input_start = 0
  729.     $game_temp.num_input_variable_id = @parameters[0]
  730.     $game_temp.num_input_digits_max = @parameters[1]
  731.     # Continue
  732.     return true
  733.   end
  734.  
  735.   #--------------------------------------------------------------------------
  736.   # * Script
  737.   #--------------------------------------------------------------------------
  738.   def command_355
  739.     # Set first line to script
  740.     script = @list[@index].parameters[0] + "\n"
  741.     # Loop
  742.     loop do
  743.       # If next event command is second line of script or after
  744.       if @list[@index + 1].code == 655
  745.         # Add second line or after to script
  746.         script += @list[@index + 1].parameters[0] + "\n"
  747.       # If event command is not second line or after
  748.       else
  749.         # Abort loop
  750.         break
  751.       end
  752.       # Advance index
  753.       @index += 1
  754.     end
  755.     # Evaluation
  756.     result = eval(script)
  757.  
  758.     # Continue
  759.     return true
  760.   end
  761. end
  762.  
  763. # *****************************************************************************
  764. #  Changes to Window_Message.  This is the bulk of the script
  765. # *****************************************************************************
  766. #==============================================================================
  767. # ** Window_Message
  768. #------------------------------------------------------------------------------
  769. #  This message window is used to display text.
  770. #==============================================================================
  771.  
  772. class Window_Message < Window_Selectable
  773.   #--------------------------------------------------------------------------
  774.   # * Object Initialization
  775.   #--------------------------------------------------------------------------
  776.   def initialize
  777.     # x-coordinate depends on justification
  778.     if $game_system.window_justification == RIGHT
  779.       x = 640 - self.width
  780.     elsif $game_system.window_justification == LEFT
  781.       x = 0
  782.     else # center
  783.       x = (640 - $game_system.window_width) / 2
  784.     end
  785.     # y-coordinate depends on height
  786.     y = 480 - $game_system.window_height - 16
  787.     super(x, y, $game_system.window_width, $game_system.window_height)
  788.     self.contents = Bitmap.new(width - 32, height - 32)
  789.     if $game_system.font == ""
  790.       self.contents.font.name = Font.default_name
  791.     else
  792.       self.contents.font.name = $game_system.font
  793.     end
  794.     self.visible = false
  795.     self.z = 9998
  796.     @fade_in = false
  797.     @fade_out = false
  798.     @contents_showing = false
  799.    
  800.     # face graphic sprite
  801.     @face = Sprite.new
  802.     @face.opacity = 0
  803.     @face.z = self.z + 1
  804.     @face_offset = 0
  805.    
  806.     # choice window
  807.     @choice_window = Window_Choice.new([])
  808.     @choice_window.back_opacity = $game_system.back_opacity
  809.    
  810.     # comic sprite
  811.     @comic = Sprite.new
  812.     @comic.opacity = 0
  813.     @comic.z = self.z + 1
  814.     if $game_system.comic_style == TALK1
  815.       @comic.bitmap = RPG::Cache.windowskin("talk1")
  816.     elsif $game_system.comic_style == TALK2
  817.       @comic.bitmap = RPG::Cache.windowskin("talk2")
  818.     else # thought
  819.       @comic.bitmap = RPG::Cache.windowskin("thought")
  820.     end
  821.    
  822.     # window image sprite
  823.     @window_back = Sprite.new
  824.     @window_back.opacity = 0
  825.     @window_back.z = self.z - 1
  826.     if $game_system.window_image != nil
  827.       @window_back.bitmap = RPG::Cache.windowskin($game_system.window_image)
  828.     end
  829.    
  830.     # name window
  831.     @name_window = Window_Name.new
  832.     @name_window.z = self.z + 1
  833.    
  834.     @pause_time = 0
  835.     @wait = 0
  836.    
  837.     @show = false
  838.    
  839.     @face_frame = 0
  840.   end
  841.   #--------------------------------------------------------------------------
  842.   # * Dispose
  843.   #--------------------------------------------------------------------------
  844.   def dispose
  845.     terminate_message
  846.     $game_temp.message_window_showing = false
  847.     if @input_number_window != nil
  848.       @input_number_window.dispose
  849.     end
  850.     @face.dispose
  851.     @choice_window.dispose
  852.     @comic.dispose
  853.     @name_window.dispose
  854.     super
  855.   end
  856.   #--------------------------------------------------------------------------
  857.   # * Terminate Message
  858.   #--------------------------------------------------------------------------
  859.   def terminate_message
  860.     @show = false
  861.     self.active = false
  862.     self.pause = false
  863.     self.contents.clear
  864.     # Clear showing flag
  865.     @contents_showing = false
  866.     # Call message callback
  867.     if $game_temp.message_proc != nil
  868.       $game_temp.message_proc.call
  869.     end
  870.     # Clear variables related to text, choices, and number input
  871.     $game_temp.message_text = nil
  872.     $game_temp.message_proc = nil
  873.     $game_temp.choice_start = 99
  874.     $game_temp.choice_max = 0
  875.     $game_temp.choice_cancel_type = 0
  876.     $game_temp.choice_proc = nil
  877.     $game_temp.num_input_start = 99
  878.     $game_temp.num_input_variable_id = 0
  879.     $game_temp.num_input_digits_max = 0
  880.     # Open gold window
  881.     if @gold_window != nil
  882.       @gold_window.dispose
  883.       @gold_window = nil
  884.     end
  885.     @choice_window.visible = false
  886.     @choice_window.active = false
  887.     @comic.opacity = 0
  888.     $game_system.slave_windows.each_pair {|name, window|
  889.       if window.show == true
  890.         window.dispose
  891.         $game_system.slave_windows.delete(name)
  892.       end
  893.     }
  894.     @done = false
  895.   end
  896.   #--------------------------------------------------------------------------
  897.   # * Refresh
  898.   #--------------------------------------------------------------------------
  899.   def refresh
  900.     self.contents.clear
  901.     if $game_system.font_color.nil?
  902.       self.contents.font.color = normal_color
  903.     else
  904.       self.contents.font.color = $game_system.font_color
  905.     end
  906.     if $game_system.windowskin != ""  
  907.       self.windowskin = RPG::Cache.windowskin($game_system.windowskin)
  908.     else
  909.       self.windowskin = RPG::Cache.windowskin($data_system.windowskin_name)
  910.     end
  911.     if $game_system.comic_style == TALK1
  912.       @comic.bitmap = RPG::Cache.windowskin("talk1")
  913.     elsif $game_system.comic_style == TALK2
  914.       @comic.bitmap = RPG::Cache.windowskin("talk2")
  915.     else # thought
  916.       @comic.bitmap = RPG::Cache.windowskin("thought")
  917.     end
  918.     @show = true
  919.     @x = @y = 0
  920.  
  921.     # If waiting for a message to be displayed
  922.     if $game_temp.message_text != nil
  923.       @text = $game_temp.message_text
  924.      
  925.       # replace shortcuts with original code
  926.       $game_system.shortcuts.each { |shortcut, code|
  927.         @text.gsub!(shortcut, code)
  928.       }
  929.      
  930.       # VERY first thing.  Check to see if this is being set up as a slave
  931.       #  or independent window.
  932.       if @text.index(/\\[Ss][Ll][Vv]\[(.*?)\]/) != nil
  933.         # is this a new slave window, or a request to display it?
  934.         if !$game_system.slave_windows.has_key?($1.to_s)
  935.           # there is no such slave window yet.  Set it up.
  936.           @text.gsub!(/\\[Ss][Ll][Vv]\[(.*?)\]/, "")
  937.           $game_system.slave_windows[$1.to_s] = Window_Slave.new(@text)
  938.           @text = ""
  939.           @show = false
  940.           terminate_message
  941.           return
  942.         end
  943.       end
  944.       if @text.index(/\\[Ii][Nn][Dd]\[(.*?)\]/) != nil
  945.         # is this a new independent window, or a request to display it?
  946.         if !$game_system.indy_windows.has_key?($1.to_s)
  947.           # there is no such slave window yet.  Set it up.
  948.           @text.gsub!(/\\[Ii][Nn][Dd]\[(.*?)\]/, "")
  949.           $game_system.indy_windows[$1.to_s] = Window_Slave.new(@text)
  950.           @text = ""
  951.           @show = false
  952.           terminate_message
  953.           return
  954.         end
  955.       end
  956.      
  957.       # Control text processing
  958.       begin
  959.         last_text = @text.clone
  960.         @text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  961.       end until @text == last_text
  962.       @text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  963.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  964.       end
  965.      
  966.       # window mode
  967.       if @text.index(/\\[Mm]/) != nil
  968.         if $game_system.ums_mode == NORMAL_MODE
  969.           $game_system.ums_mode = FIT_WINDOW_TO_TEXT
  970.         else
  971.           $game_system.ums_mode = NORMAL_MODE
  972.         end
  973.         @text.gsub!(/\\[Mm]/) { "" }
  974.       end
  975.      
  976.       # window height
  977.       @text.gsub!(/\\[Hh][Ee][Ii][Gg][Hh][Tt]\[([0-9]+)\]/) do
  978.         $game_system.window_height = $1.to_i
  979.         ""
  980.       end
  981.      
  982.       # window width
  983.       @text.gsub!(/\\[Ww][Ii][Dd][Tt][Hh]\[([0-9]+)\]/) do
  984.         $game_system.window_width = $1.to_i
  985.         ""
  986.       end
  987.      
  988.       # justification
  989.       @text.gsub!(/\\[Jj][Rr]/) do
  990.         $game_system.window_justification = RIGHT
  991.         reset_window
  992.         ""
  993.       end
  994.       @text.gsub!(/\\[Jj][Cc]/) do
  995.         $game_system.window_justification = CENTER
  996.         reset_window
  997.         ""
  998.       end      
  999.       @text.gsub!(/\\[Jj][Ll]/) do
  1000.         $game_system.window_justification = LEFT
  1001.         reset_window
  1002.         ""
  1003.       end
  1004.      
  1005.       # face graphics
  1006.       @text.gsub!(/\\[Ff][Aa][Cc][Ee]\[(.*?)\]/) do
  1007.         $game_system.face_graphic = $1.to_s
  1008.         if $1.to_s == ""
  1009.           @face.opacity = 0
  1010.         end
  1011.         ""
  1012.       end
  1013.       @text.gsub!(/\\[Ff][Ll]/) do
  1014.         $game_system.face_graphic_justification = LEFT
  1015.         ""
  1016.       end
  1017.       @text.gsub!(/\\[Ff][Rr]/) do
  1018.         $game_system.face_graphic_justification = RIGHT
  1019.         ""
  1020.       end
  1021.      
  1022.       # event centering
  1023.       @text.gsub!(/\\[Ee]\[([0-9]+)\]/) do
  1024.         $game_system.message_event = $1.to_i
  1025.         ""
  1026.       end
  1027.      
  1028.       # train actor centering
  1029.       @text.gsub!(/\\[Tt][Aa]\[([0-9]+)\]/) do
  1030.         $game_system.train_actor = $1.to_i
  1031.         ""
  1032.       end
  1033.      
  1034.       # comic thingy
  1035.       @text.gsub!(/\\[Tt]1/) do
  1036.         $game_system.comic_style = TALK1
  1037.         @comic.bitmap = RPG::Cache.windowskin("talk1.png")
  1038.         ""
  1039.       end
  1040.       @text.gsub!(/\\[Tt]2/) do
  1041.         $game_system.comic_style = TALK2
  1042.         @comic.bitmap = RPG::Cache.windowskin("talk2.png")
  1043.         ""
  1044.       end
  1045.       @text.gsub!(/\\[Tt][Hh]/) do
  1046.         $game_system.comic_style = THOUGHT
  1047.         @comic.bitmap = RPG::Cache.windowskin("thought.png")
  1048.         ""
  1049.       end
  1050.      
  1051.       # name window
  1052.       @text.gsub!(/\\[Nn][Mm]\[(.*?)\]/) do
  1053.         $game_system.name = $1.to_s
  1054.         if $1.to_s == ""
  1055.           @name_window.visible = false
  1056.           @name_window.dummy_window.visible = false
  1057.         end
  1058.         ""
  1059.       end
  1060.       # name party window
  1061.       @text.gsub!(/\\[Nn][Pp]\[([0-9]+)\]/) do
  1062.         actor = $game_party.actors[$1.to_i]
  1063.         if actor != nil
  1064.           actor.name
  1065.         else
  1066.           ""
  1067.         end
  1068.       end
  1069.      
  1070.       if $game_system.name == ""
  1071.         @name_window.visible = false
  1072.         @name_window.dummy_window.visible = false
  1073.       end
  1074.      
  1075.      
  1076.       # toggle pause
  1077.       @text.gsub!(/\\[Pp][Tt]/) do
  1078.         $game_system.show_pause = !$game_system.show_pause
  1079.         ""
  1080.       end
  1081.      
  1082.       # shaking
  1083.       @text.gsub!(/\\[Ss][Hh][Kk]\[([0-9]+)\]/) do
  1084.         $game_system.shake = $1.to_i
  1085.         ""
  1086.       end
  1087.      
  1088.       # back opacity
  1089.       @text.gsub!(/\\[Bb][Oo][Pp][Cc]\[([0-9]+)\]/) do
  1090.         $game_system.back_opacity = $1.to_i
  1091.         self.back_opacity = $game_system.back_opacity
  1092.         ""
  1093.       end
  1094.      
  1095.       # opacity
  1096.       @text.gsub!(/\\[Oo][Pp][Cc]\[([0-9]+)\]/) do
  1097.         $game_system.opacity = $1.to_i
  1098.         self.opacity = $game_system.opacity
  1099.         ""
  1100.       end
  1101.      
  1102.       # Change "\\\\" to "\000" for convenience
  1103.       @text.gsub!(/\\\\/) { "\000" }
  1104.       # Change "\\C" to "\001" and "\\G" to "\002"
  1105.       @text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  1106.       @text.gsub!(/\\[Gg]/) { "\002" }
  1107.       @text.gsub!(/\\[Cc]\[0x([0123456789abcdef]+)\]/) { "\026[#{$1}]" }
  1108.      
  1109.       # text skip code
  1110.       @text.gsub!(/\\[Ss][Kk][Ii][Pp]/) { "\003" }
  1111.      
  1112.       # ignore code
  1113.       @text.gsub!(/\\[Ii][Gg][Nn][Rr]/) { "\023" }
  1114.      
  1115.       # slave and indy windows
  1116.       @text.gsub!(/\\[Ss][Ll][Vv]\[(.*?)\]/) { "\024[#{$1}]" }
  1117.       @text.gsub!(/\\[Ii][Nn][Dd]\[(.*?)\]/) { "\025[#{$1}]" }
  1118.      
  1119.       # bold and italics
  1120.       @text.gsub!(/\\[Bb]/) { "\004" }
  1121.       @text.gsub!(/\\[Ii]/) { "\005" }
  1122.      
  1123.       # shadow
  1124.       @text.gsub!(/\\[Ss]/) { "\006" }
  1125.      
  1126.       # font
  1127.       @text.gsub!(/\\[Ff][Oo][Nn][Tt]\[(.*?)\]/) { "\007[#{$1}]" }
  1128.      
  1129.       # pause and wait
  1130.       @text.gsub!(/\\[Pp]\[([0-9]+)\]/) { "\010[#{$1}]" }
  1131.       @text.gsub!(/\\[Ww]\[([0-9]+)\]/) { "\011[#{$1}]" }
  1132.      
  1133.       # write speed
  1134.       @text.gsub!(/\\[Ww][Ss]\[([0-9]+)\]/) { "\013[#{$1}]" }
  1135.            
  1136.       # armor, items, skills, and weapons
  1137.       @text.gsub!(/\\[Oo][Aa]\[([0-9]+)\]/) {
  1138.         item = $data_armors[$1.to_i]
  1139.         "\014[#{$1}]" + "  " + item.name
  1140.       }
  1141.       @text.gsub!(/\\[Oo][Ii]\[([0-9]+)\]/) {
  1142.         item = $data_items[$1.to_i]
  1143.         "\015[#{$1}]" + "  " + item.name
  1144.       }
  1145.       @text.gsub!(/\\[Oo][Ss]\[([0-9]+)\]/) {
  1146.         item = $data_skills[$1.to_i]
  1147.         "\016[#{$1}]" + "  " + item.name
  1148.       }
  1149.       @text.gsub!(/\\[Oo][Ww]\[([0-9]+)\]/) {
  1150.         item = $data_weapons[$1.to_i]
  1151.         "\017[#{$1}]" + "  " + item.name
  1152.       }
  1153.      
  1154.       # text justification
  1155.       @text.gsub!(/\\[Tt][Cc]/) { "\020" }
  1156.       @text.gsub!(/\\[Tt][Ll]/) { "\021" }
  1157.       @text.gsub!(/\\[Tt][Rr]/) { "\022" }
  1158.      
  1159.       # Resize the window to fit the contents?
  1160.       if $game_system.ums_mode == FIT_WINDOW_TO_TEXT
  1161.         width = 1
  1162.         text = @text.split("\n")
  1163.         height = 0
  1164.         i = 0
  1165.         for line in text
  1166.           # don't count this line's width if it has the ignr code
  1167.           if !line.include?("\023")
  1168.             width = [width, self.contents.text_size(line).width].max
  1169.             delta = self.contents.text_size(line).height
  1170.             height += delta + (delta * 0.2).to_i
  1171.           end
  1172.         end
  1173.        
  1174.         if $game_system.face_graphic != "" and ($game_system.face_graphic_position == CENTER or $game_system.face_graphic_position == BOTTOM)
  1175.           width += @face.bitmap.width
  1176.           if height < @face.bitmap.height
  1177.             height = @face.bitmap.height - 32
  1178.           end
  1179.         end
  1180.        
  1181.         if height == 0
  1182.           height = 1
  1183.         end
  1184.        
  1185.         self.width = width + 48
  1186.         self.height = height + 48
  1187.         self.contents = Bitmap.new(width + 16, height)
  1188.        
  1189.         if $game_system.font == ""
  1190.           self.contents.font.name = Font.default_name
  1191.         else
  1192.           self.contents.font.name = $game_system.font
  1193.         end
  1194.        
  1195.         if $game_system.font_color.nil?
  1196.           self.contents.font.color = normal_color
  1197.         else
  1198.           self.contents.font.color = $game_system.font_color
  1199.         end
  1200.       else
  1201.         if self.width != $game_system.window_height or self.height != $game_system.window_width
  1202.           self.width = $game_system.window_width
  1203.           self.height = $game_system.window_height
  1204.           self.contents = Bitmap.new(self.width - 32, self.height - 32)
  1205.           if $game_system.font == ""
  1206.             self.contents.font.name = Font.default_name
  1207.           else
  1208.             self.contents.font.name = $game_system.font
  1209.           end
  1210.           if $game_system.font_color.nil?
  1211.             self.contents.font.color = normal_color
  1212.           else
  1213.             self.contents.font.color = $game_system.font_color
  1214.           end
  1215.         end
  1216.       end
  1217.      
  1218.       if $game_system.window_image != nil
  1219.         # figure out how we're going to resize this          
  1220.         @window_back.zoom_x = self.width.to_f / @window_back.bitmap.width
  1221.         @window_back.zoom_y = self.height.to_f / @window_back.bitmap.height
  1222.       end
  1223.      
  1224.       reset_window
  1225.      
  1226.       get_x_value
  1227.      
  1228.       @count = Graphics.frame_count
  1229.       @pause_time = 0
  1230.       @ignore = false
  1231.       @ascending = true
  1232.       @target_x = self.x + $game_system.shake
  1233.       @done = false
  1234.       @face_frame = 0
  1235.       @done = false
  1236.      
  1237.       self.oy = 0
  1238.     end
  1239.    
  1240.    
  1241.   end
  1242.  
  1243.   #--------------------------------------------------------------------------
  1244.   # * Set Window Position and Opacity Level
  1245.   #--------------------------------------------------------------------------
  1246.   def reset_window (change_opacity = true)
  1247.     # x-coordinate depends on justification
  1248.     if $game_system.message_event == -1 and $game_system.train_actor == -1
  1249.       if $game_system.window_justification == RIGHT
  1250.         self.x = 640 - $game_system.window_width
  1251.       elsif $game_system.window_justification == LEFT
  1252.         self.x = 0
  1253.       else # center
  1254.         self.x = (640 - self.width) / 2
  1255.       end
  1256.     elsif $game_system.train_actor >= 0
  1257.       if $game_system.train_actor == 0 or $game_system.train_actor > $game_party.actors.size - 1
  1258.         # center on player
  1259.         event_x = $game_player.screen_x
  1260.       else
  1261.         # center on train actor
  1262.         event_x = $game_train.actors[$game_system.train_actor - 1].screen_x
  1263.       end
  1264.       self.x = event_x - self.width / 2
  1265.       @comic.x = self.x + (self.width / 2) + 4
  1266.     else
  1267.       if $game_system.message_event == 0 or $game_map.events[$game_system.message_event] == nil
  1268.         # center on player
  1269.         event_x = $game_player.screen_x
  1270.       else
  1271.         # center on the event specified
  1272.         event_x = $game_map.events[$game_system.message_event].screen_x
  1273.       end
  1274.       self.x = event_x - self.width / 2
  1275.       @comic.x = self.x + (self.width / 2) + 4
  1276.     end
  1277.    
  1278.     if $game_temp.in_battle
  1279.       self.y = 16
  1280.     else
  1281.       if $game_system.message_event == -1 and $game_system.train_actor == -1
  1282.         case $game_system.message_position
  1283.           when 0  # up
  1284.             self.y = 16
  1285.           when 1  # middle
  1286.             self.y = (480 - $game_system.window_height) / 2
  1287.           when 2  # down
  1288.             self.y = 480 - $game_system.window_height - 24
  1289.         end
  1290.       elsif $game_system.train_actor >= 0
  1291.         if $game_system.train_actor == 0 or $game_system.train_actor > $game_party.actors.size - 1
  1292.           # center on player
  1293.           self.y = $game_player.screen_y - self.height - 48
  1294.         else
  1295.           # center on train actor
  1296.           self.y = $game_train.actors[$game_system.train_actor - 1].screen_y - self.height - 48
  1297.         end
  1298.         @comic.y = self.y + self.height - 2
  1299.         @comic.angle = 0
  1300.       else
  1301.         if $game_system.message_event == 0 or $game_map.events[$game_system.message_event] == nil
  1302.           # above player
  1303.           self.y = $game_player.screen_y - self.height - 48
  1304.         else
  1305.           # above event specified
  1306.           self.y = $game_map.events[$game_system.message_event].screen_y - self.height - 48
  1307.         end
  1308.         @comic.y = self.y + self.height - 2
  1309.         @comic.angle = 0
  1310.       end
  1311.     end
  1312.     if self.y < 0 + ($game_system.name == "" ? 0 : 16)
  1313.       if $game_system.comic_enabled
  1314.         if $game_system.message_event == 0 or $game_map.events[$game_system.message_event] == nil
  1315.           self.y = $game_player.screen_y - 16
  1316.         else
  1317.           self.y = $game_map.events[$game_system.message_event].screen_y - 16
  1318.         end
  1319.         @comic.angle = 180
  1320.         @comic.y = self.y + 2
  1321.         @comic.x = self.x + (self.width / 2) - 4
  1322.       else
  1323.         self.y = 0 + ($game_system.name == "" ? 0 : 16)
  1324.       end
  1325.     elsif self.y > 480 - self.height
  1326.       self.y = 480 - self.height
  1327.     end
  1328.     if self.x < 0
  1329.       self.x = 0
  1330.     elsif self.x > 680 - self.width - 48
  1331.       self.x = 640 - self.width
  1332.     end
  1333.    
  1334.     if change_opacity
  1335.       if $game_system.message_frame == 0 and $game_temp.message_text != ""
  1336.         self.opacity = $game_system.opacity
  1337.       else
  1338.         self.opacity = 0
  1339.       end
  1340.       self.back_opacity = $game_system.back_opacity
  1341.     end
  1342.    
  1343.     # window back stuff
  1344.     if $game_system.window_image != nil
  1345.       @window_back.bitmap = RPG::Cache.windowskin($game_system.window_image)
  1346.       @window_back.x = self.x
  1347.       @window_back.y = self.y
  1348.     end
  1349.    
  1350.       # face stuff
  1351.       if $game_system.face_graphic != ""  
  1352.         # the player has chosen to show a face graphic
  1353.         if @done and $game_system.resting_face != ""
  1354.           @face.bitmap = RPG::Cache.faces($game_system.face_graphic + $game_system.resting_face)
  1355.           if @face_frame * $game_system.face_frame_width >= @face.bitmap.width
  1356.             @face_frame = 0
  1357.           end
  1358.         else
  1359.           @face.bitmap = RPG::Cache.faces($game_system.face_graphic)
  1360.         end
  1361.        
  1362.         # picture y-coordinate
  1363.         if $game_system.face_graphic_position == ABOVE
  1364.           @face.y = self.y - @face.bitmap.height
  1365.           @face_offset = 0
  1366.         elsif $game_system.face_graphic_position == CENTER
  1367.           delta = (@face.bitmap.height - self.height) / 2
  1368.           @face.y = self.y - delta
  1369.           if $game_system.animated_faces
  1370.             @face_offset = $game_system.face_frame_width + 16
  1371.           else
  1372.             @face_offset = @face.bitmap.width + 16
  1373.           end
  1374.         elsif $game_system.face_graphic_position == BOTTOM
  1375.           @face.y = self.y + self.height - @face.bitmap.height
  1376.           if $game_system.animated_faces
  1377.             @face_offset = $game_system.face_frame_width + 16
  1378.           else
  1379.             @face_offset = @face.bitmap.width + 16
  1380.           end
  1381.         else # side
  1382.           delta = (@face.bitmap.height - self.height) / 2
  1383.           @face.y = self.y - delta
  1384.           @face_offset = 0
  1385.         end
  1386.        
  1387.         # picture x-coordinate
  1388.         if $game_system.face_graphic_justification == LEFT
  1389.           if $game_system.face_graphic_position == SIDE
  1390.             @face.x = self.x - @face.bitmap.width
  1391.           else
  1392.             @face.x = self.x + 10
  1393.           end
  1394.         else # right side
  1395.           if $game_system.animated_faces
  1396.             offset = @face.bitmap.width - $game_system.face_frame_width
  1397.           else
  1398.             offset = 0
  1399.           end
  1400.           if $game_system.face_graphic_position == SIDE
  1401.             @face.x = self.x + self.width + offset
  1402.           else
  1403.             @face.x = self.x + self.width - @face.bitmap.width - 10 + offset
  1404.             @face_offset = 0
  1405.           end
  1406.         end
  1407.        
  1408.         if $game_system.animated_faces
  1409.           @face.src_rect = Rect.new(@face_frame * $game_system.face_frame_width, 0, $game_system.face_frame_width, @face.bitmap.height)
  1410.           if @done and $game_system.resting_face != ""
  1411.             pause = $game_system.resting_animation_pause
  1412.           else
  1413.             pause = $game_system.animation_pause
  1414.           end
  1415.           if Graphics.frame_count % pause == 0
  1416.             @animate_face = true
  1417.           end
  1418.           if @animate_face
  1419.             if Graphics.frame_count % 3 == 0
  1420.               @face_frame += 1
  1421.               if @face_frame * $game_system.face_frame_width >= @face.bitmap.width
  1422.                 @face_frame = 0
  1423.                 @animate_face = false
  1424.               end
  1425.             end
  1426.           end
  1427.         end
  1428.       end
  1429.      
  1430.       # name window
  1431.       if $game_system.name != ""
  1432.         @name_window.x = self.x
  1433.         @name_window.y = self.y - 36
  1434.         @name_window.set_name($game_system.name)
  1435.       end
  1436.      
  1437.       # If choice
  1438.     if $game_temp.choice_max > 0
  1439.       @choice_window.set_choices($game_temp.choices)
  1440.       # determine x and y coords for choice window
  1441.       if $game_system.choice_justification == LEFT
  1442.         @choice_window.x = self.x
  1443.       else
  1444.         @choice_window.x = self.x + self.width - @choice_window.width
  1445.       end
  1446.       if $game_system.choice_position == ABOVE
  1447.         # check to make sure there is enough room above the textbox
  1448.         if self.y < @choice_window.height
  1449.           # not enough room above, place below
  1450.           @choice_window.y = self.y + self.height
  1451.         else
  1452.           # draw above
  1453.           @choice_window.y = self.y - @choice_window.height
  1454.         end
  1455.       elsif $game_system.choice_position == BOTTOM
  1456.         # check to make sure there is enough room below the textbox
  1457.         if (480 - self.y - self.height) < @choice_window.height
  1458.           # not enough room below, place above
  1459.           @choice_window.y = self.y - @choice_window.height
  1460.         else
  1461.           # draw below
  1462.           @choice_window.y = self.y + self.height
  1463.         end
  1464.       else # side
  1465.         if $game_system.choice_justification == LEFT
  1466.           # check to make sure there's room on the left side
  1467.           if self.y < @choice_window.width
  1468.             # not enough room on the side, check to make sure there's room below
  1469.             if (480 - self.y - self.height) < @choice_window.height
  1470.               # not enough room below, place above
  1471.               @choice_window.y = self.y - @choice_window.height
  1472.             else
  1473.               # draw below
  1474.               @choice_window.y = self.y + self.height
  1475.             end
  1476.           else
  1477.             # place on the left side
  1478.             @choice_window.y = self.y
  1479.             @choice_window.x = self.x - @choice_window.width
  1480.           end
  1481.         else # right
  1482.           # check to make sure there's room on the right side
  1483.           if (680 - (self.y + self.width)) < @choice_window.width
  1484.             # not enough room on the side, check to make sure there's room below
  1485.             if (480 - self.y - self.height) < @choice_window.height
  1486.               # not enough room below, place above
  1487.               @choice_window.y = self.y - @choice_window.height
  1488.             else
  1489.               # draw below
  1490.               @choice_window.y = self.y + self.height
  1491.             end
  1492.           else
  1493.             # place on the left side
  1494.             @choice_window.y = self.y
  1495.             @choice_window.x = self.x + self.width
  1496.           end
  1497.         end
  1498.       end
  1499.     end
  1500.    
  1501.     # If number input
  1502.     if $game_temp.num_input_variable_id > 0
  1503.       if @input_number_window == nil
  1504.         digits_max = $game_temp.num_input_digits_max
  1505.         number = $game_variables[$game_temp.num_input_variable_id]
  1506.         @input_number_window = Window_InputNumber.new(digits_max)
  1507.         @input_number_window.number = number
  1508.       end
  1509.       # determine x and y coords for number input window
  1510.       if $game_system.choice_justification == LEFT
  1511.         @input_number_window.x = self.x
  1512.       else
  1513.         @input_number_window.x = self.x + self.width - @input_number_window.width
  1514.       end
  1515.       if $game_system.choice_position == ABOVE
  1516.         # check to make sure there is enough room above the textbox
  1517.         if self.y < @input_number_window.height
  1518.           # not enough room above, place below
  1519.           @input_number_window.y = self.y + self.height
  1520.         else
  1521.           # draw above
  1522.           @input_number_window.y = self.y - @choice_window.height
  1523.         end
  1524.       elsif $game_system.choice_position == BOTTOM
  1525.         # check to make sure there is enough room below the textbox
  1526.         if (480 - self.y - self.height) < @input_number_window.height
  1527.           # not enough room below, place above
  1528.           @input_number_window.y = self.y - @input_number_window.height
  1529.         else
  1530.           # draw below
  1531.           @input_number_window.y = self.y + self.height
  1532.         end
  1533.       else # side
  1534.         if $game_system.choice_justification == LEFT
  1535.           # check to make sure there's room on the left side
  1536.           if self.y < @input_number_window.width
  1537.             # not enough room on the side, check to make sure there's room below
  1538.             if (480 - self.y - self.height) < @input_number_window.height
  1539.               # not enough room below, place above
  1540.               @input_number_window.y = self.y - @input_number_window.height
  1541.             else
  1542.               # draw below
  1543.               @input_number_window.y = self.y + self.height
  1544.             end
  1545.           else
  1546.             # place on the left side
  1547.             @input_number_window.y = self.y
  1548.             @input_number_window.x = self.x - @choice_window.width
  1549.           end
  1550.         else # right
  1551.           # check to make sure there's room on the right side
  1552.           if (680 - (self.y + self.width)) < @input_number_window.width
  1553.             # not enough room on the side, check to make sure there's room below
  1554.             if (480 - self.y - self.height) < @input_number_window.height
  1555.               # not enough room below, place above
  1556.               @input_number_window.y = self.y - @input_number_window.height
  1557.             else
  1558.               # draw below
  1559.               @input_number_window.y = self.y + self.height
  1560.             end
  1561.           else
  1562.             # place on the left side
  1563.             @input_number_window.y = self.y
  1564.             @input_number_window.x = self.x + self.width
  1565.           end
  1566.         end
  1567.       end
  1568.     end
  1569.   end
  1570.   #--------------------------------------------------------------------------
  1571.   # * Frame Update
  1572.   #--------------------------------------------------------------------------
  1573.   def update
  1574.     super
  1575.    
  1576.     if (@contents_showing and $game_system.message_event != -1 and $game_system.shake == 0) or $game_system.animated_faces
  1577.       reset_window(false)
  1578.     end
  1579.    
  1580.     if $game_system.shake != 0  # shake the window
  1581.       if @ascending
  1582.         if @target_x != self.x
  1583.           self.x += 1
  1584.         else
  1585.           @ascending = false
  1586.           @target_x = self.x - ($game_system.shake * 2)
  1587.         end
  1588.       else
  1589.         if @target_x != self.x
  1590.           self.x -= 1
  1591.         else
  1592.           @ascending = true
  1593.           @target_x = self.x + ($game_system.shake * 2)
  1594.         end
  1595.       end
  1596.     end
  1597.    
  1598.     @name_window.update
  1599.    
  1600.     if @wait > 0
  1601.       @wait -= 1
  1602.       if @wait == 0
  1603.         terminate_message
  1604.         return
  1605.       end
  1606.     end
  1607.    
  1608.     # If fade in
  1609.     if @fade_in
  1610.       if $game_temp.message_text == ""
  1611.         @fade_in = false
  1612.         return
  1613.       end
  1614.       self.contents_opacity += 24
  1615.       if $game_system.face_graphic != ""
  1616.         @face.opacity += 24
  1617.       end
  1618.       if $game_system.window_image != nil
  1619.         @window_back.opacity += 24
  1620.       end
  1621.       if $game_system.comic_enabled and $game_system.message_event != -1
  1622.         @comic.opacity = self.opacity
  1623.         @comic.visible = self.visible
  1624.       end
  1625.      
  1626.       if $game_system.name != "" and @show
  1627.         @name_window.visible = true
  1628.         if $game_system.name_window
  1629.           @name_window.dummy_window.visible = true
  1630.         end
  1631.       end
  1632.       if @input_number_window != nil
  1633.         @input_number_window.contents_opacity += 24
  1634.       end
  1635.       if self.contents_opacity == 255
  1636.         @fade_in = false
  1637.       end
  1638.       return
  1639.     end
  1640.    
  1641.     # write the text
  1642.     if @text != nil and @text != ""
  1643.       speed = $game_system.write_speed
  1644.       if $game_system.text_mode == ALL_AT_ONCE or $game_temp.in_battle
  1645.         while (c = @text.slice!(/./m)) != nil
  1646.           write_char(c)
  1647.         end
  1648.         $game_system.slave_windows.each_value { |window| window.write_all }
  1649.         return
  1650.       end
  1651.       if $game_system.text_skip
  1652.         if $game_system.skip_mode == WRITE_FASTER and Input.press?(Input::C)
  1653.           # the player is holding the action button, write faster
  1654.           speed /= 3
  1655.         elsif $game_system.skip_mode == WRITE_ALL and Input.trigger?(Input::C)
  1656.           # the player pressed the action button, write all the text
  1657.           while (c = @text.slice!(/./m)) != nil
  1658.             write_char(c)
  1659.           end
  1660.           $game_system.slave_windows.each_value { |window| window.write_all }
  1661.           return
  1662.         end
  1663.       end
  1664.       while @ignore
  1665.         c = @text.slice!(/./m)
  1666.         if c != nil
  1667.           write_char(c)
  1668.         end
  1669.       end
  1670.       if @pause_time > 0
  1671.         @pause_time -= 1
  1672.         return
  1673.       end
  1674.       if Graphics.frame_count - @count >= speed
  1675.         if $game_system.sound_effect != ""
  1676.           Audio.se_play("Audio/SE/" + $game_system.sound_effect, 80, 100)
  1677.         end
  1678.         @count = Graphics.frame_count
  1679.         c = @text.slice!(/./m)
  1680.         if c != nil
  1681.           write_char(c)
  1682.         end
  1683.       end
  1684.       return
  1685.     end
  1686.    
  1687.     if $game_system.animated_faces and $game_system.resting_face != ""
  1688.       @done = true
  1689.     end
  1690.    
  1691.     # If inputting number
  1692.     if @input_number_window != nil
  1693.       @input_number_window.update
  1694.       # Confirm
  1695.       if Input.trigger?(Input::C)
  1696.         $game_system.se_play($data_system.decision_se)
  1697.         $game_variables[$game_temp.num_input_variable_id] =
  1698.           @input_number_window.number
  1699.         $game_map.need_refresh = true
  1700.         # Dispose of number input window
  1701.         @input_number_window.dispose
  1702.         @input_number_window = nil
  1703.         terminate_message
  1704.       end
  1705.       return
  1706.     end
  1707.    
  1708.     if @wait != 0
  1709.       return
  1710.     end
  1711.    
  1712.     # If message is being displayed and contents are all written
  1713.     if @contents_showing
  1714.       # if choice
  1715.       if $game_temp.choice_max > 0
  1716.         if !@choice_window.active
  1717.           @choice_window.visible = true
  1718.           @choice_window.active = true
  1719.           @choice_window.index = 0
  1720.         end
  1721.         @choice_window.update
  1722.       else
  1723.         # If choice isn't being displayed, show pause sign
  1724.         self.pause = $game_system.show_pause
  1725.       end
  1726.         # Cancel
  1727.         if Input.trigger?(Input::B)
  1728.           if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  1729.             $game_system.se_play($data_system.cancel_se)
  1730.             $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  1731.             terminate_message
  1732.           end
  1733.         end
  1734.         # Confirm
  1735.         if Input.trigger?(Input::C) and !(@wait > 0)
  1736.           @done = true
  1737.           $game_system.slave_windows.each_value { |window|
  1738.             window.write_all
  1739.             if !window.done
  1740.               @done = false
  1741.             end
  1742.           }
  1743.           if @done
  1744.             if $game_temp.choice_max > 0
  1745.               $game_system.se_play($data_system.decision_se)
  1746.               $game_temp.choice_proc.call(@choice_window.index)
  1747.             end
  1748.             terminate_message
  1749.           else
  1750.             @finishing_up = true
  1751.           end
  1752.         end
  1753.         return
  1754.       end
  1755.      
  1756.     if @finishing_up
  1757.       $game_system.slave_windows.each_value { |window|
  1758.         if !window.done
  1759.           @done = true
  1760.           break
  1761.         end
  1762.       }
  1763.      
  1764.       if @done = false
  1765.         terminate_message
  1766.       end
  1767.     end
  1768.     # If display wait message or choice exists when not fading out
  1769.     if @fade_out == false and $game_temp.message_text != nil
  1770.       @contents_showing = true
  1771.       $game_temp.message_window_showing = true
  1772.      
  1773.       reset_window
  1774.       refresh
  1775.       Graphics.frame_reset
  1776.       if @show
  1777.         self.visible = true
  1778.       end
  1779.       self.contents_opacity = 0
  1780.       if @input_number_window != nil
  1781.         @input_number_window.contents_opacity = 0
  1782.       end
  1783.       @fade_in = true
  1784.       return
  1785.     end
  1786.     # If message which should be displayed is not shown, but window is visible
  1787.     if self.visible
  1788.       @fade_out = true
  1789.       self.opacity -= 48
  1790.       @name_window.opacity -= 48
  1791.       @comic.opacity -= 48
  1792.       @face.opacity -= 48
  1793.       @window_back.opacity -= 48
  1794.       if self.opacity == 0
  1795.         self.visible = false
  1796.         @face.opacity = 0
  1797.         @window_back.opacity = 0
  1798.         @choice_window.visible = false
  1799.         @choice_window.active = false
  1800.         @comic.opacity = 0
  1801.         @name_window.visible = false
  1802.         @name_window.dummy_window.visible = false
  1803.         @name_window.update
  1804.         @fade_out = false
  1805.         $game_temp.message_window_showing = false
  1806.       end
  1807.       return
  1808.     end
  1809.    
  1810.     if $game_temp.battle_calling or $game_temp.shop_calling or $game_temp.name_calling or $game_temp.menu_calling or $game_temp.save_calling or $game_temp.debug_calling
  1811.      
  1812.         $game_system.indy_windows.each_pair {|name, window|
  1813.           if window.show == true
  1814.             window.dispose
  1815.             $game_system.indy_windows.delete(name)
  1816.           end
  1817.         }
  1818.     end
  1819.   end
  1820.  
  1821.   #--------------------------------------------------------------------------
  1822.   # * Process and write the given character
  1823.   #--------------------------------------------------------------------------
  1824.   def write_char(c)
  1825.     if c == "\000"
  1826.       # Return to original text
  1827.       c = "\\"
  1828.     end
  1829.     # If \C[n]
  1830.     if c == "\001"
  1831.     # Change text color
  1832.       @text.sub!(/\[([0-9]+)\]/, "")
  1833.       color = $1.to_i
  1834.       if color >= 0 and color <= 7
  1835.         self.contents.font.color = text_color(color)
  1836.       end
  1837.       # go to next text
  1838.       return
  1839.     end
  1840.     # If \G
  1841.     if c == "\002"
  1842.       # Make gold window
  1843.       if @gold_window == nil
  1844.         @gold_window = Window_Gold.new
  1845.         @gold_window.x = 560 - @gold_window.width
  1846.         if $game_temp.in_battle
  1847.           @gold_window.y = 192
  1848.         else
  1849.           @gold_window.y = self.y >= 128 ? 32 : 384
  1850.         end
  1851.         @gold_window.opacity = self.opacity
  1852.         @gold_window.back_opacity = self.back_opacity
  1853.       end
  1854.       # go to next text
  1855.       return
  1856.     end
  1857.     # If \skip
  1858.     if c == "\003"
  1859.       # toggle text skipping
  1860.       $game_system.text_skip = !$game_system.text_skip
  1861.       # go to next text
  1862.       return
  1863.     end
  1864.     # If \b
  1865.     if c == "\004"
  1866.       # toggle bold
  1867.       self.contents.font.bold = !self.contents.font.bold
  1868.       # go to next text
  1869.       return
  1870.     end
  1871.     # If \i
  1872.     if c == "\005"
  1873.       # toggle italics
  1874.       self.contents.font.italic = !self.contents.font.italic
  1875.       # go to next text
  1876.       return
  1877.     end
  1878.     # If \s
  1879.     if c == "\006"
  1880.       # toggle shadow
  1881.       $game_system.shadowed_text = !$game_system.shadowed_text
  1882.       # go to next text
  1883.       return
  1884.     end
  1885.     # If \font
  1886.     if c == "\007"
  1887.       # change font
  1888.       @text.sub!(/\[(.*?)\]/, "")
  1889.       font = $1.to_s
  1890.       $game_system.font = font
  1891.       if font == ""
  1892.         self.contents.font.name = Font.default_name
  1893.       else
  1894.         self.contents.font.name = font
  1895.       end
  1896.       # go to next text
  1897.       return
  1898.     end
  1899.     # If \p[n]
  1900.     if c == "\010"
  1901.       @text.sub!(/\[([0-9]+)\]/, "")
  1902.       @pause_time = $1.to_i
  1903.  
  1904.       # go to next text
  1905.       return
  1906.     end
  1907.    
  1908.     # If \w[n]
  1909.     if c == "\011"
  1910.       @text.sub!(/\[([0-9]+)\]/, "")
  1911.       @wait = $1.to_i
  1912.  
  1913.       # go to next text
  1914.       return
  1915.     end
  1916.    
  1917.     # If \ws[n]
  1918.     if c == "\013"
  1919.       @text.sub!(/\[([0-9]+)\]/, "")
  1920.       $game_system.write_speed = $1.to_i
  1921.  
  1922.       # go to next text
  1923.       return
  1924.     end
  1925.     # If \oa[n]
  1926.     if c == "\014"
  1927.       @text.sub!(/\[([0-9]+)\]/, "")
  1928.       index = $1.to_i
  1929.       @text.sub!("  ", "")
  1930.       item = $data_armors[index]
  1931.       # draw the icon
  1932.       icon = RPG::Cache.icon(item.icon_name)
  1933.       line = self.contents.text_size("dj").height
  1934.       self.contents.blt(@x + 4, (@y * line) + 4, icon, Rect.new(0, 0, 24, 24))
  1935.       @x += 24
  1936.  
  1937.       # go to next text
  1938.       return
  1939.     end
  1940.    
  1941.     # If \oi[n]
  1942.     if c == "\015"
  1943.       @text.sub!(/\[([0-9]+)\]/, "")
  1944.       index = $1.to_i
  1945.       @text.sub!("  ", "")
  1946.       item = $data_items[index]
  1947.       # draw the icon
  1948.       icon = RPG::Cache.icon(item.icon_name)
  1949.       line = self.contents.text_size("dj").height
  1950.       self.contents.blt(@x + 4, (@y * line) + 4, icon, Rect.new(0, 0, 24, 24))
  1951.       @x += 24
  1952.  
  1953.       # go to next text
  1954.       return
  1955.     end
  1956.    
  1957.     # If \os[n]
  1958.     if c == "\016"
  1959.       @text.sub!(/\[([0-9]+)\]/, "")
  1960.       index = $1.to_i
  1961.       @text.sub!("  ", "")
  1962.       item = $data_skills[index]
  1963.       # draw the icon
  1964.       icon = RPG::Cache.icon(item.icon_name)
  1965.       line = self.contents.text_size("dj").height
  1966.       self.contents.blt(@x + 2, (@y * line) + 4, icon, Rect.new(0, 0, 24, 24))
  1967.       @x += 24
  1968.  
  1969.       # go to next text
  1970.       return
  1971.     end
  1972.    
  1973.     # If \ow[n]
  1974.     if c == "\017"
  1975.       @text.sub!(/\[([0-9]+)\]/, "")
  1976.       index = $1.to_i
  1977.       @text.sub!("  ", "")
  1978.       item = $data_weapons[index]
  1979.       # draw the icon
  1980.       icon = RPG::Cache.icon(item.icon_name)
  1981.       line = self.contents.text_size("dj").height
  1982.       self.contents.blt(@x + 2, (@y * line) + 4, icon, Rect.new(0, 0, 24, 24))
  1983.       @x += 24
  1984.      
  1985.       # go to next text
  1986.       return
  1987.     end
  1988.    
  1989.     # If \tc
  1990.     if c == "\020"
  1991.       # center justify
  1992.       $game_system.text_justification = CENTER
  1993.       get_x_value
  1994.       # go to next text
  1995.       return
  1996.     end
  1997.    
  1998.     # If \tl
  1999.     if c == "\021"
  2000.       # left justify
  2001.       $game_system.text_justification = LEFT
  2002.       get_x_value
  2003.       # go to next text
  2004.       return
  2005.     end
  2006.    
  2007.     # If \tr
  2008.     if c == "\022"
  2009.       # right justify
  2010.       $game_system.text_justification = RIGHT
  2011.       get_x_value
  2012.       # go to next text
  2013.       return
  2014.     end
  2015.    
  2016.     # If \ignr
  2017.     if c == "\023"
  2018.       # set ignore flage
  2019.       @ignore = true
  2020.       # go to next text
  2021.       return
  2022.     end
  2023.    
  2024.     # if \slv
  2025.     if c == "\024"
  2026.       # we need to show a slave window
  2027.       @text.sub!(/\[(.*?)\]/, "")
  2028.       name = $1.to_s
  2029.       $game_system.slave_windows[name].show = true
  2030.       return
  2031.     end
  2032.    
  2033.     # if \ind
  2034.     if c == "\025"
  2035.       # we need to show a independent window
  2036.       @text.sub!(/\[(.*?)\]/, "")
  2037.       name = $1.to_s
  2038.       if $game_system.indy_windows[name].show
  2039.         $game_system.indy_windows[name].dispose
  2040.         $game_system.indy_windows.delete(name)
  2041.       else
  2042.         $game_system.indy_windows[name].show = true
  2043.       end
  2044.       return
  2045.     end
  2046.    
  2047.     # if \c (hex color)
  2048.     if c == "\026"
  2049.       # convert hex color to RGB
  2050.       @text.sub!(/\[([0123456789abcdef]+)\]/, "")
  2051.       hex_code = $1.to_s
  2052.      
  2053.       red   = ("0x" + hex_code.slice(0..1)).hex
  2054.       blue  = ("0x" + hex_code.slice(2..3)).hex
  2055.       green = ("0x" + hex_code.slice(4..5)).hex
  2056.      
  2057.       self.contents.font.color = Color.new(red, blue, green)
  2058.       return
  2059.     end
  2060.    
  2061.     # If new line text
  2062.     if c == "\n"
  2063.       # Add 1 to y
  2064.       if !@ignore
  2065.         @y += 1
  2066.       end
  2067.       if @text != ""
  2068.         get_x_value
  2069.       end
  2070.       @ignore = false
  2071.  
  2072.       # go to next text
  2073.       return
  2074.     end
  2075.     if @ignore
  2076.       return
  2077.     end
  2078.     # Draw text
  2079.     line = self.contents.text_size("dj").height
  2080.     if $game_system.shadowed_text
  2081.       old_color = self.contents.font.color.clone
  2082.       self.contents.font.color = $game_system.shadow_color    
  2083.       self.contents.draw_text(6 + @x, line * @y + 2, 40, 32, c)
  2084.       self.contents.font.color = old_color
  2085.     end
  2086.     self.contents.draw_text(4 + @x, line * @y, 40, 32, c)
  2087.     # Add x to drawn text width
  2088.     @x += self.contents.text_size(c).width
  2089.   end
  2090.  
  2091.   def get_x_value
  2092.     # text justification - offset for first line
  2093.     if $game_system.text_justification == CENTER
  2094.       # get the length of the current line
  2095.       w = self.contents.text_size(@text.split("\n")[0]).width
  2096.       @x = (self.width - w - 48) / 2
  2097.     elsif $game_system.text_justification == RIGHT
  2098.       # get the length of the current line
  2099.       w = self.contents.text_size(@text.split("\n")[0]).width
  2100.       @x = self.width - w - 48
  2101.     else # left
  2102.       if $game_system.face_graphic == ""
  2103.         @x = 0
  2104.       else
  2105.         @x = @face_offset
  2106.       end
  2107.     end
  2108.   end
  2109.    
  2110. end
  2111.  
  2112. #==============================================================================
  2113. # ** Window_Choice
  2114. #------------------------------------------------------------------------------
  2115. #  This message window is used to display choices.
  2116. #==============================================================================
  2117. class Window_Choice < Window_Selectable
  2118.   def initialize (choices)
  2119.     super(0, 0, 32, choices.size * 32)
  2120.     self.visible = false
  2121.     self.active = false
  2122.     self.z = 9999
  2123.     @index = 0
  2124.     @item_max = choices.size
  2125.     @choices = choices
  2126.     self.contents = Bitmap.new(32, 32)
  2127.     self.opacity = $game_system.opacity
  2128.     self.back_opacity = $game_system.back_opacity
  2129.   end
  2130.  
  2131.   def refresh
  2132.     # determine necessary width
  2133.     width = 64
  2134.     for line in @choices
  2135.       width = [width, (self.contents.text_size(line).width + 48)].max
  2136.     end
  2137.     self.width = width
  2138.     self.height = @choices.size * 32 + 32
  2139.     self.contents = Bitmap.new(width - 32, height - 32)
  2140.     if $game_system.font == ""
  2141.       self.contents.font.name = Font.default_name
  2142.     else
  2143.       self.contents.font.name = $game_system.font
  2144.     end
  2145.     if $game_system.font_color.nil?
  2146.       self.contents.font.color = normal_color
  2147.     else
  2148.       self.contents.font.color = $game_system.font_color
  2149.     end
  2150.     if $game_system.windowskin != ""  
  2151.       self.windowskin = RPG::Cache.windowskin($game_system.windowskin)
  2152.     else
  2153.       self.windowskin = RPG::Cache.windowskin($data_system.windowskin_name)
  2154.     end
  2155.    
  2156.     # draw choices
  2157.     y = 0
  2158.     for line in @choices
  2159.       # Draw text
  2160.       if $game_system.shadowed_text
  2161.         old_color = self.contents.font.color.clone
  2162.         self.contents.font.color = $game_system.shadow_color
  2163.         self.contents.draw_text(6, 32 * y + 2, width, 32, line)
  2164.         self.contents.font.color = old_color
  2165.       end
  2166.       self.contents.draw_text(4, y * 32, width, 32, line)
  2167.       y += 1
  2168.     end
  2169.   end
  2170.      
  2171.   def set_choices(choices)
  2172.     @choices = choices
  2173.     @item_max = @choices.size
  2174.     for choice in @choices
  2175.       choice.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  2176.       choice.gsub!(/\\[Nn]\[([0-9]+)\]/) {
  2177.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  2178.       }
  2179.     end
  2180.     refresh
  2181.   end
  2182. end
  2183.  
  2184. #==============================================================================
  2185. # ** Window_Name
  2186. #------------------------------------------------------------------------------
  2187. #  This window is used to display names above the message window.  Uncomment
  2188. #   and modify the various sections to customize.
  2189. #==============================================================================
  2190. class Window_Name < Window_Base
  2191.   attr_accessor :dummy_window
  2192.  
  2193.   def initialize
  2194.     super(0, 0, 32, 64)
  2195.     self.contents = Bitmap.new(32, 32)
  2196.     self.opacity = 0
  2197.    
  2198.    
  2199.     @dummy_window = Window_Dummy.new
  2200.    
  2201.     self.visible = false
  2202.   end
  2203.  
  2204.   def set_name(name)
  2205.     @name = name
  2206.     refresh
  2207.   end
  2208.  
  2209.   def refresh
  2210.     if @name == nil
  2211.       return
  2212.     end
  2213.     self.width = self.contents.text_size(@name).width + 48
  2214.     self.contents = Bitmap.new(width - 32, height - 32)
  2215.    
  2216.    
  2217.     if $game_system.name_window
  2218.       @dummy_window.x = self.x
  2219.       @dummy_window.y = self.y + 12
  2220.       @dummy_window.set(height - 24, width - 12)
  2221.     end
  2222.    
  2223.     if $game_system.font == ""
  2224.       self.contents.font.name = Font.default_name
  2225.     else
  2226.       self.contents.font.name = $game_system.font
  2227.     end
  2228.     # uncomment this and change the font to give the name window a fancy font
  2229.     #self.contents.font.name = "Ariel"
  2230.     self.contents.font.color = Color.new(0, 0, 0, 255)
  2231.     self.contents.draw_text(0, 0, self.width, 32, @name)
  2232.     self.contents.draw_text(0, 2, self.width, 32, @name)
  2233.     self.contents.draw_text(2, 0, self.width, 32, @name)
  2234.     self.contents.draw_text(2, 2, self.width, 32, @name)
  2235.     # change the color to give the name window a seperate color
  2236.     self.contents.font.color = normal_color
  2237.     self.contents.draw_text(1, 1, self.width, 32, @name)
  2238.   end
  2239.  
  2240.   def visible=(v)
  2241.     if $game_system.name_window
  2242.       @dummy_window.visible = v
  2243.     end
  2244.     super(v)
  2245.   end
  2246.  
  2247.  
  2248.  
  2249.   def update
  2250.     super
  2251.     if $game_system.name_window
  2252.       @dummy_window.x = self.x
  2253.       @dummy_window.y = self.y + 12
  2254.       @dummy_window.update
  2255.     end
  2256.   end
  2257.  
  2258.   def dispose
  2259.     @dummy_window.dispose
  2260.     super
  2261.   end
  2262. end
  2263.  
  2264. class Window_Dummy < Window_Base
  2265.   def initialize
  2266.     super(0, 0, 32, 64)
  2267.     self.z = 9999
  2268.     self.visible = false
  2269.    
  2270.   end
  2271.  
  2272.   def set(height, width)
  2273.     self.height = height
  2274.     self.width = width
  2275.   end
  2276.  
  2277.   def update
  2278.     super
  2279.     if $game_system.windowskin != ""  
  2280.       self.windowskin = RPG::Cache.windowskin($game_system.windowskin)
  2281.     else
  2282.       self.windowskin = RPG::Cache.windowskin($data_system.windowskin_name)
  2283.     end
  2284. #    self.windowskin = RPG::Cache.windowskin('sandstone')
  2285.   end
  2286. end
  2287.  
  2288. #==============================================================================
  2289. # ** Window_Slave
  2290. #------------------------------------------------------------------------------
  2291. #  These are slave windows to the main message window.  They will close when
  2292. #   the user terminates them.  Initial settings are identical to the main
  2293. #   message window, with one exception.  When in normal mode, it will apear
  2294. #   above if the main message is below, below if it is above or centered.  Use
  2295. #   message codes to change the settings for this window.
  2296. #==============================================================================
  2297. class Window_Slave < Window_Base
  2298.   attr_accessor :show
  2299.   attr_reader :done
  2300.  
  2301.   def write_all
  2302.     @write_all = true
  2303.   end
  2304.  
  2305.   #--------------------------------------------------------------------------
  2306.   # * Object Initialization
  2307.   #--------------------------------------------------------------------------
  2308.   def initialize (text)
  2309.     super(0, 0, 33, 33)
  2310.     @text = text
  2311.    
  2312.     # x-coordinate depends on justification
  2313.     if @justification == RIGHT
  2314.       self.x = 640 - self.width
  2315.     elsif @justification == LEFT
  2316.       self.x = 0
  2317.     else # center
  2318.       self.x = (640 - self.width) / 2
  2319.     end
  2320.     # y-coordinate depends on height
  2321.     self.y = 480 - $game_system.window_height - 16
  2322.     self.contents = Bitmap.new(width - 32, height - 32)
  2323.     if $game_system.font == ""
  2324.       self.contents.font.name = Font.default_name
  2325.     else
  2326.       self.contents.font.name = $game_system.font
  2327.     end
  2328.     self.visible = false
  2329.     self.z = 9998
  2330.     @fade_in = false
  2331.     @fade_out = false
  2332.     @contents_showing = false
  2333.    
  2334.     # face graphic sprite
  2335.     @face = Sprite.new
  2336.     @face.opacity = 0
  2337.     @face.z = self.z + 1
  2338.     @face_offset = 0
  2339.    
  2340.     # choice window
  2341.     @choice_window = Window_Choice.new([])
  2342.     @choice_window.back_opacity = $game_system.back_opacity
  2343.    
  2344.     @comic_style = $game_system.comic_style
  2345.     @name = $game_system.name
  2346.    
  2347.     # comic sprite
  2348.     @comic = Sprite.new
  2349.     @comic.opacity = 0
  2350.     @comic.z = self.z + 1
  2351.     if @comic_style == TALK1
  2352.       @comic.bitmap = RPG::Cache.windowskin("talk1")
  2353.     elsif @comic_style == TALK2
  2354.       @comic.bitmap = RPG::Cache.windowskin("talk2")
  2355.     else # thought
  2356.       @comic.bitmap = RPG::Cache.windowskin("thought")
  2357.     end
  2358.    
  2359.    
  2360.    
  2361.     @pause_time = 0
  2362.     @wait = 0
  2363.    
  2364.     @mode = $game_system.ums_mode
  2365.     self.height = $game_system.window_height
  2366.     self.width = $game_system.window_width
  2367.     @justification = $game_system.window_justification
  2368.     @face_graphic = $game_system.face_graphic
  2369.     @face_graphic_justification = $game_system.face_graphic_justification
  2370.     @message_event = $game_system.message_event
  2371.     if $game_system.message_position == 2 # down
  2372.       @message_position = 0
  2373.     else
  2374.       @message_postion = 2
  2375.     end
  2376.     @face_graphic_position = $game_system.face_graphic_position
  2377.     if $game_system.font == ""
  2378.       @font = Font.default_name
  2379.     else
  2380.       @font = $game_system.font
  2381.     end
  2382.     @text_justification = $game_system.text_justification
  2383.    
  2384.     @shake = $game_system.shake
  2385.    
  2386.     @face_frame = 0
  2387.    
  2388.     refresh
  2389.   end
  2390.   #--------------------------------------------------------------------------
  2391.   # * Dispose
  2392.   #--------------------------------------------------------------------------
  2393.   def dispose
  2394.     terminate_message
  2395.     $game_temp.message_window_showing = false
  2396.     if @input_number_window != nil
  2397.       @input_number_window.dispose
  2398.     end
  2399.     @face.dispose
  2400.     @choice_window.dispose
  2401.     @comic.dispose
  2402.     if @name_window != nil
  2403.       @name_window.dispose
  2404.     end
  2405.     super
  2406.   end
  2407.   #--------------------------------------------------------------------------
  2408.   # * Terminate Message
  2409.   #--------------------------------------------------------------------------
  2410.   def terminate_message
  2411.     self.active = false
  2412.     self.pause = false
  2413.     self.contents.clear
  2414.     # Clear showing flag
  2415.     @contents_showing = false
  2416.     # Call message callback
  2417.     if $game_temp.message_proc != nil
  2418.       $game_temp.message_proc.call
  2419.     end
  2420.     # Clear variables related to text, choices, and number input
  2421.     $game_temp.message_text = nil
  2422.     $game_temp.message_proc = nil
  2423.     $game_temp.choice_start = 99
  2424.     $game_temp.choice_max = 0
  2425.     $game_temp.choice_cancel_type = 0
  2426.     $game_temp.choice_proc = nil
  2427.     $game_temp.num_input_start = 99
  2428.     $game_temp.num_input_variable_id = 0
  2429.     $game_temp.num_input_digits_max = 0
  2430.     # Open gold window
  2431.     if @gold_window != nil
  2432.       @gold_window.dispose
  2433.       @gold_window = nil
  2434.     end
  2435.     @choice_window.visible = false
  2436.     @choice_window.active = false
  2437.     @comic.opacity = 0
  2438.   end
  2439.   #--------------------------------------------------------------------------
  2440.   # * Refresh
  2441.   #--------------------------------------------------------------------------
  2442.   def refresh
  2443.    
  2444.     self.contents.clear
  2445.     if $game_system.font_color.nil?
  2446.       self.contents.font.color = normal_color
  2447.     else
  2448.       self.contents.font.color = $game_system.font_color
  2449.     end
  2450.     if $game_system.windowskin != ""  
  2451.       self.windowskin = RPG::Cache.windowskin($game_system.windowskin)
  2452.     else
  2453.       self.windowskin = RPG::Cache.windowskin($data_system.windowskin_name)
  2454.     end
  2455.     @x = @y = 0
  2456.  
  2457.     # If waiting for a message to be displayed
  2458.     if @text != nil
  2459.       # replace shortcuts with original code
  2460.       $game_system.shortcuts.each { |shortcut, code|
  2461.         @text.gsub!(shortcut, code)
  2462.       }
  2463.      
  2464.       # Control text processing
  2465.       begin
  2466.         last_text = @text.clone
  2467.         @text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  2468.       end until @text == last_text
  2469.       @text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  2470.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  2471.       end
  2472.      
  2473.       # window mode
  2474.       if @text.index(/\\[Mm]/) != nil
  2475.         if $game_system.ums_mode == NORMAL_MODE
  2476.           @mode = FIT_WINDOW_TO_TEXT
  2477.         else
  2478.           @mode = NORMAL_MODE
  2479.         end
  2480.         @text.gsub!(/\\[Mm]/) { "" }
  2481.       end
  2482.      
  2483.       # window height
  2484.       @text.gsub!(/\\[Hh][Ee][Ii][Gg][Hh][Tt]\[([0-9]+)\]/) do
  2485.         self.height = $1.to_i
  2486.         ""
  2487.       end
  2488.      
  2489.       # window width
  2490.       @text.gsub!(/\\[Ww][Ii][Dd][Tt][Hh]\[([0-9]+)\]/) do
  2491.         self.width = $1.to_i
  2492.         ""
  2493.       end
  2494.      
  2495.       # justification
  2496.       @text.gsub!(/\\[Jj][Rr]/) do
  2497.         @justification = RIGHT
  2498.         reset_window
  2499.         ""
  2500.       end
  2501.       @text.gsub!(/\\[Jj][Cc]/) do
  2502.         @justification = CENTER
  2503.         reset_window
  2504.         ""
  2505.       end      
  2506.       @text.gsub!(/\\[Jj][Ll]/) do
  2507.         @justification = LEFT
  2508.         reset_window
  2509.         ""
  2510.       end
  2511.      
  2512.       # face graphics
  2513.       @text.gsub!(/\\[Ff][Aa][Cc][Ee]\[(.*?)\]/) do
  2514.         @face_graphic = $1.to_s
  2515.         if $1.to_s == ""
  2516.           @face.opacity = 0
  2517.         end
  2518.         ""
  2519.       end
  2520.       @text.gsub!(/\\[Ff][Ll]/) do
  2521.         @face_graphic_justification = LEFT
  2522.         ""
  2523.       end
  2524.       @text.gsub!(/\\[Ff][Rr]/) do
  2525.         @face_graphic_justification = RIGHT
  2526.         ""
  2527.       end
  2528.      
  2529.       # event centering
  2530.       @text.gsub!(/\\[Ee]\[([0-9]+)\]/) do
  2531.         @message_event = $1.to_i
  2532.         ""
  2533.       end
  2534.      
  2535.       # comic thingy
  2536.       @text.gsub!(/\\[Tt]1/) do
  2537.         @comic_style = TALK1
  2538.         @comic.bitmap = RPG::Cache.windowskin("talk1.png")
  2539.         ""
  2540.       end
  2541.       @text.gsub!(/\\[Tt]2/) do
  2542.         @comic_style = TALK2
  2543.         @comic.bitmap = RPG::Cache.windowskin("talk2.png")
  2544.         ""
  2545.       end
  2546.       @text.gsub!(/\\[Tt][Hh]/) do
  2547.         @comic_style = THOUGHT
  2548.         @comic.bitmap = RPG::Cache.windowskin("thought.png")
  2549.         ""
  2550.       end
  2551.      
  2552.       # name window
  2553.       @text.gsub!(/\\[Nn][Mm]\[(.*?)\]/) do
  2554.         @name = $1.to_s
  2555.         if $1.to_s == "" and @name_window != nil
  2556.           @name_window.visible = false
  2557.         end
  2558.         ""
  2559.       end
  2560.       if @name != ""
  2561.         # name window
  2562.         @name_window = Window_Name.new
  2563.         @name_window.z = self.z + 1
  2564.         @name_window.set_name(@name)
  2565.       end
  2566.      
  2567.       # shaking
  2568.       @text.gsub!(/\\[Ss][Hh][Kk]\[([0-9]+)\]/) do
  2569.         @shake = $1.to_i
  2570.         ""
  2571.       end
  2572.      
  2573.       # back opacity
  2574.       @text.gsub!(/\\[Bb][Oo][Pp][Cc]\[([0-9]+)\]/) do
  2575.         self.back_opacity = $1.to_i
  2576.         ""
  2577.       end
  2578.      
  2579.       # opacity
  2580.       @text.gsub!(/\\[Oo][Pp][Cc]\[([0-9]+)\]/) do
  2581.         self.opacity = $1.to_i
  2582.         ""
  2583.       end
  2584.      
  2585.       # Change "\\\\" to "\000" for convenience
  2586.       @text.gsub!(/\\\\/) { "\000" }
  2587.       # Change "\\C" to "\001" and "\\G" to "\002"
  2588.       @text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  2589.       @text.gsub!(/\\[Gg]/) { "\002" }
  2590.       @text.gsub!(/\\[Cc]\[0x([0123456789abcdef]+)\]/) { "\026[#{$1}]" }
  2591.      
  2592.       # text skip code
  2593.       @text.gsub!(/\\[Ss][Kk][Ii][Pp]/) { "\003" }
  2594.      
  2595.       # ignore code
  2596.       @text.gsub!(/\\[Ii][Gg][Nn][Rr]/) { "\023" }
  2597.      
  2598.       # bold and italics
  2599.       @text.gsub!(/\\[Bb]/) { "\004" }
  2600.       @text.gsub!(/\\[Ii]/) { "\005" }
  2601.      
  2602.       # shadow
  2603.       @text.gsub!(/\\[Ss]/) { "\006" }
  2604.      
  2605.       # font
  2606.       @text.gsub!(/\\[Ff][Oo][Nn][Tt]\[(.*?)\]/) { "\007[#{$1}]" }
  2607.      
  2608.       # pause and wait
  2609.       @text.gsub!(/\\[Pp]\[([0-9]+)\]/) { "\010[#{$1}]" }
  2610.       @text.gsub!(/\\[Ww]\[([0-9]+)\]/) { "\011[#{$1}]" }
  2611.      
  2612.       # write speed
  2613.       @text.gsub!(/\\[Ww][Ss]\[([0-9]+)\]/) { "\013[#{$1}]" }
  2614.            
  2615.       # armor, items, skills, and weapons
  2616.       @text.gsub!(/\\[Oo][Aa]\[([0-9]+)\]/) {
  2617.         item = $data_armors[$1.to_i]
  2618.         "\014[#{$1}]" + "  " + item.name
  2619.       }
  2620.       @text.gsub!(/\\[Oo][Ii]\[([0-9]+)\]/) {
  2621.         item = $data_items[$1.to_i]
  2622.         "\015[#{$1}]" + "  " + item.name
  2623.       }
  2624.       @text.gsub!(/\\[Oo][Ss]\[([0-9]+)\]/) {
  2625.         item = $data_skills[$1.to_i]
  2626.         "\016[#{$1}]" + "  " + item.name
  2627.       }
  2628.       @text.gsub!(/\\[Oo][Ww]\[([0-9]+)\]/) {
  2629.         item = $data_weapons[$1.to_i]
  2630.         "\017[#{$1}]" + "  " + item.name
  2631.       }
  2632.      
  2633.       # text justification
  2634.       @text.gsub!(/\\[Tt][Cc]/) { "\020" }
  2635.       @text.gsub!(/\\[Tt][Ll]/) { "\021" }
  2636.       @text.gsub!(/\\[Tt][Rr]/) { "\022" }
  2637.      
  2638.       # Resize the window to fit the contents?
  2639.       if @mode == FIT_WINDOW_TO_TEXT
  2640.         width = 1
  2641.         text = @text.split("\n")
  2642.         height = 0
  2643.         i = 0
  2644.         for line in text
  2645.           # don't count this line's width if it has the ignr code
  2646.           if !line.include?("\023")
  2647.             width = [width, self.contents.text_size(line).width].max
  2648.             delta = self.contents.text_size(line).height
  2649.             height += delta + (6 * i) + 3
  2650.             if i < 3
  2651.               i += 1
  2652.             end
  2653.           end
  2654.         end
  2655.        
  2656.         if @face_graphic != "" and ($game_system.face_graphic_position == CENTER or $game_system.face_graphic_position == BOTTOM)
  2657.           width += @face.bitmap.width
  2658.           if height < @face.bitmap.height
  2659.             height = @face.bitmap.height - 32
  2660.           end
  2661.         end
  2662.        
  2663.         if height == 0
  2664.           height = 1
  2665.         end
  2666.          
  2667.         self.width = width + 48
  2668.         self.height = height + 48
  2669.         self.contents = Bitmap.new(width + 16, height)
  2670.         if $game_system.font == ""
  2671.           self.contents.font.name = Font.default_name
  2672.         else
  2673.           self.contents.font.name = $game_system.font
  2674.         end
  2675.         if $game_system.font_color.nil?
  2676.           self.contents.font.color = normal_color
  2677.         else
  2678.           self.contents.font.color = $game_system.font_color
  2679.         end
  2680.  
  2681.       else
  2682.         if self.width != $game_system.window_height or self.height != $game_system.window_width
  2683.           self.width = $game_system.window_width
  2684.           self.height = $game_system.window_height
  2685.           self.contents = Bitmap.new(self.width - 32, self.height - 32)
  2686.           if $game_system.font == ""
  2687.             self.contents.font.name = Font.default_name
  2688.           else
  2689.             self.contents.font.name = $game_system.font
  2690.           end
  2691.           if $game_system.font_color.nil?
  2692.             self.contents.font.color = normal_color
  2693.           else
  2694.             self.contents.font.color = $game_system.font_color
  2695.           end
  2696.         end
  2697.       end
  2698.      
  2699.       reset_window
  2700.      
  2701.       get_x_value
  2702.      
  2703.       @count = Graphics.frame_count
  2704.       @pause_time = 0
  2705.       @ignore = false
  2706.       @done = false
  2707.       @face_frame = 0
  2708.     end
  2709.    
  2710.    
  2711.    
  2712.     # If number input
  2713.     if $game_temp.num_input_variable_id > 0
  2714.       digits_max = $game_temp.num_input_digits_max
  2715.       number = $game_variables[$game_temp.num_input_variable_id]
  2716.       @input_number_window = Window_InputNumber.new(digits_max)
  2717.       @input_number_window.number = number
  2718.       @input_number_window.x = self.x + 8
  2719.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  2720.     end
  2721.   end
  2722.   #--------------------------------------------------------------------------
  2723.   # * Set Window Position and Opacity Level
  2724.   #--------------------------------------------------------------------------
  2725.   def reset_window (change_opacity = true)
  2726.     # x-coordinate depends on justification
  2727.     if @message_event == -1
  2728.       if @justification == RIGHT
  2729.         self.x = 640 - self.width
  2730.       elsif @justification == LEFT
  2731.         self.x = 0
  2732.       else # center
  2733.         self.x = (640 - self.width) / 2
  2734.       end
  2735.     else
  2736.       if @message_event == 0 or $game_map.events[@message_event] == nil
  2737.         # center on player
  2738.         event_x = $game_player.screen_x
  2739.       else
  2740.         # center on the event specified
  2741.         event_x = $game_map.events[@message_event].screen_x
  2742.       end
  2743.       self.x = event_x - self.width / 2
  2744.       @comic.x = self.x + (self.width / 2) + 4
  2745.     end
  2746.    
  2747.     if $game_temp.in_battle
  2748.       self.y = 16
  2749.     else
  2750.       if @message_event == -1
  2751.         case @message_position
  2752.           when 0  # up
  2753.             self.y = 16
  2754.           when 1  # middle
  2755.             self.y = (480 - self.height) / 2
  2756.           when 2  # down
  2757.             self.y = 480 - self.height - 24
  2758.         end
  2759.       else
  2760.         if @message_event == 0 or $game_map.events[@message_event] == nil
  2761.           # above player
  2762.           self.y = $game_player.screen_y - self.height - 48
  2763.         else
  2764.           # above event specified
  2765.           self.y = $game_map.events[@message_event].screen_y - self.height - 48
  2766.         end
  2767.         @comic.y = self.y + self.height - 2
  2768.       end
  2769.     end
  2770.     if self.y < 0 + (@name == "" ? 0 : 16)
  2771.       self.y = 0 + (@name == "" ? 0 : 16)
  2772.     elsif self.y > 480 - self.height
  2773.       self.y = 480 - self.height
  2774.     end
  2775.     if self.x < 0
  2776.       self.x = 0
  2777.     elsif self.x > 680 - self.width - 48
  2778.       self.x = 640 - self.width
  2779.     end
  2780.    
  2781.     if change_opacity
  2782.       if $game_system.message_frame == 0
  2783.         self.opacity = 255
  2784.       else
  2785.         self.opacity = 0
  2786.       end
  2787.       self.back_opacity = $game_system.back_opacity
  2788.     end
  2789.    
  2790.     # face stuff
  2791.       if @face_graphic != ""  
  2792.         # the player has chosen to show a face graphic
  2793.         if @done and $game_system.resting_face != ""
  2794.           @face.bitmap = RPG::Cache.picture(@face_graphic + $game_system.resting_face)
  2795.           if @face_frame * $game_system.face_frame_width >= @face.bitmap.width
  2796.             @face_frame = 0
  2797.           end
  2798.         else
  2799.           @face.bitmap = RPG::Cache.picture(@face_graphic)
  2800.         end
  2801.        
  2802.         # picture y-coordinate
  2803.         if @face_graphic_position == ABOVE
  2804.           @face.y = self.y - @face.bitmap.height
  2805.           @face_offset = 0
  2806.         elsif @face_graphic_position == CENTER
  2807.           delta = (@face.bitmap.height - self.height) / 2
  2808.           @face.y = self.y - delta
  2809.           if $game_system.animated_faces
  2810.             @face_offset = $game_system.face_frame_width + 16
  2811.           else
  2812.             @face_offset = @face.bitmap.width + 16
  2813.           end
  2814.         elsif @face_graphic_position == BOTTOM
  2815.           @face.y = self.y + self.height - @face.bitmap.height
  2816.           if $game_system.animated_faces
  2817.             @face_offset = $game_system.face_frame_width + 16
  2818.           else
  2819.             @face_offset = @face.bitmap.width + 16
  2820.           end
  2821.         else # side
  2822.           delta = (@face.bitmap.height - self.height) / 2
  2823.           @face.y = self.y - delta
  2824.           @face_offset = 0
  2825.         end
  2826.        
  2827.         # picture x-coordinate
  2828.         if @face_graphic_justification == LEFT
  2829.           if @face_graphic_position == SIDE
  2830.             @face.x = self.x - @face.bitmap.width
  2831.           else
  2832.             @face.x = self.x + 10
  2833.           end
  2834.         else
  2835.           if $game_system.animated_faces
  2836.             offset = @face.bitmap.width - $game_system.face_frame_width
  2837.           else
  2838.             offset = 0
  2839.           end
  2840.           if @face_graphic_position == SIDE
  2841.             @face.x = self.x + self.width + offset
  2842.           else
  2843.             @face.x = self.x + self.width - @face.bitmap.width - 10 + offset
  2844.             @face_offset = 0
  2845.           end
  2846.         end
  2847.        
  2848.         if $game_system.animated_faces
  2849.           @face.src_rect = Rect.new(@face_frame * $game_system.face_frame_width, 0, $game_system.face_frame_width, @face.bitmap.height)
  2850.           if @done and $game_system.resting_face != ""
  2851.             pause = $game_system.resting_animation_pause
  2852.           else
  2853.             pause = $game_system.animation_pause
  2854.           end
  2855.           if Graphics.frame_count % pause == 0
  2856.             @animate_face = true
  2857.           end
  2858.           if @animate_face
  2859.             if Graphics.frame_count % 3 == 0
  2860.               @face_frame += 1
  2861.               if @face_frame * $game_system.face_frame_width >= @face.bitmap.width
  2862.                 @face_frame = 0
  2863.                 @animate_face = false
  2864.               end
  2865.             end
  2866.           end
  2867.         end
  2868.       end
  2869.      
  2870.       # name window
  2871.       if @name != "" and @name != nil
  2872.         @name_window.set_name(@name)
  2873.         @name_window.x = self.x
  2874.         @name_window.y = self.y - 36
  2875.       end
  2876.      
  2877.       # If choice
  2878.     if $game_temp.choice_max > 0
  2879.       @choice_window.set_choices($game_temp.choices)
  2880.       # determine x and y coords for choice window
  2881.       if $game_system.choice_justification == LEFT
  2882.         @choice_window.x = self.x
  2883.       else
  2884.         @choice_window.x = self.x + self.width - @choice_window.width
  2885.       end
  2886.       if $game_system.choice_position == ABOVE
  2887.         # check to make sure there is enough room above the textbox
  2888.         if self.y < @choice_window.height
  2889.           # not enough room above, place below
  2890.           @choice_window.y = self.y + self.height
  2891.         else
  2892.           # draw above
  2893.           @choice_window.y = self.y - @choice_window.height
  2894.         end
  2895.       elsif $game_system.choice_position == BOTTOM
  2896.         # check to make sure there is enough room below the textbox
  2897.         if (480 - self.y - self.height) < @choice_window.height
  2898.           # not enough room below, place above
  2899.           @choice_window.y = self.y - @choice_window.height
  2900.         else
  2901.           # draw below
  2902.           @choice_window.y = self.y + self.height
  2903.         end
  2904.       else # side
  2905.         if $game_system.choice_justification == LEFT
  2906.           # check to make sure there's room on the left side
  2907.           if self.y < @choice_window.width
  2908.             # not enough room on the side, check to make sure there's room below
  2909.             if (480 - self.y - self.height) < @choice_window.height
  2910.               # not enough room below, place above
  2911.               @choice_window.y = self.y - @choice_window.height
  2912.             else
  2913.               # draw below
  2914.               @choice_window.y = self.y + self.height
  2915.             end
  2916.           else
  2917.             # place on the left side
  2918.             @choice_window.y = self.y
  2919.             @choice_window.x = self.x - @choice_window.width
  2920.           end
  2921.         else # right
  2922.           # check to make sure there's room on the right side
  2923.           if (680 - (self.y + self.width)) < @choice_window.width
  2924.             # not enough room on the side, check to make sure there's room below
  2925.             if (480 - self.y - self.height) < @choice_window.height
  2926.               # not enough room below, place above
  2927.               @choice_window.y = self.y - @choice_window.height
  2928.             else
  2929.               # draw below
  2930.               @choice_window.y = self.y + self.height
  2931.             end
  2932.           else
  2933.             # place on the left side
  2934.             @choice_window.y = self.y
  2935.             @choice_window.x = self.x + self.width
  2936.           end
  2937.         end
  2938.       end
  2939.     end
  2940.   end
  2941.   #--------------------------------------------------------------------------
  2942.   # * Frame Update
  2943.   #--------------------------------------------------------------------------
  2944.   def update
  2945.     super
  2946.    
  2947.     if !@show
  2948.       return
  2949.     else
  2950.       self.visible = true
  2951.       if @face_graphic != ""
  2952.         @face.opacity = 255
  2953.       end
  2954.       if $game_system.comic_enabled and @message_event != -1
  2955.         @comic.opacity = 255
  2956.       end
  2957.       if @name != ""
  2958.         @name_window.visible = true
  2959.         if $game_system.name_window
  2960.           @name_window.dummy_window.visible = true
  2961.         end
  2962.       end
  2963.       if @input_number_window != nil
  2964.         @input_number_window.contents_opacity = 255
  2965.       end
  2966.       reset_window
  2967.     end
  2968.    
  2969.    
  2970.     if (@contents_showing and $game_system.message_event != -1 and @shake == 0) or $game_system.animated_faces
  2971.       reset_window(false)
  2972.     end
  2973.    
  2974.     if $game_system.shake != 0  # shake the window
  2975.       if @ascending
  2976.         if @target_x != self.x
  2977.           self.x += 1
  2978.         else
  2979.           @ascending = false
  2980.           @target_x = self.x - ($game_system.shake * 2)
  2981.         end
  2982.       else
  2983.         if @target_x != self.x
  2984.           self.x -= 1
  2985.         else
  2986.           @ascending = true
  2987.           @target_x = self.x + ($game_system.shake * 2)
  2988.         end
  2989.       end
  2990.     end
  2991.    
  2992.     if @wait > 0
  2993.       @wait -= 1
  2994.       if @wait == 0
  2995.         terminate_message
  2996.         return
  2997.       end
  2998.     end
  2999.    
  3000.     # If fade in
  3001.     if @fade_in
  3002.       self.contents_opacity += 24
  3003.       if @face_graphic != ""
  3004.         @face.opacity += 24
  3005.       end
  3006.       if $game_system.comic_enabled and @message_event != -1
  3007.         @comic.opacity += 24
  3008.       end
  3009.       if @name != ""
  3010.         @name_window.visible = true
  3011.       end
  3012.       if @input_number_window != nil
  3013.         @input_number_window.contents_opacity += 24
  3014.       end
  3015.       if self.contents_opacity == 255
  3016.         @fade_in = false
  3017.       end
  3018.       return
  3019.     end
  3020.    
  3021.     # write the text
  3022.     if @text != nil and @text != ""
  3023.       speed = $game_system.write_speed
  3024.       if $game_system.text_skip
  3025.         if $game_system.skip_mode == WRITE_FASTER and Input.press?(Input::C)
  3026.           # the player is holding the action button, write faster
  3027.           speed /= 3
  3028.         elsif $game_system.skip_mode == WRITE_ALL and @write_all
  3029.           # the player pressed the action button, write all the text
  3030.           while (c = @text.slice!(/./m)) != nil
  3031.             write_char(c)
  3032.           end
  3033.           return
  3034.         end
  3035.       end
  3036.       while @ignore
  3037.         c = @text.slice!(/./m)
  3038.         if c != nil
  3039.           write_char(c)
  3040.         end
  3041.       end
  3042.       if @pause_time > 0
  3043.         @pause_time -= 1
  3044.         return
  3045.       end
  3046.       if Graphics.frame_count - @count >= speed
  3047.         if $game_system.sound_effect != ""
  3048.           Audio.se_play("Audio/SE/" + $game_system.sound_effect, 80, 100)
  3049.         end
  3050.         @count = Graphics.frame_count
  3051.         c = @text.slice!(/./m)
  3052.         if c != nil
  3053.           write_char(c)
  3054.         end
  3055.       end
  3056.       return
  3057.     end
  3058.    
  3059.     @done = true
  3060.    
  3061.     # If inputting number
  3062.     if @input_number_window != nil
  3063.       @input_number_window.update
  3064.       # Confirm
  3065.       if Input.trigger?(Input::C)
  3066.         $game_system.se_play($data_system.decision_se)
  3067.         $game_variables[$game_temp.num_input_variable_id] =
  3068.           @input_number_window.number
  3069.         $game_map.need_refresh = true
  3070.         # Dispose of number input window
  3071.         @input_number_window.dispose
  3072.         @input_number_window = nil
  3073.         terminate_message
  3074.       end
  3075.       return
  3076.     end
  3077.    
  3078.     if @wait != 0
  3079.       return
  3080.     end
  3081.    
  3082.     # If message is being displayed and contents are all written
  3083.     if @contents_showing
  3084.       # if choice
  3085.       if $game_temp.choice_max > 0
  3086.         if !@choice_window.active
  3087.           @choice_window.visible = true
  3088.           @choice_window.active = true
  3089.           @choice_window.index = 0
  3090.         end
  3091.         @choice_window.update
  3092.       else
  3093.         # If choice isn't being displayed, show pause sign
  3094.         self.pause = true
  3095.       end
  3096.       return
  3097.     end
  3098.   end
  3099.  
  3100.   #--------------------------------------------------------------------------
  3101.   # * Process and write the given character
  3102.   #--------------------------------------------------------------------------
  3103.   def write_char(c)
  3104.     if c == "\000"
  3105.       # Return to original text
  3106.       c = "\\"
  3107.     end
  3108.     # If \C[n]
  3109.     if c == "\001"
  3110.     # Change text color
  3111.       @text.sub!(/\[([0-9]+)\]/, "")
  3112.       color = $1.to_i
  3113.       if color >= 0 and color <= 7
  3114.         self.contents.font.color = text_color(color)
  3115.       end
  3116.       # go to next text
  3117.       return
  3118.     end
  3119.     # If \G
  3120.     if c == "\002"
  3121.       # Make gold window
  3122.       if @gold_window == nil
  3123.         @gold_window = Window_Gold.new
  3124.         @gold_window.x = 560 - @gold_window.width
  3125.         if $game_temp.in_battle
  3126.           @gold_window.y = 192
  3127.         else
  3128.           @gold_window.y = self.y >= 128 ? 32 : 384
  3129.         end
  3130.         @gold_window.opacity = self.opacity
  3131.         @gold_window.back_opacity = self.back_opacity
  3132.       end
  3133.       # go to next text
  3134.       return
  3135.     end
  3136.     # If \skip
  3137.     if c == "\003"
  3138.       # toggle text skipping
  3139.       #$game_system.text_skip = !$game_system.text_skip
  3140.       # go to next text
  3141.       return
  3142.     end
  3143.     # If \b
  3144.     if c == "\004"
  3145.       # toggle bold
  3146.       self.contents.font.bold = !self.contents.font.bold
  3147.       # go to next text
  3148.       return
  3149.     end
  3150.     # If \i
  3151.     if c == "\005"
  3152.       # toggle italics
  3153.       self.contents.font.italic = !self.contents.font.italic
  3154.       # go to next text
  3155.       return
  3156.     end
  3157.     # If \s
  3158.     if c == "\006"
  3159.       # toggle shadow
  3160.       #$game_system.shadowed_text = !$game_system.shadowed_text
  3161.       # go to next text
  3162.       return
  3163.     end
  3164.     # If \font
  3165.     if c == "\007"
  3166.       # change font
  3167.       @text.sub!(/\[(.*?)\]/, "")
  3168.       font = $1.to_s
  3169.       @font = font
  3170.       if font == ""
  3171.         self.contents.font.name = Font.default_name
  3172.       else
  3173.         self.contents.font.name = font
  3174.       end
  3175.       # go to next text
  3176.       return
  3177.     end
  3178.     # If \p[n]
  3179.     if c == "\010"
  3180.       @text.sub!(/\[([0-9]+)\]/, "")
  3181.       @pause_time = $1.to_i
  3182.  
  3183.       # go to next text
  3184.       return
  3185.     end
  3186.    
  3187.     # If \w[n]
  3188.     if c == "\011"
  3189.       @text.sub!(/\[([0-9]+)\]/, "")
  3190.       @wait = $1.to_i
  3191.  
  3192.       # go to next text
  3193.       return
  3194.     end
  3195.    
  3196.     # If \ws[n]
  3197.     if c == "\013"
  3198.       @text.sub!(/\[([0-9]+)\]/, "")
  3199.       $game_system.write_speed = $1.to_i
  3200.  
  3201.       # go to next text
  3202.       return
  3203.     end
  3204.     # If \oa[n]
  3205.     if c == "\014"
  3206.       @text.sub!(/\[([0-9]+)\]/, "")
  3207.       index = $1.to_i
  3208.       @text.sub!("  ", "")
  3209.       item = $data_armors[index]
  3210.       # draw the icon
  3211.       icon = RPG::Cache.icon(item.icon_name)
  3212.       self.contents.blt(@x + 2, (@y * 32) + 4, icon, Rect.new(0, 0, 24, 24))
  3213.       @x += 24
  3214.  
  3215.       # go to next text
  3216.       return
  3217.     end
  3218.    
  3219.     # If \oi[n]
  3220.     if c == "\015"
  3221.       @text.sub!(/\[([0-9]+)\]/, "")
  3222.       index = $1.to_i
  3223.       @text.sub!("  ", "")
  3224.       item = $data_items[index]
  3225.       # draw the icon
  3226.       icon = RPG::Cache.icon(item.icon_name)
  3227.       self.contents.blt(@x + 2, (@y * 32) + 4, icon, Rect.new(0, 0, 24, 24))
  3228.       @x += 24
  3229.  
  3230.       # go to next text
  3231.       return
  3232.     end
  3233.    
  3234.     # If \os[n]
  3235.     if c == "\016"
  3236.       @text.sub!(/\[([0-9]+)\]/, "")
  3237.       index = $1.to_i
  3238.       @text.sub!("  ", "")
  3239.       item = $data_skills[index]
  3240.       # draw the icon
  3241.       icon = RPG::Cache.icon(item.icon_name)
  3242.       self.contents.blt(@x + 2, (@y * 32) + 4, icon, Rect.new(0, 0, 24, 24))
  3243.       @x += 24
  3244.  
  3245.       # go to next text
  3246.       return
  3247.     end
  3248.    
  3249.     # If \ow[n]
  3250.     if c == "\017"
  3251.       @text.sub!(/\[([0-9]+)\]/, "")
  3252.       index = $1.to_i
  3253.       @text.sub!("  ", "")
  3254.       item = $data_weapons[index]
  3255.       # draw the icon
  3256.       icon = RPG::Cache.icon(item.icon_name)
  3257.       self.contents.blt(@x + 2, (@y * 32) + 4, icon, Rect.new(0, 0, 24, 24))
  3258.       @x += 24
  3259.      
  3260.       # go to next text
  3261.       return
  3262.     end
  3263.    
  3264.     # If \tc
  3265.     if c == "\020"
  3266.       # center justify
  3267.       @text_justification = CENTER
  3268.       get_x_value
  3269.       # go to next text
  3270.       return
  3271.     end
  3272.    
  3273.     # If \tl
  3274.     if c == "\021"
  3275.       # left justify
  3276.       @text_justification = LEFT
  3277.       get_x_value
  3278.       # go to next text
  3279.       return
  3280.     end
  3281.    
  3282.     # If \tr
  3283.     if c == "\022"
  3284.       # right justify
  3285.       @text_justification = RIGHT
  3286.       get_x_value
  3287.       # go to next text
  3288.       return
  3289.     end
  3290.    
  3291.     # If \ignr
  3292.     if c == "\023"
  3293.       # set ignore flage
  3294.       @ignore = true
  3295.       # go to next text
  3296.       return
  3297.     end
  3298.    
  3299.     # if \c (hex color)
  3300.     if c == "\026"
  3301.       # convert hex color to RGB
  3302.       @text.sub!(/\[([0123456789abcdef]+)\]/, "")
  3303.       hex_code = $1.to_s
  3304.      
  3305.       red   = ("0x" + hex_code.slice(0..1)).hex
  3306.       blue  = ("0x" + hex_code.slice(2..3)).hex
  3307.       green = ("0x" + hex_code.slice(4..5)).hex
  3308.      
  3309.       self.contents.font.color = Color.new(red, blue, green)
  3310.       return
  3311.     end
  3312.    
  3313.     # If new line text
  3314.     if c == "\n"
  3315.       # Add 1 to y
  3316.       if !@ignore
  3317.         @y += 1
  3318.       end
  3319.       if @text != ""
  3320.         get_x_value
  3321.       end
  3322.       @ignore = false
  3323.  
  3324.       # go to next text
  3325.       return
  3326.     end
  3327.     if @ignore
  3328.       return
  3329.     end
  3330.     # Draw text
  3331.     line = self.contents.text_size("dj").height
  3332.     if $game_system.shadowed_text
  3333.       old_color = self.contents.font.color.clone
  3334.       self.contents.font.color = $game_system.shadow_color
  3335.       self.contents.draw_text(6 + @x, line * @y + 2, 40, 32, c)
  3336.       self.contents.font.color = old_color
  3337.     end
  3338.     self.contents.draw_text(4 + @x, line * @y, 40, 32, c)
  3339.     # Add x to drawn text width
  3340.     @x += self.contents.text_size(c).width
  3341.   end
  3342.  
  3343.   def get_x_value
  3344.     # text justification - offset for first line
  3345.     if @text_justification == CENTER
  3346.       # get the length of the current line
  3347.       w = self.contents.text_size(@text.split("\n")[0]).width
  3348.       @x = (self.width - w - 48) / 2
  3349.     elsif @text_justification == RIGHT
  3350.       # get the length of the current line
  3351.       w = self.contents.text_size(@text.split("\n")[0]).width
  3352.       @x = self.width - w - 48
  3353.     else # left
  3354.       if @face_graphic == ""
  3355.         @x = 0
  3356.       else
  3357.         @x = @face_offset
  3358.       end
  3359.     end
  3360.   end
  3361. end
  3362.  
  3363. #==============================================================================
  3364. # ** Window_InputNumber
  3365. #------------------------------------------------------------------------------
  3366. #  This window is for inputting numbers, and is used within the
  3367. #  message window.
  3368. #==============================================================================
  3369.  
  3370. class Window_InputNumber < Window_Base
  3371.   #--------------------------------------------------------------------------
  3372.   # * Object Initialization
  3373.   #     digits_max : digit count
  3374.   #--------------------------------------------------------------------------
  3375.   def initialize(digits_max)
  3376.     @digits_max = digits_max
  3377.     @number = 0
  3378.     # Calculate cursor width from number width (0-9 equal width and postulate)
  3379.     dummy_bitmap = Bitmap.new(32, 32)
  3380.     @cursor_width = dummy_bitmap.text_size("0").width + 8
  3381.     dummy_bitmap.dispose
  3382.     super(0, 0, @cursor_width * @digits_max + 32, 64)
  3383.     self.contents = Bitmap.new(width - 32, height - 32)
  3384.     if $game_system.font == ""
  3385.       self.contents.font.name = Font.default_name
  3386.     else
  3387.       self.contents.font.name = $game_system.font
  3388.     end
  3389.     self.z += 9999
  3390.     self.opacity = $game_system.opacity
  3391.     self.back_opacity = $game_system.back_opacity
  3392.     @index = 0
  3393.     refresh
  3394.     update_cursor_rect
  3395.   end
  3396.  
  3397.   #--------------------------------------------------------------------------
  3398.   # * Refresh
  3399.   #--------------------------------------------------------------------------
  3400.   def refresh
  3401.     self.contents.clear
  3402.     if $game_system.font_color.nil?
  3403.       self.contents.font.color = normal_color
  3404.     else
  3405.       self.contents.font.color = $game_system.font_color
  3406.     end
  3407.     if $game_system.windowskin != ""  
  3408.       self.windowskin = RPG::Cache.windowskin($game_system.windowskin)
  3409.     else
  3410.       self.windowskin = RPG::Cache.windowskin($data_system.windowskin_name)
  3411.     end
  3412.     s = sprintf("%0*d", @digits_max, @number)
  3413.     for i in 0...@digits_max
  3414.       # Draw text
  3415.       if $game_system.shadowed_text
  3416.         old_color = self.contents.font.color.clone
  3417.         self.contents.font.color = $game_system.shadow_color
  3418.         self.contents.draw_text(i * @cursor_width + 6, 2, 32, 32, s[i,1])
  3419.         self.contents.font.color = old_color
  3420.       end
  3421.       self.contents.draw_text(i * @cursor_width + 4, 0, 32, 32, s[i,1])
  3422.     end
  3423.   end
  3424. end
Expand to see the code.
I'd use Ccoa's script, but sadly it isn't compatible with the name box addon I'm using, basically I type \n[Whatever] and it brings up a seperate box above the message box displaying the text (In this case it's "Whatever"), but while using Ccoa's UMS, it just appears in the message box itself, looking like "\n[Whatever]" followed by the text I want in the actual message box, y'know? I'm either going to need some major edits, or a new script entirely, I'm hoping it won't be too troublesome though.
I fixed my script to work with ccoa's
cocoa's ums edit
(edit: moved to the post below, I think I hit max characters in a post, or something. the UMS is HUGE)

my script-
  1. #==============================================================================
  2. #   Message Name Box
  3. #-----------------------------------------------------------------------------
  4. # made by: Silverwind on HBGames.org
  5. # version: 1.0
  6. #
  7. # How to use:
  8. #  1. add "\N[name]" in the begining of a 'show text' command.
  9. #    for example: \N[Alex]Hi, my name is Alex!
  10. #  2. set the align of the name by a call script saying:
  11. #     $game_temp.name_box_align = 0, 1, or 2
  12. #     where (0..flush left, 1..center, 2..flush right)
  13. #
  14. # edits the following classes
  15. #  * Scene_map
  16. #    create, update and dispose the name-box window.
  17. #    re-writes the methods: initialize, update
  18. #    see lines: 51, 73, 112
  19. #    
  20. #  * Window_Message
  21. #    do not display the name when /N[i] is used
  22. #    re-writes the methods: refresh
  23. #    see lines: 224-231
  24. #
  25. # new classes:
  26. #  * Window_Name_Box
  27. #
  28. # * about Cocoa's UMS:
  29. #  - this works with and without the UMS
  30. #  - to use with the UMS: disable all edits to scene_map and window_message
  31. #    by commenting the '#=begin' '#=end' in and out, in the UMS, and this script
  32. #==============================================================================
  33.  
  34. =begin  # comment out to use w/o the UMS
  35. #==============================================================================
  36. # ** Scene_Map
  37. #------------------------------------------------------------------------------
  38. #  This class performs map screen processing.
  39. #==============================================================================
  40.  
  41.  
  42. class Scene_Map
  43.   #--------------------------------------------------------------------------
  44.   # * Main Processing
  45.   #--------------------------------------------------------------------------
  46.   def main
  47.     # Make sprite set
  48.     @spriteset = Spriteset_Map.new
  49.     # Make message window
  50.     @message_window = Window_Message.new
  51.     @message_name_window = Window_Name_Box.new
  52.     # Transition run
  53.     Graphics.transition
  54.     # Main loop
  55.     loop do
  56.       # Update game screen
  57.       Graphics.update
  58.       # Update input information
  59.       Input.update
  60.       # Frame update
  61.       update
  62.       # Abort loop if screen is changed
  63.       if $scene != self
  64.         break
  65.       end
  66.     end
  67.     # Prepare for transition
  68.     Graphics.freeze
  69.     # Dispose of sprite set
  70.     @spriteset.dispose
  71.     # Dispose of message window
  72.     @message_window.dispose
  73.     @message_name_window.dispose
  74.     # If switching to title screen
  75.     if $scene.is_a?(Scene_Title)
  76.       # Fade out screen
  77.       Graphics.transition
  78.       Graphics.freeze
  79.     end
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # * Frame Update
  83.   #--------------------------------------------------------------------------
  84.   def update
  85.     # Loop
  86.     loop do
  87.       # Update map, interpreter, and player order
  88.       # (this update order is important for when conditions are fulfilled
  89.       # to run any event, and the player isn't provided the opportunity to
  90.       # move in an instant)
  91.       $game_map.update
  92.       $game_system.map_interpreter.update
  93.       $game_player.update
  94.       # Update system (timer), screen
  95.       $game_system.update
  96.       $game_screen.update
  97.       # Abort loop if player isn't place moving
  98.       unless $game_temp.player_transferring
  99.         break
  100.       end
  101.       # Run place move
  102.       transfer_player
  103.       # Abort loop if transition processing
  104.       if $game_temp.transition_processing
  105.         break
  106.       end
  107.     end
  108.     # Update sprite set
  109.     @spriteset.update
  110.     # Update message window
  111.     @message_window.update
  112.     @message_name_window.update
  113.     # If game over
  114.     if $game_temp.gameover
  115.       # Switch to game over screen
  116.       $scene = Scene_Gameover.new
  117.       return
  118.     end
  119.     # If returning to title screen
  120.     if $game_temp.to_title
  121.       # Change to title screen
  122.       $scene = Scene_Title.new
  123.       return
  124.     end
  125.     # If transition processing
  126.     if $game_temp.transition_processing
  127.       # Clear transition processing flag
  128.       $game_temp.transition_processing = false
  129.       # Execute transition
  130.       if $game_temp.transition_name == ""
  131.         Graphics.transition(20)
  132.       else
  133.         Graphics.transition(40, "Graphics/Transitions/" +
  134.           $game_temp.transition_name)
  135.       end
  136.     end
  137.     # If showing message window
  138.     if $game_temp.message_window_showing
  139.       return
  140.     end
  141.     # If encounter list isn't empty, and encounter count is 0
  142.     if $game_player.encounter_count == 0 and $game_map.encounter_list != []
  143.       # If event is running or encounter is not forbidden
  144.       unless $game_system.map_interpreter.running? or
  145.              $game_system.encounter_disabled
  146.         # Confirm troop
  147.         n = rand($game_map.encounter_list.size)
  148.         troop_id = $game_map.encounter_list[n]
  149.         # If troop is valid
  150.         if $data_troops[troop_id] != nil
  151.           # Set battle calling flag
  152.           $game_temp.battle_calling = true
  153.           $game_temp.battle_troop_id = troop_id
  154.           $game_temp.battle_can_escape = true
  155.           $game_temp.battle_can_lose = false
  156.           $game_temp.battle_proc = nil
  157.         end
  158.       end
  159.     end
  160.     # If B button was pressed
  161.     if Input.trigger?(Input::B)
  162.       # If event is running, or menu is not forbidden
  163.       unless $game_system.map_interpreter.running? or
  164.              $game_system.menu_disabled
  165.         # Set menu calling flag or beep flag
  166.         $game_temp.menu_calling = true
  167.         $game_temp.menu_beep = true
  168.       end
  169.     end
  170.     # If debug mode is ON and F9 key was pressed
  171.     if $DEBUG and Input.press?(Input::F9)
  172.       # Set debug calling flag
  173.       $game_temp.debug_calling = true
  174.     end
  175.     # If player is not moving
  176.     unless $game_player.moving?
  177.       # Run calling of each screen
  178.       if $game_temp.battle_calling
  179.         call_battle
  180.       elsif $game_temp.shop_calling
  181.         call_shop
  182.       elsif $game_temp.name_calling
  183.         call_name
  184.       elsif $game_temp.menu_calling
  185.         call_menu
  186.       elsif $game_temp.save_calling
  187.         call_save
  188.       elsif $game_temp.debug_calling
  189.         call_debug
  190.       end
  191.     end
  192.   end
  193.  
  194. end
  195.  
  196. #==============================================================================
  197. # ** Window_Message
  198. #------------------------------------------------------------------------------
  199. #  This message window is used to display text.
  200. #==============================================================================
  201.  
  202. class Window_Message < Window_Selectable
  203.  
  204.   #--------------------------------------------------------------------------
  205.   # * Refresh
  206.   #--------------------------------------------------------------------------
  207.   def refresh
  208.     self.contents.clear
  209.     self.contents.font.color = normal_color
  210.     x = y = 0
  211.     @cursor_width = 0
  212.     # Indent if choice
  213.     if $game_temp.choice_start == 0
  214.       x = 8
  215.     end
  216.     # If waiting for a message to be displayed
  217.     if $game_temp.message_text != nil
  218.       text = $game_temp.message_text
  219.       # Control text processing
  220.       begin
  221.         last_text = text.clone
  222.         text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  223.       end until text == last_text
  224.       #---------------------------------------------------------------------
  225.       # my edit: calculate name from \N[?], replace it with blank space.
  226.       text.gsub!(/\\[Nn]\[(.*?)\]/) do
  227.         name = $1.to_s
  228.         $game_temp.message_name_box = name
  229.         ""
  230.       end
  231.       #----------------------------------------------------------------------
  232.       # Change "\\\\" to "\000" for convenience
  233.       text.gsub!(/\\\\/) { "\000" }
  234.       # Change "\\C" to "\001" and "\\G" to "\002"
  235.       text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  236.       text.gsub!(/\\[Gg]/) { "\002" }
  237.       # Get 1 text character in c (loop until unable to get text)
  238.       while ((c = text.slice!(/./m)) != nil)
  239.         # If \\
  240.         if c == "\000"
  241.           # Return to original text
  242.           c = "\\"
  243.         end
  244.         # If \C[n]
  245.         if c == "\001"
  246.           # Change text color
  247.           text.sub!(/\[([0-9]+)\]/, "")
  248.           color = $1.to_i
  249.           if color >= 0 and color <= 7
  250.             self.contents.font.color = text_color(color)
  251.           end
  252.           # go to next text
  253.           next
  254.         end
  255.         # If \G
  256.         if c == "\002"
  257.           # Make gold window
  258.           if @gold_window == nil
  259.             @gold_window = Window_Gold.new
  260.             @gold_window.x = 560 - @gold_window.width
  261.             if $game_temp.in_battle
  262.               @gold_window.y = 192
  263.             else
  264.               @gold_window.y = self.y >= 128 ? 32 : 384
  265.             end
  266.             @gold_window.opacity = self.opacity
  267.             @gold_window.back_opacity = self.back_opacity
  268.           end
  269.           # go to next text
  270.           next
  271.         end
  272.         # If new line text
  273.         if c == "\n"
  274.           # Update cursor width if choice
  275.           if y >= $game_temp.choice_start
  276.             @cursor_width = [@cursor_width, x].max
  277.           end
  278.           # Add 1 to y
  279.           y += 1
  280.           x = 0
  281.           # Indent if choice
  282.           if y >= $game_temp.choice_start
  283.             x = 8
  284.           end
  285.           # go to next text
  286.           next
  287.         end
  288.         # Draw text
  289.         self.contents.draw_text(4 + x, 32 * y, 40, 32, c)
  290.         # Add x to drawn text width
  291.         x += self.contents.text_size(c).width
  292.       end
  293.     end
  294.     # If choice
  295.     if $game_temp.choice_max > 0
  296.       @item_max = $game_temp.choice_max
  297.       self.active = true
  298.       self.index = 0
  299.     end
  300.     # If number input
  301.     if $game_temp.num_input_variable_id > 0
  302.       digits_max = $game_temp.num_input_digits_max
  303.       number = $game_variables[$game_temp.num_input_variable_id]
  304.       @input_number_window = Window_InputNumber.new(digits_max)
  305.       @input_number_window.number = number
  306.       @input_number_window.x = self.x + 8
  307.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  308.     end
  309.   end
  310.  
  311. end
  312.  
  313. =end  # comment out to use w/o the UMS
  314.  
  315. class Game_Temp
  316.   attr_accessor :message_name_box   # name for message
  317.   attr_accessor :name_box_align     # name box align
  318. end
  319.  
  320. class Window_Name_Box < Window_Selectable
  321.  
  322.   def initialize
  323.     #super(80, 304, 480, 160)
  324.     super(80, 236, 480, 72)
  325.     self.contents = Bitmap.new(width - 32, height - 32)
  326.     self.visible = false
  327.     self.z = 9998
  328.     @fade_in = false
  329.     @fade_out = false
  330.     @contents_showing = false
  331.     @cursor_width = 0
  332.     self.active = false
  333.     self.index = -1
  334.     # center the name by default
  335.     @align = 1
  336.   end
  337.  
  338.   def terminate_message
  339.     self.visible = false
  340.     self.active = false
  341.     self.pause = false
  342.     self.index = -1
  343.     self.contents.clear
  344.     # Clear showing flag
  345.     @contents_showing = false
  346.     # Call message callback
  347.     if $game_temp.message_proc != nil
  348.       $game_temp.message_proc.call
  349.     end
  350.   end
  351.  
  352.   def refresh
  353.     self.contents.clear
  354.     if $game_temp.message_name_box != nil
  355.       @name = $game_temp.message_name_box
  356.       $game_temp.message_name_box = nil
  357.       if $game_temp.name_box_align != nil
  358.         @align = $game_temp.name_box_align
  359.       end
  360.     end
  361.     if @name != nil
  362.       self.visible = true
  363.       x = y = 0
  364.       w = 400
  365.       h = 32
  366.       self.contents.draw_text(4 + x, 32 * y, w, h, @name, @align)
  367.     end
  368.   end
  369.  
  370.   def update
  371.     super
  372.     if $game_temp.message_name_box != nil or @name != nil
  373.       refresh
  374.     end
  375.     if (@name != nil) and not $game_temp.message_window_showing
  376.       terminate_message
  377.       @name = nil
  378.     end
  379.   end
  380.  
  381.   def dispose
  382.     terminate_message
  383.     super
  384.   end
  385.  
  386. end
  387.  
Expand to see the code.

my version of Ccoa's UMS is edited, but it should not affect you as long as you don't use the /actor which I implemented & requires some other script of mine.
ccoa's UMS edited:
  1.  
  2. # *****************************************************************************
  3. # *    Universal Message System
  4. # *      v1.5.0
  5. # *      by Ccoa
  6. # *****************************************************************************
  7. #=begin # comment out to use w/o the UMS
  8.  
  9. # *****************************************************************************
  10. #  CONSTANTS
  11. # *****************************************************************************
  12.  
  13. # modes
  14. NORMAL_MODE        = 0
  15. FIT_WINDOW_TO_TEXT = 1
  16.  
  17. #text modes
  18. ONE_LETTER_AT_A_TIME = 0
  19. ALL_AT_ONCE          = 1
  20.  
  21. # skip modes
  22. WRITE_FASTER = 0
  23. WRITE_ALL    = 1
  24.  
  25. # justifications
  26. RIGHT  = 0
  27. CENTER = 1
  28. LEFT   = 2
  29.  
  30. # positions for extra objects (face graphics, choice box, etc)
  31. ABOVE  = 0  # place the object above the top of the message box
  32. CENTER = 1  # center the object vertically inside the message box
  33. BOTTOM = 2  # place the bottom of the object on the bottom of the message box
  34. SIDE   = 3  # to the side of the message box (which side depends on justification)
  35.  
  36. # comic type
  37. TALK1   = 0
  38. TALK2   = 1
  39. THOUGHT = 2
  40.  
  41. # *****************************************************************************
  42. #  Changes to Game_System.  This allows any changes made to be saved when the
  43. #     game is saved.
  44. # *****************************************************************************
  45.  
  46. class Game_System
  47.   attr_accessor :ums_mode # what mode the UMS is in
  48.   attr_accessor :text_skip # whether or not text skip is activated
  49.   attr_accessor :skip_mode # write the text faster while C is pressed, or just skip to the end
  50.   attr_accessor :write_speed # frame delay between characters
  51.  
  52.   attr_accessor :text_mode # write one letter at a time, or all at once?
  53.  
  54.   attr_accessor :window_height # default height of message window
  55.   attr_accessor :window_width # default width of message window
  56.   attr_accessor :window_justification # default justification of window
  57.  
  58.   attr_accessor :face_graphic # current face graphic
  59.   attr_accessor :face_graphic_justification # justification of face graphic
  60.   attr_accessor :face_graphic_position # position of face graphic
  61.  
  62.   attr_accessor :shadowed_text # whether or not to draw a shadow behind the text
  63.   attr_accessor :shadow_color # the shadow color
  64.  
  65.   attr_accessor :choice_justification # where the choice window is located
  66.   attr_accessor :choice_position # prefered position of choice window
  67.  
  68.   attr_accessor :message_event # what event to center the text over (0 player, -1 to not)
  69.  
  70.   attr_accessor :comic_enabled # using "talk" icons?
  71.   attr_accessor :comic_style   # what type of comic image to use
  72.  
  73.   attr_accessor :name # the text for the name window
  74.   attr_accessor :name_window # should the name window be visible?
  75.  
  76.   attr_accessor :font # the name of the font
  77.   attr_accessor :font_color # the name of the (permanent) font color
  78.  
  79.   attr_accessor :text_justification # the justification of the window text
  80.  
  81.   attr_accessor :show_pause # whether or not to show the pause icon
  82.  
  83.   attr_accessor :shake # the amount of shake for the window
  84.  
  85.   attr_accessor :sound_effect # SE to play with each letter
  86.  
  87.   attr_accessor :slave_windows # hash of slave windows
  88.   attr_accessor :indy_windows  # hash of independent windows
  89.  
  90.   attr_accessor :animated_faces # are the faces animated?
  91.   attr_accessor :animation_pause # how long do I wait between animation loops?
  92.   attr_accessor :face_frame_width # how many pixels wide is each face frame
  93.   attr_accessor :resting_face  # postext for waiting face graphic
  94.   attr_accessor :resting_animation_pause # how long to wait for resting graphic
  95.  
  96.   attr_accessor :windowskin # what windowskin to use for messages
  97.   attr_accessor :back_opacity # back opacity of windowskin
  98.   attr_accessor :opacity # opacity of windowskin
  99.  
  100.   attr_accessor :window_image # image used behind window
  101.  
  102.   attr_reader :shortcuts  # user-defined shortcuts
  103.  
  104.   alias ums_initialize initialize
  105.   def initialize
  106.     ums_initialize
  107.     @ums_mode = NORMAL_MODE
  108.    
  109.     @skip_mode = WRITE_ALL
  110.     @text_skip = true
  111.     @write_speed = 2
  112.    
  113.     @text_mode = ONE_LETTER_AT_A_TIME
  114.    
  115.     @window_height = 128
  116.     @window_width = 480
  117.     @window_justification = CENTER
  118.    
  119.     @face_graphic = ""
  120.     @face_graphic_justification = LEFT
  121.     @face_graphic_position = CENTER
  122.    
  123.     @shadowed_text = false
  124.     @shadow_color = Color.new(0, 0, 0, 100)
  125.    
  126.     @choice_justification = RIGHT
  127.     @choice_position = SIDE
  128.    
  129.     @message_event = -1
  130.    
  131.     @comic_enabled = false
  132.     @comic_style = TALK1
  133.    
  134.     @name = ""
  135.     @name_window = false
  136.    
  137.     @font = "Verdana"
  138.     @font_color = nil
  139.    
  140.     @text_justification = LEFT
  141.    
  142.     @show_pause = true
  143.    
  144.     @shake = 0
  145.    
  146.     @sound_effect = ""
  147.    
  148.     @slave_windows = {}
  149.     @indy_windows  = {}
  150.    
  151.     @animated_faces = false
  152.     @animation_pause = 80
  153.     @face_frame_width = 100
  154.     @resting_face = ""
  155.     @resting_animation_pause = 80
  156.    
  157.     @windowskin = ""
  158.     @opacity = 255
  159.     @back_opacity = 160
  160.    
  161.     @window_image = nil
  162.    
  163.     @used_codes = ['\v', '\n', '\c', '\g', '\skip', '\m', '\height', '\width',
  164.                    '\jr', '\jc', '\jl', '\face', '\fl', '\fr', '\b', '\i', '\s',
  165.                    '\e', '\t1', '\t2', '\th', '\nm', '\font', '\p', '\w', '\ws',
  166.                    '\oa', '\oi', '\os', '\ow', '\tl', '\tr', '\tc', '\ignr',
  167.                    '\shk', '\slv', '\ind', '\inc']
  168.                    
  169.     @shortcuts = {}
  170.   end
  171.  
  172.   def add_shortcut(shortcut, code)
  173.     text = shortcut.downcase
  174.     if !@used_codes.include?(text)
  175.       @shortcuts[shortcut] = code
  176.     end
  177.   end
  178.  
  179.   def open_window(name)
  180.     if $game_system.indy_windows.has_key?(name)
  181.       $game_system.indy_windows[name].show = true
  182.     end
  183.   end
  184.  
  185.   def close_window(name)
  186.     if $game_system.indy_windows.has_key?(name)
  187.       $game_system.indy_windows[name].dispose
  188.       $game_system.indy_windows.delete(name)
  189.     end
  190.   end
  191.  
  192.   #--------------------#
  193.   # silver wind's edit #
  194.   #--------------------#
  195.   def comic_mode()
  196.     @ums_mode = FIT_WINDOW_TO_TEXT
  197.     @comic_enabled = true
  198.     @comic_style = TALK1
  199.   end
  200.  
  201.   def set_ums_to_normal()
  202.     @ums_mode = NORMAL_MODE
  203.     @skip_mode = WRITE_ALL
  204.     @text_skip = true
  205.     @write_speed = 2
  206.     @text_mode = ONE_LETTER_AT_A_TIME
  207.     @window_height = 128
  208.     @window_width = 480
  209.     @window_justification = CENTER
  210.     @face_graphic = ""
  211.     @face_graphic_justification = LEFT
  212.     @face_graphic_position = CENTER
  213.     @shadowed_text = false
  214.     @shadow_color = Color.new(0, 0, 0, 100)
  215.     @choice_justification = RIGHT
  216.     @choice_position = SIDE
  217.     @message_event = -1
  218.     @comic_enabled = false
  219.     @comic_style = TALK1
  220.     @name = ""
  221.     @name_window = false
  222.     @font = "Verdana"
  223.     @font_color = nil
  224.     @text_justification = LEFT
  225.     @show_pause = true
  226.     @shake = 0
  227.     @sound_effect = ""
  228.     @slave_windows = {}
  229.     @indy_windows  = {}
  230.     @animated_faces = false
  231.     @animation_pause = 80
  232.     @face_frame_width = 100
  233.     @resting_face = ""
  234.     @resting_animation_pause = 80
  235.     @windowskin = ""
  236.     @opacity = 255
  237.     @back_opacity = 160
  238.     @window_image = nil
  239.   end
  240.  
  241.  
  242. end
  243.  
  244. #==============================================================================
  245. # ** Game_Temp
  246. #------------------------------------------------------------------------------
  247. #  This class handles temporary data that is not included with save data.
  248. #  Refer to "$game_temp" for the instance of this class.
  249. #==============================================================================
  250. class Game_Temp
  251.   attr_accessor :choices
  252.   attr_accessor :num_choices
  253.   attr_accessor :skip_next_choices
  254.  
  255.   alias old_init initialize
  256.   def initialize
  257.     old_init
  258.     @skip_next_choices = 0
  259.     @num_choices = 1
  260.   end
  261. end
  262.  
  263. class Scene_Map
  264.   alias ums_update update
  265.   def update
  266.     $game_system.slave_windows.each_value { |window| window.update }
  267.     $game_system.indy_windows.each_value { |window| window.update }
  268.     ums_update
  269.   end
  270. end
  271.  
  272. class Interpreter
  273.   #--------------------------------------------------------------------------
  274.   # * Event Command Execution
  275.   #--------------------------------------------------------------------------
  276.   def execute_command
  277.     # If last to arrive for list of event commands
  278.     if @index >= @list.size - 1
  279.       # End event
  280.       command_end
  281.       # Continue
  282.       return true
  283.     end
  284.     # Make event command parameters available for reference via @parameters
  285.     if !(@list[@index].code == 102 and $game_temp.skip_next_choices > 0)
  286.       @parameters = @list[@index].parameters.clone
  287.       if @list[@index].code == 402
  288.         @parameters[0] += @offset
  289.       end
  290.     end
  291.     # Branch by command code
  292.     case @list[@index].code
  293.     when 101  # Show Text
  294.       return command_101
  295.     when 102  # Show Choices
  296.       return command_102
  297.     when 402  # When [**]
  298.       return command_402
  299.     when 403  # When Cancel
  300.       return command_403
  301.     when 103  # Input Number
  302.       return command_103
  303.     when 104  # Change Text Options
  304.       return command_104
  305.     when 105  # Button Input Processing
  306.       return command_105
  307.     when 106  # Wait
  308.       return command_106
  309.     when 111  # Conditional Branch
  310.       return command_111
  311.     when 411  # Else
  312.       return command_411
  313.     when 112  # Loop
  314.       return command_112
  315.     when 413  # Repeat Above
  316.       return command_413
  317.     when 113  # Break Loop
  318.       return command_113
  319.     when 115  # Exit Event Processing
  320.       return command_115
  321.     when 116  # Erase Event
  322.       return command_116
  323.     when 117  # Call Common Event
  324.       return command_117
  325.     when 118  # Label
  326.       return command_118
  327.     when 119  # Jump to Label
  328.       return command_119
  329.     when 121  # Control Switches
  330.       return command_121
  331.     when 122  # Control Variables
  332.       return command_122
  333.     when 123  # Control Self Switch
  334.       return command_123
  335.     when 124  # Control Timer
  336.       return command_124
  337.     when 125  # Change Gold
  338.       return command_125
  339.     when 126  # Change Items
  340.       return command_126
  341.     when 127  # Change Weapons
  342.       return command_127
  343.     when 128  # Change Armor
  344.       return command_128
  345.     when 129  # Change Party Member
  346.       return command_129
  347.     when 131  # Change Windowskin
  348.       return command_131
  349.     when 132  # Change Battle BGM
  350.       return command_132
  351.     when 133  # Change Battle End ME
  352.       return command_133
  353.     when 134  # Change Save Access
  354.       return command_134
  355.     when 135  # Change Menu Access
  356.       return command_135
  357.     when 136  # Change Encounter
  358.       return command_136
  359.     when 201  # Transfer Player
  360.       return command_201
  361.     when 202  # Set Event Location
  362.       return command_202
  363.     when 203  # Scroll Map
  364.       return command_203
  365.     when 204  # Change Map Settings
  366.       return command_204
  367.     when 205  # Change Fog Color Tone
  368.       return command_205
  369.     when 206  # Change Fog Opacity
  370.       return command_206
  371.     when 207  # Show Animation
  372.       return command_207
  373.     when 208  # Change Transparent Flag
  374.       return command_208
  375.     when 209  # Set Move Route
  376.       return command_209
  377.     when 210  # Wait for Move's Completion
  378.       return command_210
  379.     when 221  # Prepare for Transition
  380.       return command_221
  381.     when 222  # Execute Transition
  382.       return command_222
  383.     when 223  # Change Screen Color Tone
  384.       return command_223
  385.     when 224  # Screen Flash
  386.       return command_224
  387.     when 225  # Screen Shake
  388.       return command_225
  389.     when 231  # Show Picture
  390.       return command_231
  391.     when 232  # Move Picture
  392.       return command_232
  393.     when 233  # Rotate Picture
  394.       return command_233
  395.     when 234  # Change Picture Color Tone
  396.       return command_234
  397.     when 235  # Erase Picture
  398.       return command_235
  399.     when 236  # Set Weather Effects
  400.       return command_236
  401.     when 241  # Play BGM
  402.       return command_241
  403.     when 242  # Fade Out BGM
  404.       return command_242
  405.     when 245  # Play BGS
  406.       return command_245
  407.     when 246  # Fade Out BGS
  408.       return command_246
  409.     when 247  # Memorize BGM/BGS
  410.       return command_247
  411.     when 248  # Restore BGM/BGS
  412.       return command_248
  413.     when 249  # Play ME
  414.       return command_249
  415.     when 250  # Play SE
  416.       return command_250
  417.     when 251  # Stop SE
  418.       return command_251
  419.     when 301  # Battle Processing
  420.       return command_301
  421.     when 601  # If Win
  422.       return command_601
  423.     when 602  # If Escape
  424.       return command_602
  425.     when 603  # If Lose
  426.       return command_603
  427.     when 302  # Shop Processing
  428.       return command_302
  429.     when 303  # Name Input Processing
  430.       return command_303
  431.     when 311  # Change HP
  432.       return command_311
  433.     when 312  # Change SP
  434.       return command_312
  435.     when 313  # Change State
  436.       return command_313
  437.     when 314  # Recover All
  438.       return command_314
  439.     when 315  # Change EXP
  440.       return command_315
  441.     when 316  # Change Level
  442.       return command_316
  443.     when 317  # Change Parameters
  444.       return command_317
  445.     when 318  # Change Skills
  446.       return command_318
  447.     when 319  # Change Equipment
  448.       return command_319
  449.     when 320  # Change Actor Name
  450.       return command_320
  451.     when 321  # Change Actor Class
  452.       return command_321
  453.     when 322  # Change Actor Graphic
  454.       return command_322
  455.     when 331  # Change Enemy HP
  456.       return command_331
  457.     when 332  # Change Enemy SP
  458.       return command_332
  459.     when 333  # Change Enemy State
  460.       return command_333
  461.     when 334  # Enemy Recover All
  462.       return command_334
  463.     when 335  # Enemy Appearance
  464.       return command_335
  465.     when 336  # Enemy Transform
  466.       return command_336
  467.     when 337  # Show Battle Animation
  468.       return command_337
  469.     when 338  # Deal Damage
  470.       return command_338
  471.     when 339  # Force Action
  472.       return command_339
  473.     when 340  # Abort Battle
  474.       return command_340
  475.     when 351  # Call Menu Screen
  476.       return command_351
  477.     when 352  # Call Save Screen
  478.       return command_352
  479.     when 353  # Game Over
  480.       return command_353
  481.     when 354  # Return to Title Screen
  482.       return command_354
  483.     when 355  # Script
  484.       return command_355
  485.     else      # Other
  486.       return true
  487.     end
  488.   end
  489.  
  490.   #--------------------------------------------------------------------------
  491.   # * Show Text
  492.   #--------------------------------------------------------------------------
  493.   def command_101
  494.     # If other text has been set to message_text
  495.     if $game_temp.message_text != nil
  496.       # End
  497.       return false
  498.     end
  499.     # Set message end waiting flag and callback
  500.     @message_waiting = true
  501.     $game_temp.message_proc = Proc.new { @message_waiting = false }
  502.     # Set message text on first line
  503.     $game_temp.message_text = @list[@index].parameters[0] + "\n"
  504.     line_count = 1
  505.     # Loop
  506.     loop do
  507.       # If next event command text is on the second line or after
  508.       if @list[@index + 1].code == 401
  509.         # Add the second line or after to message_text
  510.         $game_temp.message_text += @list[@index + 1].parameters[0] + "\n"
  511.         line_count += 1
  512.       # If the next event command is show text
  513.       elsif @list[@index + 1].code == 101
  514.         # If the text contains the \inc code
  515.         if @list[@index + 1].parameters[0].index(/\\[Ii][Nn][Cc]/) != nil
  516.           $game_temp.message_text += @list[@index + 1].parameters[0] + "\n"
  517.           $game_temp.message_text.sub!(/\\[Ii][Nn][Cc]/) { "" }
  518.         else
  519.           return true
  520.         end
  521.       # If event command is not on the second line or after
  522.       else
  523.         # If next event command is show choices
  524.         if @list[@index + 1].code == 102
  525.           # Advance index
  526.           @index += 1
  527.          
  528.           # skip this one, it was already shown?
  529.           if $game_temp.skip_next_choices > 0
  530.             $game_temp.skip_next_choices -= 1
  531.           else
  532.             # Choices setup
  533.             $game_temp.choice_start = line_count
  534.             setup_choices(@list[@index].parameters)
  535.           end
  536.         # If next event command is input number
  537.         elsif @list[@index + 1].code == 103
  538.           # If number input window fits on screen
  539.           if line_count < 4
  540.             # Advance index
  541.             @index += 1
  542.             # Number input setup
  543.             $game_temp.num_input_start = line_count
  544.             $game_temp.num_input_variable_id = @list[@index].parameters[0]
  545.             $game_temp.num_input_digits_max = @list[@index].parameters[1]
  546.           end
  547.         end
  548.         # Continue
  549.         return true
  550.       end
  551.       # Advance index
  552.       @index += 1
  553.     end
  554.   end
  555.   #--------------------------------------------------------------------------
  556.   # * Show Choices
  557.   #--------------------------------------------------------------------------
  558.   def command_102
  559.     # If text has been set to message_text
  560.     if $game_temp.message_text != nil
  561.       # End
  562.       return false
  563.     end
  564.    
  565.     if $game_temp.skip_next_choices > 0
  566.       # skip this one, it is part of another
  567.       $game_temp.skip_next_choices -= 1
  568.       @offset += 4
  569.       @index += 1
  570.       return false
  571.     else
  572.       @offset = 0
  573.     end
  574.     # Set message end waiting flag and callback
  575.     @message_waiting = true
  576.     $game_temp.message_proc = Proc.new { @message_waiting = false }
  577.     # Choices setup
  578.     $game_temp.message_text = ""
  579.     $game_temp.choice_start = 0
  580.     setup_choices(@parameters)
  581.     # Continue
  582.     return true
  583.   end
  584.   #--------------------------------------------------------------------------
  585.   # * Setup Choices
  586.   #--------------------------------------------------------------------------
  587.   def setup_choices(parameters)
  588.     params = parameters.clone
  589.     @offset = 0
  590.     i = @index
  591.     curr = 1
  592.     while curr < $game_temp.num_choices
  593.       i += 1
  594.       if @list[i].code == 102
  595.         params[0] += @list[i].parameters[0]
  596.         if @list[i].parameters[1] == 5
  597.           @cancel_flag = true
  598.         else
  599.           @cancel_flag = false
  600.         end
  601.         params[1] = @list[i].parameters[1] + (curr * 4)
  602.         curr += 1
  603.       end
  604.     end
  605.    
  606.     # Set choice item count to choice_max
  607.     $game_temp.choice_max = params[0].size
  608.     # Set choice to message_text
  609.     $game_temp.choices = params[0]
  610.     # Set cancel processing
  611.     $game_temp.choice_cancel_type = params[1]
  612.    
  613.     if $game_temp.num_choices != 1
  614.       $game_temp.skip_next_choices = $game_temp.num_choices - 1
  615.       $game_temp.num_choices = 1
  616.     end
  617.    
  618.     # Set callback
  619.     current_indent = @list[@index].indent
  620.     $game_temp.choice_proc = Proc.new { |n| @branch[current_indent] = n }
  621.   end
  622.  
  623.   #--------------------------------------------------------------------------
  624.   # * When [**]
  625.   #--------------------------------------------------------------------------
  626.   def command_402
  627.     # If fitting choices are selected
  628.     if @branch[@list[@index].indent] == @parameters[0]
  629.       # Delete branch data
  630.       @branch.delete(@list[@index].indent)
  631.       # Continue
  632.       return true
  633.     end
  634.     # If it doesn't meet the condition: command skip
  635.     return command_skip
  636.   end
  637.  
  638.   #--------------------------------------------------------------------------
  639.   # * When Cancel
  640.   #--------------------------------------------------------------------------
  641.   def command_403
  642.     # If choices are cancelled
  643.     if @cancel_flag
  644.       # Delete branch data
  645.       @branch.delete(@list[@index].indent)
  646.       # Continue
  647.       return true
  648.     end
  649.     # If it doen't meet the condition: command skip
  650.     return command_skip
  651.   end
  652.  
  653.   #--------------------------------------------------------------------------
  654.   # * Input Number
  655.   #--------------------------------------------------------------------------
  656.   def command_103
  657.     # If text has been set to message_text
  658.     if $game_temp.message_text != nil
  659.       # End
  660.       return false
  661.     end
  662.     # Set message end waiting flag and callback
  663.     @message_waiting = true
  664.     $game_temp.message_proc = Proc.new { @message_waiting = false }
  665.     # Number input setup
  666.     $game_temp.message_text = ""
  667.     $game_temp.num_input_start = 0
  668.     $game_temp.num_input_variable_id = @parameters[0]
  669.     $game_temp.num_input_digits_max = @parameters[1]
  670.     # Continue
  671.     return true
  672.   end
  673.  
  674.   #--------------------------------------------------------------------------
  675.   # * Script
  676.   #--------------------------------------------------------------------------
  677.   def command_355
  678.     # Set first line to script
  679.     script = @list[@index].parameters[0] + "\n"
  680.     # Loop
  681.     loop do
  682.       # If next event command is second line of script or after
  683.       if @list[@index + 1].code == 655
  684.         # Add second line or after to script
  685.         script += @list[@index + 1].parameters[0] + "\n"
  686.       # If event command is not second line or after
  687.       else
  688.         # Abort loop
  689.         break
  690.       end
  691.       # Advance index
  692.       @index += 1
  693.     end
  694.     # Evaluation
  695.     result = eval(script)
  696.  
  697.     # Continue
  698.     return true
  699.   end
  700. end
  701.  
  702. # *****************************************************************************
  703. #  Changes to Window_Message.  This is the bulk of the script
  704. # *****************************************************************************
  705. #==============================================================================
  706. # ** Window_Message
  707. #------------------------------------------------------------------------------
  708. #  This message window is used to display text.
  709. #==============================================================================
  710.  
  711. class Window_Message < Window_Selectable
  712.   #--------------------------------------------------------------------------
  713.   # * Object Initialization
  714.   #--------------------------------------------------------------------------
  715.   def initialize
  716.     # x-coordinate depends on justification
  717.     if $game_system.window_justification == RIGHT
  718.       x = 640 - self.width
  719.     elsif $game_system.window_justification == LEFT
  720.       x = 0
  721.     else # center
  722.       x = (640 - $game_system.window_width) / 2
  723.     end
  724.     # y-coordinate depends on height
  725.     y = 480 - $game_system.window_height - 16
  726.     super(x, y, $game_system.window_width, $game_system.window_height)
  727.     self.contents = Bitmap.new(width - 32, height - 32)
  728.     self.visible = false
  729.     self.z = 9998
  730.     @fade_in = false
  731.     @fade_out = false
  732.     @contents_showing = false
  733.    
  734.     # face graphic sprite
  735.     @face = Sprite.new
  736.     @face.opacity = 0
  737.     @face.z = self.z + 1
  738.     @face_offset = 0
  739.    
  740.     # choice window
  741.     @choice_window = Window_Choice.new([])
  742.     @choice_window.back_opacity = $game_system.back_opacity
  743.    
  744.     # comic sprite
  745.     @comic = Sprite.new
  746.     @comic.opacity = 0
  747.     @comic.z = self.z + 1
  748.     if $game_system.comic_style == TALK1
  749.       @comic.bitmap = RPG::Cache.windowskin("talk1")
  750.     elsif $game_system.comic_style == TALK2
  751.       @comic.bitmap = RPG::Cache.windowskin("talk2")
  752.     else # thought
  753.       @comic.bitmap = RPG::Cache.windowskin("thought")
  754.     end
  755.    
  756.     # window image sprite
  757.     @window_back = Sprite.new
  758.     @window_back.opacity = 0
  759.     @window_back.z = self.z - 1
  760.     if $game_system.window_image != nil
  761.       @window_back.bitmap = RPG::Cache.windowskin($game_system.window_image)
  762.     end
  763.    
  764.     # name window
  765.     @name_window = Window_Name.new
  766.     @name_window.z = self.z + 1
  767.    
  768.     @pause_time = 0
  769.     @wait = 0
  770.    
  771.     @show = false
  772.    
  773.     @face_frame = 0
  774.     # my edit- nameBox window
  775.     @message_name_window = Window_Name_Box.new
  776.    
  777.   end
  778.   #--------------------------------------------------------------------------
  779.   # * Dispose
  780.   #--------------------------------------------------------------------------
  781.   def dispose
  782.     terminate_message
  783.     $game_temp.message_window_showing = false
  784.     if @input_number_window != nil
  785.       @input_number_window.dispose
  786.     end
  787.     @face.dispose
  788.     @choice_window.dispose
  789.     @comic.dispose
  790.     @name_window.dispose
  791.     # my edit- nameBox window
  792.     @message_name_window.dispose
  793.     super
  794.   end
  795.   #--------------------------------------------------------------------------
  796.   # * Terminate Message
  797.   #--------------------------------------------------------------------------
  798.   def terminate_message
  799.     @show = false
  800.     self.active = false
  801.     self.pause = false
  802.     self.contents.clear
  803.     # Clear showing flag
  804.     @contents_showing = false
  805.     # Call message callback
  806.     if $game_temp.message_proc != nil
  807.       $game_temp.message_proc.call
  808.     end
  809.     # Clear variables related to text, choices, and number input
  810.     $game_temp.message_text = nil
  811.     $game_temp.message_proc = nil
  812.     $game_temp.choice_start = 99
  813.     $game_temp.choice_max = 0
  814.     $game_temp.choice_cancel_type = 0
  815.     $game_temp.choice_proc = nil
  816.     $game_temp.num_input_start = 99
  817.     $game_temp.num_input_variable_id = 0
  818.     $game_temp.num_input_digits_max = 0
  819.     # Open gold window
  820.     if @gold_window != nil
  821.       @gold_window.dispose
  822.       @gold_window = nil
  823.     end
  824.     @choice_window.visible = false
  825.     @choice_window.active = false
  826.     @comic.opacity = 0
  827.     $game_system.slave_windows.each_pair {|name, window|
  828.       if window.show == true
  829.         window.dispose
  830.         $game_system.slave_windows.delete(name)
  831.       end
  832.     }
  833.     @done = false
  834.   end
  835.   #--------------------------------------------------------------------------
  836.   # * Refresh
  837.   #--------------------------------------------------------------------------
  838.   def refresh
  839.     self.contents.clear
  840.     if $game_system.font_color.nil?
  841.       self.contents.font.color = normal_color
  842.     else
  843.       self.contents.font.color = $game_system.font_color
  844.     end
  845.     if $game_system.windowskin != ""  
  846.       self.windowskin = RPG::Cache.windowskin($game_system.windowskin)
  847.     else
  848.       self.windowskin = RPG::Cache.windowskin($data_system.windowskin_name)
  849.     end
  850.     if $game_system.comic_style == TALK1
  851.       @comic.bitmap = RPG::Cache.windowskin("talk1")
  852.     elsif $game_system.comic_style == TALK2
  853.       @comic.bitmap = RPG::Cache.windowskin("talk2")
  854.     else # thought
  855.       @comic.bitmap = RPG::Cache.windowskin("thought")
  856.     end
  857.     @show = true
  858.     @x = @y = 0
  859.  
  860.     # If waiting for a message to be displayed
  861.     if $game_temp.message_text != nil
  862.       @text = $game_temp.message_text
  863.      
  864.       # replace shortcuts with original code
  865.       $game_system.shortcuts.each { |shortcut, code|
  866.         @text.gsub!(shortcut, code)
  867.       }
  868.      
  869.       # VERY first thing.  Check to see if this is being set up as a slave
  870.       #  or independent window.
  871.       if @text.index(/\\[Ss][Ll][Vv]\[(.*?)\]/) != nil
  872.         # is this a new slave window, or a request to display it?
  873.         if !$game_system.slave_windows.has_key?($1.to_s)
  874.           # there is no such slave window yet.  Set it up.
  875.           @text.gsub!(/\\[Ss][Ll][Vv]\[(.*?)\]/, "")
  876.           $game_system.slave_windows[$1.to_s] = Window_Slave.new(@text)
  877.           @text = ""
  878.           @show = false
  879.           terminate_message
  880.           return
  881.         end
  882.       end
  883.       if @text.index(/\\[Ii][Nn][Dd]\[(.*?)\]/) != nil
  884.         # is this a new independent window, or a request to display it?
  885.         if !$game_system.indy_windows.has_key?($1.to_s)
  886.           # there is no such slave window yet.  Set it up.
  887.           @text.gsub!(/\\[Ii][Nn][Dd]\[(.*?)\]/, "")
  888.           $game_system.indy_windows[$1.to_s] = Window_Slave.new(@text)
  889.           @text = ""
  890.           @show = false
  891.           terminate_message
  892.           return
  893.         end
  894.       end
  895.      
  896.       # Control text processing
  897.       begin
  898.         last_text = @text.clone
  899.         @text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  900.       end until @text == last_text
  901.       @text.gsub!(/\\[Nn]\[(.*?)\]/) do
  902.         # my edit
  903.         # was $game_actors[$1.to_i]
  904.         #$data_enemies[$1.to_i] != nil ? $data_enemies[$1.to_i].name : ""
  905.         $game_temp.message_name_box = $1.to_s
  906.         ""
  907.       end
  908.      
  909.       # window mode
  910.       if @text.index(/\\[Mm]/) != nil
  911.         if $game_system.ums_mode == NORMAL_MODE
  912.           $game_system.ums_mode = FIT_WINDOW_TO_TEXT
  913.         else
  914.           $game_system.ums_mode = NORMAL_MODE
  915.         end
  916.         @text.gsub!(/\\[Mm]/) { "" }
  917.       end
  918.      
  919.       # window height
  920.       @text.gsub!(/\\[Hh][Ee][Ii][Gg][Hh][Tt]\[([0-9]+)\]/) do
  921.         $game_system.window_height = $1.to_i
  922.         ""
  923.       end
  924.      
  925.       # window width
  926.       @text.gsub!(/\\[Ww][Ii][Dd][Tt][Hh]\[([0-9]+)\]/) do
  927.         $game_system.window_width = $1.to_i
  928.         ""
  929.       end
  930.      
  931.       # justification
  932.       @text.gsub!(/\\[Jj][Rr]/) do
  933.         $game_system.window_justification = RIGHT
  934.         reset_window
  935.         ""
  936.       end
  937.       @text.gsub!(/\\[Jj][Cc]/) do
  938.         $game_system.window_justification = CENTER
  939.         reset_window
  940.         ""
  941.       end      
  942.       @text.gsub!(/\\[Jj][Ll]/) do
  943.         $game_system.window_justification = LEFT
  944.         reset_window
  945.         ""
  946.       end
  947.      
  948.       # face graphics
  949.       @text.gsub!(/\\[Ff][Aa][Cc][Ee]\[(.*?)\]/) do
  950.         $game_system.face_graphic = $1.to_s
  951.         if $1.to_s == ""
  952.           @face.opacity = 0
  953.         end
  954.         ""
  955.       end
  956.       @text.gsub!(/\\[Ff][Ll]/) do
  957.         $game_system.face_graphic_justification = LEFT
  958.         ""
  959.       end
  960.       @text.gsub!(/\\[Ff][Rr]/) do
  961.         $game_system.face_graphic_justification = RIGHT
  962.         ""
  963.       end
  964.      
  965.       # event centering
  966.       @text.gsub!(/\\[Ee]\[([0-9]+)\]/) do
  967.         $game_system.message_event = $1.to_i
  968.         ""
  969.       end
  970.      
  971.       # center text above actor (silver wind's edit)#
  972.       @text.gsub!(/\\[Aa][Cc][Tt][Oo][Rr]\[([0-9]+)\]/) do
  973.       event_id = $game_map.cat_event_id($1.to_i)
  974.       $game_system.message_event = event_id
  975.       ""
  976.      end
  977.      
  978.       # comic thingy
  979.       @text.gsub!(/\\[Tt]1/) do
  980.         $game_system.comic_style = TALK1
  981.         @comic.bitmap = RPG::Cache.windowskin("talk1.png")
  982.         ""
  983.       end
  984.       @text.gsub!(/\\[Tt]2/) do
  985.         $game_system.comic_style = TALK2
  986.         @comic.bitmap = RPG::Cache.windowskin("talk2.png")
  987.         ""
  988.       end
  989.       @text.gsub!(/\\[Tt][Hh]/) do
  990.         $game_system.comic_style = THOUGHT
  991.         @comic.bitmap = RPG::Cache.windowskin("thought.png")
  992.         ""
  993.       end
  994.      
  995.       # name window
  996.       @text.gsub!(/\\[Nn][Mm]\[(.*?)\]/) do
  997.         $game_system.name = $1.to_s
  998.         if $1.to_s == ""
  999.           @name_window.visible = false
  1000.           @name_window.dummy_window.visible = false
  1001.         end
  1002.         ""
  1003.        
  1004.       end
  1005.      
  1006.       # toggle pause
  1007.       @text.gsub!(/\\[Pp][Tt]/) do
  1008.         $game_system.show_pause = !$game_system.show_pause
  1009.         ""
  1010.       end
  1011.      
  1012.       # shaking
  1013.       @text.gsub!(/\\[Ss][Hh][Kk]\[([0-9]+)\]/) do
  1014.         $game_system.shake = $1.to_i
  1015.         ""
  1016.       end
  1017.      
  1018.       # back opacity
  1019.       @text.gsub!(/\\[Bb][Oo][Pp][Cc]\[([0-9]+)\]/) do
  1020.         $game_system.back_opacity = $1.to_i
  1021.         self.back_opacity = $game_system.back_opacity
  1022.         ""
  1023.       end
  1024.      
  1025.       # opacity
  1026.       @text.gsub!(/\\[Oo][Pp][Cc]\[([0-9]+)\]/) do
  1027.         $game_system.opacity = $1.to_i
  1028.         self.opacity = $game_system.opacity
  1029.         ""
  1030.       end
  1031.      
  1032.       # Change "\\\\" to "\000" for convenience
  1033.       @text.gsub!(/\\\\/) { "\000" }
  1034.       # Change "\\C" to "\001" and "\\G" to "\002"
  1035.       @text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  1036.       @text.gsub!(/\\[Gg]/) { "\002" }
  1037.       @text.gsub!(/\\[Cc]\[0x([0123456789abcdef]+)\]/) { "\026[#{$1}]" }
  1038.      
  1039.       # text skip code
  1040.       @text.gsub!(/\\[Ss][Kk][Ii][Pp]/) { "\003" }
  1041.      
  1042.       # ignore code
  1043.       @text.gsub!(/\\[Ii][Gg][Nn][Rr]/) { "\023" }
  1044.      
  1045.       # slave and indy windows
  1046.       @text.gsub!(/\\[Ss][Ll][Vv]\[(.*?)\]/) { "\024[#{$1}]" }
  1047.       @text.gsub!(/\\[Ii][Nn][Dd]\[(.*?)\]/) { "\025[#{$1}]" }
  1048.      
  1049.       # bold and italics
  1050.       @text.gsub!(/\\[Bb]/) { "\004" }
  1051.       @text.gsub!(/\\[Ii]/) { "\005" }
  1052.      
  1053.       # shadow
  1054.       @text.gsub!(/\\[Ss]/) { "\006" }
  1055.      
  1056.       # font
  1057.       @text.gsub!(/\\[Ff][Oo][Nn][Tt]\[(.*?)\]/) { "\007[#{$1}]" }
  1058.      
  1059.       # pause and wait
  1060.       @text.gsub!(/\\[Pp]\[([0-9]+)\]/) { "\010[#{$1}]" }
  1061.       @text.gsub!(/\\[Ww]\[([0-9]+)\]/) { "\011[#{$1}]" }
  1062.      
  1063.       # write speed
  1064.       @text.gsub!(/\\[Ww][Ss]\[([0-9]+)\]/) { "\013[#{$1}]" }
  1065.            
  1066.       # armor, items, skills, and weapons
  1067.       @text.gsub!(/\\[Oo][Aa]\[([0-9]+)\]/) {
  1068.         item = $data_armors[$1.to_i]
  1069.         "\014[#{$1}]" + "  " + item.name
  1070.       }
  1071.       @text.gsub!(/\\[Oo][Ii]\[([0-9]+)\]/) {
  1072.         item = $data_items[$1.to_i]
  1073.         "\015[#{$1}]" + "  " + item.name
  1074.       }
  1075.       @text.gsub!(/\\[Oo][Ss]\[([0-9]+)\]/) {
  1076.         item = $data_skills[$1.to_i]
  1077.         "\016[#{$1}]" + "  " + item.name
  1078.       }
  1079.       @text.gsub!(/\\[Oo][Ww]\[([0-9]+)\]/) {
  1080.         item = $data_weapons[$1.to_i]
  1081.         "\017[#{$1}]" + "  " + item.name
  1082.       }
  1083.      
  1084.       # text justification
  1085.       @text.gsub!(/\\[Tt][Cc]/) { "\020" }
  1086.       @text.gsub!(/\\[Tt][Ll]/) { "\021" }
  1087.       @text.gsub!(/\\[Tt][Rr]/) { "\022" }
  1088.      
  1089.       # Resize the window to fit the contents?
  1090.       if $game_system.ums_mode == FIT_WINDOW_TO_TEXT
  1091.         width = 1
  1092.         text = @text.split("\n")
  1093.         height = 0
  1094.         i = 0
  1095.         for line in text
  1096.           # don't count this line's width if it has the ignr code
  1097.           if !line.include?("\023")
  1098.             width = [width, self.contents.text_size(line).width].max
  1099.             delta = self.contents.text_size(line).height
  1100.             height += delta + (delta * 0.2).to_i
  1101.           end
  1102.         end
  1103.        
  1104.         if $game_system.face_graphic != "" and ($game_system.face_graphic_position == CENTER or $game_system.face_graphic_position == BOTTOM)
  1105.           width += @face.bitmap.width
  1106.           if height < @face.bitmap.height
  1107.             height = @face.bitmap.height - 32
  1108.           end
  1109.         end
  1110.        
  1111.         if height == 0
  1112.           height = 1
  1113.         end
  1114.        
  1115.         self.width = width + 48
  1116.         self.height = height + 48
  1117.         self.contents = Bitmap.new(width + 16, height)
  1118.        
  1119.         if $game_system.font_color.nil?
  1120.           self.contents.font.color = normal_color
  1121.         else
  1122.           self.contents.font.color = $game_system.font_color
  1123.         end
  1124.       else
  1125.         if self.width != $game_system.window_height or self.height != $game_system.window_width
  1126.           self.width = $game_system.window_width
  1127.           self.height = $game_system.window_height
  1128.           self.contents = Bitmap.new(self.width - 32, self.height - 32)
  1129.           if $game_system.font_color.nil?
  1130.             self.contents.font.color = normal_color
  1131.           else
  1132.             self.contents.font.color = $game_system.font_color
  1133.           end
  1134.         end
  1135.       end
  1136.      
  1137.       if $game_system.window_image != nil
  1138.         # figure out how we're going to resize this          
  1139.         @window_back.zoom_x = self.width.to_f / @window_back.bitmap.width
  1140.         @window_back.zoom_y = self.height.to_f / @window_back.bitmap.height
  1141.       end
  1142.      
  1143.       reset_window
  1144.      
  1145.       get_x_value
  1146.      
  1147.       @count = Graphics.frame_count
  1148.       @pause_time = 0
  1149.       @ignore = false
  1150.       @ascending = true
  1151.       @target_x = self.x + $game_system.shake
  1152.       @done = false
  1153.       @face_frame = 0
  1154.       @done = false
  1155.      
  1156.       self.oy = 0
  1157.     end
  1158.    
  1159.    
  1160.   end
  1161.  
  1162.   #--------------------------------------------------------------------------
  1163.   # * Set Window Position and Opacity Level
  1164.   #--------------------------------------------------------------------------
  1165.   def reset_window (change_opacity = true)
  1166.     # x-coordinate depends on justification
  1167.     if $game_system.message_event == -1
  1168.       if $game_system.window_justification == RIGHT
  1169.         self.x = 640 - $game_system.window_width
  1170.       elsif $game_system.window_justification == LEFT
  1171.         self.x = 0
  1172.       else # center
  1173.         self.x = (640 - self.width) / 2
  1174.       end
  1175.     else
  1176.       if $game_system.message_event == 0 or $game_map.events[$game_system.message_event] == nil
  1177.         # center on player
  1178.         event_x = $game_player.screen_x
  1179.       else
  1180.         # center on the event specified
  1181.         event_x = $game_map.events[$game_system.message_event].screen_x
  1182.       end
  1183.       self.x = event_x - self.width / 2
  1184.       @comic.x = self.x + (self.width / 2) + 4
  1185.     end
  1186.    
  1187.     if $game_temp.in_battle
  1188.       self.y = 16
  1189.     else
  1190.       if $game_system.message_event == -1
  1191.         case $game_system.message_position
  1192.           when 0  # up
  1193.             self.y = 16
  1194.           when 1  # middle
  1195.             self.y = (480 - $game_system.window_height) / 2
  1196.           when 2  # down
  1197.             self.y = 480 - $game_system.window_height - 24
  1198.         end
  1199.       else
  1200.         if $game_system.message_event == 0 or $game_map.events[$game_system.message_event] == nil
  1201.           # above player
  1202.           self.y = $game_player.screen_y - self.height - 48
  1203.         else
  1204.           # above event specified
  1205.           self.y = $game_map.events[$game_system.message_event].screen_y - self.height - 48
  1206.         end
  1207.         @comic.y = self.y + self.height - 2
  1208.         @comic.angle = 0
  1209.       end
  1210.     end
  1211.     if self.y < 0 + ($game_system.name == "" ? 0 : 16)
  1212.       if $game_system.comic_enabled
  1213.         if $game_system.message_event == 0 or $game_map.events[$game_system.message_event] == nil
  1214.           self.y = $game_player.screen_y - 16
  1215.         else
  1216.           self.y = $game_map.events[$game_system.message_event].screen_y - 16
  1217.         end
  1218.         @comic.angle = 180
  1219.         @comic.y = self.y + 2
  1220.         @comic.x = self.x + (self.width / 2) - 4
  1221.       else
  1222.         self.y = 0 + ($game_system.name == "" ? 0 : 16)
  1223.       end
  1224.     elsif self.y > 480 - self.height
  1225.       self.y = 480 - self.height
  1226.     end
  1227.     if self.x < 0
  1228.       self.x = 0
  1229.     elsif self.x > 680 - self.width - 48
  1230.       self.x = 640 - self.width
  1231.     end
  1232.    
  1233.     if change_opacity
  1234.       if $game_system.message_frame == 0 and $game_temp.message_text != ""
  1235.         self.opacity = $game_system.opacity
  1236.       else
  1237.         self.opacity = 0
  1238.       end
  1239.       self.back_opacity = $game_system.back_opacity
  1240.     end
  1241.    
  1242.     # window back stuff
  1243.     if $game_system.window_image != nil
  1244.       @window_back.bitmap = RPG::Cache.windowskin($game_system.window_image)
  1245.       @window_back.x = self.x
  1246.       @window_back.y = self.y
  1247.     end
  1248.    
  1249.       # face stuff
  1250.       if $game_system.face_graphic != ""  
  1251.         # the player has chosen to show a face graphic
  1252.         if @done and $game_system.resting_face != ""
  1253.           @face.bitmap = RPG::Cache.picture($game_system.face_graphic + $game_system.resting_face)
  1254.           if @face_frame * $game_system.face_frame_width >= @face.bitmap.width
  1255.             @face_frame = 0
  1256.           end
  1257.         else
  1258.           @face.bitmap = RPG::Cache.picture($game_system.face_graphic)
  1259.         end
  1260.        
  1261.         # picture y-coordinate
  1262.         if $game_system.face_graphic_position == ABOVE
  1263.           @face.y = self.y - @face.bitmap.height
  1264.           @face_offset = 0
  1265.         elsif $game_system.face_graphic_position == CENTER
  1266.           delta = (@face.bitmap.height - self.height) / 2
  1267.           @face.y = self.y - delta
  1268.           if $game_system.animated_faces
  1269.             @face_offset = $game_system.face_frame_width + 16
  1270.           else
  1271.             @face_offset = @face.bitmap.width + 16
  1272.           end
  1273.         elsif $game_system.face_graphic_position == BOTTOM
  1274.           @face.y = self.y + self.height - @face.bitmap.height
  1275.           if $game_system.animated_faces
  1276.             @face_offset = $game_system.face_frame_width + 16
  1277.           else
  1278.             @face_offset = @face.bitmap.width + 16
  1279.           end
  1280.         else # side
  1281.           delta = (@face.bitmap.height - self.height) / 2
  1282.           @face.y = self.y - delta
  1283.           @face_offset = 0
  1284.         end
  1285.        
  1286.         # picture x-coordinate
  1287.         if $game_system.face_graphic_justification == LEFT
  1288.           if $game_system.face_graphic_position == SIDE
  1289.             @face.x = self.x - @face.bitmap.width
  1290.           else
  1291.             @face.x = self.x + 10
  1292.           end
  1293.         else # right side
  1294.           if $game_system.animated_faces
  1295.             offset = @face.bitmap.width - $game_system.face_frame_width
  1296.           else
  1297.             offset = 0
  1298.           end
  1299.           if $game_system.face_graphic_position == SIDE
  1300.             @face.x = self.x + self.width + offset
  1301.           else
  1302.             @face.x = self.x + self.width - @face.bitmap.width - 10 + offset
  1303.             @face_offset = 0
  1304.           end
  1305.         end
  1306.        
  1307.         if $game_system.animated_faces
  1308.           @face.src_rect = Rect.new(@face_frame * $game_system.face_frame_width, 0, $game_system.face_frame_width, @face.bitmap.height)
  1309.           if @done and $game_system.resting_face != ""
  1310.             pause = $game_system.resting_animation_pause
  1311.           else
  1312.             pause = $game_system.animation_pause
  1313.           end
  1314.           if Graphics.frame_count % pause == 0
  1315.             @animate_face = true
  1316.           end
  1317.           if @animate_face
  1318.             if Graphics.frame_count % 3 == 0
  1319.               @face_frame += 1
  1320.               if @face_frame * $game_system.face_frame_width >= @face.bitmap.width
  1321.                 @face_frame = 0
  1322.                 @animate_face = false
  1323.               end
  1324.             end
  1325.           end
  1326.         end
  1327.       end
  1328.      
  1329.       # name window
  1330.       if $game_system.name != ""
  1331.         @name_window.x = self.x
  1332.         @name_window.y = self.y - 36
  1333.         @name_window.set_name($game_system.name)
  1334.       end
  1335.      
  1336.       # If choice
  1337.     if $game_temp.choice_max > 0
  1338.       @choice_window.set_choices($game_temp.choices)
  1339.       # determine x and y coords for choice window
  1340.       if $game_system.choice_justification == LEFT
  1341.         @choice_window.x = self.x
  1342.       else
  1343.         @choice_window.x = self.x + self.width - @choice_window.width
  1344.       end
  1345.       if $game_system.choice_position == ABOVE
  1346.         # check to make sure there is enough room above the textbox
  1347.         if self.y < @choice_window.height
  1348.           # not enough room above, place below
  1349.           @choice_window.y = self.y + self.height
  1350.         else
  1351.           # draw above
  1352.           @choice_window.y = self.y - @choice_window.height
  1353.         end
  1354.       elsif $game_system.choice_position == BOTTOM
  1355.         # check to make sure there is enough room below the textbox
  1356.         if (480 - self.y - self.height) < @choice_window.height
  1357.           # not enough room below, place above
  1358.           @choice_window.y = self.y - @choice_window.height
  1359.         else
  1360.           # draw below
  1361.           @choice_window.y = self.y + self.height
  1362.         end
  1363.       else # side
  1364.         if $game_system.choice_justification == LEFT
  1365.           # check to make sure there's room on the left side
  1366.           if self.y < @choice_window.width
  1367.             # not enough room on the side, check to make sure there's room below
  1368.             if (480 - self.y - self.height) < @choice_window.height
  1369.               # not enough room below, place above
  1370.               @choice_window.y = self.y - @choice_window.height
  1371.             else
  1372.               # draw below
  1373.               @choice_window.y = self.y + self.height
  1374.             end
  1375.           else
  1376.             # place on the left side
  1377.             @choice_window.y = self.y
  1378.             @choice_window.x = self.x - @choice_window.width
  1379.           end
  1380.         else # right
  1381.           # check to make sure there's room on the right side
  1382.           if (680 - (self.y + self.width)) < @choice_window.width
  1383.             # not enough room on the side, check to make sure there's room below
  1384.             if (480 - self.y - self.height) < @choice_window.height
  1385.               # not enough room below, place above
  1386.               @choice_window.y = self.y - @choice_window.height
  1387.             else
  1388.               # draw below
  1389.               @choice_window.y = self.y + self.height
  1390.             end
  1391.           else
  1392.             # place on the left side
  1393.             @choice_window.y = self.y
  1394.             @choice_window.x = self.x + self.width
  1395.           end
  1396.         end
  1397.       end
  1398.     end
  1399.    
  1400.     # If number input
  1401.     if $game_temp.num_input_variable_id > 0
  1402.       if @input_number_window == nil
  1403.         digits_max = $game_temp.num_input_digits_max
  1404.         number = $game_variables[$game_temp.num_input_variable_id]
  1405.         @input_number_window = Window_InputNumber.new(digits_max)
  1406.         @input_number_window.number = number
  1407.       end
  1408.       # determine x and y coords for number input window
  1409.       if $game_system.choice_justification == LEFT
  1410.         @input_number_window.x = self.x
  1411.       else
  1412.         @input_number_window.x = self.x + self.width - @input_number_window.width
  1413.       end
  1414.       if $game_system.choice_position == ABOVE
  1415.         # check to make sure there is enough room above the textbox
  1416.         if self.y < @input_number_window.height
  1417.           # not enough room above, place below
  1418.           @input_number_window.y = self.y + self.height
  1419.         else
  1420.           # draw above
  1421.           @input_number_window.y = self.y - @choice_window.height
  1422.         end
  1423.       elsif $game_system.choice_position == BOTTOM
  1424.         # check to make sure there is enough room below the textbox
  1425.         if (480 - self.y - self.height) < @input_number_window.height
  1426.           # not enough room below, place above
  1427.           @input_number_window.y = self.y - @input_number_window.height
  1428.         else
  1429.           # draw below
  1430.           @input_number_window.y = self.y + self.height
  1431.         end
  1432.       else # side
  1433.         if $game_system.choice_justification == LEFT
  1434.           # check to make sure there's room on the left side
  1435.           if self.y < @input_number_window.width
  1436.             # not enough room on the side, check to make sure there's room below
  1437.             if (480 - self.y - self.height) < @input_number_window.height
  1438.               # not enough room below, place above
  1439.               @input_number_window.y = self.y - @input_number_window.height
  1440.             else
  1441.               # draw below
  1442.               @input_number_window.y = self.y + self.height
  1443.             end
  1444.           else
  1445.             # place on the left side
  1446.             @input_number_window.y = self.y
  1447.             @input_number_window.x = self.x - @choice_window.width
  1448.           end
  1449.         else # right
  1450.           # check to make sure there's room on the right side
  1451.           if (680 - (self.y + self.width)) < @input_number_window.width
  1452.             # not enough room on the side, check to make sure there's room below
  1453.             if (480 - self.y - self.height) < @input_number_window.height
  1454.               # not enough room below, place above
  1455.               @input_number_window.y = self.y - @input_number_window.height
  1456.             else
  1457.               # draw below
  1458.               @input_number_window.y = self.y + self.height
  1459.             end
  1460.           else
  1461.             # place on the left side
  1462.             @input_number_window.y = self.y
  1463.             @input_number_window.x = self.x + self.width
  1464.           end
  1465.         end
  1466.       end
  1467.     end
  1468.   end
  1469.   #--------------------------------------------------------------------------
  1470.   # * Frame Update
  1471.   #--------------------------------------------------------------------------
  1472.   def update
  1473.     super
  1474.    
  1475.     # my edit- nameBox window
  1476.     @message_name_window.update
  1477.    
  1478.     if (@contents_showing and $game_system.message_event != -1 and $game_system.shake == 0) or $game_system.animated_faces
  1479.       reset_window(false)
  1480.     end
  1481.    
  1482.     if $game_system.shake != 0  # shake the window
  1483.       if @ascending
  1484.         if @target_x != self.x
  1485.           self.x += 1
  1486.         else
  1487.           @ascending = false
  1488.           @target_x = self.x - ($game_system.shake * 2)
  1489.         end
  1490.       else
  1491.         if @target_x != self.x
  1492.           self.x -= 1
  1493.         else
  1494.           @ascending = true
  1495.           @target_x = self.x + ($game_system.shake * 2)
  1496.         end
  1497.       end
  1498.     end
  1499.    
  1500.     @name_window.update
  1501.    
  1502.     if @wait > 0
  1503.       @wait -= 1
  1504.       if @wait == 0
  1505.         terminate_message
  1506.         return
  1507.       end
  1508.     end
  1509.    
  1510.     # If fade in
  1511.     if @fade_in
  1512.       if $game_temp.message_text == ""
  1513.         @fade_in = false
  1514.         return
  1515.       end
  1516.       self.contents_opacity += 24
  1517.       if $game_system.face_graphic != ""
  1518.         @face.opacity += 24
  1519.       end
  1520.       if $game_system.window_image != nil
  1521.         @window_back.opacity += 24
  1522.       end
  1523.       if $game_system.comic_enabled and $game_system.message_event != -1
  1524.         @comic.opacity = self.opacity
  1525.         @comic.visible = self.visible
  1526.       end
  1527.      
  1528.       if $game_system.name != ""
  1529.         @name_window.visible = true
  1530.         if $game_system.name_window
  1531.           @name_window.dummy_window.visible = true
  1532.         end
  1533.       end
  1534.       if @input_number_window != nil
  1535.         @input_number_window.contents_opacity += 24
  1536.       end
  1537.       if self.contents_opacity == 255
  1538.         @fade_in = false
  1539.       end
  1540.       return
  1541.     end
  1542.    
  1543.     # write the text
  1544.     if @text != nil and @text != ""
  1545.       speed = $game_system.write_speed
  1546.       if $game_system.text_mode == ALL_AT_ONCE or $game_temp.in_battle
  1547.         while (c = @text.slice!(/./m)) != nil
  1548.           write_char(c)
  1549.         end
  1550.         $game_system.slave_windows.each_value { |window| window.write_all }
  1551.         return
  1552.       end
  1553.       if $game_system.text_skip
  1554.         if $game_system.skip_mode == WRITE_FASTER and Input.press?(Input::C)
  1555.           # the player is holding the action button, write faster
  1556.           speed /= 3
  1557.         elsif $game_system.skip_mode == WRITE_ALL and Input.trigger?(Input::C)
  1558.           # the player pressed the action button, write all the text
  1559.           while (c = @text.slice!(/./m)) != nil
  1560.             write_char(c)
  1561.           end
  1562.           $game_system.slave_windows.each_value { |window| window.write_all }
  1563.           return
  1564.         end
  1565.       end
  1566.       while @ignore
  1567.         c = @text.slice!(/./m)
  1568.         if c != nil
  1569.           write_char(c)
  1570.         end
  1571.       end
  1572.       if @pause_time > 0
  1573.         @pause_time -= 1
  1574.         return
  1575.       end
  1576.       if Graphics.frame_count - @count >= speed
  1577.         if $game_system.sound_effect != ""
  1578.           Audio.se_play("Audio/SE/" + $game_system.sound_effect, 80, 100)
  1579.         end
  1580.         @count = Graphics.frame_count
  1581.         c = @text.slice!(/./m)
  1582.         if c != nil
  1583.           write_char(c)
  1584.         end
  1585.       end
  1586.       return
  1587.     end
  1588.    
  1589.     if $game_system.animated_faces and $game_system.resting_face != ""
  1590.       @done = true
  1591.     end
  1592.    
  1593.     # If inputting number
  1594.     if @input_number_window != nil
  1595.       @input_number_window.update
  1596.       # Confirm
  1597.       if Input.trigger?(Input::C)
  1598.         $game_system.se_play($data_system.decision_se)
  1599.         $game_variables[$game_temp.num_input_variable_id] =
  1600.           @input_number_window.number
  1601.         $game_map.need_refresh = true
  1602.         # Dispose of number input window
  1603.         @input_number_window.dispose
  1604.         @input_number_window = nil
  1605.         terminate_message
  1606.       end
  1607.       return
  1608.     end
  1609.    
  1610.     if @wait != 0
  1611.       return
  1612.     end
  1613.    
  1614.     # If message is being displayed and contents are all written
  1615.     if @contents_showing
  1616.       # if choice
  1617.       if $game_temp.choice_max > 0
  1618.         if !@choice_window.active
  1619.           @choice_window.visible = true
  1620.           @choice_window.active = true
  1621.           @choice_window.index = 0
  1622.         end
  1623.         @choice_window.update
  1624.       else
  1625.         # If choice isn't being displayed, show pause sign
  1626.         self.pause = $game_system.show_pause
  1627.       end
  1628.         # Cancel
  1629.         if Input.trigger?(Input::B)
  1630.           if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  1631.             $game_system.se_play($data_system.cancel_se)
  1632.             $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  1633.             terminate_message
  1634.           end
  1635.         end
  1636.         # Confirm
  1637.         if Input.trigger?(Input::C) and !(@wait > 0)
  1638.           @done = true
  1639.           $game_system.slave_windows.each_value { |window|
  1640.             window.write_all
  1641.             if !window.done
  1642.               @done = false
  1643.             end
  1644.           }
  1645.           if @done
  1646.             if $game_temp.choice_max > 0
  1647.               $game_system.se_play($data_system.decision_se)
  1648.               $game_temp.choice_proc.call(@choice_window.index)
  1649.             end
  1650.             terminate_message
  1651.           else
  1652.             @finishing_up = true
  1653.           end
  1654.         end
  1655.         return
  1656.       end
  1657.      
  1658.     if @finishing_up
  1659.       $game_system.slave_windows.each_value { |window|
  1660.         if !window.done
  1661.           @done = true
  1662.           break
  1663.         end
  1664.       }
  1665.      
  1666.       if @done = false
  1667.         terminate_message
  1668.       end
  1669.     end
  1670.     # If display wait message or choice exists when not fading out
  1671.     if @fade_out == false and $game_temp.message_text != nil
  1672.       @contents_showing = true
  1673.       $game_temp.message_window_showing = true
  1674.      
  1675.       reset_window
  1676.       refresh
  1677.       Graphics.frame_reset
  1678.       if @show
  1679.         self.visible = true
  1680.       end
  1681.       self.contents_opacity = 0
  1682.       if @input_number_window != nil
  1683.         @input_number_window.contents_opacity = 0
  1684.       end
  1685.       @fade_in = true
  1686.       return
  1687.     end
  1688.     # If message which should be displayed is not shown, but window is visible
  1689.     if self.visible
  1690.       @fade_out = true
  1691.       self.opacity -= 48
  1692.       @name_window.opacity -= 48
  1693.       @comic.opacity -= 48
  1694.       @face.opacity -= 48
  1695.       @window_back.opacity -= 48
  1696.       if self.opacity == 0
  1697.         self.visible = false
  1698.         @face.opacity = 0
  1699.         @window_back.opacity = 0
  1700.         @choice_window.visible = false
  1701.         @choice_window.active = false
  1702.         @comic.opacity = 0
  1703.         @name_window.visible = false
  1704.         @name_window.dummy_window.visible = false
  1705.         @name_window.update
  1706.         @fade_out = false
  1707.         $game_temp.message_window_showing = false
  1708.       end
  1709.       return
  1710.     end
  1711.    
  1712.     if $game_temp.battle_calling or $game_temp.shop_calling or $game_temp.name_calling or $game_temp.menu_calling or $game_temp.save_calling or $game_temp.debug_calling
  1713.      
  1714.         $game_system.indy_windows.each_pair {|name, window|
  1715.           if window.show == true
  1716.             window.dispose
  1717.             $game_system.indy_windows.delete(name)
  1718.           end
  1719.         }
  1720.     end
  1721.   end
  1722.  
  1723.   #--------------------------------------------------------------------------
  1724.   # * Process and write the given character
  1725.   #--------------------------------------------------------------------------
  1726.   def write_char(c)
  1727.     if c == "\000"
  1728.       # Return to original text
  1729.       c = "\\"
  1730.     end
  1731.     # If \C[n]
  1732.     if c == "\001"
  1733.     # Change text color
  1734.       @text.sub!(/\[([0-9]+)\]/, "")
  1735.       color = $1.to_i
  1736.       if color >= 0 and color <= 7
  1737.         self.contents.font.color = text_color(color)
  1738.       end
  1739.       # go to next text
  1740.       return
  1741.     end
  1742.     # If \G
  1743.     if c == "\002"
  1744.       # Make gold window
  1745.       if @gold_window == nil
  1746.         @gold_window = Window_Gold.new
  1747.         @gold_window.x = 560 - @gold_window.width
  1748.         if $game_temp.in_battle
  1749.           @gold_window.y = 192
  1750.         else
  1751.           @gold_window.y = self.y >= 128 ? 32 : 384
  1752.         end
  1753.         @gold_window.opacity = self.opacity
  1754.         @gold_window.back_opacity = self.back_opacity
  1755.       end
  1756.       # go to next text
  1757.       return
  1758.     end
  1759.     # If \skip
  1760.     if c == "\003"
  1761.       # toggle text skipping
  1762.       $game_system.text_skip = !$game_system.text_skip
  1763.       # go to next text
  1764.       return
  1765.     end
  1766.     # If \b
  1767.     if c == "\004"
  1768.       # toggle bold
  1769.       self.contents.font.bold = !self.contents.font.bold
  1770.       # go to next text
  1771.       return
  1772.     end
  1773.     # If \i
  1774.     if c == "\005"
  1775.       # toggle italics
  1776.       self.contents.font.italic = !self.contents.font.italic
  1777.       # go to next text
  1778.       return
  1779.     end
  1780.     # If \s
  1781.     if c == "\006"
  1782.       # toggle shadow
  1783.       $game_system.shadowed_text = !$game_system.shadowed_text
  1784.       # go to next text
  1785.       return
  1786.     end
  1787.     # If \font
  1788.     if c == "\007"
  1789.       # change font
  1790.       @text.sub!(/\[(.*?)\]/, "")
  1791.       font = $1.to_s
  1792.       $game_system.font = font
  1793.       if font == ""
  1794.         self.contents.font.name = Font.default_name
  1795.       else
  1796.         self.contents.font.name = font
  1797.       end
  1798.       # go to next text
  1799.       return
  1800.     end
  1801.     # If \p[n]
  1802.     if c == "\010"
  1803.       @text.sub!(/\[([0-9]+)\]/, "")
  1804.       @pause_time = $1.to_i
  1805.  
  1806.       # go to next text
  1807.       return
  1808.     end
  1809.    
  1810.     # If \w[n]
  1811.     if c == "\011"
  1812.       @text.sub!(/\[([0-9]+)\]/, "")
  1813.       @wait = $1.to_i
  1814.  
  1815.       # go to next text
  1816.       return
  1817.     end
  1818.    
  1819.     # If \ws[n]
  1820.     if c == "\013"
  1821.       @text.sub!(/\[([0-9]+)\]/, "")
  1822.       $game_system.write_speed = $1.to_i
  1823.  
  1824.       # go to next text
  1825.       return
  1826.     end
  1827.     # If \oa[n]
  1828.     if c == "\014"
  1829.       @text.sub!(/\[([0-9]+)\]/, "")
  1830.       index = $1.to_i
  1831.       @text.sub!("  ", "")
  1832.       item = $data_armors[index]
  1833.       # draw the icon
  1834.       icon = RPG::Cache.icon(item.icon_name)
  1835.       line = self.contents.text_size("dj").height
  1836.       self.contents.blt(@x + 4, (@y * line) + 4, icon, Rect.new(0, 0, 24, 24))
  1837.       @x += 24
  1838.  
  1839.       # go to next text
  1840.       return
  1841.     end
  1842.    
  1843.     # If \oi[n]
  1844.     if c == "\015"
  1845.       @text.sub!(/\[([0-9]+)\]/, "")
  1846.       index = $1.to_i
  1847.       @text.sub!("  ", "")
  1848.       item = $data_items[index]
  1849.       # draw the icon
  1850.       icon = RPG::Cache.icon(item.icon_name)
  1851.       line = self.contents.text_size("dj").height
  1852.       self.contents.blt(@x + 4, (@y * line) + 4, icon, Rect.new(0, 0, 24, 24))
  1853.       @x += 24
  1854.  
  1855.       # go to next text
  1856.       return
  1857.     end
  1858.    
  1859.     # If \os[n]
  1860.     if c == "\016"
  1861.       @text.sub!(/\[([0-9]+)\]/, "")
  1862.       index = $1.to_i
  1863.       @text.sub!("  ", "")
  1864.       item = $data_skills[index]
  1865.       # draw the icon
  1866.       icon = RPG::Cache.icon(item.icon_name)
  1867.       line = self.contents.text_size("dj").height
  1868.       self.contents.blt(@x + 2, (@y * line) + 4, icon, Rect.new(0, 0, 24, 24))
  1869.       @x += 24
  1870.  
  1871.       # go to next text
  1872.       return
  1873.     end
  1874.    
  1875.     # If \ow[n]
  1876.     if c == "\017"
  1877.       @text.sub!(/\[([0-9]+)\]/, "")
  1878.       index = $1.to_i
  1879.       @text.sub!("  ", "")
  1880.       item = $data_weapons[index]
  1881.       # draw the icon
  1882.       icon = RPG::Cache.icon(item.icon_name)
  1883.       line = self.contents.text_size("dj").height
  1884.       self.contents.blt(@x + 2, (@y * line) + 4, icon, Rect.new(0, 0, 24, 24))
  1885.       @x += 24
  1886.      
  1887.       # go to next text
  1888.       return
  1889.     end
  1890.    
  1891.     # If \tc
  1892.     if c == "\020"
  1893.       # center justify
  1894.       $game_system.text_justification = CENTER
  1895.       get_x_value
  1896.       # go to next text
  1897.       return
  1898.     end
  1899.    
  1900.     # If \tl
  1901.     if c == "\021"
  1902.       # left justify
  1903.       $game_system.text_justification = LEFT
  1904.       get_x_value
  1905.       # go to next text
  1906.       return
  1907.     end
  1908.    
  1909.     # If \tr
  1910.     if c == "\022"
  1911.       # right justify
  1912.       $game_system.text_justification = RIGHT
  1913.       get_x_value
  1914.       # go to next text
  1915.       return
  1916.     end
  1917.    
  1918.     # If \ignr
  1919.     if c == "\023"
  1920.       # set ignore flage
  1921.       @ignore = true
  1922.       # go to next text
  1923.       return
  1924.     end
  1925.    
  1926.     # if \slv
  1927.     if c == "\024"
  1928.       # we need to show a slave window
  1929.       @text.sub!(/\[(.*?)\]/, "")
  1930.       name = $1.to_s
  1931.       $game_system.slave_windows[name].show = true
  1932.       return
  1933.     end
  1934.    
  1935.     # if \ind
  1936.     if c == "\025"
  1937.       # we need to show a independent window
  1938.       @text.sub!(/\[(.*?)\]/, "")
  1939.       name = $1.to_s
  1940.       if $game_system.indy_windows[name].show
  1941.         $game_system.indy_windows[name].dispose
  1942.         $game_system.indy_windows.delete(name)
  1943.       else
  1944.         $game_system.indy_windows[name].show = true
  1945.       end
  1946.       return
  1947.     end
  1948.    
  1949.     # if \c (hex color)
  1950.     if c == "\026"
  1951.       # convert hex color to RGB
  1952.       @text.sub!(/\[([0123456789abcdef]+)\]/, "")
  1953.       hex_code = $1.to_s
  1954.      
  1955.       red   = ("0x" + hex_code.slice(0..1)).hex
  1956.       blue  = ("0x" + hex_code.slice(2..3)).hex
  1957.       green = ("0x" + hex_code.slice(4..5)).hex
  1958.      
  1959.       self.contents.font.color = Color.new(red, blue, green)
  1960.       return
  1961.     end
  1962.    
  1963.     # If new line text
  1964.     if c == "\n"
  1965.       # Add 1 to y
  1966.       if !@ignore
  1967.         @y += 1
  1968.       end
  1969.       if @text != ""
  1970.         get_x_value
  1971.       end
  1972.       @ignore = false
  1973.  
  1974.       # go to next text
  1975.       return
  1976.     end
  1977.     if @ignore
  1978.       return
  1979.     end
  1980.     # Draw text
  1981.     line = self.contents.text_size("dj").height
  1982.     if $game_system.shadowed_text
  1983.       old_color = self.contents.font.color.clone
  1984.       self.contents.font.color = $game_system.shadow_color    
  1985.       self.contents.draw_text(6 + @x, line * @y + 2, 40, 32, c)
  1986.       self.contents.font.color = old_color
  1987.     end
  1988.     self.contents.draw_text(4 + @x, line * @y, 40, 32, c)
  1989.     # Add x to drawn text width
  1990.     @x += self.contents.text_size(c).width
  1991.   end
  1992.  
  1993.   def get_x_value
  1994.     # text justification - offset for first line
  1995.     if $game_system.text_justification == CENTER
  1996.       # get the length of the current line
  1997.       w = self.contents.text_size(@text.split("\n")[0]).width
  1998.       @x = (self.width - w - 48) / 2
  1999.     elsif $game_system.text_justification == RIGHT
  2000.       # get the length of the current line
  2001.       w = self.contents.text_size(@text.split("\n")[0]).width
  2002.       @x = self.width - w - 48
  2003.     else # left
  2004.       if $game_system.face_graphic == ""
  2005.         @x = 0
  2006.       else
  2007.         @x = @face_offset
  2008.       end
  2009.     end
  2010.   end
  2011.    
  2012. end
  2013.  
  2014. #==============================================================================
  2015. # ** Window_Choice
  2016. #------------------------------------------------------------------------------
  2017. #  This message window is used to display choices.
  2018. #==============================================================================
  2019. class Window_Choice < Window_Selectable
  2020.   def initialize (choices)
  2021.     super(0, 0, 32, choices.size * 32)
  2022.     self.visible = false
  2023.     self.active = false
  2024.     self.z = 9999
  2025.     @index = 0
  2026.     @item_max = choices.size
  2027.     @choices = choices
  2028.     self.contents = Bitmap.new(32, 32)
  2029.     self.opacity = $game_system.opacity
  2030.     self.back_opacity = $game_system.back_opacity
  2031.   end
  2032.  
  2033.   def refresh
  2034.     # determine necessary width
  2035.     width = 64
  2036.     for line in @choices
  2037.       width = [width, (self.contents.text_size(line).width + 48)].max
  2038.     end
  2039.     self.width = width
  2040.     self.height = @choices.size * 32 + 32
  2041.     self.contents = Bitmap.new(width - 32, height - 32)
  2042.     if $game_system.font_color.nil?
  2043.       self.contents.font.color = normal_color
  2044.     else
  2045.       self.contents.font.color = $game_system.font_color
  2046.     end
  2047.     if $game_system.windowskin != ""  
  2048.       self.windowskin = RPG::Cache.windowskin($game_system.windowskin)
  2049.     else
  2050.       self.windowskin = RPG::Cache.windowskin($data_system.windowskin_name)
  2051.     end
  2052.    
  2053.     # draw choices
  2054.     y = 0
  2055.     for line in @choices
  2056.       # Draw text
  2057.       if $game_system.shadowed_text
  2058.         old_color = self.contents.font.color.clone
  2059.         self.contents.font.color = $game_system.shadow_color
  2060.         self.contents.draw_text(6, 32 * y + 2, width, 32, line)
  2061.         self.contents.font.color = old_color
  2062.       end
  2063.       self.contents.draw_text(4, y * 32, width, 32, line)
  2064.       y += 1
  2065.     end
  2066.   end
  2067.      
  2068.   def set_choices(choices)
  2069.     @choices = choices
  2070.     @item_max = @choices.size
  2071.     for choice in @choices
  2072.       choice.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  2073.       choice.gsub!(/\\[Nn]\[([0-9]+)\]/) {
  2074.       # my edit, was $game_actors
  2075.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  2076.       }
  2077.     end
  2078.     refresh
  2079.   end
  2080. end
  2081.  
  2082. #==============================================================================
  2083. # ** Window_Name
  2084. #------------------------------------------------------------------------------
  2085. #  This window is used to display names above the message window.  Uncomment
  2086. #   and modify the various sections to customize.
  2087. #==============================================================================
  2088. class Window_Name < Window_Base
  2089.   attr_accessor :dummy_window
  2090.  
  2091.   def initialize
  2092.     super(0, 0, 32, 64)
  2093.     self.contents = Bitmap.new(32, 32)
  2094.     self.opacity = 0
  2095.    
  2096.     @dummy_window = Window_Dummy.new
  2097.    
  2098.     self.visible = false
  2099.   end
  2100.  
  2101.   def set_name(name)
  2102.     @name = name
  2103.     refresh
  2104.   end
  2105.  
  2106.   def refresh
  2107.     if @name == nil
  2108.       return
  2109.     end
  2110.     self.width = self.contents.text_size(@name).width + 48
  2111.     self.contents = Bitmap.new(width - 32, height - 32)
  2112.    
  2113.     if $game_system.name_window
  2114.       @dummy_window.x = self.x
  2115.       @dummy_window.y = self.y + 12
  2116.       @dummy_window.set(height - 24, width - 12)
  2117.     end
  2118.    
  2119.     # uncomment this and change the font to give the name window a fancy font
  2120.     #self.contents.font.name = "Ariel"
  2121.     self.contents.font.color = Color.new(0, 0, 0, 255)
  2122.     self.contents.draw_text(0, 0, self.width, 32, @name)
  2123.     self.contents.draw_text(0, 2, self.width, 32, @name)
  2124.     self.contents.draw_text(2, 0, self.width, 32, @name)
  2125.     self.contents.draw_text(2, 2, self.width, 32, @name)
  2126.     # change the color to give the name window a seperate color
  2127.     self.contents.font.color = normal_color
  2128.     self.contents.draw_text(1, 1, self.width, 32, @name)
  2129.   end
  2130.  
  2131.   def update
  2132.     super
  2133.     if $game_system.name_window
  2134.       @dummy_window.x = self.x
  2135.       @dummy_window.y = self.y + 12
  2136.       @dummy_window.update
  2137.     end
  2138.   end
  2139.  
  2140.   def dispose
  2141.     @dummy_window.dispose
  2142.     super
  2143.   end
  2144. end
  2145.  
  2146. class Window_Dummy < Window_Base
  2147.   def initialize
  2148.     super(0, 0, 32, 64)
  2149.     self.z = 9999
  2150.     self.visible = false
  2151.   end
  2152.  
  2153.   def set(height, width)
  2154.     self.height = height
  2155.     self.width = width
  2156.   end
  2157.  
  2158.   def update
  2159.     super
  2160.     if $game_system.windowskin != ""  
  2161.       self.windowskin = RPG::Cache.windowskin($game_system.windowskin)
  2162.     else
  2163.       self.windowskin = RPG::Cache.windowskin($data_system.windowskin_name)
  2164.     end
  2165.   end
  2166. end
  2167.  
  2168. #==============================================================================
  2169. # ** Window_Slave
  2170. #------------------------------------------------------------------------------
  2171. #  These are slave windows to the main message window.  They will close when
  2172. #   the user terminates them.  Initial settings are identical to the main
  2173. #   message window, with one exception.  When in normal mode, it will apear
  2174. #   above if the main message is below, below if it is above or centered.  Use
  2175. #   message codes to change the settings for this window.
  2176. #==============================================================================
  2177. class Window_Slave < Window_Base
  2178.   attr_accessor :show
  2179.   attr_reader :done
  2180.  
  2181.   def write_all
  2182.     @write_all = true
  2183.   end
  2184.  
  2185.   #--------------------------------------------------------------------------
  2186.   # * Object Initialization
  2187.   #--------------------------------------------------------------------------
  2188.   def initialize (text)
  2189.     super(0, 0, 33, 33)
  2190.     @text = text
  2191.    
  2192.     # x-coordinate depends on justification
  2193.     if @justification == RIGHT
  2194.       self.x = 640 - self.width
  2195.     elsif @justification == LEFT
  2196.       self.x = 0
  2197.     else # center
  2198.       self.x = (640 - self.width) / 2
  2199.     end
  2200.     # y-coordinate depends on height
  2201.     self.y = 480 - $game_system.window_height - 16
  2202.     self.contents = Bitmap.new(width - 32, height - 32)
  2203.     self.visible = false
  2204.     self.z = 9998
  2205.     @fade_in = false
  2206.     @fade_out = false
  2207.     @contents_showing = false
  2208.    
  2209.     # face graphic sprite
  2210.     @face = Sprite.new
  2211.     @face.opacity = 0
  2212.     @face.z = self.z + 1
  2213.     @face_offset = 0
  2214.    
  2215.     # choice window
  2216.     @choice_window = Window_Choice.new([])
  2217.     @choice_window.back_opacity = $game_system.back_opacity
  2218.    
  2219.     @comic_style = $game_system.comic_style
  2220.     @name = $game_system.name
  2221.    
  2222.     # comic sprite
  2223.     @comic = Sprite.new
  2224.     @comic.opacity = 0
  2225.     @comic.z = self.z + 1
  2226.     if @comic_style == TALK1
  2227.       @comic.bitmap = RPG::Cache.windowskin("talk1")
  2228.     elsif @comic_style == TALK2
  2229.       @comic.bitmap = RPG::Cache.windowskin("talk2")
  2230.     else # thought
  2231.       @comic.bitmap = RPG::Cache.windowskin("thought")
  2232.     end
  2233.    
  2234.    
  2235.    
  2236.     @pause_time = 0
  2237.     @wait = 0
  2238.    
  2239.     @mode = $game_system.ums_mode
  2240.     self.height = $game_system.window_height
  2241.     self.width = $game_system.window_width
  2242.     @justification = $game_system.window_justification
  2243.     @face_graphic = $game_system.face_graphic
  2244.     @face_graphic_justification = $game_system.face_graphic_justification
  2245.     @message_event = $game_system.message_event
  2246.     if $game_system.message_position == 2 # down
  2247.       @message_position = 0
  2248.     else
  2249.       @message_postion = 2
  2250.     end
  2251.     @face_graphic_position = $game_system.face_graphic_position
  2252.     if $game_system.font == ""
  2253.       @font = Font.default_name
  2254.     else
  2255.       @font = $game_system.font
  2256.     end
  2257.     @text_justification = $game_system.text_justification
  2258.    
  2259.     @shake = $game_system.shake
  2260.    
  2261.     @face_frame = 0
  2262.    
  2263.     refresh
  2264.   end
  2265.   #--------------------------------------------------------------------------
  2266.   # * Dispose
  2267.   #--------------------------------------------------------------------------
  2268.   def dispose
  2269.     terminate_message
  2270.     $game_temp.message_window_showing = false
  2271.     if @input_number_window != nil
  2272.       @input_number_window.dispose
  2273.     end
  2274.     @face.dispose
  2275.     @choice_window.dispose
  2276.     @comic.dispose
  2277.     if @name_window != nil
  2278.       @name_window.dispose
  2279.     end
  2280.     super
  2281.   end
  2282.   #--------------------------------------------------------------------------
  2283.   # * Terminate Message
  2284.   #--------------------------------------------------------------------------
  2285.   def terminate_message
  2286.     self.active = false
  2287.     self.pause = false
  2288.     self.contents.clear
  2289.     # Clear showing flag
  2290.     @contents_showing = false
  2291.     # Call message callback
  2292.     if $game_temp.message_proc != nil
  2293.       $game_temp.message_proc.call
  2294.     end
  2295.     # Clear variables related to text, choices, and number input
  2296.     $game_temp.message_text = nil
  2297.     $game_temp.message_proc = nil
  2298.     $game_temp.choice_start = 99
  2299.     $game_temp.choice_max = 0
  2300.     $game_temp.choice_cancel_type = 0
  2301.     $game_temp.choice_proc = nil
  2302.     $game_temp.num_input_start = 99
  2303.     $game_temp.num_input_variable_id = 0
  2304.     $game_temp.num_input_digits_max = 0
  2305.     # Open gold window
  2306.     if @gold_window != nil
  2307.       @gold_window.dispose
  2308.       @gold_window = nil
  2309.     end
  2310.     @choice_window.visible = false
  2311.     @choice_window.active = false
  2312.     @comic.opacity = 0
  2313.   end
  2314.   #--------------------------------------------------------------------------
  2315.   # * Refresh
  2316.   #--------------------------------------------------------------------------
  2317.   def refresh
  2318.    
  2319.     self.contents.clear
  2320.     if $game_system.font_color.nil?
  2321.       self.contents.font.color = normal_color
  2322.     else
  2323.       self.contents.font.color = $game_system.font_color
  2324.     end
  2325.     if $game_system.windowskin != ""  
  2326.       self.windowskin = RPG::Cache.windowskin($game_system.windowskin)
  2327.     else
  2328.       self.windowskin = RPG::Cache.windowskin($data_system.windowskin_name)
  2329.     end
  2330.     @x = @y = 0
  2331.  
  2332.     # If waiting for a message to be displayed
  2333.     if @text != nil
  2334.       # replace shortcuts with original code
  2335.       $game_system.shortcuts.each { |shortcut, code|
  2336.         @text.gsub!(shortcut, code)
  2337.       }
  2338.      
  2339.       # Control text processing
  2340.       begin
  2341.         last_text = @text.clone
  2342.         @text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  2343.       end until @text == last_text
  2344.       @text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  2345.         # my edit was $game_actors
  2346.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  2347.       end
  2348.      
  2349.       # window mode
  2350.       if @text.index(/\\[Mm]/) != nil
  2351.         if $game_system.ums_mode == NORMAL_MODE
  2352.           @mode = FIT_WINDOW_TO_TEXT
  2353.         else
  2354.           @mode = NORMAL_MODE
  2355.         end
  2356.         @text.gsub!(/\\[Mm]/) { "" }
  2357.       end
  2358.      
  2359.       # window height
  2360.       @text.gsub!(/\\[Hh][Ee][Ii][Gg][Hh][Tt]\[([0-9]+)\]/) do
  2361.         self.height = $1.to_i
  2362.         ""
  2363.       end
  2364.      
  2365.       # window width
  2366.       @text.gsub!(/\\[Ww][Ii][Dd][Tt][Hh]\[([0-9]+)\]/) do
  2367.         self.width = $1.to_i
  2368.         ""
  2369.       end
  2370.      
  2371.       # justification
  2372.       @text.gsub!(/\\[Jj][Rr]/) do
  2373.         @justification = RIGHT
  2374.         reset_window
  2375.         ""
  2376.       end
  2377.       @text.gsub!(/\\[Jj][Cc]/) do
  2378.         @justification = CENTER
  2379.         reset_window
  2380.         ""
  2381.       end      
  2382.       @text.gsub!(/\\[Jj][Ll]/) do
  2383.         @justification = LEFT
  2384.         reset_window
  2385.         ""
  2386.       end
  2387.      
  2388.       # face graphics
  2389.       @text.gsub!(/\\[Ff][Aa][Cc][Ee]\[(.*?)\]/) do
  2390.         @face_graphic = $1.to_s
  2391.         if $1.to_s == ""
  2392.           @face.opacity = 0
  2393.         end
  2394.         ""
  2395.       end
  2396.       @text.gsub!(/\\[Ff][Ll]/) do
  2397.         @face_graphic_justification = LEFT
  2398.         ""
  2399.       end
  2400.       @text.gsub!(/\\[Ff][Rr]/) do
  2401.         @face_graphic_justification = RIGHT
  2402.         ""
  2403.       end
  2404.      
  2405.       # event centering
  2406.       @text.gsub!(/\\[Ee]\[([0-9]+)\]/) do
  2407.         @message_event = $1.to_i
  2408.         ""
  2409.       end
  2410.      
  2411.       # comic thingy
  2412.       @text.gsub!(/\\[Tt]1/) do
  2413.         @comic_style = TALK1
  2414.         @comic.bitmap = RPG::Cache.windowskin("talk1.png")
  2415.         ""
  2416.       end
  2417.       @text.gsub!(/\\[Tt]2/) do
  2418.         @comic_style = TALK2
  2419.         @comic.bitmap = RPG::Cache.windowskin("talk2.png")
  2420.         ""
  2421.       end
  2422.       @text.gsub!(/\\[Tt][Hh]/) do
  2423.         @comic_style = THOUGHT
  2424.         @comic.bitmap = RPG::Cache.windowskin("thought.png")
  2425.         ""
  2426.       end
  2427.      
  2428.       # name window
  2429.       @text.gsub!(/\\[Nn][Mm]\[(.*?)\]/) do
  2430.         @name = $1.to_s
  2431.         if $1.to_s == "" and @name_window != nil
  2432.           @name_window.visible = false
  2433.         end
  2434.         ""
  2435.       end
  2436.       if @name != ""
  2437.         # name window
  2438.         @name_window = Window_Name.new
  2439.         @name_window.z = self.z + 1
  2440.         @name_window.set_name(@name)
  2441.       end
  2442.      
  2443.       # shaking
  2444.       @text.gsub!(/\\[Ss][Hh][Kk]\[([0-9]+)\]/) do
  2445.         @shake = $1.to_i
  2446.         ""
  2447.       end
  2448.      
  2449.       # back opacity
  2450.       @text.gsub!(/\\[Bb][Oo][Pp][Cc]\[([0-9]+)\]/) do
  2451.         self.back_opacity = $1.to_i
  2452.         ""
  2453.       end
  2454.      
  2455.       # opacity
  2456.       @text.gsub!(/\\[Oo][Pp][Cc]\[([0-9]+)\]/) do
  2457.         self.opacity = $1.to_i
  2458.         ""
  2459.       end
  2460.      
  2461.       # Change "\\\\" to "\000" for convenience
  2462.       @text.gsub!(/\\\\/) { "\000" }
  2463.       # Change "\\C" to "\001" and "\\G" to "\002"
  2464.       @text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  2465.       @text.gsub!(/\\[Gg]/) { "\002" }
  2466.       @text.gsub!(/\\[Cc]\[0x([0123456789abcdef]+)\]/) { "\026[#{$1}]" }
  2467.      
  2468.       # text skip code
  2469.       @text.gsub!(/\\[Ss][Kk][Ii][Pp]/) { "\003" }
  2470.      
  2471.       # ignore code
  2472.       @text.gsub!(/\\[Ii][Gg][Nn][Rr]/) { "\023" }
  2473.      
  2474.       # bold and italics
  2475.       @text.gsub!(/\\[Bb]/) { "\004" }
  2476.       @text.gsub!(/\\[Ii]/) { "\005" }
  2477.      
  2478.       # shadow
  2479.       @text.gsub!(/\\[Ss]/) { "\006" }
  2480.      
  2481.       # font
  2482.       @text.gsub!(/\\[Ff][Oo][Nn][Tt]\[(.*?)\]/) { "\007[#{$1}]" }
  2483.      
  2484.       # pause and wait
  2485.       @text.gsub!(/\\[Pp]\[([0-9]+)\]/) { "\010[#{$1}]" }
  2486.       @text.gsub!(/\\[Ww]\[([0-9]+)\]/) { "\011[#{$1}]" }
  2487.      
  2488.       # write speed
  2489.       @text.gsub!(/\\[Ww][Ss]\[([0-9]+)\]/) { "\013[#{$1}]" }
  2490.            
  2491.       # armor, items, skills, and weapons
  2492.       @text.gsub!(/\\[Oo][Aa]\[([0-9]+)\]/) {
  2493.         item = $data_armors[$1.to_i]
  2494.         "\014[#{$1}]" + "  " + item.name
  2495.       }
  2496.       @text.gsub!(/\\[Oo][Ii]\[([0-9]+)\]/) {
  2497.         item = $data_items[$1.to_i]
  2498.         "\015[#{$1}]" + "  " + item.name
  2499.       }
  2500.       @text.gsub!(/\\[Oo][Ss]\[([0-9]+)\]/) {
  2501.         item = $data_skills[$1.to_i]
  2502.         "\016[#{$1}]" + "  " + item.name
  2503.       }
  2504.       @text.gsub!(/\\[Oo][Ww]\[([0-9]+)\]/) {
  2505.         item = $data_weapons[$1.to_i]
  2506.         "\017[#{$1}]" + "  " + item.name
  2507.       }
  2508.      
  2509.       # text justification
  2510.       @text.gsub!(/\\[Tt][Cc]/) { "\020" }
  2511.       @text.gsub!(/\\[Tt][Ll]/) { "\021" }
  2512.       @text.gsub!(/\\[Tt][Rr]/) { "\022" }
  2513.      
  2514.       # Resize the window to fit the contents?
  2515.       if @mode == FIT_WINDOW_TO_TEXT
  2516.         width = 1
  2517.         text = @text.split("\n")
  2518.         height = 0
  2519.         i = 0
  2520.         for line in text
  2521.           # don't count this line's width if it has the ignr code
  2522.           if !line.include?("\023")
  2523.             width = [width, self.contents.text_size(line).width].max
  2524.             delta = self.contents.text_size(line).height
  2525.             height += delta + (6 * i) + 3
  2526.             if i < 3
  2527.               i += 1
  2528.             end
  2529.           end
  2530.         end
  2531.        
  2532.         if @face_graphic != "" and ($game_system.face_graphic_position == CENTER or $game_system.face_graphic_position == BOTTOM)
  2533.           width += @face.bitmap.width
  2534.           if height < @face.bitmap.height
  2535.             height = @face.bitmap.height - 32
  2536.           end
  2537.         end
  2538.        
  2539.         if height == 0
  2540.           height = 1
  2541.         end
  2542.          
  2543.         self.width = width + 48
  2544.         self.height = height + 48
  2545.         self.contents = Bitmap.new(width + 16, height)
  2546.         if $game_system.font_color.nil?
  2547.           self.contents.font.color = normal_color
  2548.         else
  2549.           self.contents.font.color = $game_system.font_color
  2550.         end
  2551.  
  2552.       else
  2553.         if self.width != $game_system.window_height or self.height != $game_system.window_width
  2554.           self.width = $game_system.window_width
  2555.           self.height = $game_system.window_height
  2556.           self.contents = Bitmap.new(self.width - 32, self.height - 32)
  2557.           if $game_system.font_color.nil?
  2558.             self.contents.font.color = normal_color
  2559.           else
  2560.             self.contents.font.color = $game_system.font_color
  2561.           end
  2562.         end
  2563.       end
  2564.      
  2565.       reset_window
  2566.      
  2567.       get_x_value
  2568.      
  2569.       @count = Graphics.frame_count
  2570.       @pause_time = 0
  2571.       @ignore = false
  2572.       @done = false
  2573.       @face_frame = 0
  2574.     end
  2575.    
  2576.    
  2577.    
  2578.     # If number input
  2579.     if $game_temp.num_input_variable_id > 0
  2580.       digits_max = $game_temp.num_input_digits_max
  2581.       number = $game_variables[$game_temp.num_input_variable_id]
  2582.       @input_number_window = Window_InputNumber.new(digits_max)
  2583.       @input_number_window.number = number
  2584.       @input_number_window.x = self.x + 8
  2585.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  2586.     end
  2587.   end
  2588.   #--------------------------------------------------------------------------
  2589.   # * Set Window Position and Opacity Level
  2590.   #--------------------------------------------------------------------------
  2591.   def reset_window (change_opacity = true)
  2592.     # x-coordinate depends on justification
  2593.     if @message_event == -1
  2594.       if @justification == RIGHT
  2595.         self.x = 640 - self.width
  2596.       elsif @justification == LEFT
  2597.         self.x = 0
  2598.       else # center
  2599.         self.x = (640 - self.width) / 2
  2600.       end
  2601.     else
  2602.       if @message_event == 0 or $game_map.events[@message_event] == nil
  2603.         # center on player
  2604.         event_x = $game_player.screen_x
  2605.       else
  2606.         # center on the event specified
  2607.         event_x = $game_map.events[@message_event].screen_x
  2608.       end
  2609.       self.x = event_x - self.width / 2
  2610.       @comic.x = self.x + (self.width / 2) + 4
  2611.     end
  2612.    
  2613.     if $game_temp.in_battle
  2614.       self.y = 16
  2615.     else
  2616.       if @message_event == -1
  2617.         case @message_position
  2618.           when 0  # up
  2619.             self.y = 16
  2620.           when 1  # middle
  2621.             self.y = (480 - self.height) / 2
  2622.           when 2  # down
  2623.             self.y = 480 - self.height - 24
  2624.         end
  2625.       else
  2626.         if @message_event == 0 or $game_map.events[@message_event] == nil
  2627.           # above player
  2628.           self.y = $game_player.screen_y - self.height - 48
  2629.         else
  2630.           # above event specified
  2631.           self.y = $game_map.events[@message_event].screen_y - self.height - 48
  2632.         end
  2633.         @comic.y = self.y + self.height - 2
  2634.       end
  2635.     end
  2636.     if self.y < 0 + (@name == "" ? 0 : 16)
  2637.       self.y = 0 + (@name == "" ? 0 : 16)
  2638.     elsif self.y > 480 - self.height
  2639.       self.y = 480 - self.height
  2640.     end
  2641.     if self.x < 0
  2642.       self.x = 0
  2643.     elsif self.x > 680 - self.width - 48
  2644.       self.x = 640 - self.width
  2645.     end
  2646.    
  2647.     if change_opacity
  2648.       if $game_system.message_frame == 0
  2649.         self.opacity = 255
  2650.       else
  2651.         self.opacity = 0
  2652.       end
  2653.       self.back_opacity = $game_system.back_opacity
  2654.     end
  2655.    
  2656.     # face stuff
  2657.       if @face_graphic != ""  
  2658.         # the player has chosen to show a face graphic
  2659.         if @done and $game_system.resting_face != ""
  2660.           @face.bitmap = RPG::Cache.picture(@face_graphic + $game_system.resting_face)
  2661.           if @face_frame * $game_system.face_frame_width >= @face.bitmap.width
  2662.             @face_frame = 0
  2663.           end
  2664.         else
  2665.           @face.bitmap = RPG::Cache.picture(@face_graphic)
  2666.         end
  2667.        
  2668.         # picture y-coordinate
  2669.         if @face_graphic_position == ABOVE
  2670.           @face.y = self.y - @face.bitmap.height
  2671.           @face_offset = 0
  2672.         elsif @face_graphic_position == CENTER
  2673.           delta = (@face.bitmap.height - self.height) / 2
  2674.           @face.y = self.y - delta
  2675.           if $game_system.animated_faces
  2676.             @face_offset = $game_system.face_frame_width + 16
  2677.           else
  2678.             @face_offset = @face.bitmap.width + 16
  2679.           end
  2680.         elsif @face_graphic_position == BOTTOM
  2681.           @face.y = self.y + self.height - @face.bitmap.height
  2682.           if $game_system.animated_faces
  2683.             @face_offset = $game_system.face_frame_width + 16
  2684.           else
  2685.             @face_offset = @face.bitmap.width + 16
  2686.           end
  2687.         else # side
  2688.           delta = (@face.bitmap.height - self.height) / 2
  2689.           @face.y = self.y - delta
  2690.           @face_offset = 0
  2691.         end
  2692.        
  2693.         # picture x-coordinate
  2694.         if @face_graphic_justification == LEFT
  2695.           if @face_graphic_position == SIDE
  2696.             @face.x = self.x - @face.bitmap.width
  2697.           else
  2698.             @face.x = self.x + 10
  2699.           end
  2700.         else
  2701.           if $game_system.animated_faces
  2702.             offset = @face.bitmap.width - $game_system.face_frame_width
  2703.           else
  2704.             offset = 0
  2705.           end
  2706.           if @face_graphic_position == SIDE
  2707.             @face.x = self.x + self.width + offset
  2708.           else
  2709.             @face.x = self.x + self.width - @face.bitmap.width - 10 + offset
  2710.             @face_offset = 0
  2711.           end
  2712.         end
  2713.        
  2714.         if $game_system.animated_faces
  2715.           @face.src_rect = Rect.new(@face_frame * $game_system.face_frame_width, 0, $game_system.face_frame_width, @face.bitmap.height)
  2716.           if @done and $game_system.resting_face != ""
  2717.             pause = $game_system.resting_animation_pause
  2718.           else
  2719.             pause = $game_system.animation_pause
  2720.           end
  2721.           if Graphics.frame_count % pause == 0
  2722.             @animate_face = true
  2723.           end
  2724.           if @animate_face
  2725.             if Graphics.frame_count % 3 == 0
  2726.               @face_frame += 1
  2727.               if @face_frame * $game_system.face_frame_width >= @face.bitmap.width
  2728.                 @face_frame = 0
  2729.                 @animate_face = false
  2730.               end
  2731.             end
  2732.           end
  2733.         end
  2734.       end
  2735.      
  2736.       # name window
  2737.       if @name != "" and @name != nil
  2738.         @name_window.set_name(@name)
  2739.         @name_window.x = self.x
  2740.         @name_window.y = self.y - 36
  2741.       end
  2742.      
  2743.       # If choice
  2744.     if $game_temp.choice_max > 0
  2745.       @choice_window.set_choices($game_temp.choices)
  2746.       # determine x and y coords for choice window
  2747.       if $game_system.choice_justification == LEFT
  2748.         @choice_window.x = self.x
  2749.       else
  2750.         @choice_window.x = self.x + self.width - @choice_window.width
  2751.       end
  2752.       if $game_system.choice_position == ABOVE
  2753.         # check to make sure there is enough room above the textbox
  2754.         if self.y < @choice_window.height
  2755.           # not enough room above, place below
  2756.           @choice_window.y = self.y + self.height
  2757.         else
  2758.           # draw above
  2759.           @choice_window.y = self.y - @choice_window.height
  2760.         end
  2761.       elsif $game_system.choice_position == BOTTOM
  2762.         # check to make sure there is enough room below the textbox
  2763.         if (480 - self.y - self.height) < @choice_window.height
  2764.           # not enough room below, place above
  2765.           @choice_window.y = self.y - @choice_window.height
  2766.         else
  2767.           # draw below
  2768.           @choice_window.y = self.y + self.height
  2769.         end
  2770.       else # side
  2771.         if $game_system.choice_justification == LEFT
  2772.           # check to make sure there's room on the left side
  2773.           if self.y < @choice_window.width
  2774.             # not enough room on the side, check to make sure there's room below
  2775.             if (480 - self.y - self.height) < @choice_window.height
  2776.               # not enough room below, place above
  2777.               @choice_window.y = self.y - @choice_window.height
  2778.             else
  2779.               # draw below
  2780.               @choice_window.y = self.y + self.height
  2781.             end
  2782.           else
  2783.             # place on the left side
  2784.             @choice_window.y = self.y
  2785.             @choice_window.x = self.x - @choice_window.width
  2786.           end
  2787.         else # right
  2788.           # check to make sure there's room on the right side
  2789.           if (680 - (self.y + self.width)) < @choice_window.width
  2790.             # not enough room on the side, check to make sure there's room below
  2791.             if (480 - self.y - self.height) < @choice_window.height
  2792.               # not enough room below, place above
  2793.               @choice_window.y = self.y - @choice_window.height
  2794.             else
  2795.               # draw below
  2796.               @choice_window.y = self.y + self.height
  2797.             end
  2798.           else
  2799.             # place on the left side
  2800.             @choice_window.y = self.y
  2801.             @choice_window.x = self.x + self.width
  2802.           end
  2803.         end
  2804.       end
  2805.     end
  2806.   end
  2807.   #--------------------------------------------------------------------------
  2808.   # * Frame Update
  2809.   #--------------------------------------------------------------------------
  2810.   def update
  2811.     super
  2812.    
  2813.     if !@show
  2814.       return
  2815.     else
  2816.       self.visible = true
  2817.       if @face_graphic != ""
  2818.         @face.opacity = 255
  2819.       end
  2820.       if $game_system.comic_enabled and @message_event != -1
  2821.         @comic.opacity = 255
  2822.       end
  2823.       if @name != ""
  2824.         @name_window.visible = true
  2825.       end
  2826.       if @input_number_window != nil
  2827.         @input_number_window.contents_opacity = 255
  2828.       end
  2829.       reset_window
  2830.     end
  2831.    
  2832.    
  2833.     if (@contents_showing and $game_system.message_event != -1 and @shake == 0) or $game_system.animated_faces
  2834.       reset_window(false)
  2835.     end
  2836.    
  2837.     if $game_system.shake != 0  # shake the window
  2838.       if @ascending
  2839.         if @target_x != self.x
  2840.           self.x += 1
  2841.         else
  2842.           @ascending = false
  2843.           @target_x = self.x - ($game_system.shake * 2)
  2844.         end
  2845.       else
  2846.         if @target_x != self.x
  2847.           self.x -= 1
  2848.         else
  2849.           @ascending = true
  2850.           @target_x = self.x + ($game_system.shake * 2)
  2851.         end
  2852.       end
  2853.     end
  2854.    
  2855.     if @wait > 0
  2856.       @wait -= 1
  2857.       if @wait == 0
  2858.         terminate_message
  2859.         return
  2860.       end
  2861.     end
  2862.    
  2863.     # If fade in
  2864.     if @fade_in
  2865.       self.contents_opacity += 24
  2866.       if @face_graphic != ""
  2867.         @face.opacity += 24
  2868.       end
  2869.       if $game_system.comic_enabled and @message_event != -1
  2870.         @comic.opacity += 24
  2871.       end
  2872.       if @name != ""
  2873.         @name_window.visible = true
  2874.       end
  2875.       if @input_number_window != nil
  2876.         @input_number_window.contents_opacity += 24
  2877.       end
  2878.       if self.contents_opacity == 255
  2879.         @fade_in = false
  2880.       end
  2881.       return
  2882.     end
  2883.    
  2884.     # write the text
  2885.     if @text != nil and @text != ""
  2886.       speed = $game_system.write_speed
  2887.       if $game_system.text_skip
  2888.         if $game_system.skip_mode == WRITE_FASTER and Input.press?(Input::C)
  2889.           # the player is holding the action button, write faster
  2890.           speed /= 3
  2891.         elsif $game_system.skip_mode == WRITE_ALL and @write_all
  2892.           # the player pressed the action button, write all the text
  2893.           while (c = @text.slice!(/./m)) != nil
  2894.             write_char(c)
  2895.           end
  2896.           return
  2897.         end
  2898.       end
  2899.       while @ignore
  2900.         c = @text.slice!(/./m)
  2901.         if c != nil
  2902.           write_char(c)
  2903.         end
  2904.       end
  2905.       if @pause_time > 0
  2906.         @pause_time -= 1
  2907.         return
  2908.       end
  2909.       if Graphics.frame_count - @count >= speed
  2910.         if $game_system.sound_effect != ""
  2911.           Audio.se_play("Audio/SE/" + $game_system.sound_effect, 80, 100)
  2912.         end
  2913.         @count = Graphics.frame_count
  2914.         c = @text.slice!(/./m)
  2915.         if c != nil
  2916.           write_char(c)
  2917.         end
  2918.       end
  2919.       return
  2920.     end
  2921.    
  2922.     @done = true
  2923.    
  2924.     # If inputting number
  2925.     if @input_number_window != nil
  2926.       @input_number_window.update
  2927.       # Confirm
  2928.       if Input.trigger?(Input::C)
  2929.         $game_system.se_play($data_system.decision_se)
  2930.         $game_variables[$game_temp.num_input_variable_id] =
  2931.           @input_number_window.number
  2932.         $game_map.need_refresh = true
  2933.         # Dispose of number input window
  2934.         @input_number_window.dispose
  2935.         @input_number_window = nil
  2936.         terminate_message
  2937.       end
  2938.       return
  2939.     end
  2940.    
  2941.     if @wait != 0
  2942.       return
  2943.     end
  2944.    
  2945.     # If message is being displayed and contents are all written
  2946.     if @contents_showing
  2947.       # if choice
  2948.       if $game_temp.choice_max > 0
  2949.         if !@choice_window.active
  2950.           @choice_window.visible = true
  2951.           @choice_window.active = true
  2952.           @choice_window.index = 0
  2953.         end
  2954.         @choice_window.update
  2955.       else
  2956.         # If choice isn't being displayed, show pause sign
  2957.         self.pause = true
  2958.       end
  2959.       return
  2960.     end
  2961.   end
  2962.  
  2963.   #--------------------------------------------------------------------------
  2964.   # * Process and write the given character
  2965.   #--------------------------------------------------------------------------
  2966.   def write_char(c)
  2967.     if c == "\000"
  2968.       # Return to original text
  2969.       c = "\\"
  2970.     end
  2971.     # If \C[n]
  2972.     if c == "\001"
  2973.     # Change text color
  2974.       @text.sub!(/\[([0-9]+)\]/, "")
  2975.       color = $1.to_i
  2976.       if color >= 0 and color <= 7
  2977.         self.contents.font.color = text_color(color)
  2978.       end
  2979.       # go to next text
  2980.       return
  2981.     end
  2982.     # If \G
  2983.     if c == "\002"
  2984.       # Make gold window
  2985.       if @gold_window == nil
  2986.         @gold_window = Window_Gold.new
  2987.         @gold_window.x = 560 - @gold_window.width
  2988.         if $game_temp.in_battle
  2989.           @gold_window.y = 192
  2990.         else
  2991.           @gold_window.y = self.y >= 128 ? 32 : 384
  2992.         end
  2993.         @gold_window.opacity = self.opacity
  2994.         @gold_window.back_opacity = self.back_opacity
  2995.       end
  2996.       # go to next text
  2997.       return
  2998.     end
  2999.     # If \skip
  3000.     if c == "\003"
  3001.       # toggle text skipping
  3002.       #$game_system.text_skip = !$game_system.text_skip
  3003.       # go to next text
  3004.       return
  3005.     end
  3006.     # If \b
  3007.     if c == "\004"
  3008.       # toggle bold
  3009.       self.contents.font.bold = !self.contents.font.bold
  3010.       # go to next text
  3011.       return
  3012.     end
  3013.     # If \i
  3014.     if c == "\005"
  3015.       # toggle italics
  3016.       self.contents.font.italic = !self.contents.font.italic
  3017.       # go to next text
  3018.       return
  3019.     end
  3020.     # If \s
  3021.     if c == "\006"
  3022.       # toggle shadow
  3023.       #$game_system.shadowed_text = !$game_system.shadowed_text
  3024.       # go to next text
  3025.       return
  3026.     end
  3027.     # If \font
  3028.     if c == "\007"
  3029.       # change font
  3030.       @text.sub!(/\[(.*?)\]/, "")
  3031.       font = $1.to_s
  3032.       @font = font
  3033.       if font == ""
  3034.         self.contents.font.name = Font.default_name
  3035.       else
  3036.         self.contents.font.name = font
  3037.       end
  3038.       # go to next text
  3039.       return
  3040.     end
  3041.     # If \p[n]
  3042.     if c == "\010"
  3043.       @text.sub!(/\[([0-9]+)\]/, "")
  3044.       @pause_time = $1.to_i
  3045.  
  3046.       # go to next text
  3047.       return
  3048.     end
  3049.    
  3050.     # If \w[n]
  3051.     if c == "\011"
  3052.       @text.sub!(/\[([0-9]+)\]/, "")
  3053.       @wait = $1.to_i
  3054.  
  3055.       # go to next text
  3056.       return
  3057.     end
  3058.    
  3059.     # If \ws[n]
  3060.     if c == "\013"
  3061.       @text.sub!(/\[([0-9]+)\]/, "")
  3062.       $game_system.write_speed = $1.to_i
  3063.  
  3064.       # go to next text
  3065.       return
  3066.     end
  3067.     # If \oa[n]
  3068.     if c == "\014"
  3069.       @text.sub!(/\[([0-9]+)\]/, "")
  3070.       index = $1.to_i
  3071.       @text.sub!("  ", "")
  3072.       item = $data_armors[index]
  3073.       # draw the icon
  3074.       icon = RPG::Cache.icon(item.icon_name)
  3075.       self.contents.blt(@x + 2, (@y * 32) + 4, icon, Rect.new(0, 0, 24, 24))
  3076.       @x += 24
  3077.  
  3078.       # go to next text
  3079.       return
  3080.     end
  3081.    
  3082.     # If \oi[n]
  3083.     if c == "\015"
  3084.       @text.sub!(/\[([0-9]+)\]/, "")
  3085.       index = $1.to_i
  3086.       @text.sub!("  ", "")
  3087.       item = $data_items[index]
  3088.       # draw the icon
  3089.       icon = RPG::Cache.icon(item.icon_name)
  3090.       self.contents.blt(@x + 2, (@y * 32) + 4, icon, Rect.new(0, 0, 24, 24))
  3091.       @x += 24
  3092.  
  3093.       # go to next text
  3094.       return
  3095.     end
  3096.    
  3097.     # If \os[n]
  3098.     if c == "\016"
  3099.       @text.sub!(/\[([0-9]+)\]/, "")
  3100.       index = $1.to_i
  3101.       @text.sub!("  ", "")
  3102.       item = $data_skills[index]
  3103.       # draw the icon
  3104.       icon = RPG::Cache.icon(item.icon_name)
  3105.       self.contents.blt(@x + 2, (@y * 32) + 4, icon, Rect.new(0, 0, 24, 24))
  3106.       @x += 24
  3107.  
  3108.       # go to next text
  3109.       return
  3110.     end
  3111.    
  3112.     # If \ow[n]
  3113.     if c == "\017"
  3114.       @text.sub!(/\[([0-9]+)\]/, "")
  3115.       index = $1.to_i
  3116.       @text.sub!("  ", "")
  3117.       item = $data_weapons[index]
  3118.       # draw the icon
  3119.       icon = RPG::Cache.icon(item.icon_name)
  3120.       self.contents.blt(@x + 2, (@y * 32) + 4, icon, Rect.new(0, 0, 24, 24))
  3121.       @x += 24
  3122.      
  3123.       # go to next text
  3124.       return
  3125.     end
  3126.    
  3127.     # If \tc
  3128.     if c == "\020"
  3129.       # center justify
  3130.       @text_justification = CENTER
  3131.       get_x_value
  3132.       # go to next text
  3133.       return
  3134.     end
  3135.    
  3136.     # If \tl
  3137.     if c == "\021"
  3138.       # left justify
  3139.       @text_justification = LEFT
  3140.       get_x_value
  3141.       # go to next text
  3142.       return
  3143.     end
  3144.    
  3145.     # If \tr
  3146.     if c == "\022"
  3147.       # right justify
  3148.       @text_justification = RIGHT
  3149.       get_x_value
  3150.       # go to next text
  3151.       return
  3152.     end
  3153.    
  3154.     # If \ignr
  3155.     if c == "\023"
  3156.       # set ignore flage
  3157.       @ignore = true
  3158.       # go to next text
  3159.       return
  3160.     end
  3161.    
  3162.     # if \c (hex color)
  3163.     if c == "\026"
  3164.       # convert hex color to RGB
  3165.       @text.sub!(/\[([0123456789abcdef]+)\]/, "")
  3166.       hex_code = $1.to_s
  3167.      
  3168.       red   = ("0x" + hex_code.slice(0..1)).hex
  3169.       blue  = ("0x" + hex_code.slice(2..3)).hex
  3170.       green = ("0x" + hex_code.slice(4..5)).hex
  3171.      
  3172.       self.contents.font.color = Color.new(red, blue, green)
  3173.       return
  3174.     end
  3175.    
  3176.     # If new line text
  3177.     if c == "\n"
  3178.       # Add 1 to y
  3179.       if !@ignore
  3180.         @y += 1
  3181.       end
  3182.       if @text != ""
  3183.         get_x_value
  3184.       end
  3185.       @ignore = false
  3186.  
  3187.       # go to next text
  3188.       return
  3189.     end
  3190.     if @ignore
  3191.       return
  3192.     end
  3193.     # Draw text
  3194.     line = self.contents.text_size("dj").height
  3195.     if $game_system.shadowed_text
  3196.       old_color = self.contents.font.color.clone
  3197.       self.contents.font.color = $game_system.shadow_color
  3198.       self.contents.draw_text(6 + @x, line * @y + 2, 40, 32, c)
  3199.       self.contents.font.color = old_color
  3200.     end
  3201.     self.contents.draw_text(4 + @x, line * @y, 40, 32, c)
  3202.     # Add x to drawn text width
  3203.     @x += self.contents.text_size(c).width
  3204.   end
  3205.  
  3206.   def get_x_value
  3207.     # text justification - offset for first line
  3208.     if @text_justification == CENTER
  3209.       # get the length of the current line
  3210.       w = self.contents.text_size(@text.split("\n")[0]).width
  3211.       @x = (self.width - w - 48) / 2
  3212.     elsif @text_justification == RIGHT
  3213.       # get the length of the current line
  3214.       w = self.contents.text_size(@text.split("\n")[0]).width
  3215.       @x = self.width - w - 48
  3216.     else # left
  3217.       if @face_graphic == ""
  3218.         @x = 0
  3219.       else
  3220.         @x = @face_offset
  3221.       end
  3222.     end
  3223.   end
  3224. end
  3225.  
  3226. #==============================================================================
  3227. # ** Window_InputNumber
  3228. #------------------------------------------------------------------------------
  3229. #  This window is for inputting numbers, and is used within the
  3230. #  message window.
  3231. #==============================================================================
  3232.  
  3233. class Window_InputNumber < Window_Base
  3234.   #--------------------------------------------------------------------------
  3235.   # * Object Initialization
  3236.   #     digits_max : digit count
  3237.   #--------------------------------------------------------------------------
  3238.   def initialize(digits_max)
  3239.     @digits_max = digits_max
  3240.     @number = 0
  3241.     # Calculate cursor width from number width (0-9 equal width and postulate)
  3242.     dummy_bitmap = Bitmap.new(32, 32)
  3243.     @cursor_width = dummy_bitmap.text_size("0").width + 8
  3244.     dummy_bitmap.dispose
  3245.     super(0, 0, @cursor_width * @digits_max + 32, 64)
  3246.     self.contents = Bitmap.new(width - 32, height - 32)
  3247.     self.z += 9999
  3248.     self.opacity = $game_system.opacity
  3249.     self.back_opacity = $game_system.back_opacity
  3250.     @index = 0
  3251.     refresh
  3252.     update_cursor_rect
  3253.   end
  3254.  
  3255.   #--------------------------------------------------------------------------
  3256.   # * Refresh
  3257.   #--------------------------------------------------------------------------
  3258.   def refresh
  3259.     self.contents.clear
  3260.     if $game_system.font_color.nil?
  3261.       self.contents.font.color = normal_color
  3262.     else
  3263.       self.contents.font.color = $game_system.font_color
  3264.     end
  3265.     if $game_system.windowskin != ""  
  3266.       self.windowskin = RPG::Cache.windowskin($game_system.windowskin)
  3267.     else
  3268.       self.windowskin = RPG::Cache.windowskin($data_system.windowskin_name)
  3269.     end
  3270.     s = sprintf("%0*d", @digits_max, @number)
  3271.     for i in 0...@digits_max
  3272.       # Draw text
  3273.       if $game_system.shadowed_text
  3274.         old_color = self.contents.font.color.clone
  3275.         self.contents.font.color = $game_system.shadow_color
  3276.         self.contents.draw_text(i * @cursor_width + 6, 2, 32, 32, s[i,1])
  3277.         self.contents.font.color = old_color
  3278.       end
  3279.       self.contents.draw_text(i * @cursor_width + 4, 0, 32, 32, s[i,1])
  3280.     end
  3281.   end
  3282. end
  3283.  
  3284. #=end # comment out to use w/o the UMS
Expand to see the code.
Hey thanks again silver! :heart:

That just about fills my request, lol, it's all working together great! :thumb:
Also yeah, that script is pretty HUGE, I hope it wasn't too much trouble for you :o:

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=76591