Class: UI::Storage::Summary

Inherits:
UI::SpriteStack show all
Defined in:
scripts/01450 Systems/00010 Storage/00002 UI_Storage/00203 Summary.rb

Overview

Stack responsive of showing a summary

Constant Summary collapse

POSITION =

Position of the summary depending on the state

[
  [210, 200], # Reduced
  [210, 10] # Developped
]
LETTER_POSITION =

Position of the letter depending on the state

[
  [1, 0], # Reduced
  [95, 15] # Developped
]
TEXT_TRANSITION_TIME =

Time between each text transition

2

Constants inherited from UI::SpriteStack

UI::SpriteStack::NO_INITIAL_IMAGE

Instance Attribute Summary collapse

Attributes inherited from UI::SpriteStack

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

Instance Method Summary collapse

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_animation, #update_position, #visible, #visible=, #with_cache, #with_font, #with_surface, #z, #z=

Constructor Details

#initialize(viewport, reduced) ⇒ Summary

Create a new summary object

Parameters:

  • viewport (Viewport)
  • reduced (Boolean)

    if the UI is initially reduced or not



23
24
25
26
27
28
29
30
31
32
33
# File 'scripts/01450 Systems/00010 Storage/00002 UI_Storage/00203 Summary.rb', line 23

def initialize(viewport, reduced)
  super(viewport, *POSITION[1]) # Initially in developped making easier to create the stack
  @reduced = reduced
  # @type [Yuki::Animation::TimedAnimation]
  @animation = nil
  @last_time = Graphics.current_time
  @last_text = 0
  create_stack
  reset_text_visibility
  set_position(*POSITION[0]) if reduced
end

Instance Attribute Details

#reducedBoolean (readonly)

Tell if the UI is reduced or not

Returns:

  • (Boolean)


7
8
9
# File 'scripts/01450 Systems/00010 Storage/00002 UI_Storage/00203 Summary.rb', line 7

def reduced
  @reduced
end

Instance Method Details

#data=(pokemon)

Update the shown pokemon



45
46
47
48
# File 'scripts/01450 Systems/00010 Storage/00002 UI_Storage/00203 Summary.rb', line 45

def data=(pokemon)
  super
  reset_text_visibility if @sprite.visible
end

#done?boolean

Tell if the animation is done

Returns:

  • (boolean)


52
53
54
55
56
# File 'scripts/01450 Systems/00010 Storage/00002 UI_Storage/00203 Summary.rb', line 52

def done?
  return true unless @animation

  return @animation.done?
end

#reduce

Reduce the UI (start animation)



59
60
61
62
63
64
65
# File 'scripts/01450 Systems/00010 Storage/00002 UI_Storage/00203 Summary.rb', line 59

def reduce
  return if @reduced

  @animation = Yuki::Animation.move_discreet(0.2, self, *POSITION[1], *POSITION[0])
  @animation.start
  @reduced = true
end

#show

Show the UI (start animation)



68
69
70
71
72
73
74
# File 'scripts/01450 Systems/00010 Storage/00002 UI_Storage/00203 Summary.rb', line 68

def show
  return unless @reduced

  @animation = Yuki::Animation.move_discreet(0.2, self, *POSITION[0], *POSITION[1])
  @animation.start
  @reduced = false
end

#update

Update the composition state



36
37
38
39
40
41
42
# File 'scripts/01450 Systems/00010 Storage/00002 UI_Storage/00203 Summary.rb', line 36

def update
  @sprite&.update
  update_text_transition
  return if !@animation || @animation.done?

  @animation.update
end