| 
 
| 赞 | 10 |  
| VIP | 15 |  
| 好人卡 | 6 |  
| 积分 | 16 |  
| 经验 | 229303 |  
| 最后登录 | 2025-8-8 |  
| 在线时间 | 1612 小时 |  
 Lv3.寻梦者 
	梦石0 星屑1638 在线时间1612 小时注册时间2007-8-28帖子3252  
 | 
| #================================================================= # MTV 脚本,by 66RPG_柳柳
 #=================================================================
 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]
 break
 end
 end
 else
 $lrc_text = ""
 end
 end
 end
 #==============================================================================
 # 本脚本来自www.66RPG.com,使用和转载请保留此信息
 #==============================================================================
 # ------------------------------------------------------------------------
 # 高精度计时器 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()
 #-------------------------------------#
 
 
 
 
 #==============================================================================
 # 本脚本来自www.66RPG.com,使用和转载请保留此信息
 #==============================================================================
 
 
 #==============================================================================
 # 仭 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_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
 refresh
 end
 #--------------------------------------------------------------------------
 # ● 刷新
 #--------------------------------------------------------------------------
 def refresh(text = "")
 MTV.new_text
 self.contents.clear
 if $game_temp.in_battle
 self.opacity = 120
 else
 self.opacity = 0
 end
 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)
 end
 end
 
 | 
 |