#=============================================================================== # Message Window Formatting # By Jet10985 (Jet) #=============================================================================== # This script will allow you to type freely when making Text Events, because it # will automatically format the text to not go past the window edges. # This script has: 0 customization options. #=============================================================================== # Overwritten Methods: # None #------------------------------------------------------------------------------- # Aliased methods: # Window_Message: start_message #=============================================================================== =begin To force a next line in the text, put \line inside the message where you want to force text to the next line =end class String def each_word array = self.split(" ") if block_given? array.each {|a| yield a } else return array end end end class Window_Message alias jet1847_start_message start_message unless $@ def start_message(*args, &block) if $game_message.choice_max > 0 for i in 0...$game_message.texts.size next unless i >= $game_message.choice_start - 1 $game_message.texts[i] += " \\xjet" end end jet1847_start_message(*args, &block) @text.gsub!(/\\line/i) { " \\xjet " } temp_text = @text.split("\x00") new_text = "" space_taken = 0 temp_text.each {|line| line.each_word {|word| space_taken += self.contents.text_size("#{word} ").width if word == "\\xjet" space_taken = 0 new_text.concat("\x00") elsif space_taken > self.width - @contents_x - 32 space_taken = 0 new_text.concat("\x00#{word} ") space_taken += self.contents.text_size("#{word} ").width else new_text.concat("#{word} ") end } } f = @text.scan(/\x00/i).size $game_message.choice_start = f - $game_message.choice_max @text = new_text end end