Class: GamePlay::PokemonStorage

Inherits:
BaseCleanUpdate show all
Includes:
Util::GiveTakeItem
Defined in:
scripts/01450 Systems/00200 Storage/00003 GamePlay_Storage/00001 Main.rb,
scripts/01450 Systems/00200 Storage/00003 GamePlay_Storage/00002 Logic.rb,
scripts/01450 Systems/00200 Storage/00003 GamePlay_Storage/00004 Mouse.rb,
scripts/01450 Systems/00200 Storage/00003 GamePlay_Storage/00003 Inputs.rb,
scripts/01450 Systems/00200 Storage/00003 GamePlay_Storage/00005 Choice.rb,
scripts/01450 Systems/00200 Storage/00003 GamePlay_Storage/00006 Actions.rb

Direct Known Subclasses

PokemonTradeStorage

Constant Summary collapse

BASE_UI_KEYS =

List of keys supported by the base UI depending on the mode

regular = %i[A X Y B], # mode = :pokemon
regular, # mode = :item
%i[A L R B], # mode = :battle
regular, # in multi selection
regular, # in single selection
regular, # about to swap
%i[A LEFT RIGHT B], # On the box attempting to change
regular
BASE_UI_TEXTS =

List of texts shown by the base UI depending on the mode

[
  regular = [[:ext_text, 9007, 14], [:get_text, nil], [:ext_text, 9007, 16], [:ext_text, 9007, 15]], # mode = :pokemon
  regular, # mode = :item
  [[:ext_text, 9007, 14], [:ext_text, 9007, 18], [:ext_text, 9007, 19], [:ext_text, 9007, 15]], # mode = :battle
  [[:ext_text, 9007, 14], [:ext_text, 9007, 23], [:ext_text, 9007, 16], [:ext_text, 9007, 20]], # in multi selection
  [[:ext_text, 9007, 14], [:get_text, nil], [:ext_text, 9007, 16], [:ext_text, 9007, 20]], # in single selection
  [[:ext_text, 9007, 17], [:get_text, nil], [:ext_text, 9007, 16], [:ext_text, 9007, 20]], # about to swap
  [[:ext_text, 9007, 21], [:ext_text, 9007, 18], [:ext_text, 9007, 19], [:ext_text, 9007, 15]], # On the box attempting to change
  [[:get_text, nil], [:get_text, nil], [:get_text, nil], [:ext_text, 9007, 22]] # When making a choice
]
MODE_TO_BASE_UI_MODE =

Hash describing which mode to choose in the base UI when we're in detailed mode

{ pokemon: 0, item: 1, battle: 2 }
SELECTION_MODE_ACTIONS =

List of Action depending on the selection mode

{
  detailed: :action_a_detailed,
  fast: :action_a_fast,
  grouped: :action_a_grouped
}
AIU_KEY2METHOD =

List of method called by automatic_input_update when pressing on a key

{
  A: :action_a, B: :action_b, X: :action_x, Y: :action_y,
  L: :action_l, R: :action_r, L2: :action_l2, R2: :action_r2,
  LEFT: :action_left, RIGHT: :action_right, UP: :action_up, DOWN: :action_down
}
CHOICE_BOX_OPTIONS =

List of options shown when choosing the box option

[
  [:text_get, 33, 45], # Change name
  [:text_get, 33, 44], # Change theme
  [:ext_text, 9007, 3], # Add box after
  [:text_get, 33, 38] # Remove
]
MESSAGE_BOX_OPTIONS =

Message shown when choosing the box option

[:ext_text, 9007, 0]
SINGLE_POKEMON_CHOICE =

List of options shown when choosing something for a single pokemon

[
  [:text_get, 33, 39], # Move
  [:text_get, 33, 41], # Summary
  [:text_get, 33, 80], # Give
  [:text_get, 33, 79], # Take
  [:text_get, 33, 42], # Mark
  [:text_get, 33, 81] # Release
]
SINGLE_POKEMON_MESSAGE =

Message shown when manipulating a single Pokemon

[:ext_text, 9007, 1]
SELECTED_POKEMON_MESSAGE =

Message shown when we manipulate various Pokemon

[:ext_text, 9007, 2]
BOX_NAME_MESSAGE =

Message shown when we want to rename a box

[:ext_text, 9007, 4]
BOX_THEME_CHOICE_MESSAGE =

Message shown when choosing the theme

[:ext_text, 9007, 5]
BOX_NEW_NAME_MESSAGE =

Message shown when we want to give a name to the new box

[:ext_text, 9007, 6]
BOX_NEW_DEFAULT_NAME =

New box name

[:ext_text, 9007, 7]
REMOVE_BOX_MESSAGE =

Message shown to confirm if we want to remove the box

