class AdventureRL::Menu
Constants
- DEFAULT_SETTINGS
- MENUS
This Array will be filled with creaed Menus.
Public Class Methods
new(settings = {})
click to toggle source
Calls superclass method
AdventureRL::Layer::new
# File lib/AdventureRL/Menu.rb, line 32 def initialize settings = {} @settings = DEFAULT_SETTINGS.merge settings @mouse_buttons_event_handler = EventHandlers::MouseButtons.new @settings.get(:mouse_buttons_event_handler) super @settings @active = @settings.get :active MENUS << self if (@settings.get(:auto_update)) end
update()
click to toggle source
# File lib/AdventureRL/Menu.rb, line 16 def self.update get_active_menus.each(&:update) end
Public Instance Methods
activate()
click to toggle source
# File lib/AdventureRL/Menu.rb, line 55 def activate @active = true end
add_object(object, id = DEFAULT_INVENTORY_ID)
click to toggle source
Overwrite add_object
method, so we can validate, that the given object
is a Button
.
Calls superclass method
AdventureRL::Layer#add_object
# File lib/AdventureRL/Menu.rb, line 42 def add_object object, id = DEFAULT_INVENTORY_ID #Helpers::Error.error( # "Expected given object to be a Button, but got", # "'#{object.inspect}:#{object.class.name}`." #) unless (object.is_a? Button) super @mouse_buttons_event_handler.subscribe object if (object.is_a? Button) end
deactivate()
click to toggle source
# File lib/AdventureRL/Menu.rb, line 59 def deactivate @active = false end
draw()
click to toggle source
Calls superclass method
AdventureRL::Layer#draw
# File lib/AdventureRL/Menu.rb, line 87 def draw return if (is_inactive?) super end
is_active?()
click to toggle source
# File lib/AdventureRL/Menu.rb, line 63 def is_active? return !!@active end
is_inactive?()
click to toggle source
# File lib/AdventureRL/Menu.rb, line 67 def is_inactive? return !is_active? end
update()
click to toggle source
Calls superclass method
AdventureRL::Layer#update
# File lib/AdventureRL/Menu.rb, line 81 def update return if (is_inactive?) @mouse_buttons_event_handler.update super end