Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- Simple Paragrapher by Balrogic
- This script is really simple. It does all the work on it's own.
- There is only one thing you need to configure, the width of the
- text drawing area in your message box. The default value of 520
- is perfect with the default font settings and message box size.
- If you change your font or window and notice that text gets cut
- off at the right side of your message window then uncomment puts
- statement at line 32, activate your console window if inactive
- and make a test event with a line of text that fills the entire
- message line without getting cut off. Change the TEXT_WIDTH to
- that number.
- This script is free to use in both commercial and non-commercial
- games. Donations are optional but not discouraged. Private message
- me at http://forums.rpgmakerweb.com/index.php?/user/52841-balrogic/
- and offer me some pizza money if you just can't help yourself.
- =end
- class Window_Message < Window_Base
- # CONFIGURATION # Changing this changes how much text
- TEXT_WIDTH = 520 # to draw before making a new line.
- def process_all_text
- open_and_wait
- text = convert_escape_characters($game_message.all_text)
- pos = {}
- new_page(text, pos)
- text = new_text_thingy(text)
- #puts contents.text_size(text).width
- process_character(text.slice!(0, 1), text, pos) until text.empty?
- end
- def new_text_thingy(text)
- @texty = []
- @lengthy = 0
- allowable = TEXT_WIDTH - new_line_x
- text = text.split("\n")
- text.each_with_index {|value, index| text[index] = value.split(" ")}
- text.each_with_index {|value, index|
- if contents.text_size(value.join(" ")).width <= allowable
- @texty[index] = value.join(" ")
- else
- @texty[index] = ""
- value.each {|final|
- if contents.text_size(@texty[index] + final).width - @lengthy <= allowable
- @texty[index] += final + " "
- else
- @texty[index] += "\n"
- @lengthy = contents.text_size(@texty[index]).width
- @texty[index] += final + " "
- end
- } # value.each
- end
- } # text.each_with_index
- @texty.join("\n")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment