例如 :(拉丁语??)
---------------------
[Title] Lipsum
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean in ultrices
nulla, vel pharetra diam. Nunc faucibus pretium leo, a lacinia erat posuere
ut. Etiam porttitor enim et bibendum facilisis. Praesent eu elit ut metus
tempus aliquet. Cras tempor mauris sapien, ut laoreet quam condimentum ut.
<P>Aliquam aliquet ut quam vel sollicitudin. Fusce vestibulum semper sapien
nec luctus. Sed rhoncus, neque vitae
end
end
# =============================================================================
# 设定结束 ~ !
# =============================================================================
class Game_Interpreter
def add_journal(title)
return if $game_system.journal_keys.include?(title)
$game_system.journal_keys.push(title)
end
def clear_journal
$game_system.journal_keys.clear
end
def remove_journal(title)
$game_system.journal_keys.delete(title)
end
def journal_number(number)
$game_system.journal_number = number
end
end
# -----------------------------------------------------------------------------
# Updates version 1.1
# Window content caches
# -----------------------------------------------------------------------------
class << Cache
def journal_bmp(key)
@journal ||= {}
@journal[key]
end
def journal_clear
@journal ||= {}
end
end
class << Marshal
alias theo_storyjournal_load load
def load(port, proc = nil)
theo_storyjournal_load(port, proc)
rescue TypeError
if port.kind_of?(File)
port.rewind
port.read
else
port
end
end
end
class << DataManager
def open_journal_text
$journal = {}
key = ""
load_data("Data/Journal.txt").split(/[\r\n]+/).each do |txt|
next if txt =~ /(^\s*(#|\/\/).*|^\s*$)/
if txt =~ /^\[Title\]\s*(.+)/i
key = $1.to_s
$journal[key] = ""
else
txt.gsub!(/\[line\]/i) {"\n"}
txt.gsub!(/\[page\]/i) {"<P>"}
$journal[key] += txt
end
end
end
alias theo_storyjournal_load_db load_database
def load_database
open_journal_text
theo_storyjournal_load_db
end
end
class Game_System
attr_accessor :journal_number
alias theo_storyjournal_init initialize
def initialize
theo_storyjournal_init
@journal_number = 1
@journals = {}
end
def journal_keys
@journals[@journal_number] ||= []
end
end
class Window_JournalList < Window_Selectable
def initialize
super(0,0,window_width,window_height)
refresh
activate
select(0)
end
def title_window=(window)
@title_window = window
update_help
end
def window_width
return Theo::Journal::ListWidth
end
def window_height
return Graphics.height
end
def item_max
return [$game_system.journal_keys.size,1].max
end
def draw_item(index)
rect = item_rect(index)
rect.x += 4
draw_text(rect, $game_system.journal_keys[index])
end
def journal_contents
$journal[journal_title] || ""
end
def journal_title
$game_system.journal_keys[index] || ""
end
def update_help
return unless Theo::Journal::InstantRefresh
if @help_window
@help_window.set_title(journal_title)
end
@title_window.set_title(journal_title) if @title_window
end
end
class Window_JournalTitle < Window_Base
def initialize(x)
super(x,0,Graphics.width - x,fitting_height(1))
set_title("")
end
def set_title(str)
@title = str
refresh
end
def refresh
contents.clear
draw_text(contents.rect,@title,1)
end
def set_title(title)
@title = title
load_journal_data(journal_contents)
end
def journal_contents
$journal[@title] || ""
end
def load_journal_data(str)
@page = 0
@texts = str.split(/<P>/i)
refresh
end
def get_cache
Cache.journal_bmp([@title, @page])
end
def set_cache
Cache.journal_cache([@title, @page], contents)
end
def refresh
contents.clear
if get_cache
draw_cached_bitmap
else
draw_contents
draw_current_page if Theo::Journal::DisplayPage
set_cache
end
end
def draw_cached_bitmap
begin
contents.blt(0,0,get_cache, get_cache.rect)
rescue
Cache.journal_clear
draw_contents
draw_current_page if Theo::Journal::DisplayPage
set_cache
end
end
def draw_contents
draw_text_ex(4,0,@texts[@page])
end
def draw_current_page
reset_font_settings
ypos = contents.height - line_height
contents.fill_rect(0,ypos-2,contents.width,2,Color.new(255,255,255,128))
rect = Rect.new(4,ypos,contents.width-4,line_height)
pg = sprintf("%d / %d",@page+1,@texts.size)
draw_text(rect,Theo::Journal::VocabPage)
draw_text(rect,pg,2)
end
def update
super
next_page if Input.trigger?(:RIGHT)
prev_page if Input.trigger?(:LEFT)
end
def next_page
return if @page + 1 >= @texts.size
@page += 1
refresh
end
def prev_page
return if @page + 1 <= 1
@page -= 1
refresh
end
def process_character(c, text, pos)
@text = text
if Theo::Journal::WordWrap && text[0] != ' '
w = text_size(get_word(text)).width + 6
if (pos[:x] + w) >= contents.width
process_new_line(text, pos)
return
end
end
super
end
def get_word(text)
result = ''
text.each_char do |c|
break if c =~ /\s/
result += c
end
result
end
end
class Window_MenuCommand < Window_Command
alias theo_storyjournal_add_ori_cmd add_original_commands
def add_original_commands
theo_storyjournal_add_ori_cmd
return unless Theo::Journal::MainMenu
add_command(Theo::Journal::VocabCommand, :storyjournal)
end
end
class Scene_Menu < Scene_MenuBase
alias theo_storyjournal_cmnd_window create_command_window
def create_command_window
theo_storyjournal_cmnd_window
@command_window.set_handler(:storyjournal, method(:enter_journal))
end
def enter_journal
SceneManager.call(Story_Journal)
end
end
class Story_Journal < Scene_MenuBase
def start
super
create_journal_list
create_journal_title
create_journal_contents
end
def create_journal_list
@list = Window_JournalList.new
@list.set_handler(:ok, method(:on_journal_ok))
@list.set_handler(:cancel, method(:return_scene))
end
def create_journal_title
@title = Window_JournalTitle.new(@list.width)
@title.set_title(@list.journal_title)
end
def on_journal_ok
@list.activate
return if Theo::Journal::InstantRefresh
@title.set_title(@list.journal_title)
@contents.load_journal_data(@list.journal_contents)
end