Class: Core::States::AlchemyMenu

Inherits:
State show all
Includes:
Core, GUI
Defined in:
lib/states/menus/alchemy.rb

Constant Summary

Constants included from Core

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

Instance Attribute Summary

Attributes inherited from State

#window, #x, #y

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 State

#draw_cursor, #finish, #update_cursor

Constructor Details

#initialize(window, previous, party) ⇒ AlchemyMenu

Returns a new instance of AlchemyMenu.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/states/menus/alchemy.rb', line 9

def initialize(window, previous, party)
  super(window)
  @previous = previous
  @party = party
  @background = Core.sprite("menu/ingame_background")
  @w = Core::GUI::Window.new(0, 0, 1024, 768, Trans.menu(:botany))
  @w.add(:charselect, CharSelector.new(32, 32, party))
  @w.add(:experience, Textfield.new(320, 32, 256, 32, "#{Trans.menu(:experience)}: #{@party.members[@w.get(:charselect).index].skills.level_to_s(Game.find_skill(:botany))}", 24, :center))
  @w.add(:recipies_text, Textfield.new(32, 96, 256, 32, Trans.menu(:recipies), 24, :center))
  @w.add(:recipies, Container.new(32, 128, 256, 584, 24))
  @w.add(:items_text, Textfield.new(736, 96, 256, 32, Trans.menu(:items), 24, :center))
  @w.add(:items, Inventory.new(736, 128, 256, 584, @party.members[@w.get(:charselect).index], [:herb, :food, :poison], 24))
  @w.add(:info_header, Textfield.new(320, 480, 384, 200, "", 24, :center))
  @w.add(:info, Textfield.new(320, 512, 384, 200, ""))
  @w.add(:grid, Grid.new(320, 128, 12, 6, [Core::Game::Item]))
end

Instance Method Details

#drawObject



45
46
47
48
49
# File 'lib/states/menus/alchemy.rb', line 45

def draw
  @background.draw(0, 0, 0)
  @w.draw
  draw_cursor
end

#updateObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/states/menus/alchemy.rb', line 26

def update
  super
  if @window.pressed?(Gosu::KbEscape) or @w.remove?
    @window.advance(@previous)
  end
  @w.update
  if @w.get(:charselect).changed?
    char = @party.members[@w.get(:charselect).index]
    @w.get(:experience).text = "#{Trans.menu(:experience)}: #{char.skills.level_to_s(Game.find_skill(:botany))}"
    @w.get(:items).inventory = char.inventory
    @w.get(:grid).clear
  end
  if @w.get(:items).changed?
    @w.get(:info_header).text = Trans.item(@w.get(:items).selected.name)
    @w.get(:info).text = Trans.item("#{@w.get(:items).selected.name}_desc")
    @w.get(:grid).add(@w.get(:items).selected)
  end
end