[Script] [ACE] [Map] Animated Map Name

sanggameboysanggameboy Posts: 1,943Registered
[align=center][size=x-large]Animated Map Name[/size][/align]

[chapter]Giới thiệu[/chapter]
Hiện hiệu ứng giới thiệu tên Map, rất mượt, rất đẹp.

[chapter]Hình ảnh[/chapter]
Map_Name_ss.png

amnss2.png

[chapter]Tính năng[/chapter]
Có nhiều loại, mỗi map có thể tạo một phong cách hiện riêng, vd:
Icon, Font, Size...v.v...

[chapter]Cách sử dụng[/chapter]
Bỏ trên script Main là được

[chapter]Script[/chapter]
=begin =========================================================================
Dekita's                                                                   v1.4
                             ★ Animatéd Map Namé™ ★

================================================================================
 Script Information:
====================
 This script creates a highly dynamic and customisable map name "window"
 and gives the ability to remove the old (shit) one.
 
 Features :~
 Multiple effect types,
 Each map can have its own unique map name display features, such as...
 Location, Icon, Font, Size, Effect, ect.
  
================================================================================
 ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
================================================================================
 1. You must give credit to "Dekita"
 2. You are NOT allowed to repost this script.(or modified versions)
 3. You are NOT allowed to convert this script.(into other game engines e.g RGSS2)
 4. You are NOT allowed to use this script for Commercial games.
 5. ENJOY!

"FINE PRINT" 
By using this script you hereby agree to the above terms and conditions, 
 if any violation of the above terms occurs "legal action" may be taken.
Not understanding the above terms and conditions does NOT mean that 
 they do not apply to you.
If you wish to discuss the terms and conditions in further detail you can 
contact me at http://dekitarpg.wordpress.com/ or DekitaRPG@gmail.com 

================================================================================
 History:
=========
 D /M /Y
 21/o1/2o13 - Added individual letter position to fix the rpg maker
              "irregular letter" bug,(for map name window only obviously)
 11/o1/2o13 - increased efficiency,
            - added background option,
            - fixed bug, (icons not doing name effect properly)
 o9/o1/2o13 - added 18 effects,
 o8/o1/2o13 - added 8 effects,
              fixed bug, (typo)
 o6/o1/2o13 - started && finished,
 
================================================================================
 Known Bugs:
============
 N/A
 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 If a new bug is found please contact me at
 http://dekitarpg.wordpress.com/ 
 
================================================================================
 INSTRUCTIONS:
==============
 Place this script UNDER "▼ Materials" and ABOVE "▼ Main" in your script editor.

================================================================================
 SCRIPT CALLS:
=============
 reset_map_name
 ^ Does what it says.(and resets the map name display trigger and shows it again)
 
================================================================================
 NOTETAGS: (map noteboxes)
