class Core::GUI::CharSelector

Attributes

index[R]

Public Class Methods

new(x, y, party, w=256, h=32) click to toggle source
Calls superclass method Core::GUI::Element::new
# File lib/gui/char_selector.rb, line 8
def initialize(x, y, party, w=256, h=32)
  super(x, y, w, h)
  @index = 0
  @changed = false
  @party = party
  @background = Core.sprite("gui/charselect_background")
  @font = Core.font(Core::DEFAULT_FONT, 24)
  @left = Button.new(x, y, 32, 32, "<", lambda {left}, false)
  @right = Button.new(x+w-32, y, 32, 32, ">", lambda {right}, false)
end

Public Instance Methods

changed?() click to toggle source
# File lib/gui/char_selector.rb, line 38
def changed?
  if @changed
    @changed = false
    return true
  else
    return false
  end
end
draw() click to toggle source
# File lib/gui/char_selector.rb, line 46
def draw
  @background.draw(@x+@xoff, @y+@yoff, Core::GUI_Z + 9, @w/@background.width, @h/@background.height)
  @font.draw(@party.members[@index].name, @x+@xoff+(@w/2)-(@font.text_width(@party.members[@index].name)/2), @y+@yoff+(@h/6), Core::GUI_Z + 10, 1, 1, Gosu::Color::BLACK)
  @left.draw
  @right.draw
end
left() click to toggle source
# File lib/gui/char_selector.rb, line 24
def left
  @index -= 1
  if @index < 0
    @index = @party.members.size-1
  end
  @changed = true
end
right() click to toggle source
# File lib/gui/char_selector.rb, line 31
def right
  @index += 1
  if @index >= @party.members.size
    @index = 0
  end
  @changed = true
end
update() click to toggle source
# File lib/gui/char_selector.rb, line 18
def update
  @left.xoff = @right.xoff = @xoff
  @left.yoff = @right.yoff = @yoff
  @left.update
  @right.update
end