Class: UI::Storage::ModeHandler

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

Overview

Class responsive of handling the mode for the PC UI

Constant Summary collapse

AVAILABLE_MODES =

List the available modes

%i[pokemon item battle]
AVAILABLE_SELECTION_MODES =

List the available modes

%i[detailed fast grouped]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mode, selection_mode) ⇒ ModeHandler

Create a new Mode Handler

Parameters:

  • selection_mode (Symbol)

    :detailed, :fast or :grouped



17
18
19
20
21
22
23
24
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00010 ModeHandler.rb', line 17

def initialize(mode, selection_mode)
  # @type [Array<#mode=>]
  @mode_uis = []
  # @type [Array<#selection_mode=>]
  @select_mode_uis = []
  self.mode = mode
  self.selection_mode = selection_mode
end

Instance Attribute Details

#modeSymbol

Get the current mode

Returns:

  • (Symbol)

    :pokemon, :item, :battle, :box



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

def mode
  @mode
end

#selection_modeSymbol

Get the current selection mode

Returns:

  • (Symbol)

    :detailed, :fast, :grouped



12
13
14
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00010 ModeHandler.rb', line 12

def selection_mode
  @selection_mode
end

Instance Method Details

#add_mode_ui(mode_ui)

Add a mode ui

Parameters:



28
29
30
31
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00010 ModeHandler.rb', line 28

def add_mode_ui(mode_ui)
  @mode_uis << mode_ui
  mode_ui.mode = @mode
end

#add_selection_mode_ui(selection_mode_ui)

Add a selection mode ui

Parameters:



35
36
37
38
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00010 ModeHandler.rb', line 35

def add_selection_mode_ui(selection_mode_ui)
  @select_mode_uis << selection_mode_ui
  selection_mode_ui.selection_mode = @selection_mode
end

#swap_modeSymbol

Swap the mode

Returns:

  • (Symbol)


62
63
64
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00010 ModeHandler.rb', line 62

def swap_mode
  self.mode = AVAILABLE_MODES[AVAILABLE_MODES.index(@mode) + 1] || AVAILABLE_MODES.first
end

#swap_selection_modeSymbol

Swap the selection mode

Returns:

  • (Symbol)


68
69
70
# File 'scripts/01450 Systems/00200 Storage/00002 UI_Storage/00010 ModeHandler.rb', line 68

def swap_selection_mode
  self.selection_mode = AVAILABLE_SELECTION_MODES[AVAILABLE_SELECTION_MODES.index(@selection_mode) + 1] || AVAILABLE_SELECTION_MODES.first
end