Class: UI::GenericBase
- Inherits:
-
SpriteStack
- Object
- SpriteStack
- UI::GenericBase
- Defined in:
- scripts/01450 Systems/00000 General/00100 UI Generics/00400 GenericBase.rb
Overview
Generica base UI for most of the scenes
Direct Known Subclasses
Defined Under Namespace
Classes: ControlButton
Constant Summary collapse
- DEFAULT_KEYS =
List of key by default
%i[A X Y B]
- BUTTON_TO_HIDE =
List of button to hide when a text is shown
0..2
Constants inherited from SpriteStack
Instance Attribute Summary collapse
- #background ⇒ Sprite readonly
-
#button_texts ⇒ Array<String>
The texts shown in the button.
-
#ctrl ⇒ Array<ControlButton>
readonly
The control buttons.
-
#keys ⇒ Array<Symbol>
Keys shown in the button.
Attributes inherited from SpriteStack
#animated, #data, #moving, #stack, #viewport, #x, #y
Instance Method Summary collapse
-
#hide_win_text
Hide the “win text”.
-
#initialize(viewport, texts = [], keys = DEFAULT_KEYS, hide_background_and_button: false) ⇒ GenericBase
constructor
Create a new GenericBase UI.
-
#show_win_text(text)
Show the “win text” (bottom text giving information to the player).
-
#update_background_animation
Update the background animation.
-
#win_text_visible? ⇒ Boolean
Tell if the win text is visible.
Methods inherited from SpriteStack
#[], #add_background, #add_line, #add_text, #anime, #anime_delta_set, #dispose, #each, #execute_anime, #move, #move_to, #opacity, #opacity=, #push, #push_sprite, #set_origin, #set_position, #simple_mouse_in?, #size, #stop_animation, #translate_mouse_coords, #update, #update_animation, #update_position, #visible, #visible=, #with_cache, #with_font, #with_surface, #z, #z=
Constructor Details
#initialize(viewport, texts = [], keys = DEFAULT_KEYS, hide_background_and_button: false) ⇒ GenericBase
Create a new GenericBase UI
21 22 23 24 25 26 27 28 29 30 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00400 GenericBase.rb', line 21 def initialize(, texts = [], keys = DEFAULT_KEYS, hide_background_and_button: false) super() @keys = keys create_graphics self. = texts if @button_background.visible = false @ctrl.each {|| .visible = false} end end |
Instance Attribute Details
#background ⇒ Sprite (readonly)
11 12 13 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00400 GenericBase.rb', line 11 def background @background end |
#button_texts ⇒ Array<String>
Returns the texts shown in the button.
7 8 9 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00400 GenericBase.rb', line 7 def @button_texts end |
#ctrl ⇒ Array<ControlButton> (readonly)
Returns the control buttons.
9 10 11 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00400 GenericBase.rb', line 9 def ctrl @ctrl end |
#keys ⇒ Array<Symbol>
Returns keys shown in the button.
5 6 7 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00400 GenericBase.rb', line 5 def keys @keys end |
Instance Method Details
#hide_win_text
Hide the “win text”
60 61 62 63 64 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00400 GenericBase.rb', line 60 def hide_win_text .each { |i| @ctrl[i].visible = true } win_text.visible = false @win_text_background.visible = false end |
#show_win_text(text)
Show the “win text” (bottom text giving information to the player)
51 52 53 54 55 56 57 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00400 GenericBase.rb', line 51 def show_win_text(text) .each { |i| @ctrl[i].visible = false } text_sprite = win_text text_sprite.visible = true text_sprite.text = text @win_text_background.visible = true end |
#update_background_animation
Update the background animation
73 74 75 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00400 GenericBase.rb', line 73 def update_background_animation @background.set_origin((@background.ox - 0.5) % 16, (@background.oy - 0.5) % 16) end |
#win_text_visible? ⇒ Boolean
Tell if the win text is visible
68 69 70 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00400 GenericBase.rb', line 68 def win_text_visible? @win_text_background&.visible end |