CODE
#==============================================================================
# ** XP: Night_Runner's Social Scene in MOD's Scene Menu script.
#------------------------------------------------------------------------------
# History:
# Date Created: 19/Mar/2012
# Created for: Yuu-Mon Musuedo
# @> http://www.rpgrevolution.com/forums/index.php?showtopic=55386
#
# Description:
# This script adds a social menu option to MOG's Scene_Menu, and contains
# the details for the scene's functioning.
#
# How to Install:
# Copy this entire script. In your game editor select Tools >> Script
# Editor. Along the left scroll to the bottom, right click on 'Main' and
# select 'Insert'. Paste this code on the right.
#
# Customisation:
# See below on between lines 28 - 55.
#==============================================================================
#==============================================================================
# ** Customisation
#==============================================================================
module NR_P3_Menu
#--------------------------------------------------------------------------
# * Window Generics
#--------------------------------------------------------------------------
Window_Speed = 10 # How slow to move the windows
Opacity_Speed = 10 # Increase by 10 per frame (solid image is 255)
#--------------------------------------------------------------------------
# * Character Window
#--------------------------------------------------------------------------
Character_Picture_Name = "Everlyse_Social" # Graphics/Pictures/
#--------------------------------------------------------------------------
# * Title Window
#--------------------------------------------------------------------------
Title_Text = 'Social Network' # The text at the top of the scene
Title_Font_Increase = 10 # Increases the font size by 10 pixels
#--------------------------------------------------------------------------
# * Stats Window
#--------------------------------------------------------------------------
Stats = {"Charm" => 1, # Charm looks in variable 1
"Fatigue" => 2, # Fatigue looks in variable 2
"Scholarship" => 3, # Scholarship looks in variable 3
"Art" => 4, # Art looks in variable 4
"Courage" => 5, # Courage looks in variable 5
}
Friends = {"Number of Friends" => 6} # No. of Friends looks in variable 6
Stats_Text_DY = 24 # Width between lines of text
Stats_Font_Size = Stats_Text_DY * 22 / 32 + 4 # Font size
end
#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
# Edited to allow the user to add a command
#==============================================================================
class Window_Command
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :commands
#--------------------------------------------------------------------------
# * Add Command
#--------------------------------------------------------------------------
def add_command(command_name)
@commands << command_name.to_s
@item_max = @commands.size
self.contents.dispose if self.contents.is_a?(Bitmap)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
# Add a check that this is the window to fake the index for
@nr_P3Menu_fake_index = true if @commands.include?('p3Menu')
end
end
#==============================================================================
# ** Window_P3
#------------------------------------------------------------------------------
# This window class contains the windowskin and movement functions.
#==============================================================================
class Window_P3 < Window_Base
#--------------------------------------------------------------------------
# * Included Modules
#--------------------------------------------------------------------------
include NR_P3_Menu
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :finished_movement
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
@original_x = x
@original_y = y
@d_opacity = Opacity_Speed
super
self.windowskin = RPG::Cache.windowskin("Windowskin - PZE - System")
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
@finished_movement = false
refresh
end
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
def update
super
return if @finished_movement
dx = @desired_x - self.x
dy = @desired_y - self.y
self.x += (dx + Window_Speed - 1) / Window_Speed
self.y += (dy + Window_Speed - 1) / Window_Speed
self.opacity += @d_opacity
if !(self.opacity.between?(1, 244)) and @desired_x == self.x and @desired_y == self.y
@finished_movement = true
end
end
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
def return_to_start
@desired_x = @original_x
@desired_y = @original_y
@d_opacity = -Opacity_Speed
@finished_movement = false
end
end
#==============================================================================
# ** Window_P3Title
#------------------------------------------------------------------------------
# This window displays the title information in the social menu.
#==============================================================================
class Window_P3Title < Window_P3
#--------------------------------------------------------------------------
# * Included Modules
#--------------------------------------------------------------------------
include NR_P3_Menu
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
def initialize
super(-640, -16, 672, 96)
@desired_x = -16
@desired_y = self.y
end
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.size += Title_Font_Increase
t_width = self.contents.width
t_height = self.contents.height
t = Title_Text
self.contents.draw_text(64, 0, t_width - 64, t_height, t)
self.contents.font.size -= Title_Font_Increase
end
end
#==============================================================================
# ** Window_P3Stats
#------------------------------------------------------------------------------
# This window displays the stats in the social menu.
#==============================================================================
class Window_P3Stats < Window_P3
#--------------------------------------------------------------------------
# * Included Modules
#--------------------------------------------------------------------------
include NR_P3_Menu
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(-640, 86, 340, 340)
@desired_x = 10
@desired_y = self.y
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.font.size = Stats_Font_Size
# Initialize the y for the stats
y = 0
for stat in Stats.keys
# Draw the stat name
self.contents.draw_text(0, y, width - 32, Stats_Text_DY, stat.to_s)
y += Stats_Text_DY
# Draw the value
value = $game_variables[Stats[stat].to_i].to_i
value_text = "[%03d/%03d]" % [value, 100]
self.contents.draw_text(10, y, width - 32, Stats_Text_DY, value_text)
y += Stats_Text_DY
end
# Draw the friends section
y = self.contents.height - Stats_Text_DY
stat_text = Friends.keys[0].to_s + ": "
value = $game_variables[Friends.values[0].to_i].to_i
value_text = "[%03d/%03d]" % [value, 100]
text = stat_text + value_text
self.contents.draw_text(0, y, width - 32, Stats_Text_DY, text)
end
end
#==============================================================================
# ** Window_P3Base
#------------------------------------------------------------------------------
# This window displays along the bottom of the scene, it contains no text
#==============================================================================
class Window_P3Base < Window_P3
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(640, 480 - 64 + 16, 672, 64)
@desired_x = -16
@desired_y = self.y
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
end
end
#==============================================================================
# ** Window_P3Character
#------------------------------------------------------------------------------
# This window displays the character along the right
#==============================================================================
class Window_P3Character < Window_P3
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(640, -16, 672, 512)
self.back_opacity = 0
@desired_x = -16
@desired_y = self.y
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
bitmap = RPG::Cache.picture(Character_Picture_Name)
self.contents.blt(0, 0, bitmap, bitmap.rect)
end
end
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# Edited to have an exrta option in the menu
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias nr_p3Menu_intiailize initialize unless $@
alias nr_p3Menu_update update unless $@
#--------------------------------------------------------------------------
# * Class Variables
#--------------------------------------------------------------------------
@@last_index = 0
#--------------------------------------------------------------------------
# Object Initialization
#--------------------------------------------------------------------------
def initialize(*args)
# Run the original initialize
nr_p3Menu_intiailize(*args)
# Set the index from the last time this menu was opened
@menu_index = @@last_index
end
#--------------------------------------------------------------------------
# * Update Cursor Position
#--------------------------------------------------------------------------
def cursor_position_update
@cursor_y = 100 + 206 * @command_window.index / 6 + 20
@cursor_x = 50 + (3 - (3 - @command_window.index).abs) * 15 - 68
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update(*args)
# Add the extra command if necessary
if not @command_window.commands.include?('p3Menu')
@command_window.add_command('p3Menu')
end
# Run the orginal update
nr_p3Menu_update(*args)
# Save the last index
@@last_index = @command_window.index
end
#--------------------------------------------------------------------------
# * Update Command
#--------------------------------------------------------------------------
def update_command
cursor_position_update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
if $game_party.actors.size == 0 and @command_window.index < 4
$game_system.se_play($data_system.buzzer_se)
return
end
case @command_window.index
when 0
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item.new
when 1
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4
$game_system.se_play($data_system.decision_se)
$scene = Scene_SocialMenu.new
when 5
if $game_system.save_disabled
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
$scene = Scene_Save.new
when 6
$game_system.se_play($data_system.decision_se)
$scene = Scene_End.new
end
return
end
end
end
#==============================================================================
# ** Scene_SocialMenu
#------------------------------------------------------------------------------
# This class performs the social menu processing.
#==============================================================================
class Scene_SocialMenu
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Create the backdrop & windows
create_background
create_windows
# Execute transition
if MOG::MENU_BACKGROUND == 0
Graphics.transition(MOG::MNTT, "Graphics/Transitions/" + MOG::MNTP)
else
Graphics.transition
end
# 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
return_window_to_start
# Prepare for transition
Graphics.freeze
# Dispose of window
dispose_background
dispose_windows
end
#--------------------------------------------------------------------------
# * Create Background
#--------------------------------------------------------------------------
def create_background
if MOG::MENU_BACKGROUND == 0
# Get the default background
@mnback = Plane.new
@mnback.bitmap = RPG::Cache.picture("Mn_back")
@mnback.blend_type = 0
@mnback.z = 5
@mnback2 = Plane.new
@mnback2.bitmap = RPG::Cache.picture("Mn_back")
@mnback2.blend_type = 0
@mnback2.z = 5
@mnback2.opacity = 60
else
@spriteset = Spriteset_Map.new
end
end
#--------------------------------------------------------------------------
# * Create Windows
#--------------------------------------------------------------------------
def create_windows
dispose_windows if @windows.is_a?(Array)
@windows = []
@windows << Window_P3Title.new
@windows << Window_P3Character.new
@windows << Window_P3Stats.new
@windows << Window_P3Base.new
for i in 0...@windows.size
window = @windows[i]
window.z = 100 + i
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update the background and windows
windows_slide_update
@windows.each { |window| window.update}
# If a button is triggered, play the se and return to the menu
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
$scene = Scene_Menu.new
end
end
#--------------------------------------------------------------------------
# Windows_slide_update
#--------------------------------------------------------------------------
def windows_slide_update
if MOG::MENU_BACKGROUND == 0
@mnback.oy += 1
@mnback.ox += 1
@mnback2.oy += 1
@mnback2.ox -= 1
end
end
#--------------------------------------------------------------------------
# * Return Windows to Starting Position
#--------------------------------------------------------------------------
def return_window_to_start
@windows.each { |window| window.return_to_start }
loop do
finished_movement = true
Graphics.update
for window in @windows
window.update
finished_movement = false if window.opacity > 0
end
windows_slide_update
break if finished_movement == true
end
end
#--------------------------------------------------------------------------
# * Dispose Background
#--------------------------------------------------------------------------
def dispose_background
if MOG::MENU_BACKGROUND == 0
@mnback.dispose
@mnback.dispose
@mnback2.dispose
@mnback2.dispose
else
@spriteset.dispose
end
end
#--------------------------------------------------------------------------
# * Dispose Windows
#--------------------------------------------------------------------------
def dispose_windows
@windows.each { |window| window.dispose }
@windows = nil
end
end
#==============================================================================
# ** End of Script.
#==============================================================================
And hopefully it works this time, I've uploaded the demo if you need to see the resources:
link