Class: GamePlay::Dex

Inherits:
BaseCleanUpdate::FrameBalanced show all
Includes:
UI
Defined in:
scripts/01450 Systems/00101 Dex/00003 GamePlay/00100 Dex.rb,
scripts/01450 Systems/00101 Dex/00003 GamePlay/00101 Dex_Graphics.rb

Overview

Class that shows the Pokedex

Constant Summary collapse

NAME_FORMAT =

Text format for the name

'%03d - %s'
ACTIONS =

Array of actions to do according to the pressed button

%i[action_A action_X action_Y action_B]

Constants inherited from BaseCleanUpdate

BaseCleanUpdate::AIU_KEY2METHOD

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

GamePlay::DisplayMessage::MESSAGE_ERROR, GamePlay::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 inherited from 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, #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(page_id = false) ⇒ Dex

Create a new Pokedex interface

Parameters:



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'scripts/01450 Systems/00101 Dex/00003 GamePlay/00100 Dex.rb', line 12

def initialize(page_id = false)
  # We call initialize from GamePlay::Base without arguments to take the default
  super()

  # Pokemon used to generate the list sprites (icon & name)
  @pokemonlist = PFM::Pokemon.new(data_dex($pokedex.variant).creatures.first&.db_symbol || 1, 1)
  # Information telling in which direction (in x) the arrow goes
  @arrow_direction = 1
  # Current state
  @state = page_id ? 1 : 0
  # Current page id
  @page_id = page_id.is_a?(PFM::Pokemon) ? page_id.id : page_id
  @pkmn = page_id.is_a?(PFM::Pokemon) ? page_id.dup : nil
  # Generation of the Pokemon we can see (& adjust page id)
  generate_selected_pokemon_array(page_id)
  # Generation of the Pokemon object used to show the Pokemon info
  generate_pokemon_object
  # We reset the mousewell to prevent issue with scrolling
  Mouse.wheel = 0
end

Instance Method Details

#create_graphics

Create all the graphics



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'scripts/01450 Systems/00101 Dex/00003 GamePlay/00101 Dex_Graphics.rb', line 4

def create_graphics
  create_viewport
  create_base_ui
  unless @page_id # If we're only showing a Pokemon Dex info we'll not create the other sprites
    create_list
    create_arrow
    create_scroll_bar
    create_progression
    create_worldmap
  end
  create_face
  create_frame
  create_info
  # We update the state to give the dex an initial state before it shows
  change_state(@state)
end

#update_graphics

Update all the graphics



22
23
24
25
26
# File 'scripts/01450 Systems/00101 Dex/00003 GamePlay/00101 Dex_Graphics.rb', line 22

def update_graphics
  @base_ui.update_background_animation
  update_arrow
  @pokeface.update_graphics
end

#update_inputs

Update the UI inputs



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'scripts/01450 Systems/00101 Dex/00003 GamePlay/00100 Dex.rb', line 34

def update_inputs
  return action_A if Input.trigger?(:A)
  return action_X if Input.trigger?(:X)
  return action_Y if Input.trigger?(:Y)
  return action_B if Input.trigger?(:B)
  return false if @page_id

  if @state == 0 # Liste
    max_index = @selected_pokemons.size - 1
    if index_changed(:@index, :UP, :DOWN, max_index)
      update_index
    elsif index_changed!(:@index, :LEFT, :RIGHT, max_index)
      9.times { index_changed!(:@index, :LEFT, :RIGHT, max_index) }
      update_index
    elsif Mouse.wheel != 0
      @index = (@index - Mouse.wheel) % (max_index + 1)
      Mouse.wheel = 0
      update_index
    end
  elsif @state == 1 # Description
    max_index = @selected_pokemons.size - 1
    update_index_descr if index_changed(:@index, :UP, :DOWN, max_index)
  elsif @state == 2
    @pokemon_worldmap.update
  end
end

#update_mouse(_moved = false)

Update the mouse interaction with the ctrl buttons

Parameters:

  • _moved (Boolean) (defaults to: false)

    if the mouse moved during the frame



63
64
65
# File 'scripts/01450 Systems/00101 Dex/00003 GamePlay/00100 Dex.rb', line 63

def update_mouse(_moved = false)
  update_mouse_ctrl_buttons(@ctrl, ACTIONS)
end