I'm using a book script by ForeverZer0, and I don't remember how but I remember I did something to get a 'books' label to show up on the menu, and it works, I can access the various books I activate during the game, which is what I want it to do. But there's a problem with the menu where it will show the book on the sidebar, and then when I select the book, it will switch to displaying the book's text, in a mode where it then shows the title on top... but still keeps the sidebar active. So, the two titles are redundant, and I want the sidebar to go away once I select the book.
[spoiler](https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww.theneonheart.com%2Fimages%2FPoe2.png&hash=456fbcce2459b795da6301dfbcabf038e4d8e794)[/spoiler]
[spoiler](https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww.theneonheart.com%2Fimages%2FPoe3.png&hash=1ef1f950f8622cd3f541b3dd09f4cb2bd206dd71)[/spoiler]
It doesn't do this when I call the book scene directly from the game. Then it looks like this which is what I want it to look like when you choose a book from the menu.
[spoiler](https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww.theneonheart.com%2Fimages%2FPoe4.png&hash=91a0830285729e63a265c3973e8312709c388bb6)[/spoiler]
Also, I guess I'm going to have a problem with changing the windowskin from when you access the menu to when you choose a book. I want it to be two different windowskins, and right now it is only the one, the whole menu the same as the book. So, I'm also wondering if there is a way to change the windowskin once you select a book and it opens.
[spoiler](https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww.theneonheart.com%2Fimages%2FPoe1.png&hash=c44c326046b8d3bd0dc3a4ad1c85bcc1a2a0cb00)[/spoiler]
If you can help me with this I'll appreciate it. Thanks for reading.
This the code you used?
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
# Journal
# Author: ForeverZer0
# Version: 2.4
# Data: 12.30.2010
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#
# Introduction:
# I wrote this script after seeing a request here on CP for something similar.
# It basically just allows the player to view a Journal that show the player
# information about people they have encountered and places they have visited.
# Can also log weapons, armors, and items.
#
# Features:
# - Easy to use/configure
# - Nice simple interface
# - Will log people, places, weapons, armors, and items seperately
# - Configurable what type of entries you would like to log.
# - Configurable layout
# - Option to use pictures
# - Fully compatible "stats" you want the system to display.
#
# Instructions:
# - Place script in the usual place.
# - All configuration is below, and explained in each section.
# - All pictures must be in folder labeled "Journal" within your game's
# Picture folder.
# - All you have to do is assign arbitrary "ids" to each person and location
# respectively. After you have completed configuration, when you want the
# person/place to be added to the Journal, use these script calls:
#
# Journal.add_character(ID)
# Journal.add_location(ID)
# Journal.add_weapon(ID)
# Journal.add_armor(ID)
# Journal.add_item(ID)
#
# You can also delete entries in the same way:
#
# Journal.delete_character(id)
# Journal.delete_location(id)
# Journal.delete_weapon(id)
# Journal.delete_armor(id)
# Journal.delete_item(id)
#
# Where the "ID" is the number you assigned to each.
# - To call the scene, use this script call:
#
# $scene = Scene_Journal.new
#
# - The script comes with a fix for those who like to use smaller text sizes
# (like myself), which will allow for more information to be displayed on
# the screen at once.
# - If you would like to change the look up a little bit, just change around
# the X and Y values in Window_Journal.
#
# Credits/Thanks:
# - ForeverZer0, for the script.
#
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# BEGIN CONFIGURATION
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
module Journal
# If true, a line height of 20 pixels will be used, which looks better with
# smaller font sizes.
SMALL_TEXT = true
# The width of the entry list used for Scene_Journal. The other windows will
# automatically adjust to this width.
LIST_WIDTH = 192
# Define what aspects of the journal you would like to use. Choose from the
# values listed below and add them to the array. DO NOT change the values.
# Omit values for types you do not want to use.
# 'People' - 'Places' - 'Weapons' - 'Armors' - 'Items'
LIST_ORDER = ['People', 'Places', 'Weapons', 'Armors', 'Items']
# Configure if you would like for items, weapons, and armors to be unlocked
# automatically when they are first aquired by the player. If using this
# options, IDs MUST match the IDs used in the Database. You will also need to
# manually add anything the player begins with at game start.
AUTO_WEAPONS = true
AUTO_ARMORS = true
AUTO_ITEMS = true
#-------------------------------------------------------------------------------
CHARACTER_STATS = ['Name:', 'Race:', 'Age:', 'Height:', 'Weight:']
# Configure the values used for the above array for each character. Just make
# sure the value that corresponds to each stat is at the same index in the [].
# Just make sure that the first stat is the name, it will be used on the menu
# to select which character/location will be viewed.
def self.character_info(id)
info = case id
when 1 then ['Aluxes', 'Human', '19', '5\'10"', '165 lbs.']
when 2 then ['Hilda', 'Human', '20', '5\'5"', '113']
when 3 then ['Basil', 'Human', '24', '6\'0"', '187 lbs.']
end
return info != nil ? info : []
end
# Short paragraph/description of character. Uses Blizzard's slice_text method
# to automatically break to next line when needed, so do not concern yourself
# with that.
def self.character_bio(id)
text = case id
when 1
'Our everyday hero, that seems to make an appearance in every demo.'
when 2
'Random witch girl.'
when 3
'Another RPGXP character.'
end
return text != nil ? text : ''
end
#-------------------------------------------------------------------------------
LOCATION_STATS = ['Name:', 'Country:']
# Configure the values used for the above array for each location. Just make
# sure the value that corresponds to each stat is at the same index in the [].
# Just make sure that the first stat is the name, it will be used on the menu
# to select which character/location will be viewed.
def self.location_info(id)
info = case id
when 1 then ['New York', 'USA']
when 2 then ['Ohio', 'USA']
when 3 then ['Iowa', 'Who cares...']
end
return info != nil ? info : []
end
# Short paragraph/description of location. Uses Blizzard's slice_text method
# to automatically break to next line when needed, so do not concern yourself
# with that.
def self.location_bio(id)
return case id
when 1
'The state north of Pennsylvania.'
when 2
'The state west of Pennsylvania.'
when 3
'A boring state.'
else
''
end
end
#-------------------------------------------------------------------------------
WEAPON_STATS = ['Name:', 'Origin:']
def self.weapon_info(id)
text = case id
when 1 then ['Bronze Sword', 'Everywhere.']
when 2 then ['Iron Sword', 'Right here.']
when 3 then ['Mythril Sword', 'Blah blah.']
end
end
def self.weapon_bio(id)
return case id
when 1
'Simple sword. Seems to be the standard that all RPG games have the hero start with.'
when 2
'Slighly better than the Bronze sword.'
when 3
'Yet another sword that is in almost every RPG.'
else
''
end
end
#-------------------------------------------------------------------------------
ARMOR_STATS = ['Name:', 'Origin:']
def self.armor_info(id)
text = case id
when 1 then ['', '']
when 2 then ['', '']
when 3 then ['', '']
end
end
def self.armor_bio(id)
return case id
when 1
''
when 2
''
when 3
''
else
''
end
end
#-------------------------------------------------------------------------------
ITEM_STATS = ['Name:', 'Origin:']
def self.item_info(id)
text = case id
when 1 then ['', '']
when 2 then ['', '']
when 3 then ['', '']
end
end
def self.item_bio(id)
return case id
when 1
''
when 2
''
when 3
''
else
''
end
end
#-------------------------------------------------------------------------------
# Set the following to true if you would loke pictures to be displayed for
# the respective type of Journal entries. They will be defined below.
CHARACTER_PIC = true
LOCATION_PIC = true
WEAPON_PIC = true
ARMOR_PIC = true
ITEM_PIC = true
# Filenames of character pictures.
def self.character_pic(id)
file = case id
when 1 then 'Aluxes'
when 2 then 'Hilda'
when 3 then 'Basil'
end
return file != nil ? RPG::Cache.picture("Journal/#{file}") : Bitmap.new(1,1)
end
# Filenames of location pictures.
def self.location_pic(id)
file = case id
when 1 then ''
when 2 then ''
when 3 then ''
end
return file != nil ? RPG::Cache.picture("Journal/#{file}") : Bitmap.new(1,1)
end
# Filename of weapon pictures.
def self.weapon_pic(id)
file = case id
when 1 then ''
when 2 then ''
when 3 then ''
end
return file != nil ? RPG::Cache.picture("Journal/#{file}") : Bitmap.new(1,1)
end
# Filename of weapon pictures.
def self.armor_pic(id)
file = case id
when 1 then ''
when 2 then ''
when 3 then ''
end
return file != nil ? RPG::Cache.picture("Journal/#{file}") : Bitmap.new(1,1)
end
# Filenames of item pictures.
def self.item_pic(id)
file = case id
when 1 then ''
when 2 then ''
when 3 then ''
end
return file != nil ? RPG::Cache.picture("Journal/#{file}") : Bitmap.new(1,1)
end
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# END CONFIGURATION
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
def self.add_character(id)
unless $game_system.journal['People'].include?(id)
$game_system.journal['People'].push(id)
$game_system.journal['People'].sort!
end
end
def self.add_location(id)
unless $game_system.journal['Places'].include?(id)
$game_system.journal['Places'].push(id)
$game_system.journal['Places'].sort!
end
end
def self.add_weapon(id)
unless $game_system.journal['Weapons'].include?(id)
$game_system.journal['Weapons'].push(id)
$game_system.journal['Weapons'].sort!
end
end
def self.add_armor(id)
unless $game_system.journal['Armors'].include?(id)
$game_system.journal['Armors'].push(id)
$game_system.journal['Armors'].sort!
end
end
def self.add_item(id)
unless $game_system.journal['Items'].include?(id)
$game_system.journal['Items'].push(id)
$game_system.journal['Items'].sort!
end
end
def self.delete_character(id)
$game_system.journal['People'].delete(id)
$game_system.journal['People'].sort!
end
def self.delete_location(id)
$game_system.journal['Places'].delete(id)
$game_system.journal['Places'].sort!
end
def self.delete_weapon(id)
$game_system.journal['Weapons'].delete(id)
$game_system.journal['Weapons'].sort!
end
def self.delete_armor(id)
$game_system.journal['Armors'].delete(id)
$game_system.journal['Armors'].sort!
end
def self.delete_item(id)
$game_system.journal['Items'].delete(id)
$game_system.journal['Items'].sort!
end
end
#===============================================================================
# ** Game_System
#===============================================================================
class Game_System
attr_accessor :journal
alias zer0_journal_init initialize
def initialize
zer0_journal_init
@journal = {}
Journal::LIST_ORDER.each {|key| @journal[key] = [] }
end
def journal_entries(type)
entries = []
case type
when 'People'
@journal[type].each {|id| entries.push(Journal.character_info(id)[0]) }
when 'Places'
@journal[type].each {|id| entries.push(Journal.location_info(id)[0]) }
when 'Weapons'
@journal[type].each {|id| entries.push(Journal.weapon_info(id)[0]) }
when 'Armors'
@journal[type].each {|id| entries.push(Journal.armor_info(id)[0]) }
when 'Items'
@journal[type].each {|id| entries.push(Journal.item_info(id)[0]) }
end
return entries.empty? ? ['None'] : entries
end
end
#===============================================================================
# ** Game_Party
#===============================================================================
class Game_Party
alias zer0_auto_add_weapon gain_weapon
def gain_weapon(weapon_id, n)
# Unlock weapon ID if recieved.
if Journal::AUTO_WEAPONS& ![nil, 0].include?(weapon_id)
Journal.add_weapon(weapon_id)
end
zer0_auto_add_weapon(weapon_id, n)
end
alias zer0_auto_add_armor gain_armor
def gain_armor(armor_id, n)
# Unlock armor ID if recieved.
if Journal::AUTO_ARMORS && ![nil, 0].include?(armor_id)
Journal.add_armor(armor_id)
end
zer0_auto_add_armor(armor_id, n)
end
alias zer0_auto_add_item gain_item
def gain_item(item_id, n)
# Unlock item ID if recieved.
if Journal::AUTO_ITEMS && ![nil, 0].include?(item_id)
Journal.add_item(item_id)
end
zer0_auto_add_item(item_id, n)
end
end
#===============================================================================
# ** Bitmap (slice_text method by Blizzard)
#===============================================================================
class Bitmap
def slice_text(text, width)
words = text.split(' ')
return words if words.size == 1
result, current_text = [], words.shift
words.each_index {|i|
if self.text_size("#{current_text} #{words[i]}").width > width
result.push(current_text)
current_text = words[i]
else
current_text = "#{current_text} #{words[i]}"
end
result.push(current_text) if i >= words.size - 1}
return result
end
end
#===============================================================================
# ** Window_Journal
#===============================================================================
class Window_Journal < Window_Base
attr_accessor :type
def initialize
super(Journal::LIST_WIDTH, 0, 640 - Journal::LIST_WIDTH, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.visible = false
@type = ''
end
def id=(id)
@id = id
refresh
end
def refresh
self.contents.clear
return if @id == nil
# Set local variables, branching by what type is being viewed.
case @type
when 'People'
stats = Journal::CHARACTER_STATS
info = Journal.character_info(@id)
bio = Journal.character_bio(@id)
pic = Journal::CHARACTER_PIC ? Journal.character_pic(@id) : nil
when 'Places'
stats = Journal::LOCATION_STATS
info = Journal.location_info(@id)
bio = Journal.location_bio(@id)
pic = Journal::LOCATION_PIC ? Journal.location_pic(@id) : nil
when 'Weapons'
stats = Journal::WEAPON_STATS
info = Journal.weapon_info(@id)
bio = Journal.weapon_bio(@id)
pic = Journal::WEAPON_PIC ? Journal.weapon_pic(@id) : nil
when 'Armors'
stats = Journal::ARMOR_STATS
info = Journal.armor_info(@id)
bio = Journal.armor_bio(@id)
pic = Journal::ARMOR_PIC ? Journal.armor_pic(@id) : nil
when 'Items'
stats = Journal::ITEM_STATS
info = Journal.item_info(@id)
bio = Journal.item_bio(@id)
pic = Journal::ITEM_PIC ? Journal.item_pic(@id) : nil
end
width = 640 - Journal::LIST_WIDTH - 40
bio = self.contents.slice_text(bio, width)
if pic != nil
rect = Rect.new(0, 0, pic.width, pic.height)
self.contents.blt(self.width-pic.width-64, 32, pic, rect)
end
# Draw the values on the window's bitmap.
self.contents.font.color = system_color
y = Journal::SMALL_TEXT ? 20 : 32
stats.each_index {|i| self.contents.draw_text(0, i*(y*2), 128, y, stats[i])}
self.contents.draw_text(0, 320, 128, y, 'Description:')
self.contents.font.color = normal_color
info.each_index {|i| self.contents.draw_text(8, y+i*(y*2), 128, y, info[i])}
bio.each_index {|i| self.contents.draw_text(8, (320+y)+i*y, width, y, bio[i])}
end
end
#===============================================================================
# ** Scene_Journal
#===============================================================================
class Scene_Journal
#-------------------------------------------------------------------------------
def main
# Create lists of the entries for each Journal content type.
@entry_lists, @index = [], 0
# Create list of entry titles.
Journal::LIST_ORDER.each {|key|
next unless $game_system.journal.has_key?(key)
window = Window_Command.new(Journal::LIST_WIDTH, $game_system.journal_entries(key))
window.visible = window.active = false
window.height = 480
@entry_lists.push(window)
}
# Create main command window.
@command_window = Window_Command.new(Journal::LIST_WIDTH, Journal::LIST_ORDER)
@command_window.height = 480
# Create main window for viewing information and dummy window.
@dummy_window = Window_Base.new(Journal::LIST_WIDTH, 0, 640 - Journal::LIST_WIDTH, 480)
@journal_window = Window_Journal.new
@windows = @entry_lists + [@journal_window, @command_window, @dummy_window]
# Transition and start main loop for the scene.
Graphics.transition
loop {Graphics.update; Input.update; update; break if $scene != self}
# Dispose all windows and prepare for transition.
Graphics.freeze
@windows.each {|window| window.dispose}
end
#-------------------------------------------------------------------------------
def update
# Update all the windows.
@windows.each {|window| window.update }
# Branch update method depending on what window is active.
@command_window.active ? update_command : update_entry_selection
end
#-------------------------------------------------------------------------------
def update_command
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
# Deactivate command window and make selected entry list active.
@index = @command_window.index
@command_window.active = @command_window.visible = false
@entry_lists[@index].active = @entry_lists[@index].visible = true
end
end
#-------------------------------------------------------------------------------
def update_entry_selection
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
# Deactivate entry list and make command window active.
@command_window.active = @command_window.visible = true
@entry_lists[@index].active = @entry_lists[@index].visible = false
@journal_window.visible = false
elsif Input.trigger?(Input::C)
@journal_window.visible = true
$game_system.se_play($data_system.decision_se)
type = Journal::LIST_ORDER[@index]
# Set the type and id variables for the journal window and refresh.
@journal_window.type = type
@journal_window.id = $game_system.journal[type][@entry_lists[@index].index]
end
end
end
Can you upload your "Window_MenuCommand"?
I would also like to see what you use to call up books from the world map.
Sorry I'm just getting back to you... someone had hijacked my email account, so I didn't know anyone had responded.
The script is called 'Book/Library Scene', it looks like this:
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# Book/Library Scene
# Author: ForeverZer0
# Version: 1.2
# Date: 9.1.2010
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
#
# Version History:
# v. 1.0 9.1.2010
# - Original version
# v. 1.1 9.3.2010
# - Added option for full-screen text
# - Made the page number window slightly wider
# v. 1.2 9.25.2010
# - Added option to simply call scene with the book ID argument and have
# that book already displayed.
#
# Introduction:
# Calls a scene that will allow player to read through books that they have
# collected.
#
# Features:
# - Easy to configure, text is read from an external text document
# - Text will automatically fit itself into the proper size for the window
# width and pages, regardless of font or font size.
#
# Instructions:
# 1. Fill in the configuration below.
# 2. Create a new folder within the "Data" folder, and name it "Books".
# 3. Within this folder, create simple text documents (.txt).
# 4. Name them EXACTLY as you did for its respective title (below).
# 5. Turn word-wrap OFF.
# 6. Create as large as document as you would like, but only break to a new
# line in between paragraphs, not when the text reaches the edge of the
# window. Every time a new line is started, it guarantees that the current
# line will start on a new line in the scene, regardless of the font size.
#
# Use the following Script Calls:
# Books.unlock(BOOK_ID)
# - Unlocks the book with BOOK_ID
# $scene = Scene_Book.new
# - Calls the Book scene.
# $scene = Scene_Book.new(BOOK_ID)
# - Calls the book scene. The book with BOOK_ID will already be displayed.
# This will also disable the book list feature. The book does not have
# to be unlocked to call this way.
#
# Credits/Thanks:
# ForeverZer0, for the script
# Blizzard, for the "slice_text" method
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
module Books
#===============================================================================
# BEGIN CONFIGURATION
#===============================================================================
RETURN_SCENE = Scene_Map
# Class of the scene that the game return to after you exit the book scene.
SORT_BY_ID = true
# If true, the books will be listed in order of their Book ID, else they will
# be listed in the order they were aquired.
PAGE_TURN_SE = ['046-Book01', 80, 100]
# Set to the name of the SE that will be played when a player turns a page.
# Set to nil to disable this feature. [FILENAME, VOLUME, PITCH]
FULLSCREEN_TEXT = false
# If true, the text window will extend over the book list and take up the
# entire screen (minus the header).
def self.title(book_id)
# Here is where you define the labels used for the books. The titles will
# be used as the filename to be loaded as well.
# when BOOK_ID then 'TITLE'
return case book_id
when 0 then 'journal0'
when 1 then 'journal1'
end
end
#===============================================================================
# END CONFIGURATION
#===============================================================================
def self.unlock(book_id)
# Adds the Book ID to the array.
unless $game_system.books.include?(book_id)
$game_system.books.push(book_id)
# Sorts the array by the Book IDs if so configured.
if SORT_BY_ID
$game_system.books.sort!
end
end
end
def self.get_text(book_id)
# Opens a text document, makes an array whose elements consist of the lines
# of the document, and returns it.
filename = 'Data/Books/' + title(book_id) + '.txt'
begin
file = File.open(filename, 'r')
rescue
raise("Error occured while attempting to open the following file:\n\n" +
"\t#{filename}\n\n" +
"Please make sure that the file exist before you continue.")
end
book = []
file.each_line {|line| book.push(line)}
file.close
return book
end
end
#===============================================================================
# ** Game_System
#===============================================================================
class Game_System
attr_accessor :books # Array: Stores the IDs of all unlocked books.
alias zer0_book_init initialize
def initialize
zer0_book_init
@books = []
end
end
#===============================================================================
# ** Scene_Book
#===============================================================================
class Scene_Book
def initialize(book_id = nil)
@book_id = book_id
@no_list = @book_id != nil
end
def main
# Create a variable that is set to the window width (depending on config)
@window_width = Books::FULLSCREEN_TEXT ? 640 : 512
@window_width = 640 if @no_list
# Create a blank dummy window.
@dummy_window = Window_Base.new(128, 64, 512, 416)
# Create Help_Window to display the book titles.
@help_window = Window_Base.new(0, 0, 448, 64)
@help_window.contents = Bitmap.new(416, 32)
# Create the page number window
@page_window = Window_Base.new(448, 0, 192, 64)
@page_window.contents = Bitmap.new(160, 32)
# Create the window that text will be displayed on.
x = @window_width == 640 ? 0 : 128
@text_window = Window_Base.new(x, 64, @window_width, 416)
@text_window.contents = Bitmap.new(@window_width - 32, 384)
@text_window.z = @help_window.z + 20
@text_window.visible = false
# Make a copy of the Books array.
@books = $game_system.books.clone
# Create instance variable for updating the text window.
@update_text = false
# Make list of all books, if possible, else make list empty.
if @books.empty?
help_string = 'No books are currently available.'
@command_window = Window_Base.new(0, 64, 128, 416)
else
help_string = 'Whick book would you like to read?'
@titles = []
@books.each {|book_id| @titles.push(Books.title(book_id))}
@command_window = Window_Command.new(128, @titles)
@command_window.height, @command_window.y = 416, 64
end
# Display text on the help screen
@help_window.contents.draw_text(0, 0, 416, 32, help_string, 1)
# Create array that holds all the windows
@windows = [@dummy_window, @help_window, @text_window,
@command_window, @page_window]
if @no_list
@page_number = 1
$game_system.se_play($data_system.decision_se)
@help_window.contents.clear
@help_window.contents.draw_text(0, 0, 416, 32, Books.title(@book_id), 1)
@command_window.active, @update_text = false, true
compile_text
@text_window.visible = true
end
Graphics.transition
# Main loop
loop {Graphics.update; Input.update; update; break if $scene != self}
Graphics.freeze
@windows.each {|window| window.dispose}
end
def update
# Update windows.
@windows.each {|window| window.update}
if @command_window.is_a?(Window_Command) && @command_window.active
update_command_window
return
elsif @update_text
update_text_window
return
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Books::RETURN_SCENE.new
end
end
def update_command_window
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Books::RETURN_SCENE.new
elsif Input.trigger?(Input::C)
@page_number = 1
$game_system.se_play($data_system.decision_se)
@book_id = @books[@command_window.index]
@help_window.contents.clear
@help_window.contents.draw_text(0, 0, 416, 32, Books.title(@book_id), 1)
@command_window.active, @update_text = false, true
compile_text
@text_window.visible = true
end
end
def update_text_window
if Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT)
old_page = @page_number
@page_number += Input.trigger?(Input::LEFT) ? -1 : 1
@page_number = [[@page_number, @pages.size].min, 1].max
# Play SE if configured as such.
if old_page != @page_number && Books::PAGE_TURN_SE != nil
se = Books::PAGE_TURN_SE
audio = RPG::AudioFile.new(se[0], se[1], se[2])
$game_system.se_play(audio)
end
# Refresh the window
refresh_text
elsif Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
if @no_list
$scene = Books::RETURN_SCENE.new
else
@update_text, @command_window.active = false, true
@text_window.visible = false
end
end
end
def compile_text
# Gets an array whose elements are the lines of the text document.
text = Books.get_text(@book_id)
# Iterate over each line of the text. Break each line up into segments that
# will fit into the window, then add them all together.
@pages, lines = [], []
text.each {|paragraph|
segment = @text_window.contents.slice_text(paragraph, @window_width - 32)
segment.each {|line| lines.push(line)}
}
# Organizes the lines (12 per page) into pages.
page_numbers = (lines.size / 12) + 1
(0...page_numbers).each {|i| @pages[i] = lines[i*12, 12]}
refresh_text
end
def refresh_text
[@text_window.contents, @page_window.contents].each {|bitmap| bitmap.clear}
# Displays the lines of the current page onto the window.
page = @pages[@page_number - 1]
page.each_index {|i|
@text_window.contents.draw_text(0, i*32, @window_width - 32, 32, page[i])}
# Set the proper text to the page screen.
string = "Page #{@page_number}/#{@pages.size}"
@page_window.contents.draw_text(0, 0, 160, 32, string, 1)
end
end
class Bitmap
# The slice_text method was created by Blizzard. I take no credit for it.
def slice_text(text, width)
words = text.split(' ')
return words if words.size == 1
result, current_text = [], words.shift
words.each_index {|i|
if self.text_size("#{current_text} #{words[i]}").width > width
result.push(current_text)
current_text = words[i]
else
current_text = "#{current_text} #{words[i]}"
end
result.push(current_text) if i >= words.size - 1}
return result
end
end
Here is my Window_Command
#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
# This window deals with general command choices.
#==============================================================================
class Window_Command < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command text string array
#--------------------------------------------------------------------------
def initialize(width, commands)
# Compute window height from command quantity
super(0, 0, width, commands.size * 32 + 32)
@item_max = commands.size
@commands = commands
self.contents = Bitmap.new(width - 32, @item_max * 32)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# color : text color
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index])
end
#--------------------------------------------------------------------------
# * Disable Item
# index : item number
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end
I don't see a specific Window_MenuCommand
Sorry, I don't know how to do that.
Now that you have the scripts here for others to look at, maybe somebody else can help you.