#===============================================================================
# Mobius' Title Command Manager
# Author: Mobius XVI
# Version: 1.0
# Date: 9 AUG 2017
#===============================================================================
#
# Introduction:
#
# This script allows you to add custom commands to the title, remove existing
# commands, and order them however you like.
#
# Instructions:
#
# - Place this script below all the default scripts but above main.
# If you're using other scripts which affect the title, I recommend
# placing this script above them in the script editor.
#
# - The customization section below has additional instructions on
# how to set up and organize the commands.
#
# Issues/Bugs/Possible Bugs:
#
# - As this script replaces the default title system scripts, it
# may be incompatible with other title system scripts.
#
#
# Credits/Thanks:
# - Mobius XVI, author
#
# License
#
# This script is available in its entirety for commercial and non-commercial
# use. View the specific license terms below.
#
# The MIT License (MIT)
#
# Copyright (c) 2017 darmes
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Further, if you do decide to use this script in a commercial product,
# I'd ask that you let me know via a forum post or a PM. Thanks.
#
#==============================================================================
# ** CUSTOMIZATION START
#==============================================================================
module Mobius
module Title_Commands
# COMMAND OPTIONS #
# These options allow you to configure all of the title commands.
# Big picture: Every command has a 'command key' associated it with.
# This allows you to link several different settings to the same command.
# The keys are all of the type ':key_name'. That is a colon followed
# by the key's name. As a rule, the keys should be all lowercase.
# Additionally every command will need a key placed in the COMMAND_ORDER,
# COMMAND_NAMES, and COMMAND_CALLS options below. It's optional for
# COMMAND_ACTOR_SELECT, and COMMAND_ACTOR_REQUIRED.
# Order of Commands #
# Place all of your command keys in between the two square brackets.
# Each key should be separated from the others with a comma.
# The order in which these keys are placed will determine their order
# in game, i.e. the first (top) key will be the first (top) command.
COMMAND_ORDER = [
:new_game,
:continue,
:shutdown,
]
# Command Display Names #
# This links your command keys to their display text in game.
# In general, these will be the same but they might vary a little.
# Think of this like setting a 'word' in the database. In fact,
# this overwrites the database setting, so be sure to define them here.
# Each entry is a pair like this - :command_key => "Display Name"
# Separate entries with commas. The order of these entries does NOT
# affect the order in game.
COMMAND_NAMES = {
:new_game => "New Game",
:continue => "Continue",
:shutdown => "Shutdown",
}
# Command Script Calls #
# This links your command keys to their script call.
# In general, these will be very similar to their key.
# If a script says you can call it by doing this:
# SceneManager.call(Scene_CustomScript)
# You will likely need the 'Scene_CustomScript' part.
# Look at the continue command below for an example.
# Each entry is a pair like this - :command_key => Script_Call
# Separate entries with commas. The order of these entries does NOT
# affect the order in game.
COMMAND_CALLS = {
:new_game => :command_new_game, # special
:continue => Scene_Load,
:shutdown => :command_shutdown, # special
}
# NOTE FOR ADVANCED USERS #
# You'll notice in the above command calls, that new_game and shutdown
# use symbols connected to preexisting method names. This ensures
# all original functionality remains intact. However, this also
# means that should you want to write your own method for a
# command, you can link it to a key by writing the method name as
# a symbol. The script will then treat is as such.
end
end
#==============================================================================
# ** CUSTOMIZATION END
#------------------------------------------------------------------------------
# ** EDIT BELOW THIS LINE AT OWN RISK!!!
#==============================================================================
#==============================================================================
# ** Window_TitleCommand
#==============================================================================
class Window_TitleCommand < Window_Command
#--------------------------------------------------------------------------
# * Configuration Binding
#--------------------------------------------------------------------------
include Mobius::Title_Commands
#--------------------------------------------------------------------------
# * Create Command List
#--------------------------------------------------------------------------
def make_command_list
for cmd in COMMAND_ORDER
cmd_name = COMMAND_NAMES[cmd]
add_command(cmd_name, cmd)
end
end
end
#==============================================================================
# ** Scene_Title
#==============================================================================
class Scene_Title < Scene_Base
#--------------------------------------------------------------------------
# * Configuration Binding
#--------------------------------------------------------------------------
include Mobius::Title_Commands
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
# create window
@command_window = Window_TitleCommand.new
# Add command handlers
for cmd in COMMAND_ORDER
# get command call
cmd_call = COMMAND_CALLS[cmd]
if cmd_call.is_a?(Symbol)
method_symbol = cmd_call
# if command call is a class and not a symbol
elsif cmd_call.is_a?(Class)
# create a new method for the class
method_symbol = create_command_method(cmd_call)
end
# set command handler
@command_window.set_handler(cmd, method(method_symbol))
end
end
#--------------------------------------------------------------------------
# * Create Command Method
#--------------------------------------------------------------------------
def create_command_method(scene_class)
# convert class to canonical symbol
sym = scene_class.name.to_sym
# create method body as proc
block = proc { close_command_window
SceneManager.call(scene_class) }
# Use 'send hack' to call define method since it's private
self.class.send🙂define_method, sym, block)
# return the symbol for reference later
return sym
end
end