#==============================================================================
# ** Journal
#------------------------------------------------------------------------------
# This window displays a journal.
#==============================================================================
class Window_Journal < Window_Base
# ------------------------
attr_accessor :index
attr_accessor :quest_size
def initialize
# Offset - enter the offset to the first variable you are using
# This is one less than the variable number.
@offset = 0
# populate your journal with entries. Each entry must match its variable number!
@quest = []
@description = []
@quest[0] = "Quest Log"
@description[0] = "You have no active or completed quests"
@quest[1] = "Help Man"
@description[1] = "Help out the man."
@quest[2] = "Kill Chicken"
@description[2] = "Kill a chicken & return it to Helga."
@quest[3] = "Make cow eat"
@description[3] = "Find an emaciated cow & feed it."
@quest[4] = "Sniff the Glove"
@description[4] = "Bark like a dog."
@quest[5] = "Jump off a bridge after your friends"
@description[5] = "Just to show long text: Funny story reverting back to \
childhood cliche, and a camping trip with my friends. \
Did they jump off a bridge? Yes, they did. Did I follow \
them? Of course I did!"
super(0, 32, 460, 330)
@index = 0
@quest_size = @quest.size
# draw the bitmap. the text will appear on this bitmap
self.contents = Bitmap.new(width - 32, height - 32)
refresh
### to change the windowskin for the journal
# self.windowskin = RPG::Cache.windowskin("RMXP4life_Wood.png")
###
end
#--------------------------------------------------------------------------
# * Draw the contents of the item window
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in @index..@quest.size - 1
if $game_variables[i + @offset] > 0
self.contents.draw_text(4, 0, 300, 32, @quest[i])
if $game_variables[i + @offset] == 1
self.contents.font.color = Color.new(255,0,0,255)
self.contents.draw_text(304, 0, 120, 32, "Active", 2)
else
self.contents.font.color = Color.new(0,255,0,255)
self.contents.draw_text(304, 0, 120, 32, "Complete", 2)
end
self.contents.font.color = normal_color
# draw paragraph
self.contents.draw_wrap_text(4, 64, 428, 32, @description[i])
@index = i
break
end
end
if @index == 0
self.contents.draw_text(4, 0, 300, 32, @quest[0])
self.contents.draw_wrap_text(4, 64, 428, 32, @description[0])
end
end
end
#==============================================================================
# ** Bitmap Class Add-ons from MACL 2.1
# NOTE: If you have the MACL, don't delete this.
# Make sure this is below the MACL
#------------------------------------------------------------------------------
class Bitmap
#--------------------------------------------------------------------------
# * Dummy Bitmap
#--------------------------------------------------------------------------
@@dummy = Bitmap.new(32, 32)
attr_accessor :dummy
#--------------------------------------------------------------------------
# Name : Text Size
# Info : Gets text size based off dummy bitmap
# Author : SephirothSpawn
# Call Info : One Argument, a String
#--------------------------------------------------------------------------
def Bitmap.text_size(text)
return @@dummy.text_size(text)
end
#-------------------------------------------------------------------------
# Name : Draw Wrapped Text
# Info : Draws Text with Text Wrap
# Author : Trickster
# Call Info : Five Arguments
# Integer X and Y, Define Position
# Integer Width, defines the width of the text rectangle
# Integer Height, defines the height of the text
# String Text, Text to be drawn
# Modified : Brew. Add 'p' for line breaks
#-------------------------------------------------------------------------
def draw_wrap_text(x, y, width, height, text)
# Get Array of Text
strings = text.split
# Run Through Array of Strings
strings.each do |string|
# Get Word
word = string + ' '
# If p, move to next line
if string == "p"
x = 0
y += height
next
end
# Get Word Width
word_width = text_size(word).width
# If Can't Fit on Line move to next one
x, y = 0, y + height if x + word_width > width
# Draw Text Memory
self.draw_text(x, y, word_width, height, word)
# Add To X
x += word_width
end
end
end