Advertisement
FlipelyFlip

Window_BattleMessage Fix

Oct 6th, 2012
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.61 KB | None | 0 0
  1. #==============================================================================
  2. # ** Window_BattleMessage
  3. #------------------------------------------------------------------------------
  4. #  Message window displayed during battle. In addition to the normal message
  5. # window functions, it also has a battle progress narration function.
  6. #==============================================================================
  7.  
  8. class Window_BattleMessage < Window_Message
  9.   #--------------------------------------------------------------------------
  10.   # * Object Initialization
  11.   #--------------------------------------------------------------------------
  12.   def initialize
  13.     super
  14.     self.openness = 255
  15.     @lines = []
  16.     @position = 2
  17.     refresh
  18.   end
  19.   #--------------------------------------------------------------------------
  20.   # * Dispose
  21.   #--------------------------------------------------------------------------
  22.   def dispose
  23.     super
  24.   end
  25.   #--------------------------------------------------------------------------
  26.   # * Frame Update
  27.   #--------------------------------------------------------------------------
  28.   def update
  29.     super
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # * Open Window (disabled)
  33.   #--------------------------------------------------------------------------
  34.   def open
  35.   end
  36.   #--------------------------------------------------------------------------
  37.   # * Close Window (disabled)
  38.   #--------------------------------------------------------------------------
  39.   def close
  40.   end
  41.   #--------------------------------------------------------------------------
  42.   # * Set Window Background and Position (disabled)
  43.   #--------------------------------------------------------------------------
  44.   def reset_window
  45.     @position = $game_message.position
  46.     case @position
  47.     when 0  # Top
  48.       self.y = 0
  49.     when 1  # Middle
  50.       self.y = 144
  51.     when 2  # Bottom
  52.       self.y = 288
  53.     end
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # * Clear
  57.   #--------------------------------------------------------------------------
  58.   def clear
  59.     @lines.clear
  60.     refresh
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # * Get Row Count
  64.   #--------------------------------------------------------------------------
  65.   def line_number
  66.     return @lines.size
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # * Go Back One Line
  70.   #--------------------------------------------------------------------------
  71.   def back_one
  72.     @lines.pop
  73.     refresh
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # * Return to Designated Line
  77.   #     line_number : Line number
  78.   #--------------------------------------------------------------------------
  79.   def back_to(line_number)
  80.     while @lines.size > line_number
  81.       @lines.pop
  82.     end
  83.     refresh
  84.   end
  85.   #--------------------------------------------------------------------------
  86.   # * Add Text
  87.   #     text : Text to be added
  88.   #--------------------------------------------------------------------------
  89.   def add_instant_text(text)
  90.     @lines.push(text)
  91.     refresh
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # * Replace Text
  95.   #     text : Text to be replaced
  96.   #    Replaces the last line with different text.
  97.   #--------------------------------------------------------------------------
  98.   def replace_instant_text(text)
  99.     @lines.pop
  100.     @lines.push(text)
  101.     refresh
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # * Get Text From Last Line
  105.   #--------------------------------------------------------------------------
  106.   def last_instant_text
  107.     return @lines[-1]
  108.   end
  109.   #--------------------------------------------------------------------------
  110.   # * Refresh
  111.   #--------------------------------------------------------------------------
  112.   def refresh
  113.     self.contents.clear
  114.     for i in 0...@lines.size
  115.       draw_line(i)
  116.     end
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # * Draw Line
  120.   #     index : Line number
  121.   #--------------------------------------------------------------------------
  122.   def draw_line(index)
  123.     rect = Rect.new(0, 0, 0, 0)
  124.     rect.x += 4
  125.     rect.y += index * WLH
  126.     rect.width = contents.width - 8
  127.     rect.height = WLH
  128.     self.contents.clear_rect(rect)
  129.     self.contents.font.color = normal_color
  130.     self.contents.draw_text(rect, @lines[index])
  131.   end
  132. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement