#==============================================================================
# ** Quest Settings
#------------------------------------------------------------------------------
# This module holds settings that are shared for all quest related items.
#==============================================================================
module Quest_Settings
#--------------------------------------------------------------------------
# * The quest names
#--------------------------------------------------------------------------
QUEST_NAMES = []
QUEST_NAMES[0] = "Help Man"
QUEST_NAMES[1] = "Kill Chicken"
QUEST_NAMES[2] = "Make cow eat"
QUEST_NAMES[3] = "Sniff the Glove"
QUEST_NAMES[4] = "Jump off a bridge after your friends"
QUEST_NAMES[5] = "Daily Chores"
#--------------------------------------------------------------------------
# * The quest descriptions
#--------------------------------------------------------------------------
QUEST_DESCS = []
QUEST_DESCS[0] = "Help out the man."
QUEST_DESCS[1] = "Kill a chicken & return it to Helga."
QUEST_DESCS[2] = "Find an emaciated cow & feed it."
QUEST_DESCS[3] = "Bark like a dog."
QUEST_DESCS[4] = "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!"
QUEST_DESCS[5] = "Father wants Kaze and I to help \n" +
"him in the farm today. No doubt, it will be another " +
"long and tiresome day in the fields again. I wonder " +
"what sort of job he will have us doing this time? " +
"He seems to always make me work the hardest, anyway. " +
"Let`s just get this over with so we can get some food " +
"afterwards, eh?"
#--------------------------------------------------------------------------
# * If the user has no quests this information will be displayed.
#--------------------------------------------------------------------------
QUEST_DEF_NAME = "Quest Log"
QUEST_DEF_DESC = "You have no active or completed quests"
#--------------------------------------------------------------------------
# * The quest pictures
#--------------------------------------------------------------------------
QUEST_PICS = []
# Quest Pictures must be placed inside 'Graphics/Pictures/'
QUEST_PIC_DIR = 'Journal/'
QUEST_PICS[0] = 'quest_default.png'
QUEST_PICS[1] = 'farm.png'
QUEST_PICS[2] = 'farm2.png'
QUEST_PICS[3] = 'farm3.png'
#--------------------------------------------------------------------------
# * Index offset into "$game_variables" for quest info.
#--------------------------------------------------------------------------
VARIABLE_OFFSET = 0
#--------------------------------------------------------------------------
# Just a safety precaution to make sure the user understands the amount
# of quest names must equal the amount of the descriptions and vice versa.
#--------------------------------------------------------------------------
if QUEST_NAMES.size != QUEST_DESCS.size
difference = (QUEST_NAMES.size - QUEST_DESCS.size).abs
if QUEST_NAMES.size > QUEST_DESCS.size
print("There are " + difference.to_s + " more quest names then there " +
"are quest descriptions.")
else
print("There are " + difference.to_s + " more quest descriptions then " +
"there are quest names.")
end
end
end
#==============================================================================
# ** Window_Journal
#------------------------------------------------------------------------------
# This window displays a journal.
#==============================================================================
class Window_Journal < Window_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :index
attr_accessor :quests
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 460, 480)
self.contents = Bitmap.new(width - 32, height - 32)
# This array will contain all the quests that the user knows when this
# window is created.
@quests = []
# Iterate through our quests
for i in 0...Quest_Settings::QUEST_NAMES.size
# If the quest has been turned on draw it.
if $game_variables[i + Quest_Settings::VARIABLE_OFFSET] > 0
# Save the index of a quest that is active complete or otherwise known
@quests << i
end
end
# Intialize the starting index.
@index = 0
# Draw the window
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# Clear the window.
self.contents.clear
# If there are no quests draw the default information.
if @quests.size == 0
# Draw the quest name.
self.contents.draw_text(4, 0, 300, 32,
Quest_Settings::QUEST_DEF_NAME)
# Draw the quest description.
self.contents.font.color = normal_color
self.contents.draw_wrap_text(4, 64, 300, 32,
Quest_Settings::QUEST_DEF_DESC)
else
# Return before we make a mistake.
return if @quests[index].nil?
# Draw the quest name.
self.contents.draw_text(4, 0, 300, 32,
Quest_Settings::QUEST_NAMES[@index])
# Draw whether quest status.
if $game_variables[@index + Quest_Settings::VARIABLE_OFFSET] == 1
self.contents.font.color = Color.new(255,0,0,255)
self.contents.draw_text(150, 0, 120, 32, "Active", 2)
else
self.contents.font.color = Color.new(0,255,0,255)
self.contents.draw_text(150, 0, 120, 32, "Complete", 2)
end
# Draw the quest description.
self.contents.font.color = normal_color
self.contents.draw_wrap_text(4, 64, 300, 32,
Quest_Settings::QUEST_DESCS[@index])
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 /n move to next line
if string == " /n"
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
#==============================================================================
# * Scene_Journal
#------------------------------------------------------------------------------
# This class contains the windows for the quest menu
# To access from the menu, insert $scene = Scene_Journal.new in your menu
#
# Brewmeister - V10MAR08
# Props to Lambchop (original creator) & Trickster (draw_wrap_text method)
#==============================================================================
class Scene_Journal
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Intialize the map in the background.
@spriteset = Spriteset_Map.new
# Initialize our journal window.
@journal_window = Window_Journal.new
@journal_window.back_opacity = 190
# So we get that arrow that points down.
@journal_window.pause = true
# Create a sprite object to display the quest image.
@quest_sprite = Sprite.new
@quest_sprite.bitmap = nil
@quest_sprite.z = 999
Graphics.transition
update_quest_picture(@journal_window.index)
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@journal_window.dispose
# Dispose of the sprite and its bitmap
@quest_sprite.bitmap.dispose unless @quest_sprite.bitmap.nil?
@quest_sprite.dispose unless @quest_sprite.disposed?
# Get rid of the map.
@spriteset.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
update_journal if @journal_window.active
end
#--------------------------------------------------------------------------
# * Update Journal
#--------------------------------------------------------------------------
def update_journal
# Cancel key pressed (go to menu)
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(4)
return
end
# No quests. No need to check for input.
return if @journal_window.quests.size == 0
# The user has pressed the down button.
if Input.trigger?(Input::DOWN)
# Increment the index.
@journal_window.index += 1
# Test to see if we exceed the maximum if so reset the index.
if @journal_window.index > (@journal_window.quests.size - 1)
# Set the position to zero.
@journal_window.index = 0
end
update_quest_picture(@journal_window.index)
# Refresh the window.
@journal_window.refresh
end
# The user has pressed the up button.
if Input.trigger?(Input::UP)
# Decrement the index.
@journal_window.index -= 1
# Test to see if we are less than zero.
if @journal_window.index < 0
# Set the current index to the last position in the quest log.
@journal_window.index = @journal_window.quests.size
end
update_quest_picture(@journal_window.index)
# Refresh the window.
@journal_window.refresh
end
end
#--------------------------------------------------------------------------
# * Update Quest Picture
#--------------------------------------------------------------------------
def update_quest_picture(index)
# The index of the picture.
questpic_index = index
# If the current index exceeds the picture to be used.
if index > (Quest_Settings::QUEST_PICS.size - 1)
questpic_index = 0
end
# Change the sprite's bitmap.
@quest_sprite.bitmap =
RPG::Cache.picture(Quest_Settings::QUEST_PIC_DIR +
Quest_Settings::QUEST_PICS[questpic_index])
@quest_sprite.x = 640 - @quest_sprite.bitmap.width
end
end