Class: UI::Quest::QuestList

Inherits:
SpriteStack show all
Defined in:
scripts/01450 Systems/08000 Quest/00002 UI_Quest/00500 Quest_List.rb

Constant Summary collapse

NB_QUEST_BUTTON =

Number of buttons generated

7
BUTTON_OFFSET =

Offset between each button

28
BASE_X =

Base X coordinate

19
BASE_Y =

Base Y coordinate

41

Constants inherited from SpriteStack

SpriteStack::NO_INITIAL_IMAGE

Instance Attribute Summary collapse

Attributes inherited from SpriteStack

#animated, #data, #moving, #stack, #viewport, #x, #y

Instance Method Summary collapse

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, quest_hash, category) ⇒ QuestList

Create a new QuestList

Parameters:

  • viewport (Viewport)

    viewport in which the SpriteStack will be displayed

  • quest_hash (Hash)

    the hash containing the quests

  • category (Symbol)

    the current category the UI spawns in



23
24
25
26
27
28
29
30
31
# File 'scripts/01450 Systems/08000 Quest/00002 UI_Quest/00500 Quest_List.rb', line 23

def initialize(viewport, quest_hash, category)
  super(viewport)
  @quest_hash = quest_hash
  @quest_array = quest_hash.map { |_key, value| value }
  @timing = :slow
  @category = category
  @index = 0
  create_quest_buttons
end

Instance Attribute Details

#buttonsArray<QuestButton> (readonly)

Returns:



15
16
17
# File 'scripts/01450 Systems/08000 Quest/00002 UI_Quest/00500 Quest_List.rb', line 15

def buttons
  @buttons
end

#indexInteger

Returns index of the current active item.

Returns:

  • (Integer)

    index of the current active item



13
14
15
# File 'scripts/01450 Systems/08000 Quest/00002 UI_Quest/00500 Quest_List.rb', line 13

def index
  @index
end

#timing=(value)

Parameters:

  • the (Symbol)

    pace of the timing (:slow, :medium, :fast)



17
18
19
# File 'scripts/01450 Systems/08000 Quest/00002 UI_Quest/00500 Quest_List.rb', line 17

def timing=(value)
  @timing = value
end

Instance Method Details

#change_mode(mode) ⇒ Yuki::Animation::ScalarAnimation

Change the right button mode and return the animation

Parameters:

  • mode (Symbol)

Returns:

  • (Yuki::Animation::ScalarAnimation)


71
72
73
74
75
76
77
78
79
80
# File 'scripts/01450 Systems/08000 Quest/00002 UI_Quest/00500 Quest_List.rb', line 71

def change_mode(mode)
  anim = Yuki::Animation
  animation = @buttons[0].change_mode(mode)
  coord = (mode == :compact ? -87 : 87)
  (1..5).each do |i|
    bt = @buttons[i]
    animation.parallel_add(anim.move_discreet(0.5, bt, bt.x, bt.y, bt.x, @buttons[i].y + coord, distortion: :SMOOTH_DISTORTION))
  end
  return animation
end

#last_index?Boolean

Tell if the current index is the same as the last quest for this category

Returns:

  • (Boolean)


64
65
66
# File 'scripts/01450 Systems/08000 Quest/00002 UI_Quest/00500 Quest_List.rb', line 64

def last_index?
  return index == @quest_array.size - 1
end

#move_down

Move all the buttons down



55
56
57
58
59
60
61
# File 'scripts/01450 Systems/08000 Quest/00002 UI_Quest/00500 Quest_List.rb', line 55

def move_down
  @buttons.last.quest = @quest_array[index + (NB_QUEST_BUTTON - 1)]
  animation = move_down_animation
  @buttons.rotate!(1)
  self.index = index + 1
  return animation
end

#move_up

Move all the buttons up



46
47
48
49
50
51
52
# File 'scripts/01450 Systems/08000 Quest/00002 UI_Quest/00500 Quest_List.rb', line 46

def move_up
  @buttons.last.quest = @quest_array[index - 1]
  animation = move_up_animation
  @buttons.rotate!(-1)
  self.index = index - 1
  return animation
end

#number_of_buttonsInteger

Return the number of buttons registered in the stack

Returns:



35
36
37
# File 'scripts/01450 Systems/08000 Quest/00002 UI_Quest/00500 Quest_List.rb', line 35

def number_of_buttons
  return @quest_array.size
end