#===============================================================================
# Expanded Details
# by: Xuroth
# v0.9
#-------------------------------------------------------------------------------
# Intro: This script allows you to display details for any selected item.
# You can use this for adding a bit more depth to your game. To view
# details, just go to your Item Menu and press the Shift key!
#
#
# Features:
# - Display 10 lines of text for more info than other similar scripts
# - Reads data from text files
# - Skill Details
# - Character Biography
# - Shows custom pictures (Requested by LiTTleDRAgo)
#
# Planned Future Features:
# - Unlimited lines
# - Optional Detailed Stats
# - and more!
#
#-------------------------------------------------------------------------------
# How to set up:
# You will need 5 text files named 'Item_Detail.rxdata',
# 'Weapon_Detail.rxdata', 'Armor_Detail.rxdata', 'Skill_Detail.rxdata',
# and 'Actor_Detail.rxdata. These are simple .txt files renamed with
# the .rxdata extension. The first 10 lines are reserved, but every 10
# lines after that is used for each item. example:
#
# lines 11-20 = object #1 in database(actors, skills, items, etc)
#
#-------------------------------------------------------------------------------
# Version History
# -0.5 Initial Completion
# -0.6 Updated some code, bug fixes
# -0.7 Added Skill Descriptions, Initial release
# -0.8 Added Character Bios, modified code
# -0.9 Added custom graphics display, modified code
#
#-------------------------------------------------------------------------------
# Credits:
# - Xuroth (for script)
# - game_guy (for help with alias)
# - DerVVulfman (help with basic coding and original idea)
# - Blizzard
# - ForeverZer0
#
# Thanks to all the above scripters! Just by making your awesome scripts, you
# all have inspired me to take up the art. Thanks for helping me with various
# problems, and I hope to learn more from all of you!
#
#===============================================================================
#=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
##
## Configuration
##
#=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# For now, there are only a few constants that can be edited to customize the
# the look. In future versions, there will be more to change as I add new
# features.
# TITLE_FONT -Define which font to use for the object name
# TITLE_SIZE -font size for the object name
# TITLE_COLOR -Item name color (R, G, B, O)
#
# DESC_FONT -Font style for the description text
# DESC_SIZE -Size of the text in the description
# DESC_COLOR -Color of Description text...
#
# BIO_NAME -String that should be displayed for actor biographies
# DESC_NAME -String for the 'Description:' header
#
# USE_PIC -Set to true to use a picture from "Graphics/Pictures"
# Thats it for now. Enjoy!
#-------------------------------------------------------------------------------
module Xuroth
DESC_FONT = 'Tahoma'
DESC_SIZE = 20
DESC_COLOR = Color.new (255, 255, 255, 255) #White is default
TITLE_FONT = 'Tahoma'
TITLE_SIZE = 24
TITLE_COLOR = Color.new(0, 255, 0, 255) #Green by default
BIO_NAME = 'Biography:'
DESC_NAME = 'Description:'
#Set the value below to true to use a graphic in the window. For item, weapons,
#skills, and armors, just name the files exactly like the object in the
#database, only lowercase. These MUST be in the Graphics/Pictures folder.
#If the picture does not exist, the system should be fine. Pics must be .png!
USE_PIC = true
end
#-------------------------------------------------------------------------------
#
# End of Configuration
#
#=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Window_Details < Window_Base
#--------------------------------------------------
# => Sets up the window
#--------------------------------------------------
def initialize
super(0, 0, 640, 480) #call from Window_Base to create a window
self.contents = Bitmap.new(width - 32, height - 32) #set up the text
self.contents.font.name = Xuroth::TITLE_FONT
self.contents.font.size = Xuroth::TITLE_SIZE
self.contents.font.color = Xuroth::TITLE_COLOR
#z-layer makes the detail window appear overtop all the item windows
self.z += 10
@details = [] #declares a variable to hold the details information later
#call the refresh_reset method
refresh_reset
end
#--------------------------------------------------
# => Resets the window so text doesn't get messy
#--------------------------------------------------
def refresh_reset
#clears the window
self.contents.clear
end
#--------------------------------------------------
# => Refreshes the window with details
#--------------------------------------------------
def refresh
#set a local variable to the global $selected_item value
item = $selected_item.id
@color = Xuroth::TITLE_COLOR
#tests to see if item is an Item
if $selected_item.is_a?(RPG::Item)
#get the item's name
item_name = $data_items[item].name
#get the item's icon
item_icon = $data_items[item].icon_name
bitmap = RPG::Cache.icon(item_icon)
#now draw the icon!
self.contents.blt(5, 8, bitmap, Rect.new(0, 0, 24, 24), 255)
#and set a variable to hold the file name. named the same as other
#detail scripts in case you want to use this one (for some reason)
#and dont want to re-write all your lore (though your formatting
#will likely need to be edited.)
@detail_file = File.open("Data/Item_Detail.rxdata")
@desc_hdr = false #use DESCNAME Header
if Xuroth::USE_PIC
@picfilename = $data_items[item].name
if @picfilename != nil
if FileTest.exist?("Graphics/Pictures/#{@picfilename}.png")
bitmap2 = RPG::Cache.picture("#{@picfilename}")
rect2 = Rect.new(0, 0, bitmap2.width, bitmap2.height)
self.contents.blt(600 - bitmap2.width - 32, 0, bitmap2, rect2)
else
@picfilename = ''
end
end
end
#tests to see if the item is a Weapon
elsif $selected_item.is_a?(RPG::Weapon)
#get the name, icon, and file name as before
item_name = $data_weapons[item].name
item_icon = $data_weapons[item].icon_name
bitmap = RPG::Cache.icon(item_icon)
#now draw the icon!
self.contents.blt(5, 8, bitmap, Rect.new(0, 0, 24, 24), 255)
@detail_file = File.open("Data/Weapon_Detail.rxdata")
@desc_hdr = false #use DESCNAME Header
if Xuroth::USE_PIC
@picfilename = $data_weapons[item].name
if @picfilename != nil
if FileTest.exist?("Graphics/Pictures/#{@picfilename}.png")
bitmap2 = RPG::Cache.picture("#{@picfilename}")
rect2 = Rect.new(0, 0, bitmap2.width, bitmap2.height)
self.contents.blt(600 - bitmap2.width - 32, 0, bitmap2, rect2)
else
@picfilename = ''
end
end
end
#tests to see if the item is an Armor
elsif $selected_item.is_a?(RPG::Armor)
#and again, fetch name and icon
item_name = $data_armors[item].name
item_icon = $data_armors[item].icon_name
bitmap = RPG::Cache.icon(item_icon)
#now draw the icon!
self.contents.blt(5, 8, bitmap, Rect.new(0, 0, 24, 24), 255)
@detail_file = File.open("Data/Armor_Detail.rxdata")
@desc_hdr = false #use DESCNAME Header
if Xuroth::USE_PIC
@picfilename = $data_armors[item].name
if @picfilename != nil
if FileTest.exist?("Graphics/Pictures/#{@picfilename}.png")
bitmap2 = RPG::Cache.picture("#{@picfilename}")
rect2 = Rect.new(0, 0, bitmap2.width, bitmap2.height)
self.contents.blt(600 - bitmap2.width - 32, 0, bitmap2, rect2)
else
@picfilename = ''
end
end
end
elsif $selected_item.is_a?(RPG::Skill)
item_name = $data_skills[item].name
item_icon = $data_skills[item].icon_name
bitmap = RPG::Cache.icon(item_icon)
#now draw the icon!
self.contents.blt(5, 8, bitmap, Rect.new(0, 0, 24, 24), 255)
@detail_file = File.open("Data/Skill_Detail.rxdata")
@desc_hdr = false #use DESCNAME Header
if Xuroth::USE_PIC
@picfilename = $data_skills[item].name
if @picfilename != nil
if FileTest.exist?("Graphics/Pictures/#{@picfilename}.png")
bitmap2 = RPG::Cache.picture("#{@picfilename}")
rect2 = Rect.new(0, 0, bitmap2.width, bitmap2.height)
self.contents.blt(600 - bitmap2.width - 32, 0, bitmap2, rect2)
else
@picfilename = ''
end
end
end
else #Else, $selected_item must be a character.
item_name = $game_party.actors[$selected_item].name
actor = $game_party.actors[$selected_item]
draw_actor_graphic(actor, 16, 48)
@detail_file = File.open("Data/Actor_Detail.rxdata")
@desc_hdr = true #Use the BIONAME Header
if Xuroth::USE_PIC
@picfilename = $game_party.actors[$selected_item].name
if @picfilename != nil
if FileTest.exist?("Graphics/Pictures/#{@picfilename}.png")
bitmap2 = RPG::Cache.picture("#{@picfilename}")
rect2 = Rect.new(0, 0, bitmap2.width, bitmap2.height)
self.contents.blt(600 - bitmap2.width - 32, 0, bitmap2, rect2)
else
@picfilename = ''
end
end
end
end
if item_name == nil
item_name = 'Nobody'
end
self.contents.font.color = Xuroth::TITLE_COLOR
self.contents.draw_text(32, 8, 256, 24, item_name)
self.contents.font.color = Xuroth::DESC_COLOR
#now call the method that actually gets and displays the detailed info!
fetch_details(item)
show_details(3, 72)
end
#--------------------------------------------------
# => Gets Details and stores them into an array
#--------------------------------------------------
def fetch_details(item)
#array that holds details:
description =
[
item * 10,
item * 10 + 1,
item * 10 + 2,
item * 10 + 3,
item * 10 + 4,
item * 10 + 5,
item * 10 + 6,
item * 10 + 7,
item * 10 + 8,
item * 10 + 9
]
#stores all lines into variable
@details = @detail_file.readlines
#now set up !?Another?! variable used for processing the data.
@desc = []
#now set it to hold only 10 lines at a time!
for i in 0..9
@desc[i] = @details[description[i]]
end
#finished! now run the display details method!
return
end
#--------------------------------------------------
# => Displays the contents of the array as text
#--------------------------------------------------
def show_details(x, y)
#draw the Description title
self.contents.font.color = Xuroth::DESC_COLOR
if @desc_hdr == true
self.contents.draw_text(x, y + 96, 640, 32, Xuroth::BIO_NAME)
else
self.contents.draw_text(x, y + 96, 640, 32, Xuroth::DESC_NAME)
end
self.contents.font.color = Xuroth::DESC_COLOR
#draw all 10 lines normally
for i in 0..9
if @desc[i] == nil #checks if i is nil. if so, fixes it!
@desc[i] = ' '
else
self.contents.draw_text(x - 32, y + 128, 640, 32, @desc[i])
y += 20
end
end
#method end
end
#class end
end
#===================================================================
# >>> Scene_Item
#===================================================================
# This edits several methods via alias
# and adds a new method for checking
# input.
class Scene_Item
alias detail_main main
def main
@detail_window = Window_Details.new
@detail_window.visible = false
@detail_window.active = false
detail_main
@detail_window.dispose
end
alias detail_update update
def update
detail_update
$selected_item = @item_window.item
if @item_window.active
update_item
return
end
if @detail_window.active
update_details
return
end
end
def update_details
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
unless $game_party.item_can_use?(@item.id)
@item_window.refresh
end
@item_window.active = true
@detail_window.visible = false
@detail_window.active = false
@detail_window.refresh_reset
return
end
end
alias new_update_item update_item
def update_item
new_update_item
if Input.trigger?(Input::A)
# Below if-then statement checks for blank item, and cancels
# the input.
if $selected_item == nil
return
end
$game_system.se_play($data_system.decision_se)
@detail_window.refresh
@item_window.active = false
@detail_window.visible = true
@detail_window.active = true
end
end
end
#===================================================================
# >>> Scene_Skill
#===================================================================
class Scene_Skill
alias skill_detail_main main
def main
@detail_window = Window_Details.new
@detail_window.visible = false
@detail_window.active = false
skill_detail_main
@detail_window.dispose
end
alias detail_update update
def update
detail_update
$selected_item = @skill_window.skill
if @skill_window.active
update_skill
return
end
if @detail_window.active
update_details
return
end
end
def update_details
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
unless @actor.skill_can_use?(@skill.id)
@skill_window.refresh
end
@skill_window.active = true
@detail_window.visible = false
@detail_window.active = false
@detail_window.refresh_reset
return
end
end
alias new_update_skill update_skill
def update_skill
new_update_skill
if Input.trigger?(Input::A)
if $selected_item == nil
return
end
$game_system.se_play($data_system.decision_se)
@detail_window.refresh
@skill_window.active = false
@detail_window.visible = true
@detail_window.active = true
end
end
end
#===================================================================
# >>> Scene_Item
#===================================================================
class Scene_Status
def main
@detail_window = Window_Details.new
@actor = $game_party.actors[@actor_index]
$selected_item = @actor
@status_window = Window_Status.new(@actor)
@status_window.visible = true
@status_window.active = true
@detail_window.visible = false
@detail_window.active = false
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@status_window.dispose
@detail_window.dispose
end
alias actor_detail_update update
def update
actor_detail_update
$selected_item = @actor_index
if @status_window.active
update_actor
return
end
if @detail_window.active
update_details
return
end
end
def update_details
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@status_window.active = true
@detail_window.visible = false
@detail_window.active = false
@detail_window.refresh_reset
return
end
end
def update_actor
if Input.trigger?(Input::A)
if $selected_item == nil
return
end
$game_system.se_play($data_system.decision_se)
@detail_window.refresh
@status_window.active = false
@detail_window.visible = true
@detail_window.active = true
end
end
end