==========

 Font_Name_Tags :
 <FONT NAME: X> 
 <FN: X>
 replace X with the Font_Name array index.
 
 Font_Size_Tags :
 <FONT SIZE: X>
 <FS: X>
 replace X with the font size.
 
 Font_Bold_Tags : 
 <FONT BOLD: bool>
 <FB: bool>
 replace bool with true or false

 Font-italic_Tags :
 <FONT ITALIC: bool>
 <FI: bool>
 replace bool with true or false
 
 Font_Color_Tags :
 (main color tags)
   <FONT COLOR: red, grn, blu, alp>
   <FC: red, grn, blu, alp>
 (outline color tags)
   <FONT OUT COLOR: red, grn, blu, alp>
   <FOC: red, grn, blu, alp>
 red = the red value of the font
 grn = the green value of the font
 blu = the blue value of the font
 alp = the alpha value of the font
 
 Icon_id_Tags :
 <NAME ICON: X>
 <ICON: X>
 <NI: X>
 replace x with the icon id from your iconset
 
 Icon_Position_Tags :
 <ICON POS: x, y>
 <IP, x, y>
 x / y = the screen position.
 
 Icon_Center_Tags :
 <ICON CENTER: bool_X, bool_Y>
 <ICEN: bool_X, bool_Y>
 bool_X / bool_Y should be replaced with true or false  e.g <ICEN: true, false> 
               this would center the icon's x value in the middle but not the y

 Icon_Effect_Tags :
 <ICON EFFECT: bool>
 <IC: bool>
 bool = true or false
 
 Map_Name_Effect_Tags :
 <NAME EFFECT: id>
 <NAME EFF: id>
 <NE: id>
 id = the effect id for this map.
 
 <NO NAME EFFECT>
 <NO NAME EFF>
 <NO NE>
 makes this map have no name effect
 
 Map_Name_Slide_Tags :
 <NAME SLIDE: dist>
 <NS DIST: dist>
 <NSD: dist>
 dist = the distance of the slide, eg. 180
 
 Map_Name_Position_Tags :
 <NAME POS: x, y>
 <NP: x, y>
 x, y = the position of the map name
 
 <NAME CENTER: bool_X, bool_Y>
 <NCEN: bool_X, bool_Y>
 bool_X / bool_Y should be replaced with true or false  e.g <NCEN: true, false> 
               this would center the name's x value in the middle but not the y

 Map_Name_L_S_D_Tags :
 <NAME DELAY: val>
 <ND: val>
 val = the delay value from one letter showing till the next.
 
 BACKGROUND NOTETAGS : 
 <BACKGROUND: "IMAGE NAME">
 <BG: "IMAGE NAME">
 These notetags will change the maps background image name,
 for use if you want t use a special image for a background box :p
 
 <BGPOS: x, y>
 <BGP: x, y>
 Background box position.
 
 <SHOW BG: bool>
 <SBG: bool>
 Do you want to show the background ? bool = true / false
 

 Single Huge Notetag :
 Tired of putting loads of litte '<' and '>' ? use this notetag .
 <MAP NAME>
 # -- notes go here
 <\MAP NAME>
 or 
 <MNW>
 # -- notes go here
 <\MNW>
 
 the notes for inside these notetags are the same as above without the '<' and '>'
 e.g 
 
 <MNW>
 FN: X
 FS: X
 FB: bool
 FI: bool
 FC: red, grn, blu, alp
 FOC: red, grn, blu, alp
 NI: X
 IP, x, y
 ICEN: bool_X, bool_Y
 IC: bool
 NE: id
 NO NE
 NSD: dist
 NP: x, y
 NCEN: bool_X, bool_Y
 ND: val
 BG: "IMAGENAME"
 BGP: x, y
 SBG: bool
 </MNW>
 
 <LET: id, x, y>
 <letter id, x, y>
 id = the id position of the letter, the first letter is 0, second = 1 ect.
 x = the extra distance added to the origional x position of this letter
 y = the extra distance added to the origional y position of this letter
 NOTE : This notetag cannot be used within the "large notetag"
 NOTE" : You can put as may of this notetag into a map's notebox as you like
 e.g
 <let: 0, 2, 0>
 <let: 1, 2, 0>
 <let: 3, 2, 0>
 
=end #=========================================================================#
module Map_Name_Window
Font_Name=[]#Do Not Delete.

  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  # ★ GENERAL SETTINGS ★
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  
  Remove_Default_Name_Window = true # obviously...
  
  # Z value for the new map name "window" reccommended to be about 200
  Map_Name_z = 200
  
  # The delay from entering the map till the name begins to show. (Frames)
  Delay_Timer = 30
  
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  # ★ FONT SETTINGS ★
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  
  # This adjusts the fonts used for your maps. If the font at the start of
  # the array doesn't exist on the player's computer, it'll use the next one.
  # the games default font will be used if a maps font name is unspecified.
  Font_Name[0] = ["VL Gothic"    , Font.default_name]
  Font_Name[1] = ["Arial"        , Font.default_name]
  Font_Name[2] = ["Xirod"        , Font.default_name]
  Font_Name[3] = ["Comic Sans MS", Font.default_name]
  Font_Name[4] = ["Verdana"      , Font.default_name]
  Font_Name[5] = ["Arial"        , Font.default_name]
  Font_Name[6] = ["Courier"      , Font.default_name]

  Font_Size = 16
  
  Font_Bold = true
  
  Font_Italic = true
  
  Font_Color = [ 255, 255, 255, 255 ] # [ red, grn, blu, alpha ]

  Font_Out_Col=[ 0  , 0  , 0  , 128 ] # Font outline color, same format as above.
  
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  # ★ ICON SETTINGS ★
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  
  #Icon= [ use? , icon id ] 
  Icon = [ true , 304 ] # Default iconset map icon = 231
  
  Icon_Pos  = [15, 15] # [x, y] (position of the icon)
  
  Icon_Has_Effects = true # Icon has the same effects as letters ?
  
  Center_Icon = [ false , false ] # format = [ center x ? , center y ? ]
  
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  # ★ LETTER SETTINGS ★
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

  Map_Name_Pos = [25, 10] # [x, y] (position of the first letter in the map name)
  
  # The delay between each letter showing, this results in a fade like effect.
  L_S_D_Timer = 15
  
  Center_Name = [ false , false ] # format = [ center x ? , center y ? ]
  
  Slide_Distance = Graphics.width / 4 # the distance that letters slide.
  
  Letter_Effects = true # do letters have effects ? e.g slide, spin...
  
  L_Effect_Type = 0
  # 0 = Basic Left Slide
  # 1 = Basic Right Slide
  # 2 = Top Drop Left Slide
  # 3 = Top Drop Right Slide
  # 4 = Bottoms up Left Slide
  # 5 = Bottoms up Right Slide
  # 6 = Basic Left Spin
  # 7 = Basic Right Spin
  # 8 = Basic Left Swirl Top
  # 9 = Basic Left Swirl Bottom
  # 10 = Basic Right Swirl Bottom
  # 11 = Basic Right Swirl Top
  # 12 = Slide Up
  # 13 = Slide Down
  # 14 = Slide Up & Left
  # 15 = Slide Up & Right
  # 16 = Slide Down & Left
  # 17 = Slide Down & Right
  # 18 = Slide Up & Left, Left Spin
  # 19 = Slide Up & Left, Right Spin
  # 20 = Slide Up & Right, Left Spin
  # 21 = Slide Up & Right, Right Spin
  # 22 = Slide Down & Left, Left Spin
  # 23 = Slide Down & Left, Right Spin
  # 24 = Slide Down & Right, Left Spin
  # 25 = Slide Down & Right, Right Spin

  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  # ★ BACKGROUND SETTINGS ★
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

  # Basic background color , format = (red , green , blue , alpha)
  BackGound_Color_1 = Color.new(0,0,0,128)
  BackGound_Color_2 = Color.new(0,0,0,0)
  
  Show_Background = true#false # self explanitory
  
  # This is the name of the folder you want to store your map name bg images in,
  # This MUST be within your games poject folder.
  BG_Image_Folder = "Graphics/Map Windows/"

