Class: UI::Shop::ItemList::ListButton
- Inherits:
-
UI::SpriteStack
- Object
- UI::SpriteStack
- UI::Shop::ItemList::ListButton
- Defined in:
- scripts/01450 Systems/00203 Shop/00002 ItemShop UI/00030 ItemList.rb
Constant Summary
Constants inherited from UI::SpriteStack
UI::SpriteStack::NO_INITIAL_IMAGE
Instance Attribute Summary collapse
-
#index ⇒ Integer
Index of the button in the list.
Attributes inherited from UI::SpriteStack
#animated, #data, #moving, #stack, #viewport, #x, #y
Instance Method Summary collapse
-
#active? ⇒ Boolean
Is the button active.
-
#icon_data=(icon)
Set the item icon.
-
#initialize(viewport, index) ⇒ ListButton
constructor
Create a new Item sell button.
-
#price=(price)
Set the item price.
-
#reset
Reset the button coordinate.
-
#text=(text)
Set the button text.
Methods inherited from UI::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) ⇒ ListButton
Create a new Item sell button
182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'scripts/01450 Systems/00203 Shop/00002 ItemShop UI/00030 ItemList.rb', line 182 def initialize(, index) @index = index super(, BASE_X + (active? ? ACTIVE_OFFSET : 0), BASE_Y + BUTTON_OFFSET * index) add_background('shop/button_list').set_z(1) @item_name = add_text(37, 8, 92, 18, nil.to_s, 1, color: 10) @item_name.z = 2 @item_price = add_text(133, 8, 37, 17, nil.to_s, 2, color: 0) @item_price.draw_shadow = false @item_price.z = 2 @item_icon = add_sprite(3, 2, NO_INITIAL_IMAGE, type: ItemSprite) @item_icon.z = 3 end |
Instance Attribute Details
#index ⇒ Integer
Returns Index of the button in the list.
177 178 179 |
# File 'scripts/01450 Systems/00203 Shop/00002 ItemShop UI/00030 ItemList.rb', line 177 def index @index end |
Instance Method Details
#active? ⇒ Boolean
Is the button active
196 197 198 |
# File 'scripts/01450 Systems/00203 Shop/00002 ItemShop UI/00030 ItemList.rb', line 196 def active? @index == 1 end |
#icon_data=(icon)
Set the item icon
218 219 220 221 222 223 224 |
# File 'scripts/01450 Systems/00203 Shop/00002 ItemShop UI/00030 ItemList.rb', line 218 def icon_data=(icon) if self.visible == false @item_icon.set_bitmap(nil) else @item_icon.data = icon end end |
#price=(price)
Set the item price
210 211 212 213 214 |
# File 'scripts/01450 Systems/00203 Shop/00002 ItemShop UI/00030 ItemList.rb', line 210 def price=(price) return unless (self.visible = !price.nil?) @item_price.text = price.to_s end |
#reset
Reset the button coordinate
227 228 229 |
# File 'scripts/01450 Systems/00203 Shop/00002 ItemShop UI/00030 ItemList.rb', line 227 def reset set_position(BASE_X + (active? ? ACTIVE_OFFSET : 0), BASE_Y + BUTTON_OFFSET * index) end |
#text=(text)
Set the button text
202 203 204 205 206 |
# File 'scripts/01450 Systems/00203 Shop/00002 ItemShop UI/00030 ItemList.rb', line 202 def text=(text) return unless (self.visible = !text.nil?) @item_name.text = text end |