RPG Crisis Community Forums: Paragraph Formatter - RPG Maker VX Scripts - Tutorials/Scripts - RPG Crisis Community Forums

Jump to content

Paragraph Formatter Bookmark

User is offline Elemental Crisis 

  • Administrator
    • Group: Administrators
    • Posts: 2,394
    • Joined: 22-June 10
    • LocationUSA
    • Time Online: 1d 6h 20m 59s

    31
    2538/9400
    Hit Points
    4670/4670
    Magic Points
    44%
    Experience
    : ADVENTURER
    ADVENTURER


    Tutorial/Script info

    • Added on: 25 July 2010 - 08:50 PM
    • Date Updated: 25 July 2010 - 08:53 PM
    • Views: 780
    Description: This is a scripting tool. It's purpose is to allow the user to input an unbroken string and have returned a paragraph which has the ends of each line in line with each other. It serves roughly the same function as does the justifying option in Microsoft Word. See the screenshots if you are still confused.

    Script Name: Paragraph Formatter
    Author: modern algebra
    Version: 2.0
    Number Of Scripts: 3 (1 required, 2 optional)
    Description:
    This is a scripting tool. It's purpose is to allow the user to input an unbroken string and have returned a paragraph which has the ends of each line in line with each other. It serves roughly the same function as does the justifying option in Microsoft Word. See the screenshots if you are still confused.

    Features
    * A nice, easy way to display long strings in a paragraph format
    * Easy to add and modify at runtime, allowing for the switching between formatting classes for each situation
    * You can write your own formatter or artist classes and use the paragraphing tool to suit your situation.
    * Highly customizable.

    Screenshots:


    Instructions:
    As a scripter's tool, it can be quite heavy for non-scripters to use. That is why I wrote a facade for common use of the tool. Naturally, you will still need some scripting knowledge, but the facade allows for this code:

    bitmap.draw_paragraph (x, y, max_width, max_height, string)

    Where bitmap is the bitmap you are drawing to. This can be self.contents in a window, or any instance of the bitmap class.

    It can be used like this, if you want to draw the paragraph in a different way:

    formatter = 
    artist = 
    specifications = 
    pg = Paragrapher.new (formatter, artist)
    text_bitmap = pg.paragraph (string, specifications)
    bitmap.blt (x, y, text_bitmap, Rect.new (0,0,text_bitmap.width, text_bitmap.height))

    Basically, you choose your formatter and artist class at runtime. This means that if you want to use Paragraph::Formatter_2, because you are using a font with set width for all characters, then you would choose that here. Currently, there is only one Artist class, Paragraph::Artist, but of course you can make your own if it does not suit you. You can either specify a bitmap or a fixnum. The fixnum would just be the max width, and the paragrapher would create a bitmap which was at font_size 22, default font name, and it would space each line 32 pixels. With a bitmap, you specify max_width, max_height, font and font size, and anything else that has an effect. Naturally, bitmap in the code is the bitmap you are drawing the paragraph on. If you have any questions, just ask. Also, the text_size method of Bitmap does not, in fact, work properly. In a little while I will post a way to get around this problem as it can get in the way of drawing nice paragraphs.

    Put the scripts above main and below the default scripts. For all additional Paragrapher classes, just add them in the Script Editor below the Paragraph Formatter in their own slots, but still above Main. For more pertinent instructions, see the header of the script.

    Author's Notes
    This script was inspired by Zeriab, and pretty much everything that is good about this script is due to Zeriab. Zeriab deserves more credit for this script then I do, rightly, but since the world isn't just... Anyway, he deserves all my thanks for being an excellent teacher.

    Frequently Asked Questions:
    N/A

    Scripts:
    Paragraph Formatter -Required
    Spoiler

    Special Codes Formatter - Optional
    Spoiler

    Paragrapher::Formatter 2 - Optional
    Spoiler
    0
    • View members tutorials/scripts
    • RPG Maker VX Scripts

    Share:

    Powered by (IM) Tutorials 1.1.2 © 2011, by Michael McCune