mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 14:14:59 +00:00
Added hide_choice and rename_choice which alter the next set of choices shown by an event
This commit is contained in:
@@ -35,6 +35,8 @@ class Interpreter
|
|||||||
@child_interpreter = nil # child interpreter
|
@child_interpreter = nil # child interpreter
|
||||||
@branch = {} # branch data
|
@branch = {} # branch data
|
||||||
@buttonInput = false
|
@buttonInput = false
|
||||||
|
@hidden_choices = []
|
||||||
|
@renamed_choices = []
|
||||||
end_follower_overrides
|
end_follower_overrides
|
||||||
end
|
end
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -189,10 +189,8 @@ class Interpreter
|
|||||||
# Display the text, with choices/number choosing if appropriate
|
# Display the text, with choices/number choosing if appropriate
|
||||||
@message_waiting = true # Lets parallel process events work while a message is displayed
|
@message_waiting = true # Lets parallel process events work while a message is displayed
|
||||||
if choices
|
if choices
|
||||||
cmd_texts = []
|
command = pbMessage(message + message_end, choices[0], choices[1])
|
||||||
choices[0].each { |cmd| cmd_texts.push(_MAPINTL($game_map.map_id, cmd)) }
|
@branch[@list[@index].indent] = choices[2][command] || command
|
||||||
command = pbMessage(message + message_end, cmd_texts, choices[1])
|
|
||||||
@branch[@list[@index].indent] = command
|
|
||||||
elsif number_input_variable
|
elsif number_input_variable
|
||||||
params = ChooseNumberParams.new
|
params = ChooseNumberParams.new
|
||||||
params.setMaxDigits(number_input_max_digits)
|
params.setMaxDigits(number_input_max_digits)
|
||||||
@@ -210,25 +208,38 @@ class Interpreter
|
|||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
def command_102
|
def command_102
|
||||||
choices = setup_choices(@list[@index].parameters)
|
choices = setup_choices(@list[@index].parameters)
|
||||||
tl_choices = []
|
|
||||||
choices[0].each { |cmd| tl_choices.push(_MAPINTL($game_map.map_id, cmd)) }
|
|
||||||
@message_waiting = true
|
@message_waiting = true
|
||||||
command = pbShowCommands(nil, tl_choices, choices[1])
|
command = pbShowCommands(nil, choices[0], choices[1])
|
||||||
@message_waiting = false
|
@message_waiting = false
|
||||||
@branch[@list[@index].indent] = command
|
@branch[@list[@index].indent] = choices[2][command] || command
|
||||||
Input.update # Must call Input.update again to avoid extra triggers
|
Input.update # Must call Input.update again to avoid extra triggers
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup_choices(params)
|
def setup_choices(params)
|
||||||
# Get initial options
|
# Get initial options
|
||||||
choices = params[0]
|
choices = params[0].clone
|
||||||
cancel_index = params[1]
|
cancel_index = params[1]
|
||||||
# Clone @list so the original isn't modified
|
# Clone @list so the original isn't modified
|
||||||
@list = Marshal.load(Marshal.dump(@list))
|
@list = Marshal.load(Marshal.dump(@list))
|
||||||
# Get more choices
|
# Get more choices
|
||||||
@choice_branch_index = 4
|
@choice_branch_index = 4
|
||||||
ret = add_more_choices(choices, cancel_index, @index + 1, @list[@index].indent)
|
ret = add_more_choices(choices, cancel_index, @index + 1, @list[@index].indent)
|
||||||
|
# Rename choices
|
||||||
|
ret[0].each_with_index { |choice, i| ret[0][i] = @renamed_choices[i] if @renamed_choices[i] }
|
||||||
|
@renamed_choices.clear
|
||||||
|
# Remove hidden choices
|
||||||
|
ret[2] = Array.new(ret[0].length) { |i| i }
|
||||||
|
@hidden_choices.each_with_index do |condition, i|
|
||||||
|
next if !condition
|
||||||
|
ret[0][i] = nil
|
||||||
|
ret[2][i] = nil
|
||||||
|
end
|
||||||
|
ret[0].compact!
|
||||||
|
ret[2].compact!
|
||||||
|
@hidden_choices.clear
|
||||||
|
# Translate choices
|
||||||
|
ret[0].map! { |ch| _MAPINTL($game_map.map_id, ch) }
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -269,6 +280,15 @@ class Interpreter
|
|||||||
# Find more choices to add
|
# Find more choices to add
|
||||||
return add_more_choices(choices, cancel_index, choice_index + 1, indent)
|
return add_more_choices(choices, cancel_index, choice_index + 1, indent)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def hide_choice(number, condition = true)
|
||||||
|
@hidden_choices[number - 1] = condition
|
||||||
|
end
|
||||||
|
|
||||||
|
def rename_choice(number, new_name, condition = true)
|
||||||
|
return if !condition || nil_or_empty?(new_name)
|
||||||
|
@renamed_choices[number - 1] = new_name
|
||||||
|
end
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# * When [**]
|
# * When [**]
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user