Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** 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(0, 0, window_width, window_height)
- self.z = 200
- self.openness = 0
- self.windowskin = Cache.system('WindowMessage')
- create_all_windows
- clear_instance_variables
- 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?
- process_input
- $game_message.clear
- @gold_window.close
- Fiber.yield
- break unless text_continue?
- end
- close_and_wait
- $game_message.visible = false
- @fiber = nil
- end
- def process_all_text
- text = convert_escape_characters($game_message.all_text)
- open_and_wait(text)
- pos = {}
- new_page(text, pos)
- process_character(text.slice!(0, 1), text, pos) until text.empty?
- end
- def open_and_wait(text)
- lines = text.split("\n")
- width = text_size(lines.max{ |a, b| a.size <=> b.size }).width
- self.width = width + 42
- self.height = lines.size * 18 + 32
- 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 - 42 if self.x + width + 42 > Graphics.width
- choice_height = fitting_height($game_message.choices.size)
- self.y = Graphics.height - height - choice_height if self.y + height + choice_height > Graphics.height
- open
- Fiber.yield until open?
- end
- def text_continue?
- $game_message.has_text?
- end
- def new_page(text, pos)
- contents.clear
- reset_font_settings
- pos[:x] = 5
- pos[:y] = 0
- pos[:new_x] = 5
- pos[:height] = calc_line_height(text)
- clear_flags
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment