Class: UI::NameInputUI
- Inherits:
-
Window
- Object
- LiteRGSS::Disposable
- LiteRGSS::Drawable
- LiteRGSS::Window
- Window
- UI::NameInputUI
- Defined in:
- scripts/01450 Systems/00205 Input/00002 UI/00002 NameInputUI.rb
Constant Summary collapse
- NO_CHAR =
Character used to indicate there's no char there
'_'
Instance Attribute Summary collapse
-
#chars ⇒ Array<String>
readonly
Return the chars the user has inserted.
Attributes inherited from LiteRGSS::Window
#__index__, #active, #back_opacity, #contents_opacity, #cursor_rect, #cursorskin, #height, #opacity, #ox, #oy, #pause, #pause_x, #pause_y, #pauseskin, #stretch, #viewport, #visible, #width, #window_builder, #windowskin, #x, #y, #z
Instance Method Summary collapse
- #add_char(char)
-
#initialize(viewport, max_size, chars, character, phrase) ⇒ NameInputUI
constructor
Create a new NameInputUI.
- #remove_char
- #update
Methods inherited from Window
#simple_mouse_in?, #translate_mouse_coords
Methods inherited from LiteRGSS::Window
#lock, #locked?, new, #set_origin, #set_position, #set_size, #unlock
Methods inherited from LiteRGSS::Disposable
Constructor Details
#initialize(viewport, max_size, chars, character, phrase) ⇒ NameInputUI
Create a new NameInputUI
14 15 16 17 18 19 20 21 22 23 |
# File 'scripts/01450 Systems/00205 Input/00002 UI/00002 NameInputUI.rb', line 14 def initialize(, max_size, chars, character, phrase) super(, *window_parameters, skin: default_windowskin) @character = character @phrase = phrase @chars = chars @index = 0 @max_size = max_size create_graphics @counter = 0 end |
Instance Attribute Details
#chars ⇒ Array<String> (readonly)
Return the chars the user has inserted
5 6 7 |
# File 'scripts/01450 Systems/00205 Input/00002 UI/00002 NameInputUI.rb', line 5 def chars @chars end |
Instance Method Details
#add_char(char)
25 26 27 28 29 |
# File 'scripts/01450 Systems/00205 Input/00002 UI/00002 NameInputUI.rb', line 25 def add_char(char) return if @chars.size >= @max_size @chars.push(char) refresh_chars end |
#remove_char
31 32 33 34 |
# File 'scripts/01450 Systems/00205 Input/00002 UI/00002 NameInputUI.rb', line 31 def remove_char @chars.pop refresh_chars end |
#update
36 37 38 39 40 41 42 43 44 45 |
# File 'scripts/01450 Systems/00205 Input/00002 UI/00002 NameInputUI.rb', line 36 def update @counter += 1 if @counter == 30 @inputs[@chars.size]&.visible = false elsif @counter == 60 @inputs[@chars.size]&.visible = true @counter = 0 end @character_sprite&.update end |