Class: UI::Storage::CursorHandler

Inherits:
Object
  • Object
show all
Defined in:
scripts/01450 Systems/00200 Storage/00002 UI_Storage/00011 CursorHandler.rb

Overview

Class that handle all the logic related to cursor movement between each party of the UI

Instance Method Summary collapse

Constructor Details

#initialize(cursor) ⇒ CursorHandler

Create a cusor handler

Parameters:



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

def initialize(cursor)
  @cursor = cursor
end

Instance Method Details

#indexInteger

Get the index of the cursor

Returns:



22
23
24
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00011 CursorHandler.rb', line 22

def index
  @cursor.index
end

#modeSymbol

Get the cursor mode

Returns:

  • (Symbol)

    :box, :party, :box_choice



13
14
15
16
17
18
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00011 CursorHandler.rb', line 13

def mode
  return :box if @cursor.inbox
  return :box_choice if @cursor.select_box

  return :party
end

#move_downBoolean

Move the cursor down

Returns:

  • (Boolean)

    if the action was a success



60
61
62
63
64
65
66
67
68
69
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00011 CursorHandler.rb', line 60

def move_down
  @cursor.visible = true
  if @cursor.select_box
    @cursor.inbox = true
    @cursor.index = @cursor.index
  else
    @cursor.index += @cursor.inbox ? 6 : 2
  end
  return true
end

#move_leftBoolean

Move the cursor to the left

Returns:

  • (Boolean)

    if the action was a success



37
38
39
40
41
42
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00011 CursorHandler.rb', line 37

def move_left
  @cursor.visible = true
  return false if @cursor.select_box

  return @cursor.inbox ? move_left_inbox : move_left_party
end

#move_rightBoolean

Move the cursor to the right

Returns:

  • (Boolean)

    if the action was a success



28
29
30
31
32
33
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00011 CursorHandler.rb', line 28

def move_right
  @cursor.visible = true
  return false if @cursor.select_box

  return @cursor.inbox ? move_right_inbox : move_right_party
end

#move_upBoolean

Move the cursor up

Returns:

  • (Boolean)

    if the action was a success



46
47
48
49
50
51
52
53
54
55
56
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00011 CursorHandler.rb', line 46

def move_up
  @cursor.visible = true
  return false if @cursor.select_box

  if @cursor.inbox && @cursor.index <= 5
    @cursor.select_box = true
  else
    @cursor.index -= @cursor.inbox ? 6 : 2
  end
  return true
end