Class: UI::KeyBinding
- Inherits:
-
KeyShortcut
- Object
- LiteRGSS::Disposable
- LiteRGSS::Drawable
- LiteRGSS::Sprite
- LiteRGSS::ShaderedSprite
- Sprite
- KeyShortcut
- UI::KeyBinding
- Defined in:
- scripts/01450 Systems/00000 General/00100 UI Generics/00600 KeyShortcut.rb
Overview
Class that allow to show a binding of a specific key
Constant Summary
Constants inherited from KeyShortcut
UI::KeyShortcut::KeyIndex, UI::KeyShortcut::NUMPAD_KEY_INDEX
Instance Attribute Summary collapse
-
#index ⇒ Integer
readonly
The index of the key in the Keys array.
-
#key ⇒ Symbol
readonly
The key the button describe.
Attributes inherited from LiteRGSS::ShaderedSprite
Attributes inherited from LiteRGSS::Sprite
#__index__, #angle, #bitmap, #height, #mirror, #opacity, #ox, #oy, #src_rect, #viewport, #visible, #width, #x, #y, #z, #zoom, #zoom_x, #zoom_y
Instance Method Summary collapse
-
#find_key(key)
Find the key rect in the Sprite according to the input key requested.
-
#initialize(viewport, key, index) ⇒ KeyBinding
constructor
Create a new KeyBinding sprite.
-
#update
Update the key.
Methods inherited from KeyShortcut
Methods inherited from Sprite
#load, #mouse_in?, #set_origin_div, #set_rect, #set_rect_div, #set_z, #simple_mouse_in?, #translate_mouse_coords
Methods inherited from LiteRGSS::Sprite
new, #set_origin, #set_position
Methods inherited from LiteRGSS::Disposable
Constructor Details
#initialize(viewport, key, index) ⇒ KeyBinding
Create a new KeyBinding sprite
57 58 59 60 61 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00600 KeyShortcut.rb', line 57 def initialize(, key, index) @index = index @key = key super(, key, false) end |
Instance Attribute Details
#index ⇒ Integer (readonly)
Returns the index of the key in the Keys array.
52 53 54 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00600 KeyShortcut.rb', line 52 def index @index end |
#key ⇒ Symbol (readonly)
Returns the key the button describe.
50 51 52 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00600 KeyShortcut.rb', line 50 def key @key end |
Instance Method Details
#find_key(key)
Find the key rect in the Sprite according to the input key requested
65 66 67 68 69 70 71 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00600 KeyShortcut.rb', line 65 def find_key(key) key_val = Input::Keys[key][@index] || -1 if (id = KeyIndex.index(key_val) || NUMPAD_KEY_INDEX.index(key_val)) return set_rect_div(id % 10, id / 10, 10, 5) end set_rect_div(9, 4, 10, 5) # A blank key end |
#update
Update the key
74 75 76 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00600 KeyShortcut.rb', line 74 def update find_key(@key) end |