module Sword
#=======================================
#★ 魔劍工舖 - 地圖上顯示地圖名 1.01
# [url]http://blog.yam.com/a870053jjkj/[/url]
#=======================================
ON, OFF = true, false
#=======================================
#● 使用者自定設置
Sword67_XorY = [-10, 0] # 顯示地圖名稱的窗口位置,分別為 [X座標, Y座標] # 640, 416
Sword67_Align = 0 # 文字的靠邊位置,0為左、1為中、2為右
Sword67_Opacity = 255 # 設定窗口背景的不透明度和淡出上限
Sword67_Adjunct = 120 # 地圖名稱顯示的時間,0為永久顯示(每40約1秒)
Sword67_Switche = 12 # 指定1個開關編號,該開關為ON表示關閉此腳本功能
Sword67_Show = ON # 是否在起始地圖顯示地圖名
Sword67_Fade = [5, 5] # 設定每幀 [加, 減] 不透明度的淡出淡入效果,0為不使用
#=======================================
$Sword ? $Sword[67] = true : $Sword = {67=>true} # 腳本使用標誌
($Sword_VX = false ; RPG::Weather rescue $Sword_VX = true) if $Sword_VX == nil
Sword67s1_Fade = [Sword67_Fade[0] > 0 ? Sword67_Opacity / Sword67_Fade[0] : 0,
Sword67_Fade[1] > 0 ? Sword67_Opacity / Sword67_Fade[1] : 0]
#-------------------------------------------------------------
#● 紀錄是否在起始地圖顯示地圖名的標誌
def self.sword67=(s) ; @sword67 = s ; end
def self.sword67 ; @sword67 ; end
self.sword67 = Sword67_Show
end
#=======================================
#■ 處理主角的類
if $Sword_VX
class Game_Player < Game_Character
attr_reader :new_map_id # 新地圖的地圖編號
end
end
#=======================================
#■ 地圖名稱的窗口
class WSword_MapName < Window_Base
include Sword # 連接自定設置
#-------------------------------------------------------------
#● 初始化物件
def initialize(a = 0)
b = $Sword_VX ? 'v' : 'x'
@map_name = a == 0 ? load_data("Data/MapInfos.r#{b}data")[$game_map.map_id].name :
load_data("Data/MapInfos.r#{b}data")[a].name # 獲取地圖名稱
super(Sword67_XorY[0], Sword67_XorY[1], 33, 33)
self.contents = Bitmap.new(width - 32, height - 32)
self.windowskin = RPG::Cache.windowskin("mapname")
# self.width = contents.text_size(@map_name).width + 40
# self.height = contents.text_size(@map_name).height + 43
self.width = 870
self.height = contents.text_size(@map_name).height + 60
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#-------------------------------------------------------------
#● 描繪內容
def refresh
self.contents.clear ; self.contents.font.color = normal_color ; self.contents.font.size = 24
case Sword67_Align # 窗口靠邊設定
when 1 ; self.x -= self.width / 2
when 2 ; self.x -= self.width
end
self.contents.draw_text(4, 0, self.width, 48, @map_name) # 窗口內容
end
end
#=======================================
#■ 處理地圖畫面的類
class Scene_Map
include Sword # 連接自定設置
#-------------------------------------------------------------
#● 主處理
alias sword67_main main unless $Sword_VX
def main
sword67_map_name ; $Sword_VX ? super : sword67_main
unless @sword_map_name == nil
@sword_map_name.dispose
@sword_map_name = nil
end
end
#-------------------------------------------------------------
#● 更新
alias sword67_update update
def update
if Sword67_Fade[0] > 0 and @sword_map_name and (not @sword_map_wait == true)
@sword_map_name.opacity = [@sword_map_name.opacity +
Sword67_Fade[0], Sword67_Opacity].min
@sword_map_name.contents_opacity = [@sword_map_name.opacity +
Sword67_Fade[0], Sword67_Opacity].min
end
# 窗口顯示時間計算
@sword_map_wait = [Graphics.frame_count, Graphics.frame_count +
Sword67_Adjunct + Sword67s1_Fade[0]] unless @sword_map_wait
if @sword_map_wait.is_a?(Array) and Sword67_Adjunct != 0
@sword_map_wait[0] <= @sword_map_wait[1] ? @sword_map_wait[0] += 1 :
@sword_map_wait = true
end
if @sword_map_wait == true ; if @sword_map_name
if @sword_map_name.opacity == 0 or Sword67_Fade[1] == 0
@sword_map_name.dispose ; @sword_map_name = nil
@sword_map_wait = nil
else
@sword_map_name.opacity = [@sword_map_name.opacity -
Sword67_Fade[1], 0].max
@sword_map_name.contents_opacity = [@sword_map_name.opacity -
Sword67_Fade[1], 0].max
end ; end ; end
sword67_update
end
#-------------------------------------------------------------
#● 主角的場所移動
if $Sword_VX ; alias sword67_transfer_player update_transfer_player
else ; alias sword67_transfer_player transfer_player ; end
def transfer_player
return unless $game_player.transfer? if $Sword_VX
$game_switches[Sword67_Switche] ? 0 : @sword_map_wait = false
# 重新顯示窗口
unless @sword_map_name == nil
@sword_map_name.dispose
@sword_map_name = nil
end
Sword.sword67 = true
sword67_transfer_player
sword67_map_name
end
def update_transfer_player ; transfer_player ; end
#-------------------------------------------------------------
#● 顯示地圖名稱窗口的處理
def sword67_map_name
if $game_switches[Sword67_Switche] == false and Sword.sword67
@sword_map_name = WSword_MapName.new($Sword_VX ?
$game_player.new_map_id : $game_temp.player_new_map_id)
# @sword_map_name.opacity = Sword67_Fade[0] > 0 ? 0 : Sword67_Opacity
@sword_map_name.opacity = 0
#@sword_map_name.contents_opacity = 0 if Sword67_Fade[0] > 0
@sword_map_name.contents_opacity = 0
Sword.sword67 = false
end
end
end