end # DO NOT DELETE #
module M_N_W_RegExp #
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  # ★ REGEXP SETTINGS ★ 
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  # only change these if you know what you are doing.
  #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  
  F_Name = /(?:FONT NAME|font name|FN|fn):[ ](\d+)/
  F_Size = /(?:FONT SIZE|FS):[ ](\d+)/i
  F_Bold = /(?:FONT BOLD|FB):[ ](.*)/i
  F_Ital = /(?:FONT ITALIC|FI):[ ](.*)/i
  F_Col_ = /(?:FONT COLOR|FC):[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i
  F_OCol = /(?:FONT OUT COLOR|FOC):[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i
  Icon   = /(?:NAME ICON|ICON|NI):[ ](\d+)/i
  IPos   = /(?:ICON POS|IP):[ ](\d+),[ ](\d+)/i
  ICent  = /(?:ICON CENTER|ICEN):[ ](.*),[ ](.*)/i
  IEffs  = /(?:ICON EFFECT|IEFF):[ ](.*)/i
  Eff    = /(?:NAME EFFECT|NAME EFF|NE):[ ](\d+)/i
  NEff   = /(?:NO NAME EFFECT|NO NAME EFF|NO NE)/i
  Slide  = /(?:NAME SLIDE|NS DIST|NSD):[ ](\d+)/i
  Posi   = /(?:NAME POS|NP):[ ](\d+),[ ](\d+)/i
  Pos2   = /(?:NAME CENTER|NCEN):[ ](.*),[ ](.*)/i
  LSD_   = /(?:NAME DELAY|ND):[ ](\d+)/i
  Large  = /<(?:MAP NAME|MNW)>([^><]*)<\/(?:MAP NAME|MNW)>/im
  BG__   = /(?:BACKGROUND|BG):[ ]"(.*)"/i
  BGpos  = /(?:BGPOS|BGP):[ ](\d+),[ ](\d+)/i
  BGshow = /(?:SHOW BG|SBG):[ ](.*)/i
  Letter_Fixx = /<(?:LET|letter):[ ](\d+), (\d+), (\d+)>/i
                            #####################
                            # CUSTOMISATION END #
end                         #####################
#☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
#                                                                               #
#                       http://dekitarpg.wordpress.com/                         #
#                                                                               #
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
#===============================================================================#
# ARE YOU MODIFYING BEYOND THIS POINT? \.\.                                     #
# YES?\.\.                                                                      #
# OMG, REALLY? \|                                                               #
# WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\..                              #
# I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\..                                #
#===============================================================================#

$imported = {} if $imported.nil?
$imported[:Dekita_Anim_Map_Name] = true

#===============================================================================#
class RPG::Map
#===============================================================================#

  attr_reader(:map_name_font_name)
  attr_reader(:map_name_font_size)
  attr_reader(:map_name_font_bold)
  attr_reader(:map_name_font_ital)
  attr_reader(:map_name_font_col_)
  attr_reader(:map_name_font_ocol)
  attr_reader(:map_name_icon)
  attr_reader(:map_name_icon_pos)
  attr_reader(:map_name_icon_pos_centered)
  attr_reader(:map_name_icon_gets_effects)
  attr_reader(:map_name_effect)
  attr_reader(:map_name_slide_dist)
  attr_reader(:map_name_letter_show_delay)
  attr_reader(:map_name_position)
  attr_reader(:map_name_position_centered)
  attr_reader(:map_name_bg)
  attr_reader(:map_name_bg_pos)
  attr_reader(:map_name_bg_show)
  attr_reader(:map_name_ind_let_fixx)

  def get_map_name_icon_info
    @map_name_font_name = Font.default_name
    @map_name_font_size = Map_Name_Window::Font_Size
    @map_name_font_bold = Map_Name_Window::Font_Bold
    @map_name_font_ital = Map_Name_Window::Font_Italic
    @map_name_font_col_ = Map_Name_Window::Font_Color
    @map_name_font_ocol = Map_Name_Window::Font_Out_Col
    @map_name_icon = Map_Name_Window::Icon
    @map_name_icon_pos = Map_Name_Window::Icon_Pos
    @map_name_icon_pos_centered = Map_Name_Window::Center_Icon
    @map_name_icon_gets_effects = Map_Name_Window::Icon_Has_Effects
    @map_name_effect = [Map_Name_Window::Letter_Effects,Map_Name_Window::L_Effect_Type]
    @map_name_slide_dist = Map_Name_Window::Slide_Distance
    @map_name_position = Map_Name_Window::Map_Name_Pos
    @map_name_position_centered = Map_Name_Window::Center_Name
    @map_name_letter_show_delay = Map_Name_Window::L_S_D_Timer
    @map_name_bg = nil
    @map_name_bg_pos = @map_name_position
    @map_name_bg_show = Map_Name_Window::Show_Background
    @map_name_ind_let_fixx = []
    self.note.split(/[\r\n]+/).each { |line| ; case line 
    when /<#{M_N_W_RegExp::F_Name}>/ ; @map_name_font_name = Map_Name_Window::Font_Name[$1.to_i]
    when /<#{M_N_W_RegExp::F_Size}>/ ; @map_name_font_size = $1.to_i
    when /<#{M_N_W_RegExp::F_Bold}>/ ; @map_name_font_bold = $1.to_s
    when /<#{M_N_W_RegExp::F_Ital}>/ ; @map_name_font_ital = $1.to_s
    when /<#{M_N_W_RegExp::F_Col_}>/ ; @map_name_font_col_ = [$1.to_i,$2.to_i,$3.to_i,$4.to_i]
    when /<#{M_N_W_RegExp::F_OCol}>/ ; @map_name_font_ocol = [$1.to_i,$2.to_i,$3.to_i,$4.to_i,]
    when /<#{M_N_W_RegExp::Icon}>/  ; @map_name_icon = [true, $1.to_i]
    when /<#{M_N_W_RegExp::IPos}>/  ; @map_name_icon_pos = [$1.to_i, $2.to_i]
    when /<#{M_N_W_RegExp::ICent}>/ ; @map_name_icon_pos_centered = [$1.to_s.downcase, $2.to_s.downcase]
    when /<#{M_N_W_RegExp::IEffs}>/ ; @map_name_icon_gets_effects = $1.to_s.downcase
    when /<#{M_N_W_RegExp::Eff}>/   ; @map_name_effect = [true, $1.to_i]
    when /<#{M_N_W_RegExp::NEff}>/  ; @map_name_effect = [false, 0]
    when /<#{M_N_W_RegExp::Slide}>/ ; @map_name_slide_dist = $1.to_i
    when /<#{M_N_W_RegExp::Posi}>/  ; @map_name_position = [$1.to_i, $2.to_i]
    when /<#{M_N_W_RegExp::Pos2}>/  ; @map_name_position_centered = [$1.to_s.downcase, $2.to_s.downcase]
    when /<#{M_N_W_RegExp::LSD_}>/  ; @map_name_letter_show_delay = $1.to_i
    when /<#{M_N_W_RegExp::BG__}>/  ; @map_name_bg = $1.to_s
    when /<#{M_N_W_RegExp::BGpos}>/ ; @map_name_bg_pos = [$1.to_i, $2.to_i]
    when /<#{M_N_W_RegExp::BGshow}>/ ; @map_name_bg_show = $1.to_s.downcase
    when M_N_W_RegExp::Letter_Fixx
      @map_name_ind_let_fixx.push([$1.to_i, $2.to_i, $3.to_i])
    end ; } # self.note.split
    get_mni(self.note) 
  end
  
  def get_mni(note)
    note.scan(M_N_W_RegExp::Large) { setup_map_name_info($1) }
  end

  def setup_map_name_info(info)
    @map_name_font_name = Map_Name_Window::Font_Name[$1.to_i] if info =~ M_N_W_RegExp::F_Name
    @map_name_font_size = $1.to_i if info =~ M_N_W_RegExp::F_Size
    @map_name_font_bold = $1.to_s.downcase if info =~ M_N_W_RegExp::F_Bold
    @map_name_font_ital = $1.to_s.downcase if info =~ M_N_W_RegExp::F_Ital      
    @map_name_font_col_ = [$1.to_i,$2.to_i,$3.to_i,$4.to_i] if info =~ M_N_W_RegExp::F_Col_
    @map_name_font_ocol = [$1.to_i,$2.to_i,$3.to_i,$4.to_i] if info =~ M_N_W_RegExp::F_OCol
    @map_name_icon   = [true,$1.to_i] if info =~ M_N_W_RegExp::Icon
    @map_name_icon_pos = [$1.to_i, $2.to_i] if info =~ M_N_W_RegExp::IPos
    @map_name_icon_pos_centered = [$1.to_s.downcase, $2.to_s.downcase] if info =~ M_N_W_RegExp::ICent
    @map_name_icon_gets_effects = $1.to_s.downcase if info =~ M_N_W_RegExp::IEffs
    @map_name_effect = [true,$1.to_i] if info =~ M_N_W_RegExp::Eff
    @map_name_effect = [false, 0]     if info =~ M_N_W_RegExp::NEff
    @map_name_slide_dist = $1.to_i    if info =~ M_N_W_RegExp::Slide
    @map_name_position = [$1.to_i,$2.to_i]  if info =~ M_N_W_RegExp::Posi
    @map_name_position_centered = [$1.to_s.downcase, $2.to_s.downcase] if info =~ M_N_W_RegExp::Pos2
    @map_name_letter_show_delay = $1.to_i if info =~ M_N_W_RegExp::LSD_
    @map_name_bg = $1.to_s if info =~ M_N_W_RegExp::BG__
    @map_name_bg_pos = [$1.to_i,$2.to_i] if info =~ M_N_W_RegExp::BGpos
    @map_name_bg_show = $1.to_s.downcase if info =~ M_N_W_RegExp::BGshow
  end  

end

#==============================================================================
module Cache
#==============================================================================
  
  def self.mapname_im(filename)
    load_bitmap(Map_Name_Window::BG_Image_Folder, filename)
  end
  
end

#==============================================================================
class Game_Temp
#==============================================================================

  attr_accessor :mapname
  
  alias :map_name_initialize_GT :initialize
  def initialize
    map_name_initialize_GT
    @mapname = nil
  end  
  
end

#===============================================================================#
class Game_Map
#===============================================================================#
 
  alias :map_nameGMsetup :setup
  def setup(map_id)
    map_nameGMsetup(map_id)
    @map.get_map_name_icon_info
  end
  
  def setup_map_name_info
  end

  def map_name_icon
    @map.map_name_icon
  end
  
  def map_name_icon_pos_x
    @map.map_name_icon_pos[0]
  end
  
  def map_name_icon_pos_y
    @map.map_name_icon_pos[1]
  end

  def map_name_icon_pos_x_center?
    @map.map_name_icon_pos_centered[0]
  end
  
  def map_name_icon_pos_y_center?
    @map.map_name_icon_pos_centered[1]
  end
  
  def map_name_icon_effects?
    @map.map_name_icon_gets_effects
  end

  def map_name_effect
    @map.map_name_effect
  end
  
  def map_name_slide
    @map.map_name_slide_dist
  end
  
  def map_name_font_name
    @map.map_name_font_name
  end

  def map_name_font_size
    @map.map_name_font_size
  end
  
  def map_name_font_bold
    @map.map_name_font_bold
  end
  
  def map_name_font_italic
    @map.map_name_font_ital
  end
  
  def map_name_position_x
    @map.map_name_position[0]
  end
  
  def map_name_position_y
    @map.map_name_position[1]
  end
  
  def map_name_pos_center_x?
    @map.map_name_position_centered[0]
  end
  
  def map_name_pos_center_y?
    @map.map_name_position_centered[1]
  end
  
  def map_name_LSD
    @map.map_name_letter_show_delay
  end
  
  def map_name_font_color
    c = @map.map_name_font_col_ 
    Color.new(c[0],c[1],c[2],c[3])
  end
  
  def map_name_font_out_color
    c = @map.map_name_font_ocol
    Color.new(c[0],c[1],c[2],c[3])
  end
  
  def map_name_bg
    @map.map_name_bg
  end
  
  def map_name_bg_x
    @map.map_name_bg_pos[0]
  end
  
  def map_name_bg_y
    @map.map_name_bg_pos[1]
  end

  def map_name_bg_showing?
    @map.map_name_bg_show
  end

  def ind_letter_fixx
    @map.map_name_ind_let_fixx
  end
  
end

#==============================================================================
class Game_Interpreter
#==============================================================================

  def reset_map_name
    $game_temp.mapname = nil
  end
  
end

#==============================================================================
class Sprite_MapName < Sprite
#==============================================================================

  include Map_Name_Window

  def initialize(letter, x = 0, y = 0, timer = 0, index = 0)
    super(nil)
    create_variables(timer, index)
    get_letter_effects if @letter_effects[0]
    x = x_needs_fixed?(letter, x) if letter != nil
    y = y_needs_fixed?(letter, y) if letter != nil
    create_map_name(letter, x, y) if letter != nil
  end
  
  def x_needs_fixed?(letter, x)
    $game_map.ind_letter_fixx.each {|let|
    return x += let[1] if let[0] == @letter_index }
    return x
  end
  
  def y_needs_fixed?(letter, y)
    $game_map.ind_letter_fixx.each {|let|
    return y += let[2] if let[0] == @letter_index }
    return y
  end

  def create_variables(t, i)
    @open          = true
    @slide_left    = false
    @slide_right   = false
    @slide_up      = false
    @slide_down    = false
    @timer         = t
    @timer_val     = 0
    @letter_index  = i
    @angle_type    = nil
    @letter_effects = $game_map.map_name_effect
    @slide_distance = $game_map.map_name_slide
  end

  def create_map_name(letter, x, y)
    size = $game_map.map_name_font_size
    self.bitmap = Bitmap.new(size,size)
    self.bitmap.font.name = $game_map.map_name_font_name
    self.bitmap.font.size = size
    self.bitmap.font.bold = $game_map.map_name_font_bold
    self.bitmap.font.italic = $game_map.map_name_font_italic
    self.bitmap.font.color = $game_map.map_name_font_color
    self.bitmap.font.out_color = $game_map.map_name_font_out_color
    self.bitmap.draw_text(0, 0, size, size, letter.to_s)
    self.x = x
    self.y = y + (size / 2).to_i
    self.z = Map_Name_z + 2
    self.opacity = 0
  end

  def get_letter_effects
    case @letter_effects[1]
    when 0 ; basic_left_slide
    when 1 ; basic_right_slide
    when 2 ; basic_left_slide ; get_angle_type(0)
    when 3 ; basic_right_slide ; get_angle_type(1)
    when 4 ; basic_left_slide ; get_angle_type(1)
    when 5 ; basic_right_slide ; get_angle_type(0)
    when 6 ; basic_left_spin ; get_angle_type(2)
    when 7 ; basic_right_spin ; get_angle_type(3) 
    when 8 ; basic_right_slide ; get_angle_type(4)
    when 9 ; basic_left_slide ; get_angle_type(4)
    when 10; basic_right_slide ; get_angle_type(5)
    when 11; basic_left_slide ; get_angle_type(5)
    when 12; basic_up_slide
    when 13; basic_down_slide
    when 14; basic_up_slide ; basic_left_slide
    when 15; basic_up_slide ; basic_right_slide
    when 16; basic_down_slide ; basic_left_slide
    when 17; basic_down_slide ; basic_right_slide
    when 18; basic_up_slide ;basic_left_slide; basic_left_spin ;get_angle_type(2)
    when 19; basic_up_slide ;basic_left_slide; basic_right_spin ;get_angle_type(3)
    when 20; basic_up_slide ;basic_right_slide; basic_left_spin ;get_angle_type(2)
    when 21; basic_up_slide ;basic_right_slide; basic_right_spin ;get_angle_type(3)
    when 22; basic_down_slide ;basic_left_slide ; basic_left_spin ;get_angle_type(2)
    when 23; basic_down_slide ;basic_left_slide ; basic_right_spin ;get_angle_type(3)
    when 24; basic_down_slide ;basic_right_slide ; basic_left_spin ;get_angle_type(2)
    when 25; basic_down_slide ;basic_right_slide ; basic_right_spin ;get_angle_type(3)
    end
  end
  
  def basic_left_slide
     @slide_left = true
    self.ox = -(@slide_distance).to_i 
  end
  
  def basic_right_slide
     @slide_right = true
    self.ox = (@slide_distance).to_i 
  end
  
  def basic_up_slide
    @slide_up = true
    self.oy = -(@slide_distance).to_i
  end
  
  def basic_down_slide
    @slide_down = true
    self.oy = (@slide_distance).to_i
  end

  def basic_left_spin
    @move_for_spin = true
  end
  
  def basic_right_spin
    @move_for_spin = true
  end
  
  def get_angle_type(angle_type)
    @angle_type = angle_type
    case angle_type
    when 0 ; self.angle =  50
    when 1 ; self.angle = -50
    when 2 ; self.angle = -360
    when 3 ; self.angle =  360
    when 4 ; self.angle =  (50 * (@timer / (@letter_index+1)))
    when 5 ; self.angle = -(50 * (@timer / (@letter_index+1)))
    end
  end
  
  def update
    super
    update_timer
    update_show
    update_slide if @open
    update_angle if @angle_type != nil
  end
  
  def update_timer
    return if @timer_val >= @timer
    @timer_val += 1 
    self.opacity = 1
  end
  
  def update_show
    self.opacity += 1 if @open
    self.opacity -= 1 if !@open
    @open = false if self.opacity >= 255
  end
  
  def update_slide
    self.ox += 1 if self.ox < 0 && @slide_left
    self.ox -= 1 if self.ox > 0 && @slide_right
    self.oy += 1 if self.oy < 0 && @slide_up
    self.oy -= 1 if self.oy > 0 && @slide_down
  end
  
  def update_angle
    return if @angle_type == nil
    return if self.angle.between?(-0.49,0.49)
    case @angle_type
    when 0, 1 ; self.angle < 0 ? self.angle += 0.2 : self.angle -= 0.2
    when 2, 3 ; self.angle.between?(-5,5) ?
      self.angle < 0 ? self.angle += 0.5 : self.angle -= 0.5 :
      self.angle < 0 ? self.angle += 1.5 : self.angle -= 1.5 
    when 4, 5 ; self.angle.between?(-10,10) ? self.angle.between?(-4,4) ?
      self.angle < 0 ? self.angle += 0.5 : self.angle -= 0.5 : # 2nd between
      self.angle < 0 ? self.angle += 1.5 : self.angle -= 1.5 : # 1st between
      self.angle < 0 ? self.angle += 2.5 : self.angle -= 2.5 
    end
  end
  
  def dispose
    super
    if self.bitmap != nil
      self.bitmap.dispose
    end    
  end 
    
end

#==============================================================================
class Sprite_MapIcon < Sprite_MapName
#==============================================================================
  
  def initialize(icon, x = 0, y = 0, timer, index)
    super(nil, x, y, timer, index)
    self.bitmap = Cache.system("Iconset")
    rect = Rect.new(icon % 16 * 24, icon / 16 * 24, 24, 24)
    self.bitmap.blt(0, 0, self.bitmap, rect)
    self.src_rect.set(rect.x, rect.y, 24, 24)
    self.x = x
    self.y = y
    self.z = Map_Name_z + 1
  end
  
  def update
    super
  end
  
  def dispose
    super
    if self.bitmap != nil
      self.bitmap.dispose
    end    
  end 
    
end

#==============================================================================
class Sprite_MapName_BG < Sprite
#==============================================================================
  
  include Map_Name_Window
  
  def initialize(x, y, width, height, image = nil)
    super(nil)
    self.z = Map_Name_z
    self.opacity = 0
    @open = true
    if image == nil
      create_standard_bg(x, y, width, height)
    else
      create_background_image(x, y, image)
    end
    @timer = 0
    update
  end
  
  def create_standard_bg(x, y, width, height)
    self.bitmap = Bitmap.new(width,height)
    rect = Rect.new(0, 0,width,height)
    rect.width /= 2
    self.bitmap.gradient_fill_rect(rect, BackGound_Color_2, BackGound_Color_1)
    rect.x = rect.width
    self.bitmap.gradient_fill_rect(rect, BackGound_Color_1, BackGound_Color_2)
    self.x = x
    self.y = y + (height / 2 )
  end
  
  def create_background_image(x, y, image)
    self.bitmap = Cache.mapname_im(image)
    self.x = x
    self.y = y
  end

  def update
    super
    @timer += 1 if !@open
    self.opacity += 1 if @open
    self.opacity -= 1 if !@open
    @open = false if self.opacity >= 250
  end
  
  def dispose
    super
    if self.bitmap != nil
      self.bitmap.dispose
    end    
  end 
    
end

#==============================================================================
module Spriteset_Map_Name
#==============================================================================

  def init_map_name_set
    return if $game_temp.mapname == $game_map.display_name
    $game_temp.mapname = $game_map.display_name
    create_map_name
    create_map_name_icon
    create_map_name_BG
    @delay_timer = 0
    @display_mn_timer = 0
  end
  
  def create_map_name_icon
    return unless $game_map.map_name_icon[0]
    x = $game_map.map_name_icon_pos_x
    y = $game_map.map_name_icon_pos_y
    x = (Graphics.width / 2) - (12) if $game_map.map_name_icon_pos_x_center?
    y = (Graphics.height / 2) - (12) if $game_map.map_name_icon_pos_y_center?
    timer = $game_map.map_name_LSD
    index = 0
    icon = $game_map.map_name_icon[1]
    @map_icon = Sprite_MapIcon.new(icon, x, y, timer, index)
  end
  
  def create_map_name
    x = $game_map.map_name_position_x
    y = $game_map.map_name_position_y
    n = $game_map.display_name.to_s.split(//)
    @map_name = [] 
    timer = $game_map.map_name_LSD
    index = 0
    fbvaal = ($game_map.map_name_font_bold ? 0 : 0) + ($game_map.map_name_font_italic ? 0 : 0)
    if $game_map.map_name_pos_center_x?
      n_size = ($game_map.display_name.size+1) * ($game_map.map_name_font_size + fbvaal )
      x = (Graphics.width / 2) - (n_size / 2)
    end
    if $game_map.map_name_pos_center_y?
      n_size = ($game_map.map_name_font_size + fbvaal )
      y = (Graphics.height / 2) - (n_size / 2)
    end
    for i in n
      @map_name.push( Sprite_MapName.new(i[0], x, y, timer, index))
      x += ($game_map.map_name_font_size / 4 * 3)
      timer += $game_map.map_name_LSD
      index += 1
    end 
  end

  def create_map_name_BG
    return unless $game_map.map_name_bg_showing?
    timer = $game_map.map_name_LSD
    mbgwid = ($game_map.display_name.size) * @map_name[0].width / 4 * 3
    mbghei = @map_name[0].height
    mbgx = $game_map.map_name_bg_x
    mbgy = $game_map.map_name_bg_y
    image = $game_map.map_name_bg
    @map_BG = Sprite_MapName_BG.new(mbgx, mbgy, mbgwid, mbghei, image) if @map_name != nil
  end

  def update_map_name_set
    if $game_temp.mapname != $game_map.display_name
      dispose_map_name_set
      init_map_name_set
    end
    return if @map_name == nil
    update_map_name_DPBz if @map_name != nil
    update_map_name_BG if @map_BG != nil
    update_map_name_icon if @map_icon != nil
    @display_mn_timer += 1
    if @display_mn_timer > 600
      @map_name.each {|i| return if i.opacity > 0 }
      return if @map_icon != nil && @map_icon.opacity > 0
      return if @map_BG != nil && @map_BG.opacity > 0 
      dispose_map_name_set
    end
  end
  
  def update_map_name_DPBz
    return if @delay_timer == nil
    @delay_timer += 1
    return unless @delay_timer >= Map_Name_Window::Delay_Timer
    @map_name.each {|sprite| sprite.update } if @map_name != nil
  end
  
  def update_map_name_BG
    @map_BG.update if @map_BG != nil
  end
  
  def update_map_name_icon
    @map_icon.update if @map_icon != nil
  end

  def dispose_map_name_set
    @map_BG.dispose if @map_BG != nil
    @map_icon.dispose if @map_icon != nil
    @map_name.each {|sprite| sprite.dispose } if @map_name != nil
    @map_BG = nil 
    @map_icon = nil 
    @map_name = nil 
    @delay_timer = nil
  end  
  
end

#==============================================================================
class Spriteset_Map
#==============================================================================

  include Spriteset_Map_Name
  
  alias :initialize_map_name :initialize
  alias :dispose_map_name    :dispose
  alias :update_map_name     :update
  
  def initialize
    initialize_map_name
    init_map_name_set
  end
  
  def dispose
    dispose_map_name
    dispose_map_name_set
  end
  
  def update
    update_map_name
    update_map_name_set
  end

end

#==============================================================================
class Window_MapName < Window_Base
#==============================================================================

  if Map_Name_Window::Remove_Default_Name_Window
    
    def refresh
      contents.clear
    end
    
  end # if Map_Name_Window::Remove_Default_Name_Window

end

#==============================================================================#
#                               - SCRIPT END -                                 #
#==============================================================================#
#                      http://dekitarpg.wordpress.com/                         #
#==============================================================================#

[chapter]Điều khoản sử dụng[/chapter]
Không được phép sử dụng script này trong dự án thương mại.
ONLY FREE

[chapter]Credit[/chapter]
Dekita
«1

Comments

Sign In or Register to comment.