All pastes #207627 Raw Edit

Someone

public ruby v1 · immutable
#207627 ·published 2006-10-18 03:00 UTC
rendered paste body
class MenuIcon < Sprite  attr_reader :description  def initialize(icon, x, y, viewport, description = '')    super(viewport)    self.bitmap = Bitmap.new(32, 32)    self.x, self.y = x, y    @icon = icon    @description = description    refresh  end  def refresh    self.bitmap.clear    bitmap = RPG::Cache.icon(@icon)    self.bitmap.blt(4, 4, bitmap, Rect.new(0, 0, 24, 24))  endendclass Main_Menu  def initialize(index = 0)    @index = index    @spriteset = Spriteset_Map.new    @viewport = Viewport.new(0, 0, 640, 480)    @viewport.z = 9000    @offset_x = (640 - 32 * 5) / 2    @offset_y = (480 - 32) / 3    @icons = [MenuIcon.new('032-Item01', @offset_x, @offset_y, @viewport,              'Inventory'),              MenuIcon.new('008-Weapon08', @offset_x + 32, @offset_y, @viewport,              'Skills'),              MenuIcon.new('013-Body01', @offset_x + 64, @offset_y, @viewport,              'Equipment'),              MenuIcon.new('050-Skill07', @offset_x + 96, @offset_y, @viewport,              'Status'),              MenuIcon.new('020-Accessory05', @offset_x + 128, @offset_y, @viewport,              'Quit')]    @text = Sprite.new(@viewport)    @text.x = @offset_x    @text.y = @offset_y + 32    @text.bitmap = Bitmap.new(160, 32)    set_description(@icons[@index].description)    Graphics.transition    loop do      Graphics.update      Input.update      update      break if $scene != self    end    Graphics.freeze    @spriteset.dispose    @icons.each {|icon| icon.dispose; }    @text.dispose    @viewport.dispose  end  def update    @spriteset.update    @viewport.update    @icons.each {|icon| icon.update; }    @text.update    if Input.trigger?(Input::LEFT)      index = @index      @index = [@index - 1, 0].max      return if index == @index      $game_system.se_play($data_system.cursor_se)      set_description(@icons[@index].description)    end    if Input.trigger?(Input::RIGHT)      index = @index      @index = [@index + 1, (@icons.size - 1)].min      return if index == @index      $game_system.se_play($data_system.cursor_se)      set_description(@icons[@index].description)    end    if Input.trigger?(Input::B)      $game_system.se_play($data_system.cancel_se)      $scene = Scene_Map.new    end  end  def set_description(text, align = 1)    @text.bitmap.clear    @text.bitmap.draw_text(0, 0, @text.bitmap.width, @text.bitmap.height,                           text, align)  endendclass Scene_Map  def call_menu    $game_temp.menu_calling = false    if $game_temp.menu_beep      $game_system.se_play($data_system.decision_se)      $game_temp.menu_beep = false    end    $game_player.straighten    $scene = Main_Menu.new  endend