You are on page 1of 16

#==============================================================================

# Phantasia-esque CMS
# Version: 1.0
# Author: modern algebra (rmrk.net)
# Date: October 6, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script gives you a menu design that is inspired by a mix between
# Tales of Phantasia and my own Full Status CMS. Like Tales of Phantasia,
# each actor gets their own window and their sprite is shown walking in the
# top right corner. Like FSCMS, the command window and optional windows are
# hugely customizable, allowing you to relatively easily add new scripts to
# be accessible from the menu (with an automatic index finder so that you
# don't need to modify the return_scene methods of the respective scripts
# that you add to the menu), call common events from the menu (including
# the ability to select an actor and have your common event operate only on
# the actor chosen) and you can use any of the five optional windows that
# are in the FSCMS - Location, Playtime, Gold, Steps, and Variable.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
#
# Place this script below any scripts you intend to add to the menu, but
# still above Main.
#
# Please see Editable Region A at line 58 for configuration options and see
# Editable Region B at line 107 for instructions on adding scenes (or common
# events) to the menu and other configuration options.
#
# Note that you can alter the composition of the menu or the optional
# windows in-game with the following script calls:
#
# add_custom_command (command_id)
# remove_custom_command (command_id)
# command_id : ID of the command being added/removed from the commands
# These are defined by you - see Editable Region B at line 107
# add_optional_window (window_id)
# remove_optional_window (window_id)
# window_id : ID of the window being added/removed from the menu
# 0 => Gold Window :shows amount of party gold
# 1 => PlayTime Window :shows current playtime
# 2 => Steps Window :shows number of steps party has taken
# 3 => Location Window :shows name of the current map
# 4 => Variable Window :shows the value of a designated variable
#==============================================================================
#==============================================================================
# *** Phantasia CMS
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This module holds configuration data for Phantasia CMS
#==============================================================================
module Phantasia_CMS
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# ** CONSTANTS
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# EDITABLE REGION A
#``````````````````````````````````````````````````````````````````````````
# Here is where all configuration data is setup. Please read the comments
# adjacent to each comment to discover what it does.
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# SPRITE_X_ and SPRITE_Y_POSITION constants determine the position of the
# sprites as they appear in the menu. Default of 0, 0, they will be placed
# at -32, 64 in reference to the upper right corner of their box. They will
# need to be altered when using larger sprites than RTP
SPRITE_X_OFFSET = 0
SPRITE_Y_OFFSET = 0
# The number of frames before the sprites in the menu change direction.
# 60 Frames = 1 second
SPRITE_DIRECTION_FRAMES = 60
# Each of the following color options refer to the windowskin palette.
# So 0 is normal_color, 16 is system_color, etc.. You can use any of the
# colours from the palette, from 0 - 31. If you wish to set it directly by
# rgb values, then you can use an array like [red, green, blue].
EXP_BAR_COLOR1 = 28 # First Gradient Shade
EXP_BAR_COLOR2 = 29 # Second Gradient Shade
ACTOR_NAME_COLOR = 16 # The color of the name of the actor in the menu
VOCAB_EXP = "EXP" # The vocabulary for representing Experience
# If you wish to use an image for your background in the menu rather than
# the default blur and darken effect, place the image you want to use in
# your System folder and put its name between quotes. If you do not wish to
# use this feature, leave it as "" and it will default to blur and darken.
MENU_BACKDROP = ""
# Boolean on whether to show the windows even when the party is less than
# 4 members. When true, all four windows will always be shown, but where you
# are missing an actor it will be blank. When false, only windows for which
# there is an actor will be shown.
EMPTY_WINDOWS_SHOWN = false
# For common event commands that require actor selection, this is the ID of
# the variable that will hold the chosen actor's ID.
CE_ACTOR_VARIABLE_ID = 1
# If you decide to show a Variable optional window, this is the ID of the
# variable that will be shown in the menu.
VARWINDOW_VARIABLE_ID = 3
# Optional Window Icons. For all icons, # -1 => no icon. >0 => icon index
VARWINDOW_VARIABLE_ICON = 141 # Icon of variable window
GOLD_ICON = 2644 # Icon of gold window
PLAYTIME_ICON = 11480 # Icon of playtime window
STEPS_ICON = 48 # Icon of steps window
LOCATION_ICON = 10773 # Icon of location window
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# END EDITABLE REGION A
#//////////////////////////////////////////////////////////////////////////
CUSTOM_COMMANDS = {
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# EDITABLE REGION B
#``````````````````````````````````````````````````````````````````````````
# This is where you can configure the initial composition of the menu;
# the order of optional windows, the order of the command list, and setting
# up commands that can be included in the command list - all of that is
# done here.
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Command Setup
# Inspired by Yanfly's Scene Menu Redux
#
# Each command can be set up in the following format:
#
# CommandID => ["Name", IconID, DisableCondition, ActorSelect?,
# SceneName, SceneArguments],
#
# CommandID : this is the ID that this command is represented by. It is
# used in denoting the order in which it appears in the command list
# at line 194. This MUST be unique for each command
# Name : This is how the command appears in the list. If it is represented
# by a method or value included in Vocab, then you can input its
# call. Otherwise, write it exactly as it should appear.
# IconID : The ID of the icon that will appear next to the name of the
# command in the command window.
# DisableCondition : if this is put as a string, it will evaluate the
# string as code and use it's an integer, then the command will be
# disabled if the switch with that ID is ON. If it is a string, it
# will evaluate the string as code. This is useful for scripts that
# have disable conditions updated through event-inaccessible booleans.
# If this is set to -1, it will never be disabled
# ActorSelect? : Truth value of whether or not actor should be selected.
# If true, the first argument sent to the scene will always be
# @target_window.index. If true when the command calls a common event,
# then the ID of the actor chosen will be saved to a variable as
# designated by CE_ACTOR_VARIABLE_ID at line 78
# SceneName : This is the class name of the scene being called once this
# command is selected. You MUST know this data from whatever script you
# are trying to add. If you want this command to call a common event,
# place the ID of the catalogue you wish to call instead. If there is
# more than one command that calls the same scene, then there will
# need to be some manual index setting when returning to the menu
# from that scene.
# SceneArguments : a String of the arguments to be passed to the scene
# when it is called. This too must be known from the script you are
# trying to add.
#
# Note that the comma after the last square bracket must be excluded if you
# are not adding any more commands after it. If you receive a syntax error
# after configuring this script, then it is likely a missing comma or bracket
# or, as noted, there is a comma after the last command.
# Be sure to check your commas before reporting the error.
#
# EXAMPLE 1:
#
# 7 => ["Quests", 178, "$game_system.quest_disabled || $game_party.quests.l
ist.empty?",
# false, Scene_Quest, "1"],
#
# This will create a command called Quests that is represented by the
# icon with index 178. It does not require actor selection and calls:
# $scene = Scene_Quest.new (1)
# when selected. The option is disabled if:
# $game_system.quest_disabled || $game_party.quests.list.empty?
# returns true. It's ID is 7, so when setting up your command list, this
# command will show up wherever you set 7 in the list
#
# EXAMPLE 2:
#
# 15 => ["Vocab::escape", 134, 5, false, 4]
# }
#
# This will create a command that is called whatever you have labelled
# the escape option in the Terms section of the database. It is
# represented by the icon with index 134. It is disabled if the switch
# with ID 5 is ON; it does not require actor selection, and it calls
# the common event with ID 4
0 => ["Vocab::item", 2246, "$game_party.members.empty?", false, Scene_Item],
1 => ["Vocab::skill", 2248, "$game_party.members.empty?", true, Scene_Skill]
,
2 => ["Vocab::equip", 2247, "$game_party.members.empty?", true, Scene_Equip]
,
3 => ["Vocab::status", 2249, "$game_party.members.empty?", true, Scene_Statu
s],
4 => ["Vocab::save", 2250, "$game_system.save_disabled", false, Scene_File,
"true, false, false"],
5 => ["Vocab::game_end", 2251, -1, false, Scene_End],
}
# This is where you setup the order that commands appear in the command
# window of the menu. List them by their command ID, as it is explained
# above. The default commands are:
# 0 => Item
# 1 => Skill
# 2 => Equip
# 3 => Status
# 4 => Save
# 5 => End Game
# Those can be changed by you above, if you desire, and you can always add
# more commands with whatever IDs you want. Note, however, that those
# command IDs must appear in the array below or they will NOT appear in the
# initial menu. This array can be modified in-game by the following script
# calls:
#
# add_custom_command (command_id)
# remove_custom_command (command_id)
# command_id : ID of the command being added/removed from the commands
COMMANDLIST = [0, 1, 2, 3, 4, 5]
# Which optional windows ought to be created, from bottom to top?
# 0 => Gold Window
# 1 => PlayTime Window
# 2 => Steps Window
# 3 => Location Window
# 4 => Variable Window
# This array can be modified in-game by the following script calls:
#
# add_optional_window (window_id)
# remove_optional_window (window_id)
# window_id : ID of the window being added/removed from the menu
OPTIONAL_WINDOWS = [0, 1, 3]
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# END EDITABLE REGION B
#//////////////////////////////////////////////////////////////////////////
end
#==============================================================================
# ** Game System
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new instance variables - phancms_custom_commands, phancms_optional_windows
# aliased method - initialize
#==============================================================================
class Game_System
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Public Instance Variables
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
attr_reader :tpcms_command_list # Holds current array of commands in menu
attr_reader :tpcms_optional_windows # Holds current array of optional windows
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias ma_phancms_intz_cstmcmmns_6hj2 initialize
def initialize (*args)
# Initialize new variables
@tpcms_command_list = Phantasia_CMS::COMMANDLIST
@tpcms_optional_windows = Phantasia_CMS::OPTIONAL_WINDOWS
ma_phancms_intz_cstmcmmns_6hj2 (*args) # Run Original Method
end
end
#==============================================================================
# ** Game Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new method - get_exp_progress
#==============================================================================
class Game_Actor
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Get Exp Progress
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def exp_progress
return @exp - @exp_list[@level]
end
end
#==============================================================================
# ** Game Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new methods - add_custom_command; add_optional_window;
# remove_custom_command; remove_optional_window
#==============================================================================
class Game_Interpreter
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Custom Commands Add/Remove
# id : Command ID to add or remove
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def add_custom_command (id)
$game_system.tpcms_command_list.push (id) unless $game_system.tpcms_command_
list.include? (id)
end
def remove_custom_command (id)
$game_system.tpcms_command_list.delete (id)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Optional Windows Add/Remove
# id : window ID to add or remove
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def add_optional_window (id)
$game_system.tpcms_optional_windows.push (id) unless $game_system.tpcms_opti
onal_windows.include? (id)
end
def remove_optional_window (id)
$game_system.tpcms_optional_windows.delete (id)
end
end
#==============================================================================
# ** Sprite_MenuActor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This window displays the walking sprite of an actor.
#==============================================================================
class Sprite_MenuActor < Sprite_Character
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize (party_id, x, y, viewport = nil)
actor = $game_party.members[party_id]
character = Game_Character.new
@frame_count = 0
character.set_graphic (actor.character_name, actor.character_index)
super (viewport, character)
self.x, self.y, self.z = x, y, 200
case party_id
when 1 then @character.turn_left
when 2 then @character.turn_up
when 3 then @character.turn_right
end
update_bitmap
update
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Frame Update
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def update
# Turn at user-specified intervals
if @frame_count == Phantasia_CMS::SPRITE_DIRECTION_FRAMES
@character.turn_right_90
@frame_count = 0
end
@character.update_move
@character.update_animation
update_src_rect
@frame_count += 1
end
end
#==============================================================================
# ** Window_Gold
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# overwritten super method - draw_currency_value
#==============================================================================
class Window_Gold
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Draw Currency Value
# value : amount to draw
# x, y : coordinates to draw at
# width : amount of room to draw
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def draw_currency_value (value, x, y, width, *args)
if Phantasia_CMS::GOLD_ICON >= 0
draw_icon (Phantasia_CMS::GOLD_ICON, x, y)
x += 24
width -= 24
end
# Run Original Method
super (value, x, y, width, *args)
end
end
#==============================================================================
# ** Window_TPCMS_MenuActor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This window displays basic status information on a party member.
#==============================================================================
class Window_TPCMS_MenuActor < Window_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize (party_id)
@party_id = party_id
@naming = false
width, height = (Graphics.width - 160) / 2, (Graphics.height / 2)
x = (party_id % 2)*(width + 160)
y = (party_id / 2)*height
super (x, y, width, height)
refresh
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Dispose
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def dispose
@actor_sprite.dispose unless @actor_sprite.nil? || @actor_sprite.disposed?
super
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Frame Update
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def update
@actor_sprite.update unless @actor_sprite.nil? || @actor_sprite.disposed?
super
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Create Sprite
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def create_sprite
@actor_sprite.dispose unless @actor_sprite.nil? || @actor_sprite.disposed?
sprite_x = self.x + self.width - 32 + Phantasia_CMS::SPRITE_X_OFFSET
sprite_y = self.y + 64 + Phantasia_CMS::SPRITE_Y_OFFSET
@actor_sprite = Sprite_MenuActor.new (@party_id, sprite_x, sprite_y)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Refresh
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def refresh
self.contents.clear
return if @party_id >= $game_party.members.size
create_sprite
actor = $game_party.members[@party_id]
# Draw Actor Stuff
@naming = true
draw_actor_name(actor, 0, 0)
@naming = false
draw_actor_class(actor, 0, WLH)
if contents.height / WLH < 7
# Only Draw Level
draw_actor_level(actor, 0, WLH * 2)
y = [WLH*3, contents.height - WLH*3].max
else
y = (contents.height - 3*WLH) / 2
draw_actor_level(actor, 0, y)
draw_actor_exp (actor, 0, y + WLH, contents.width)
y *= 2
end
draw_actor_state(actor, 0, y, contents.width)
draw_actor_hp(actor, 0, y + WLH, contents.width)
draw_actor_mp(actor, 0, y + WLH*2, contents.width)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Normal Color
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def normal_color
if @naming
if Phantasia_CMS::ACTOR_NAME_COLOR.is_a? (Fixnum)
return text_color (Phantasia_CMS::ACTOR_NAME_COLOR)
else
return Color.new (*Phantasia_CMS::ACTOR_NAME_COLOR)
end
end
return super
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Draw Actor EXP
# actor : the actor to draw exp of
# x, y : coordinates to start drawing
# width : the total width of guage
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def draw_actor_exp (actor, x, y, width = 120)
draw_actor_exp_gauge(actor, x, y, width)
self.contents.font.color = system_color
tw = contents.text_size (Phantasia_CMS::VOCAB_EXP).width
self.contents.draw_text(x, y, tw, WLH, Phantasia_CMS::VOCAB_EXP)
self.contents.font.color = normal_color
xr = x + width
room = width - tw
tw = contents.text_size (actor.next_exp_s).width
d_room = (room - 11) / 2
if tw > d_room
self.contents.draw_text(xr - room, y, room, WLH, actor.exp_s, 2)
else
self.contents.draw_text(xr - room, y, d_room, WLH, actor.exp_s, 2)
self.contents.draw_text(xr - room + d_room, y, 11, WLH, "/", 2)
self.contents.draw_text(xr - d_room, y, d_room, WLH, actor.next_exp_s, 2)
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Draw Actor EXP Gauge
# actor : the actor to draw exp of
# x, y : coordinates to start drawing
# width : the total width of guage
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def draw_actor_exp_gauge (actor, x, y, width = 120)
gw = width * actor.exp_progress / actor.next_rest_exp_s.to_i
# Get colors
if Phantasia_CMS::EXP_BAR_COLOR1.is_a? (Fixnum)
gc1 = text_color (Phantasia_CMS::EXP_BAR_COLOR1)
else
gc1 = Color.new (*Phantasia_CMS::EXP_BAR_COLOR1)
end
if Phantasia_CMS::EXP_BAR_COLOR2.is_a? (Fixnum)
gc2 = text_color (Phantasia_CMS::EXP_BAR_COLOR2)
else
gc2 = Color.new (*Phantasia_CMS::EXP_BAR_COLOR2)
end
self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
end
end
#==============================================================================
# ** Window_TPCMS_Target
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This window is a transparent window used for cursor purposes
#==============================================================================
class Window_TPCMS_Target < Window_Selectable
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize
super(-16, -16, Graphics.width + 32, Graphics.height + 32, 160)
@item_max = $game_party.members.size
@column_max = 2
self.active = false
self.opacity = 0
self.z = 250
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Item Rect
# index : item number (actor)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def item_rect (index)
rect = super (index)
rect.height = contents.height / 2
rect.y = (index / @column_max) * rect.height
return rect
end
end
#==============================================================================
# ** Window_MenuCommand
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This window shows commands in the menu
# overwritten super methods - draw_item
#==============================================================================
class Window_TPCMS_MenuCommand < Window_Command
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize(*args)
super (*args)
max_height = Graphics.height - ($game_system.tpcms_optional_windows.size*(WL
H + 32))
if self.height > max_height
self.height = max_height
create_contents
refresh
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Draw Item
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def draw_item (i, enabled = true)
rect = item_rect(i)
self.contents.clear_rect(rect)
# Draw icon
icon = Phantasia_CMS::CUSTOM_COMMANDS[$game_system.tpcms_command_list[i]][1]
draw_icon (icon, rect.x + 2, rect.y, enabled)
rect.x += 28
rect.width -= 32
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(rect, @commands[i])
end
end
#==============================================================================
# ** Window Location
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This window shows the current location
#==============================================================================
class Window_TPCMS_Location < Window_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize (x, y)
height = 32 + WLH
y -= height
super (x, y, 160, height)
x, tw = 0, contents.width
if Phantasia_CMS::LOCATION_ICON >= 0
draw_icon (Phantasia_CMS::LOCATION_ICON, x, 0)
x += 24
tw -= 24
end
map_name = load_data ("Data/MapInfos.rvdata")[$game_map.map_id].name
contents.font.color = normal_color
contents.draw_text (x, 0, tw, WLH, map_name, 2)
end
end
#==============================================================================
# ** Window PlayTime
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This window shows total playtime
#==============================================================================
class Window_TPCMS_PlayTime < Window_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize (x, y)
super (x, y, 160, 32 + WLH)
refresh
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Refresh
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def refresh
self.contents.clear
x, tw = 0, contents.width
if Phantasia_CMS::PLAYTIME_ICON >= 0
draw_icon (Phantasia_CMS::PLAYTIME_ICON, x, 0)
x += 24
tw -= 24
end
@total_sec = Graphics.frame_count / Graphics.frame_rate
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(x, 0, tw, WLH, text, 2)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Frame Update
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
refresh
end
end
end
#==============================================================================
# ** Window StepCount
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This window shows total number of steps party has taken
#==============================================================================
class Window_TPCMS_StepCount < Window_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize (x, y)
super (x, y, 160, 32 + WLH)
x, tw = 0, contents.width
# Draw step count icon
if Phantasia_CMS::STEPS_ICON >= 0
draw_icon (Phantasia_CMS::STEPS_ICON, x, 0)
x += 24
tw -= 24
end
# Draw Step Count
contents.font.color = normal_color
contents.draw_text (x, 0, tw, WLH, $game_party.steps.to_s, 2)
end
end
#==============================================================================
# ** Window Variable
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This window shows the value of a specified variable
#==============================================================================
class Window_TPCMS_Variable < Window_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize (x, y)
super (x, y, 160, 32 + WLH)
refresh
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Refresh
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def refresh
x, tw = 0, contents.width
# Draw varibale icon
if Phantasia_CMS::VARWINDOW_VARIABLE_ICON >= 0
draw_icon (Phantasia_CMS::VARWINDOW_VARIABLE_ICON, x, 0)
x += 24
tw -= 24
end
# Draw Variable
text = $game_variables[Phantasia_CMS::VARWINDOW_VARIABLE_ID].to_s
contents.font.color = normal_color
contents.draw_text (x, 0, tw, WLH, text, 2)
end
end
#==============================================================================
# ** Scene_Menu
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# completely overwritten class
#==============================================================================
class Scene_Menu < Scene_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
# menu_index : command cursor's initial position
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize(menu_index = 0, manual = false)
if manual
@menu_index = menu_index
return
elsif $scene.is_a? (Scene_Map)
@menu_index = 0
return
end
# Check where it is coming from.
$game_system.tpcms_command_list.each_index { |i|
j = $game_system.tpcms_command_list[i]
# If coming from this designated scene
next if Phantasia_CMS::CUSTOM_COMMANDS[j][4].is_a? (Fixnum)
if $scene.is_a? (Phantasia_CMS::CUSTOM_COMMANDS[j][4])
# Set menu index to its position
@menu_index = i
return
end
}
@menu_index = 0
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Start processing
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def start
super
create_menu_background
create_command_window
@target_window = Window_TPCMS_Target.new
@windows = [@command_window, @target_window]
for i in 0...4
break if !Phantasia_CMS::EMPTY_WINDOWS_SHOWN && i >= $game_party.members.s
ize
@windows.push (Window_TPCMS_MenuActor.new (i))
end
create_optional_windows
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Termination Processing
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def terminate
super
dispose_menu_background
@windows.each { |window| window.dispose }
@optional_windows.each { |window| window.dispose }
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Frame Update
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def update
super
update_menu_background
# Update Actor windows
@windows.each { |window| window.update if window.is_a? (Window_TPCMS_MenuAct
or) }
# Update Playtime if it is shown
if $game_system.tpcms_optional_windows.include? (1)
@optional_windows[$game_system.tpcms_optional_windows.index (1)].update
end
if @target_window.active
update_actor_selection
return
end
# Update Command Window
if @command_window.active
update_command_selection
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Create Background for Menu Screen
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def create_menu_background
if Phantasia_CMS::MENU_BACKDROP == ""
super
else
@menuback_sprite = Sprite.new
@menuback_sprite.bitmap = Cache.system (Phantasia_CMS::MENU_BACKDROP)
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Create Command Window
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def create_command_window
@commands, @disabled_commands, @actor_commands = [], [], []
@scene_calls, @scene_arguments = [], []
index = 0
$game_system.tpcms_command_list.each { |i|
command = Phantasia_CMS::CUSTOM_COMMANDS[i]
name = command[0][/Vocab/i] != nil ? eval (command[0]) : command[0]
@commands.push (name)
if command[2].is_a? (String)
boolean = eval (command[2])
@disabled_commands.push (index) if boolean
else
@disabled_commands.push (index) if command[2] > 0 && $game_switches[comm
and[2]]
end
@actor_commands.push (index) if command[3]
@scene_calls.push (command[4])
@scene_arguments.push (command[5])
index += 1
}
@command_window = Window_TPCMS_MenuCommand.new(160, @commands)
@command_window.index = @menu_index
@command_window.x = (Graphics.width - 160) / 2
# Disable commands
@disabled_commands.each { |index| @command_window.draw_item (index, false) }
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Create Optional Windows
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def create_optional_windows
y = Graphics.height
@optional_windows = []
$game_system.tpcms_optional_windows.each { |i|
window = optional_window (i)
y -= window.height
window.y = y
@optional_windows.push (window)
}
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Optional Window
# index : index of optional window
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def optional_window (index)
x = (Graphics.width - 160) / 2
return case index
when 0 then Window_Gold.new (x, 0)
when 1 then Window_TPCMS_PlayTime.new (x, 0)
when 2 then Window_TPCMS_StepCount.new (x, 0)
when 3 then Window_TPCMS_Location.new (x, 0)
when 4 then Window_TPCMS_Variable.new (x, 0)
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Update Command Selection
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def update_command_selection
@command_window.update
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
# Return if Disabled
if @disabled_commands.include? (@command_window.index)
Sound.play_buzzer
return
end
Sound.play_decision
# Start Actor Selection if command desires actor selection
if @actor_commands.include? (@command_window.index)
start_actor_selection
else
call_next_scene
end
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Start Actor Selection
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def start_actor_selection
@command_window.active = false
@target_window.active = true
if $game_party.last_actor_index < @target_window.item_max
@target_window.index = $game_party.last_actor_index
else
@target_window.index = 0
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * End Actor Selection
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def end_actor_selection
$game_party.last_actor_index = @target_window.index
@command_window.active = true
@target_window.active = false
@target_window.index = -1
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Update Actor Selection
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def update_actor_selection
@target_window.update
if Input.trigger?(Input::B)
Sound.play_cancel
end_actor_selection
elsif Input.trigger?(Input::C)
select_actor
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Select Actor
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def select_actor
$game_party.last_actor_index = @target_window.index
Sound.play_decision
call_next_scene
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Call Next Scene
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def call_next_scene
# Call next scene
if @scene_calls[@command_window.index].is_a? (Fixnum)
# If actor selected
if @actor_commands.include? (@command_window.index)
var_id = Phantasia_CMS::CE_ACTOR_VARIABLE_ID
$game_variables[var_id] = $game_party.members[@target_window.index].id
end
# Run Common Event if Scene call is an integer
$game_temp.common_event_id = @scene_calls[@command_window.index]
$scene = Scene_Map.new
else
# Call specified scene
args = []
if @scene_arguments[@command_window.index] != nil
args = eval ("[#{@scene_arguments[@command_window.index]}]")
end
# If actor selected
if @actor_commands.include? (@command_window.index)
args.unshift (@target_window.index)
end
$scene = @scene_calls[@command_window.index].new (*args)
end
end
end

You might also like