04-05-2007, 01:00 PM (This post was last modified: 06-21-2017, 03:56 AM by DerVVulfman.)
ATP(Advanced Text Paragrapher)
by Samo, The thief
V1.0
Apr 5 2007
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
I will make Easier the life of many scripters with this. This script transforms a really
long script in a paragraph(like a loong description.)
Maybe you won't be too much impressed with this. I use this in My RTBS for the dialogs
and descriptions. Dialogs are very difficult, so this makes thing really easy!
CODE:
-----
here it is:
WINDOW_BASE VERSION
ATP COde. Click Here!
Code:
=begin
ATP(Advanced Text Paragrapher) V1.0 by Samo, The thief
Ok, Something of The Scripters do normally to draw a text in form of a paragraph is
doing an array [] that contains each line. The Time Has come For
This Microsoft Word Effect!
This Script Just need a Long String and it will paragraph it!
How to call it?
paragraph = str_paragraph(string, width of the paragraph.)
Example :
@my_paragraph = str_paragraph("La la la la la la la la la , This is a Looooong Strriiiing!", 120)
Returns an Array with each line separately.
How to draw it?
draw_paragraph(x,y,width,height, paragraph)
width and height for each line, not for the paragraph.
.::-NOTE-::.
If you put a ' ^ '(must be between spaces), the text will pass to the next line.
This Symbol Won't be drawed.
Reminder: Always use '' instead of ""! It works faster!
=end
class Window_Base < Window
#--------------------------------------------------
def str_paragraph(str_old, width)
temp_str = ''
str = '' + str_old
words = []
size = 0
str_size = 0
#
while ((c = str.slice!(/./m)) != nil)
temp_str += c
str_size += 1
if c == ' '
words.push(temp_str)
temp_str = ''
end
if str.size == 0
words.push(temp_str)
temp_str = ''
end
end
lines = []
for i in 0...words.size
word = words[i]
if word == '^ '
lines.push(temp_str)
temp_str = ''
next
end
temp_str += word
size = contents.text_size(temp_str).width
if size > width - contents.text_size(' ').width
for i in 1..word.size
temp_str = temp_str.chop
end
lines.push(temp_str)
temp_str = ''
temp_str += word
end
end
words = words.compact
if temp_str != ''
lines.push(temp_str)
end
return lines
end
#---------------------------------------------------------------------
def draw_paragraph(x,y,width,height,lines,align = 0)
for i in 0...lines.size
self.contents.draw_text(x, y + i * self.contents.font.size + 1, width, height, lines[i], align)
end
end
#-----------------------------------------------------------------
end
BITMAP VERSION
ATP COde. Click Here!
Code:
=begin
ATP(Advanced Text Paragrapher) V1.0 by Samo, The thief
Ok, Something of The Scripters do normally to draw a text in form of a paragraph is
doing an array [] that contains each line. The Time Has come For
This Microsoft Word Effect!
This Script Just need a Long String and it will paragraph it!
How to call it?
paragraph = str_paragraph(string, width of the paragraph.)
Example :
@my_paragraph = str_paragraph("La la la la la la la la la , This is a Looooong Strriiiing!", 120)
Returns an Array with each line separately.
How to draw it?
draw_paragraph(x,y,width,height, paragraph)
width and height for each line, not for the paragraph.
.::-NOTE-::.
If you put a ' ^ '(must be between spaces), the text will pass to the next line.
This Symbol Won't be drawed.
Reminder: Always use '' instead of ""! It works faster!
=end
class Bitmap
#--------------------------------------------------
def str_paragraph(str_old, width)
temp_str = ''
str = '' + str_old
words = []
size = 0
str_size = 0
#
while ((c = str.slice!(/./m)) != nil)
temp_str += c
str_size += 1
if c == ' '
words.push(temp_str)
temp_str = ''
end
if str.size == 0
words.push(temp_str)
temp_str = ''
end
end
lines = []
for i in 0...words.size
word = words[i]
if word == '^ '
lines.push(temp_str)
temp_str = ''
next
end
temp_str += word
size = text_size(temp_str).width
if size > width - text_size(' ').width
for i in 1..word.size
temp_str = temp_str.chop
end
lines.push(temp_str)
temp_str = ''
temp_str += word
end
end
words = words.compact
if temp_str != ''
lines.push(temp_str)
end
return lines
end
#---------------------------------------------------------------------
def draw_paragraph(x,y,width,height,lines,align = 0)
for i in 0...lines.size
draw_text(x, y + i * self.contents.font.size + 1, width, self.contents.font.size, lines[i], align)
end
end
#-----------------------------------------------------------------
end
INSTRUCTIONS:
-------------
Enjoy the script and give me the credit. Replies please! What do you think of this?