[:ext_text, 9007, 8]
REMOVE_BOX_CHOICES =

Choice option for remove box confirmation

[
  [:text_get, 33, 84], # No
  [:text_get, 33, 83] # Yes
]
MOVE_POKEMON_MESSAGE =

Message shown when we want to move a Pokemon

[:ext_text, 9007, 9]
MOVE_SELECTED_POKEMON_MESSAGE =

Message shown when we want to move several Pokemon

[:ext_text, 9007, 10]
RELEASE_POKEMON_MESSAGE1 =

Message shown when we try to release a Pokemon

[:ext_text, 9007, 11]
RELEASE_POKEMON_CHOICES =

Choice option for release pokemon confirmation

[
  [:text_get, 33, 84], # No
  [:text_get, 33, 83] # Yes
]
RELEASE_SELECTED_POKEMON_MESSAGE =

Message shown when we try to release several Pokemon

[:ext_text, 9007, 12]

Constants inherited from Base

Base::DEFAULT_TRANSITION, Base::DEFAULT_TRANSITION_PARAMETER

Constants included from Input

Input::ALIAS_KEYS, Input::AXIS_MAPPING, Input::AXIS_SENSITIVITY, Input::DEAD_ZONE, Input::Keyboard, Input::Keys, Input::NON_TRIGGER_ZONE, Input::REPEAT_COOLDOWN, Input::REPEAT_SPACE

Constants included from DisplayMessage

DisplayMessage::MESSAGE_ERROR, DisplayMessage::MESSAGE_PROCESS_ERROR

Instance Attribute Summary

Attributes inherited from Base

#__last_scene, #__result_process, #running, #viewport

Attributes included from DisplayMessage

#message_window

Instance Method Summary collapse

Methods included from Util::GiveTakeItem

#givetake_give_egg_message, #givetake_give_item, #givetake_give_item_message, #givetake_give_item_update_state, #givetake_take_item

Methods inherited from BaseCleanUpdate

#automatic_input_update, #update

Methods inherited from Base

#add_disposable, #call_scene, #dispose, #find_parent, #main, #return_to_scene, #snap_to_bitmap, #update, #visible, #visible=

Methods included from Input

dir4, dir8, get_text, joy_axis_position, press?, register_events, released?, repeat?, swap_states, trigger?

Methods included from DisplayMessage

#can_display_message_be_called?, #close_message_window, #display_message, #display_message_and_wait, #message_class, #message_processing?, #message_visible, #message_visible=

Constructor Details

#initialize(storage = $storage, party = $actors) ⇒ PokemonStorage

Create a new Storage Scene

Parameters:

  • storage (PFM::Storage) (defaults to: $storage)

    the current storage object

  • party (Array<PFM::Pokemon>) (defaults to: $actors)


30
31
32
33
34
35
36
37
38
39
# File 'scripts/01450 Systems/00200 Storage/00003 GamePlay_Storage/00001 Main.rb', line 30

def initialize(storage = $storage, party = $actors)
  super()
  @storage = storage
  @party = party
  @index = storage.current_box
  @battle_index = 0
  @mouse_actions = BASE_UI_KEYS.map { |arr| arr.map { |v| AIU_KEY2METHOD[v] || :action_b } }
  @moving_pokemon = false
  Mouse.wheel = 0
end

Instance Method Details

#refresh

Refresh everything in the UI



4
5
6
7
8
9
10
# File 'scripts/01450 Systems/00200 Storage/00003 GamePlay_Storage/00002 Logic.rb', line 4

def refresh
  @composition.storage = @storage
  @composition.party = @party
  update_summary
  update_mode
  @selection.update_selection
end

#update_graphics



41
42
43
44
# File 'scripts/01450 Systems/00200 Storage/00003 GamePlay_Storage/00001 Main.rb', line 41

def update_graphics
  @composition.update
  @base_ui&.update_background_animation
end

#update_inputs

Update the input of the scene



17
18
19
20
21
# File 'scripts/01450 Systems/00200 Storage/00003 GamePlay_Storage/00003 Inputs.rb', line 17

def update_inputs
  return false unless @composition.done?

  return automatic_input_update(AIU_KEY2METHOD)
end

#update_mouse(moved)

Update the mouse action



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'scripts/01450 Systems/00200 Storage/00003 GamePlay_Storage/00004 Mouse.rb', line 4

def update_mouse(moved)
  if Mouse.wheel != 0
    mouse_wheel_action
  elsif Mouse.trigger?(:LEFT)
    mouse_left_action
  elsif Mouse.trigger?(:RIGHT)
    mouse_right_action
  elsif moved
    mouse_moved_action
  else
    update_mouse_ctrl_buttons(@base_ui.ctrl, @mouse_actions[@base_ui.mode])
  end
  return false
end