1) Substitua o script [VS] Window_Message por:
Resultado:
Créditos:
Valentine
Readerusama (pela Windowskin)
- Código:
#==============================================================================
# ** Window_Message
#------------------------------------------------------------------------------
# Autor: Valentine
#==============================================================================
class Game_Message
attr_accessor :event_id
def clear
@texts = []
@choices = []
@face_name = ''
@face_index = 0
@background = 0
@position = 2
@event_id = 0
@choice_cancel_type = 0
@choice_proc = nil
@num_input_variable_id = 0
@num_input_digits_max = 0
@item_choice_variable_id = 0
@scroll_mode = false
@scroll_speed = 2
@scroll_no_fast = false
end
end
#==============================================================================
# ** Game_Interpreter
#==============================================================================
class Game_Interpreter
def command_101
wait_for_message
$game_message.face_name = @params[0]
$game_message.face_index = @params[1]
$game_message.background = @params[2]
$game_message.position = @params[3]
$game_message.event_id = @event_id
while next_event_code == 401 # Texto
@index += 1
$game_message.add(@list[@index].parameters[0])
end
case next_event_code
when 102 # Mostrar escolhas
@index += 1
setup_choices(@list[@index].parameters)
when 103 # Entrada numérica
@index += 1
setup_num_input(@list[@index].parameters)
when 104 # Selecionar item
@index += 1
setup_item_choice(@list[@index].parameters)
end
wait_for_message
end
end
#==============================================================================
# ** Window_ChoiceList
#==============================================================================
class Window_ChoiceList < Window_Command
def initialize(message_window)
@message_window = message_window
super(0, 0)
self.openness = 0
self.windowskin = Cache.system('WindowMessage')
deactivate
end
def update_placement
self.width = [max_choice_width + 12, 96].max + padding * 2
self.width = [ width, Graphics.width].min
self.height = fitting_height($game_message.choices.size)
self.x = @message_window.x + @message_window.width - width
self.y = @message_window.y + @message_window.height
end
end
#==============================================================================
# ** Window_Message
#==============================================================================
class Window_Message < Window_Base
def initialize
super(adjust_x, 0, 640, window_height)
self.z = 200
self.openness = 0
self.windowskin = Cache.system('WindowMessage')
create_all_windows
clear_instance_variables
@ok_button = Button.new(self, 0, 0, Vocab::Ok) { $game_message.visible = false }
@ok_button.visible = false
end
def adjust_x
Graphics.width / 2 - 320
end
def dispose
super
dispose_all_windows
end
def update
super
update_all_windows
update_fiber
end
def fiber_main
$game_message.visible = true
loop do
process_all_text if $game_message.has_text?
@ok_button.visible = (!$game_message.choice? && !$game_message.item_choice?)
process_input
# Se clicou em Ok ou pressinou Esc
unless $game_message.choice? || $game_message.item_choice?
@ok_button.visible = false
$network.send_next_event_command
end
$game_message.clear
@gold_window.close
# Se morreu com a janela de escolhas aberta
@choice_window.close
@item_window.close
Fiber.yield
break unless text_continue?
end
close_and_wait
# Se pressionou Esc
$game_message.visible = false
@fiber = nil
end
def process_all_text
text = convert_escape_characters($game_message.all_text)
# Remove os caracteres especiais para que seja
#calculada a largura correta do texto
open_and_wait(remove_special_characters(text))
pos = {}
new_page(text, pos)
process_character(text.slice!(0, 1), text, pos) until text.empty?
end
def remove_special_characters(text)
result = text.clone
# gsub converte regexp para string, diferentemente
#do delete que não faz esta conversão
result.gsub!(/\eC\[(\d+)\]/i, '')
result.gsub!(/\e$/i, '')
result.gsub!(/\e{/i, '')
result.gsub!(/\e}/i, '')
result.gsub!(/\e./i, '')
result.gsub!(/\e|/i, '')
result.gsub!(/\e!/i, '')
result.gsub!(/\e>/i, '')
result.gsub!(/\e</i, '')
result.gsub!(/\e^/i, '')
result
end
def open_and_wait(text)
lines = text.split("\n")
width = text_size(lines.max{ |a, b| a.size <=> b.size }).width
width += $game_message.face_name.empty? ? 47 : 149
height = lines.size * calc_line_height(text) + 32
height = 120 if height < 120 && !$game_message.face_name.empty?
self.width = width
self.height = height
if $game_message.event_id > 0
self.x = [$game_map.events[$game_message.event_id].screen_x - self.width / 2, 0].max
self.y = [$game_map.events[$game_message.event_id].screen_y - 35 - self.height, 0].max
self.x = Graphics.width - width - 47 if self.x + width + 47 > Graphics.width
# Se a mensagem é mostrada nos eventos comuns
else
update_placement
self.x = (Graphics.width - width) / 2
end
choice_height = fitting_height($game_message.choices.size)
self.y = Graphics.height - height - choice_height if self.y + height + choice_height > Graphics.height
@ok_button.x = width - 55
@ok_button.y = height - 15
open
Fiber.yield until open?
end
def text_continue?
$game_message.has_text?
end
def update_show_fast
@show_fast = true if Input.trigger?(Configs::ATTACK_KEY)
end
def new_page(text, pos)
contents.clear
draw_face($game_message.face_name, $game_message.face_index, 0, 0)
reset_font_settings
pos[:x] = new_line_x
pos[:y] = 0
pos[:new_x] = new_line_x
pos[:height] = calc_line_height(text)
clear_flags
end
def new_line_x
$game_message.face_name.empty? ? 10 : 109
end
def calc_line_height(text)
20
end
def input_pause
self.pause = true
wait(10)
Fiber.yield until Input.trigger?(:B) || !$game_message.visible
Input.update
self.pause = false
end
def input_choice
@choice_window.start
Fiber.yield while @choice_window.active && $game_message.visible
end
def input_item
@item_window.start
Fiber.yield while @item_window.active && $game_message.visible
end
end
#==============================================================================
# ** Control
#==============================================================================
class Control
end
#==============================================================================
# ** Button
#==============================================================================
class Button < Control
def x=(x)
@x = x
end
def y=(y)
@y = y
end
end
Resultado:
Créditos:
Valentine
Readerusama (pela Windowskin)
Última edição por Valentine em Qua Dez 29, 2021 11:30 am, editado 8 vez(es)