Balrogic

RPG Maker VX Ace Script - Simple Paragrapher by Balrogic

Mar 3rd, 2015
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. =begin
  2. Simple Paragrapher 1.01 by Balrogic
  3.  
  4. This script is really simple. It does all the work on it's own.
  5. There is only one thing you might need to configure, the offset
  6. of the text drawing area in your message box. It's optional,
  7. you can leave it alone unless you're using a different font and
  8. the message box is giving you problems. For example,
  9.  
  10. OFFSET = 1 + (24)
  11.  
  12. will fix a problem that can cause certain custom font settings
  13. to draw characters outside of the message box. Number in
  14. parenthesis equal to standard_padding * 2, leave it alone unless
  15. you've changed the standard padding in Window_Base.
  16.  
  17. This script is free to use in both commercial and non-commercial
  18. games. Donations are optional but not discouraged. Private message
  19. me at http://forums.rpgmakerweb.com/index.php?/user/52841-balrogic/
  20. and offer me some pizza money if you just can't help yourself.
  21. =end
  22. class Window_Message < Window_Base
  23.  
  24.   # CONFIGURATION - Positive for shorter text, negative for longer text.
  25.   OFFSET = 0 + (24)
  26.  
  27.   def process_all_text
  28.     open_and_wait
  29.     text = convert_escape_characters($game_message.all_text)
  30.     pos = {}
  31.     new_page(text, pos)
  32.     text = new_text_thingy(text)
  33.     puts contents.text_size(text).width
  34.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  35.   end
  36.   def new_text_thingy(text)
  37.     @texty = []
  38.     allowable = width - OFFSET - new_line_x
  39.     text = text.split("\n")
  40.     text.each_with_index {|value, index| text[index] = value.split(" ")}
  41.     text.each_with_index {|value, index|
  42.       @lengthy = 0
  43.       if contents.text_size(value.join(" ")).width <= allowable
  44.         @texty[index] = value.join(" ")
  45.       else
  46.         @texty[index] = ""
  47.         value.each {|final|
  48.           if contents.text_size(@texty[index] + final).width - @lengthy <= allowable
  49.             @texty[index] += final + " "
  50.           else
  51.             @texty[index] += "\n"
  52.             @lengthy = contents.text_size(@texty[index]).width
  53.             @texty[index] += final + " "
  54.           end
  55.         } # value.each
  56.       end
  57.     } # text.each_with_index
  58.     @texty.join("\n")
  59.   end
  60. end
Advertisement
Add Comment
Please, Sign In to add comment