=begin
************
AWARD SCREEN
************
by ?xshara?n
Version History
---------------
Dates are in dd-mm-yyyy
v1.0: 13-05-2007
First release. Standard features requested by Amon36.
v1.1: 13-05-2007
Fixed picture alignment. Now picture in any size is centered horizontally.
Added new feature to prevent game closing if picture is not found.
Added new option to align description text.
Features
--------
- Adds a new menu under "Status" called "Awards"
- Enlists all awards in the game.
Awards that are not yet received will be shown in ???? with no description.
- Have up to three lines of description.
- Switch activators may be defined more than one.
- Game will not close if any picture is missing. A black box will be
displayed instead.
Two examples included.
Known bugs
----------
- "Awards" replaces "Save" menu, since addition of this will need
redesign of left portion of default menu.
- Currently only works with DBS.
Compatibility
-------------
- Should work with any scripts that doesn't modify these classes:
class Scene_Menu method main, update_command
class Scene_End method update, command_cancel
- Should not work with SDK.
- Doesn't work with any CMS (see Support on merging).
Support
-------
If there is any errors to this script, let me know. Provide the line number of
the error, what it says (exactly as appears on your screen before the game closes),
and how did you create the error. You can also provide the code of that line
(recommended). For example:
Awards line 99 NameError
Undefined variable name or method "update" for <#Window_Award>
Code: @award_window.update
If there is script incompatibility and you want me to merge, please
provide me the conflicting script (at least a link to the Internet
where I can find it; not a dead link please!) and I'll try merging them.
This also applies to CMS.
DO NOT ASK me to convert this script to SDK-compatible, I prefer not to.
These and any suggestions should be e-mailed to
hoshiro [dot] exsharaen [at] gmail [dot] com
Replace each bracketed words with appropriate symbols.
Enjoy! ;)
=end
=begin
************
Installation
************
Just make a new page above Main and copy-paste this script to the new page.
********
SETTINGS
********
There is only one setting: the awards themselves. Awards are stored in AWARDS
constant below. Each awards will use the following format:
award_id =>
{
:title => "Your title here",
:activator => [<game switches ID(s) here>],
:active_pic_name => "picture filename",
:dimmed_pic_name => "dimmed picture filename",
:description => "Awards description here"
}
See the examples of using this format.
To keep in mind:
award_id is used only to distinguish each awards (so they are unique each other)
and doesn't affect the way they are activated.
Use numbers or strings (numbers are recommended) for award_id.
:activator is a collection (array) of game switches you use to activate the award.
Keep in mind that they are defined between brackets [].
Separate each switch ID by a comma.
:description can have up to three lines. Separate each line by "\n"
(without quotes). To make reading easier, you can split lines as exampled below.
All pictures goes to \Graphics\Pictures of your game folder. Maximum size is
400px x 300px; any picture larger than that will be cropped.
=end
# All awards goes here
AWARDS =
{
0 =>
{
:title => "Beastslayer",
:activator => [1],
:active_pic_name => "rune1",
:dimmed_pic_name => "rune1 dimmed",
:description => "Awards for beating yourself ;P"
},
1 =>
{
:title => "Dragonslayer",
:activator => [2, 3],
:active_pic_name => "rune11", # example of picture not found
:dimmed_pic_name => "rune11 dimmed",
:description => "Awards for beating a dragon.\n" +
"This is a long description, let's see if it fits to one line...\n" +
"It fits! You can write longer description for awards up to 3 lines!"
}
}
# Description text alignment
# 0 = left, 1 = center, 2 = right
# Defaults to 0 (left)
DESC_ALIGNMENT = 1
# SETTINGS END HERE
class Window_Award < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 64, 640, 416)
@item_max = AWARDS.size
self.contents = Bitmap.new(width - 32, @item_max * 32)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
# Draw all award title
y = 0
AWARDS.each {|key, value|
detail = AWARDS[key]
# Activated?
activated = true
for switch in detail[:activator]
unless $game_switches[switch]
activated = false
break
end
end
# If activated, draw award title, else draw "????"
title = activated ? detail[:title] : "????"
self.contents.draw_text(4, y, 608, 32, title)
y += 32
}
end
end
class Window_AwardDetail < Window_Base
def initialize(award_index)
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
@award_index = award_index
refresh
end
def refresh
self.contents.clear
# Get award
award = AWARDS[@award_index]
# Activated?
activated = true
for switch in award[:activator]
unless $game_switches[switch]
activated = false
break
end
end
# Draw award name if activated
title = activated ? award[:title] : "????"
self.contents.font.bold = true
self.contents.font.italic = true
self.contents.draw_text(0, 0, 608, 32, title, 1)
# Draw award picture
begin
pic_type = activated ? award[:active_pic_name] : award[:dimmed_pic_name]
award_pic = RPG::Cache.picture(pic_type)
src_rect = Rect.new(0, 0, 400, 300)
# Centering image...
pic_width = (award_pic.width > 400) ? 400 : award_pic.width
x = (640 - pic_width) / 2 - 16
self.contents.blt(x, 40, award_pic, src_rect)
# In case picture doesn't exist...
rescue Errno::ENOENT
pic_width = 400
x = (640 - pic_width) / 2 - 16
# Draw a black box instead
self.contents.fill_rect(x, 40, 400, 300, Color.new(0, 0, 0))
self.contents.draw_text(x, 40 + 150 - 16, 400, 32, "Picture not available", 1)
end
# Draw description
y = 348
if activated
# Split lines
award[:description].each_line {|line|
self.contents.font.bold = false
self.contents.font.italic = false
# Draw each description line
self.contents.draw_text(0, y, 608, 32, line, DESC_ALIGNMENT)
y += 32
}
end
end
end
class Scene_Award
def initialize(index = 0)
@index = index
end
def main
# Make award window
@award_window = Window_Award.new
@award_window.index = @index
@help_window = Window_Help.new
@help_window.set_text("AWARDS", 1)
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose award window
@award_window.dispose
@help_window.dispose
end
def update
@award_window.update
@help_window.update
# Cancel selection and return to menu scene
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Menu.new(4)
return
end
# Enters award detail scene
if Input.trigger?(Input::C)
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to award detail screen
$scene = Scene_AwardDetail.new(@award_window.index)
return
end
end
end
class Scene_AwardDetail
def initialize(award_index = 0)
@award_index = award_index
end
def main
@award_detail_window = Window_AwardDetail.new(@award_index)
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose award window
@award_detail_window.dispose
end
def update
# Go back to award selection screen
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to award selection screen
$scene = Scene_Award.new(@award_index)
return
end
end
end
class Scene_Menu
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make command window
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = "Status"
s7 = "Awards"
s6 = "End Game"
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s7, s6])
@command_window.index = @menu_index
# If number of party members is 0
if $game_party.actors.size == 0
# Disable items, skills, equipment, and status
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
# If save is forbidden
if $game_system.save_disabled
# Disable save
@command_window.disable_item(4)
end
# Make play time window
@playtime_window = Window_PlayTime.new
@playtime_window.x = 0
@playtime_window.y = 224
# Make steps window
@steps_window = Window_Steps.new
@steps_window.x = 0
@steps_window.y = 320
# Make gold window
@gold_window = Window_Gold.new
@gold_window.x = 0
@gold_window.y = 416
# Make status window
@status_window = Window_MenuStatus.new
@status_window.x = 160
@status_window.y = 0
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@command_window.dispose
@playtime_window.dispose
@steps_window.dispose
@gold_window.dispose
@status_window.dispose
end
alias award_update_command update_command
def update_command
if Input.trigger?(Input::C)
case @command_window.index
when 4 # awards menu
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to award screen
$scene = Scene_Award.new
return
=begin
when 5 # save
# If saving is forbidden
if $game_system.save_disabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to save screen
$scene = Scene_Save.new
return
=end
when 5 # end game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to end game screen
$scene = Scene_End.new
return
end
end
award_update_command
end
end
=begin
class Scene_Save
#--------------------------------------------------------------------------
# * Decision Processing
#--------------------------------------------------------------------------
def on_decision(filename)
# Play save SE
$game_system.se_play($data_system.save_se)
# Write save data
file = File.open(filename, "wb")
write_save_data(file)
file.close
# If called from event
if $game_temp.save_calling
# Clear save call flag
$game_temp.save_calling = false
# Switch to map screen
$scene = Scene_Map.new
return
end
# Switch to menu screen
$scene = Scene_Menu.new(5)
end
#--------------------------------------------------------------------------
# * Cancel Processing
#--------------------------------------------------------------------------
def on_cancel
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# If called from event
if $game_temp.save_calling
# Clear save call flag
$game_temp.save_calling = false
# Switch to map screen
$scene = Scene_Map.new
return
end
# Switch to menu screen
$scene = Scene_Menu.new(5)
end
end
=end
class Scene_End
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update command window
@command_window.update
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Menu.new(5)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 # to title
command_to_title
when 1 # shutdown
command_shutdown
when 2 # quit
command_cancel
end
return
end
end
#--------------------------------------------------------------------------
# * Process When Choosing [Cancel] Command
#--------------------------------------------------------------------------
def command_cancel
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to menu screen
$scene = Scene_Menu.new(5)
end
end