All pastes #382673 Raw Edit

Script For Necrile

public text v1 · immutable
·published 2007-03-05 20:50 UTC
rendered paste body
#==============================================================================
# ■ Window_Selectable
#------------------------------------------------------------------------------
#  Credits to Selwyn
#==============================================================================

class Window_Selectable < Window_Base
  alias initialize_scrollbar initialize
  alias update_scrollbar update
  alias dispose_scrollbar dispose
  #--------------------------------------------------------------------------
  # &#9679; initialize
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    initialize_scrollbar(x, y, width, height)
    @scrollbar = Sprite.new
    @scrollbar.x = x + self.width - 13
    @scrollbar.y = y + 17
    @scrollbar.z = 3001
    @scrollback = Sprite.new
    bitmap = Bitmap.new(8, 448)
    bitmap.fill_rect(0, 0, 8, 448, Color.new(0, 0, 0))
    @scrollback.bitmap = bitmap
    @scrollback.x = x + self.width - 14
    @scrollback.y = y + 16
    @scrollback.z = 3000
    @scrollback.src_rect.set(0, 0, 8, self.height - 32)
    self.scrollbar = false
  end
  #--------------------------------------------------------------------------
  # &#9679; contents=
  #--------------------------------------------------------------------------
  def contents=(contents)
    super(contents)
    unless self.contents.nil?
      height = (self.height-33)/(self.contents.height/(self.height-32).to_f)
      self.scrollbar = true
      if height > self.height - 34
        self.scrollbar = false
      end
      y = self.top_row * (self.height - 34) / row_max
      rect = Rect.new(0, 0, 6, height)
      bmp = RPG::Cache.picture("scrollbar") rescue nil
      if bmp.nil?
        bmp = Bitmap.new(6, 480)
        color = self.windowskin.nil? ? Color.new(255, 255, 255) :
          self.windowskin.get_pixel(0, 0)
        bmp.fill_rect(0, 0, 6, 480, color)
      end
      @scrollbar.bitmap = bmp
      @scrollbar.src_rect.set(0, 0, 6, height)
      @scrollbar.y = y + self.y + 17
      @scrollback.src_rect.set(0, 0, 8, self.height - 32)
    end
  end
  #--------------------------------------------------------------------------
  # &#9679; dispose
  #--------------------------------------------------------------------------
  def dispose
    dispose_scrollbar
    if @scrollback.bitmap != nil
      @scrollback.bitmap.clear
    end
    @scrollbar.dispose
    @scrollback.dispose
  end
  #--------------------------------------------------------------------------
  # &#9679; scrollbar=
  #--------------------------------------------------------------------------
  def scrollbar=(bool)
    @scrollbar.visible = bool
    @scrollback.visible = bool
  end
  #--------------------------------------------------------------------------
  # &#9679; update
  #--------------------------------------------------------------------------
  def update
    update_scrollbar
    unless self.contents.nil?
      height = (self.height-33)/(self.contents.height/(self.height-32).to_f)
      self.scrollbar = true
      if height > self.height - 34
        self.scrollbar = false
      end
      y = self.top_row * (self.height - 34) / row_max
      @scrollbar.src_rect.set(0, 0, 6, height)
      @scrollbar.y = y + self.y + 17
      @scrollback.src_rect.set(0, 0, 8, self.height - 32)
    end
  end
end