Class: AdventureRL::Menu
Constant Summary
collapse
[]
- DEFAULT_SETTINGS =
Settings.new(
active: false,
auto_update: false,
mouse_buttons_event_handler: {
auto_update: false,
only_mouse_buttons: true
}
)
Constants inherited
from Layer
Layer::MASK_ID
AdventureRL::Modifiers::Inventory::DEFAULT_INVENTORY_ID
Helpers::Error::PADDING, Helpers::Error::STACK_TRACE_PADDING, Helpers::Error::STACK_TRACE_SIZE
Constants inherited
from Mask
AdventureRL::Mask::MASKS
Constants inherited
from Point
Point::POINTS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Layer
#get_real_point, #get_real_scale, #get_rotation, #get_scale, #get_solids_manager, #has_solids_manager?, #increase_rotation, #increase_scale, #move_by, #set_rotation, #set_scale
#added_object?, #get_object, #get_objects, #remove_object, #remove_objects, #removed
directory_exists?, error, error_no_directory, error_no_file, file_exists?
Methods inherited from Mask
#assign_to, #assigned_to?, #collides_with?, #collides_with_hash?, #collides_with_mask?, #collides_with_point?, #get_assigned, #get_center, #get_corner, #get_layer, #get_mask, #get_origin, #get_real_center, #get_real_corner, #get_real_side, #get_real_sides, #get_side, #get_sides, #get_size, #has_layer?, #has_mask?, #set_layer, #set_size
Methods inherited from Point
#assign_to, #assigned_to?, #collides_with?, #collides_with_hash?, #collides_with_mask?, #collides_with_point?, #get_assigned, #get_layer, #get_point, #get_position, #get_real_point, #get_real_position, #has_layer?, #has_point?, #keys, #move_by, #set_layer, #set_position, #values, #x, #y
Constructor Details
#initialize(settings = {}) ⇒ Menu
Returns a new instance of Menu.
32
33
34
35
36
37
38
|
# 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
|
Class Method Details
6
7
8
9
10
|
# File 'lib/AdventureRL/Menu.rb', line 6
def self.button_down btnid
.each do ||
.button_down btnid
end
end
|
11
12
13
14
15
|
# File 'lib/AdventureRL/Menu.rb', line 11
def self.button_up btnid
.each do ||
.button_up btnid
end
end
|
19
20
21
|
# File 'lib/AdventureRL/Menu.rb', line 19
def self.
return MENUS.select(&:is_active?)
end
|
.update ⇒ Object
16
17
18
|
# File 'lib/AdventureRL/Menu.rb', line 16
def self.update
.each(&:update)
end
|
Instance Method Details
#activate ⇒ Object
55
56
57
|
# File 'lib/AdventureRL/Menu.rb', line 55
def activate
@active = true
end
|
#add_object(object, id = DEFAULT_INVENTORY_ID) ⇒ Object
Also known as:
add_button, add_item, add, <<
Overwrite #add_object method, so we can validate, that the given object is a Button.
42
43
44
45
46
47
48
49
|
# File 'lib/AdventureRL/Menu.rb', line 42
def add_object object, id = DEFAULT_INVENTORY_ID
super
@mouse_buttons_event_handler.subscribe object if (object.is_a? Button)
end
|
71
72
73
74
|
# File 'lib/AdventureRL/Menu.rb', line 71
def button_down btnid
return if (is_inactive?)
@mouse_buttons_event_handler.button_down btnid
end
|
76
77
78
79
|
# File 'lib/AdventureRL/Menu.rb', line 76
def button_up btnid
return if (is_inactive?)
@mouse_buttons_event_handler.button_up btnid
end
|
#deactivate ⇒ Object
59
60
61
|
# File 'lib/AdventureRL/Menu.rb', line 59
def deactivate
@active = false
end
|
#draw ⇒ Object
87
88
89
90
|
# File 'lib/AdventureRL/Menu.rb', line 87
def draw
return if (is_inactive?)
super
end
|
#is_active? ⇒ Boolean
63
64
65
|
# File 'lib/AdventureRL/Menu.rb', line 63
def is_active?
return !!@active
end
|
#is_inactive? ⇒ Boolean
67
68
69
|
# File 'lib/AdventureRL/Menu.rb', line 67
def is_inactive?
return !is_active?
end
|
#update ⇒ Object
81
82
83
84
85
|
# File 'lib/AdventureRL/Menu.rb', line 81
def update
return if (is_inactive?)
@mouse_buttons_event_handler.update
super
end
|