Advertisement
LiTTleDRAgo

[RGSS] Hodgeelmf's Custom Message Script (edited)

Aug 13th, 2013
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 91.34 KB | None | 0 0
  1. #==============================================================================
  2. # ** Custom Message Script by Hodgeelmf **
  3. #
  4. #     Version 1.4
  5. #
  6. #       Version History
  7. #         1.0.0 - Basic functionality
  8. #         1.1.0 - Fixed issue with bubble size and bolded text
  9. #               Modified gold window
  10. #               Added /q function
  11. #         1.2.0 - Added Icon display
  12. #               Added Face Graphics
  13. #               Fixed Gold command iteration error (This is what formerly broke
  14. #                                                   the script)
  15. #               Added use of Windowskin Graphic
  16. #               Fixed sub window termination to be more natural
  17. #         1.3.0 - Added thought indicater option
  18. #               Added emotion colors
  19. #         1.4.0 - Fixed glitch when switching from Windowskin to Bubble mode
  20. #               Added function to disable bubble bouncing
  21. #         1.4.1 - Fixed text drawing issue when choices displayed without
  22. #               preceding message text
  23. #                 Created \nc command
  24. #
  25. #       **************UPDATE NOTE*******************
  26. #         This script displays all choices immediately after the text
  27. #         which precedes them.  I have added a command to prevent this
  28. #         should you elect to do so:
  29. #
  30. #               \nc
  31. #
  32. #           I see no reason to turn this into a toggle currently unless
  33. #           there were significant push for it
  34. #
  35. #
  36. #     Necessary updates
  37. #
  38. #       -Add other various functions like display hp, quest, etc.
  39. #
  40. #==============================================================================
  41. =begin
  42.  
  43. Welcome to the Custom Message script!
  44.  
  45. Installation instructions:
  46.  
  47. 1.  Install this script above Main, preferrably directly above
  48. 2.  Download attached graphics (message_bubble and pointer2)
  49.     and place in Graphics/Pictures
  50. 3.  That's it!
  51.  
  52. Message commands:
  53.  
  54. \e[x]   Display message over a map event
  55.  
  56.     By default, bubble messages display over the player's sprite.  Values
  57.     outside of the map events range will display over the player as well.
  58.  
  59. \c[x]   Change message text color (0-8)
  60.  
  61. \n[x]   Insert actor name
  62.  
  63. \v[x]   Insert variable value
  64.  
  65. \b      Toggle bold text
  66.  
  67. \w[x]   Wait control (0-999)
  68.  
  69.     Wait values are determined by frame.  40 FPS is the script rate.
  70.  
  71. \p      Pause control
  72.  
  73.     Forces the player to press enter before continuing.
  74.  
  75. \q      Forced ending
  76.  
  77.     Forces the message winddow to close once the character is encountered.
  78.     Typically best to use directly after a wait timer.
  79.    
  80. \f      Force position
  81.  
  82.     Forces a specific position for the message bubble.
  83.    
  84.     0 - Upper right of the sprite
  85.     1 - Upper left of the sprite
  86.     2 - Lower right of the sprite
  87.     3 - Lower left of the sprite
  88.    
  89. \g      Displays gold window
  90.  
  91.     Fades in the gold window to the bottom right corner of the screen.  To keep
  92.     it displayed after current message, add \g into the next master message.
  93.  
  94. \i[x]   Display icon
  95.  
  96.     Displays an icon from the "Icons" folder.  A constant array, Icons, is
  97.     compiled at runtime to store imported icon names in addition to RTP.
  98.    
  99. \z[x]   Display face graphic (found in Graphics/Faces - you may have to create this
  100.                                                         folder)
  101.  
  102.     Displays a face graphic on the left of the message.  Currently this script
  103.     only supports images with one face (as opposed to a whole faceset).
  104.  
  105. \t     Thought Bubble
  106.  
  107.         Uses thought indicater (ie two dots instead of mouth opening style)
  108.        
  109. \m[x]   Mood Coloring
  110.  
  111.         Changes bubble color to indicate speakers/thinkers mood (0-4)
  112.        
  113. \nc     Do not Display Choices
  114.  
  115.         Keeps choices from being appended to the text preceding them
  116.    
  117. \h[x]  Display Hp
  118.  
  119.     Not functioning at this point
  120.  
  121. \s[x]   Sub window controls (explained below)
  122.  
  123.  
  124.   Master - the message which controls sub windows
  125.   Sub - any message that displays as a part of a master
  126.    
  127.     1. The master message always has a higher z value than any sub messages
  128.     2. Sub message must immediately follow the master message and be in
  129.         consecutive order (ex. sub 0 must be the next event command after
  130.         the master message, sub 1 must be the next event command after
  131.         sub 0, etc.)
  132.     3. Sub messagge numbers do not reset after a master message.  For
  133.         example, if the first master messsage contains two sub messages,
  134.         the second master message with sub messages must begin with sub
  135.         message number 3, and so on.
  136.     4. Use \s[x] where x is the number of the sub message to indicate that
  137.         a particular message is a sub message
  138.     5. Call sub messages in a master message with \s[x] where x is the
  139.         number of the sub message.
  140.     6. There is no limit to the number of sub messages, but since text is
  141.         drawn one letter at a time, too many messages may cause lag.
  142.        
  143.   ***NOTE***
  144.       If any of these commands seem bulky, it is because there is a glitch in
  145.       the run script command in the event editor which does not allow for
  146.       single lines changing global variables to function properly.
  147.        
  148. Script commands (from the Event Editor):
  149.  
  150.   1. Choose message style (bubble, windowskin or invisible)
  151.      
  152.       ***** If you do not have the correct images in Graphics/Pictures
  153.       ***** the script will automatically change to WINDOWSKIN mode and
  154.       ***** change the default text color to white
  155.  
  156.       $game_system.message_text_mode = x
  157.      
  158.       TEXT_MODE_BUBBLE
  159.       TEXT_MODE_INVISIBLE
  160.       TEXT_MODE_WINDOWSKIN
  161.      
  162.   2. Enable or disable bubble bouncing (only applies when in TEXT_MODE_BUBBLE)
  163.  
  164.       $game_system.message_bubble_bounce = x
  165.      
  166.       BUBBLE_BOUNCE_ON
  167.       BUBBLE_BOUNCE_OFF
  168.      
  169.   2. Change position of invisible text
  170.  
  171.       $game_system.invisible_position = x
  172.      
  173.       INVISIBLE_POSITION_TOP
  174.       INVISIBLE_POSITION_MIDDLE
  175.       INVISIBLE_POSITION_BOTTOM
  176.       INVISIBLE_POSITION_BOOK(arbitrary value from one of my projects)
  177.      
  178.   3. Change outline text options
  179.  
  180.       $game_system.message_text_outline = x
  181.      
  182.       TEXT_NORMAL
  183.       TEXT_OUTLINE
  184.      
  185.   4. Change text speed
  186.  
  187.       $game_system.message_text_speed = x
  188.      
  189.       TEXT_SPEED_SLOW
  190.       TEXT_SPEED_MEDIUM
  191.       TEXT_SPEED_FAST
  192.  
  193.   5. Change text skip rate (one letter per frame up to all at once)
  194.      
  195.       $game_system.message_text_skip = x
  196.  
  197.       TEXT_SKIP_NORMAL  (1)
  198.       TEXT_SKIP_DOUBLE  (2)
  199.       TEXT_SKIP_TRIPLE  (3)
  200.       TEXT_SKIP_FULL
  201.  
  202.      
  203.   5. Change text size
  204.  
  205.       $game_system.message_text_size = x
  206.      
  207.       TEXT_SIZE_SMALL
  208.       TEXT_SIZE_MEDIUM
  209.       TEXT_SIZE_LARGE
  210.       TEXT_SIZE_JUMBO
  211.      
  212.   6. Change text font
  213.  
  214.       $game_system.message_text_font = x
  215.      
  216.       TEXT_FONT_DEFAULT
  217.       TEXT_FONT_CORSIVA
  218.      
  219.   7. Color Constants
  220.  
  221.       TEXT_COLOR_BLACK
  222.       TEXT_COLOR_WHITE
  223.      
  224.   8. Face Graphic Functions
  225.  
  226.       $game_system.face_graphic_type = x
  227.      
  228.   9. Face Graphic Constants
  229.  
  230.       FACE_GRAPHIC_FULL - typically a bust which looks better offset to the left
  231.                           and extending abovve the bubble
  232.       FACE_GRAPHIC_BOX -  traditional boxed in face graphics which need to be
  233.                           encased by the bubble to look correct
  234.      
  235.   10. Global Methods (for ease of access)
  236.  
  237.       message(string) - place in script box in event processing
  238.      
  239.       ***** Only place this command once per Event Script Box *****
  240.      
  241.       You may wish to have dialogue or entries that are longer than three
  242.       lines.  This global method allows you to supply a string to
  243.       $game_temp.message_text manually.  The best way to do so is to store
  244.       a message in a variable and pass it to the method.  In this example
  245.       script there is a Game_Messages class which has public methods that
  246.       assign a message to a variable.  For full games, it would be better
  247.       to create a text file to load from.  The best formatter to use is
  248.       %q (ex @message = %q(lots of text...can be multiple lines).  The
  249.       %q formatter mimicks the event dialogue box text editing format
  250.       so you can use single "\" characters instead of using "\\" or not
  251.       being able to use special characters at all.
  252.      
  253.       default_color(x) - set message default color
  254.      
  255.       Input either a number 0 through 8 or a Color object.
  256.      
  257.       face(string) - set default face graphic
  258.      
  259.       Use this method to supply a default face graphic for messages.  This graphic
  260.       has secondary priority to one explicitly declared in a message, so is useful
  261.       for largely unbroken monologues.
  262.      
  263.       clear_face - clears the default face graphic
  264.      
  265.       small_text
  266.       medium_text   - Shortcut methods to change $game_system.message_text_size
  267.       large_text
  268.       jumbo_text
  269.      
  270.       slow_text
  271.       fast_text     - Shortcut methods to change $game_system.messge_text_speed
  272.      
  273.            
  274.      
  275.                                       Enjoy! And remember to credit!
  276.  
  277. =end
  278.  
  279. #========================================================================
  280. #   Game_Messages
  281. #       You can easily create messages to display of any length using this
  282. #       Class or a similar one of your creation.
  283. #========================================================================
  284.  
  285. class Game_Messages
  286.  
  287.   # This message is obviously far too long for a bubble message, but it looks
  288.   # quite good with a darkened screen tone
  289.  
  290.   # When loaded into a global variable, these class methods can be called to
  291.   # the event editor with two lines of code.  For your own projects, you will
  292.   # probably want a more sophisticated heirarchy.
  293.   def message_1
  294.     @message = "  \c[0]\bMessage commands:\b
  295.  
  296. \c[6]\b\\e[x]\c[0]     Display message over a map event\b
  297.                   By default, bubble messages display over the player's sprite.  Values
  298.                   outside of the map events range will display over the player as well.
  299. \c[6]\b\\c[x]\c[0]     Change message text color (0-8)\b
  300. \c[6]\b\\n[x]\c[0]     Insert actor name\b
  301. \c[6]\b\\v[x]\c[0]     Insert variable value\b
  302. \c[6]\b\\b\c[0]        Toggle bold text\b
  303. \c[6]\b\\w[x]\c[0]     Wait control (0-999)\b
  304.                   Wait values are determined by frame.  40 FPS is the script rate.
  305. \c[6]\b\\p\c[0]        Pause control\b
  306.                   Forces the player to press enter before continuing.
  307. \c[6]\b\\q\c[0]        Forced ending\b
  308.                   Forces the message winddow to close once the character is encountered.
  309.                   Typically best to use directly after a wait timer.
  310. \c[6]\b\\f[x]\c[0]      Force position\b
  311.                   Forces a specific position for the message bubble.
  312.  
  313.                   \b0\b - Upper right of the sprite
  314.                   \b1\b - Upper left of the sprite
  315.                   \b2\b - Lower right of the sprite
  316.                   \b3\b - Lower left of the sprite
  317. \c[6]\b\\g\c[0]        Displays gold window\b
  318.                    Fades in the gold window to the bottom right corner of the screen.  To keep
  319.                    it displayed after current message, add \\\\g into the next master message.
  320. \c[6]\b\\i[x]\c[0]      Displays an icon from Graphics/Icons\b
  321. \c[6]\b\\z[x]\c[0]      Displays a face graphic from Graphics/Faces\b
  322.                    References an array compiled at runtime from Graphics/Faces.  You will have
  323.                    to create this folder and manually install files.                    
  324. \c[6]\b\\s[x]\c[0]     Sub window controls\b (see documentation for full instructions)"
  325.   end
  326.  
  327.   def message_2
  328.     @message = %q(          \c[6]\b$game_system Properties\b\c[0]
  329.    
  330.               Change these properties in the Event Editor by using the Script command.  Begin with
  331.               $game_system, then add a "." followed by the property you wish to alter.  In the
  332.               Script command you will need to use two lines.  For example:
  333.              
  334.                           $game_system.message_text_speed =\
  335.                           TEXT_SPEED_FAST
  336.            
  337.           The properties are listed below with available values to the right.  For full
  338.           documentation, refer to the script instructions.
  339.          
  340.               \c[6]\bmessage_text_mode\b\c[0]             TEXT_MODE_INVISIBLE,TEXT_MODE_BUBBLE,TEXT_MODE_WINDOWSKIN
  341.               \c[6]\binvisible_position\b\c[0]                    INVISIBLE_POSITION_TOP,INVISIBLE_POSITION_MIDDLE,
  342.                                                                    INVISIBLE_POSITION_BOTTOM
  343.               \c[6]\bmessage_text_outline\b\c[0]          TEXT_NORMAL,TEXT_OUTLINE
  344.               \c[6]\bmessage_text_speed\b\c[0]           TEXT_SPEED_SLOW,TEXT_SPEED_MEDIUM,TEXT_SPEED_FAST
  345.               \c[6]\bmessage_text_size\b\c[0]               TEXT_SIZE_SMALL,TEXT_SIZE_MEDIUM,TEXT_SIZE_LARGE,
  346.                                                                   TEXT_SIZE_JUMBO
  347.               \c[6]\bmessage_text_font\b\c[0]               TEXT_FONT_DEFAULT, whatever constant you would
  348.                                                                    like to create
  349.               \c[6]\bmessage_text_skip\b\c[0]               TEXT_SKIP_NORMAL,TEXT_SKIP_DOUBLE,TEXT_SKIP_TRIPLE,
  350.                                                                   TEXT_SKIP_QUAD,
  351.                                                                   TEXT_SKIP_QUIN,TEXT_SKIP_FULL
  352.               \c[6]\bmessage_skip_disabled\b\c[0]       true,false
  353.               \c[6]\bface_graphic_type\b\c[0]                  FACE_GRAPHIC_BOX,FACE_GRAPHIC_FULL
  354.               \c[6]\bface_graphic_name\b\c[0]                file name of graphic - without folders
  355.               \c[6]\bdefault_color\b\c[0]                            any Color object
  356.               \c[6]\bmessage_text_outline_color\b\c[0]  any Color object)
  357.  
  358.   end
  359.    
  360. end
  361.  
  362. #========================================================================
  363. #   Global Variables - simplest way to create communication between
  364. #                       Interpreter and Window_Message
  365. #========================================================================
  366.  
  367. $separate_choices = false
  368.  
  369. #========================================================================
  370. #   Constant Declaration
  371. #========================================================================
  372.  
  373. # Stores the class methods for quick custom message access
  374. $game_messages = Game_Messages.new
  375.  
  376. BUBBLE_BOUNCE_ON = 1
  377. BUBBLE_BOUNCE_OFF = 0
  378.  
  379. BUBBLE_UPPER_LEFT = Rect.new(0,0,13,10)
  380. BUBBLE_LOWER_LEFT = Rect.new(0,10,13,9)
  381. BUBBLE_UPPER_RIGHT = Rect.new(13,0,12,10)
  382. BUBBLE_LOWER_RIGHT = Rect.new(13,10,12,9)
  383.  
  384. SKIN_UPPER_LEFT = Rect.new(128,0,10,10)
  385. SKIN_LOWER_LEFT = Rect.new(128,54,10,10)
  386. SKIN_UPPER_RIGHT = Rect.new(182,0,10,10)
  387. SKIN_LOWER_RIGHT = Rect.new(182,54,10,10)
  388.  
  389. TEXT_MODE_BUBBLE = 0
  390. TEXT_MODE_INVISIBLE = 1
  391. TEXT_MODE_WINDOWSKIN = 2
  392.  
  393. INVISIBLE_POSITION_TOP = [320,0]
  394. INVISIBLE_POSITION_MIDDLE = [320,240]
  395. INVISIBLE_POSITION_BOTTOM = [320,480]
  396. INVISIBLE_POSITION_BOOK = [460,35]
  397.  
  398. TEXT_NORMAL = 0
  399. TEXT_OUTLINE = 1
  400.  
  401. TEXT_SPEED_SLOW = 2
  402. TEXT_SPEED_MEDIUM = 1
  403. TEXT_SPEED_FAST = 0
  404.  
  405. TEXT_SKIP_NORMAL = 1
  406. TEXT_SKIP_DOUBLE = 2
  407. TEXT_SKIP_TRIPLE = 3
  408. TEXT_SKIP_QUAD = 4
  409. TEXT_SKIP_QUIN = 5
  410. TEXT_SKIP_FULL = 6
  411.  
  412. TEXT_SIZE_SMALL = 14
  413. TEXT_SIZE_MEDIUM = 16
  414. TEXT_SIZE_LARGE = 18
  415. TEXT_SIZE_JUMBO = 28
  416.  
  417. # Remember to set a common default or fallback font since some users won't have
  418. # them all
  419. TEXT_FONT_DEFAULT = "Arial"
  420. TEXT_FONT_CORSIVA = ["Monotype Corsiva", "Arial"]
  421. TEXT_FONT_BOLI = ["MV Boli", "Arial"]
  422. TEXT_FONT_COMICSANS = ["Comic Sans MS", "Arial"]
  423.  
  424. TEXT_COLOR_BLACK = Color.new(0,0,0)
  425. TEXT_COLOR_WHITE = Color.new(250,250,250)
  426.  
  427. FACE_GRAPHIC_FULL = 0
  428. FACE_GRAPHIC_BOX = 1
  429.  
  430. =begin
  431. # Compile Icon array
  432. # RTP icons are best stored manually
  433. Icons = ['001-Weapon01','002-Weapon02','003-Weapon03','004-Weapon04'\
  434. ,'005-Weapon05','006-Weapon06','007-Weapon07','008-Weapon08'\
  435. ,'009-Shield01','010-Head01','011-Head02','012-Head03','013-Body01'\
  436. ,'014-Body02','015-Body03','016-Accessory01','017-Accessory02'\
  437. ,'018-Accessory03','019-Accessory04','020-Accessory05'\
  438. ,'021-Potion01','022-Potion02','023-Potion03','024-Potion04'\
  439. ,'025-Herb01','026-Herb02','027-Herb03','028-Herb04'\
  440. ,'029-Key01','030-Key02','031-Key03','032-Item01'\
  441. ,'033-Item02','034-Item03','035-Item04','036-Item05'\
  442. ,'037-Item06','038-Item07','039-Item08','040-Item09'\
  443. ,'041-Item10','042-Item11','043-Item12','044-Skill01'\
  444. ,'045-Skill02','046-Skill03','047-Skill04','048-Skill05'\
  445. ,'049-Skill06','050-Skill07']
  446.  
  447. # All icons in the icon folder are dynamically added at runtime
  448. ICON_FOLDER_PATH = Dir::getwd + "/Graphics/Icons/"
  449. dir = Dir.new(ICON_FOLDER_PATH)
  450. dir.each { |file|
  451.   if file != "." && file != ".."
  452.     Icons.push file
  453.   end
  454. }
  455. =end
  456.  
  457. # Compile Face array
  458. if File.directory? Dir::getwd + "/Graphics/Faces/"
  459.   Faces = []
  460.   FACE_FOLDER_PATH = Dir::getwd + "/Graphics/Faces/"
  461.   dir = Dir.new(FACE_FOLDER_PATH)
  462.   dir.each { |file|
  463.     if file != "." && file != ".."
  464.       Faces.push file
  465.     end
  466.   }
  467. end
  468.  
  469. #========================================================================
  470. #   Global Methods
  471. #       Use these methods to quickly modify basic settings or set text
  472. #       to $game_temp.message_text manually
  473. #========================================================================
  474.  
  475. def message(text)
  476.   $game_system.map_interpreter.message_waiting = true
  477.   $game_temp.message_proc = Proc.new { @message_waiting = false }
  478.   $game_temp.message_text = text
  479. end
  480.  
  481. def default_color(color)
  482.   # If an integer passed to the method
  483.   if color.class == Fixnum
  484.     case color
  485.     when 0
  486.       $game_system.default_color = TEXT_COLOR_BLACK
  487.     when 1
  488.       $game_system.default_color = Color.new(128, 128, 255, 255)
  489.     when 2
  490.       $game_system.default_color = Color.new(255, 128, 128, 255)
  491.     when 3
  492.       $game_system.default_color = Color.new(128, 255, 128, 255)
  493.     when 4
  494.       $game_system.default_color = Color.new(128, 255, 255, 255)
  495.     when 5
  496.       $game_system.default_color = Color.new(255, 128, 255, 255)
  497.     when 6
  498.       $game_system.default_color = Color.new(255, 255, 128, 255)
  499.     when 7
  500.       $game_system.default_color = Color.new(192, 192, 192, 255)
  501.     when 8
  502.       $game_system.default_color = TEXT_COLOR_WHITE
  503.     else
  504.       $game_system.default_color = TEXT_COLOR_BLACK
  505.     end
  506.   # If a Color class value is passed to the method
  507.   elsif color.class == Color
  508.     $game_sytem.default_color = color
  509.   end
  510.  
  511.   return true
  512. end
  513.  
  514. def mood_color(color)
  515.   case color
  516.   when 0
  517.     return Color.new(70,130,180,190)
  518.   when 1
  519.     return Color.new(178,34,34,190)
  520.   when 2
  521.     return Color.new(238,174,238,190)
  522.   when 3
  523.     return Color.new(139,136,120,180)
  524.   when 4
  525.     return Color.new(255,215,0,190)
  526.   end
  527. end
  528.  
  529. def face(name)
  530.   $game_system.face_graphic_name = name
  531. end
  532.  
  533. def clear_face
  534.   $game_system.face_graphic_name = nil
  535. end
  536.  
  537. def small_text
  538.   $game_system.message_text_size == TEXT_SIZE_SMALL
  539. end
  540.  
  541. def medium_text
  542.   $game_system.message_text_size == TEXT_SIZE_MEDIUM
  543. end
  544.  
  545. def large_text
  546.   $game_system.message_text_size == TEXT_SIZE_LARGE
  547. end
  548.  
  549. def jumbo_text
  550.   $game_system.message_text_size == TEXT_SIZE_JUMBO
  551. end
  552.  
  553. def slow_text
  554.   $game_system.message_text_speed == TEXT_SPEED_SLOW
  555. end
  556.  
  557. def fast_text
  558.   $game_system.message_text_speed == TEXT_SPEED_FAST
  559. end
  560.  
  561. #========================================================================
  562. #   Game Temp
  563. #
  564. #       @current_event - tracks the current game event for ease of access
  565. #========================================================================
  566.  
  567. class Game_Temp
  568.  
  569.   attr_accessor :current_event
  570.   attr_accessor :consecutive_gold_window
  571.  
  572.   alias old_initialize initialize
  573.  
  574.   def initialize
  575.     old_initialize
  576.     @current_event = nil
  577.     @consecutive_gold_window = false
  578.   end
  579.  
  580. end
  581.  
  582. #========================================================================
  583. #   Game System
  584. #
  585. #       Stores message text options
  586. #       Use $game_system to view and change values
  587. #========================================================================
  588.  
  589. class Game_System
  590.   attr_accessor :message_text_mode
  591.   attr_accessor :message_bubble_bounce
  592.   attr_accessor :invisible_position
  593.   attr_accessor :message_text_outline
  594.   attr_accessor :message_text_speed
  595.   attr_accessor :message_text_size
  596.   attr_accessor :message_text_font
  597.   attr_accessor :message_skip_disabled
  598.   attr_accessor :face_graphic_type
  599.   attr_accessor :face_graphic_name
  600.   attr_accessor :message_text_skip
  601.   attr_accessor :default_color
  602.   attr_accessor :message_text_outline_color
  603.  
  604.   alias old_initialize initialize
  605.  
  606.   def initialize
  607.     old_initialize
  608.     @message_text_mode = TEXT_MODE_BUBBLE
  609.     @message_bubble_bounce = BUBBLE_BOUNCE_ON
  610.     @invisible_position = INVISIBLE_POSITION_TOP
  611.     @message_text_outline = TEXT_NORMAL
  612.     @message_text_speed = TEXT_SPEED_FAST
  613.     @message_text_size = TEXT_SIZE_SMALL
  614.     @message_text_font = TEXT_FONT_DEFAULT
  615.     @message_text_skip = TEXT_SKIP_NORMAL
  616.     @message_skip_disabled = false
  617.     @face_graphic_type = FACE_GRAPHIC_BOX
  618.     @face_graphic_name = nil
  619.     @default_color = TEXT_COLOR_BLACK
  620.     @message_text_outline_color = TEXT_COLOR_WHITE
  621.    
  622.   end
  623.  
  624. end
  625.  
  626. #========================================================================
  627. #   Game Player
  628. #
  629. #        The only change is in the condition --if Input.trigger?(Input::C)--
  630. #        The change allows for $game_temp.message text to be manually
  631. #          altered and still function properly
  632. #========================================================================
  633.  
  634. class Game_Player
  635.   #--------------------------------------------------------------------------
  636.   # * Frame Update
  637.   #--------------------------------------------------------------------------
  638.   def update
  639.     # Remember whether or not moving in local variables
  640.     last_moving = moving?
  641.     # If moving, event running, move route forcing, and message window
  642.     # display are all not occurring
  643.     unless moving? or $game_system.map_interpreter.running? or
  644.            @move_route_forcing or $game_temp.message_window_showing
  645.       # Move player in the direction the directional button is being pressed
  646.       case Input.dir4
  647.       when 2
  648.         move_down
  649.       when 4
  650.         move_left
  651.       when 6
  652.         move_right
  653.       when 8
  654.         move_up
  655.       end
  656.     end
  657.     # Remember coordinates in local variables
  658.     last_real_x = @real_x
  659.     last_real_y = @real_y
  660.     super
  661.     # If character moves down and is positioned lower than the center
  662.     # of the screen
  663.     if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  664.       # Scroll map down
  665.       $game_map.scroll_down(@real_y - last_real_y)
  666.     end
  667.     # If character moves left and is positioned more let on-screen than
  668.     # center
  669.     if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  670.       # Scroll map left
  671.       $game_map.scroll_left(last_real_x - @real_x)
  672.     end
  673.     # If character moves right and is positioned more right on-screen than
  674.     # center
  675.     if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  676.       # Scroll map right
  677.       $game_map.scroll_right(@real_x - last_real_x)
  678.     end
  679.     # If character moves up and is positioned higher than the center
  680.     # of the screen
  681.     if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  682.       # Scroll map up
  683.       $game_map.scroll_up(last_real_y - @real_y)
  684.     end
  685.     # If not moving
  686.     unless moving?
  687.       # If player was moving last time
  688.       if last_moving
  689.         # Event determinant is via touch of same position event
  690.         result = check_event_trigger_here([1,2])
  691.         # If event which started does not exist
  692.         if result == false
  693.           # Disregard if debug mode is ON and ctrl key was pressed
  694.           unless $DEBUG and Input.press?(Input::CTRL)
  695.             # Encounter countdown
  696.             if @encounter_count > 0
  697.               @encounter_count -= 1
  698.             end
  699.           end
  700.         end
  701.       end
  702.       #-----------------------------------------------------------------
  703.       #  Allows messages to display without interruption when directly
  704.       #  assigned to $game_temp.message_text
  705.       #-----------------------------------------------------------------
  706.       # If C button was pressed
  707.       if Input.trigger?(Input::C) && $game_temp.message_text == nil
  708.         # Same position and front event determinant
  709.         check_event_trigger_here([0])
  710.         check_event_trigger_there([0,1,2])
  711.       end
  712.     end
  713.   end
  714. end
  715.  
  716. #========================================================================
  717. #   Interpreter
  718. #
  719. #       Edit forces the interpreter to wait to update until all messages
  720. #         currently on screen have finished writing
  721. #========================================================================
  722.  
  723.  
  724. class Interpreter
  725.  
  726.   attr_accessor :list
  727.   attr_accessor :index
  728.   attr_accessor :message_waiting
  729.  
  730.   alias old_update update
  731.  
  732.   def update
  733.    
  734.     #if $scene.message_window != nil && $scene.message_window.finished != nil
  735.     if $game_temp.message_text != nil
  736.       return
  737.     else
  738.       old_update
  739.       $game_temp.current_event = @event_id
  740.     end
  741.   end
  742.  
  743.   def command_101
  744.     # If other text has been set to message_text
  745.     if $game_temp.message_text != nil
  746.       # End
  747.       return false
  748.     end
  749.     # Check for consecutive gold window calls
  750.     temp_index = @index+1
  751.     loop do
  752.       case @list[temp_index].code
  753.       when 401
  754.         temp_index += 1
  755.       when 101
  756.         break
  757.       else
  758.         break
  759.       end
  760.     end
  761.    
  762.     # Search for consecutive message window with /g formatter
  763.     text = nil
  764.    
  765.     # Iterate through max possible message size
  766.     for i in 0...3
  767.       # Check for existence of list element before checking code
  768.       if @list[temp_index+i] != nil
  769.         # Search for /g
  770.         if @list[temp_index+i].code == 101 or @list[temp_index+i].code == 401
  771.           text = @list[temp_index+i].parameters[0].slice(/\\[Gg]/)
  772.           if text != nil
  773.             # Allows for gold window to continue after first message
  774.             $game_temp.consecutive_gold_window = true
  775.             break
  776.           end
  777.         end
  778.       end
  779.     end
  780.     # Turns consecutive flag off if need be
  781.     if $game_temp.consecutive_gold_window == true && text == nil
  782.       $game_temp.consecutive_gold_window = false
  783.     end
  784.     # Set message end waiting flag and callback
  785.     @message_waiting = true
  786.     $game_temp.message_proc = Proc.new { @message_waiting = false }
  787.     # Set message text on first line
  788.     $game_temp.message_text = @list[@index].parameters[0] + "\n"
  789.     line_count = 1
  790.     # Loop
  791.     loop do
  792.       # If next event command text is on the second line or after
  793.       if @list[@index+1].code == 401
  794.         # Add the second line or after to message_text
  795.         $game_temp.message_text += @list[@index+1].parameters[0] + "\n"
  796.         line_count += 1
  797.       # If event command is not on the second line or after
  798.       else        
  799.         # If next event command is show choices
  800.         if @list[@index+1].code == 102
  801.           # Make sure choice appellation is allowed
  802.           for choice in @list[@index+1].parameters[0]
  803.             if choice.slice(/\\[Nn][Cc]/)
  804.               $separate_choices = true
  805.               break
  806.             end
  807.           end
  808.           if $separate_choices == true
  809.             return
  810.           end
  811.           # Advance index
  812.           @index += 1
  813.           # Choices setup
  814.           $game_temp.choice_start = line_count
  815.           #Insert 5 spaces for indenting choices
  816.           for i in 0...@list[@index].parameters[0].size
  817.             if @list[@index].parameters[0][i].slice(0,5) != '     '
  818.               @list[@index].parameters[0][i].insert(0,'     ')
  819.             end
  820.           end
  821.           setup_choices(@list[@index].parameters)
  822.         # If next event command is input number
  823.         elsif @list[@index+1].code == 103
  824.           # If number input window fits on screen
  825.           if line_count < 4
  826.             # Advance index
  827.             @index += 1
  828.             # Number input setup
  829.             $game_temp.num_input_start = line_count
  830.             $game_temp.num_input_variable_id = @list[@index].parameters[0]
  831.             $game_temp.num_input_digits_max = @list[@index].parameters[1]
  832.           end
  833.         end
  834.         # Continue
  835.         return true
  836.       end
  837.       # Advance index
  838.       @index += 1
  839.     end
  840.   end
  841. end
  842.  
  843. #========================================================================
  844. #   Spriteset Map
  845. #
  846. #       Edit allows access to the character_sprites variable
  847. #       Use $game_map.character_sprites to access
  848. #========================================================================
  849.  
  850. class Spriteset_Map
  851.  
  852.   attr_accessor :character_sprites  
  853.  
  854. end
  855.  
  856. class Scene_Map
  857.  
  858.   attr_accessor :spriteset
  859.   attr_accessor :message_window
  860.  
  861. end
  862.  
  863. #========================================================================
  864. #   Window Base
  865. #
  866. #       Edit allows for color 8 (black)
  867. #========================================================================
  868.  
  869. class Window_Base < Window
  870.  
  871.   #--------------------------------------------------------------------------
  872.   # * Get Text Color
  873.   #     n : text color number (0-7)
  874.   #--------------------------------------------------------------------------
  875.   def text_color(n)
  876.     case n
  877.     when 0
  878.       return Color.new(250, 250, 250, 255)
  879.     when 1
  880.       return Color.new(45, 45, 255, 255)
  881.     when 2
  882.       return Color.new(255, 45, 45, 255)
  883.     when 3
  884.       return Color.new(45, 255, 45, 255)
  885.     when 4
  886.       return Color.new(45, 215, 215, 255)
  887.     when 5
  888.       return Color.new(255, 45, 255, 255)
  889.     when 6
  890.       return Color.new(230, 230, 15, 255)
  891.     when 7
  892.       return Color.new(125, 125, 125, 255)
  893.     when 8
  894.       return Color.new(0, 0, 0)
  895.     else
  896.       normal_color
  897.     end
  898.   end
  899.  
  900. end
  901.  
  902. #==============================================================================
  903. # ** Window_Gold
  904. #------------------------------------------------------------------------------
  905. #  The gold window has been modified to use an icon and some outlined text
  906. #==============================================================================
  907.  
  908. class Window_Gold_New < Window_Base
  909.   def initialize
  910.     @current_gold = $game_party.gold
  911.    
  912.     @icon = Sprite.new
  913.     @icon.opacity = 0
  914.     @icon.bitmap = Bitmap.new('Graphics/Icons/032-Item01')
  915.     @icon.ox = @icon.bitmap.width/2
  916.     @icon.oy = @icon.bitmap.height/2
  917.     @icon.x,@icon.y = 624,460
  918.    
  919.     draw_gold
  920.   end
  921.  
  922.   def update
  923.     refresh
  924.     @icon.opacity += 12 if @icon.opacity < 192
  925.     @gold.opacity += 12 if @gold.opacity < 192
  926.   end
  927.  
  928.   def refresh
  929.     if @current_gold != $game_party.gold
  930.       @current_gold = $game_party.gold
  931.       @gold.bitmap.clear
  932.       draw_gold
  933.     end
  934.   end
  935.  
  936.   def draw_gold
  937.     @gold = Sprite.new
  938.     @gold.opacity = 0
  939.     @gold.bitmap = Bitmap.new(100,32)
  940.     @gold.ox,@gold.oy = @gold.bitmap.width/2,@gold.bitmap.height/2
  941.     @gold.x = 560
  942.     @gold.y = 465
  943.     @gold.z = 50
  944.     @gold.bitmap.font.size = 18
  945.     @gold.bitmap.font.bold = true
  946.     @gold.bitmap.font.color = text_color(8)
  947.     @gold.bitmap.draw_text(22,0,75,30,$game_party.gold.to_s,2)
  948.     @gold.bitmap.draw_text(22,2,75,30,$game_party.gold.to_s,2)
  949.     @gold.bitmap.draw_text(21,1,75,30,$game_party.gold.to_s,2)
  950.     @gold.bitmap.draw_text(23,1,75,30,$game_party.gold.to_s,2)
  951.     @gold.bitmap.font.color = text_color(6)
  952.     @gold.bitmap.draw_text(22,1,75,30,@current_gold.to_s,2)
  953.   end
  954.  
  955.   def fade_out
  956.     @icon.opacity -= 48
  957.     @gold.opacity -= 48
  958.   end
  959.  
  960.   def dispose
  961.     @icon.bitmap.dispose
  962.     @icon.dispose
  963.     @gold.bitmap.dispose
  964.     @gold.dispose
  965.   end
  966.  
  967. end
  968.  
  969. #==============================================================================
  970. # ** Window_InputNumber
  971. #------------------------------------------------------------------------------
  972. #  This window is for inputting numbers, and is used within the
  973. #  message window.
  974. #==============================================================================
  975.  
  976. class Window_InputNumber < Window_Base
  977.  
  978.   attr_accessor :x
  979.   attr_accessor :y
  980.  
  981.   #--------------------------------------------------------------------------
  982.   # * Object Initialization
  983.   #     digits_max : digit count
  984.   #--------------------------------------------------------------------------
  985.   def initialize(digits_max,x=0,y=0,indent=0)
  986.     @digits_max = digits_max
  987.     @number = 0
  988.     @x = x
  989.     @y = y
  990.     @indent = indent
  991.     @count = 0
  992.     @move_right = true
  993.     # Calculate character width for drawing and tracking cursor movement
  994.     dummy_bitmap = Bitmap.new(32, 32)
  995.     dummy_bitmap.font.size = $game_system.message_text_size
  996.     dummy_bitmap.font.name = $game_system.message_text_font
  997.     @width = (dummy_bitmap.text_size('0').width\
  998.         + dummy_bitmap.text_size(' ').width)
  999.     @x = @x - (@width*@digits_max)
  1000.     dummy_bitmap.dispose
  1001.     @index = 0
  1002.     # Create number display bitmap
  1003.     @number_window = Sprite.new
  1004.     @number_window.x = @x
  1005.     @number_window.y = @y
  1006.     @number_window.z = 15
  1007.     @number_window.bitmap = Bitmap.new(@width*@digits_max, 40)
  1008.     @number_window.bitmap.font.color = TEXT_COLOR_BLACK
  1009.     @number_window.bitmap.font.size = $game_system.message_text_size
  1010.     @number_window.bitmap.font.name = $game_system.message_text_font
  1011.     # Create the cursor to track input position
  1012.     create_cursor
  1013.   end
  1014.   #--------------------------------------------------------------------------
  1015.   # * Get Number
  1016.   #--------------------------------------------------------------------------
  1017.   def number
  1018.     return @number
  1019.   end
  1020.   #--------------------------------------------------------------------------
  1021.   # * Set Number
  1022.   #     number : new number
  1023.   #--------------------------------------------------------------------------
  1024.   def number=(number)
  1025.     @number = [[number, 0].max, 10 ** @digits_max - 1].min
  1026.     refresh
  1027.   end
  1028.   #--------------------------------------------------------------------------
  1029.   # * Create Cursor
  1030.   #--------------------------------------------------------------------------
  1031.   def create_cursor
  1032.     @cursor = Sprite.new
  1033.     @cursor.bitmap = Bitmap.new(32,5)
  1034.     @cursor.x = @number_window.x
  1035.     @cursor.y = @number_window.y\
  1036.               + @number_window.bitmap.text_size('0').height + 3
  1037.     @cursor.z = 16
  1038.     @cursor.opacity = 185
  1039.     width = @number_window.bitmap.text_size('0').width + 2
  1040.     @cursor.bitmap.fill_rect(0,0,width,2,text_color(1))
  1041.   end
  1042.   #--------------------------------------------------------------------------
  1043.   # * Cursor Update
  1044.   #--------------------------------------------------------------------------
  1045.   def update_cursor
  1046.     @count += 1
  1047.     if @count % 10 == 0
  1048.       if @move_right == true
  1049.         @cursor.x += 1
  1050.       else
  1051.         @cursor.x -= 1
  1052.       end
  1053.       if @count == 20
  1054.         if @move_right == true
  1055.           @move_right = false
  1056.         else
  1057.           @move_right = true
  1058.         end
  1059.         @count = 0
  1060.       end
  1061.     end
  1062.   end
  1063.   #--------------------------------------------------------------------------
  1064.   # * Frame Update
  1065.   #--------------------------------------------------------------------------
  1066.   def update
  1067.     update_position
  1068.     # If up or down directional button was pressed
  1069.     if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN)
  1070.       $game_system.se_play($data_system.cursor_se)
  1071.       # Get current place number and change it to 0
  1072.       place = 10 ** (@digits_max - 1 - @index)
  1073.       n = @number / place % 10
  1074.       @number -= n * place
  1075.       # If up add 1, if down substract 1
  1076.       n = (n + 1) % 10 if Input.repeat?(Input::UP)
  1077.       n = (n + 9) % 10 if Input.repeat?(Input::DOWN)
  1078.       # Reset current place number
  1079.       @number += n * place
  1080.       refresh
  1081.     end
  1082.     # Cursor right
  1083.     if Input.repeat?(Input::RIGHT)
  1084.       if @digits_max >= 2
  1085.         $game_system.se_play($data_system.cursor_se)
  1086.         @index = (@index + 1) % @digits_max
  1087.         @cursor.x += @width
  1088.         if @index == 0
  1089.           @cursor.x = @number_window.x
  1090.         end
  1091.       end
  1092.     end
  1093.     # Cursor left
  1094.     if Input.repeat?(Input::LEFT)
  1095.       if @digits_max >= 2
  1096.         $game_system.se_play($data_system.cursor_se)
  1097.         @index = (@index + @digits_max - 1) % @digits_max
  1098.         @cursor.x -= @width
  1099.         if @index == @digits_max - 1
  1100.           @cursor.x += @width * @digits_max
  1101.         end
  1102.       end
  1103.     end
  1104.     update_cursor
  1105.   end
  1106.  
  1107.   #--------------------------------------------------------------------------
  1108.   # * Dispose
  1109.   #--------------------------------------------------------------------------
  1110.  
  1111.   def dispose
  1112.     @number_window.bitmap.clear
  1113.     @number_window = nil
  1114.     @cursor.bitmap.clear
  1115.     @cursor = nil
  1116.   end
  1117.  
  1118.   #--------------------------------------------------------------------------
  1119.   # * Update Position for Bubble Movement
  1120.   #--------------------------------------------------------------------------
  1121.  
  1122.   def update_position
  1123.     if @number_window.x != @x
  1124.       @number_window.x = @x
  1125.       @cursor.x = @number_window.x + (@index * @width)
  1126.     end
  1127.     if @number_window.y != @y
  1128.       @number_window.y = @y
  1129.       @cursor.y = @number_window.y\
  1130.                 + @number_window.bitmap.text_size('0').height + 3
  1131.     end    
  1132.   end
  1133.  
  1134.   #--------------------------------------------------------------------------
  1135.   # * Refresh
  1136.   #--------------------------------------------------------------------------
  1137.   def refresh
  1138.     @number_window.bitmap.clear
  1139.     s = sprintf("%0*d", @digits_max, @number)
  1140.     for i in 0...@digits_max
  1141.       @number_window.bitmap.draw_text(i * @width, 0, 32, 32, s[i,1])
  1142.     end
  1143.   end
  1144. end
  1145.  
  1146. #========================================================================
  1147. #   Window Message
  1148. #
  1149. #       Controls message displayed from the show text event command
  1150. #
  1151. #       This modified version also allows for a message to be displayed
  1152. #         from a script.  Simply change $game_temp.message_text to
  1153. #         whatever text you want to display.  Remember that outside
  1154. #         of the message entry box in the event commands, you will have
  1155. #         to manuall insert the newline character "\n".)
  1156. #========================================================================
  1157.  
  1158. class Window_Message < Window_Base
  1159.  
  1160.   attr_accessor :contents_showing
  1161.   attr_accessor :finished
  1162.   attr_accessor :fade_in
  1163.   attr_accessor :fade_out
  1164.   attr_accessor :message
  1165.   attr_accessor :enter_pressed
  1166.  
  1167.   #--------------------------------------------------------------------------
  1168.   # * Object Initialization
  1169.   #
  1170.   #       Prepare message variables, then wait for re_initialize
  1171.   #--------------------------------------------------------------------------
  1172.   def initialize(sub=false, text=nil)
  1173.     # Bubble message variables
  1174.     @enter_pressed = false
  1175.     @text_height = 0
  1176.     @fade_in = false
  1177.     @event = 0
  1178.     @contents_showing = false
  1179.     @finished = nil
  1180.     @position = ''
  1181.     @active = false
  1182.     @lines = 0
  1183.     @up = 0
  1184.     @count = 0
  1185.     @cursor_count = 0
  1186.     @cursor_move_right = nil
  1187.     @wait = 0
  1188.     @wait_add = 0
  1189.     @pause = false
  1190.     @index = 0
  1191.     @sub = sub
  1192.     @face = nil
  1193.     @face_extension_x = 0
  1194.     @face_extension_y = 0
  1195.     @thought = false
  1196.     @bubble_color = nil
  1197.     @hp = nil
  1198.     if @sub == false
  1199.       @sub_number = nil
  1200.       @sub_windows = []
  1201.     end
  1202.     @indent = false
  1203.     @text = text
  1204.   end
  1205.   #--------------------------------------------------------------------------
  1206.   # * Re_Initialize
  1207.   #
  1208.   #       Call when actual text processing occurs
  1209.   #--------------------------------------------------------------------------
  1210.     def re_initialize
  1211.      
  1212.       if $game_temp.message_text != nil
  1213.         # Prevent improper cursor indention on choices
  1214.         @indent = false
  1215.         if $game_system.face_graphic_name != nil
  1216.           @face = $game_system.face_graphic_name
  1217.         else
  1218.           @face = nil
  1219.         end
  1220.         @face_extension_x = 0
  1221.         @face_extension_y = 0
  1222.        
  1223.         temp = Sprite.new
  1224.         temp = Bitmap.new(32,32)
  1225.         # Set @text to whatever text will display
  1226.         # For sub messages this will already be set
  1227.         if @text == nil
  1228.           @text = $game_temp.message_text
  1229.         end
  1230.        
  1231.         # Change \ escaped characters to character codes for processing
  1232.         prep_text
  1233.        
  1234.         # Determine number of lines in the message
  1235.         @lines = 0
  1236.         @text.each_line {|line|
  1237.           @lines += 1
  1238.         }
  1239.        
  1240.         temp_text = @text.clone
  1241.         # Get rid of any non displayed elements to determine the
  1242.         #   appropriate message box size
  1243.        
  1244.         def get_digits(integer)
  1245.           if integer < 10
  1246.             return 1
  1247.           elsif integer >= 10
  1248.             return 2
  1249.           elsif integer >= 100
  1250.             return 3
  1251.           end
  1252.         end
  1253.        
  1254.         while temp_text.slice(/\001\[([0-9]+)\]/)
  1255.           temp_text.slice!(/\001\[([0-9]+)\]/)
  1256.         end
  1257.        
  1258.         while temp_text.slice(/\002/)
  1259.           temp_text.slice!(/\002/)
  1260.         end
  1261.        
  1262.         while temp_text.slice(/\004\[([0-9]+)\]/)
  1263.           temp_text.slice!(/\004\[([0-9]+)\]/)
  1264.         end
  1265.        
  1266.         while temp_text.slice(/\005\[([0-9]+)\]/) != nil
  1267.           temp_text.slice!(/\005\[([0-9]+)\]/)
  1268.         end
  1269.        
  1270.         while temp_text.slice(/\006/)
  1271.           temp_text.slice!(/\006/)
  1272.         end
  1273.        
  1274.         while temp_text.slice(/\007\[([0-9]+)\]/)
  1275.           temp_text.slice!(/\007\[([0-9]+)\]/)
  1276.         end
  1277.        
  1278.         while temp_text.slice(/\011/) != nil
  1279.           temp_text.slice!(/\011/)
  1280.         end
  1281.                
  1282.         while temp_text.slice(/\015\[([0-9]+)\]/)
  1283.           temp_text.slice!(/\015\[([0-9]+)\]/)
  1284.           @face = Faces[$1.to_i]
  1285.         end
  1286.        
  1287.         # Make sure @thought is false unless specified true
  1288.         @thought = false
  1289.         while temp_text.slice(/\017/)
  1290.           temp_text.slice!(/\017/)
  1291.           @thought = true
  1292.           @text.slice!(/\017/)
  1293.         end
  1294.        
  1295.         # Change @bubble_color to keep default color unless specified other color
  1296.         @bubble_color = nil
  1297.         while temp_text.slice(/\018\[([0-9]+)\]/)
  1298.           temp_text.slice!(/\018\[([0-9]+)\]/)
  1299.           @bubble_color = mood_color($1.to_i)
  1300.           @text.slice!(/\018\[([0-9]+)\]/)
  1301.         end
  1302.        
  1303.         # Determine message bubble size
  1304.         bitmap = Sprite.new
  1305.         bitmap.bitmap = Bitmap.new(32,32)
  1306.         bitmap.bitmap.font.name = $game_system.message_text_font
  1307.         bitmap.bitmap.font.size = $game_system.message_text_size
  1308.         @text_rect = Rect.new(0,0,0,0)
  1309.         @line_width = []
  1310.         i = 0
  1311.         temp_text.each_line {|line|
  1312.           temp = bitmap.bitmap.text_size(line)
  1313.           @line_width[i] = temp.width
  1314.           if temp.width > @text_rect.width
  1315.             @text_rect.width = temp.width
  1316.           end
  1317.           @text_height = temp.height
  1318.           i += 1
  1319.         }
  1320.        
  1321.         # Add space for number input if necessary
  1322.         if $game_temp.num_input_variable_id > 0 && @sub == false
  1323.           @lines += 1
  1324.         end
  1325.  
  1326.         @text_rect.height = @text_height * @lines
  1327.        
  1328.         total_size = 0
  1329.         longest_line = 0
  1330.         current_line_height = @text_height
  1331.         @line_height_correction = [0,0,0,0]
  1332.         line = 0
  1333.         skip = 0
  1334.        
  1335.         for i in 0...temp_text.size
  1336.           # Check for bold toggling and icon insertion
  1337.           if temp_text[i] == 3
  1338.             bitmap.bitmap.font.bold == false ? bitmap.bitmap.font.bold = true : bitmap.bitmap.font.bold = false
  1339.           end
  1340.           # Check for icon insertion and add 24 pixels to this line's width
  1341.           if temp_text[i] == 12
  1342.             # Add sufficient width for an icon to be inserted in the text
  1343.             total_size += 24
  1344.             # Adjust the height of the text box if necessary
  1345.             if current_line_height < 24
  1346.               current_line_height = 24
  1347.               @text_rect.height += (24 - @text_height)
  1348.               @line_height_correction[line] = (24 - @text_height)
  1349.             end
  1350.             # Set variable to skip over icon text in sizing operations
  1351.             skip = 4
  1352.           end
  1353.           # Check for face graphic
  1354.           if temp_text[i] == 13
  1355.             temp_text.slice(/\015\[([0-9]+)\]/)
  1356.             skip = 4
  1357.             @face = Faces[$1.to_i]
  1358.           end
  1359.           # Check for new line character
  1360.           if temp_text[i] == 10
  1361.             total_size = 0
  1362.             current_line_height = @text_height
  1363.             line += 1
  1364.           end
  1365.           # Do not size characters relating to an icon
  1366.           if skip == 0
  1367.             total_size += bitmap.bitmap.text_size(temp_text.slice(i,1)).width
  1368.           else
  1369.             skip -= 1
  1370.           end
  1371.           # Make sure longest line sets the bubble width value
  1372.           longest_line = total_size if total_size > longest_line
  1373.         end
  1374.        
  1375.         # Insert facce graphic name if none explicit in message and
  1376.         # one is stored in $game_system
  1377.         if $game_system.face_graphic_name != nil && temp_text.slice(/\015\[([0-9]+)\]/) == nil
  1378.           @face = $game_system.face_graphic_name
  1379.         end
  1380.         # Account for face graphic in message box graphic
  1381.         if @face != nil
  1382.           determine_face_extension
  1383.         else
  1384.           @face_extension_x = 0
  1385.           @face_extension_y = 0
  1386.         end
  1387.        
  1388.         if $game_system.face_graphic_type == FACE_GRAPHIC_FULL
  1389.           @text_rect.width = longest_line
  1390.         else
  1391.           @text_rect.width = longest_line + @face_extension_x
  1392.         end
  1393.  
  1394.         # Set start values for text drawing
  1395.         @x=@y=0
  1396.         # Determine message position and create the message bubble
  1397.         #(only if $game_system.message_text_mode == TEXT_MODE_BUBBLE        
  1398.         if $game_system.message_text_mode != TEXT_MODE_INVISIBLE
  1399.           # Check for existence of necessary Bubble files if mode is set to Bubble
  1400.           if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  1401.             # Correct text mode if files do not exist
  1402.             if File.exist?("Graphics/Pictures/Message_Bubble.png") == false || \
  1403.               File.exist?("Graphics/Pictures/Pointer2.png") == false
  1404.               $game_system.message_text_mode = TEXT_MODE_WINDOWSKIN
  1405.               default_color(8)
  1406.             end
  1407.           end            
  1408.           determine_position
  1409.           create_bubble
  1410.         else
  1411.           @bubble_correction_y = 0
  1412.           @message_box = Sprite.new
  1413.           @message_box.bitmap = Bitmap.new(@text_rect.width+25, @text_rect.height+26)
  1414.           @message_box.ox = @message_box.bitmap.width/2
  1415.           @message_box.oy = @message_box.bitmap.height/2
  1416.           @message_box.x = $game_system.invisible_position[0]
  1417.           @message_box.y = $game_system.invisible_position[1]
  1418.           if @message_box.y - @message_box.bitmap.height/2 < 0
  1419.             @message_box.y += @message_box.bitmap.height/2
  1420.           elsif @message_box.y + @message_box.bitmap.height/2 > 480
  1421.             @message_box.y -= @message_box.bitmap.height/2
  1422.           end
  1423.         end
  1424.         # Create message sprite for drawing actual text
  1425.         @message = Sprite.new
  1426.         @message.x = @message_box.x
  1427.         @message.y = @message_box.y
  1428.         if @sub == false
  1429.           @message.z += 1
  1430.         end
  1431.         @message.ox = @message_box.ox
  1432.         @message.oy = @message_box.oy
  1433.         @message.bitmap = \
  1434.           Bitmap.new(@message_box.bitmap.width,@message_box.bitmap.height)
  1435.         @message.bitmap.font.size = $game_system.message_text_size
  1436.         @message.bitmap.font.color = TEXT_COLOR_BLACK
  1437.         @speed = $game_system.message_text_speed
  1438.         @text_color = $game_system.default_color
  1439.       end
  1440.     end
  1441.   #--------------------------------------------------------------------------
  1442.   # * Dispose
  1443.   #--------------------------------------------------------------------------
  1444.   def dispose
  1445.     terminate_message
  1446.     $game_temp.message_window_showing = false
  1447.     if @input_number_window != nil
  1448.       @input_number_window.dispose
  1449.     end
  1450.   end
  1451.  
  1452.   #--------------------------------------------------------------------------
  1453.   # * Subs Finished?
  1454.   #
  1455.   #       Checks to see if all sub messages have finished writing
  1456.   #--------------------------------------------------------------------------
  1457.   def subs_finished?
  1458.     abort_flag = true
  1459.     count = 0
  1460.     for sub in @sub_windows
  1461.       count += 1 if (sub.finished == true && sub.enter_pressed == false)
  1462.       if sub.finished && sub.enter_pressed
  1463.         sub.enter_pressed = false
  1464.       end
  1465.     end
  1466.     abort_flag = false if count == @sub_windows.size
  1467.     if abort_flag == true
  1468.       return false
  1469.     else
  1470.       return true
  1471.     end
  1472.   end
  1473.  
  1474.   #--------------------------------------------------------------------------
  1475.   # * Erase Subs
  1476.   #
  1477.   #       Erases any existing subb messages
  1478.   #--------------------------------------------------------------------------
  1479.   def erase_subs
  1480.     if @sub_windows != nil
  1481.       for sub in @sub_windows
  1482.         sub.fade_out = true
  1483.       end
  1484.     end
  1485.   end
  1486.   #--------------------------------------------------------------------------
  1487.   # * Terminate Message
  1488.   #--------------------------------------------------------------------------
  1489.   def terminate_message
  1490.     # Call message callback
  1491.     if @message != nil
  1492.       @message_box.bitmap.clear
  1493.       @message.z -= 1
  1494.       @message.bitmap.clear
  1495.     end
  1496.     if @cursor != nil
  1497.       @cursor.bitmap.clear
  1498.       @cursor.dispose
  1499.       @cursor = nil
  1500.     end
  1501.     if $game_temp.message_proc != nil
  1502.       $game_temp.message_proc.call
  1503.     end
  1504.     # Clear variables related to text, choices, and number input
  1505.     $game_temp.message_text = nil
  1506.     $game_temp.message_proc = nil
  1507.     $game_temp.choice_start = 99
  1508.     $game_temp.choice_max = 0
  1509.     $game_temp.choice_cancel_type = 0
  1510.     $game_temp.choice_proc = nil
  1511.     $game_temp.num_input_start = 99
  1512.     $game_temp.num_input_variable_id = 0
  1513.     $game_temp.num_input_digits_max = 0
  1514.     # Dispose of gold window
  1515.     if @gold_window != nil && $game_temp.consecutive_gold_window == false
  1516.       @gold_window.dispose
  1517.       @gold_window = nil
  1518.     end
  1519.     @contents_showing = false
  1520.     @finished = nil
  1521.     @active = false
  1522.     $game_temp.message_window_showing = false
  1523.     @text = nil
  1524.     if @sub == false
  1525.       erase_subs
  1526.       temp = subs_finished?
  1527.       if temp == true
  1528.         for i in 0...@sub_windows.size
  1529.           @sub_windows[i] = nil
  1530.         end
  1531.         @sub_windows = []
  1532.       end
  1533.     end
  1534.     @sub_number = nil
  1535.   end
  1536.   #--------------------------------------------------------------------------
  1537.   # * Draw_Message
  1538.   #--------------------------------------------------------------------------
  1539.   def draw_message
  1540.     return if @pause == true
  1541.     return if @text == nil
  1542.     # Indent if choice and following message text
  1543.     index = $game_system.map_interpreter.index - 2
  1544.     code = $game_system.map_interpreter.list[index].code
  1545.  
  1546.     # Check for choice following a line of text
  1547.     if @y == $game_temp.choice_start && (code == 101 || code == 401) \
  1548.       && @indent == false && $separate_choices == false
  1549.       @indent = true
  1550.       #@x = 16 + @face_extension_x
  1551.     end
  1552.    
  1553.     if @wait == 0
  1554.  
  1555.       # Set correction for icon insertion
  1556.       y_correction = 0
  1557.       for i in 0..@y
  1558.         if @line_height_correction[i] != nil
  1559.           y_correction += @line_height_correction[i]
  1560.         end
  1561.       end
  1562.       # Set offset value dependant on text mode
  1563.       if $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  1564.         offset = 10
  1565.       elsif $game_system.message_text_mode == TEXT_MODE_BUBBLE
  1566.         offset = 13
  1567.       else
  1568.         offset = 0
  1569.       end
  1570.  
  1571.       if @face != nil
  1572.         if $game_system.face_graphic_type == FACE_GRAPHIC_FULL
  1573.           base_y = (@face_extension_y + @text_rect.height) - (@text_rect.height + 20)
  1574.         else
  1575.           base_y = @bubble_correction_y
  1576.         end
  1577.       else
  1578.         base_y = @bubble_correction_y
  1579.       end
  1580.       @text_y ||= base_y
  1581.       y = @text_y + (@text_height * @y) + @bubble_correction_y + y_correction
  1582.      
  1583.       # Insert face graphic if included
  1584.       if @text.slice!(/\015\[([0-9]+)\]/) || @face != nil
  1585.         draw_face
  1586.       end
  1587.      
  1588.       # Check for formatting options character from text
  1589.       @c = @text[0,1].slice(/./m)
  1590.       case @c
  1591.       # If \\
  1592.       when "\000"
  1593.         # Return to original text
  1594.         @c = "\\"
  1595.         @text.sub!("\000") {"\\"}
  1596.         return
  1597.       # If \C[n]
  1598.       when "\001"
  1599.         # Change text color
  1600.         @text.sub!(/\[([0-9]+)\]/, "")
  1601.         color = $1.to_i
  1602.         if color >= 0 and color <= 8
  1603.           @message.bitmap.font.color = text_color(color)
  1604.           @text_color = text_color(color)
  1605.         end
  1606.         @text.slice!("\001")
  1607.         # go to next text
  1608.         return
  1609.       # If \G
  1610.       when "\002"
  1611.         # Make gold window
  1612.         if @gold_window == nil
  1613.           @gold_window = Window_Gold_New.new
  1614.           #@gold_window.x = 560 - @gold_window.width
  1615.           if $game_temp.in_battle
  1616.           #  @gold_window.y = 192
  1617.           else
  1618.           #  @gold_window.y = 0
  1619.           end
  1620.           #@gold_window.opacity = @message.opacity
  1621.           #@gold_window.back_opacity = 200
  1622.         end
  1623.         @text.slice!("\002")
  1624.         # go to next text
  1625.         return
  1626.       # If \B
  1627.       when "\003"
  1628.         if @message.bitmap.font.bold == false
  1629.           @message.bitmap.font.bold = true
  1630.         else
  1631.           @message.bitmap.font.bold = false
  1632.         end
  1633.         @text.slice!("\003")
  1634.         return
  1635.       # If sub window is being called
  1636.       when "\004"
  1637.         @text.slice!("\004")
  1638.         @text.sub!(/\[([0-9]+)\]/, "")
  1639.         if @sub == false
  1640.           @sub_number = $1
  1641.           event_key = $game_temp.current_event
  1642.           # Find the cooresponding slave window
  1643.           # Must immediately follow master window and be
  1644.           # in consecutive order
  1645.           num = 0
  1646.           index = 0
  1647.           if $game_system.map_interpreter.list[$game_system.map_interpreter.index].code == 101 \
  1648.             && num != @sub_number.to_i
  1649.             for i in $game_system.map_interpreter.index\
  1650.               ...$game_system.map_interpreter.list.size
  1651.               if $game_system.map_interpreter.list[i].code == 101
  1652.                 num = $game_system.map_interpreter.list[i].parameters[0].slice(/\\[Ss]\[([0-9]+)\]/)
  1653.                 num = num.slice(/([0-9]+)/).to_i if num!= nil
  1654.                 if num != nil
  1655.                   if num != @sub_number.to_i
  1656.                     num += 1
  1657.                   end
  1658.                   index = i
  1659.                 end
  1660.                 if num == @sub_number.to_i
  1661.                   break
  1662.                 end
  1663.               end
  1664.             end
  1665.           else
  1666.             index = $game_system.map_interpreter.index
  1667.           end
  1668.           $game_system.map_interpreter.index = index
  1669.           # Save original index value for later
  1670.           original_index = $game_system.map_interpreter.index
  1671.           lines = 1
  1672.           if $game_system.map_interpreter.list[index].code == 101
  1673.             # Loop until the cooresponding \s[x] character is found
  1674.             loop do
  1675.               # Break if there is nothing more to sort through
  1676.               if $game_system.map_interpreter.list[index] == nil
  1677.                 break
  1678.               end
  1679.               # Check the \s[x] for a match with the initial match in master message
  1680.               temp = $game_system.map_interpreter.list[index].parameters.clone
  1681.               number = temp[0].slice(/\\[Ss]\[([0-9]+)\]/)
  1682.               if number != nil
  1683.                 number = number.slice(/[0-9]+/)
  1684.               end
  1685.               # If the proper match is found, create sub window
  1686.               if number == @sub_number
  1687.                 # Create message text for sub message
  1688.                 # Make sure sub message begins at first line
  1689.                 while $game_system.map_interpreter.list[index].code != 101
  1690.                   index -= 1
  1691.                 end
  1692.                 text = $game_system.map_interpreter.list[index].parameters[0].clone
  1693.                 if $game_system.map_interpreter.list[index+1].code == 401
  1694.                   text = text + "\n"
  1695.                   lines += 1
  1696.                 end
  1697.                 # Continue to add text if there is something to be added
  1698.                 if $game_system.map_interpreter.list[index+1].code == 401
  1699.                   # Loop until all sub message text is added
  1700.                   loop do
  1701.                     index += 1
  1702.                     text = text + $game_system.map_interpreter.list[index].parameters[0].clone
  1703.                     if $game_system.map_interpreter.list[index+1].code == 401
  1704.                       text = text + "\n"
  1705.                       lines += 1
  1706.                     else
  1707.                       break
  1708.                     end
  1709.                   end
  1710.                 end
  1711.                 # If last sub window, set event index
  1712.                 if @text.slice("\004") == nil
  1713.                   $game_system.map_interpreter.index = index + 1
  1714.                 end
  1715.                 # Create actual sub window object and place it into
  1716.                 # @sub_windows array for update and disposal
  1717.                 sub = Window_Message.new(true,text)
  1718.                 @sub_windows.push sub
  1719.                 break
  1720.               else
  1721.                 index += 1
  1722.               end
  1723.             end # end loop
  1724.           return
  1725.           end # end if code == 101
  1726.         end
  1727.       # When \w[x]
  1728.       when "\005"
  1729.         @text.slice!(/\005\[([0-9]+)\]/)
  1730.         @wait_add = $1.to_i
  1731.         @wait += @wait_add
  1732.         @wait_add = 0
  1733.         return
  1734.       # When \p
  1735.       when "\006"
  1736.         @text.slice!("\006")
  1737.         if @enter_pressed == false
  1738.           @pause = true
  1739.         end
  1740.         return
  1741.       # When \q
  1742.       when "\011"
  1743.         terminate_message
  1744.         return
  1745.       # When \i[x]
  1746.       when "\014"  
  1747.         #@text.slice!(/\014\[([0-9]+)\]/)
  1748.         @text.slice!(/\014\[([0-9A-Za-z_\-]+)\]/)
  1749.         icon = Sprite.new
  1750.         icon.opacity = 0
  1751.         icon.bitmap = RPG::Cache.icon($1)
  1752.         true_y = @text_y + (@y * @text_height) + y_correction #+ y + @face_extension_y - (@text_rect.height + 25)
  1753.         @message.bitmap.blt(offset+@x+@face_extension_x,true_y,icon.bitmap,Rect.new(0,0,24,24))
  1754.         @x += 24
  1755.       # When \h[x]
  1756.       when "\016"
  1757.         @text.slice!(/\016\[([0-9]+)\]/)
  1758.         @hp = $game_party.actors[$1.to_i].hp
  1759.       end
  1760.      
  1761.       # Get 1 character from text
  1762.       @c = @text.slice!(/./m)
  1763.  
  1764.       if @c == nil
  1765.         @finished = true
  1766.         if $game_temp.choice_max > 0
  1767.           @cursor_move_right = true
  1768.           @index = 0
  1769.           create_cursor
  1770.           $separate_choices = false
  1771.         elsif $game_temp.num_input_variable_id > 0 && @sub == false
  1772.           digits_max = $game_temp.num_input_digits_max
  1773.           number = $game_variables[$game_temp.num_input_variable_id]
  1774.           x = @message.x + @message.bitmap.width/2 - 13
  1775.           y = @message.y - @message.bitmap.height/2\
  1776.               + @text_height * (@y) + @bubble_correction_y
  1777.           @input_number_window = Window_InputNumber.new(digits_max,x,y,@face_extension_x)
  1778.           @input_number_window.number = number
  1779.         end
  1780.         return
  1781.       end
  1782.       # If new line text
  1783.       if @c == "\n"
  1784.         # Add 1 to y
  1785.         @y += 1
  1786.         @x = 0
  1787.         # Indent if choice
  1788.         if @y >= $game_temp.choice_start
  1789.           @x = 0
  1790.         end
  1791.         # go to next text
  1792.         return
  1793.       end
  1794.       # Draw text    
  1795.       @message.bitmap.font.name = $game_system.message_text_font
  1796.       # Set exact y value for drawing
  1797.       if @face_extension_y != 0
  1798.         true_y = y + @face_extension_y - (@text_rect.height + 25)
  1799.       else
  1800.         true_y = y
  1801.       end
  1802.      
  1803.       true_y = @text_y + @y*@text_height + y_correction
  1804.      
  1805.       if $game_system.message_text_outline == TEXT_OUTLINE
  1806.         if $game_system.message_text_outline == TEXT_OUTLINE
  1807.           @message.bitmap.font.color = $game_system.message_text_outline_color
  1808.         elsif @message.bitmap.font.color != $game_system.default_color
  1809.           @message.bitmap.font.color = $game_system.default_color
  1810.         end
  1811.         # Correct character writing position for lower case "f"
  1812.         # due to Monotype Corsiva text writing glitch
  1813.         temp = @x
  1814.         if  @c == 'f' && $game_system.message_text_font == TEXT_FONT_CORSIVA
  1815.           @x -= 2
  1816.         end
  1817.         @message.bitmap.draw_text(offset+@x+@face_extension_x+1,true_y,40,32,@c)
  1818.         @message.bitmap.draw_text(offset+@x+@face_extension_x-1,true_y,40,32,@c)
  1819.         @message.bitmap.draw_text(offset+@x+@face_extension_x,true_y+1,40,32,@c)
  1820.         @message.bitmap.draw_text(offset+@x+@face_extension_x,true_y-1,40,32,@c)
  1821.        
  1822.         # Correct any change made to @x so that text is written
  1823.         # in the proper place
  1824.         if  @x != temp
  1825.           @x = temp
  1826.         end
  1827.        
  1828.       end
  1829.      
  1830.       @message.bitmap.font.color = @text_color
  1831.      
  1832.       # Correct character writing position for lower case "f"
  1833.       # due to Monotype Corsiva text writing glitch
  1834.       temp = @x
  1835.       if @c == 'f' && $game_system.message_text_font == TEXT_FONT_CORSIVA
  1836.         @x -= 2
  1837.       end
  1838.       @message.bitmap.draw_text(offset+@x+@face_extension_x,true_y,40,32,@c)
  1839.       # Correct any change made to @x so that text is written
  1840.       # in the proper place
  1841.       if @x != temp && $game_system.message_text_font == TEXT_FONT_CORSIVA
  1842.         @x = temp
  1843.       end
  1844.       # Add x to drawn text width
  1845.       @x += @message.bitmap.text_size(@c).width
  1846.       @wait = $game_system.message_text_speed
  1847.       @wait_add = 0
  1848.     else
  1849.       @wait -= 1
  1850.     end
  1851.   end
  1852.  
  1853.   #--------------------------------------------------------------------------
  1854.   # * Determine Face Extension
  1855.   #     This method determines how much distance needs to be added to the
  1856.   #     face graphic
  1857.   #--------------------------------------------------------------------------
  1858.   def determine_face_extension
  1859.     sprite = Sprite.new
  1860.     sprite.opacity = 0
  1861.     sprite.bitmap = Bitmap.new("Graphics/Faces/#{@face}")
  1862.     # Set extension value in horizontal direction
  1863.     if @face != nil
  1864.       @face_extension_x = sprite.bitmap.width
  1865.       if $game_system.face_graphic_type == FACE_GRAPHIC_BOX
  1866.         @face_extension_x += 5
  1867.       end
  1868.       if sprite.bitmap.height > @text_rect.height
  1869.         @face_extension_y = sprite.bitmap.height - @text_rect.height
  1870.       end
  1871.     end
  1872.     sprite.bitmap.dispose
  1873.     sprite = nil
  1874.   end
  1875.  
  1876.   #--------------------------------------------------------------------------
  1877.   # * Draw Face Graphics
  1878.   #--------------------------------------------------------------------------
  1879.   def draw_face
  1880.     sprite = Sprite.new
  1881.     sprite.opacity = 0
  1882.     sprite.bitmap = Bitmap.new("Graphics/Faces/#{@face}")
  1883.     rect = Rect.new(0,0,sprite.bitmap.width,sprite.bitmap.height)
  1884.     if $game_system.face_graphic_type == FACE_GRAPHIC_FULL
  1885.       @message.bitmap.blt(0,0,sprite.bitmap,rect)
  1886.     else
  1887.       y = @text_y + 10
  1888.       @message.bitmap.blt(13,y,sprite.bitmap,rect)
  1889.     end
  1890.     sprite.bitmap.dispose
  1891.     sprite = nil
  1892.   end
  1893.  
  1894.   #--------------------------------------------------------------------------
  1895.   # * Refresh
  1896.   #--------------------------------------------------------------------------
  1897.   def refresh
  1898.     if @pause == false
  1899.       if Input.trigger?(Input::C) && $game_system.message_skip_disabled == false
  1900.         @enter_pressed = true
  1901.         until @c == nil || @text == nil
  1902.           draw_message
  1903.         end
  1904.         @enter_pressed = false if @sub == false
  1905.       else
  1906.         if $game_system.message_text_skip != TEXT_SKIP_FULL
  1907.           count = $game_system.message_text_skip
  1908.           for i in 0...count
  1909.             draw_message if (@c != nil || @text != nil)
  1910.           end
  1911.         else
  1912.           if @c == nil && @text != nil
  1913.             draw_message
  1914.           end
  1915.           until @c == nil || @text == nil
  1916.             draw_message
  1917.           end
  1918.         end
  1919.       end
  1920.     else
  1921.       if Input.trigger?(Input::C)
  1922.         temp = subs_finished?
  1923.         if temp == true
  1924.           erase_subs
  1925.           @pause = false
  1926.         end
  1927.       end
  1928.       draw_message
  1929.     end
  1930.   end
  1931.   #--------------------------------------------------------------------------
  1932.   # * Frame Update
  1933.   #--------------------------------------------------------------------------
  1934.   def update
  1935.     # Update sub messages if they exist
  1936.     if @sub_windows != nil
  1937.       for i in 0...@sub_windows.size
  1938.         @sub_windows[i].update
  1939.       end
  1940.     end
  1941.     # Update gold window if it exists
  1942.     if @gold_window != nil
  1943.       @gold_window.update
  1944.     end
  1945.     # Update bubble graphic
  1946.     if @active == true && ($game_system.message_text_mode == TEXT_MODE_BUBBLE \
  1947.       || $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN)
  1948.       update_bubble
  1949.     end
  1950.     # If fade in
  1951.     if @fade_in
  1952.       if $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  1953.         max_opacity = 192
  1954.       else
  1955.         max_opacity = 255
  1956.       end
  1957.       @message_box.opacity += 24
  1958.       if @input_number_window != nil
  1959.         @input_number_window.contents_opacity += 24
  1960.       end
  1961.       if @message_box.opacity == max_opacity
  1962.         @fade_in = false
  1963.       end
  1964.       return
  1965.     end
  1966.    
  1967.     # If fade out
  1968.     if @fade_out
  1969.       @message_box.opacity -= 48
  1970.       @message.opacity -= 48
  1971.       if @cursor != nil
  1972.         @cursor.opacity -= 48
  1973.       end
  1974.       if @input_number_window != nil
  1975.         @input_number_window.contents_opacity -= 24
  1976.       end
  1977.       if @gold_window != nil && $game_temp.consecutive_gold_window == false
  1978.         @gold_window.fade_out
  1979.       end
  1980.       if @message_box.opacity == 0 && @message.opacity == 0
  1981.         @fade_out = false
  1982.         terminate_message if @sub == false
  1983.       end
  1984.       return
  1985.     end
  1986.    
  1987.     # If inputting number
  1988.     if @input_number_window != nil
  1989.       @input_number_window.update
  1990.       # Confirm
  1991.       if Input.trigger?(Input::C)
  1992.         $game_system.se_play($data_system.decision_se)
  1993.         $game_variables[$game_temp.num_input_variable_id] =
  1994.           @input_number_window.number
  1995.         $game_map.need_refresh = true
  1996.         # Dispose of number input window
  1997.         @input_number_window.dispose
  1998.         @input_number_window = nil
  1999.        
  2000.         if @sub_windows != nil
  2001.           temp = subs_finished?
  2002.           if temp == true
  2003.             @fade_out = true
  2004.             erase_subs
  2005.           end
  2006.         end
  2007.       end
  2008.       return
  2009.     end
  2010.     # If message is being displayed
  2011.     if @contents_showing && @finished == true
  2012.       # If choice isn't being displayed, show pause sign
  2013.       if $game_temp.choice_max == 0
  2014.         @active = true
  2015.       else
  2016.         update_cursor
  2017.       end
  2018.       # Cancel
  2019.       if Input.trigger?(Input::B)
  2020.         if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  2021.           $game_system.se_play($data_system.cancel_se)
  2022.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  2023.           terminate_message
  2024.         end
  2025.       end
  2026.       # Confirm
  2027.       if Input.trigger?(Input::C)
  2028.         if $game_temp.choice_max > 0
  2029.           $game_system.se_play($data_system.decision_se)
  2030.           $game_temp.choice_proc.call(@index)
  2031.         end
  2032.         if @sub_windows != nil
  2033.           temp = subs_finished?
  2034.           if temp == true
  2035.             @fade_out = true
  2036.             erase_subs
  2037.           end
  2038.         end
  2039.       end
  2040.       return
  2041.     end
  2042.     # If display wait message or choice exists when not fading out
  2043.     if $game_temp.message_text != nil && @finished == nil
  2044.       @contents_showing = true
  2045.       $game_temp.message_window_showing = true
  2046.       @finished = false
  2047.       re_initialize
  2048.       Graphics.frame_reset
  2049.       if @input_number_window != nil
  2050.         @input_number_window.contents_opacity = 0
  2051.       end
  2052.       @fade_in = true
  2053.       return
  2054.     elsif @finished == false
  2055.       refresh
  2056.       return
  2057.     end
  2058.   end
  2059.  
  2060.   def interpreter
  2061.     $scene.is_a?(Scene_Map) ?
  2062.     $game_system.map_interpreter :
  2063.     $game_system.battle_interpreter
  2064.   end
  2065.  
  2066.   def sprite_event(id)
  2067.     sprites = $scene.spriteset.character_sprites
  2068.     event = sprites.select do |s|
  2069.       s.character == interpreter.get_character(id)
  2070.     end
  2071.     return event.first
  2072.   end
  2073.   #--------------------------------------------------------------------------
  2074.   # Create Message Bubble
  2075.   #--------------------------------------------------------------------------
  2076.   # Remember! The bubble will currently display based on the src_rect of
  2077.   # the $character_sprite bitmap...need to work on this...
  2078.  
  2079.   def create_bubble # Text can be multiple lines
  2080.     sprites = $scene.spriteset.character_sprites
  2081.     @event_x = sprite_event(@event).x
  2082.     @event_y = sprite_event(@event).y
  2083.     # Draw bubble bitmap to blt from
  2084.     bubble = Sprite.new
  2085.     if @position.include?('Flipped_Down')
  2086.       @bubble_correction_y = 7
  2087.     else
  2088.       @bubble_correction_y = 0
  2089.     end
  2090.     # Set basic x and y values for bubble drawing
  2091.     # If a face graphic will be drawn
  2092.     if @face != nil
  2093.       # If face graphic drawn outside bubble
  2094.       if $game_system.face_graphic_type == FACE_GRAPHIC_FULL
  2095.         base_y = (@face_extension_y + @text_rect.height) - (@text_rect.height + 20)
  2096.         # If bubble is flipped horizontally
  2097.         if @position.include?('Mirror')
  2098.           base_x = 0
  2099.         else
  2100.           base_x = @face_extension_x
  2101.         end
  2102.         # If bubble is not flipped vertically
  2103.         if not @position.include?('Flipped_Down')
  2104.           base_y -= 6
  2105.         end
  2106.         base_height = @text_rect.height
  2107.         height_extension = @face_extension_y
  2108.         if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  2109.           width_extension = @face_extension_x + 25
  2110.         elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2111.           width_extension = @face_extension_x + 20
  2112.         elsif $game_system.message_text_mode == TEXT_MODE_INVISIBLE
  2113.           width_extension = @face_extension_x + 20
  2114.         end
  2115.       # If face graphic drawn inside bubble
  2116.       else
  2117.         base_x = 0
  2118.         base_y = @bubble_correction_y
  2119.         base_height = @face_extension_y + @text_rect.height
  2120.         if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  2121.           width_extension = 25
  2122.           height_extension = 20 + 6
  2123.         elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2124.           width_extension = 20
  2125.           height_extension = 20
  2126.         elsif $game_system.message_text_mode == TEXT_MODE_INVISIBLE
  2127.           width_extension = 20
  2128.           height_extension = 20
  2129.         end
  2130.       end
  2131.     else
  2132.       base_x = 0
  2133.       base_y = @bubble_correction_y
  2134.       base_height = @text_rect.height
  2135.       if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  2136.         height_extension = 20 + 7
  2137.         width_extension = 25
  2138.       elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2139.         height_extension = 20
  2140.         width_extension = 20
  2141.       elsif $game_system.message_text_mode == TEXT_MODE_INVISIBLE
  2142.         height_extension = 20
  2143.         width_extension = 20
  2144.       end
  2145.     end
  2146.     base_width = @text_rect.width
  2147.    
  2148.     # Set text drawing starting coordinates
  2149.     @text_y = base_y
  2150.    
  2151.     if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  2152.       bubble.bitmap = Bitmap.new("Graphics/Pictures/Message_Bubble")
  2153.     elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2154.       bubble.bitmap = Bitmap.new("Graphics/Windowskins/"+$data_system.windowskin_name)
  2155.     elsif $game_system.message_text_mode == TEXT_MODE_INVISIBLE
  2156.       bubble.bitmap = Bitmap.new(32,32)
  2157.     end
  2158.    
  2159.     # Make the bubble bitmap the appropriate size
  2160.     @message_box = Sprite.new
  2161.        
  2162.     true_width = base_width + width_extension
  2163.     true_height = base_height + height_extension
  2164.     @message_box.bitmap = Bitmap.new(true_width,true_height)
  2165.     @message_box.ox = @message_box.bitmap.width/2
  2166.     @message_box.oy = @message_box.bitmap.height/2
  2167.     @message_box.x = sprite_event(@event).x\
  2168.       + @message_box.bitmap.width/2\
  2169.       + sprite_event(@event).src_rect.width/2 - 15
  2170.     if $game_system.face_graphic_type == FACE_GRAPHIC_FULL
  2171.       @message_box.x -= @face_extension_x
  2172.     end
  2173.     @message_box.y = sprite_event(@event).y\
  2174.       - ((sprite_event(@event).src_rect.height/3)*2)\
  2175.       - @message_box.oy
  2176.     if $game_system.face_graphic_type == FACE_GRAPHIC_FULL \
  2177.       && @position.include?('Flipped_Down')
  2178.       @message_box.y -= @face_extension_y
  2179.     end
  2180.     if @sub == false
  2181.       @message_box.z += 1
  2182.     end
  2183.    
  2184.     # Set rectangles for graphic block transfers
  2185.     if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  2186.       upper_left = BUBBLE_UPPER_LEFT
  2187.       lower_left = BUBBLE_LOWER_LEFT
  2188.       upper_right = BUBBLE_UPPER_RIGHT
  2189.       lower_right = BUBBLE_LOWER_RIGHT
  2190.      
  2191.     elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2192.       background = Rect.new(base_x+1,base_y+1,base_width+20-2,base_height+20-2)
  2193.       source_rect = Rect.new(0,0,128,128)
  2194.       @message_box.bitmap.stretch_blt(background,bubble.bitmap,source_rect)
  2195.       upper_left = SKIN_UPPER_LEFT
  2196.       lower_left = SKIN_LOWER_LEFT
  2197.       upper_right = SKIN_UPPER_RIGHT
  2198.       lower_right = SKIN_LOWER_RIGHT
  2199.     end
  2200.     unless $game_system.message_text_mode == TEXT_MODE_INVISIBLE
  2201.       # Blt the upper left quadrant of the bubble
  2202.       rect = Rect.new(0,0,13,10)    
  2203.       @message_box.bitmap.blt(base_x,base_y,bubble.bitmap,upper_left)
  2204.      
  2205.       # Blt the lower left quadrant of the bubble
  2206.       rect.set(0,10,13,9)
  2207.       y = base_y + base_height + lower_left.height
  2208.       @message_box.bitmap.blt(base_x,y,bubble.bitmap,lower_left)
  2209.      
  2210.       # Blt the upper right quadrant of the bubble
  2211.       rect.set(13,0,12,10)
  2212.       x = base_x + base_width + upper_right.width
  2213.       @message_box.bitmap.blt(x,base_y,bubble.bitmap,upper_right)
  2214.      
  2215.       # Blt the lower right quadrant of the bubble
  2216.       rect.set(13,10,12,9)
  2217.       x = base_x + base_width + lower_right.width
  2218.       y = base_y + base_height + upper_right.height
  2219.       @message_box.bitmap.blt(x,y,bubble.bitmap,lower_right)
  2220.     end
  2221.     if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  2222.       # Fill in the left side gap
  2223.       rect.set(0,8,13,1)    
  2224.       x = base_x
  2225.       y = base_y + upper_left.height
  2226.       rect2 = Rect.new(x,y,13,base_height)
  2227.       @message_box.bitmap.stretch_blt(rect2,bubble.bitmap,rect)
  2228.        
  2229.       # Fill in the right side gap
  2230.       rect.set(13,8,12,1)
  2231.       x = base_x + base_width + upper_right.width
  2232.       y = base_y + upper_right.height
  2233.       rect2 = Rect.new(x,y,13,base_height)
  2234.       @message_box.bitmap.stretch_blt(rect2,bubble.bitmap,rect)
  2235.      
  2236.       # Fill in the middle gap    
  2237.       x = base_x + upper_left.width - 1
  2238.       y = base_y
  2239.       width = base_width
  2240.       height = base_height + upper_left.height + lower_left.height
  2241.       rect.set(x,y,1,height)
  2242.       rect2.set(x,y,base_width,height)
  2243.       @message_box.bitmap.stretch_blt(rect2,@message_box.bitmap,rect)
  2244.    
  2245.       # Place character pointer either below or above bubble
  2246.       if @position.include?('Flipped_Down')
  2247.         if @thought == false
  2248.           rect.set(15,19,10,8)
  2249.         else
  2250.           rect.set(25,8,10,8)
  2251.         end
  2252.         x = base_x + 9
  2253.         y = base_y - @bubble_correction_y
  2254.         @message_box.bitmap.blt(x,y,bubble.bitmap,rect)
  2255.         @message_box.y = sprite_event(@event).y\
  2256.           - ((sprite_event(@event).src_rect.height/3)*2)\
  2257.           + @message_box.oy - @face_extension_y#- (offset_y-@text_rect.height-20)
  2258.       else
  2259.         if @thought == false
  2260.           rect.set(0,19,10,8)
  2261.         else
  2262.           rect.set(25,0,10,8)
  2263.         end
  2264.         x = base_x + 9
  2265.         y = base_y + base_height + 17
  2266.         @message_box.bitmap.blt(x,y,bubble.bitmap,rect)
  2267.       end
  2268.       if @position.include?('Mirror')
  2269.         @message_box.mirror = true
  2270.         @message_box.x = sprite_event(@event).x\
  2271.           - sprite_event(@event).src_rect.width/2\
  2272.           - @message_box.bitmap.width/2 + 15 + base_x #+offset_x
  2273.       end
  2274.     # Fill in rim of a windowskin box
  2275.     elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2276.      
  2277.       # Top rim
  2278.       dest_rect = Rect.new(base_x+10,base_y,base_width,10)
  2279.       source_rect = Rect.new(148,0,24,10)
  2280.       @message_box.bitmap.stretch_blt(dest_rect,bubble.bitmap,source_rect)
  2281.      
  2282.       # Bottom rim
  2283.       dest_rect = Rect.new(base_x+10,base_y+base_height+20-10,base_width,10)
  2284.       source_rect = Rect.new(148,54,24,10)
  2285.       @message_box.bitmap.stretch_blt(dest_rect,bubble.bitmap,source_rect)
  2286.      
  2287.       # Left rim
  2288.       dest_rect = Rect.new(base_x,base_y+10,10,base_height)
  2289.       source_rect = Rect.new(128,10,10,44)
  2290.       @message_box.bitmap.stretch_blt(dest_rect,bubble.bitmap,source_rect)
  2291.      
  2292.       # Right rim
  2293.       dest_rect = Rect.new(base_x+base_width+20-10,base_y+10,10,base_height)
  2294.       source_rect = Rect.new(182,10,10,44)
  2295.       @message_box.bitmap.stretch_blt(dest_rect,bubble.bitmap,source_rect)
  2296.      
  2297.     end
  2298.     # Prepare bubble for up/down animation
  2299.     @up = true
  2300.     @message_box.opacity = 0
  2301.     @fade_in = true
  2302.     # Dispose of the blted bubble
  2303.     bubble.bitmap.dispose
  2304.     bubble = nil
  2305.     @contents_showing = true
  2306.     @active = true
  2307.    
  2308.     if @bubble_color.class == Color
  2309.       @message_box.color = @bubble_color
  2310.     end
  2311.  
  2312.   end
  2313.   #--------------------------------------------------------------------------
  2314.   # * Determine Bubble Position
  2315.   #--------------------------------------------------------------------------
  2316.   def determine_position(no_text=false)
  2317.    
  2318.     sprites = $scene.spriteset.character_sprites
  2319.     @position = ''
  2320.     # Check upper screen boundary
  2321.     temp = @text_rect.height + 25 + sprite_event(@event).src_rect.height
  2322.     if sprite_event(@event).y - temp < 0
  2323.       @position += 'Flipped_Down'
  2324.     end
  2325.     temp = @text_rect.width + 45
  2326.     if sprite_event(@event).x\
  2327.       + sprite_event(@event).src_rect.width/2 + temp > 640
  2328.       @position += 'Mirror'
  2329.     end
  2330.     if no_text == false
  2331.       if @text.slice(/\007\[([0-9]+)\]/)
  2332.         #c = @text.slice(/[0-9]+/).to_i
  2333.         @text.slice!(/\007\[([0-9]+)\]/)
  2334.         c = $1.to_i
  2335.         @position = ''
  2336.         if c == 0
  2337.           @position = ''
  2338.         elsif c == 1
  2339.           @position = 'Flipped_Down'
  2340.         elsif c == 2
  2341.           @position = 'Mirror'
  2342.         elsif c == 3
  2343.           @position = 'Flipped_Down Mirror'
  2344.         end
  2345.       end
  2346.     end
  2347.   end
  2348.   #--------------------------------------------------------------------------
  2349.   # * Bubble Graphic Update
  2350.   #--------------------------------------------------------------------------
  2351.   def update_bubble
  2352.    
  2353.     # Create an easier to use access point to the screen sprites
  2354.     sprites = $scene.spriteset.character_sprites
  2355.    
  2356.     # Bounce bubble
  2357.     if $game_system.message_text_mode == TEXT_MODE_BUBBLE \
  2358.         && $game_system.message_bubble_bounce == BUBBLE_BOUNCE_ON
  2359.      
  2360.       @count += 1
  2361.      
  2362.       if @count % 10 == 0 && @up == true
  2363.         @message_box.y -= 1
  2364.         if @input_number_window != nil
  2365.           @input_number_window.y -= 1
  2366.         end
  2367.         if @cursor != nil
  2368.           @cursor.y -= 1
  2369.         end
  2370.         if @count == 20
  2371.           @count = 0
  2372.           @up = false
  2373.         end
  2374.       elsif @count % 10 == 0 && @up == false
  2375.         @message_box.y += 1
  2376.         if @input_number_window != nil
  2377.           @input_number_window.y += 1
  2378.         end
  2379.         if @cursor != nil
  2380.           @cursor.y += 1
  2381.         end
  2382.         if @count == 20
  2383.           @count = 0
  2384.           @up = true
  2385.         end
  2386.       end
  2387.     end
  2388.        
  2389.     x = @event_x
  2390.     y = @event_y
  2391.    
  2392.     @event_x = sprite_event(@event).x
  2393.     @event_y = sprite_event(@event).y
  2394.    
  2395.     if @event_x != x || @event_y != y
  2396.            
  2397.       if @event_x != x
  2398.         @message_box.x = @message_box.x + (@event_x - x)
  2399.         if @input_number_window != nil
  2400.           @input_number_window.x = @input_number_window.x + (@event_x-x)
  2401.         end
  2402.         if @cursor != nil
  2403.           @cursor.x = @cursor.x + (@event_x - x)
  2404.         end
  2405.       end
  2406.      
  2407.       if @event_y - @face_extension_y != y
  2408.         @message_box.y = @message_box.y + (@event_y - y)
  2409.         if @input_number_window != nil
  2410.           @input_number_window.y = @input_number_window.y + (@event_y-y)
  2411.         end
  2412.         if @cursor != nil
  2413.           @cursor.y = @cursor.y + (@event_y - y)
  2414.         end
  2415.       end
  2416.          
  2417.       change = false
  2418.       # Check upper screen boundary
  2419.       temp = @message_box.y - @message_box.bitmap.height/2
  2420.       if temp < 0 && (@position.include?('Flipped_Down') == false)
  2421.         change = true
  2422.       end
  2423.       # Check lower screen boundary
  2424.       temp = @message_box.y + @message_box.bitmap.height/2
  2425.       if temp > 480
  2426.         change = true
  2427.       end
  2428.       # Check right screen boundary
  2429.       temp = @message_box.x + @message_box.bitmap.width/2
  2430.       if temp > 640
  2431.         change = true
  2432.       end
  2433.       # Check left screen boundary
  2434.       temp = @message_box.x - @message_box.bitmap.width/2
  2435.       if temp < 0
  2436.         change = true
  2437.       end
  2438.      
  2439.       if change == true
  2440.         @message_box.bitmap.clear
  2441.         determine_position(true)
  2442.         create_bubble
  2443.         if @cursor != nil
  2444.           reset_cursor
  2445.         end
  2446.         if @position.include?('Flipped_Down')
  2447.           get_text
  2448.         end
  2449.         @message_box.z -= 1
  2450.       end
  2451.        
  2452.  
  2453.     end
  2454.    
  2455.     @message.y = @message_box.y
  2456.     @message.x = @message_box.x      
  2457.  
  2458.   end
  2459.  
  2460.   #--------------------------------------------------------------------------
  2461.   # * Get Message Text
  2462.   #--------------------------------------------------------------------------
  2463.  
  2464.   def get_text
  2465.    
  2466.     index = $game_system.map_interpreter.index - 1
  2467.     until $game_system.map_interpreter.list[index].code == 101
  2468.       index -= 1
  2469.     end
  2470.     old_text = @text.clone
  2471.     @text = ""
  2472.     @lines.times do
  2473.       if $game_system.map_interpreter.list[index].code == 102 \
  2474.         || $game_system.map_interpreter.list[index].code == 402
  2475.         for i in 0...$game_system.map_interpreter.list[index].parameters.size
  2476.           if $game_system.map_interpreter.list[index].parameters[0][i].class == String
  2477.             @text = @text + $game_system.map_interpreter.list[index].parameters[0][i].clone + "\n"
  2478.           end
  2479.         end
  2480.       else        
  2481.         @text = @text + $game_system.map_interpreter.list[index].parameters[0].clone + "\n"
  2482.       end
  2483.       index += 1
  2484.     end
  2485.    
  2486.     prep_text
  2487.     @message.bitmap.clear
  2488.     @x = 0
  2489.     @x += 10 if $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2490.     @y = 0
  2491.     begin
  2492.       draw_message
  2493.     end until @text == old_text
  2494.   end
  2495.  
  2496.   #--------------------------------------------------------------------------
  2497.   # * Prepare Text for processing
  2498.   #--------------------------------------------------------------------------
  2499.  
  2500.   def prep_text
  2501.     # Determine what event the message will be over
  2502.     if @text.slice!(/\\E?\[(.(\d+)|(\d+))\]/i) == nil
  2503.       @event = 0 # Default to current event
  2504.     else
  2505.       @event = $1.to_i
  2506.     end
  2507.     # Control text processing
  2508.     begin
  2509.       @last_text = @text.clone
  2510.       @text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  2511.     end until @text == @last_text
  2512.     @text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  2513.       $game_actors[$1.to_i] != nil ? "#{$game_actors[$1.to_i].name}:"+"\n" : ""
  2514.     end
  2515.     # Change "\\\\" to "\000" for convenience
  2516.     @text.gsub!(/\\\\/) { "\000" }
  2517.     # Change "\\C" to "\001" and "\\G" to "\002"
  2518.     #   and "\\B" to "\003" and "\\S" to "\004"
  2519.     #   and "\\W" to "\005" and "\\p" to "\006"
  2520.     #   and "\\F" to "\007" and "\\q" to "\011"
  2521.     #   and "\\I" to "\014  and "\\z" to "\015"
  2522.     #   and "\\T" to "\017  and "\\m" to "\018"
  2523.  
  2524.     while @text.slice(/\\[Cc]\[([0-9]+)\]/) != nil
  2525.       @text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  2526.     end
  2527.     @text.gsub!(/\\[Gg]/) { "\002" }
  2528.     @text.gsub!(/\\[Bb]/) { "\003" }
  2529.     @text.gsub!(/\\[Ss]/) { "\004" }
  2530.     while @text.slice(/\\[Ww]\[([0-9]+)\]/) != nil
  2531.       @text.gsub!(/\\[Ww]\[([0-9]+)\]/) { "\005[#{$1}]" }
  2532.     end        
  2533.     while @text.slice(/\\[Pp]/) != nil
  2534.       @text.gsub!(/\\[Pp]/) { "\006" }
  2535.     end
  2536.     while @text.slice(/\\[Ii]/) != nil
  2537.       @text.gsub!(/\\[Ii]\[([0-9A-Za-z_\-]+)\]/) { "\014[#{$1}]" }
  2538.     end
  2539.    # while @text.slice(/\\[Ii]/) != nil
  2540.    #   @text.gsub!(/\\[Ii]\[([0-9]+)\]/) { "\014[#{$1}]" }
  2541.    # end
  2542.     while @text.slice(/\\[Zz]/) != nil
  2543.       # Check for face directory existence
  2544.       if File.directory? Dir::getwd + "/Graphics/Faces/"
  2545.         @text.slice(/\\[Zz]\[([0-9]+)\]/)
  2546.         # Check for file existence
  2547.         if Faces[$1.to_i] != nil
  2548.           @text.gsub!(/\\[Zz]\[([0-9]+)\]/) { "\015[#{$1}]" }
  2549.         else
  2550.           @text.gsub!(/\\[Zz]\[([0-9]+)\]/) { "" }
  2551.         end
  2552.       else
  2553.         @text.gsub!(/\\[Zz]\[([0-9]+)\]/) { "" }
  2554.       end
  2555.     end
  2556.     while @text.slice(/\\[Hh]/) != nil
  2557.       @text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\016[#{$1}]" }
  2558.     end
  2559.     @text.gsub!(/\\[Ff]/) { "\007" }
  2560.     @text.gsub!(/\\[Qq]/) { "\011" }
  2561.     @text.gsub!(/\\[Tt]/) { "\017" }
  2562.     while @text.slice(/\\[Mm]\[([0-9]+)]/)
  2563.       @text.gsub!(/\\[Mm]\[([0-9]+)]/) { "\018[#{$1}]" }
  2564.     end
  2565.     @text.slice!(/\\[Nn][Cc]/)
  2566.   end
  2567.   #--------------------------------------------------------------------------
  2568.   # * Create cursor graphic
  2569.   #--------------------------------------------------------------------------
  2570.   def create_cursor
  2571.    
  2572.     if $game_system.message_text_mode == TEXT_MODE_BUBBLE or
  2573.       $game_system.message_text_mode == TEXT_MODE_INVISIBLE
  2574.       @cursor = Sprite.new
  2575.       @cursor.bitmap = Bitmap.new("Graphics/Pictures/Pointer2")
  2576.       @cursor.ox = @cursor.bitmap.width
  2577.       if $separate_choices == false
  2578.         indent = @message.bitmap.text_size("    ").width
  2579.       else
  2580.         indent = @message.bitmap.text_size("    ").width
  2581.       end
  2582.      
  2583.     elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2584.       template = Sprite.new
  2585.       template.opacity = 0
  2586.       template.bitmap = Bitmap.new("Graphics/Windowskins/"+$data_system.windowskin_name)
  2587.       source_rect = Rect.new(128,64,32,32)
  2588.       # Set width of the cursor rectangle
  2589.       width = @line_width[@lines-$game_temp.choice_max+@index]
  2590.       # Correct for added spaces in choices following main text
  2591.       width -= @message.bitmap.text_size('     ').width if @indent == true
  2592.       dest_rect = Rect.new(0,0,width,@text_height)
  2593.       if @cursor == nil
  2594.         @cursor = Sprite.new
  2595.       else
  2596.         @cursor.bitmap.clear
  2597.         @cursor.bitmap.dispose
  2598.       end
  2599.       @cursor.opacity = 255
  2600.       @cursor.bitmap = Bitmap.new(width,@text_height)
  2601.       # Upper left
  2602.       source_rect = Rect.new(128,64,3,3)
  2603.       @cursor.bitmap.blt(0,0,template.bitmap,source_rect)
  2604.       # Upper right
  2605.       source_rect = Rect.new(157,64,3,3)
  2606.       @cursor.bitmap.blt(width-3,0,template.bitmap,source_rect)
  2607.       # Lower left
  2608.       source_rect = Rect.new(128,93,3,3)
  2609.       @cursor.bitmap.blt(0,@text_height-3,template.bitmap,source_rect)
  2610.       # Lower right
  2611.       source_rect = Rect.new(157,93,3,3)
  2612.       @cursor.bitmap.blt(width-3,@text_height-3,template.bitmap,source_rect)
  2613.       # Top fill in
  2614.       source_rect = Rect.new(131,64,26,3)
  2615.       dest_rect = Rect.new(3,0,width-6,3)
  2616.       @cursor.bitmap.stretch_blt(dest_rect,template.bitmap,source_rect)
  2617.       # Bottom fill in
  2618.       source_rect = Rect.new(131,93,26,3)
  2619.       dest_rect = Rect.new(3,@text_height-3,width-6,3)
  2620.       @cursor.bitmap.stretch_blt(dest_rect,template.bitmap,source_rect)
  2621.       # Left fill in
  2622.       source_rect = Rect.new(128,67,3,@text_height-6)
  2623.       dest_rect = Rect.new(0,3,3,@text_height-6)
  2624.       @cursor.bitmap.stretch_blt(dest_rect,template.bitmap,source_rect)
  2625.       # Right fill in
  2626.       source_rect = Rect.new(157,67,3,@text_height-6)
  2627.       dest_rect = Rect.new(width-3,3,3,@text_height-6)
  2628.       @cursor.bitmap.stretch_blt(dest_rect,template.bitmap,source_rect)
  2629.       # Center fill in
  2630.       source_rect = Rect.new(131,67,26,26)
  2631.       dest_rect = Rect.new(3,3,width-6,@text_height-6)
  2632.       @cursor.bitmap.stretch_blt(dest_rect,template.bitmap,source_rect)
  2633.      
  2634.       @cursor.ox = 0
  2635.       template.bitmap.clear
  2636.       template = nil
  2637.       indent = @message.bitmap.text_size("  ").width
  2638.     end
  2639.     return if @cursor.nil?
  2640.       @cursor.oy = @cursor.bitmap.height/2
  2641.      
  2642.       if @indent == true
  2643.         @cursor.x = @message.x - @message.ox + 14 + @face_extension_x + indent
  2644.       else
  2645.         @cursor.x = @message.x - @message.ox + @face_extension_x + indent
  2646.       end
  2647.  
  2648.       y_correction = 0
  2649.       @line_height_correction.each { |number|
  2650.           y_correction += number
  2651.       }
  2652.      
  2653.       @cursor.y = @message.y - @message.oy + @bubble_correction_y \
  2654.         + 10 + @text_height/2 + ((@lines-$game_temp.choice_max+@index)*@text_height)\
  2655.         + y_correction
  2656.       @cursor.z += 5
  2657.       # More accurately place windowskin rectangle
  2658.       if $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2659.         @cursor.y -= 1
  2660.       end
  2661.       # Correct for bad sizing of bitmap draw_text method
  2662.       if $game_system.message_text_size == TEXT_SIZE_LARGE
  2663.         @cursor.y -= 2
  2664.       elsif
  2665.         $game_system.message_text_size == TEXT_SIZE_JUMBO
  2666.         @cursor.y -= 6
  2667.       end
  2668.    
  2669.   end  
  2670.   #--------------------------------------------------------------------------
  2671.   # * Reset cursor graphic
  2672.   #--------------------------------------------------------------------------
  2673.  
  2674.   def reset_cursor
  2675.    
  2676.     @cursor.x = @message_box.x - @message_box.ox + 16
  2677.     @cursor.y = @message_box.y - @message_box.oy\
  2678.       + ((@lines-$game_temp.choice_max + 1)*@text_height)\
  2679.       + @bubble_correction_y
  2680.   end
  2681.  
  2682.   #--------------------------------------------------------------------------
  2683.   # * Update cursor graphic
  2684.   #--------------------------------------------------------------------------
  2685.   def update_cursor
  2686.     if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  2687.       modulus = 10
  2688.     elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2689.       modulus = 3
  2690.     else
  2691.       modulus = 6
  2692.     end
  2693.     return if @cursor.nil?
  2694.     @cursor_count += 1
  2695.     if @cursor_count % modulus  == 0 && @cursor_move_right == true
  2696.       if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  2697.         @cursor.x += 1
  2698.       elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2699.         @cursor.opacity -= 10
  2700.       end
  2701.       if @cursor_count == modulus * 5
  2702.         @cursor_count = 0
  2703.         @cursor_move_right = false
  2704.       end
  2705.      
  2706.     elsif @cursor_count % modulus == 0 && @cursor_move_right == false
  2707.       if $game_system.message_text_mode == TEXT_MODE_BUBBLE
  2708.         @cursor.x -= 1
  2709.       elsif $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2710.         @cursor.opacity += 10
  2711.       end
  2712.      if @cursor_count == modulus * 5
  2713.         @cursor_count = 0
  2714.         @cursor_move_right = true
  2715.       end
  2716.     end
  2717.    
  2718.     if Input.trigger?(Input::UP)
  2719.       if @index != 0
  2720.         @cursor.y -= @text_height
  2721.         @index -= 1
  2722.       else
  2723.         @cursor.y += @text_height * ($game_temp.choice_max-1)
  2724.         @index = $game_temp.choice_max-1
  2725.       end
  2726.       if $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2727.         create_cursor
  2728.       end
  2729.     elsif Input.trigger?(Input::DOWN)
  2730.       if @index != $game_temp.choice_max-1
  2731.         @cursor.y += @text_height
  2732.         @index += 1
  2733.       else
  2734.         @cursor.y -= @text_height * ($game_temp.choice_max-1)
  2735.         @index = 0
  2736.       end
  2737.       if $game_system.message_text_mode == TEXT_MODE_WINDOWSKIN
  2738.         create_cursor
  2739.       end
  2740.     end
  2741.   end  
  2742.  
  2743. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement