Jump to content
Kayzee

Word Wrapping Message Boxes

Recommended Posts

Uh, yeah, using this script has reduced the time I have to spend on dialog entry by about 300%.  I just type away and know it will be fine.  If I need a double space I just throw in a \NL and bam, done.  Thankya thankya thankya for this script, KiloZapit.

Share this post


Link to post
Share on other sites

Awww shucks... you two are making me blush...

*bashfully sprinkles fairy dust on the two with a giggle*

I am glad my little script helps people!

Share this post


Link to post
Share on other sites

After materials and above main.

Share this post


Link to post
Share on other sites

Hi Killozapit (does this name means something, i really like the jokes you make sometimes lol)

 

  So i am using your script with ace Message from yanfly AND message busts from galv (yeah i like busts, they're graphically intense). If i put the bust at the bottom right (mirrored) and at a higher Z than the message box, which is the configuration i am planning to use because it doesnt occupy a good portion of the screen, the message doesn’t recognizes the mirrored bust at the bottom right and just goes behind it with no line jumping.

 Of course this is expected, as they're completely different scripts. But how about you make a version 07, with an option to, even manually thorough a script call or something, pull the end of the line a custom ammount of pixels to the back, so your script can recognize that there's a mirrored bust, and it will star jumping lines before a bust to the right side of the screen?

I know something more ellaborated could be made by analyzing both scripts, but i would be very grateful with any of these upgrades to a better compability with busts.

Edited by Nosleinad

Share this post


Link to post
Share on other sites

Okay! I updated it just for you! Hehe, you can use the \rm[] command to change the right margin... though that would mean you basically have to put a command at the start of every message... I may move stuff to Game_Message and have diffrent configs for Window_Message sometime in the future. I would recommend leaving the default right margin at 0 because it will effect item descriptions and stuff too now.

Share this post


Link to post
Share on other sites

Yay...i received some fairy dust at the same day i asked for it. I even changed my avatar here, as i use it in the rpgmakerweb. Thanks a lot Killozapit, i am testing it right now, and if i find something i will let you know.

 

Edit: This crash just happened at my first message, without using any of your script codes and without changing anything in your script. The message appears and whiule the first word is being draw, this crash happens :) .

 

30u9.jpg

Edited by Nosleinad

Share this post


Link to post
Share on other sites

Ooopsie, it should work now. Still version 7 for now, just forgot to re-add the @ in front there. *sprinkles more fairy dust on you :3*

Edited by KilloZapit

Share this post


Link to post
Share on other sites

It's working like a charm, tks a lot. In a few months i expect to release a demo of my project to the public. I am already at 1:30h of gameplay, but i am also waiting to replace some graphics for animated High fantasy ones through it's next products.

Share this post


Link to post
Share on other sites

Neato! Good luck!

Share this post


Link to post
Share on other sites

I love the simplicity of this script! Thanks KilloZapit!! Awesome stuff here! :D

Share this post


Link to post
Share on other sites

You are very welcome~! *sprinkles fairy dust on you.*

Share this post


Link to post
Share on other sites

This script is an absolute life saver when dealing with long conversation scenes! Thank you so much!

Share this post


Link to post
Share on other sites

Thankies very much! *sprinkles fairy dust on you too* Hehe...

Share this post


Link to post
Share on other sites

Sorry if I am necro-ing an old topic, but how exactly do I install this script?

I've watched several videos about scripting and still have abosolutely no idea what to do.

Share this post


Link to post
Share on other sites

Do you know how to call up the script list? You can get it by pushing F11 or pushing the button with the notepad with a pencil on top of it I think... anyway you need to copy and paste it in a slot between the materials label and the main label... You can right-click on the slot list to bring up a menu to insert new ones or otherwise manipulate them. Try not to mess with any of the scripts normally in there, but you can take a look if you want.

Edited by KilloZapit

Share this post


Link to post
Share on other sites

