Class: GamePlay::Bag

Inherits:
GamePlay::BaseCleanUpdate::FrameBalanced show all
Includes:
BagMixin, UI::Bag, Util::Item
Defined in:
scripts/01450 Systems/00103 Bag/00003 GamePlay/00300 Bag.rb,
scripts/01450 Systems/00103 Bag/00003 GamePlay/00340 Bag_Mouse.rb,
scripts/01450 Systems/00103 Bag/00003 GamePlay/00302 Bag_Inputs.rb,
scripts/01450 Systems/00103 Bag/00003 GamePlay/00320 Bag_Choices.rb,
scripts/01450 Systems/00103 Bag/00003 GamePlay/00330 Bag_Actions.rb,
scripts/01450 Systems/00103 Bag/00003 GamePlay/00301 Bag_Graphics.rb,
scripts/01450 Systems/00103 Bag/00003 GamePlay/00310 Bag_Animations.rb

Overview

Scene responsive of displaying the bag

The bag has various modes :

- :menu : when opened from the menu
- :battle : when opened from the battle
- :berry : when opened to plant berry
- :hold : when opened to give an item to a Pokemon
- :shop : when opened to sell item
- :map : when an event request an item

Direct Known Subclasses

Battle_Bag

Constant Summary collapse

POCKET_NAMES =

List of pocket name

[
  nil.to_s,
  [:text_get, 15, 4], # Items
  [:text_get, 15, 1], # Pokeball
  [:text_get, 15, 5], # CT / CS
  [:text_get, 15, 3], # Berries
  [:text_get, 15, 8], # Key Items
  [:text_get, 15, 0], # Medicine
  [:ext_text, 9000, 150], # Letters
  [:ext_text, 9000, 151] # Favorites
]
POCKETS_PER_MODE =

List of pocket index the player can see according to the modes

{
  menu: [1, 2, 6, 3, 5, 4, 8],
  battle: [2, 6, 4],
  berry: [4],
  hold: [1, 2, 6, 4],
  shop: [1, 2, 6, 3, 4]
}
FAVORITE_POCKET_ID =

ID of the favorite pocket (shortcut)

8
ACTIONS =

List of action the mouse can perform with ctrl button

%i[action_a action_x action_y action_b]
MOUSE_OVER_ENABLED =

Tell if the mouse over is enabled

false
CHOICE_MODE_A =

Constant that list all the choice method called when the player press A depending on the bag mode

{
  menu: :choice_a_menu,
  berry: :choice_a_berry,
  hold: :choice_a_hold,
  shop: :choice_a_shop,
  map: :choice_a_map,
  battle: :choice_a_battle
}
CHOICE_MODE_Y =

Constant that list all the choice called when the player press Y depending on the bag mode

{
  menu: :choice_y_menu
}
SEARCH_CHOICE_INDEX =

Index of the search choice when pressing Y

3
CTRL_TEXTS_PER_MODE =

List of button text according to the mode

{
  menu: [
    [:ext_text, 9000, 152], # Action
    info = [:ext_text, 9000, 153], # Info
    sort = [:ext_text, 9000, 154], # Sort
    [:ext_text, 9000, 115]  # Quit
  ],
  battle: [
    [:ext_text, 9000, 159], # Use
    info, sort,
    cancel = [:ext_text, 9000, 17] # Cancel
  ],
  berry: [
    [:ext_text, 9000, 156], # Plant
    info, sort, cancel
  ],
  hold: [
    [:ext_text, 9000, 157], # Give
    info, sort, cancel
  ],
  shop: [
    [:ext_text, 9000, 155], # Sell
    info, sort, cancel
  ],
  map: [
    [:ext_text, 9000, 158], # Choose
    info, sort, cancel
  ]
}

Constants inherited from BaseCleanUpdate

GamePlay::BaseCleanUpdate::AIU_KEY2METHOD

Constants inherited from Base

GamePlay::Base::DEFAULT_TRANSITION, GamePlay::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 included from BagMixin

#battle_item_wrapper, #mode, #return_data

Attributes inherited from Base

#__last_scene, #__result_process, #running, #viewport

Attributes included from DisplayMessage

#message_window

Instance Method Summary collapse

Methods included from Util::Item

#util_item_on_use_sequence, #util_item_open_party_sequence, #util_item_useitem

Methods included from BagMixin

#selected_item_db_symbol

Methods inherited from GamePlay::BaseCleanUpdate::FrameBalanced

#update

Methods included from Graphics::FPSBalancer::Marker

#frame_balanced?

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(mode = :menu) ⇒ Bag

Create a new Bag Scene

Parameters:

  • mode (Symbol) (defaults to: :menu)

    mode of the bag scene allowing to choose the pocket to show



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'scripts/01450 Systems/00103 Bag/00003 GamePlay/00300 Bag.rb', line 38

def initialize(mode = :menu)
  super()
  @return_data = -1
  @mode = mode
  load_pockets
  @socket_index = $user_data.dig(:psdk_bag, :socket_index, mode) || $bag.last_socket || 0
  @socket_index = @socket_index.clamp(0, @last_socket_index = @pocket_indexes.size - 1)
  load_item_list
  @index = $user_data.dig(:psdk_bag, :index, mode) || $bag.last_index || 0
  @index = @index.clamp(0, @last_index)
  @compact_mode = $user_data.dig(:psdk_bag, :compact_mode) || :enabled
  @searching = false
  Mouse.wheel = 0
end

Instance Method Details

#update_graphics



36
37
38
39
40
# File 'scripts/01450 Systems/00103 Bag/00003 GamePlay/00301 Bag_Graphics.rb', line 36

def update_graphics
  @base_ui.update_background_animation
  @animation&.call
  update_arrow
end

#update_inputs



3
4
5
6
7
8
9
# File 'scripts/01450 Systems/00103 Bag/00003 GamePlay/00302 Bag_Inputs.rb', line 3

def update_inputs
  return false if @animation
  return update_search &&
         update_ctrl_button &&
         update_socket_input &&
         update_list_input
end

#update_mouse(moved) ⇒ Boolean

Update the mouse interactions

Parameters:

  • moved (Boolean)

    if the mouse moved durring the frame

Returns:

  • (Boolean)

    if the thing after can update



10
11
12
13
14
# File 'scripts/01450 Systems/00103 Bag/00003 GamePlay/00340 Bag_Mouse.rb', line 10

def update_mouse(moved)
  return update_mouse_index if Mouse.wheel != 0
  return false if moved && update_mouse_list
  return update_pocket_input && update_ctrl_button_mouse
end