Class: GamePlay::NameInput

Inherits:
BaseCleanUpdate::FrameBalanced show all
Includes:
NameInputMixin
Defined in:
scripts/01450 Systems/00205 Input/00003 GamePlay/00700 NameInput.rb

Direct Known Subclasses

NumberInput

Constant Summary collapse

DEFAULT_HINT =

Hint shown about how to enter name

[:ext_text, 9000, 162]
GUESSED_PHRASE =

GUESSED PHRASE when not given

[:ext_text, 9000, 163]

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

DisplayMessage::MESSAGE_ERROR, DisplayMessage::MESSAGE_PROCESS_ERROR

Instance Attribute Summary

Attributes included from NameInputMixin

#return_name

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, #dispose, #find_parent, #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(default_name, max_length, character = nil, phrase: nil) ⇒ NameInput

Create a new NameInput scene

Parameters:

  • default_name (String)

    the choosen name if no choice

  • max_length (Integer)

    the maximum number of characters in the choosen name

  • character (PFM::Pokemon, String, nil) (defaults to: nil)

    the character to display

  • phrase (String, nil) (defaults to: nil)

    phrase to show in order to display the name



13
14
15
16
17
18
19
20
# File 'scripts/01450 Systems/00205 Input/00003 GamePlay/00700 NameInput.rb', line 13

def initialize(default_name, max_length, character = nil, phrase: nil)
  super()
  @return_name = @default_name = default_name[0, max_length].dup.force_encoding(Encoding::UTF_8)
  @input_name = @default_name.chars
  @max_length = max_length
  @character = character
  @phrase = phrase || guess_phrase
end

Instance Method Details

#mainself

Make main return self for compatibility

Returns:

  • (self)


41
42
43
44
# File 'scripts/01450 Systems/00205 Input/00003 GamePlay/00700 NameInput.rb', line 41

def main
  super
  return self
end

#update_graphics

Update the graphics of the scene



33
34
35
36
37
# File 'scripts/01450 Systems/00205 Input/00003 GamePlay/00700 NameInput.rb', line 33

def update_graphics
  @base_ui&.update_background_animation
  @name_input_ui&.update
  @hint_ui&.update
end

#update_inputsBoolean

Update the inputs of the scene

Returns:

  • (Boolean)

    if the other “input” related updates can be called



24
25
26
27
28
29
30
# File 'scripts/01450 Systems/00205 Input/00003 GamePlay/00700 NameInput.rb', line 24

def update_inputs
  if (text = Input.get_text)
    update_name(text.chars)
    return false
  end
  return joypad_update_inputs && true
end