Do you know how to call up the script list? You can get it by pushing F11 or pushing the button with the notepad with a pencil on top of it I think... anyway you need to copy and paste it in a slot between the materials label and the main label... You can right-click on the slot list to bring up a menu to insert new ones or otherwise manipulate them. Try not to mess with any of the scripts normally in there, but you can take a look if you want.

Is that where I'm gonna put all scripts?

Share this post


Link to post
Share on other sites

Just saw this script and it looks very nice.  :)

 

Is it still being worked on?  Would it at all be possible to make alignment options?  Specifically text centering and justification (aligned on both left and right sides -- like in books.)  I've yet to see a justification option in any text script, and I always thought it would be really cool to have.

Share this post


Link to post
Share on other sites

Is that where I'm gonna put all scripts?

Yuppers... it may take some getting used to, so you may want to back up stuff before you mess with it.

 

Just saw this script and it looks very nice.  :)

 

Is it still being worked on?  Would it at all be possible to make alignment options?  Specifically text centering and justification (aligned on both left and right sides -- like in books.)  I've yet to see a justification option in any text script, and I always thought it would be really cool to have.

It's not really being activly worked on but I still will try and fix any major bugs. I think fancy alignment options are a bit byond the scope of what I want to do with the script. That kind of thing I think would be better off done with a whole new text engine, and I am not sure I want to try doing that right now. In perticular it would involve changeing the whole text rendering to precalculate line width. Right now it just calculates stuff as it is drawn.

Edited by KilloZapit
  • Like 1

Share this post


Link to post
Share on other sites

I LOVE this script.  Thank you for your hard work, if that means anything to you.  :D

 

I prefer not to use all-in-one scripts like Yanfly myself, because it has many features that are useless to me.  I like using scripts that do only what I need them to do. 

Share this post


Link to post
Share on other sites

Has anyone ever found it annoying to manually break up text to fit in the message boxes, especially if you start tweaking with the game resolution or the text box sizes? Well, I sure have. It's rather annoying to me that simple word wrapping is beyond the capability of the vx ace engine... but no more for I bring ye, yonder script to solve yon problem! It also adds a few new escape sequences and a optional HTML-like whitespace mode that converts linebreaks to spaces. More features (like possibly a option to get rid of leading/trailing spaces for a line) may come in the future.

 

 

 

#========================================================================
# ** Word Wrapping Message Boxes, by: KilloZapit
#------------------------------------------------------------------------
# Changes message boxes so it will automatically wrap long lines.
#
# Note: I consider this script to be public domain, and put no
# restrictions on it's use whatsoever. My only request is that
# a link back to the script is provided so more people can
# access it if they want to.
#
# Version the Second:
#   Now strips color codes and icon codes so they don't break words.
#   Also calculates icon width along with text width for words.
# Version the Third:
#   Now also strips delays and other timing related codes.
#   Splits for non-icon control codes before counting icons.
#   Control codes can now break lines in case of font changes.
#   Added some comments to clarify some code.
# Version the Forth:
#   Fixed a small bug that might cause a error when counting icons.
#   Added a small notice for copyright questions.
# Version the Fifth:
#   Added "collapse" mode, which elimanates extra spaces.
#   Can now use "whitespace" mode outside of wordwrap mode if needed.
# Version the Sixth:
#   Fixed problems with collapsed whitespace not wraping words right.
# Version the Seventh:
#   Added option to add a margin to the right hand side of the window.
#------------------------------------------------------------------------
# Also adds the following new escape sequences:
#
# \ww  - Word Wrap: turns word wrap on if it's off
# \nw  - No Wrap: Turns word wrap off
# \ws  - WhiteSpace mode: Converts newlines to spaces (like HTML)
# \nl  - New Line: Preserves hard returns
# \cs  - Collapse whiteSpace: Eliminates extra spaces (also like HTML)
# \pre - PRE-formatted: Preserves spaces
# \br  - line BRake: manual newline for whitespace mode
# \rm  - Right Margin: extra space on the right side of the window
#========================================================================

