#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Journal Display by Blizzard
# Version: 2.0
# Type: Journal Viewer
# Date: 22.1.2008
# Date v2.0: 24.1.2008
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Compatibility:
#
# 99% compatible with SDK v1.x. 90% compatible with SDK v2.x. Should be
# compatible with everything else. WILL corrupt old savegames.
#
#
# Features:
#
# - define texts that should be displayed
# - easy change of the text that is being displayed
# - returns to the scene that called it
#
# new in 2.0:
#
# - now able to unlock pages during game play
# - display pages in unlocking order or a fixed order
# - add now page title and text instead of text only
#
#
# Explanation:
#
# This script will allow you to use a journal scene that shows some text that
# you define in advance. You can change the text displayed to any other of
# the predefined texts with one command.
#
#
# Configuration:
#
# Set up the configuration below and add your pictures to the folder you
# specified. Call the scene with following syntax:
#
# $scene = Scene_Journal.new
#
# If you want to unlock another page, simply use a "Call Script" event
# command with following syntax:
#
# $game_system.unlock_journal(PAGE_NUMBER)
#
# PAGE_NUMBER - page number to unlock
#
#
# IMPORTANT NOTE:
#
# If one of your texts is too long to fit in one page, simply split it into
# two pages into two titles and unlock all the pages that you need. You can
# also use something like
#
#
#
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#==============================================================================
# module BlizzCFG
#==============================================================================
module BlizzCFG
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# font name in which the journal should be displayed
JOURNAL_FONTNAME = 'Arial'
# font size in which the journal should be displayed
JOURNAL_FONTSIZE = 22
# 0 = left, 1 = center, 2 = right
JOURNAL_FONTALIGN = 0
# if you set this to true, pages will be displayed in the order you unlock them
IN_ORDER = false
# entries, the template is ["Title", "Text"]
JOURNAL_ENTRIES = [
["Getting started", "This is the first entry."],
["Second entry", "Don't forget that the last entry does NOT have a comma after the string."],
["Testing text slicer", "This text repeats itself. This text repeats itself. This text repeats itself. This text repeats itself. This text repeats itself. This text repeats itself. Oh yeah, this is entry 2."],
["This text is too long", "I have copy-pasted a text here that doesn't fit into one page to demonstrate how to split a text that is simply too long to fit in one page. L3X has his own will. He destroyed his own extern controller module due to the fact that his Tech4X AI was developed enough so he could do it. He would have never done it if it wasn't for the Scord virus attack. There is no known way to manipulate this cyborg from within anymore. As a model of the limited L3X1-MU5 series he has close combat abilities beyond those of a mere" +
"human. L3X himself was not originally implement with the Tech4X AI, he was fighting during Scord War 1 with the Tech3 AI. As a reward he was upgraded with the Tech4X AI due to his excellent performance in Scord War 1. Well, since this text"],
["This text is too long (continued)", "actually exactly fits into one page, I have added those last words to simply prolong it."]
]
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
end
#==============================================================================
# Game_System
#==============================================================================
class Game_System
attr_reader :journal
alias init_journal_later initialize
def initialize
init_journal_later
@journal = []
end
def unlock_journal(id)
@journal.push(id-1) unless @journal.include?(id-1)
end
end
#==============================================================================
# Window_Base
#==============================================================================
class Window_Base
def slice_text(text, width)
result, last_word, current_text = [], 0, ''
(0..text.size).each {|i|
if text[i, 1] == ' ' || i == text.size
word = text[last_word, i-last_word]
if self.contents.text_size("#{current_text} #{word}").width > width
result.push(current_text)
current_text = word
else
current_text += (current_text == '' ? word : " #{word}")
end
last_word = i+1
end}
result.push("#{current_text} #{text[last_word, text.size-last_word]}")
return result
end
end
#==============================================================================
# Window_JournalDisplay
#==============================================================================
class Window_JournalDisplay < Window_Base
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = BlizzCFG::JOURNAL_FONTNAME
self.contents.font.size = BlizzCFG::JOURNAL_FONTSIZE
@index, @journal = 0, $game_system.journal.clone
@journal.sort! unless BlizzCFG::IN_ORDER
refresh
end
def refresh
self.contents.clear
self.contents.draw_text(4, 416, 252, 32, 'Page', 2)
self.contents.draw_text(4, 416, 292, 32, (@index+1).to_s, 2)
self.contents.draw_text(4, 416, 600, 32, '/', 1)
self.contents.draw_text(312, 416, 292, 32, @journal.size.to_s)
return if @journal.size == 0
self.contents.draw_text(4, 0, 600, 32, BlizzCFG::JOURNAL_ENTRIES[@journal[@index]][0], 1)
text = slice_text(BlizzCFG::JOURNAL_ENTRIES[@journal[@index]][1], 592)
text.each_index {|i| self.contents.draw_text(4, (i+1)*32+16, 600, 32, text[i], BlizzCFG::JOURNAL_FONTALIGN)}
end
def update
super
if Input.repeat?(Input::RIGHT)
if @journal.size == 0
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.cursor_se)
@index = (@index+1) % @journal.size
refresh
end
elsif Input.repeat?(Input::LEFT)
if @journal.size == 0
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.cursor_se)
@index = (@index+@journal.size-1) % @journal.size
refresh
end
end
end
end
#==============================================================================
# Scene_Journal
#==============================================================================
class Scene_Journal
def initialize
@scene = $scene.class
end
def main
@window = Window_JournalDisplay.new
Graphics.transition
loop do
Graphics.update
Input.update
@window.update
break if Input.trigger?(Input::C) || Input.trigger?(Input::B)
end
$game_system.se_play($data_system.cancel_se)
Graphics.freeze
@window.dispose
$scene = @scene.new
end
end