Class: BattleUI::GenericChoice
- Inherits:
-
UI::SpriteStack
- Object
- UI::SpriteStack
- BattleUI::GenericChoice
- Includes:
- GoingInOut, HideShow, UI
- Defined in:
- scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00107 GenericChoice.rb
Overview
Class that allow a choice do be made
The object tells the player validated on #validated? and the result is stored inside #result
The object should be updated through #update otherwise no validation is possible
When result was taken, the scene should call #reset to undo the validated state
The goal of this class is to provide the cursor handling. You have to define the buttons! Here's the list of methods you should define
- create_buttons
- create_sub_choice (add the subchoice as a stack item! & store it in @sub_choice)
- validate (set the result to the proper value)
- update_key_index
To allow flexibility (sub actions) this generic choice allow you to define a “sub generic” choice that only needs to responds to #update, #reset and #done? in @sub_choice
Direct Known Subclasses
Constant Summary collapse
- CURSOR_OFFSET_X =
Offset X of the cursor compared to the element it shows
-10 # Offset Y of the cursor compared to the element it shows
- CURSOR_OFFSET_Y =
Offset Y of the cursor compared to the element it shows
6
Constants inherited from UI::SpriteStack
UI::SpriteStack::NO_INITIAL_IMAGE
Instance Attribute Summary collapse
-
#animation_handler ⇒ Yuki::Animation::Handler{ Symbol => Yuki::Animation::TimedAnimation}
readonly
Get the animation handler.
-
#scene ⇒ Battle::Scene
readonly
Get the scene.
Attributes inherited from UI::SpriteStack
#animated, #data, #moving, #stack, #viewport, #x, #y
Instance Method Summary collapse
-
#done? ⇒ Boolean
Tell if all animations are done.
-
#initialize(viewport, scene) ⇒ GenericChoice
constructor
Create a new GenericChoice.
-
#reset
Reset the choice.
-
#update
Update the Window cursor.
Methods included from GoingInOut
Methods included from HideShow
Methods inherited from UI::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_animation, #update_position, #visible, #visible=, #with_cache, #with_font, #with_surface, #z, #z=
Constructor Details
#initialize(viewport, scene) ⇒ GenericChoice
Create a new GenericChoice
37 38 39 40 41 42 43 44 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00107 GenericChoice.rb', line 37 def initialize(, scene) super(, .rect.width) @scene = scene @animation_handler = Yuki::Animation::Handler.new @index = 0 create_sprites @__in_out = :out end |
Instance Attribute Details
#animation_handler ⇒ Yuki::Animation::Handler{ Symbol => Yuki::Animation::TimedAnimation} (readonly)
Get the animation handler
29 30 31 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00107 GenericChoice.rb', line 29 def animation_handler @animation_handler end |
#scene ⇒ Battle::Scene (readonly)
Get the scene
32 33 34 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00107 GenericChoice.rb', line 32 def scene @scene end |
Instance Method Details
#done? ⇒ Boolean
Tell if all animations are done
65 66 67 68 69 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00107 GenericChoice.rb', line 65 def done? return false if @sub_choice && !@sub_choice.done? return @animation_handler.done? end |
#reset
Reset the choice
72 73 74 75 76 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00107 GenericChoice.rb', line 72 def reset @result = nil @sub_choice&.reset update_cursor(true) end |
#update
Update the Window cursor
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'scripts/01600 Alpha 25 Battle Engine/00001 Battle_Scene/00001 BattleUI/00107 GenericChoice.rb', line 47 def update @animation_handler.update return unless in? super return unless done? return if validated? return validate if validating? return cancel if canceling? last_index = @index update_key_index update_mouse_index update_cursor if last_index != @index end |