# Standard config module.
module KZIsAwesome
  module WordWrap

    # change this if you don't want wordwrap on by default.
    DEFAULT_WORDWRAP = true

    # change this if you want white space mode on by default.
    DEFAULT_WHITESPACE = false
   
    # change this if you want white space mode on by default.
    DEFAULT_COLLAPSE = true
    
    # change this to add a right margin to the window.
    DEFAULT_RIGHT_MARGIN = 0

  end
end

class Window_Base < Window
  include KZIsAwesome::WordWrap

  alias_method :initialize_kz_window_base, :initialize
  def initialize(x, y, width, height)
    initialize_kz_window_base(x, y, width, height)
    @wordwrap = DEFAULT_WORDWRAP
    @convert_newlines = DEFAULT_WHITESPACE
    @collapse_whitespace = DEFAULT_COLLAPSE
    @right_margin = DEFAULT_RIGHT_MARGIN
    @lastc = "\n"
  end

  alias_method :process_character_kz_window_base, :process_character
  def process_character(c, text, pos)
    c = ' ' if @convert_newlines && c == "\n"
    if @wordwrap && c =~ /[ \t]/
      c = '' if @collapse_whitespace && @lastc =~ /[\s\n\f]/
      if pos[:x] + get_next_word_size(c, text) > contents.width - @right_margin
        process_new_line(text, pos)
      else
        process_normal_character(c, pos)
      end
      @lastc = c
    else
      @lastc = c
      process_character_kz_window_base(c, text, pos)
    end
  end

  def get_next_word_size(c, text)
    # Split text by the next space/line/page and grab the first split
    nextword = text.split(/[\s\n\f]/, 2)[0]
    if nextword
      icons = 0
      if nextword =~ /\e/i
        # Get rid of color codes and YEA Message system outline colors
        nextword = nextword.split(/\e[oOcC]+\[\d*\]/).join
        # Get rid of message timing control codes
        nextword = nextword.split(/\e[\.\|\^<>!]/).join
        # Split text by the first non-icon escape code
        # (the hH is for compatibility with the Icon Hues script)
        nextword = nextword.split(/\e[^iIhH]+/, 2)[0]
        # Erase and count icons in remaining text
        nextword.gsub!(/\e[iIhH]+\[[\d,]*\]/) do
          icons += 1
          ''
        end if nextword
      end
      wordsize = (nextword ? text_size(c + nextword).width : text_size( c ).width)
      wordsize += icons * 24
    else
      wordsize = text_size( c ).width
    end
    return wordsize
  end

  alias_method :process_escape_character_kz_window_base, :process_escape_character
  def process_escape_character(code, text, pos)
    case code.upcase
    when 'WW'
      @wordwrap = true
    when 'NW'
      @wordwrap = false
    when 'WS'
      @convert_newlines = true
    when 'NL'
      @convert_newlines = false
    when 'CS'
      @collapse_whitespace = true
    when 'PRE'
      @collapse_whitespace = false
    when 'BR'
      process_new_line(text, pos)
      @lastc = "\n"
    when 'RM'
      @right_margin = obtain_escape_param(text)
    else
      process_escape_character_kz_window_base(code, text, pos)
    end
    # Recalculate the next word size and insert line breaks
    # (Needed primarily for font changes)
    if pos[:x] + get_next_word_size('', text) > contents.width
      process_new_line(text, pos)
    end
  end

end

 

 

Edit: Now up to version SEVEN! Six is afraid of it!)

 

you're my hero

Share this post


Link to post
Share on other sites

you're my hero

Awww shucks you replied to this old thing just to tell me that? Your making me blush...

Share this post


Link to post
Share on other sites

This is a really awesome script, thanks for sharing. (I just wish I knew about this for my first game...)

Share this post


Link to post
Share on other sites

Kudos to you! This is something I needed for so long. I always click "preview" a milion times trying to fix the text. Thanks a lot for this! :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted