Class: UI::Options::Button
- Inherits:
-
SpriteStack
- Object
- SpriteStack
- UI::Options::Button
- Defined in:
- scripts/01450 Systems/00105 Options/00002 UI/00003 Button.rb
Constant Summary collapse
- OPTION_OFFSET_Y =
40
- OPTION_BASE_X =
19
- OPTION_OFFSET_X =
4
Constants inherited from SpriteStack
Instance Attribute Summary collapse
-
#option ⇒ GamePlay::Options::Helper
readonly
Option modified by the button.
-
#value ⇒ Option
Current value shown by the button.
Attributes inherited from SpriteStack
#animated, #data, #moving, #stack, #viewport, #x, #y
Instance Method Summary collapse
-
#initialize(viewport, index, option) ⇒ Button
constructor
Create a new Option Button.
-
#reload_texts
Reload the name of the button for when the language is changed in the options.
-
#value_index ⇒ Integer
Return the value index.
-
#value_text ⇒ String
Retreive the option value text.
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, index, option) ⇒ Button
Create a new Option Button
17 18 19 20 21 22 23 24 |
# File 'scripts/01450 Systems/00105 Options/00002 UI/00003 Button.rb', line 17 def initialize(, index, option) super(, OPTION_BASE_X, OPTION_OFFSET_Y * index) @option = option @value = option.current_value @option_background = add_background('options/option') @option_name = add_text(8, 3, 0, 16, @option.name, color: 10) @option_value = add_text(14, 19, 96, 16, value_text, 1) end |
Instance Attribute Details
#option ⇒ GamePlay::Options::Helper (readonly)
Option modified by the button
9 10 11 |
# File 'scripts/01450 Systems/00105 Options/00002 UI/00003 Button.rb', line 9 def option @option end |
#value ⇒ Option
Current value shown by the button
12 13 14 |
# File 'scripts/01450 Systems/00105 Options/00002 UI/00003 Button.rb', line 12 def value @value end |
Instance Method Details
#reload_texts
Reload the name of the button for when the language is changed in the options
48 49 50 51 |
# File 'scripts/01450 Systems/00105 Options/00002 UI/00003 Button.rb', line 48 def reload_texts @option_name.text = @option.name @option_value.text = value_text end |
#value_index ⇒ Integer
Return the value index
28 29 30 31 |
# File 'scripts/01450 Systems/00105 Options/00002 UI/00003 Button.rb', line 28 def value_index return @value if @option.type == :slider @option.values.index(@value) || 0 end |
#value_text ⇒ String
Retreive the option value text
42 43 44 45 |
# File 'scripts/01450 Systems/00105 Options/00002 UI/00003 Button.rb', line 42 def value_text return format(@option.values_text, @value) if @option.type == :slider @option.values_text[value_index] end |