Class: Core::Game::Combat::GUI

Inherits:
Object
  • Object
show all
Defined in:
lib/game/combat/gui.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGUI

Returns a new instance of GUI.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/game/combat/gui.rb', line 11

def initialize
  @x = 0
  @y = 544
  @z = 5000
  @bg = Core.sprite("gui/battle_infoback")
  @w = {} # Currently shown windows
  @ready = []
  @paused = false
  @chosen = @choose = nil
  @attacking = []
  @casting = []
  @using = []
  @add = {}
end

Instance Attribute Details

#attackingObject (readonly)

Returns the value of attribute attacking.



9
10
11
# File 'lib/game/combat/gui.rb', line 9

def attacking
  @attacking
end

#castingObject (readonly)

Returns the value of attribute casting.



9
10
11
# File 'lib/game/combat/gui.rb', line 9

def casting
  @casting
end

#usingObject (readonly)

Returns the value of attribute using.



9
10
11
# File 'lib/game/combat/gui.rb', line 9

def using
  @using
end

Instance Method Details

#abort_action(actor) ⇒ Object



93
94
95
96
97
98
99
100
# File 'lib/game/combat/gui.rb', line 93

def abort_action(actor)
  @paused = false
  @choose = nil
  @chosen = nil
  @w[:select_spell].close! if @w[:select_spell]
  @w[:select_item].close! if @w[:select_item]
  setup_ready_actions(actor)
end

#attackedObject



81
82
83
# File 'lib/game/combat/gui.rb', line 81

def attacked
  @attacking = []
end

#drawObject



70
71
72
73
74
75
# File 'lib/game/combat/gui.rb', line 70

def draw
  @bg.draw(@x, @y, @z, 1024/@bg.width.to_f, 224/@bg.height.to_f)
  @w.each_value { |w|
    w.draw
  }
end

#item_usedObject



89
90
91
# File 'lib/game/combat/gui.rb', line 89

def item_used
  @using = []
end

#open_info(obj, x, y) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/game/combat/gui.rb', line 33

def open_info(obj, x, y)
  if @choose and !@chosen
    @chosen = obj
  else
    if Core.config[:combat_gui_info_window_x]
      x = Core.config[:combat_gui_info_window_x]
    end
    if Core.config[:combat_gui_info_window_y]
      y = Core.config[:combat_gui_info_window_y]
    end
    @w[:info] = Core::GUI::Window.new(x, y, 320, 256, "Info", true, "gui/container_background", true)
    @w[:info].add(:text, Core::GUI::Textfield.new(8, 8, 304, 240, "#{obj}"))
    @w[:info].title = "#{Core::Trans.enemy(obj.data.name)}"
    @w[:info].save_pos(:combat_gui_info_window_x, :combat_gui_info_window_y)
  end
end

#paused?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/game/combat/gui.rb', line 77

def paused?
  return @paused
end

#push(type, *parms) ⇒ Object



26
27
28
29
30
31
# File 'lib/game/combat/gui.rb', line 26

def push(type, *parms)
  case type
  when :ready
    ready(parms)
  end
end

#spell_castObject



85
86
87
# File 'lib/game/combat/gui.rb', line 85

def spell_cast
  @casting = []
end

#updateObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/game/combat/gui.rb', line 50

def update
  @w.each_value { |w|
    w.update
    if w.remove?
      @w.delete(@w.key(w))
    end
  }
  @add.each do |k, v|
    @w.store(k, v)
  end
  @add = {}
  w = @w[:select_spell]
  if w and w.selected
    @choose = lambda { cast(w.actor, @chosen, w.selected) }
  end
  if @choose and @chosen
    @choose.call
  end
end