Ccoa's UMS

Hello guys,

I'm using Ccoa's UMS, and I have a few questions about it:

- How can I change the x, y, coordinates of the face graphic that is displayed?
- How can I change the x, y, coordinates of the name box that is displayed?
- How can I change the x, y, coordinates of the text that is being written in the textbox?

I'm not exactly a scripter, but I don't think it should be that hard to change these things, I just need to know where I can do so within the script.

PS: If you happen to know a message system script that is better, I'm open for suggestions. I'm having no problems with this current script really, but I haven't been keeping track of the new scripts lately. If you do make a suggestion, please include how I can modify the above three things as well.

I hope someone can help, thank you in advance.
Oh by the way I have here the UMS so that if you don't know where to find it you won't have to waste time searching for it.

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

Be Well
I'll look into it, thank you

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