Class: UI::Quest::ObjectiveList
- Inherits:
-
SpriteStack
- Object
- SpriteStack
- UI::Quest::ObjectiveList
- Defined in:
- scripts/01450 Systems/08000 Quest/00002 UI_Quest/00600 ObjectiveList.rb
Constant Summary
Constants inherited from SpriteStack
Instance Attribute Summary
Attributes inherited from SpriteStack
#animated, #data, #moving, #stack, #viewport, #x, #y
Instance Method Summary collapse
-
#initialize(viewport) ⇒ ObjectiveList
constructor
Initialize the ObjectiveList component.
-
#scroll_text(direction)
Scroll the text in the right direction if there's more than 4 objectives.
-
#update_text(data)
Update the text depending on the forwarded data.
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) ⇒ ObjectiveList
Initialize the ObjectiveList component
6 7 8 9 10 11 12 |
# File 'scripts/01450 Systems/08000 Quest/00002 UI_Quest/00600 ObjectiveList.rb', line 6 def initialize() super(, *coordinates) @max_index = 0 @index_text = 0 create_text create_arrows end |
Instance Method Details
#scroll_text(direction)
Scroll the text in the right direction if there's more than 4 objectives
35 36 37 38 39 40 41 42 43 44 |
# File 'scripts/01450 Systems/08000 Quest/00002 UI_Quest/00600 ObjectiveList.rb', line 35 def scroll_text(direction) return if @max_index <= 4 return if @index_text == 0 && direction == :UP return if @index_text == @max_index && direction == :DOWN coord = direction == :UP ? 16 : -16 @index_text += direction == :UP ? -1 : 1 @text.y = @text.y + coord update_arrows end |
#update_text(data)
Update the text depending on the forwarded data
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'scripts/01450 Systems/08000 Quest/00002 UI_Quest/00600 ObjectiveList.rb', line 16 def update_text(data) @text.y = y @index_text = 0 text = '' # Reducing by 4 to get an index and to account for the first 4 items # Useful to make sure the player can't scroll until he sees only one objective @max_index = data.size - 4 @max_index = 0 if @max_index < 0 data.each_with_index do |arr, i| color = arr[1] ? "\c[13]" : "\c[12]" text += arr[0] text += "\n" if i < data.size - 1 end @text.multiline_text = text update_arrows end |