Class: UI::Bag::ButtonList::ItemButton
- Inherits:
-
SpriteStack
- Object
- SpriteStack
- UI::Bag::ButtonList::ItemButton
- Defined in:
- scripts/01450 Systems/00103 Bag/00002 UI/00060 ButtonList.rb
Overview
Button showing the item name
Constant Summary collapse
- BACKGROUND =
Name of the button background
'bag/button_list'
Constants inherited from SpriteStack
Instance Attribute Summary collapse
-
#index ⇒ Integer
Index of the button in the list.
Attributes inherited from SpriteStack
#animated, #data, #moving, #stack, #viewport, #x, #y
Instance Method Summary collapse
-
#active? ⇒ Boolean
Is the button active.
-
#initialize(viewport, index) ⇒ ItemButton
constructor
Create a new Item button.
-
#reset
Reset the button coordinate.
-
#text=(text)
Set the button text.
Methods inherited from SpriteStack
#[], #add_background, #add_line, #add_text, #anime, #anime_delta_set, #dispose, #each, #execute_anime, #move, #move_to, #opacity, #opacity=, #push, #push_sprite, #set_origin, #set_position, #simple_mouse_in?, #size, #stop_animation, #translate_mouse_coords, #update, #update_animation, #update_position, #visible, #visible=, #with_cache, #with_font, #with_surface, #z, #z=
Constructor Details
#initialize(viewport, index) ⇒ ItemButton
Create a new Item button
148 149 150 151 152 153 |
# File 'scripts/01450 Systems/00103 Bag/00002 UI/00060 ButtonList.rb', line 148 def initialize(, index) @index = index super(, BASE_X + (active? ? ACTIVE_OFFSET : 0), BASE_Y + BUTTON_OFFSET * index) create_background @item_name = create_text end |
Instance Attribute Details
#index ⇒ Integer
Returns Index of the button in the list.
143 144 145 |
# File 'scripts/01450 Systems/00103 Bag/00002 UI/00060 ButtonList.rb', line 143 def index @index end |
Instance Method Details
#active? ⇒ Boolean
Is the button active
156 157 158 |
# File 'scripts/01450 Systems/00103 Bag/00002 UI/00060 ButtonList.rb', line 156 def active? @index == 2 end |
#reset
Reset the button coordinate
169 170 171 |
# File 'scripts/01450 Systems/00103 Bag/00002 UI/00060 ButtonList.rb', line 169 def reset set_position(BASE_X + (active? ? ACTIVE_OFFSET : 0), BASE_Y + BUTTON_OFFSET * index) end |
#text=(text)
Set the button text
162 163 164 165 166 |
# File 'scripts/01450 Systems/00103 Bag/00002 UI/00060 ButtonList.rb', line 162 def text=(text) return unless (self.visible = !text.nil?) @item_name.text = text end |