#===============================================================================
# * [ACE] Letter Animations
#===============================================================================
# * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
# * Version: 1.0
# * Updated: 06/01/2019
# * Requires: -------
#-------------------------------------------------------------------------------
# * < Change Log >
#-------------------------------------------------------------------------------
# * Version 1.0 (06/01/2019)
# - Initial release.
#-------------------------------------------------------------------------------
# * < Description >
#-------------------------------------------------------------------------------
# * This script will let you use image-sheets for the letters in the message
# window. The letters can be animated using these image-sheets.
#-------------------------------------------------------------------------------
# * < Script Calls >
#-------------------------------------------------------------------------------
# * To change the message box's letter style, use this script call BEFORE the
# "Show Message" event command:
#
# set_msg_win_style('style_key', hue)
#
# Replace the 'style_key' with a valid setting key from the 'Styles' setting
# area found in this script!
# You can also use nil here, in which case this script will be disabled until
# you use this script call again with a valid setting key instead of nil.
#
# Replace the hue with an integer number between 0 and 360.
# This will set the hue of the letter images.
# You can omit this argument, in which case 0 will be used automatically.
#
# Note that the effect of this script call is saved! Once you use this, the
# message box letter style will remain on the values you used the last time
# in this script call, even after loading a saved game!
#
# Examples:
#
# set_msg_win_style('default')
# set_msg_win_style('yellow')
# set_msg_win_style('curly_blue',126)
# set_msg_win_style('edgy_yellow_red',80)
#
#-------------------------------------------------------------------------------
# * < Image Setup >
#-------------------------------------------------------------------------------
# * First thing first, you must setup your character images before you can use
# this script.
# I won't lie, this can be a pretty boring job, but once it's done, you can
# use the completed character set any time you want in the future.
# * Each letter style used by this script must be in it's own separate folder!
# You can setup the folder used for each letter style separately in the script
# settings, so you have full control over this too.
# * You must have an image for each characters you use in your texts, even if
# they are only used once during a 120 hours game (which is highly unlikely,
# but still :D)! However, if you are sure that a character will not appear in
# a given letter style ever during your game, it is safe to leave that
# character out from that letter style's folder.
# * The letter image-sheets can have any size (width x height) and the image
# frames on them can be formatted in any way (rows x columns), but each
# image frame must have the same width and height!
# All image frames used in the drawing AND in the idle animation must be on
# the SAME image-sheet! You can select which image frames to use for which
# animation, so don't worry about that.
# * The image frames are "numbered" in a specific (and logical) way.
# The numbering starts from 0 (from the top-leftmost frame) and goes to
# infinity (to the bottom-rightmost frame).
# For example:
#
# -----------------
# | 0 | 1 | 2 | 3 |
# -----------------
# | 4 | 5 | 6 | 7 |
# -----------------
#
# You will use these index numbers in the :frames animation settings.
# * The image frames themselves must all have the same height in the same
# style! This is to let you adjust the vertical positions of your characters
# manually, since doing this automatically would lead to a pretty convoluted
# setting area, which is not what most of us want, right?
# This means that the height of your characters will always be the height
# between the top of the tallest character and the bottom of the smallest
# character. Well, this is the only way I can explain it, but if it's not
# enough, you can check the PSD files in each letter style folder, and check
# the "Guide Lines" layer folder to see what I mean. I marked the important
# vertical positioning lines there, so that I always know the vertical
# positioning of my characters. Note that those layers are only there as a
# guide, they do not affect anything in this script, nor are they needed for
# this script to work!
# Hahh! Got you! This is a copy/paste paragraph from another script of mine,
# I never really made sample images for this script, sorry! :P
# * There can be no empty pixels on the left or right side on your character
# images! The automatic character width calculation is based on the width of
# the character image frames, that's why there should be no useless empty
# pixels on the sides. The spacing between the characters itself can be setup
# for each letter styles separately in the script settings, so this part is
# not on your character images at all.
# Actually, you can have empty pixels on the image frames used in the drawing
# animation, since those are most probably incomplete letters until they are
# fully "drawn" anyway, but make sure that the image frames used in the idle
# animation don't have empty pixels on the sides!
# If you can't make the image frames this way, you can still adjust the
# spacing after specific letters and even between specific letters, so you can
# still use those images, but you will have a lot more to setup that way.
# * You can have whatever drawn on your character images. This script is meant
# to be used for text drawing, but that is not the only thing you can draw
# with it, it all depends on what you have on your character images.
#-------------------------------------------------------------------------------
# * < Installation >
#-------------------------------------------------------------------------------
# * Place this script below Materials but above Main!
# * If you are using my Control Configuration System script, place this script
# above those scripts!
#-------------------------------------------------------------------------------
# * < Compatibility Info >
#-------------------------------------------------------------------------------
# * No known incompatibilities.
# * There is no word-wrap feature in this script! There won't be one either,
# unless someone (othar than me) is willing to make an addon for that.
# This probably means that this script will not work well with word-wrap
# scripts.
#-------------------------------------------------------------------------------
# * < Known Issues >
#-------------------------------------------------------------------------------
# * No known issues.
#-------------------------------------------------------------------------------
# * < Terms of Use >
#-------------------------------------------------------------------------------
# * Free to use for whatever purposes you want.
# * Credit me (Sixth) in your game, pretty please! :P
# * Posting modified versions of this script is allowed as long as you notice me
# about it with a link to it!
#===============================================================================
$imported = {} if $imported.nil?
$imported["SixthLetterEX"] = true
#===============================================================================
# Settings:
#===============================================================================
module MsgLtrEX
#-----------------------------------------------------------------------------
# Letter Image Settings:
#-----------------------------------------------------------------------------
# This is where you will setup the character list and their image names.
# Each character you want to use in any letter style must be specified here.
#
# Format:
#
# 'character' => 'filename',
#
# The character can be any valid character, really.
# Although, sadly, the font type used in this editor does not support some
# (well, a lot of) extra character symbols, so you won't be able to set those
# up here.
#
# There are some extra characters which are normally not displayed, but you
# can still specify a filename for them and use them in your texts.
# One of them, for example, is the "\t" character, which denotes the paragraph
# character when the TAB key is pressed.
# The only special character which is processed automatically is the "\n"
# character which denotes a line-break. That won't be displayed at all, it
# will just start a new line, like it would normally.
#
# And this is a good place to state that you can insert a manual line-break
# with the "\n" character in your texts.
#
# The list I made contains most of the basic characters (letters, numbers,
# signs, etc) and some extra ones as well, but it is far from including all
# of the displayable characters, so feel free to add your own character
# settings here.
#
# The character image filenames you setup here are the default ones for all of
# your letter styles. You can change the filename for each character in your
# letter style setting area with the :img option if needed.
#
# I have noted some of the settings here with a "No image file setup!" line.
# That means that these characters don't have a character image for any letter
# style I made, so they are unusable in your texts until you make an image
# for them.
#-----------------------------------------------------------------------------
Letters = {
# Spaces:
' ' => 'space',
"\t" => 'tab',
# Lowercase letters:
'a' => 'a_lc', 'b' => 'b_lc', 'c' => 'c_lc', 'd' => 'd_lc', 'e' => 'e_lc',
'f' => 'f_lc', 'g' => 'g_lc', 'h' => 'h_lc', 'i' => 'i_lc', 'j' => 'j_lc',
'k' => 'k_lc', 'l' => 'l_lc', 'm' => 'm_lc', 'n' => 'n_lc', 'o' => 'o_lc',
'p' => 'p_lc', 'q' => 'q_lc', 'r' => 'r_lc', 's' => 's_lc', 't' => 't_lc',
'u' => 'u_lc', 'v' => 'v_lc', 'w' => 'w_lc', 'x' => 'x_lc', 'y' => 'y_lc',
'z' => 'z_lc',
# Uppercase letters:
'A' => 'a_uc', 'B' => 'b_uc', 'C' => 'c_uc', 'D' => 'd_uc', 'E' => 'e_uc',
'F' => 'f_uc', 'G' => 'g_uc', 'H' => 'h_uc', 'I' => 'i_uc', 'J' => 'j_uc',
'K' => 'k_uc', 'L' => 'l_uc', 'M' => 'm_uc', 'N' => 'n_uc', 'O' => 'o_uc',
'P' => 'p_uc', 'Q' => 'q_uc', 'R' => 'r_uc', 'S' => 's_uc', 'T' => 't_uc',
'U' => 'u_uc', 'V' => 'v_uc', 'W' => 'w_uc', 'X' => 'x_uc', 'Y' => 'y_uc',
'Z' => 'z_uc',
# Numbers:
'0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4',
'5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9',
# Signs:
'.' => 'point',
',' => 'comma',
';' => 'semicolon',
':' => 'doublepoint',
'!' => 'exclamation',
'?' => 'question',
'_' => 'underscore',
"'" => 'apostrophe1',
'`' => 'apostrophe2',
#'’' => 'apostrophe3', # No image file setup!
'"' => 'quote',
#'“' => 'quote1', # No image file setup!
#'”' => 'quote2', # No image file setup!
'@' => 'at',
'#' => 'numero',
'$' => 'dollar',
'€' => 'euro',
'£' => 'pound',
"\\" => 'lbrace',
'/' => 'rbrace',
# Math:
'+' => 'plus',
'-' => 'minus',
'*' => 'multiply',
'÷' => 'divide',
'=' => 'equal',
'~' => 'approx',
'%' => 'percent',
'^' => 'on_square',
'&' => 'and',
'|' => 'or',
'(' => 'lbracket_normal',
')' => 'rbracket_normal',
'[' => 'lbracket_square',
']' => 'rbracket_square',
'{' => 'lbracket_curly',
'}' => 'rbracket_curly',
'<' => 'smaller',
'>' => 'higher',
# <-- Add more character settings here if needed!
}
#-----------------------------------------------------------------------------
# Letter Style Settings:
#-----------------------------------------------------------------------------
# This is the place where you can setup the identifiers, folder, spacing and
# animation settings for your letter styles.
# You will use the setting keys from this setting in all letter style related
# things in the provided script call.
#
# Format:
#
# 'style_key' => {
# :folder => "folder_path/",
# :spacing => {
# :horz => value,
# :vert => value,
# 'char' => value,
# 'char1char2' => value,
# ...
# },
# :draw => {
# :cols => amount,
# :rows => amount,
# :frames => [index1, index2, ...],
# :wait => value,
# :repeat => amount,
# },
# :idle => {
# :cols => amount,
# :rows => amount,
# :frames => [index1, index2, ...],
# :wait => value,
# :repeat => amount,
# },
# 'char1' => {
# :img => "filename",
# :draw => { * draw_animation_settings_here * },
# :idle => { * idle_animation_settings_here * },
# },
# ...
# },
#
# You can make as many letter style settings as you want.
# The 'default' letter style setting must contain ALL setting options
# (excluding the character specific ones - those are optional even there)!
# The :folder option is the only one that is mandatory for ALL other letter
# style settings. If a letter style is missing some other setting options,
# those will be loaded from the 'default' letter style automatically.
# For this reason, you should never remove or rename the setting key for the
# 'default' letter style settings!
#
# If you don't use a 'style' argument for the letter style changing script
# call, the 'default' letter style will be used automatically.
#
# Okay, so that's all for the basics...
# Now lets see the details...
# I will break this into multiple sections for easier readability.
#
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# 1. Folder settings:
#
# :folder => "folder_path/",
#
# A simple option for start.
# You just enter the path of the folder containing all character images for
# the letter style here.
# Don't forget the "/" sign at the end, that is needed!
#
# Because there can be no files named the same in the same folder, you must
# set this up for ALL of your letter style settings!
#
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# 2. Spacing settings:
#
# :spacing => {
# :horz => value,
# :vert => value,
# 'char' => value,
# 'char1char2' => value,
# ...
# },
#
# This one seems a bit longer, but it's still simple enough...
#
# First, you have 2 static options:
# :horz - The default horizontal spacing between the letter images.
# :vert - The vertical spacing between each line drawn.
#
# And than you can add unlimited amount of custom horizontal spacing settings.
# You can do this 2 different ways:
#
# - Use this format: 'char' => value,
# You must replace the 'char' with a valid setting key from the
# 'Letters' setting area (found above this setting area).
# This will make the draw method use the spacing value you specify here AFTER
# the specified character.
# Example: 'a' => 1, '!' => 0,
#
# - Use this format: 'char1char2' => value,
# Here you must replace the 'char1char2' part with 2 valid setting keys from
# the 'Letters' setting area (found above this setting area).
# This will make the draw method use the spacing value you specify here
# BETWEEN the 2 specified characters.
# Example: 'av' => 0, 'BY' => 2,
#
# If none of the above 2 custom, letter specific horizontal spacing settings
# are set, the default value will be loaded automatically instead (from the
# :horz setting option).
#
# The value must be an integer number and it is measured in pixels!
#
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# 3. Animation settings:
#
# :draw/:idle => {
# :cols => amount,
# :rows => amount,
# :frames => [index1, index2, ...],
# :wait => value,
# :repeat => amount,
# },
#
# Another bigger setting group.
# This one will setup the default drawing/idle animation for your letters.
# Both animation setting groups (:draw and :idle) got the same setting options
# and layout, so I will just merge the details on them here.
#
# When the letter is drawn, it will start out with the :draw animation
# settings. This will let you make a drawing animation for each of your
# letters.
# When this draw animation is finished, the letter will switch to the :idle
# animation settings. This will let you make a separate animation for the
# letters when they are "finished the drawing", or you can just simply use it
# for stopping the animation, and let the letter be static for the rest of the
# day.
# The letters will keep appearing one after the other, each waiting for the
# previous letter's :draw animation to finish. For that reason, you may want
# to consider using short draw animations with only a few frames or a very
# quick one with more frames (the latter will definitely look smoother),
# otherwise the player will get bored of it, or even worse, will get annoyed
# by it.
# Note that when the player presses the "skip" or "fast-forward" button, the
# :draw animation ends immediately for all letters and the whole text will be
# displayed at once (all letters also switch to their :idle animation).
#
# The animation is made by using image-sheets for your letters.
# This image sheet can be formatted in any way, and can be any size.
# The :cols and :rows options will setup the formatting of the image-sheet.
# For example, if you have an image-sheet containing 8 image frames in a
# 2 x 4 format, you will have to set the :rows setting to 2 and the :cols
# setting to 4.
# You don't have to use all image frames from the image-sheet, you have the
# option to select exactly which frames you want to use and in which order
# with the next setting option.
#
# The :frames setting option will let you setup which image frames you want
# to use from the image-sheet, how many times you want to use them in the
# animation cycle and in which order you want to use them.
# For more information about getting the correct image frame indexes for this
# setting, head to the "Image Setup" details found in the header of this
# script.
# You must enter at least one image frame into this setting array!
# You can use unlimited amount of image frames here, and you can re-use the
# same image frame index multiple times as well if needed.
#
# The :wait setting option will let you control the speed of the animation
# cycle. This must be an integer number, 0 or higher!
# The higher the value you set here, the slower the animation gets!
#
# The :repeat option will let you setup how many times the animation cycle
# repeats before stopping the animation. The animation will stop on the last
# image frame from the :frames setting option.
# If you set this to 0, the animation will be blocked completely (so, the
# drawn letter images will NOT be animated at all), and if you set it to -1,
# the animation cycle will repeat endlessly.
# If you set it to 1 or higher, the animation cycle will stop after that many
# repeats.
#
# You may want to setup static (not animated) letters, especially for the
# :idle animation settings. You can do so by setting the :repeat option to 0,
# and by entering only 1 frame index into the :frames setting array.
# The :wait setting is irrelevant in this case, but you must setup a valid
# value for it still!
# The rest of the settings must be setup properly, even if you don't want to
# animate the letter (:cols and :rows).
#
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# 4. Character specific settings:
#
# 'char1' => {
# :img => "filename",
# :draw => { * draw_animation_settings_here * },
# :idle => { * idle_animation_settings_here * },
# },
#
# These setting groups are optional only!
# With these, you can setup a custom image-sheet name, and animation settings
# for each of your letters in a letter style.
#
# The 'char1' setting key must be replaced by a valid setting key used in the
# 'Letters' setting area (found above this setting area). The settings in the
# character specific setting groups will apply to the specified character
# only!
#
# The :img setting option will let you setup a custom image-sheet filename
# for the letter. I don't recommend using this option. It is much better to
# just stick with the same filenames for all of your letter styles, since the
# letter images must be in different folders for each letters styles anyway.
#
# The :draw and :idle setting options will setup a custom drawing/idle
# animation for the letter. This can come in handy, since a drawing animation
# for the 'M' letter could have more animation frames than, for example, the
# '!' sign has.
#
# All setting options here are optional, so you can leave out the ones you
# don't want to modify for the letter (they will use the default ones instead
# that way).
# But keep in mind that if you use the :draw or the :idle setting groups here,
# you must setup ALL setting options for those groups (:rows, :cols, :frames,
# :wait and :repeat)!
#
# You can enter unlimited amount of character specific settings here!
#
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# And this would be it.
#
#-----------------------------------------------------------------------------
Styles = {
#-----------------------------------------------------------------------------
'default' => {
# Folder for the letter images
:folder => "Graphics/FontEX/Microsoft Himalaya/s23_white_gray_grad/",
# Spacing settings:
:spacing => {
:horz => 1, :vert => 2,
},
# Default drawing animation settings
:draw => {
:rows => 1, :cols => 1, :wait => 6, :repeat => 0,
:frames => [0],
},
# Default idle animation settings
:idle => {
:rows => 1, :cols => 1, :wait => 6, :repeat => 0,
:frames => [0],
},
# Letter image settings:
# Add custom animation settings for your letters here if needed.
# Format:
# 'letter' => {:draw => {*settings*}, :idle => {*settings*}},
#
},
#-----------------------------------------------------------------------------
'yellow' => {
:folder => "Graphics/FontEX/WST_Engl/s21_yellow_grad/",
:spacing => {
:horz => 1, :vert => -2,
},
},
#-----------------------------------------------------------------------------
# <-- Add more letter style setting here!
}
#===============================================================================
# End of settings! O.o
#===============================================================================
def self.get_data(sky,opt,*edt)
dt = Styles['default'].merge(Styles[sky] || {})
case opt
when :img # edt = char
if dt[edt[0]] && dt[edt[0]][:img]
return dt[edt[0]][:img]
else
return Letters[edt[0]]
end
when :spacing # edt = [:horz/:vert,char1,char2]
case edt[0]
when :horz
if edt[2]
ky = edt[1] + edt[2]
return dt[:spacing][ky] if dt[:spacing][ky]
end
return dt[:spacing][edt[1]] || dt[:spacing][:horz]
when :vert
return dt[:spacing][:vert]
end
when :draw, :idle # edt = [char]
if dt[edt[0]] && dt[edt[0]][opt]
return dt[edt[0]][opt]
else
return dt[opt]
end
else
return dt[opt]
end
end
end
module Cache
@ltr_ex_cache = {}
def self.letter_ex(fname,folder,hue=0)
fky = [folder,hue]
@ltr_ex_cache[fky] = [] if @ltr_ex_cache[fky].nil?
@ltr_ex_cache[fky] << fname unless @ltr_ex_cache[fky].include?(fname)
load_bitmap(folder,fname,hue)
end
def self.clear_letter_ex(*styles)
styles.each do |style|
case style
when Array
dt = MsgLtrEX::Styles['default'].merge(MsgLtrEX::Styles[style[0]] || {})
folder = dt[:folder]
fky = [folder,style[1]]
else
dt = MsgLtrEX::Styles['default'].merge(MsgLtrEX::Styles[style] || {})
folder = dt[:folder]
fky = [folder,0]
end
next unless @ltr_ex_cache[fky]
@ltr_ex_cache[fky].each do |img|
if fky[1] == 0 # No hue change
ky = folder + img
else # Custom hue
ky = [folder + img,fky[1]]
end
@cache[ky].dispose
@cache.delete(ky)
end
@ltr_ex_cache.delete(fky)
end
end
def self.preload_letter_ex(styles)
styles.each do |style,sdt|
# Load normal characters, no hue change
letters = (sdt[:load] || MsgLtrEX::Letters.keys).clone
letters -= sdt[:skip] if sdt[:skip]
fold = MsgLtrEX.get_data(style,:folder)
letters.each do |ch|
Cache.letter_ex(MsgLtrEX.get_data(style,:img,ch),fold,0)
end
if sdt[:hue] # Load custom hue types if there is any
sdt[:hue].each do |hue,hdt|
letters = (hdt[:load] || MsgLtrEX::Letters.keys).clone
letters -= hdt[:skip] if hdt[:skip]
letters.each do |ch|
Cache.letter_ex(MsgLtrEX.get_data(style,:img,ch),fold,hue)
end
end
end
end
end
end
class AnImgEX6 < Sprite
attr_accessor :data, :pause
def initialize(data,view=nil,fold="Graphics/Pictures/")
@data = data; @view = view
@folder = fold unless @folder
@counter = @data[:wait]
@repeat = @data[:repeat] || -1
@pattern = @cmd_y = 0
@cols = @data[:cols] || 1
@rows = @data[:rows] || 1
super(view)
setup_sprite
reset_frames
end
def setup_sprite
self.bitmap = Cache.custom(@data[:img],@folder).clone
self.opacity = @data[:opacity] if @data[:opacity]
self.z = @data[:z] if @data[:z]
self.src_rect.width = self.bitmap.width/@cols
self.src_rect.height = self.bitmap.height/@rows
self.ox = self.src_rect.width/2
self.oy = self.src_rect.height/2
end
def change_image_data(data)
@data = data
@cols = @data[:cols] || 1
@rows = @data[:rows] || 1
self.bitmap.dispose if self.bitmap && !self.bitmap.disposed?
setup_sprite
if @data[:frames][@pattern].nil?
reset_frames
else
reset_frames(@pattern)
end
end
def reset_frames(ptrn=0)
@counter = @data[:wait]
@pattern = ptrn
frm = @data[:idle] || @data[:frames][@pattern]
if @cols > 1
self.src_rect.x = (frm % @cols) * self.src_rect.width
else
self.src_rect.x = 0
end
if @rows > 1
self.src_rect.y = (frm / @cols) * self.src_rect.height
else
self.src_rect.y = 0
end
end
def update
super
update_sprite_frames unless @pause
end
def update_sprite_frames
return if @repeat == 0
if @counter > 0
@counter -= 1
else
@counter = @data[:wait]
@pattern += 1
if @pattern >= @data[:frames].size
@pattern = 0
@repeat -= 1 if @repeat > 0
end
if @cols > 1
mx = @data[:frames][@pattern] % @cols
self.src_rect.x = mx * self.src_rect.width
end
if @rows > 1
my = @data[:frames][@pattern] / @cols
self.src_rect.y = my * self.src_rect.height
end
end
end
end
class LetterEX < AnImgEX6
attr_accessor :letter, :nletter, :pattern
def initialize(letter,nletter,lhue,data,view=nil,fold="Graphics/Pictures/")
@letter = letter
@nletter = nletter
@lhue = lhue
super(data,view,fold)
end
def setup_sprite
self.bitmap = Cache.letter_ex(@data[:img],@folder,@lhue).clone
self.opacity = @data[:opacity] if @data[:opacity]
self.z = @data[:z] if @data[:z]
self.src_rect.width = self.bitmap.width/@cols
self.src_rect.height = self.bitmap.height/@rows
self.ox = self.src_rect.width/2
self.oy = self.src_rect.height/2
end
end
class Window_Base < Window
attr_accessor :letters, :ltr_style
alias add_ltr_vars8815 initialize
def initialize(x, y, width, height)
init_ltr_vars
add_ltr_vars8815(x, y, width, height)
end
def init_ltr_vars
@letters = []
end
def setup_ltr_vars(sky='default',hue=0)
@ltr_style = sky
@ltr_hue = hue
return unless sky
@ltr_folder = MsgLtrEX.get_data(sky,:folder)
end
def draw_text_ex(x, y, text)
reset_font_settings
text = convert_escape_characters(text)
pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
pos[:text] = text
process_character(text.slice!(0, 1), text, pos) until text.empty?
end
alias add_ltr_proc8861 process_normal_character
def process_normal_character(c, pos)
if @ltr_style
process_letter_ex(c, pos)
else
add_ltr_proc8861(c, pos)
end
end
def process_letter_ex(c, pos)
fname = MsgLtrEX.get_data(@ltr_style,:img,c)
nc = pos[:text][0]
hsp = MsgLtrEX.get_data(@ltr_style,:spacing,:horz,c,nc)
ddt = MsgLtrEX.get_data(@ltr_style,:draw,c)
ldt = ddt.clone
ldt[:img] = fname
ldt[:opacity] = self.contents_opacity
ldt[:z] = self.z
ltr = LetterEX.new(c,nc,@ltr_hue,ldt,self.viewport,@ltr_folder)
@letters << ltr
ltr.x = self.x + standard_padding + ltr.ox + pos[:x]
ltr.y = self.y + standard_padding + ltr.oy + pos[:y]
tw = ltr.src_rect.width + hsp
pos[:x] += tw
end
alias add_nline_ex8876 process_new_line
def process_new_line(text, pos)
if @ltr_style
process_new_line_ltr_ex(text, pos)
else
add_nline_ex8876(text, pos)
end
end
def process_new_line_ltr_ex(text, pos)
pos[:x] = pos[:new_x]
if @letters[-1]
pos[:height] = @letters[-1].src_rect.height
else
pos[:height] = calc_line_height(text)
end
pos[:y] += pos[:height] + MsgLtrEX.get_data(@ltr_style,:spacing,:vert)
end
alias upd_letter_ex9926 update_tone
def update_tone
upd_letter_ex9926
@letters.each {|ltr| ltr.update }
end
def dispose_letters
@letters.each {|ltr| ltr.dispose }
@letters = []
end
def dispose
dispose_letters
super
end
end
class Window_Message < Window_Base
alias restart_opa9974 update_background
def update_background
restart_opa9974
self.contents_opacity = 255
@ltr_style = $game_system.ltr_style
@ltr_hue = $game_system.ltr_hue
return unless @ltr_style
@ltr_folder = MsgLtrEX.get_data(@ltr_style,:folder)
end
alias add_txt_ltr_ex7541 new_page
def new_page(text, pos)
add_txt_ltr_ex7541(text, pos)
pos[:text] = text
dispose_letters
end
def close
if @ltr_style
until @letters.all? {|ltr| ltr.opacity == 0 }
@letters.each {|ltr| ltr.opacity -= 28 }
self.contents_opacity -= 28
Fiber.yield
end
dispose_letters
end
super
end
alias wait_ltr_ex7751 wait_for_one_character
def wait_for_one_character
if @ltr_style
wait_for_ltr_ex
else
wait_ltr_ex7751
end
end
def wait_for_ltr_ex
if @letters[-1]
dt = @letters[-1].data
wtime = [dt[:frames].size * dt[:wait] * dt[:repeat],1].max
wtime.times do
update_show_fast
break if @show_fast || @line_show_fast
Fiber.yield
end
ddt = MsgLtrEX.get_data(@ltr_style,:idle,@letters[-1].letter)
ldt = ddt.clone
ldt[:img] = dt[:img]
ldt[:opacity] = dt[:opacity]
ldt[:z] = dt[:z]
@letters[-1].change_image_data(ldt)
end
end
end
class Game_System
attr_accessor :ltr_style, :ltr_hue
end
class Scene_Base
attr_accessor :message_window
end
class Game_Interpreter
def set_msg_win_style(sky='default',hue=0)
$game_system.ltr_style = sky
$game_system.ltr_hue = hue
end
end
#==============================================================================
# !!END OF SCRIPT - OHH, NOES!!
#==============================================================================