Class: UI::Storage::Cursor

Inherits:
ShaderedSprite show all
Defined in:
scripts/01450 Systems/00200 Storage/00002 UI_Storage/00008 Cursor.rb

Overview

Class responsive of showing the cursor

Constant Summary collapse

BOX_INITIAL_POSITION =

Box initial position

[17, 42]
PARTY_POSITIONS =

Party positions

[
  [233, 50], [281, 66],
  [233, 98], [281, 115],
  [233, 146], [281, 162]
]
ARROW_IMAGES =

List of graphics depending on the selection mode

{ battle: 'pc/arrow_red', pokemon: 'pc/arrow_blue', grouped: 'pc/arrow_green', item: 'pc/arrow_yellow' }

Instance Attribute Summary collapse

Attributes inherited from LiteRGSS::ShaderedSprite

#blendmode, #shader

Attributes inherited from LiteRGSS::Sprite

#__index__, #angle, #bitmap, #height, #mirror, #opacity, #ox, #oy, #src_rect, #viewport, #visible, #width, #x, #y, #z, #zoom, #zoom_x, #zoom_y

Instance Method Summary collapse

Methods inherited from Sprite

#load, #mouse_in?, #set_origin_div, #set_rect, #set_rect_div, #set_z, #simple_mouse_in?, #translate_mouse_coords

Methods inherited from LiteRGSS::Sprite

new, #set_origin, #set_position

Methods inherited from LiteRGSS::Disposable

#dispose, #disposed?

Constructor Details

#initialize(viewport, index, inbox, mode_handler) ⇒ Cursor

Create a new cusror object

Parameters:

  • viewport (Viewport)
  • index (Integer)

    index of the cursor where it is

  • inbox (Boolean)

    If the cursor is in box or not

  • mode_handler (ModeHandler)


35
36
37
38
39
40
41
42
43
44
45
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00008 Cursor.rb', line 35

def initialize(viewport, index, inbox, mode_handler)
  super(viewport)
  @max_index_box = PFM.storage_class.box_size - 1
  @max_index_battle = PARTY_POSITIONS.size - 1
  @inbox = inbox
  @index = index % (max_index + 1)
  mode_handler.add_selection_mode_ui(self)
  mode_handler.add_mode_ui(self)
  update_position
  set_z(31)
end

Instance Attribute Details

#inboxBoolean

Get the inbox property /!\ Always update this before index

Returns:

  • (Boolean)


10
11
12
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00008 Cursor.rb', line 10

def inbox
  @inbox
end

#indexInteger

Get the index

Returns:



7
8
9
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00008 Cursor.rb', line 7

def index
  @index
end

#modeSymbol

Get the current mode

Returns:

  • (Symbol)


19
20
21
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00008 Cursor.rb', line 19

def mode
  @mode
end

#select_boxBoolean

Get the select box mode

Returns:

  • (Boolean)


13
14
15
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00008 Cursor.rb', line 13

def select_box
  @select_box
end

#selection_modeSymbol

Get the current selection mode

Returns:

  • (Symbol)


16
17
18
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00008 Cursor.rb', line 16

def selection_mode
  @selection_mode
end

Instance Method Details

#done?Boolean

Tell if the animation is done

Returns:

  • (Boolean)


54
55
56
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00008 Cursor.rb', line 54

def done?
  return @animation ? @animation.done? : true
end

#force_index(inbox, index)

Force an index (mouse operation)

Parameters:



74
75
76
77
78
79
80
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00008 Cursor.rb', line 74

def force_index(inbox, index)
  @select_box = false
  @inbox = inbox
  @index = index % (max_index + 1)
  update_position
  self.visible = false
end

#max_indexInteger

Get the max index

Returns:



60
61
62
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00008 Cursor.rb', line 60

def max_index
  return @inbox ? @max_index_box : @max_index_battle
end

#update

Update the animation



48
49
50
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00008 Cursor.rb', line 48

def update
  @animation&.update
end