def calc_c_width(c, text,lines)
case c
when "\r"
when "\n"
calc_new_line(lines)
when "\f"
when "\e"
obtain_escape_code(text)
obtain_escape_param(text)
else
calc_normal_c(c,lines)
end
end
def calc_normal_c(c,lines)
text_width = text_size(c).width
if lines[@line_num] + text_width > window_width - standard_padding*2
@max_width = lines[@line_num]
@line_num += 1
end
lines[@line_num] += text_size(c).width
end
# 处理普通文本
def process_normal_character(c, pos, text)
text_width = text_size(c).width
if pos[:x] + text_width > contents_width
process_new_line(text,pos)
end
draw_text(pos[:x], pos[:y], text_width * 2, pos[:height], c)
pos[:x] += text_width
wait_for_one_character
end
#--------------------------------------------------------------------------
# ● 普通文字的处理
#--------------------------------------------------------------------------
#def process_normal_character(c, pos)
# super
# wait_for_one_character
#end
#--------------------------------------------------------------------------
# ● 换行文字的处理
#--------------------------------------------------------------------------
def process_new_line(text, pos)
@line_show_fast = false
super
if need_new_page?(text, pos)
input_pause
new_page(text, pos)
end
end
#--------------------------------------------------------------------------
# ● 判定是否需要翻页
#--------------------------------------------------------------------------
def need_new_page?(text, pos)
pos[:y] + pos[:height] > contents.height && !text.empty?
end
#--------------------------------------------------------------------------
# ● 翻页文字的处理
#--------------------------------------------------------------------------
def process_new_page(text, pos)
text.slice!(/^\n/)
input_pause
new_page(text, pos)
end
#--------------------------------------------------------------------------
# ● 处理控制符指定的图标绘制
#--------------------------------------------------------------------------
def process_draw_icon(icon_index, pos)
super
wait_for_one_character
end
#--------------------------------------------------------------------------
# ● 控制符的处理
# code : 控制符的实际形式(比如“\C[1]”是“C”)
# text : 绘制处理中的字符串缓存(字符串可能会被修改)
# pos : 绘制位置 {:x, :y, :new_x, :height}
#--------------------------------------------------------------------------
def process_escape_character(code, text, pos)
case code.upcase
when '$'
@gold_window.open
when '.'
wait(15)
when '|'
wait(60)
when '!'
input_pause
when '>'
@line_show_fast = true
when '<'
@line_show_fast = false
when '^'
@pause_skip = true
else
super
end
end
#--------------------------------------------------------------------------
# ● 处理输入等待
#--------------------------------------------------------------------------
def input_pause
self.pause = true
wait(10)
Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C)
Input.update
self.pause = false
end
#--------------------------------------------------------------------------
# ● 处理选项的输入
#--------------------------------------------------------------------------
def input_choice
@choice_window.start
Fiber.yield while @choice_window.active
end
#--------------------------------------------------------------------------
# ● 处理数值的输入
#--------------------------------------------------------------------------
def input_number
@number_window.start
Fiber.yield while @number_window.active
end
#--------------------------------------------------------------------------
# ● 处理物品的选择
#--------------------------------------------------------------------------
def input_item
@item_window.start
Fiber.yield while @item_window.active
end
end