Class: PFM::Choice_Helper
- Defined in:
- scripts/01450 Systems/00000 General/00001 PFM/00200 Helpers/00200 Choice_Helper.rb
Overview
Class that help to make choice inside Interfaces
Instance Method Summary collapse
-
#cancel
Cancel the choice from outside.
-
#display_choice(viewport, x, y, width, *args, on_update: nil, align_right: false) ⇒ Integer
Display the choice.
-
#initialize(klass, can_cancel = true, cancel_index = nil) ⇒ Choice_Helper
constructor
Create a new Choice_Helper.
-
#register_choice(text, *args, disable_detect: nil, on_validate: nil, color: nil) ⇒ self
Register a choice.
-
#size ⇒ Integer
Return the number of choices (for calculation).
Constructor Details
#initialize(klass, can_cancel = true, cancel_index = nil) ⇒ Choice_Helper
Create a new Choice_Helper
8 9 10 11 12 13 14 15 16 17 |
# File 'scripts/01450 Systems/00000 General/00001 PFM/00200 Helpers/00200 Choice_Helper.rb', line 8 def initialize(klass, can_cancel = true, cancel_index = nil) # List of registered choices # @type [Array<Hash>] @choices = [] # Class used to display the choice # @type [Class] @class = klass @can_cancel = can_cancel @cancel_index = cancel_index end |
Instance Method Details
#cancel
Cancel the choice from outside
26 27 28 |
# File 'scripts/01450 Systems/00000 General/00001 PFM/00200 Helpers/00200 Choice_Helper.rb', line 26 def cancel @canceled = true end |
#display_choice(viewport, x, y, width, *args, on_update: nil, align_right: false) ⇒ Integer
Display the choice
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'scripts/01450 Systems/00000 General/00001 PFM/00200 Helpers/00200 Choice_Helper.rb', line 51 def display_choice(, x, y, width, *args, on_update: nil, align_right: false) @canceled = false # @type [Yuki::ChoiceWindow] window = build_choice_window(, x, y, width, align_right) loop do Graphics.update next if Graphics::FPSBalancer.global.skipping? && (!$scene. || $scene..can_sub_window_be_updated?) window.update on_update&.call(*args) break if check_cancel(window) break if check_validate(window) end $game_system.se_play($data_system.decision_se) index = window.index window.dispose call_validate_handle(index) return index end |
#register_choice(text, *args, disable_detect: nil, on_validate: nil, color: nil) ⇒ self
Register a choice
37 38 39 40 |
# File 'scripts/01450 Systems/00000 General/00001 PFM/00200 Helpers/00200 Choice_Helper.rb', line 37 def register_choice(text, *args, disable_detect: nil, on_validate: nil, color: nil) @choices << { text: text, args: args, disable_detect: disable_detect, on_validate: on_validate, color: color } return self end |
#size ⇒ Integer
Return the number of choices (for calculation)
21 22 23 |
# File 'scripts/01450 Systems/00000 General/00001 PFM/00200 Helpers/00200 Choice_Helper.rb', line 21 def size return @choices.size end |