Module: Util::SystemMessage
- Included in:
- Interpreter
- Defined in:
- scripts/01450 Systems/00004 Message/00650 SystemMessage.rb
Overview
Module that help showing system message.
How to use it : “`ruby
include Util::SystemMessage
# ...
show_message(:message_name) # Basic message
if yes_no_choice(load_message(:message_name)) # Choice from interpreter
show_message(:message_name, pokemon: pokemon) # Will set PKNICK[0] & PKNAME[0]
show_message(:message_name, pokemon_1: pokemon) # Will set PKNICK[1] & PKNAME[1]
show_message(:message_name, item: item_id, pokemon: pokemon) # Will set ITEM2[0], PKNICK[0] & PKNAME[0]
show_message_and_wait(:message_name) # Will wait until the message box disappear
“`
How to define “:message_name”s :
- Simple message (from RH) : `Util::SystemMessage::MESSAGES[:message_name] = [:text_get, id, line]`
- Complex message : `Util::SystemMessage::MESSAGES[:message_name] = proc { |opts| next(message_contents) }`
Note : opts are the optionnals arguments sent to show_message
Constant Summary collapse
- MESSAGES =
List of message by name
{ received_pokemon: [:ext_text, 8999, 15], give_nickname_question: [:ext_text, 8999, 16], is_nickname_correct_qesion: [:ext_text, 8999, 17], pokemon_stored_to_box: [:ext_text, 8999, 18], bag_store_item_in_pocket: [:text_get, 41, 9], pokemon_shop_unavailable: [:ext_text, 9003, 1] }
- HAS_NUMBER_REG =
Capture regexp
/_([0-9]+)$/
- IS_POKEMON =
Tell if the key contain pokemon
/^pokemon/
- IS_ITEM =
Tell if the key contain item
/^item/
- IS_NUMBER1 =
Tell if the key contain num1
/^num1/
- IS_NUMBER2 =
Tell if the key contain num2
/^num2/
- IS_NUMBER3 =
Tell if the key contain num3
/^num3/
Class Method Summary collapse
-
.load_message(message_name, opts = nil)
Load a message.
-
.parse_opts(opts)
Parse the message opts.
-
.show_message(message_name, opts = nil)
Show a message.
-
.show_message_and_wait(message_name, opts = nil)
Show a message.
Class Method Details
.load_message(message_name, opts = nil)
Load a message
48 49 50 51 52 53 54 55 56 57 |
# File 'scripts/01450 Systems/00004 Message/00650 SystemMessage.rb', line 48 def (, opts = nil) PFM::Text.reset_variables parse_opts(opts) if opts = MESSAGES[] string = .is_a?(Array) ? send(*) : .call(opts) string = opts[:header] + string if opts&.key?(:header) return PFM::Text.(string.dup) ensure PFM::Text.reset_variables end |
.parse_opts(opts)
Parse the message opts
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'scripts/01450 Systems/00004 Message/00650 SystemMessage.rb', line 89 def parse_opts(opts) text_handler = PFM::Text opts.each do |key, value| next text_handler.set_variable(key, value) if key.is_a?(String) number = key.match(HAS_NUMBER_REG)&.captures&.first&.to_i || 0 if key.match?(IS_POKEMON) text_handler.set_pkname(value, number) text_handler.set_pknick(value, number) elsif key.match?(IS_ITEM) text_handler.set_item_name(value, number) elsif key.match?(IS_NUMBER1) text_handler.set_num1(value, number) elsif key.match?(IS_NUMBER2) text_handler.set_num2(value, number) elsif key.match?(IS_NUMBER3) text_handler.set_num3(value, number) end end end |
.show_message(message_name, opts = nil)
Show a message
62 63 64 65 66 67 68 69 70 71 |
# File 'scripts/01450 Systems/00004 Message/00650 SystemMessage.rb', line 62 def (, opts = nil) = (, opts) if is_a?(Interpreter) () elsif is_a?(Scene_Map) || is_a?(GamePlay::Base) () else $scene.() end end |
.show_message_and_wait(message_name, opts = nil)
Show a message
76 77 78 79 80 81 82 83 84 85 |
# File 'scripts/01450 Systems/00004 Message/00650 SystemMessage.rb', line 76 def (, opts = nil) = (, opts) if is_a?(GamePlay::Base) return () elsif is_a?(Interpreter) () else $scene.() end end |