Project1
标题:
求MTV歌词显示脚本如何关闭??
[打印本页]
作者:
化螺耕
时间:
2013-7-14 15:01
标题:
求MTV歌词显示脚本如何关闭??
如题,纯正的脚本盲一个,不知道怎么关闭,特来请教各位大神~~脚本如下:
#==============================================
# 增加两个用来进行条件判断的临时变量
#==============================================
class Game_Temp
attr_accessor :old_text
attr_accessor :refresh_times
alias meanfree_initialize initialize
def initialize
meanfree_initialize
@old_text = ""
@refresh_times = 0
end
end
module MTV
#===============================================================
# 读取文件。文件相对地址:Audio/BGM
# file_name:文件名;length:MTV长度,按照.1秒为单位记数
#===============================================================
def self.load(file_name,length = 0)
$mtv_time = []
$mtv_text = []
$game_system.mtv_length = length
#=============================================================
# 打开文件并且读取之
#=============================================================
file = File.open("Audio/BGM/"+file_name)
#=============================================================
# 读取歌词
#=============================================================
for line in file.readlines
#===========================================================
# 转为UTF-8编码
#===========================================================
line = EasyConv.s2u(line)
#===========================================================
# 寻找本行歌词
#===========================================================
this_line_text = line[line.scan(/\]/).size*10,line.size]
#===========================================================
# 把读取的行分存成时间与文字
#===========================================================
for i in 0...line.scan(/\]/).size
temp_b = line[i*10+1,8]
temp_c = temp_b.split(/:/)[0]
mmsecond = 600 * temp_c.to_i
temp_c = temp_b.split(/:/)[1]
mmsecond += 10 * temp_c.to_f
$mtv_time.push(mmsecond.to_i)
$mtv_text.push(this_line_text)
end
end
file.close
end
#===============================================================
# 开始MTV字幕
#===============================================================
def self.mtv_begin
$game_system.mtv_now = true
$game_system.mtv_begin_time = $sys_timer.now()
$lrc_text = ""
return
end
#===============================================================
# 结束MTV字幕
#===============================================================
def self.stop
$game_system.mtv_now = false
return
end
#===============================================================
# 测试MTV是否播放
#===============================================================
def self.mtv?
return $game_system.mtv_now
end
#===============================================================
# 获取MTV字幕
#===============================================================
def self.new_text
if $game_system.mtv_now
#===========================================================
# 求出已经经过的时间
#===========================================================
nt = $sys_timer.now()
nt -= $game_system.mtv_begin_time
nt = nt.to_i
nt /= 100
#===========================================================
# 制作循环
#===========================================================
if $game_system.mtv_length>0 and nt > $game_system.mtv_length
nt -= $game_system.mtv_length
end
#===========================================================
# 放出字幕
#===========================================================
for tm in 0...$mtv_time.size
if $mtv_time[tm] == nt
$lrc_text = $mtv_text[tm]
#=======================================
# 时间有限
$game_temp.old_text = $lrc_text
$game_temp.refresh_times += 1
# 面粉无敌
#=======================================
break
end
end
else
$lrc_text = ""
end
end
end
# ------------------------------------------------------------------------
# 高精度计时器 by FantasyDR
# ------------------------------------------------------------------------
# E-mail:
[email protected]
# ------------------------------------------------------------------------
# 2005.10.18
# ------------------------------------------------------------------------
# 该类已经被定义为全局变量 $sys_timer
# 如果只需要精确到毫秒,请设置初始化参数为true
# decimal属性设置返回时间值的小数位数。
# ------------------------------------------------------------------------
# 下面是一些有用的方法列表,调用时写:$sys_timer.方法名
# 例如 $sys_timer.clear()
# ------------------------------------------------------------------------
# clear() :计时器清零
# now() :获取当前经过的时间,单位毫秒
# now_s() :获取当前经过的时间,单位秒
# ------------------------------------------------------------------------
class SystemTimer
attr_accessor:decimal #小数位数设定,默认为3
def initialize(use_GetTime=false)
# 初始化,根据系统选择不同精度计时器
@qpFrequency = Win32API.new("kernel32","QueryPerformanceFrequency",'p','L')
@qpCounter = Win32API.new("kernel32","QueryPerformanceCounter",'p','L')
@tGetTime = Win32API.new("winmm","timeGetTime",'','L')
@decimal=3
@perf_cnt=" " * 8
@time_start=" " * 8
@time_now=" " * 8
result = @qpFrequency.call(@perf_cnt)
if use_GetTime
result = 0
end
if result!=0
@perf_flag=true
else
@perf_flag=false
@perf_cnt=[1000,0].pack('LL')
end
#设置时间比例因数
@time_scale=@perf_cnt.unpack('LL')
@time_scale[0] /= 1000.0
@time_scale[1] /= 1000.0
#起始时间清零
self.clear()
end
#-=====================-#
# 计时器清零
#-=====================-#
def clear()
if @perf_flag
@qpCounter.call(@time_start)
else
@time_start=[@tGetTime.call(),0].pack('LL')
end
end
#-==============================-#
# 获取当前经过的时间,单位毫秒
#-==============================-#
def now()
now_time = 0.0e1
now_time += self.timer() - self.start()
now_time /= self.scale()
return self.debug(now_time)
end
#-==============================-#
# 获取当前经过的时间,单位秒
#-==============================-#
def now_s()
now_time = 0.0e1
now_time += self.timer() - self.start()
now_time /= (self.scale()*1000)
return self.debug(now_time)
end
#-==============================-#
# 帧错...
#-==============================-#
def debug(now_time)
if @decimal>0
now_time = (now_time * (10**@decimal)).floor/(10.0**@decimal)
else
now_time = now_time.floor
end
return now_time
#以下用于debug模式
if now_time < 0
p "Timer Wrong!! Clear...",now_time,\
@perf_flag,@qpCounter,@tGetTime,
@time_now.unpack('LL')[0],@time_now.unpack('LL')[1],
@time_start.unpack('LL')[0],@time_start.unpack('LL')[1]
self.clear()
return 0.0
else
return now_time
end
end
#-=====================-#
# 获取时间比例因数
#-=====================-#
def scale()
return @time_scale[0]+\
@time_scale[1]*0xffffffff
end
#-=====================-#
# 获取起始滴答数
#-=====================-#
def start()
return @time_start.unpack('LL')[0]+\
@time_start.unpack('LL')[1]*0xffffffff
end
#-=====================-#
# 获取当前的嘀哒数
#-=====================-#
def timer()
if @perf_flag
@qpCounter.call(@time_now)
else
@time_now=[@tGetTime.call(),0].pack('LL')
end
return @time_now.unpack('LL')[0]+\
@time_now.unpack('LL')[1]*0xffffffff
end
end
#-------------------------------------#
# 初始化自身成一个全局变量
#-------------------------------------#
$sys_timer=SystemTimer.new()
#-------------------------------------#
#==============================================================================
# 仭 EasyConv module - Ver 0.90
#------------------------------------------------------------------------------
# Moonlight INN
# http://cgi.members.interq.or.jp/aquarius/rasetsu/
# RaTTiE
#
[email protected]
#------------------------------------------------------------
# EasyConv::s2u(text) : S-JIS -> UTF-8
# EasyConv::u2s(text) : UTF-8 -> S-JIS
#==============================================================================
module EasyConv
# API梡掕悢掕媊
CP_ACP = 0
CP_UTF8 = 65001
#--------------------------------------------------------------------------
# 仠 S-JIS -> UTF-8
#--------------------------------------------------------------------------
def s2u(text)
# API掕媊
m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
# S-JIS -> Unicode
len = m2w.call(CP_ACP, 0, text, -1, nil, 0);
buf = "\0" * (len*2)
m2w.call(CP_ACP, 0, text, -1, buf, buf.size/2);
# Unicode -> UTF-8
len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil);
ret = "\0" * len
w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil);
return ret
end
# module_function偲偟偰岞奐
module_function :s2u
#--------------------------------------------------------------------------
# 仠 UTF-8 -> S-JIS
#--------------------------------------------------------------------------
def u2s(text)
# API掕媊
m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
# UTF-8 -> Unicode
len = m2w.call(CP_UTF8, 0, text, -1, nil, 0);
buf = "\0" * (len*2)
m2w.call(CP_UTF8, 0, text, -1, buf, buf.size/2);
# Unicode -> S-JIS
len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil);
ret = "\0" * len
w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil);
return ret
end
# module_function偲偟偰岞奐
module_function :u2s
end
#==============================================================================
# ■ Game_System
#------------------------------------------------------------------------------
# 处理系统附属数据的类。也可执行诸如 BGM 管理之类的功能。本类的实例请参考
# $game_system 。
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :mtv_begin_time
attr_accessor :mtv_now
attr_accessor :mtv_length
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
alias mtv_gamesystem_initialize initialize
def initialize
mtv_gamesystem_initialize
@mtv_begin_time = $sys_timer.now()
@mtv_now = false
@mtv_length = 0
end
end
#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
# 处理地图画面的类。
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
alias mtv_scenemap_update update
def update
MTV.new_text
@mtv_window.refresh
mtv_scenemap_update
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
alias mtv_scenemap_main main
def main
@mtv_window = Window_MTV.new
mtv_scenemap_main
@mtv_window.dispose
end
#--------------------------------------------------------------------------
# ● 调用战斗 (调整自动切换BGM)
#--------------------------------------------------------------------------
def call_battle
# 清除战斗调用标志
$game_temp.battle_calling = false
# 清除菜单调用标志
$game_temp.menu_calling = false
$game_temp.menu_beep = false
# 生成遇敌计数
$game_player.make_encounter_count
# 记忆地图 BGM 、停止 BGM
$game_temp.map_bgm = $game_system.playing_bgm
unless MTV.mtv?
$game_system.bgm_play($game_system.battle_bgm)
# 演奏战斗开始 SE
$game_system.se_play($data_system.battle_start_se)
end
# 矫正主角姿势
$game_player.straighten
# 切换到战斗画面
$scene = Scene_Battle.new
end
end
#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
# 处理战斗的类。
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
alias mtv_scenebattle_update update
def update
@mtv_window.refresh
mtv_scenebattle_update
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
alias mtv_scenebattle_main main
def main
@mtv_window = Window_MTV.new
mtv_scenebattle_main
@mtv_window.dispose
end
end
#==============================================================================
# ■ Window_MTV
#------------------------------------------------------------------------------
# 显示MTV字幕的窗口。
#==============================================================================
class Window_MTV < Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(0, 416, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
$lrc_text = ""
self.z = 9999
#===========================
# 时间有限
@temp_text = ""
$game_temp.old_text = ""
# 面粉无敌
#===========================
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh(text = "")
#=================================================
# 时间有限
if $game_temp.in_battle
self.opacity = 0
else
self.opacity = 0
end
if $game_system.mtv_now == false or $lrc_text == ""
self.contents.clear
else
if $game_temp.refresh_times != 1
if $game_temp.old_text != @temp_text
self.contents.clear
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(0, 0, 608, 32, $lrc_text, 1)
self.contents.font.color = Color.new(255,255,255,255)
self.contents.draw_text(1, 1, 608, 32, $lrc_text, 1)
@temp_text = $lrc_text
end
else
self.contents.clear
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(0, 0, 608, 32, $lrc_text, 1)
self.contents.font.color = Color.new(255,255,255,255)
self.contents.draw_text(1, 1, 608, 32, $lrc_text, 1)
@temp_text = $lrc_text
end
end
# 面粉无敌
#==================================================
end
end
复制代码
作者:
化螺耕
时间:
2013-7-15 14:27
5555555555555555……………………自己顶一下
作者:
爱夏的鱼
时间:
2013-7-15 17:09
应该有某号开关设置的吧
作者:
化螺耕
时间:
2013-7-15 17:56
我自己会了,Yeah~~~~~~~~原来是脚本直接写一个MTV.stop就搞定了……
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1