Message Choice Edit
Authors: Wecoc
Version: 1.1
Type: Message Add-on
Key Term: Message Add-on
IntroductionThis edit changes choice distribution displaying it horizontally instead of vertically. Long sentences will be shown as always.
Features
- Short sentences will be shown horizontally (even if 4 choices fit on 1 line).
- Long sentences will be shown as always.
- You can easily activate and deactivate the script anytime using Game Temp.
Screenshots(http://s13.postimage.org/j9gimi1bb/sillyexample.png)
That was silly
DemoNone.
Script
#==============================================================================
# Choice Edit - versiĆ³n 1.1
# by Wecoc
#==============================================================================
class Game_Temp
attr_accessor :choice_short
attr_accessor :choice_type
attr_accessor :choice_data
alias ini initialize unless $@
def initialize
ini
# To activate / deactivate the script only thing you have to do is
#modify next line:
@choice_short = true
# false: vertical (default), true : horizontal (just short words)
# Long sentences will always be displayed vertically.
@choice_data = nil
@choice_type = 0 # 0 = vertical, 1 = horizontal
end
end
class Interpreter
def setup_choices(parameters)
$game_temp.choice_max = parameters[0].size
$game_temp.choice_data = parameters[0]
w = $game_temp.choice_data.to_s.length
if w > 26
$game_temp.choice_type = 0
else
if $game_temp.choice_short == true
$game_temp.choice_type = 1
else
$game_temp.choice_type = 0
end
end
if $game_temp.choice_type == 0 # Vertical
for text in parameters[0]
$game_temp.message_text += text + "\n"
end
else # Horizontal
for text in parameters[0]
$game_temp.message_text += text + " "
end
$game_temp.message_text += "\n"
end
$game_temp.message_text += "\n"
$game_temp.choice_cancel_type = parameters[1]
current_indent = @list[@index].indent
$game_temp.choice_proc = Proc.new { |n| @branch[current_indent] = n }
end
end
class Interpreter
def command_101 # Show Text
if $game_temp.message_text != nil
return false
end
@message_waiting = true
$game_temp.message_proc = Proc.new { @message_waiting = false }
$game_temp.message_text = @list[@index].parameters[0] + "\n"
line_count = 1
loop do
if @list[@index+1].code == 401 # Show Text
$game_temp.message_text += @list[@index+1].parameters[0] + "\n"
line_count += 1
else
if @list[@index+1].code == 102 # Show Choices
a = @list[@index+1].parameters[0]
w = a.to_s.length
if w > 26
$game_temp.choice_type = 0
else
if $game_temp.choice_short == true
$game_temp.choice_type = 1
else
$game_temp.choice_type = 0
end
end
if (@list[@index+1].parameters[0].size <= 4 - line_count and
$game_temp.choice_type == 0) or (line_count < 4 and
$game_temp.choice_type == 1) then
@index += 1
$game_temp.choice_start = line_count
setup_choices(@list[@index].parameters)
end
elsif @list[@index+1].code == 103 # Input Number
if line_count < 4
@index += 1
$game_temp.num_input_start = line_count
$game_temp.num_input_variable_id = @list[@index].parameters[0]
$game_temp.num_input_digits_max = @list[@index].parameters[1]
end
end
return true
end
@index += 1
end
end
end
class Window_Message < Window_Selectable
def refresh
self.contents.clear
self.contents.font.color = normal_color
x = y = 0
if $game_temp.choice_start == 0
x = 8
end
@cursor_width = 0
if $game_temp.message_text != nil
text = $game_temp.message_text
begin
last_text = text.clone
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until text == last_text
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
text.gsub!(/\\\\/) { "\000" }
text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
text.gsub!(/\\[Gg]/) { "\002" }
while ((c = text.slice!(/./m)) != nil)
if c == "\000"
c = "\\"
end
if c == "\001"
text.sub!(/\[([0-9]+)\]/, "")
color = $1.to_i
if color >= 0 and color <= 7
self.contents.font.color = text_color(color)
end
next
end
if c == "\002"
if @gold_window == nil
@gold_window = Window_Gold.new
@gold_window.x = 560 - @gold_window.width
if $game_temp.in_battle
@gold_window.y = 192
else
@gold_window.y = self.y >= 128 ? 32 : 384
end
@gold_window.opacity = self.opacity
@gold_window.back_opacity = self.back_opacity
end
next
end
if c == "\n"
if y >= $game_temp.choice_start
@cursor_width = [@cursor_width, x].max
end
y += 1
x = 0
if y >= $game_temp.choice_start and $game_temp.choice_type == 0
x = 8
end
next
end
self.contents.draw_text(4 + x, 32 * y, 40, 32, c)
x += self.contents.text_size(c).width
end
end
# If choice
if $game_temp.choice_max > 0
@column_max = $game_temp.choice_max if $game_temp.choice_type == 1
@item_max = $game_temp.choice_max
self.active = true
self.index = 0
end
# If number input
if $game_temp.num_input_variable_id > 0
digits_max = $game_temp.num_input_digits_max
number = $game_variables[$game_temp.num_input_variable_id]
@input_number_window = Window_InputNumber.new(digits_max)
@input_number_window.number = number
@input_number_window.x = self.x + 8
@input_number_window.y = self.y + $game_temp.num_input_start * 32
end
end
def update_cursor_rect
if @index >= 0
if $game_temp.choice_type == 0
n = $game_temp.choice_start + @index
self.cursor_rect.set(8, n * 32, @cursor_width, 32)
else
n = $game_temp.choice_start
w = self.contents.text_size($game_temp.choice_data[@index]).width
a = 0
for i in 0..@index-1
a += self.contents.text_size($game_temp.choice_data[i] + " ").width
end
self.cursor_rect.set(a, n * 32, w+10, 32)
end
else
self.cursor_rect.empty
end
end
end
InstructionsUse $game_temp.choice_short = (true/false) on a Script Call before a choice to activate or deactivate the script.
CompatibilityShould be compatible, but I didn't used any alias except on Game Temp.
Credits and Thanks
Author's NotesPlease report any bugs/issues/incompatibilities.