=begin
#==============================================================================#
# AMN Glossary
# Version 1.01
# Author: AMoonlessNight
# Date: 07 Nov 2019
# Latest: 07 Nov 2019
#==============================================================================#
# UPDATE LOG
#------------------------------------------------------------------------------#
# 07 Nov 2019 - created the script
#==============================================================================#
# TERMS OF USE
#------------------------------------------------------------------------------#
# - Please credit AMoonlessNight or A-Moonless-Night
# - Free for non-commercial use
# - Contact for commercial use
# - I'd love to see your game if you end up using one of my scripts
#==============================================================================#
This script makes a basic glossary scene, where you can select different terms
and see what they mean. It's pretty basic, but could also be used as a simple
journal or a help screen.
Set up the glossary in the editable region below.
You can access the glossary scene by using the following:
SceneManager.call(Scene_Glossary)
There is also an option to have it in the main menu.
#------------------------------------------------------------------------------#
NOTE: It is recommended that you used Killozappit's Word Wrapping Message Boxes
with this script to make the text automatically wrap.
You can find it here:
https://www.rpgmakercentral.com/topic/6964-word-wrapping-message-boxes/
#------------------------------------------------------------------------------#
=end
module AMN_Glossary
#==============================================================================
# ** EDITABLE REGION BELOW
#------------------------------------------------------------------------------
# Change the values in the area below to suit your needs.
#==============================================================================
Menu_Option = true # whether to have the Glossary show as an option
# in the menu
Glossary_Name = "Glossary" # what to call the option in the menu
Draw_Page_Numbers = true # whether to draw page numbers at the bottom
Glossary = {
# Each entry should have a unique title, e.g. "Battles", "Items", "Dashing".
# Each entry should have an array [] of strings, e.g. ["text"].
# You can make multiple pages for one entry by closing off the string
# with " followed by a comma.
# E.g. ["this is page one.", "this is page two.", "page three.",]
# You can use escape codes in the text to change the colour, etc. Just make
# sure you use double slashes, e.g. \\c[3]
# Don't use escape codes in the titles.
# You will need to input the line breaks manually, unless you use a word
# wrapping script (like Killozappit's).
#"Title" => ["text", "can be", "split into", "multiple pages"],
"Dashing" => ["Holding down the \\C[3]Shift\\C[0] key while moving will
make you dash, spending \\C[4]Stamina Points\\C[0]. When your \\C[4]Stamina
Points\\C[0] are out (as displayed in the bottom-left corner of the screen),
your dash will automatically stop, and you will switch back to walking.
Your \\C[4]Stamina Points\\C[0] will automatically start refilling when
you stop moving.
You can increase your maximum \\C[4]Stamina Points \\C[0] by the use of
perks, or certain \\C[4]Elite Items\\C[0] found rarely in the game."],
#---------------------
"Entry 2" => ["You can use escape codes, such as \\c[1]coloured text\\c[0].
Just remember to put two dashes."],
#---------------------
"Entry 3" => ["You can have \\{multiple\\} pages,", "like so."],
#---------------------
"Entry 4" => ["You can use variables in the text as well. Variable 4 is
set to \\v[4]."],
#---------------------
"Entry 5" => ["Include as many entries as you'd like."],
#---------------------
# Copy and paste as needed; just make sure there's a comma after each: ],
#==============================================================================
# ** END OF EDITABLE REGION
#------------------------------------------------------------------------------
# Please do not edit below this point unless you know what you are doing.
#==============================================================================
}
end
class Window_AMNGlossary < Window_Selectable
attr_reader :info_window
def initialize(x, y)
make_item_list
super(x, y, window_width, window_height)
refresh
activate
end
def window_width
160
end
def window_height
Graphics.height
end
def make_item_list
@data = AMN_Glossary::Glossary.keys
end
def item_max
@data ? @data.size : 1
end
def draw_item(index)
item = @data[index]
if item
rect = item_rect_for_text(index)
rect.width -= 4
draw_text(rect, item)
end
end
def info_window=(info_window)
@info_window = info_window
update
end
def update
super
@info_window.category = @data[index] if @info_window
end
end
class Window_AMNInfo < Window_Base
def initialize(x, y, width, height)
super(x, y, width, height)
@category = nil
setup_data
end
def setup_data
@data = AMN_Glossary::Glossary.clone
refresh
end
def index_max
return 0 unless @category && @data.key?(@category)
@data[@category].size - 1
end
def increase_index
prev = @index
@index = [@index + 1, index_max].min
@index = 0 if prev == index_max
refresh
end
def decrease_index
prev = @index
@index = [@index - 1, 0].max
@index = index_max if prev == 0
refresh
end
def category=(category)
return if @category == category
@category = category
@index = 0
refresh
end
def refresh
contents.clear
draw_info
end
def draw_info
return unless @category
item = @data[@category][@index]
return unless item
draw_text_ex(0, 0, item)
reset_font_settings
if AMN_Glossary::Draw_Page_Numbers
page = "Page #{@index+1}/#{index_max+1}"
c = text_size(page).width
page.insert(0, "\\c[16]"); page.insert(11, "\\c[0]")
draw_text_ex(contents_width - c, contents.height - line_height, page)
end
end
end
class Scene_Glossary < Scene_MenuBase
def start
super
create_glossary_window
create_info_window
end
def create_glossary_window
@glossary_window = Window_AMNGlossary.new(0,0)
@glossary_window.set_handler(:ok, method(:on_glossary_ok))
@glossary_window.set_handler(:cancel, method(:return_scene))
@glossary_window.select(0)
end
def create_info_window
x = @glossary_window.x + @glossary_window.width
width = Graphics.width - @glossary_window.width
height = @glossary_window.height
@info_window = Window_AMNInfo.new(x, 0, width, height)
@glossary_window.info_window = @info_window
end
def on_glossary_ok
@info_window.increase_index
@glossary_window.activate
end
end
class Window_MenuCommand < Window_Command
alias amn_glossary_windmenucmd_addogcommands add_original_commands
def add_original_commands
amn_glossary_windmenucmd_addogcommands
if AMN_Glossary::Menu_Option
add_command(AMN_Glossary::Glossary_Name, :amn_glossary, main_commands_enabled)
end
end
end
class Scene_Menu < Scene_MenuBase
def command_amn_glossary
SceneManager.call(Scene_Glossary)
end
alias amn_glossary_scenemenu_createcomwind create_command_window
def create_command_window
amn_glossary_scenemenu_createcomwind
if AMN_Glossary::Menu_Option
@command_window.set_handler(:amn_glossary, method(:command_amn_glossary))
end
end
end