#==============================================================================
# [PS0]读书读报系统
# Reading_System
#==============================================================================
# [更新记录]
# - 2011.12.27 By 仲秋启明
# * 编写开始,遵循PS0协议;
# * 设定开关以控制
# - 2012.02.24 By feizhaodan
# * 修正没法翻页和显示问题
#------------------------------------------------------------------------------
# [使用方法]
# - 替换原Window_ScrollText或复制到Main之前
# - 打开Reading_System_Switch定义的开关
#==============================================================================
$_PS0 = {} if $_PS0 == nil
$_PS0["Reading_System"] = 20120205
#==============================================================================
# [PS0] 通用配置模块
#==============================================================================
module PS0
module Reading_System
Reading_System_Switch = 50
end
end
#==============================================================================
# ■ Window_ScrollText
#------------------------------------------------------------------------------
# 显示滚动文字的窗口。
# 这类窗口没有边框,归类为窗口只是为了方便。
# 窗口打开时角色不能移动。
#==============================================================================
class Window_ScrollText < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize
super(0, 0, Graphics.width, Graphics.height)
self.opacity = 0
self.arrows_visible = false
hide
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
if $game_switches[PS0::Reading_System::Reading_System_Switch] != true
if $game_message.scroll_mode
self.opacity = 0
update_message if @text
start_message if !@text && $game_message.has_text?
end
else
self.opacity = 200
if Input.trigger?(:B) or Input.trigger?(:C)
terminate_message
elsif Input.trigger?(:DOWN) or Input.trigger?(:RIGHT)
self.oy += 512 if self.oy + 512 < contents.height
self.oy = [self.oy,contents.height].min
elsif Input.trigger?(:UP) or Input.trigger?(:LEFT)
self.oy -= 512
self.oy = [self.oy,0].max
end
if $game_message.scroll_mode
start_message if !@text && $game_message.has_text?
end
end
end
#--------------------------------------------------------------------------
# ● 开始信息的显示
#--------------------------------------------------------------------------
def start_message
@text = $game_message.all_text
refresh
show
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
reset_font_settings
update_all_text_height
create_contents
draw_text_ex(4, 0, @text)
if $game_switches[PS0::Reading_System::Reading_System_Switch] != true
self.oy = @scroll_pos = -height
end
end
#--------------------------------------------------------------------------
# ● 更新绘制所有内容所需的高度
#--------------------------------------------------------------------------
def update_all_text_height
@all_text_height = 1
convert_escape_characters(@text).each_line do |line|
@all_text_height += calc_line_height(line, false)
end
reset_font_settings
end
#--------------------------------------------------------------------------
# ● 计算窗口内容的高度
#--------------------------------------------------------------------------
def contents_height
@all_text_height ? @all_text_height : super
end
#--------------------------------------------------------------------------
# ● 更新信息
#--------------------------------------------------------------------------
def update_message
if $game_switches[PS0::Reading_System::Reading_System_Switch] != true
@scroll_pos += scroll_speed
self.oy = @scroll_pos
terminate_message if @scroll_pos >= contents.height
end
end
#--------------------------------------------------------------------------
# ● 获取滚动速度
#--------------------------------------------------------------------------
def scroll_speed
$game_message.scroll_speed * (show_fast? ? 1.0 : 0.5)
end
#--------------------------------------------------------------------------
# ● 快进判定
#--------------------------------------------------------------------------
def show_fast?
!$game_message.scroll_no_fast && (Input.press?(:A) || Input.press?(:C))
end
#--------------------------------------------------------------------------
# ● 结束信息的显示
#--------------------------------------------------------------------------
def terminate_message
@text = nil
$game_message.clear
hide
end
end