Class: Core::GUI::ItemInfo

Inherits:
Element show all
Includes:
Core
Defined in:
lib/gui/item_info.rb

Constant Summary

Constants included from Core

CURSOR_Z, DEFAULT_CONFIG, DEFAULT_FONT, FOG_Z, Core::GUI_Z, HOME_PATH, LIBRARY_PATH, MAPOBJECT_Z, MAP_Z, PARTICLE_Z, RELEASE, SAVE_DIR, VERSION

Instance Attribute Summary

Attributes inherited from Element

#h, #w, #x, #xoff, #y, #yoff, #zoff

Instance Method Summary collapse

Methods included from Core

anim, animations, animations=, between?, config, exit, font, inside?, load_game, mouse_inside?, multiline, particles, particles=, save_game, silently, sprite, tiles, window, window=

Methods inherited from Element

#remove?, #update

Constructor Details

#initialize(x, y) ⇒ ItemInfo

Returns a new instance of ItemInfo.



6
7
8
9
10
11
12
13
# File 'lib/gui/item_info.rb', line 6

def initialize(x, y)
  super(x, y, 672, 160)
  @bg = Core.sprite("gui/iteminfo_background")
  @img = Core.sprite("items/none")
  @bigfont = Core.font(Core::DEFAULT_FONT, 32)
  @font = Core.font(Core::DEFAULT_FONT, 24)
  @item = nil
end

Instance Method Details

#drawObject



22
23
24
25
26
27
28
29
30
# File 'lib/gui/item_info.rb', line 22

def draw
  super
  @bg.draw(@x, @y, Core::GUI_Z + 9, @w/@bg.width.to_f, @h/@bg.height.to_f)
  @img.draw(@x, @y, Core::GUI_Z + 10, @h/@img.width.to_f, @h/@img.height.to_f)
  if @item
    @bigfont.draw(Trans.item(@item.name), @x+@h+4, @y+4, Core::GUI_Z + 11, 1, 1, Gosu::Color::BLACK)
    @font.draw(Trans.item("#{@item.name}_desc"), @x+@h+4, @y+36, Core::GUI_Z + 11, 1, 1, Gosu::Color::BLACK)
  end
end

#item=(item) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/gui/item_info.rb', line 14

def item=(item)
  @item = item
  if @item
    @img = @item.img
  else
    @img = Core.sprite("items/none")
  end
end