03-08-2007, 01:00 PM (This post was last modified: 05-10-2017, 09:52 PM by DerVVulfman.)
Advanced Text Effects Script (ATE) V1.0
by Samo, the thief.
Mar 8 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.
Hey! are you tired of putting the same draw text four times more with a x-1
or something like that when trying to do an outline.
Maybe you do a window_base new method called draw_text_outline.
Well, i have a faster way with the smallest script i ever written.
All you have to do is to put after drawing a text, a string.
if you want a bisel, an outline, a shadow. See the Demo for more info
Code
----
here it is:
code
Code:
=begin
Advanced Text Effects(ATE) V1.0 by Samo, the thief.
This script will evitate you doing your methods of special drawing text manually.
You will be able to do an outline, a shadow, and something else, by only putting
when you draw the text:
(x,y,width,height,str,align,method)
Name Description Type
x x coordinate Integer
y y coordinate Integer
width width Integer
height height Integer
str string Integer
align alignment: Integer
Like in Micro Word
0 Left, 1 Medium,
2 Right.
method The Method That String
will indicate
what we want.
Look Down for a List.
In a Normal window, a draw_text with outline should be like this:
self.contents.draw_text(60,45,120,32,"Thanks Outline Script! Now i look Better!", 1, 'outline')
This also comes with a message system(if you don't like it, just erase the part
of Window_Mesagge)
The message System Works in this Way. There are especial Characters that will
define the type of effect to apply. Just put them, they will appear invisible:
~ No method is used in the message. It makes special characters appear.
@ Outline
# Small Shadow
$ Big Shadow
% Selected Item
^ Light Bisel
& Small Bisel
* Medium Bisel
` Text is Drawn Normally, text effects can appear in the message.
=end
class Bitmap
#-----------------------------------------------------------------------
alias samo_outline_bitmap_draw_text draw_text #Alias of original Draw_text
#------------------------------------------------------------------------
def draw_text(x, y, width, height, str, align = 0, method = 'normal')
if method == 'outline'
r = font.color.red #Takes the original color of the window by numbers
g = font.color.green
b = font.color.blue
a = font.color.alpha
font.color= Color.new(0,0,0) #Color Black
draw_text(x - 1, y, width, height, str, align)
draw_text(x + 1, y, width, height, str, align)
draw_text(x , y+1, width, height, str, align)
draw_text(x , y-1, width, height, str, align)
font.color = Color.new(r,g,b,a) #Returns teh color no to normal
samo_outline_bitmap_draw_text(x, y, width, height, str, align) #draw the text without outline
end
if method == 'Shadow Wide'
r = font.color.red #Takes the original color of the window by numbers
g = font.color.green
b = font.color.blue
a = font.color.alpha
font.color = Color.new(0,0,0,125)
draw_text(x +12, y + 4, width, height, str, align)
font.color = Color.new(r,g,b,a) #Returns teh color no to normal
samo_outline_bitmap_draw_text(x, y, width, height, str, align) #draw the text without outline
end
if method == 'Shadow Small'
r = font.color.red #Takes the original color of the window by numbers
g = font.color.green
b = font.color.blue
a = font.color.alpha
font.color = Color.new(0,0,0,175)
draw_text(x +3, y + 3, width, height, str, align)
font.color = Color.new(r,g,b,a) #Returns teh color no to normal
samo_outline_bitmap_draw_text(x, y, width, height, str, align) #draw the text without outline
end
if method == 'Selected Item'
r = font.color.red #Takes the original color of the window by numbers
g = font.color.green
b = font.color.blue
a = font.color.alpha
font.color= Color.new(120,255,120,225)
draw_text(x - 1, y, width, height, str, align)
draw_text(x + 1, y, width, height, str, align)
draw_text(x , y+1, width, height, str, align)
draw_text(x , y-1, width, height, str, align)
font.color = Color.new(r,g,b,a) #Returns teh color no to normal
samo_outline_bitmap_draw_text(x, y, width, height, str, align) #draw the text without outline
end
if method == 'Light Bisel'
r = font.color.red #Takes the original color of the window by numbers
g = font.color.green
b = font.color.blue
a = font.color.alpha
font.color= Color.new(0,0,0,255)
draw_text(x + 1, y, width, height, str, align)
draw_text(x , y+1, width, height, str, align)
font.color = Color.new(r,g,b,a) #Returns teh color no to normal
samo_outline_bitmap_draw_text(x, y, width, height, str, align) #draw the text without outline
end
if method == 'Small Bisel'
r = font.color.red #Takes the original color of the window by numbers
g = font.color.green
b = font.color.blue
a = font.color.alpha
font.color= Color.new(0,0,0,255)
draw_text(x + 1, y, width, height, str, align)
draw_text(x , y+1, width, height, str, align)
font.color= Color.new(125,125,125,255)
draw_text(x - 1, y, width, height, str, align)
draw_text(x , y-1, width, height, str, align)
font.color = Color.new(r,g,b,a) #Returns teh color no to normal
samo_outline_bitmap_draw_text(x, y, width, height, str, align) #draw the text without outline
end
if method == 'Medium Bisel'
r = font.color.red #Takes the original color of the window by numbers
g = font.color.green
b = font.color.blue
a = font.color.alpha
font.color= Color.new(0,0,0,255)
draw_text(x + 2, y, width, height, str, align)
draw_text(x , y+2, width, height, str, align)
draw_text(x + 2, y+2, width, height, str, align)
font.color= Color.new(125,125,125,255)
draw_text(x - 2, y, width, height, str, align)
draw_text(x , y-2, width, height, str, align)
draw_text(x - 2, y-2, width, height, str, align)
font.color = Color.new(r,g,b,a) #Returns teh color no to normal
samo_outline_bitmap_draw_text(x, y, width, height, str, align) #draw the text without outline
end
if method == 'normal'
samo_outline_bitmap_draw_text(x, y, width, height, str, align) #draw the text without outline
end
end
#-----------------------------------------------------------------------
#-----------------------------------------------------------------------
end
class Sprite_Timer < Sprite
#--------------------------------------------------------------------------
def update
super
self.visible = $game_system.timer_working
if $game_system.timer / Graphics.frame_rate != @total_sec
self.bitmap.clear
@total_sec = $game_system.timer / Graphics.frame_rate
min = @total_sec / 60
sec = @total_sec % 60
text = sprintf("%02d:%02d", min, sec)
self.bitmap.font.color.set(255, 255, 255)
self.bitmap.draw_text(0,0,88,48, text, 1, true)
end
end
end
class Window_PartyCommand < Window_Selectable
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(160 + index * 160 + 4, 0, 128 - 10, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect.x,rect.y,rect.width,rect.height, @commands[index], 1)
end
end
#==============================================================================
# ** Window_Message
#------------------------------------------------------------------------------
# This message window is used to display text.
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
x = y = 0
@cursor_width = 0
# Indent if choice
if $game_temp.choice_start == 0
x = 8
end
@method = 'normal'
# If waiting for a message to be displayed
if $game_temp.message_text != nil
text = $game_temp.message_text
if text.include?('~')
not_effects = true
@method = 'normal'
else
not_effects = false
end
# Control text processing
begin
last_text = text.clone
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until text == last_text
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
# Change "\\\\" to "00" for convenience
text.gsub!(/\\\\/) { "00" }
# Change "\\C" to "01" and "\\G" to "02"
text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "01[#{$1}]" }
text.gsub!(/\\[Gg]/) { "02" }
# Get 1 text character in c (loop until unable to get text)
while ((c = text.slice!(/./m)) != nil)
# If \\
if c == "00"
# Return to original text
c = "\\"
end
# If \C[n]
if c == "01"
# Change text color
text.sub!(/\[([0-9]+)\]/, "")
color = $1.to_i
if color >= 0 and color <= 7
self.contents.font.color = text_color(color)
end
# go to next text
next
end
# If \G
if c == "02"
# Make gold window
if @gold_window == nil
@gold_window = Window_Gold.new
@gold_window.x = 560 - @gold_window.width
if $game_temp.in_battle
@gold_window.y = 192
else
@gold_window.y = self.y >= 128 ? 32 : 384
end
@gold_window.opacity = self.opacity
@gold_window.back_opacity = self.back_opacity
end
# go to next text
next
end
# If new line text
if c == "\n"
# Update cursor width if choice
if y >= $game_temp.choice_start
@cursor_width = [@cursor_width, x].max
end
# Add 1 to y
y += 1
x = 0
# Indent if choice
if y >= $game_temp.choice_start
x = 8
end
# go to next text
next
end
# Draw text
unless not_effects == true
if c == "@"
@method = 'outline'
next
elsif c == "#"
@method = 'Shadow Small'
next
elsif c == "$"
@method = 'Shadow Wide'
next
elsif c == "%"
@method = 'Selected Item'
next
elsif c == "^"
@method = 'Light Bisel'
next
elsif c == "&"
@method = 'Small Bisel'
next
elsif c == "`"
@method = 'normal'
next
elsif c == "*"
@method = 'Medium Bisel'
next
end
end
if c == "~"
next
end
self.contents.draw_text(4 + x, 32 * y, 40, 32, c,0,@method)
# Add x to drawn text width
x += self.contents.text_size(c).width
end
end
# If choice
if $game_temp.choice_max > 0
@item_max = $game_temp.choice_max
self.active = true
self.index = 0
end
# If number input
if $game_temp.num_input_variable_id > 0
digits_max = $game_temp.num_input_digits_max
number = $game_variables[$game_temp.num_input_variable_id]
@input_number_window = Window_InputNumber.new(digits_max)
@input_number_window.number = number
@input_number_window.x = self.x + 8
@input_number_window.y = self.y + $game_temp.num_input_start * 32
end
end
end
INSTRUCTIONS:
-------------
Quote:This script will evitate you doing your methods of special drawing text manually.
You will be able to do an outline, a shadow, and something else, by only putting
when you draw the text:
(x,y,width,height,str,align,method)
Name Description Type
x x coordinate Integer
y y coordinate Integer
width width Integer
height height Integer
str string Integer
align alignment: Integer
Like in Micro Word
0 Left, 1 Medium,
2 Right.
method The Method That String
will indicate
what we want.
Look Down for a List.
In a Normal window, a draw_text with outline should be like this:
self.contents.draw_text(60,45,120,32,"Thanks Outline Script! Now i look Better!", 1, 'outline')
This also comes with a message system(if you don't like it, just erase the part
of Window_Mesagge)
The message System Works in this Way. There are especial Characters that will
define the type of effect to apply. Just put them, they will appear invisible:
~ No method is used in the message. It makes special characters appear.
@ Outline
# Small Shadow
$ Big Shadow
% Selected Item
^ Light Bisel
& Small Bisel
* Medium Bisel
` Text is Drawn Normally, text effects can appear in the message.
Enjoy the script and give me the credit. Replies please! What do you think of this?