class Window_Details < Window_Base
#initialize method does the window setup.
def initialize
#call from Window_Base to create a window
super(0, 0, 640, 480)
#set up the text area inside the window
self.contents = Bitmap.new(width - 32, height - 32)
#now setup font size, type, and color
self.contents.font.name = 'Tahoma'
self.contents.font.size = 20
self.contents.font.color = normal_color #white
#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
#Refresh_Reset clears the window so text doesnt overlap
# if you browse 2 or more details
def refresh_reset
#clears the window
self.contents.clear
end
# Refresh updates the @details variable with new info
def refresh
#set a local variable to the global $selected_item value
item = $selected_item.id
#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
#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")
#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
@detail_file = File.open("Data/Weapon_Detail.rxdata")
#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
@detail_file = File.open("Data/Armor_Detail.rxdata")
end
#sets a variable to hold the icon
bitmap = RPG::Cache.icon(item_icon) #should not need .png extension as
#another scripter mentioned that RMXP
#automatically loads the correct file
#format. this will only conflict (in
#theory) if there are multiple icons
#with the same name, but different formats.
#now draw the icon!
self.contents.blt(5, 8, bitmap, Rect.new(0, 0, 24, 24), 255)
self.contents.draw_text(32, 8, 256, 24, item_name)
#now call the method that actually gets and displays the detailed info!
fetch_details(item)
show_details(5, 22)
end
#this method here grabs the details from the files. Similar to Jackatrade's
#original script and DerVVulfman's Grouping and Details script, this uses
# three different files for details. Each description can hold 10 lines of
#text, though in the next version, I will try to update this so it can tell
#automagically how many lines to use, and also make the window scrollable !!!
#Note: due to limitations (my current scripting ability) I can not add sweet
#features to make this desirable. Keep in mind that 1.0 of this is only to
#be a simplistic and very basic system. I hope to add more later!
def fetch_details(item)
#Im not really familiar with arrays. so Im just setting one up that can
#store the detail lines thouth I doubt its used efficiently. I'm sure that
#other scripters can see how to do this better.
#Here I cheated and looked at Jackatrade's original script to see how he
#set this up.
#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
def show_details(x, y)
#draw the Description title (next version this will be easier to change!)
self.contents.draw_text(x, y - 20, 640, 32, "Description:")
#draw all 10 lines normally
for i in 0..9
self.contents.draw_text(x, y, 640, 32, @desc[i])
y += 20
end
#method end
end
#class end
end
#==============================================================================#
class Scene_Item
alias detail_main main
def main
detail_main
@detail_window = Window_Details.new
@detail_window.visible = false
@detail_window.active = false
@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
# input effect is true.
if $selected_item == nil
return
end
$game_system.se_play($data_system.decision_se)
@detail_window.refresh #for some reason, it crashes here
@item_window.active = false
@detail_window.visible = true
@detail_window.active = true
end
end
end