class Window_Quest < Window_Base
#--------------------------------------------------------------------------
def initialize(quest)
super(0, 65, 640, 415)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
@quest = quest
@stepsBegY = 0
refresh
end
#--------------------------------------------------------------------------
def refresh
self.contents.clear
rect = Rect.new(x, y, self.width - 32, self.height - 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
draw_description
draw_delimiter
for i in 0...@quest.steps_size
draw_step(i)
end
end
#--------------------------------------------------------------------------
def draw_delimiter
rect = Rect.new(0, @stepsBegY, self.width, 4)
self.contents.fill_rect(rect, gray_color)
end
#--------------------------------------------------------------------------
def draw_description
self.contents.font.color = green_color
x = 0
dx = x
y = 0
lineheight = 32
text = @quest.get_description.clone
while ((c = text.slice!(/./m)) != nil)
if c == "\n"
dx = 0
y += 32
else
dx = x + self.contents.text_size(c).width
if dx > self.width - 32
dx = 0
y += 32
end
end
self.contents.draw_text(x, y, self.contents.text_size(c).width, lineheight, c)
x = dx
end
@stepsBegY = y + 32
end
#--------------------------------------------------------------------------
def draw_step(index)
step = @quest.get_step(index)
if step != nil
description = step.get_description
self.contents.font.color = normal_color
if step.get_status == 1
self.contents.font.color = gray_color
description = description + ' (выполнено)'
end
x = 4
y = @stepsBegY + 8 + index * 32
rect = Rect.new(x, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(x + 2, y, 480, 32, description, 0)
end
end
end