SHARE
TWEET

[RMXP] Multiple Message Windows (Non-SDK)

ForeverZer0 May 21st, 2011 211 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. # ** Multiple Message Windows
  3. #------------------------------------------------------------------------------
  4. # Originally written by Wachunga
  5. # Optimized and De-SDK'ed by ForeverZer0
  6. # 1.5
  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)
  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. class Scene_Map
  1410.  
  1411.   #--------------------------------------------------------------------------
  1412.   # * New Message Window Addition
  1413.   #--------------------------------------------------------------------------
  1414.   def new_message_window(index)
  1415.     if @message_window[index] != nil
  1416.       # clear message windows at and after this index
  1417.       last_index = @message_window.size - 1
  1418.       last_index.downto(index) { |i|
  1419.         if @message_window[i] != nil
  1420.           @message_window[i].dispose
  1421.           @message_window[i] = nil
  1422.         end
  1423.       }
  1424.       @message_window.compact!
  1425.     end
  1426.     @message_window.push(Window_Message.new(index))
  1427.   end
  1428.  
  1429. end
  1430.  
  1431. #------------------------------------------------------------------------------
  1432.  
  1433. class Scene_Battle
  1434.  
  1435.   #--------------------------------------------------------------------------
  1436.   # * New Message Window Addition
  1437.   #--------------------------------------------------------------------------
  1438.   def new_message_window(index)
  1439.     if @message_window[index] != nil
  1440.       # clear message windows at and after this index
  1441.       last_index = @message_window.size - 1
  1442.       last_index.downto(index) { |i|
  1443.         if @message_window[i] != nil
  1444.           @message_window[i].dispose
  1445.           @message_window[i] = nil
  1446.         end
  1447.       }
  1448.       @message_window.compact!
  1449.     end
  1450.     @message_window.push(Window_Message.new(index))
  1451.   end
  1452.  
  1453. end
  1454.  
  1455. #------------------------------------------------------------------------------
  1456.  
  1457. class Game_System
  1458.   attr_reader :message
  1459.  
  1460.   alias wachunga_mmw_game_system_init initialize
  1461.   def initialize
  1462.     wachunga_mmw_game_system_init
  1463.     @message = Game_Message.new
  1464.   end
  1465.  
  1466.   # Zer0 Edit
  1467.   alias zer0_shaded_text_fix_upd update
  1468.   def update
  1469.     zer0_shaded_text_fix_upd
  1470.     if @SHADED_TEXT != nil && Blizzard_Shaded_Text_Fix == true
  1471.       if $game_temp.message_window_showing
  1472.         @SHADED_TEXT = false
  1473.       else
  1474.         @SHADED_TEXT = true
  1475.       end
  1476.     end
  1477.   end
  1478. end
  1479.  
  1480. #------------------------------------------------------------------------------
  1481.  
  1482. class Game_Player < Game_Character   # Zer0 edit
  1483.  
  1484.   # Redefines the update method
  1485.   def update
  1486.     # Remember whether or not moving in local variables
  1487.     last_moving = moving?
  1488.     # If moving, event running, move route forcing, and message window
  1489.     # display are all not occurring
  1490.     unless moving? ||
  1491.       @move_route_forcing ||
  1492.       ($game_system.map_interpreter.running? &&
  1493.       !$game_temp.message_window_showing) ||
  1494.       ($game_temp.message_window_showing &&
  1495.       !$game_system.message.move_during) ||
  1496.       ($game_temp.choice_max > 0 || $game_temp.num_input_digits_max > 0)
  1497.       # Move player in the direction the directional button is being pressed
  1498.       case Input.dir4
  1499.       when 2
  1500.         move_down
  1501.       when 4
  1502.         move_left
  1503.       when 6
  1504.         move_right
  1505.       when 8
  1506.         move_up
  1507.       end
  1508.     end
  1509.     # Remember coordinates in local variables
  1510.     last_real_x = @real_x
  1511.     last_real_y = @real_y
  1512.     super
  1513.     # If character moves down and is positioned lower than the center
  1514.     # of the screen
  1515.     if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  1516.       # Scroll map down
  1517.       $game_map.scroll_down(@real_y - last_real_y)
  1518.     end
  1519.     # If character moves left and is positioned more let on-screen than
  1520.     # center
  1521.     if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  1522.       # Scroll map left
  1523.       $game_map.scroll_left(last_real_x - @real_x)
  1524.     end
  1525.     # If character moves right and is positioned more right on-screen than
  1526.     # center
  1527.     if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  1528.       # Scroll map right
  1529.       $game_map.scroll_right(@real_x - last_real_x)
  1530.     end
  1531.     # If character moves up and is positioned higher than the center
  1532.     # of the screen
  1533.     if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  1534.       # Scroll map up
  1535.       $game_map.scroll_up(last_real_y - @real_y)
  1536.     end
  1537.     # If not moving
  1538.     unless moving?
  1539.       # If player was moving last time
  1540.       if last_moving
  1541.         # Event determinant is via touch of same position event
  1542.         result = check_event_trigger_here([1,2])
  1543.         # If event which started does not exist
  1544.         if result == false
  1545.           # Disregard if debug mode is ON and ctrl key was pressed
  1546.           unless $DEBUG and Input.press?(Input::CTRL)
  1547.             # Encounter countdown
  1548.             if @encounter_count > 0
  1549.               @encounter_count -= 1
  1550.             end
  1551.           end
  1552.         end
  1553.       end
  1554.       # If C button was pressed
  1555.       if Input.trigger?(Input::C)
  1556.         # Same position and front event determinant
  1557.         check_event_trigger_here([0])
  1558.         check_event_trigger_there([0,1,2])
  1559.       end
  1560.     end
  1561.   end
  1562.  
  1563.   #--------------------------------------------------------------------------
  1564.   # * Touch Event Starting Determinant
  1565.   #--------------------------------------------------------------------------
  1566.   # This is a fix if Blizzard's Optimized default scripts are being used
  1567.  
  1568.   def check_event_trigger_touch(x, y)
  1569.     result = false                         # <--------- MOVED from....
  1570.     # If event is running
  1571.     if $game_system.map_interpreter.running?
  1572.       return result
  1573.     end
  1574.     #result = false                        # <--------- ...HERE
  1575.     # All event loops
  1576.     $game_map.events.each_value {|event|
  1577.       # If event coordinates and triggers are consistent
  1578.       if event.x == x && event.y == y && [1,2].include?(event.trigger)
  1579.         # If starting determinant is front event (other than jumping)
  1580.         if !event.jumping? && !event.over_trigger?
  1581.           event.start
  1582.           result = true
  1583.         end
  1584.       end
  1585.     }
  1586.     return result
  1587.   end
  1588.  
  1589. end
  1590.  
  1591. #------------------------------------------------------------------------------
  1592. class Interpreter
  1593.   attr_reader :event_id
  1594.  
  1595.   alias wachunga_mmw_interp_setup setup
  1596.   def setup(list, event_id)
  1597.     wachunga_mmw_interp_setup(list, event_id)
  1598.     # index of window for the message
  1599.     @msgindex = 0
  1600.     # whether multiple messages are displaying
  1601.     @multi_message = false
  1602.   end
  1603.  
  1604.   def setup_choices(parameters)
  1605.     # Set choice item count to choice_max
  1606.     $game_temp.choice_max = parameters[0].size
  1607.     # Set choice to message_text
  1608.     parameters[0].each {|text| $game_temp.message_text[@msgindex] += text + "\n"}
  1609.     # Set cancel processing
  1610.     $game_temp.choice_cancel_type = parameters[1]
  1611.     # Set callback
  1612.     current_indent = @list[@index].indent
  1613.     $game_temp.choice_proc = Proc.new { |n| @branch[current_indent] = n }
  1614.   end
  1615.  
  1616.   #--------------------------------------------------------------------------
  1617.   # * Show Text
  1618.   #--------------------------------------------------------------------------
  1619.   def command_101
  1620.     # If other text has been set to message_text
  1621. #------------------------------------------------------------------------------
  1622. # Begin Multiple Message Windows Edit
  1623. #------------------------------------------------------------------------------
  1624.     if $game_temp.message_text[@msgindex] != nil
  1625.       if @multi_message
  1626.         @msgindex += 1
  1627.         $scene.new_message_window(@msgindex)
  1628.       else
  1629.         # End
  1630. #------------------------------------------------------------------------------
  1631. # End Multiple Message Windows Edit
  1632. #------------------------------------------------------------------------------
  1633.         return false
  1634. #------------------------------------------------------------------------------
  1635. # Begin Multiple Message Windows Edit
  1636. #------------------------------------------------------------------------------
  1637.       end
  1638.     end
  1639.     @msgindex = 0 if !@multi_message
  1640.     @multi_message = false
  1641. #------------------------------------------------------------------------------
  1642. # End Multiple Message Windows Edit
  1643. #------------------------------------------------------------------------------
  1644.     # Set message end waiting flag and callback
  1645.     @message_waiting = true
  1646. #------------------------------------------------------------------------------
  1647. # Begin Multiple Message Windows Edit
  1648. #------------------------------------------------------------------------------
  1649.     # just adding indexes
  1650.     $game_temp.message_proc[@msgindex] = Proc.new { @message_waiting = false }
  1651.     # Set message text on first line
  1652.     $game_temp.message_text[@msgindex] = @list[@index].parameters[0] + "\n"
  1653. #------------------------------------------------------------------------------
  1654. # End Multiple Message Windows Edit
  1655. #------------------------------------------------------------------------------
  1656.     line_count = 1
  1657.     # Loop
  1658.     loop do
  1659.       # If next event command text is on the second line or after
  1660.       if @list[@index+1].code == 401
  1661.         # Add the second line or after to message_text
  1662. #------------------------------------------------------------------------------
  1663. # Begin Multiple Message Windows Edit
  1664. #------------------------------------------------------------------------------
  1665.         # just adding index
  1666.         $game_temp.message_text[@msgindex]+=@list[@index+1].parameters[0]+"\n"
  1667. #------------------------------------------------------------------------------
  1668. # End Multiple Message Windows Edit
  1669. #------------------------------------------------------------------------------
  1670.         line_count += 1
  1671.       # If event command is not on the second line or after
  1672.       else
  1673.         # If next event command is show choices
  1674.         if @list[@index+1].code == 102
  1675.           # If choices fit on screen
  1676.           if @list[@index+1].parameters[0].size <= 4 - line_count
  1677.             # Advance index
  1678.             @index += 1
  1679.             # Choices setup
  1680.             $game_temp.choice_start = line_count
  1681.             setup_choices(@list[@index].parameters)
  1682.           end
  1683.         # If next event command is input number
  1684.         elsif @list[@index+1].code == 103
  1685.           # If number input window fits on screen
  1686.           if line_count < 4
  1687.             # Advance index
  1688.             @index += 1
  1689.             # Number input setup
  1690.             $game_temp.num_input_start = line_count
  1691.             $game_temp.num_input_variable_id = @list[@index].parameters[0]
  1692.             $game_temp.num_input_digits_max = @list[@index].parameters[1]
  1693.           end
  1694. #------------------------------------------------------------------------------
  1695. # Begin Multiple Message Windows Edit
  1696. #------------------------------------------------------------------------------
  1697.         # start multimessage if next line is "Show Text" starting with "\\+"
  1698.         elsif @list[@index+1].code == 101
  1699.           if @list[@index+1].parameters[0][0..1]=="\\+"
  1700.             @multi_message = true
  1701.             @message_waiting = false
  1702.           end
  1703. #------------------------------------------------------------------------------
  1704. # End Multiple Message Windows Edit
  1705. #------------------------------------------------------------------------------
  1706.         end
  1707.         # Continue
  1708.         return true
  1709.       end
  1710.       # Advance index
  1711.       @index += 1
  1712.     end
  1713.   end
  1714.  
  1715.   #--------------------------------------------------------------------------
  1716.   # * Show Choices
  1717.   #--------------------------------------------------------------------------
  1718.   def command_102
  1719.     # If text has been set to message_text
  1720. #------------------------------------------------------------------------------
  1721. # Begin Multiple Message Windows Edit
  1722. #------------------------------------------------------------------------------
  1723.     # just adding index
  1724.     if $game_temp.message_text[@msgindex] != nil
  1725. #------------------------------------------------------------------------------
  1726. # End Multiple Message Windows Edit
  1727. #------------------------------------------------------------------------------
  1728.       # End
  1729.       return false
  1730.     end
  1731.     # Set message end waiting flag and callback
  1732.     @message_waiting = true
  1733. #------------------------------------------------------------------------------
  1734. # Begin Multiple Message Windows Edit
  1735. #------------------------------------------------------------------------------
  1736.     # adding more indexes
  1737.     $game_temp.message_proc[@msgindex] = Proc.new { @message_waiting = false }
  1738.     # Choices setup
  1739.     $game_temp.message_text[@msgindex] = ''
  1740. #------------------------------------------------------------------------------
  1741. # End Multiple Message Windows Edit
  1742. #------------------------------------------------------------------------------
  1743.     $game_temp.choice_start = 0
  1744.     setup_choices(@parameters)
  1745.     # Continue
  1746.     return true
  1747.   end
  1748.  
  1749.   #--------------------------------------------------------------------------
  1750.   # * Input Number
  1751.   #--------------------------------------------------------------------------
  1752.   def command_103
  1753.     # If text has been set to message_text
  1754. #------------------------------------------------------------------------------
  1755. # Begin Multiple Message Windows Edit
  1756. #------------------------------------------------------------------------------
  1757.     # just adding index
  1758.     if $game_temp.message_text[@msgindex] != nil
  1759. #------------------------------------------------------------------------------
  1760. # End Multiple Message Windows Edit
  1761. #------------------------------------------------------------------------------
  1762.       # End
  1763.       return false
  1764.     end
  1765.     # Set message end waiting flag and callback
  1766.     @message_waiting = true
  1767. #------------------------------------------------------------------------------
  1768. # Begin Multiple Message Windows Edit
  1769. #------------------------------------------------------------------------------
  1770.     # adding more indexes
  1771.     $game_temp.message_proc[@msgindex] = Proc.new { @message_waiting = false }
  1772.     # Number input setup
  1773.     $game_temp.message_text[@msgindex] = ''
  1774. #------------------------------------------------------------------------------
  1775. # End Multiple Message Windows Edit
  1776. #------------------------------------------------------------------------------
  1777.     $game_temp.num_input_start = 0
  1778.     $game_temp.num_input_variable_id = @parameters[0]
  1779.     $game_temp.num_input_digits_max = @parameters[1]
  1780.     # Continue
  1781.     return true
  1782.   end
  1783.  
  1784.   #--------------------------------------------------------------------------
  1785.   # * Script
  1786.   #--------------------------------------------------------------------------
  1787.   # Fix for RMXP bug: call script boxes that return false hang the game
  1788.   # See, e.g., http://rmxp.org/forums/showthread.php?p=106639  
  1789.   #--------------------------------------------------------------------------
  1790.   def command_355
  1791.     # Set first line to script
  1792.     script = @list[@index].parameters[0] + "\n"
  1793.     # Loop
  1794.     loop do
  1795.       # If next event command is second line of script or after
  1796.       if @list[@index+1].code == 655
  1797.         # Add second line or after to script
  1798.         script += @list[@index+1].parameters[0] + "\n"
  1799.       # If event command is not second line or after
  1800.       else
  1801.         # Abort loop
  1802.         break
  1803.       end
  1804.       # Advance index
  1805.       @index += 1
  1806.     end
  1807.     # Evaluation
  1808.     result = eval(script)
  1809.     # If return value is false
  1810.     if result == false
  1811.       # End
  1812. #------------------------------------------------------------------------------
  1813. # Begin Edit
  1814. #------------------------------------------------------------------------------
  1815.       #return false
  1816. #------------------------------------------------------------------------------
  1817. # End Edit
  1818. #------------------------------------------------------------------------------
  1819.     end
  1820.     # Continue
  1821.     return true
  1822.   end
  1823.  
  1824.   def message
  1825.     message = $game_system.message if $game_system != nil
  1826.   end
  1827.  
  1828. end
  1829.  
  1830. #------------------------------------------------------------------------------
  1831.  
  1832. class Game_Map
  1833.   attr_accessor :last_display_x                # last display x-coord * 128
  1834.   attr_accessor :last_display_y                # last display y-coord * 128
  1835.  
  1836.   alias wachunga_mmw_game_map_update update
  1837.   def update
  1838.     @last_display_x = @display_x
  1839.     @last_display_y = @display_y
  1840.     wachunga_mmw_game_map_update
  1841.   end
  1842.  
  1843.   def name
  1844.     return load_data('Data/MapInfos.rxdata')[@map_id].name
  1845.   end
  1846. end
  1847.  
  1848. #------------------------------------------------------------------------------
  1849.  
  1850. class Bitmap
  1851.  
  1852.   attr_accessor :orientation
  1853.  
  1854.   #--------------------------------------------------------------------------
  1855.   # * Rotation Calculation
  1856.   #--------------------------------------------------------------------------
  1857.   def rotation(target)
  1858.     return if not [0, 90, 180, 270].include?(target) # invalid orientation
  1859.     if @rotation != target
  1860.       degrees = target - @orientation
  1861.       if degrees < 0
  1862.         degrees += 360
  1863.       end
  1864.       rotate(degrees)
  1865.     end    
  1866.   end
  1867.  
  1868.   #--------------------------------------------------------------------------
  1869.   # * Rotate Square (Clockwise)
  1870.   #--------------------------------------------------------------------------
  1871.   def rotate(degrees = 90)
  1872.     # method originally by SephirothSpawn
  1873.     # would just use Sprite.angle but its rotation is buggy
  1874.     # (see http://www.rmxp.org/forums/showthread.php?t=12044)
  1875.     return if not [90, 180, 270].include?(degrees)
  1876.     copy = self.clone
  1877.     if degrees == 90
  1878.       # Passes Through all Pixels on Dummy Bitmap
  1879.       (0...self.height).each {|i|
  1880.         (0...self.width).each {|j|
  1881.           self.set_pixel(width - i - 1, j, copy.get_pixel(j, i))
  1882.         }
  1883.       }
  1884.     elsif degrees == 180
  1885.       (0...self.height).each {|i|
  1886.         (0...self.width).each {|j|
  1887.           self.set_pixel(width - j - 1, height - i - 1, copy.get_pixel(j, i))
  1888.         }
  1889.       }      
  1890.     elsif degrees == 270
  1891.       (0...self.height).each {|i|
  1892.         (0...self.width).each {|j|
  1893.           self.set_pixel(i, height - j - 1, copy.get_pixel(j, i))
  1894.         }
  1895.       }
  1896.     end
  1897.     @orientation = (@orientation + degrees) % 360
  1898.   end
  1899.  
  1900. end
  1901.  
  1902. #------------------------------------------------------------------------------
  1903.  
  1904. class Window_Base
  1905.  
  1906.   #--------------------------------------------------------------------------
  1907.   # * Check Color
  1908.   #     color : color to check
  1909.   #--------------------------------------------------------------------------
  1910.   def check_color(color)
  1911.     if color.type == Color
  1912.       # already a Color object
  1913.       return color
  1914.     elsif color[0].chr == "#"
  1915.       # specified as hexadecimal
  1916.       r = color[1..2].hex
  1917.       g = color[3..4].hex
  1918.       b = color[5..6].hex
  1919.       return Color.new(r,g,b)
  1920.     else
  1921.       # specified as integer (0-7)
  1922.       color = color.to_i
  1923.       if color >= 0 && color <= 7
  1924.         return text_color(color)
  1925.       end
  1926.     end
  1927.     return normal_color
  1928.   end
  1929.  
  1930. end
  1931.  
  1932. #------------------------------------------------------------------------------
  1933.  
  1934. class Window_InputNumber < Window_Base
  1935.  
  1936.   def set_font(fname, fsize, fcolor)
  1937.     return if fname == nil && fsize == nil && fcolor == nil
  1938.     # Calculate cursor width from number width
  1939.     dummy_bitmap = Bitmap.new(32, 32)
  1940.     dummy_bitmap.font.name = fname
  1941.     dummy_bitmap.font.size = fsize
  1942.     @cursor_width = dummy_bitmap.text_size('0').width + 8
  1943.     dummy_bitmap.dispose
  1944.     self.width = @cursor_width * @digits_max + 32
  1945.     self.contents = Bitmap.new(width - 32, height - 32)
  1946.     self.contents.font.name = fname
  1947.     self.contents.font.size = fsize
  1948.     self.contents.font.color = check_color(fcolor)
  1949.     refresh
  1950.     update_cursor_rect
  1951.   end
  1952.  
  1953.   def refresh
  1954.     self.contents.clear
  1955. #------------------------------------------------------------------------------
  1956. # Begin Multiple Message Windows Edit
  1957. #------------------------------------------------------------------------------
  1958.     #self.contents.font.color = normal_color
  1959. #------------------------------------------------------------------------------
  1960. # Begin Multiple Message Windows Edit
  1961. #------------------------------------------------------------------------------
  1962.     s = sprintf("%0*d", @digits_max, @number)
  1963.     (0...@digits_max).each {|i|
  1964.       self.contents.draw_text(i * @cursor_width + 4, 0, 32, 32, s[i,1])
  1965.     }
  1966.   end
  1967.  
  1968. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top