Advertisement
LiTTleDRAgo

[RGSS] Multiple Message Windows 1.5 (Un-SDK, BlizzABS edit)

Aug 20th, 2016
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 71.20 KB | None | 0 0
  1. #==============================================================================
  2. # ** Multiple Message Windows 1.5
  3. #------------------------------------------------------------------------------
  4. # Originally written by Wachunga
  5. # Optimized and De-SDK'ed by ForeverZer0
  6. # Ex Version by LiTTleDRAgo
  7. # 2006-11-17
  8. #==============================================================================
  9. =begin
  10.  
  11. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  12.  
  13. - Credit for the original script is 100% Wachunga. Original map and events
  14.   are also Wachunga's original.
  15.  
  16. - Edits have been made by ForeverZer0 to eliminate the SDK requirement
  17.   and improve coding and performance
  18. - I have added a compatibility switch for Blizzard's simple shaded text if you
  19.   are you using that, because it doesn't look right with message text. The
  20.   switch will disable it whenever a message is showing, but otherwise will
  21.   shade everything else.
  22. - This script must be placed below Blizzard's Tons-of-Add-ons if you are
  23.   using it. If you don't you will get an error. It has something to do with
  24.   the Lagless HUD script. Some bug I couldn't isolate... If you find it, let
  25.   me know, else just keep it under Tons.
  26.  
  27. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  28.  
  29.   This custom message system adds numerous features on top of the default
  30.   message system, the most notable being the ability to have multiple message
  31.   windows open at once. The included features are mostly themed around turning
  32.   messages into speech (and thought) balloons, but default-style messages are
  33.   of course still possible.
  34.  
  35.   Note:
  36.   This version of the script uses the SDK, available from:
  37.   http://www.rmxp.org/forums/showthread.php?t=1802
  38.  
  39.   FEATURES
  40.  
  41.   New in 1.5:
  42.   * \C[#ffffff] for hexadecimal color
  43.   * \C for return to default color
  44.   * display name of item, weapon, armor or skill
  45.     * \N[In] = display name of item with id n (note the "I")
  46.     * \N[Wn] = display name of weapon with id n (note the "W")
  47.     * \N[An] = display name of armor with id n (note the "A")
  48.     * \N[Sn] = display name of skill with id n (note the "S")
  49.   * display icon of item, weapon, armor or skill
  50.     * \I[In] = display icon of item with id n (note the "I")
  51.     * \I[Wn] = display icon of weapon with id n (note the "W")
  52.     * \I[An] = display icon of armor with id n (note the "A")
  53.     * \I[Sn] = display icon of skill with id n (note the "S")
  54.   * display icon and name of item, weapon, armor or skill
  55.     * \I&N[In] = display icon and name of item with id n (note the "I")
  56.     * \I&N[Wn] = display icon and name of weapon with id n (note the "W")
  57.     * \I&N[An] = display icon and name of armor with id n (note the "A")
  58.     * \I&N[Sn] = display icon and name of skill with id n (note the "S")
  59.   * new windowskins available
  60.   * speech windowskin now definable separately from default windowskin
  61.   * fixed bold bug where degree sign would occasionally appear
  62.   * input number window now shares parent window's font
  63.   * changed \Var[n] back to default of \V[n]
  64.  
  65.   New in 1.1:
  66.   * message.autocenter for automatically centering text within messages
  67.   * \N[en] for displaying name of enemy with id n (note the "e")
  68.   * \MAP for displaying the name of the current map
  69.  
  70.   At a glance:
  71.   * multiple message windows
  72.   * speech balloons
  73.     * position over player/event (follows movement and scrolling)
  74.     * optional message tail (for speech or thought balloons)
  75.     * can specify location relative to player/event (up, down, left, right)
  76.   * thought balloons
  77.     * can use different windowskin, message tail and font color
  78.   * letter-by-letter mode
  79.     * variable speed (and delays)
  80.     * skippable on button press
  81.   * autoresize messages
  82.   * player movement allowed during messages
  83.     * if speaker moves offscreen, message closes (like ChronoTrigger)
  84.   * everything also works during battle
  85.   * settings configurable at anytime  
  86.  
  87.   Full list of options:
  88.  
  89.   (Note that all are case *insensitive*.)
  90.  
  91.   =============================================================================
  92.    Local (specified in message itself and resets at message end)
  93.   =============================================================================
  94.   - \L = letter-by-letter mode toggle
  95.   - \S[n] = set speed at which text appears in letter-by-letter mode
  96.   - \D[n] = set delay (in frames) before next text appears
  97.   - \P[n] = position message over event with id n
  98.             * use n=0 for player
  99.             * in battle, use n=a,b,c,d for actors (e.g. \P[a] for first actor)
  100.               and n=1,...,n for enemies (e.g. \P[1] for first enemy)
  101.               where order is actually the reverse of troop order (in database)
  102.   - \P = position message over current event (default for floating messages)
  103.   - \^ = message appears directly over its event
  104.   - \v = message appears directly below its event
  105.   - \< = message appears directly to the left of its event
  106.   - \> = message appears directly to the right of its event
  107.   - \B = bold text
  108.   - \I = italic text
  109.   - \C[#xxxxxx] = change to color specified by hexadecimal (eg. ffffff = white)
  110.   - \C = change color back to default
  111.   - \! = message autoclose
  112.   - \? = wait for user input before continuing
  113.   - \+ = make message appear at same time as preceding one
  114.          * note: must be at the start of message to work
  115.   - \@ = thought balloon
  116.   - \N[En] = display name of enemy with id n (note the "E")
  117.   - \N[In] = display name of item with id n (note the "I")
  118.   - \N[Wn] = display name of weapon with id n (note the "W")
  119.   - \N[An] = display name of armor with id n (note the "A")
  120.   - \N[Sn] = display name of skill with id n (note the "S")
  121.   - \I[In] = display icon of item with id n (note the "I")
  122.   - \I[Wn] = display icon of weapon with id n (note the "W")
  123.   - \I[An] = display icon of armor with id n (note the "A")
  124.   - \I[Sn] = display icon of skill with id n (note the "S")
  125.   - \I&N[In] = display icon and name of item with id n (note the "I")
  126.   - \I&N[Wn] = display icon and name of weapon with id n (note the "W")
  127.   - \I&N[An] = display icon and name of armor with id n (note the "A")
  128.   - \I&N[Sn] = display icon and name of skill with id n (note the "S")
  129.   - \MAP = display the name of the current map
  130.  
  131.   These are, of course, in addition to the default options:
  132.   - \V[n] = display value of variable n
  133.   - \N[n] = display name of actor with id n
  134.   - \C[n] = change color to n
  135.   - \G = display gold window
  136.   - \\ = show the '\' character
  137.  
  138.   =============================================================================
  139.    Global (specified below or by Call Script and persist until changed)
  140.   =============================================================================
  141.  
  142.   Zer0 Note:
  143.   If you use any of these in another script, etc. and not a script call, you
  144.   will need to place "$game_system." before each command.
  145.  
  146.   Miscellaneous:
  147.   - message.move_during = true/false
  148.     * allow/disallow player to move during messages
  149.   - message.show_pause = true/false
  150.     * show/hide "waiting for player" pause graphic
  151.   - message.autocenter = true/false
  152.     * enable/disable automatically centering text within messages
  153.  
  154.   Speech/thought balloon related:
  155.   - message.resize = true/false
  156.     * enable/disable automatic resizing of messages (only as big as necessary)
  157.   - message.floating = true/false
  158.     * enable/disable positioning messages above current event by default
  159.       (i.e. equivalent to including \P in every message)
  160.   - message.location = TOP, BOTTOM, LEFT or RIGHT
  161.     * set default location for floating messages relative to their event
  162.   - message.show_tail = true/false
  163.     * show/hide message tail for speech/thought balloons
  164.  
  165.   Letter-by-letter related:
  166.   - message.letter_by_letter = true/false
  167.     * enable/disable letter-by-letter mode (globally)
  168.   - message.text_speed = 0-20
  169.     * set speed at which text appears in letter-by-letter mode (globally)
  170.   - message.skippable = true/false
  171.     * allow/disallow player to skip to end of message with button press
  172.  
  173.   Font:
  174.   - message.font_name = font
  175.     * set font to use for text, overriding all defaults
  176.       (font can be any TrueType from Windows/Fonts folder)
  177.   - message.font_size = size
  178.     * set size of text  (default 22), overriding all defaults
  179.   - message.font_color = color
  180.     * set color of text, overriding all defaults
  181.     * you can use same 0-7 as for \C[n] or "#xxxxxx" for hexadecimal
  182.  
  183.   Note that the default thought and shout balloon windowskins don't
  184.   stretch to four lines very well (unfortunately).
  185.    
  186.   Thanks:
  187.   XRXS code for self-close and wait for input
  188.   Slipknot for a convenient approach to altering settings in-game
  189.   SephirothSpawn for bitmap rotate method
  190.  
  191. =end
  192.  
  193. #==============================================================================
  194. # Settings
  195. #==============================================================================
  196.  
  197.   # Zer0 Edit. Blizzard's Simple Shaded Text just looks kinda funny when used
  198.   # on black text (which is default for MMS). If you are using Shaded Text and
  199.   # do not want it to display for the message windows, set this to true. It will
  200.   # still show for everything else.
  201.  
  202.   Blizzard_Shaded_Text_Fix = true
  203.  
  204.   #----------------------------------------------------------------------------
  205.   # Windowskins
  206.   #----------------------------------------------------------------------------
  207.   # Note: all files must be in the Graphics/Windowskins/ folder
  208.   # Tip: tails don't look right on windowskins with gradient backgrounds
  209.  
  210.   # filenames of tail and windowskin used for speech balloons
  211.   FILENAME_SPEECH_TAIL = 'white-tail_speech.png'
  212.   FILENAME_SPEECH_WINDOWSKIN = 'white-windowskin_speech.png'
  213.  
  214.   # filenames of tail and windowskin used for thought balloons
  215.   FILENAME_THOUGHT_TAIL = 'white-tail_thought.png'
  216.   FILENAME_THOUGHT_WINDOWSKIN = 'white-windowskin_thought.png'
  217.  
  218.   #----------------------------------------------------------------------------
  219.   # Fonts
  220.   #----------------------------------------------------------------------------
  221.   # Note: if floating or resize (i.e. 'speech balloons') are disabled,
  222.   # Font.default_name, Font.default_size and Font.default_color are used
  223.   # (you can change these in Main)
  224.   # During gameplay, you can use message.font_name etc to override all defaults
  225.  
  226.   # defaults for speech text
  227.   SPEECH_FONT_COLOR = "#000000"
  228.   SPEECH_FONT_NAME = ['Comic Sans MS', 'Arial']
  229.   SPEECH_FONT_SIZE = 20
  230.  
  231.   # defaults for thought text
  232.   THOUGHT_FONT_COLOR = "#000000"
  233.   THOUGHT_FONT_NAME = ['Comic Sans MS', 'Arial']
  234.   THOUGHT_FONT_SIZE = 20
  235.  
  236.   # note that you can use an array of fonts for SPEECH_FONT_NAME, etc.
  237.   # e.g. ['Verdana', 'MS PGothic']
  238.   # (if Verdana is not available, MS PGothic will be used instead)
  239.  
  240.   #----------------------------------------------------------------------------
  241.   # Misc
  242.   #----------------------------------------------------------------------------
  243.   # If using a specialty windowskin (e.g. the default thought balloon one),
  244.   # you can force the window width to always be a multiple of the number
  245.   # specified in this constant (even when using the resize feature).
  246.   # This allows, for example, the windowskin frame to be designed to
  247.   # repeat every 16 pixels so that the frame never looks cut off.
  248.   THOUGHT_WIDTH_MULTIPLE = 16
  249.   # (set to 0 if you're not using any such windowskins)
  250.  
  251. class Game_Message
  252.  
  253.   # Any of the below can be changed by a Call Script event during gameplay.
  254.   # E.g. turn letter-by-letter mode off with: message.letter_by_letter = false
  255.  
  256.   attr_accessor :move_during
  257.   attr_accessor :letter_by_letter
  258.   attr_accessor :text_speed
  259.   attr_accessor :skippable
  260.   attr_accessor :resize
  261.   attr_accessor :floating
  262.   attr_accessor :autocenter
  263.   attr_accessor :show_tail
  264.   attr_accessor :show_pause
  265.   attr_accessor :location
  266.   attr_accessor :font_name
  267.   attr_accessor :font_size
  268.   attr_accessor :font_color
  269.  
  270.   def initialize
  271.     # whether or not messages appear one letter at a time
  272.     @letter_by_letter = true
  273.     # note: can also change within a single message with \L
  274.  
  275.     # the default speed at which text appears in letter-by-letter mode
  276.     @text_speed = 0
  277.     # note: can also change within a single message with \S[n]
  278.    
  279.     # whether or not players can skip to the end of (letter-by-letter) messages
  280.     @skippable = true
  281.    
  282.     # whether or not messages are automatically resized based on the message
  283.     @resize = true
  284.    
  285.     # whether or not message windows are positioned above
  286.     # characters/events by default, i.e. without needing \P every message
  287.     # (only works if resize messages enabled -- otherwise would look very odd)
  288.     @floating = true
  289.    
  290.     # whether or not to automatically center lines within the message
  291.     @autocenter = true
  292.    
  293.     # whether or not event-positioned messages have a tail(for speech balloons)
  294.     # (only works if floating and resized messages enabled -- otherwise would
  295.     # look very odd indeed)
  296.     @show_tail = true
  297.    
  298.     # whether or not to display "waiting for user input" pause graphic
  299.     # (probably want this disabled for speech balloons)
  300.     @show_pause = false
  301.  
  302.     # whether the player is permitted to move while messages are displayed
  303.     @move_during = true
  304.    
  305.     # the default location for floating messages (relative to the event)
  306.     # note that an off-screen message will be "flipped" automatically
  307.     @location = TOP
  308.    
  309.     # font details
  310.     # overrides all defaults; leave nil to just use defaults (e.g. as above)
  311.     @font_name = nil
  312.     @font_size = nil
  313.     @font_color = nil
  314.   end
  315. end
  316.  
  317. #==============================================================================
  318. # Private constants (don't edit)
  319. #==============================================================================
  320.  
  321.   # used for message.location
  322.   TOP = 8
  323.   BOTTOM = 2
  324.   LEFT = 4
  325.   RIGHT = 6
  326.  
  327. #------------------------------------------------------------------------------
  328.  
  329. class Window_Message < Window_Selectable
  330.  
  331.   def initialize(msgindex=0)
  332.     super(80, 304, 480, 160)
  333.     self.contents = Bitmap.new(width - 32, height - 32)
  334.     self.visible = false
  335.     #------------------------------------------------------------------------------
  336.     # Begin Multiple Message Windows Edit
  337.     #------------------------------------------------------------------------------
  338.     self.z = 9000 + msgindex * 5 # permits messages to overlap legibly
  339.     #------------------------------------------------------------------------------
  340.     # End Multiple Message Windows Edit
  341.     #------------------------------------------------------------------------------
  342.     @fade_in = false
  343.     @fade_out = false
  344.     @contents_showing = false
  345.     @cursor_width = 0
  346.     self.active = false
  347.     self.index = -1
  348.     #------------------------------------------------------------------------------
  349.     # Begin Multiple Message Windows Edit
  350.     #------------------------------------------------------------------------------
  351.     @msgindex = msgindex
  352.     @tail = Sprite.new
  353.     @tail.bitmap =
  354.       if @msgindex == 0
  355.         RPG::Cache.windowskin(FILENAME_SPEECH_TAIL)
  356.       else
  357.         # don't use cached version or else all tails
  358.         # are rotated when multiple are visible at once
  359.         Bitmap.new('Graphics/Windowskins/'+FILENAME_SPEECH_TAIL)
  360.       end
  361.     # keep track of orientation of tail bitmap
  362.     if @tail.bitmap.orientation == nil
  363.       @tail.bitmap.orientation = 0
  364.     end
  365.     # make origin the center, not top left corner
  366.     @tail.ox = @tail.bitmap.width/2
  367.     @tail.oy = @tail.bitmap.height/2
  368.     @tail.z = 9999
  369.     @tail.visible = false
  370.     if $game_system.message.floating && $game_system.message.resize
  371.       @windowskin = FILENAME_SPEECH_WINDOWSKIN
  372.     else
  373.       # use windowskin specified in database
  374.       @windowskin = $game_system.windowskin_name
  375.     end
  376.     if $game_system.message.floating && $game_system.message.resize
  377.       # if used as speech balloons, use constants
  378.       @font_name = SPEECH_FONT_NAME
  379.       @font_color = check_color(SPEECH_FONT_COLOR)
  380.       @font_size = SPEECH_FONT_SIZE
  381.     else
  382.       # use defaults
  383.       @font_name = Font.default_name
  384.       @font_color = Font.default_color
  385.       @font_size = Font.default_size
  386.     end
  387.     # override defaults if necessary
  388.     if $game_system.message.font_name != nil
  389.       @font_name = $game_system.message.font_name
  390.     end
  391.     if $game_system.message.font_color != nil
  392.       @font_color = check_color($game_system.message.font_color)
  393.     end
  394.     if $game_system.message.font_size != nil
  395.       @font_size = $game_system.message.font_size
  396.     end
  397.     @update_text = true
  398.     @letter_by_letter = $game_system.message.letter_by_letter
  399.     @text_speed = $game_system.message.text_speed
  400.     # id of character for speech balloons
  401.     @float_id = nil
  402.     # location of box relative to speaker
  403.     @location = $game_system.message.location
  404.     #------------------------------------------------------------------------------
  405.     # End Multiple Message Windows Edit
  406.     #------------------------------------------------------------------------------
  407.   end
  408.  
  409.   def dispose
  410.     terminate_message
  411.     #------------------------------------------------------------------------------
  412.     # Begin Multiple Message Windows Edit
  413.     #------------------------------------------------------------------------------
  414.     # have to check all windows before claiming that no window is showing
  415.     if $game_temp.message_text.compact.empty?
  416.     #------------------------------------------------------------------------------
  417.     # End Multiple Message Windows Edit
  418.     #------------------------------------------------------------------------------
  419.       $game_temp.message_window_showing = false
  420.     #------------------------------------------------------------------------------
  421.     # Begin Multiple Message Windows Edit
  422.     #------------------------------------------------------------------------------
  423.     end
  424.     #------------------------------------------------------------------------------
  425.     # End Multiple Message Windows Edit
  426.     #------------------------------------------------------------------------------
  427.     if @input_number_window != nil
  428.       @input_number_window.dispose
  429.     end
  430.     super
  431.   end
  432.  
  433.   def terminate_message
  434.     self.active = false
  435.     self.pause = false
  436.     self.index = -1
  437.     self.contents.clear
  438.     # Clear showing flag
  439.     @contents_showing = false
  440.  
  441.     # Clear variables related to text, choices, and number input
  442.     #------------------------------------------------------------------------------
  443.     # Begin Multiple Message Windows Edit
  444.     #------------------------------------------------------------------------------
  445.     @tail.visible = false
  446.     # note that these variables are now indexed arrays
  447.     $game_temp.message_text[@msgindex] = nil
  448.     # Call message callback
  449.     if $game_temp.message_proc[@msgindex] != nil
  450.       # make sure no message boxes are displaying
  451.       if $game_temp.message_text.compact.empty?
  452.         $game_temp.message_proc[@msgindex].call
  453.       end
  454.       $game_temp.message_proc[@msgindex] = nil
  455.     end
  456.     @update_text = true
  457.     #------------------------------------------------------------------------------
  458.     # End Multiple Message Windows Edit
  459.     #------------------------------------------------------------------------------
  460.     $game_temp.choice_start = 99
  461.     $game_temp.choice_max = 0
  462.     $game_temp.choice_cancel_type = 0
  463.     $game_temp.choice_proc = nil
  464.     $game_temp.num_input_start = 99
  465.     $game_temp.num_input_variable_id = 0
  466.     $game_temp.num_input_digits_max = 0
  467.     # Open gold window
  468.     if @gold_window != nil
  469.       @gold_window.dispose
  470.       @gold_window = nil
  471.     end
  472.   end
  473.  
  474.   def refresh
  475.     self.contents.clear
  476.     #------------------------------------------------------------------------------
  477.     # Begin Multiple Message Windows Edit
  478.     #------------------------------------------------------------------------------
  479.     @x = @y = 0 # now instance variables
  480.     @float_id = nil
  481.     @location = $game_system.message.location
  482.     if $game_system.message.floating && $game_system.message.resize
  483.       @windowskin = FILENAME_SPEECH_WINDOWSKIN
  484.     else
  485.       # use windowskin specified in database
  486.       @windowskin = $game_system.windowskin_name
  487.     end
  488.     if $game_system.message.floating && $game_system.message.resize
  489.       # if used as speech balloons, use constants
  490.       @font_name = SPEECH_FONT_NAME
  491.       @font_color = check_color(SPEECH_FONT_COLOR)
  492.       @font_size = SPEECH_FONT_SIZE
  493.     else
  494.       # use default font
  495.       @font_name = Font.default_name
  496.       @font_color = Font.default_color
  497.       @font_size = Font.default_size
  498.     end
  499.     # override font defaults
  500.     if $game_system.message.font_name != nil
  501.       @font_name = $game_system.message.font_name
  502.     end
  503.     if $game_system.message.font_color != nil
  504.       @font_color = check_color($game_system.message.font_color)
  505.     end
  506.     if $game_system.message.font_size != nil
  507.       @font_size = $game_system.message.font_size
  508.     end
  509.     @line_widths = nil
  510.     @wait_for_input = false
  511.     @tail.bitmap =
  512.       if @msgindex == 0
  513.         RPG::Cache.windowskin(FILENAME_SPEECH_TAIL)
  514.       else
  515.         Bitmap.new('Graphics/Windowskins/'+FILENAME_SPEECH_TAIL)
  516.       end
  517.     RPG::Cache.windowskin(FILENAME_SPEECH_TAIL)
  518.     @tail.bitmap.orientation = 0 if @tail.bitmap.orientation == nil
  519.     @text_speed = $game_system.message.text_speed
  520.     @letter_by_letter = $game_system.message.letter_by_letter
  521.     @delay = @text_speed
  522.     @player_skip = false
  523.     #------------------------------------------------------------------------------
  524.     # End Multiple Message Windows Edit
  525.     #------------------------------------------------------------------------------
  526.     @cursor_width = 0
  527.     # Indent if choice
  528.     if $game_temp.choice_start == 0
  529.       @x = 8
  530.     end
  531.     # If waiting for a message to be displayed
  532.     #------------------------------------------------------------------------------
  533.     # Begin Multiple Message Windows Edit
  534.     #------------------------------------------------------------------------------
  535.     if $game_temp.message_text[@msgindex] != nil
  536.       @text = $game_temp.message_text[@msgindex] # now an instance variable
  537.     #------------------------------------------------------------------------------
  538.     # End Multiple Message Windows Edit
  539.     #------------------------------------------------------------------------------
  540.       # Control text processing
  541.       begin
  542.         last_text = @text.clone
  543.         @text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  544.       end until @text == last_text
  545.       @text.gsub!(/\\[Nn]\[([0-9]+)\]/) {
  546.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ''
  547.       }
  548.       # Change "\\\\" to "\000" for convenience
  549.       @text.gsub!(/\\\\/) { "\000" }
  550.       @text.gsub!(/\\[Gg]/) { "\002" }
  551.     #------------------------------------------------------------------------------
  552.     # Begin Multiple Message Windows Edit
  553.     #------------------------------------------------------------------------------
  554.       # display icon of item, weapon, armor or skill
  555.       @text.gsub!(/\\[Ii]\[([IiWwAaSs][0-9]+)\]/) { "\013[#{$1}]" }
  556.       # display name of enemy, item, weapon, armor or skill
  557.       @text.gsub!(/\\[Nn]\[([EeIiWwAaSs])([0-9]+)\]/) {
  558.         case $1.downcase
  559.           when 'e'
  560.             entity = $data_enemies[$2.to_i]
  561.           when 'i'
  562.             entity = $data_items[$2.to_i]
  563.           when 'w'
  564.             entity = $data_weapons[$2.to_i]
  565.           when 'a'
  566.             entity = $data_armors[$2.to_i]
  567.           when 's'
  568.             entity = $data_skills[$2.to_i]
  569.         end
  570.         entity != nil ? entity.name : ''
  571.       }
  572.       # display icon and name of item, weapon, armor or skill
  573.       @text.gsub!(/\\[Ii]&[Nn]\[([IiWwAaSs])([0-9]+)\]/) {
  574.         case $1.downcase
  575.           when 'e'
  576.             entity = $data_enemies[$2.to_i]
  577.           when 'i'
  578.             entity = $data_items[$2.to_i]
  579.           when 'w'
  580.             entity = $data_weapons[$2.to_i]
  581.           when 'a'
  582.             entity = $data_armors[$2.to_i]
  583.           when 's'
  584.             entity = $data_skills[$2.to_i]
  585.         end
  586.         entity != nil ? "\013[#{$1+$2}] " + entity.name : ''
  587.       }      
  588.       # display name of current map
  589.       @text.gsub!(/\\[Mm][Aa][Pp]/) { $game_map.name }
  590.       # change font color
  591.       @text.gsub!(/\\[Cc]\[([0-9]+|#[0-9A-Fa-f]{6,6})\]/) { "\001[#{$1}]" }
  592.       # return to default color
  593.       @text.gsub!(/\\[Cc]/) { "\001" }
  594.       # toggle letter-by-letter mode
  595.       @text.gsub!(/\\[Ll]/) { "\003" }
  596.       # change text speed (for letter-by-letter)
  597.       @text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\004[#{$1}]" }
  598.       # insert delay
  599.       @text.gsub!(/\\[Dd]\[([0-9]+)\]/) { "\005[#{$1}]" }
  600.       # self close message
  601.       @text.gsub!(/\\[!]/) { "\006" }
  602.       # wait for button input
  603.       @text.gsub!(/\\[?]/) { "\007" }
  604.       # bold
  605.       @text.gsub!(/\\[Bb]/) { "\010" }
  606.       # italic
  607.       @text.gsub!(/\\[Ii]/) { "\011" }
  608.       # thought balloon
  609.       if @text.gsub!(/\\[@]/, '') != nil
  610.         @windowskin = FILENAME_THOUGHT_WINDOWSKIN
  611.         @font_name = THOUGHT_FONT_NAME
  612.         @font_size = THOUGHT_FONT_SIZE
  613.         @font_color = check_color(THOUGHT_FONT_COLOR)
  614.         @tail.bitmap =
  615.           if @msgindex == 0
  616.             RPG::Cache.windowskin(FILENAME_THOUGHT_TAIL)
  617.           else
  618.             Bitmap.new('Graphics/Windowskins/'+FILENAME_THOUGHT_TAIL)
  619.           end
  620.         @tail.bitmap.orientation = 0 if @tail.bitmap.orientation == nil
  621.       end
  622.       # Get rid of "\\+" (multiple messages)
  623.       @text.gsub!(/\\[+]/, '')
  624.       # Get rid of "\\^", "\\v", "\\<", "\\>" (relative message location)
  625.       if @text.gsub!(/\\\^/, '') != nil
  626.         @location = 8
  627.       elsif @text.gsub!(/\\[Vv]/, '') != nil
  628.         @location = 2
  629.       elsif @text.gsub!(/\\[<]/, '') != nil
  630.         @location = 4
  631.       elsif @text.gsub!(/\\[>]/, '') != nil
  632.         @location = 6
  633.       end
  634.       # Get rid of "\\P" (position window to given character)
  635.       if @text.gsub!(/\\[Pp]\[([0-9]+)\]/, '') != nil
  636.         @float_id = $1.to_i
  637.       elsif @text.gsub!(/\\[Pp]\[([a-zA-Z])\]/, '') != nil &&
  638.           $game_temp.in_battle
  639.         @float_id = $1.downcase
  640.       elsif @text.gsub!(/\\[Pp]/, '') != nil ||
  641.         ($game_system.message.floating && $game_system.message.resize) &&
  642.         !$game_temp.in_battle
  643.         @float_id = $game_system.map_interpreter.event_id
  644.       end
  645.       if $game_system.message.resize || $game_system.message.autocenter
  646.         # calculate length of lines
  647.         text = @text.clone
  648.         temp_bitmap = Bitmap.new(1,1)
  649.         temp_bitmap.font.name = @font_name
  650.         temp_bitmap.font.size = @font_size
  651.         @line_widths = [0,0,0,0]
  652.         (0..3).each  do |i|
  653.           line = text.split(/\n/)[3-i]
  654.           if line == nil
  655.             next
  656.           end
  657.           line.gsub!(/[\001-\007](\[[#A-Fa-f0-9]+\])?/, '')
  658.           line.gsub!(/\013\[[IiWwAaSs][0-9]+\]/, "\013")
  659.           line.chomp.split(//).each do |c|
  660.             case c
  661.               when "\000"
  662.                 c = "\\"
  663.               when "\010"
  664.                 # bold
  665.                 temp_bitmap.font.bold = !temp_bitmap.font.bold
  666.                 next
  667.               when "\011"
  668.                 # italics
  669.                 temp_bitmap.font.italic = !temp_bitmap.font.italic
  670.                 next
  671.               when "\013"
  672.                 # icon
  673.                 @line_widths[3-i] += 24
  674.                 next
  675.             end
  676.             @line_widths[3-i] += temp_bitmap.text_size(c).width
  677.           end
  678.           if (3-i) >= $game_temp.choice_start
  679.             # account for indenting
  680.             @line_widths[3-i] += 8 unless $game_system.message.autocenter
  681.           end
  682.         end
  683.         if $game_temp.num_input_variable_id > 0
  684.           # determine cursor_width as in Window_InputNumber
  685.           # (can't get from @input_number_window because it doesn't exist yet)
  686.           cursor_width = temp_bitmap.text_size('0').width + 8
  687.           # use this width to calculate line width (+8 for indent)
  688.           input_number_width = cursor_width*$game_temp.num_input_digits_max
  689.           input_number_width += 8 unless $game_system.message.autocenter
  690.           @line_widths[$game_temp.num_input_start] = input_number_width
  691.         end
  692.         temp_bitmap.dispose
  693.       end
  694.       resize
  695.       reposition if @float_id != nil
  696.       self.contents.font.name = @font_name
  697.       self.contents.font.size = @font_size
  698.       self.contents.font.color = @font_color
  699.       self.windowskin = RPG::Cache.windowskin(@windowskin)
  700.       # autocenter first line if enabled
  701.       # (subsequent lines are done as "\n" is encountered)
  702.       if $game_system.message.autocenter && @text != ''
  703.         @x = (self.width-40)/2 - @line_widths[0]/2
  704.       end
  705.     #------------------------------------------------------------------------------
  706.     # End Multiple Message Windows Edit
  707.     #------------------------------------------------------------------------------
  708.     end
  709.   end
  710.  
  711.   #--------------------------------------------------------------------------
  712.   # * Resize Window
  713.   #--------------------------------------------------------------------------
  714.   def resize
  715.     if !$game_system.message.resize
  716.       # reset to defaults
  717.       self.width = 480
  718.       self.height = 160
  719.       self.contents = Bitmap.new(width - 32, height - 32)
  720.       self.x = 80 # undo any centering
  721.       return
  722.     end
  723.     max_x = @line_widths.max
  724.     max_y = 4
  725.     @line_widths.each {|line| max_y -= 1 if line == 0 && max_y > 1}
  726.     if $game_temp.choice_max  > 0
  727.       # account for indenting
  728.       max_x += 8 unless $game_system.message.autocenter
  729.     end
  730.     new_width = max_x + 40
  731.     if @windowskin == FILENAME_THOUGHT_WINDOWSKIN && THOUGHT_WIDTH_MULTIPLE >0
  732.       # force window width to be a multiple of THOUGHT_WIDTH_MULTIPLE
  733.       # so that specialty windowskins (e.g. thought balloon) look right
  734.       if new_width % THOUGHT_WIDTH_MULTIPLE != 0
  735.         new_width += THOUGHT_WIDTH_MULTIPLE-(new_width%THOUGHT_WIDTH_MULTIPLE)
  736.       end
  737.     end
  738.     self.width = new_width
  739.     self.height = max_y * 32 + 32
  740.     self.contents = Bitmap.new(width - 32, height - 32)
  741.     self.x = 320 - (self.width/2) # center
  742.   end
  743.  
  744.   #--------------------------------------------------------------------------
  745.   # * Reposition Window
  746.   #--------------------------------------------------------------------------
  747.   def reposition
  748.     if $game_temp.in_battle
  749.       if 'abcd'.include?(@float_id) # must be between a and d
  750.         @float_id = @float_id[0] - 97 # a = 0, b = 1, c = 2, d = 3
  751.         return if $scene.spriteset.actor_sprites[@float_id] == nil
  752.         sprite = $scene.spriteset.actor_sprites[@float_id]
  753.       else
  754.         @float_id -= 1 # account for, e.g., player entering 1 for index 0
  755.         return if $scene.spriteset.enemy_sprites[@float_id] == nil
  756.         sprite = $scene.spriteset.enemy_sprites[@float_id]
  757.       end
  758.       char_height = sprite.height
  759.       char_width = sprite.width
  760.       char_x = sprite.x
  761.       char_y = sprite.y - char_height/2
  762.     else # not in battle...
  763.       char = (@float_id == 0 ? $game_player : $game_map.events[@float_id])
  764.       if char == nil
  765.         # no such character
  766.         @float_id = nil
  767.         return
  768.       end
  769.       # close message (and stop event processing) if speaker is off-screen
  770.       if char.screen_x <= 0 || char.screen_x >= 640 ||
  771.          char.screen_y <= 0 || char.screen_y > 480
  772.         terminate_message
  773.         $game_system.map_interpreter.command_115
  774.         return
  775.       end
  776.       char_height = RPG::Cache.character(char.character_name,0).height / 4
  777.       char_width = RPG::Cache.character(char.character_name,0).width / 4
  778.       # record coords of character's center
  779.       char_x = char.screen_x
  780.       char_y = char.screen_y - char_height/2
  781.     end
  782.     params = [char_height, char_width, char_x, char_y]
  783.     # position window and message tail
  784.     vars = new_position(params)
  785.     x = vars[0]
  786.     y = vars[1]
  787.     # check if any window locations need to be "flipped"
  788.     if @location == 4 && x < 0
  789.       # switch to right
  790.       @location = 6
  791.       vars = new_position(params)
  792.       x = vars[0]
  793.       if (x + self.width) > 640
  794.         # right is no good either...
  795.         if y >= 0
  796.           # switch to top
  797.           @location = 8
  798.           vars = new_position(params)
  799.         else
  800.           # switch to bottom
  801.           @location = 2
  802.           vars = new_position(params)
  803.         end
  804.       end
  805.     elsif @location == 6 && (x + self.width) > 640
  806.       # switch to left
  807.       @location = 4
  808.       vars = new_position(params)
  809.       x = vars[0]
  810.       if x < 0
  811.         # left is no good either...
  812.         if y >= 0
  813.           # switch to top
  814.           @location = 8
  815.           vars = new_position(params)
  816.         else
  817.           # switch to bottom
  818.           @location = 2
  819.           vars = new_position(params)
  820.         end
  821.       end
  822.     elsif @location == 8 && y < 0
  823.       # switch to bottom
  824.       @location = 2
  825.       vars = new_position(params)
  826.       y = vars[1]
  827.       if (y + self.height) > 480
  828.         # bottom is no good either...
  829.         # note: this will probably never occur given only 3 lines of text
  830.         x = vars[0]
  831.         if x >= 0
  832.           # switch to left
  833.           @location = 4
  834.           vars = new_position(params)
  835.         else
  836.           # switch to right
  837.           @location = 6
  838.           vars = new_position(params)
  839.         end
  840.       end
  841.     elsif @location == 2 && (y + self.height) > 480
  842.       # switch to top
  843.       @location = 8
  844.       vars = new_position(params)
  845.       y = vars[1]
  846.       if y < 0
  847.         # top is no good either...
  848.         # note: this will probably never occur given only 3 lines of text
  849.         x = vars[0]
  850.         if x >= 0
  851.           # switch to left
  852.           @location = 4
  853.           vars = new_position(params)
  854.         else
  855.           # switch to right
  856.           @location = 6
  857.           vars = new_position(params)
  858.         end
  859.       end
  860.     end
  861.     x = vars[0]
  862.     y = vars[1]
  863.     tail_x = vars[2]
  864.     tail_y = vars[3]    
  865.     # adjust windows if near edge of screen
  866.     if x < 0
  867.       x = 0
  868.     elsif (x + self.width) > 640
  869.       x = 640 - self.width
  870.     end
  871.     if y < 0
  872.       y = 0
  873.     elsif (y + self.height) > 480
  874.       y = 480 - self.height
  875.     elsif $game_temp.in_battle && @location == 2 && (y > (320 - self.height))
  876.       # when in battle, prevent enemy messages from overlapping battle status
  877.       # (note that it could still happen from actor messages, though)
  878.       y = 320 - self.height
  879.       tail_y = y
  880.     end
  881.     # finalize positions
  882.     self.x = x
  883.     self.y = y
  884.     @tail.x = tail_x
  885.     @tail.y = tail_y
  886.   end
  887.  
  888.   #--------------------------------------------------------------------------
  889.   # * Determine New Window Position
  890.   #--------------------------------------------------------------------------  
  891.   def new_position(params)
  892.     char_height = params[0]
  893.     char_width = params[1]
  894.     char_x = params[2]
  895.     char_y = params[3]
  896.     if @location == 8
  897.       # top
  898.       x = char_x - self.width/2
  899.       y = char_y - char_height/2 - self.height - @tail.bitmap.height/2
  900.       @tail.bitmap.rotation(0)
  901.       tail_x = x + self.width/2
  902.       tail_y = y + self.height
  903.     elsif @location == 2
  904.       # bottom
  905.       x = char_x - self.width/2
  906.       y = char_y + char_height/2 + @tail.bitmap.height/2
  907.       @tail.bitmap.rotation(180)
  908.       tail_x = x + self.width/2
  909.       tail_y = y
  910.     elsif @location == 4
  911.       # left
  912.       x = char_x - char_width/2 - self.width - @tail.bitmap.width/2
  913.       y = char_y - self.height/2
  914.       @tail.bitmap.rotation(270)
  915.       tail_x = x + self.width
  916.       tail_y = y + self.height/2
  917.     elsif @location == 6
  918.       # right
  919.       x = char_x + char_width/2 + @tail.bitmap.width/2
  920.       y = char_y - self.height/2
  921.       @tail.bitmap.rotation(90)
  922.       tail_x = x
  923.       tail_y = y + self.height/2
  924.     end
  925.     return [x,y,tail_x,tail_y]
  926.   end
  927.      
  928.   #--------------------------------------------------------------------------
  929.   # * Update Text
  930.   #--------------------------------------------------------------------------  
  931.   def update_text
  932.     if @text != nil
  933.       # Get 1 text character in c (loop until unable to get text)
  934.       while ((c = @text.slice!(/./m)) != nil)
  935.         # If \\
  936.         if c == "\000"
  937.           # Return to original text
  938.           c = "\\"
  939.         end
  940.         # If \C[n] or \C[#xxxxxx] or \C
  941.         if c == "\001"
  942.           # Change text color
  943.           @text.sub!(/\[([0-9]+|#[0-9A-Fa-f]{6,6})\]/, '')
  944.           if $1 != nil
  945.             self.contents.font.color = check_color($1)
  946.           else
  947.             # return to default color
  948.             if $game_system.message.font_color != nil
  949.               color = check_color($game_system.message.font_color)
  950.             elsif $game_system.message.floating && $game_system.message.resize
  951.               color = check_color(SPEECH_FONT_COLOR)
  952.             else
  953.               # use defaults
  954.               color = Font.default_color
  955.             end
  956.             self.contents.font.color = color
  957.           end
  958.           # go to next text
  959.           next
  960.         end
  961.         # If \G
  962.         if c == "\002"
  963.           # Make gold window
  964.           if @gold_window == nil
  965.             @gold_window = Window_Gold.new
  966.             @gold_window.x = 560 - @gold_window.width
  967.             if $game_temp.in_battle
  968.               @gold_window.y = 192
  969.             else
  970.               @gold_window.y = self.y >= 128 ? 32 : 384
  971.             end
  972.             @gold_window.opacity = self.opacity
  973.             @gold_window.back_opacity = self.back_opacity
  974.           end
  975.           # go to next text
  976.           next
  977.         end
  978.         # If \L
  979.         if c == "\003"
  980.           # toggle letter-by-letter mode
  981.           @letter_by_letter = !@letter_by_letter
  982.           # go to next text
  983.           next
  984.         end
  985.         # If \S[n]
  986.         if c == "\004"
  987.           @text.sub!(/\[([0-9]+)\]/, '')
  988.           speed = $1.to_i
  989.           if speed >= 0
  990.             @text_speed = speed
  991.             # reset player skip after text speed change
  992.             @player_skip = false            
  993.           end
  994.           return
  995.         end
  996.         # If \D[n]
  997.         if c == "\005"
  998.           @text.sub!(/\[([0-9]+)\]/, '')
  999.           delay = $1.to_i
  1000.           if delay >= 0
  1001.             @delay += delay
  1002.             # reset player skip after delay
  1003.             @player_skip = false
  1004.           end
  1005.           return
  1006.         end  
  1007.         # If \!
  1008.         if c == "\006"
  1009.           # close message and return from method
  1010.           terminate_message
  1011.           return
  1012.         end
  1013.         # If \?
  1014.         if c == "\007"
  1015.           @wait_for_input = true
  1016.           return
  1017.         end
  1018.         if c == "\010"
  1019.           # bold
  1020.           self.contents.font.bold = !self.contents.font.bold
  1021.           return
  1022.         end
  1023.         if c == "\011"
  1024.           # italics
  1025.           self.contents.font.italic = !self.contents.font.italic
  1026.           return
  1027.         end
  1028.         if c == "\013"
  1029.           # display icon of item, weapon, armor or skill
  1030.           @text.sub!(/\[([IiWwAaSs])([0-9]+)\]/, '')
  1031.           case $1.downcase
  1032.             when 'i'
  1033.               item = $data_items[$2.to_i]
  1034.             when 'w'
  1035.               item = $data_weapons[$2.to_i]
  1036.             when 'a'
  1037.               item = $data_armors[$2.to_i]
  1038.             when 's'
  1039.               item = $data_skills[$2.to_i]
  1040.           end
  1041.           if item == nil
  1042.             return
  1043.           end
  1044.           bitmap = RPG::Cache.icon(item.icon_name)
  1045.           self.contents.blt(4+@x, 32*@y+4, bitmap, Rect.new(0, 0, 24, 24))
  1046.           @x += 24
  1047.           #self.contents.draw_text(x + 28, y, 212, 32, item.name)
  1048.           return
  1049.         end
  1050.         # If new line text
  1051.         if c == "\n"
  1052.           # Update cursor width if choice
  1053.           if @y >= $game_temp.choice_start
  1054.             width = $game_system.message.autocenter ? @line_widths[@y]+8 : @x
  1055.             @cursor_width = [@cursor_width, width].max
  1056.           end
  1057.           # Add 1 to y
  1058.           @y += 1
  1059.           if $game_system.message.autocenter && @text != ''
  1060.             @x = (self.width-40)/2 - @line_widths[@y]/2
  1061.           else
  1062.             @x = 0
  1063.             # Indent if choice
  1064.             if @y >= $game_temp.choice_start
  1065.               @x = 8
  1066.             end
  1067.           end
  1068.           # go to next text
  1069.           next
  1070.         end
  1071.         # Draw text
  1072.         self.contents.draw_text(4 + @x, 32 * @y, 40, 32, c)
  1073.         # Add x to drawn text width
  1074.         @x += self.contents.text_size( c ).width
  1075.         # add text speed to time to display next character
  1076.         @delay += @text_speed unless !@letter_by_letter || @player_skip
  1077.         return if @letter_by_letter && !@player_skip
  1078.       end
  1079.     end
  1080.     # If choice
  1081.     if $game_temp.choice_max > 0
  1082.       @item_max = $game_temp.choice_max
  1083.       self.active = true
  1084.       self.index = 0
  1085.     end
  1086.     # If number input
  1087.     if $game_temp.num_input_variable_id > 0
  1088.       digits_max = $game_temp.num_input_digits_max
  1089.       number = $game_variables[$game_temp.num_input_variable_id]
  1090.       @input_number_window = Window_InputNumber.new(digits_max)
  1091.       @input_number_window.set_font(@font_name, @font_size, @font_color)
  1092.       @input_number_window.number = number
  1093.       @input_number_window.x =
  1094.         if $game_system.message.autocenter
  1095.           offset = (self.width-40)/2-@line_widths[$game_temp.num_input_start]/2
  1096.           self.x + offset + 4
  1097.         else
  1098.           self.x + 8
  1099.         end
  1100.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  1101.     end
  1102.     @update_text = false
  1103.   end
  1104.  
  1105.   def reset_window
  1106.     if $game_temp.in_battle
  1107.       self.y = 16
  1108.     else
  1109.       case $game_system.message_position
  1110.       when 0  # up
  1111.         self.y = 16
  1112.       when 1  # middle
  1113.         self.y = 160
  1114.       when 2  # down
  1115.         self.y = 304
  1116.       end
  1117.     end
  1118.     if $game_system.message_frame == 0
  1119.       self.opacity = 255
  1120.     else
  1121.       self.opacity = 0
  1122.     end
  1123. #------------------------------------------------------------------------------
  1124. # Begin Multiple Message Windows Edit
  1125. #------------------------------------------------------------------------------
  1126.     # transparent speech balloons don't look right, so keep opacity at 255
  1127.     # self.back_opacity = 160
  1128.     @tail.opacity = 255
  1129. #------------------------------------------------------------------------------
  1130. # End Multiple Message Windows Edit
  1131. #------------------------------------------------------------------------------
  1132.   end
  1133.  
  1134.   def update
  1135.     super
  1136.     # If fade in
  1137.     if @fade_in
  1138.       self.contents_opacity += 24
  1139.       if @input_number_window != nil
  1140.         @input_number_window.contents_opacity += 24
  1141.       end
  1142.       if self.contents_opacity == 255
  1143.         @fade_in = false
  1144.       end
  1145. #------------------------------------------------------------------------------
  1146. # Begin Multiple Message Windows Edit
  1147. #------------------------------------------------------------------------------
  1148.       # return
  1149. #------------------------------------------------------------------------------
  1150. # End Multiple Message Windows Edit
  1151. #------------------------------------------------------------------------------
  1152.     end
  1153.     # If inputting number
  1154.     if @input_number_window != nil
  1155.       @input_number_window.update
  1156.       # Confirm
  1157.       if Input.trigger?(Input::C)
  1158.         $game_system.se_play($data_system.decision_se)
  1159.         $game_variables[$game_temp.num_input_variable_id] =
  1160.           @input_number_window.number
  1161.         $game_map.need_refresh = true
  1162.         # Dispose of number input window
  1163.         @input_number_window.dispose
  1164.         @input_number_window = nil
  1165.         terminate_message
  1166.       end
  1167.       return
  1168.     end
  1169.     # If message is being displayed
  1170.     if @contents_showing
  1171.     #------------------------------------------------------------------------------
  1172.     # Begin Multiple Message Windows Edit
  1173.     #------------------------------------------------------------------------------
  1174.       # Confirm or cancel finishes waiting for input or message
  1175.       if Input.trigger?(Input::C) || Input.trigger?(Input::B)
  1176.         if @wait_for_input
  1177.           @wait_for_input = false
  1178.           self.pause = false
  1179.         elsif $game_system.message.skippable
  1180.           @player_skip = true
  1181.         end
  1182.       end
  1183.       if need_reposition?
  1184.         reposition # update message position for character/screen movement
  1185.         if @contents_showing == false
  1186.           # i.e. if char moved off screen
  1187.           return
  1188.         end
  1189.       end
  1190.       if @update_text && !@wait_for_input
  1191.         if @delay == 0
  1192.           update_text
  1193.         else
  1194.           @delay -= 1
  1195.         end
  1196.         return
  1197.       end
  1198.  
  1199.       # If choice isn't being displayed, show pause sign
  1200.       if !self.pause && ($game_temp.choice_max == 0 || @wait_for_input)
  1201.         self.pause = true unless !$game_system.message.show_pause
  1202.       end
  1203. #------------------------------------------------------------------------------
  1204. # End Multiple Message Windows Edit
  1205. #------------------------------------------------------------------------------
  1206.       # Cancel
  1207.       if Input.trigger?(Input::B)
  1208.         if $game_temp.choice_max > 0 && $game_temp.choice_cancel_type > 0
  1209.           $game_system.se_play($data_system.cancel_se)
  1210.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  1211.           terminate_message
  1212.         end
  1213. #------------------------------------------------------------------------------
  1214. # Begin Multiple Message Windows Edit
  1215. #------------------------------------------------------------------------------
  1216.         # personal preference: cancel button should also continue
  1217.         terminate_message
  1218. #------------------------------------------------------------------------------
  1219. # End Multiple Message Windows Edit
  1220. #------------------------------------------------------------------------------
  1221.       end
  1222.       # Confirm
  1223.       if Input.trigger?(Input::C)
  1224.         if $game_temp.choice_max > 0
  1225.           $game_system.se_play($data_system.decision_se)
  1226.           $game_temp.choice_proc.call(self.index)
  1227.         end
  1228.         terminate_message
  1229.       end
  1230.       return
  1231.     end
  1232.     # If display wait message or choice exists when not fading out
  1233.     if @fade_out == false && $game_temp.message_text[@msgindex] != nil
  1234.       @contents_showing = true
  1235.       $game_temp.message_window_showing = true
  1236.       reset_window
  1237.       refresh
  1238.       Graphics.frame_reset
  1239.       self.visible = true
  1240. #------------------------------------------------------------------------------
  1241. # Begin Multiple Message Windows Edit
  1242. #------------------------------------------------------------------------------
  1243.       if show_message_tail?
  1244.         @tail.visible = true
  1245.       elsif @tail.visible
  1246.         @tail.visible = false
  1247.       end
  1248. #------------------------------------------------------------------------------
  1249. # End Multiple Message Windows Edit
  1250. #------------------------------------------------------------------------------
  1251.       self.contents_opacity = 0
  1252.       if @input_number_window != nil
  1253.         @input_number_window.contents_opacity = 0
  1254.       end
  1255.       @fade_in = true
  1256.       return
  1257.     end
  1258.     # If message which should be displayed is not shown, but window is visible
  1259.     if self.visible
  1260.       @fade_out = true
  1261.       self.opacity -= 96
  1262. #------------------------------------------------------------------------------
  1263. # Begin Multiple Message Windows Edit
  1264. #------------------------------------------------------------------------------
  1265.       @tail.opacity -= 96 if @tail.opacity > 0
  1266.       if need_reposition?
  1267.         reposition # update message position for character/screen movement
  1268.       end
  1269. #------------------------------------------------------------------------------
  1270. # End Multiple Message Windows Edit
  1271. #------------------------------------------------------------------------------
  1272.       if self.opacity == 0
  1273.         self.visible = false
  1274.         @fade_out = false
  1275. #------------------------------------------------------------------------------
  1276. # Begin Multiple Message Windows Edit
  1277. #------------------------------------------------------------------------------
  1278.         @tail.visible = false if @tail.visible
  1279.         # have to check all windows before claiming that no window is showing
  1280.         if $game_temp.message_text.compact.empty?
  1281. #------------------------------------------------------------------------------
  1282. # End Multiple Message Windows Edit
  1283. #------------------------------------------------------------------------------
  1284.           $game_temp.message_window_showing = false  
  1285. #------------------------------------------------------------------------------
  1286. # Begin Multiple Message Windows Edit
  1287. #------------------------------------------------------------------------------
  1288.         end
  1289. #------------------------------------------------------------------------------
  1290. # End Multiple Message Windows Edit
  1291. #------------------------------------------------------------------------------
  1292.       end
  1293.       return
  1294.     end
  1295.   end
  1296.  
  1297.   #--------------------------------------------------------------------------
  1298.   # * Repositioning Determination
  1299.   #--------------------------------------------------------------------------
  1300.   def need_reposition?
  1301.     if !$game_temp.in_battle && $game_system.message.floating &&
  1302.         $game_system.message.resize && @float_id != nil
  1303.       if $game_system.message.move_during && @float_id == 0 &&
  1304.           (($game_player.last_real_x != $game_player.real_x) ||
  1305.           ($game_player.last_real_y != $game_player.real_y))
  1306.           # player with floating message moved
  1307.           # (note that relying on moving? leads to "jumpy" message boxes)
  1308.           return true
  1309.       elsif ($game_map.last_display_y != $game_map.display_y) ||
  1310.          ($game_map.last_display_x != $game_map.display_x)
  1311.         # player movement or scroll event caused the screen to scroll
  1312.         return true
  1313.       else
  1314.         char = $game_map.events[@float_id]
  1315.         if char != nil &&
  1316.           ((char.last_real_x != char.real_x) ||
  1317.           (char.last_real_y != char.real_y))
  1318.           # character moved
  1319.           return true
  1320.         end
  1321.       end    
  1322.     end
  1323.     return false
  1324.   end
  1325.  
  1326.   #--------------------------------------------------------------------------
  1327.   # * Show Message Tail Determination
  1328.   #--------------------------------------------------------------------------
  1329.   def show_message_tail?
  1330.     if $game_system.message.show_tail && $game_system.message.floating &&
  1331.       $game_system.message.resize && $game_system.message_frame == 0 &&
  1332.       @float_id != nil
  1333.       return true
  1334.     end
  1335.     return false
  1336.   end
  1337.  
  1338.   def update_cursor_rect
  1339.     if @index >= 0
  1340.       n = $game_temp.choice_start + @index
  1341. #------------------------------------------------------------------------------
  1342. # Begin Multiple Message Windows Edit
  1343. #------------------------------------------------------------------------------
  1344.       if $game_system.message.autocenter
  1345.         x = 4 + (self.width-40)/2 - @cursor_width/2
  1346.       else
  1347.         x = 8
  1348.       end
  1349.       self.cursor_rect.set(x, n * 32, @cursor_width, 32)
  1350. #------------------------------------------------------------------------------
  1351. # End Multiple Message Windows Edit
  1352. #------------------------------------------------------------------------------
  1353.     else
  1354.       self.cursor_rect.empty
  1355.     end
  1356.   end
  1357.  
  1358. end
  1359.  
  1360. #------------------------------------------------------------------------------
  1361.  
  1362. class Game_Character
  1363.   attr_reader   :last_real_x                   # last map x-coordinate
  1364.   attr_reader   :last_real_y                   # last map y-coordinate
  1365.   alias wachunga_game_char_update update
  1366.   def update
  1367.     @last_real_x = @real_x
  1368.     @last_real_y = @real_y
  1369.     wachunga_game_char_update
  1370.   end
  1371. end
  1372.  
  1373. #------------------------------------------------------------------------------
  1374.  
  1375. class Game_Temp
  1376.   alias wachunga_mmw_game_temp_initialize initialize
  1377.   def initialize
  1378.     wachunga_mmw_game_temp_initialize
  1379.     @message_text = []
  1380.     @message_proc = []
  1381.   end
  1382. end
  1383.  
  1384. #------------------------------------------------------------------------------
  1385.  
  1386. class Sprite_Battler < RPG::Sprite
  1387.   # necessary for positioning messages relative to battlers
  1388.   attr_reader :height
  1389.   attr_reader :width
  1390. end
  1391.  
  1392. #------------------------------------------------------------------------------
  1393.  
  1394. class Scene_Battle
  1395.   # necessary for accessing actor/enemy sprites in battle
  1396.   attr_reader :spriteset
  1397. end
  1398.  
  1399. #------------------------------------------------------------------------------
  1400.  
  1401. class Spriteset_Battle
  1402.   # necessary for accessing actor/enemy sprites in battle
  1403.   attr_reader :actor_sprites
  1404.   attr_reader :enemy_sprites
  1405. end
  1406.  
  1407. #------------------------------------------------------------------------------
  1408.  
  1409.  
  1410. #------------------------------------------------------------------------------
  1411.  
  1412. module MMW_Method
  1413.  
  1414.   attr_reader :multi_message_window
  1415.  
  1416.   def update_multi_message
  1417.     @multi_message_window = [@message_window] unless @multi_message_window
  1418.     @multi_message_window.each {|mw| mw.disposed? || mw.update}
  1419.   end
  1420.  
  1421.   def dispose_multi_message
  1422.     @multi_message_window.each {|mw| mw.disposed? || mw.dispose}
  1423.   end
  1424.  
  1425.   #--------------------------------------------------------------------------
  1426.   # * New Message Window Addition
  1427.   #--------------------------------------------------------------------------
  1428.   def new_message_window(index)
  1429.     if @multi_message_window[index] != nil
  1430.       # clear message windows at and after this index
  1431.       last_index = @multi_message_window.size - 1
  1432.       last_index.downto(index) { |i|
  1433.         if @multi_message_window[i] != nil
  1434.           @multi_message_window[i].dispose
  1435.           @multi_message_window[i] = nil
  1436.         end
  1437.       }
  1438.       @multi_message_window.compact!
  1439.     end
  1440.     @multi_message_window.push(Window_Message.new(index))
  1441.   end
  1442. end
  1443.  
  1444.  
  1445. class Scene_Map
  1446.  
  1447.  
  1448.   include MMW_Method
  1449.   alias drg128_upd update unless method_defined?(:drg128_upd)    
  1450.   alias drg128_main main unless method_defined?(:drg128_main)
  1451.   #--------------------------------------------------------------------------
  1452.   # * drg152_main
  1453.   #--------------------------------------------------------------------------
  1454.   def main
  1455.     drg128_main
  1456.     dispose_multi_message
  1457.   end
  1458.  
  1459.   def update
  1460.     update_multi_message
  1461.     drg128_upd
  1462.   end
  1463.    
  1464.  
  1465. end
  1466.  
  1467.  
  1468. class Scene_Battle
  1469.  
  1470.   include MMW_Method
  1471.   alias drg128_upd update unless method_defined?(:drg128_upd)    
  1472.   alias drg128_main main unless method_defined?(:drg128_main)
  1473.   #--------------------------------------------------------------------------
  1474.   # * drg152_main
  1475.   #--------------------------------------------------------------------------
  1476.   def main
  1477.     drg128_main
  1478.     dispose_multi_message
  1479.   end
  1480.  
  1481.   def update
  1482.     update_multi_message
  1483.     drg128_upd
  1484.   end
  1485.    
  1486.  
  1487.  
  1488. end
  1489.  
  1490. #------------------------------------------------------------------------------
  1491.  
  1492. class Game_System
  1493.  
  1494.   def message
  1495.     @message ||= Game_Message.new
  1496.   end
  1497.  
  1498.   # Zer0 Edit
  1499.   alias zer0_shaded_text_fix_upd update
  1500.   def update
  1501.     message
  1502.     zer0_shaded_text_fix_upd
  1503.     if @SHADED_TEXT != nil && Blizzard_Shaded_Text_Fix == true
  1504.       if $game_temp.message_window_showing
  1505.         @SHADED_TEXT = false
  1506.       else
  1507.         @SHADED_TEXT = true
  1508.       end
  1509.     end
  1510.   end
  1511.   #--------------------------------------------------------------------------
  1512.   # Can Move?
  1513.   #--------------------------------------------------------------------------
  1514.   def blizzabs_can_move?(type=0)
  1515.     player = $BlizzABS.actors[0]
  1516.     message_showing = $game_temp.message_window_showing
  1517.     interpreter = $game_system.map_interpreter.running?
  1518.     return type == 0 ? (((player.ai.act.defend? && player.attacked == 0) ||
  1519.           $game_system.turn_button && Input.press?(Input::Turn)) &&
  1520.           !player.moving? && !player.move_route_forcing &&
  1521.           (!interpreter || message_showing) &&
  1522.           (!message_showing || $game_system.message.move_during) &&
  1523.           $game_temp.choice_max <= 0 && $game_temp.num_input_digits_max <= 0) :
  1524.           (player.move_route_forcing ||  (interpreter && !message_showing) ||
  1525.           (message_showing && !$game_system.message.move_during) ||
  1526.           ($game_temp.choice_max > 0 || $game_temp.num_input_digits_max > 0))
  1527.   end
  1528. end
  1529.  
  1530. #------------------------------------------------------------------------------
  1531.  
  1532. class Game_Player < Game_Character   # Zer0 edit
  1533.  
  1534.   #--------------------------------------------------------------------------
  1535.   # * Frame Update
  1536.   #--------------------------------------------------------------------------
  1537.   alias drg128_upd update
  1538.   def update
  1539.     update_mmw_moving
  1540.     drg128_upd
  1541.   end
  1542.  
  1543.   #--------------------------------------------------------------------------
  1544.   # * update_mmw_moving
  1545.   #--------------------------------------------------------------------------
  1546.   def update_mmw_moving
  1547.     message_showing = $game_temp.message_window_showing
  1548.     unless moving? || @move_route_forcing ||
  1549.       ($game_system.map_interpreter.running? && !message_showing) ||
  1550.       (message_showing && !$game_system.message.move_during) ||
  1551.       ($game_temp.choice_max > 0 || $game_temp.num_input_digits_max > 0)
  1552.       if (input = Input.dir4)
  1553.         case input
  1554.         when 2 then move_down
  1555.         when 4 then move_left
  1556.         when 6 then move_right
  1557.         when 8 then move_up
  1558.         end
  1559.       end
  1560.     end
  1561.   end
  1562.   #--------------------------------------------------------------------------
  1563.   # * Touch Event Starting Determinant
  1564.   #--------------------------------------------------------------------------
  1565.   # This is a fix if Blizzard's Optimized default scripts are being used
  1566.  
  1567.   def check_event_trigger_touch(x, y)
  1568.     result = false                         # <--------- MOVED from....
  1569.     # If event is running
  1570.     if $game_system.map_interpreter.running?
  1571.       return result
  1572.     end
  1573.     #result = false                        # <--------- ...HERE
  1574.     # All event loops
  1575.     $game_map.events.each_value {|event|
  1576.       # If event coordinates and triggers are consistent
  1577.       if event.x == x && event.y == y && [1,2].include?(event.trigger)
  1578.         # If starting determinant is front event (other than jumping)
  1579.         if !event.jumping? && !event.over_trigger?
  1580.           event.start
  1581.           result = true
  1582.         end
  1583.       end
  1584.     }
  1585.     return result
  1586.   end
  1587.  
  1588. end
  1589.  
  1590.  
  1591.  
  1592. #==============================================================================
  1593. # ** Interpreter
  1594. #------------------------------------------------------------------------------
  1595. #  This interpreter runs event commands. This class is used within the
  1596. #  Game_System class and the Game_Event class.
  1597. #==============================================================================
  1598. class Interpreter
  1599.   attr_reader :event_id
  1600.   #--------------------------------------------------------------------------
  1601.   # * Constant
  1602.   #--------------------------------------------------------------------------
  1603.   SCRIPT_WAIT_RESULTS = [:wait, FalseClass]
  1604.   #--------------------------------------------------------------------------
  1605.   # * Alias Listing
  1606.   #--------------------------------------------------------------------------
  1607.   alias drg128_setup setup unless method_defined?(:drg128_setup)
  1608.   alias drg128_upd update unless method_defined?(:drg128_upd)
  1609.   #--------------------------------------------------------------------------
  1610.   # * Setup
  1611.   #--------------------------------------------------------------------------
  1612.   def setup(*args)
  1613.     drg128_setup(*args)
  1614.     # index of window for the message
  1615.     @msgindex = 0
  1616.     $game_temp.message_text, $game_temp.message_proc = [],[] unless $game_temp.message_text.is_a?(Array)
  1617.     # whether multiple messages are displaying
  1618.     @multi_message = false
  1619.   end
  1620.   #--------------------------------------------------------------------------
  1621.   # * Update
  1622.   #--------------------------------------------------------------------------
  1623.   def update(*args)
  1624.     @message_waiting = $game_temp.message_window_showing
  1625.     drg128_upd(*args)
  1626.   end
  1627.   #--------------------------------------------------------------------------
  1628.   # * Message
  1629.   #--------------------------------------------------------------------------
  1630.   def message() $game_system.message if $game_system end
  1631.   def message_eval(v) eval(v)  end
  1632.   #--------------------------------------------------------------------------
  1633.   # * Setup Choices
  1634.   #--------------------------------------------------------------------------
  1635.   def setup_choices(parameters)
  1636.     # Set choice item count to choice_max
  1637.     $game_temp.choice_max = parameters[0].size
  1638.     # Set choice to message_text
  1639.     parameters[0].each {|text| $game_temp.message_text[@msgindex] += text + "\n"}
  1640.     # Set cancel processing
  1641.     $game_temp.choice_cancel_type = parameters[1]
  1642.     # Set callback
  1643.     current_indent = @list[@index].indent
  1644.     $game_temp.choice_proc = Proc.new { |n| @branch[current_indent] = n }
  1645.   end
  1646.   #--------------------------------------------------------------------------
  1647.   # * Show Text
  1648.   #--------------------------------------------------------------------------
  1649.   def command_101
  1650.     # If other text has been set to message_text
  1651.     if $game_temp.message_text[@msgindex] != nil
  1652.       if @multi_message
  1653.         @msgindex += 1
  1654.         $scene.new_message_window(@msgindex)
  1655.       else
  1656.         # End
  1657.         return false
  1658.       end
  1659.     end
  1660.     @msgindex = 0 if !@multi_message
  1661.     @multi_message = false
  1662.     # Set message end waiting flag and callback
  1663.     @message_waiting = true
  1664.     # just adding indexes
  1665.     $game_temp.message_proc[@msgindex] = Proc.new { @message_waiting = false }
  1666.     # Set message text on first line
  1667.     $game_temp.message_text[@msgindex] = @list[@index].parameters[0] + "\n"
  1668.     #$scene.multi_message_window[@msgindex].event_id = @event_id
  1669.     line_count = 1
  1670.     # Loop
  1671.     loop do
  1672.       # If next event command text is on the second line or after
  1673.       if @list[@index+1].code == 401 || (@list[@index+1].code == 101 &&
  1674.           @list[@index+1].parameters[0][0..1] == '\\#')
  1675.         # just adding index
  1676.         $game_temp.message_text[@msgindex] += @list[@index+1].parameters[0]+"\n"
  1677.         line_count += 1
  1678.       # If event command is not on the second line or after
  1679.       else
  1680.         # If next event command is show choices
  1681.         if @list[@index+1].code == 102
  1682.           # If choices fit on screen
  1683.           if @list[@index+1].parameters[0].size <= 4 - line_count
  1684.             # Prevent the closure of a single window with multiple windows
  1685.             $game_temp.input_in_window = true            
  1686.             # Flag this window as having choices displayed for multi
  1687.             $scene.multi_message_window[@msgindex].choice_window = @msgindex
  1688.             # Advance index
  1689.             @index += 1
  1690.             # Choices setup
  1691.             $game_temp.choice_start = line_count
  1692.             setup_choices(@list[@index].parameters)
  1693.           end
  1694.         # If next event command is input number
  1695.         elsif @list[@index+1].code == 103
  1696.           # If number input window fits on screen
  1697.           if line_count < 4
  1698.             # Prevent the closure of a single window with multiple windows
  1699.             $game_temp.input_in_window = true
  1700.             # Flag this window as having choices displayed
  1701.             $scene.multi_message_window[@msgindex].choice_window = @msgindex
  1702.             # Advance index
  1703.             @index += 1
  1704.             # Number input setup
  1705.             $game_temp.num_input_start = line_count
  1706.             $game_temp.num_input_variable_id = @list[@index].parameters[0]
  1707.             $game_temp.num_input_digits_max = @list[@index].parameters[1]
  1708.             $game_temp.num_input_variable_id_backup =
  1709.               @list[@index].parameters[0]
  1710.           end
  1711.         # start multimessage if next line is "Show Text" starting with "\\+"
  1712.         elsif @list[@index+1].code == 101
  1713.           if @list[@index+1].parameters[0][0..1]=='\\+'
  1714.             @multi_message,@message_waiting = true, false
  1715.           end
  1716.         end
  1717.         # Continue
  1718.         return true
  1719.       end
  1720.       # Advance index
  1721.       @index += 1
  1722.     end
  1723.   end
  1724.   #--------------------------------------------------------------------------
  1725.   # * Show Choices
  1726.   #--------------------------------------------------------------------------
  1727.   def command_102
  1728.     # Prevent the closure of a single window with multiple windows
  1729.     $game_temp.input_in_window = true
  1730.     # Flag this window as having choices displayed for multi
  1731.     $scene.multi_message_window[@msgindex].choice_window = @msgindex  
  1732.     # If text has been set to message_text
  1733.     # just adding index
  1734.     return false if $game_temp.message_text[@msgindex] != nil
  1735.     # Set message end waiting flag and callback
  1736.     @message_waiting = true
  1737.     # adding more indexes
  1738.     $game_temp.message_proc[@msgindex] = Proc.new { @message_waiting = false }
  1739.     # Choices setup
  1740.     $game_temp.message_text[@msgindex] = ''
  1741.     $game_temp.choice_start = 0
  1742.     setup_choices(@parameters)
  1743.     # Continue
  1744.     return true
  1745.   end
  1746.   #--------------------------------------------------------------------------
  1747.   # * Input Number
  1748.   #--------------------------------------------------------------------------
  1749.   def command_103
  1750.     # Prevent the closure of a single window with multiple windows
  1751.     $game_temp.input_in_window = true
  1752.     # Flag this window as having choices displayed for multi
  1753.     $scene.multi_message_window[@msgindex].choice_window = @msgindex  
  1754.     # If text has been set to message_text
  1755.     # just adding index
  1756.     return false if $game_temp.message_text[@msgindex] != nil
  1757.     # Set message end waiting flag and callback
  1758.     @message_waiting = true
  1759.     # adding more indexes
  1760.     $game_temp.message_proc[@msgindex] = Proc.new { @message_waiting = false }
  1761.     # Number input setup
  1762.     $game_temp.message_text[@msgindex] = ''
  1763.     $game_temp.num_input_start = 0
  1764.     $game_temp.num_input_variable_id = @parameters[0]
  1765.     $game_temp.num_input_digits_max = @parameters[1]
  1766.     $game_temp.num_input_variable_id_backup = @list[@index].parameters[0]
  1767.     # Continue
  1768.     return true
  1769.   end
  1770.   #--------------------------------------------------------------------------
  1771.   # ● Redefined method: same_map?, next_event_code
  1772.   #--------------------------------------------------------------------------
  1773.   define_method(:same_map?)       { @map_id == $game_map.map_id    }
  1774.   define_method(:next_event_code) { @list[@index + 1].code         }
  1775.   #--------------------------------------------------------------------------
  1776.   # * Overwriten method: command_355
  1777.   #--------------------------------------------------------------------------
  1778.   def command_355
  1779.     script = @list[index = @index].parameters[0] + "\n"
  1780.     while [655, 355].include?(next_event_code) do
  1781.       script += @list[@index+=1].parameters[0] + "\n"
  1782.     end
  1783.     wait = SCRIPT_WAIT_RESULTS.include?(eval(script))
  1784.     return wait ? !(@index = index) : true
  1785.   end  
  1786. end
  1787.  
  1788. #------------------------------------------------------------------------------
  1789.  
  1790. class Game_Map
  1791.   attr_accessor :last_display_x                # last display x-coord * 128
  1792.   attr_accessor :last_display_y                # last display y-coord * 128
  1793.  
  1794.   alias wachunga_mmw_game_map_update update
  1795.   def update
  1796.     @last_display_x = @display_x
  1797.     @last_display_y = @display_y
  1798.     wachunga_mmw_game_map_update
  1799.   end
  1800.  
  1801.   def name
  1802.     return load_data('Data/MapInfos.rxdata')[@map_id].name
  1803.   end
  1804. end
  1805.  
  1806. #------------------------------------------------------------------------------
  1807.  
  1808. class Bitmap
  1809.  
  1810.   attr_accessor :orientation
  1811.  
  1812.   #--------------------------------------------------------------------------
  1813.   # * Rotation Calculation
  1814.   #--------------------------------------------------------------------------
  1815.   def rotation(target)
  1816.     return if not [0, 90, 180, 270].include?(target) # invalid orientation
  1817.     if @rotation != target
  1818.       degrees = target - @orientation
  1819.       if degrees < 0
  1820.         degrees += 360
  1821.       end
  1822.       rotate(degrees)
  1823.     end    
  1824.   end
  1825.  
  1826.   #--------------------------------------------------------------------------
  1827.   # * Rotate Square (Clockwise)
  1828.   #--------------------------------------------------------------------------
  1829.   def rotate(degrees = 90)
  1830.     # method originally by SephirothSpawn
  1831.     # would just use Sprite.angle but its rotation is buggy
  1832.     # (see http://www.rmxp.org/forums/showthread.php?t=12044)
  1833.     return if not [90, 180, 270].include?(degrees)
  1834.     copy = self.clone
  1835.     if degrees == 90
  1836.       # Passes Through all Pixels on Dummy Bitmap
  1837.       (0...self.height).each {|i|
  1838.         (0...self.width).each {|j|
  1839.           self.set_pixel(width - i - 1, j, copy.get_pixel(j, i))
  1840.         }
  1841.       }
  1842.     elsif degrees == 180
  1843.       (0...self.height).each {|i|
  1844.         (0...self.width).each {|j|
  1845.           self.set_pixel(width - j - 1, height - i - 1, copy.get_pixel(j, i))
  1846.         }
  1847.       }      
  1848.     elsif degrees == 270
  1849.       (0...self.height).each {|i|
  1850.         (0...self.width).each {|j|
  1851.           self.set_pixel(i, height - j - 1, copy.get_pixel(j, i))
  1852.         }
  1853.       }
  1854.     end
  1855.     @orientation = (@orientation + degrees) % 360
  1856.   end
  1857.  
  1858. end
  1859.  
  1860. #------------------------------------------------------------------------------
  1861.  
  1862. class Window_Base
  1863.  
  1864.   #--------------------------------------------------------------------------
  1865.   # * Check Color
  1866.   #     color : color to check
  1867.   #--------------------------------------------------------------------------
  1868.   def check_color(color)
  1869.     if color.type == Color
  1870.       # already a Color object
  1871.       return color
  1872.     elsif color[0].chr == "#"
  1873.       # specified as hexadecimal
  1874.       r = color[1..2].hex
  1875.       g = color[3..4].hex
  1876.       b = color[5..6].hex
  1877.       return Color.new(r,g,b)
  1878.     else
  1879.       # specified as integer (0-7)
  1880.       color = color.to_i
  1881.       if color >= 0 && color <= 7
  1882.         return text_color(color)
  1883.       end
  1884.     end
  1885.     return normal_color
  1886.   end
  1887.  
  1888. end
  1889.  
  1890. #------------------------------------------------------------------------------
  1891.  
  1892. class Window_InputNumber < Window_Base
  1893.  
  1894.   def set_font(fname, fsize, fcolor)
  1895.     return if fname == nil && fsize == nil && fcolor == nil
  1896.     # Calculate cursor width from number width
  1897.     dummy_bitmap = Bitmap.new(32, 32)
  1898.     dummy_bitmap.font.name = fname
  1899.     dummy_bitmap.font.size = fsize
  1900.     @cursor_width = dummy_bitmap.text_size('0').width + 8
  1901.     dummy_bitmap.dispose
  1902.     self.width = @cursor_width * @digits_max + 32
  1903.     self.contents = Bitmap.new(width - 32, height - 32)
  1904.     self.contents.font.name = fname
  1905.     self.contents.font.size = fsize
  1906.     self.contents.font.color = check_color(fcolor)
  1907.     refresh
  1908.     update_cursor_rect
  1909.   end
  1910.  
  1911.   def refresh
  1912.     self.contents.clear
  1913. #------------------------------------------------------------------------------
  1914. # Begin Multiple Message Windows Edit
  1915. #------------------------------------------------------------------------------
  1916.     #self.contents.font.color = normal_color
  1917. #------------------------------------------------------------------------------
  1918. # Begin Multiple Message Windows Edit
  1919. #------------------------------------------------------------------------------
  1920.     s = sprintf("%0*d", @digits_max, @number)
  1921.     (0...@digits_max).each {|i|
  1922.       self.contents.draw_text(i * @cursor_width + 4, 0, 32, 32, s[i,1])
  1923.     }
  1924.   end
  1925.  
  1926. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement