- Joined
- Mar 20, 2013
- Messages
- 387
- Reaction score
- 93
- First Language
- English
- Primarily Uses
Mobius's Menu Command Manager 1.5
by
MobiusXVI
Release Notes
v. 1.0 Initial Release
v. 1.5 Support for Common Events
v. 1.6 Fixed bugged paralysis states not working
Introduction
This script allows you to add custom commands to the menu, remove existing commands, and order them however you like!
Features
- Easily add new commands to the menu
- Remove un-needed commands from the menu
- Helps custom scripts come back to the menu correctly
- Add Common Event calls to your menu
How to Use
Copy the script into the script editor below the default scripts but above Main. If you're using other scripts which affect the menu, I recommend placing this script above them in the script editor. Follow the instructions and configuration guidance within the script itself.
Script
Code:
#===============================================================================
# Mobius' Menu Command Manager
# Author: Mobius XVI
# Version: 1.6
# Date: 9 AUG 2017
#===============================================================================
#
# Introduction:
#
# This script allows you to add custom commands to the menu, remove existing
# commands, and order them however you like. The script can also help
# custom commands come back to the menu correctly.
#
# Instructions:
#
# - Place this script below all the default scripts but above main.
# If you're using other scripts which affect the menu, 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 menu system scripts, it
# may be incompatible with other menu system scripts.
#
#
# Credits/Thanks:
# - Mobius XVI, author
# - Zeus81, for his 'Bitmap Export' script which brought the background_sprite
# snapshot functionality to RMXP
#
# License
#
# This script is available in its entirety for commercial and non-commercial
# use. View the specific license terms below.
#
# The portions of this script written by me is licensed under the MIT License:
#
# The MIT License (MIT)
#
# Copyright (c) 2015 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.
#
# Zeus81's script is licensed under CC BY 4.0. View the full license text here:
# http://creativecommons.org/licenses/by/4.0/
# The script is only a portion of the original as I removed those features
# that weren't necessary for this script to function. You can get the full
# script here:
# http://forums.rpgmakerweb.com/index.php?/topic/21633-bitmap-export/
#
#==============================================================================
# ** CUSTOMIZATION START
#==============================================================================
module Mobius
module Menu_Commands
# MENU LOOK OPTIONS #
# These options let you change how the menu looks
# MENU_OPACITY is used to make the menu somewhat transparent so that
# the background can be seen behind it. You can set this to an interger
# value between 0 (completely transparent) and 255 (completely opaque).
MENU_OPACITY = 128
# The BACKGROUND_BLENDING_COLOR is used to darken the background map
# picture so that it is less intrusive. I recommend leaving this as is,
# but if you want to change it, you can set the four numbers to any
# integer values in the range 0-255. The numbers are RGBA.
BACKGROUND_BLENDING_COLOR = Color.new(16, 16, 16, 128)
######################################################################
# COMMAND OPTIONS #
# These options allow you to configure all of the menu 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 = [
:item,
:skill,
:equip,
:status,
:save,
:common_event,
:end_game,
]
# 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 = {
:item => "Item",
:skill => "Skill",
:equip => "Equip",
:status => "Status",
:save => "Save",
:common_event => "Common Event 1",
:end_game => "End Game",
}
# 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:
# $scene = Scene_CustomScript.new
# You will likely need the 'Scene_CustomScript' part.
# You can also use numbers to indicate that you want to call
# a common event. Simply put the ID (as seen in the database) of
# the common event you want to call instead of a script call.
# 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 = {
:item => Scene_Item,
:skill => Scene_Skill,
:equip => Scene_Equip,
:status => Scene_Status,
:save => Scene_Save,
:end_game => Scene_End,
:common_event => 1,
}
# Does Command Need Actor Select? #
# This sets which commands need to select an actor in the menu
# before moving to the next scene. In the default scripts, the
# skills, equip, and status commands need to know which actor
# you want to set before they move to their scenes. It's possible
# some custom commands may need this as well. Just place the
# command keys that need it here. If it doesn't need it, just
# leave it out. The order of these entries does NOT affect
# the order in game.
COMMAND_ACTOR_SELECT = [
:skill,
:equip,
:status,
]
# Disable Command When Party Size Is Zero? #
# This sets which commands should be disabled when the party size
# is zero. In the default scripts, the item, skills, equip, and
# status commands are disabled when this is the case.
# It's possible some custom commands may need this as well.
# Just place the command keys that need it here. If it doesn't
# need it, just leave it out. The order of these entries
# does NOT affect the order in game.
COMMAND_ACTOR_REQUIRED = [
:item,
:skill,
:equip,
:status,
]
# Disable Actor Abilities when paralyzed ? #
# This sets which commands should be disabled when an actor is 'paralyzed'
# (or has a similar type of state). In the default scripts, the skills
# command is disabled when this is the case.
# It's possible some custom commands may need this as well.
# Just place the command keys that need it here. If it doesn't
# need it, just leave it out. The order of these entries
# does NOT affect the order in game.
COMMAND_ACTOR_ABILITIES = [
:skill
]
# Save Command Key Is? #
# This sets which command key is the 'save' command key, so
# that it can be disabled whenever you disable saving via events.
# In general, you can leave the default save key alone in the
# above options and therefore leave this one alone too.
SAVE_COMMAND = :save
end
end
#==============================================================================
# ** CUSTOMIZATION END
#------------------------------------------------------------------------------
# ** EDIT BELOW THIS LINE AT OWN RISK!!!
#==============================================================================
#==============================================================================
# ** Scene_Base
#==============================================================================
class Scene_Base
#--------------------------------------------------------------------------
# * Play Decision SE
#--------------------------------------------------------------------------
def play_decision_se
$game_system.se_play($data_system.decision_se)
end
#--------------------------------------------------------------------------
# * Play Cancel SE
#--------------------------------------------------------------------------
def play_cancel_se
$game_system.se_play($data_system.cancel_se)
end
#--------------------------------------------------------------------------
# * Play Buzzer SE
#--------------------------------------------------------------------------
def play_buzzer_se
$game_system.se_play($data_system.buzzer_se)
end
end
#==============================================================================
# ** Scene_Menu
#==============================================================================
class Scene_Menu < Scene_Base
#--------------------------------------------------------------------------
# * Configuration Binding
#--------------------------------------------------------------------------
include Mobius::Menu_Commands
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = determine_starting_menu_index(menu_index)
@disabled_commands = []
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Create all windows
create_windows
# Check/Execute disable of party items
disable_on_zero_party?
# Check/Execute disable of saving
disable_save?
# 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
dispose_windows
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@command_window.update
@gold_window.update
@status_window.update
# If command window is active: call update_command
if @command_window.active
update_command
return
end
# If status window is active: call update_status
if @status_window.active
update_status
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
on_exit
return
end
# If C button was pressed
if Input.trigger?(Input::C)
on_command
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
def update_status
# If B button was pressed
if Input.trigger?(Input::B)
on_status_exit
return
end
# If C button was pressed
if Input.trigger?(Input::C)
on_status_command
return
end
end
#--------------------------------------------------------------------------
# * On Exit
#--------------------------------------------------------------------------
def on_exit
# Play cancel SE
play_cancel_se
# Switch to map screen
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# * On Command
#--------------------------------------------------------------------------
def on_command
# Get index and key
index = @command_window.index
key = command_index_to_key(index)
# Exit processing if command is disabled
if command_disabled?(index)
command_fail
else
command_success(key)
end
end
#--------------------------------------------------------------------------
# * Command Success
#--------------------------------------------------------------------------
def command_success(key)
play_decision_se
# If command needs actor selection
if COMMAND_ACTOR_SELECT.include?(key)
# Make status window active
activate_status_window
else
# Switch to new screen
process_command_call(key)
end
end
#--------------------------------------------------------------------------
# * Command Fail
#--------------------------------------------------------------------------
def command_fail
play_buzzer_se
end
#--------------------------------------------------------------------------
# * Activate Status Window
#--------------------------------------------------------------------------
def activate_status_window
@command_window.active = false
@status_window.active = true
@status_window.index = 0
end
#--------------------------------------------------------------------------
# * On Status Exit
#--------------------------------------------------------------------------
def on_status_exit
play_cancel_se
# Make command window active
@command_window.active = true
@status_window.active = false
@status_window.index = -1
end
#--------------------------------------------------------------------------
# * On Status Command
#--------------------------------------------------------------------------
def on_status_command
# Get index and key
index = @command_window.index
key = command_index_to_key(index)
# If this actor's action limit is 2 or more
if actor_unable?(key)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
play_decision_se
# Switch to new screen
process_command_call(key, true)
end
#--------------------------------------------------------------------------
# * Actor Able?
#--------------------------------------------------------------------------
def actor_unable?(key)
# If this command should be disabled when the actor is 'paralyzed'
# and if the actor's action limit is 2 or more (is paralyzed)
(COMMAND_ACTOR_ABILITIES.include?(key)) and
($game_party.actors[@status_window.index].restriction >= 2)
end
#--------------------------------------------------------------------------
# * Process Command Call
#--------------------------------------------------------------------------
def process_command_call(key, status_window = false)
# Get command call
call = COMMAND_CALLS[key]
# If call is a Class, treat as a scene class
if call.is_a?(Class)
# If call was made from the status window, pass in the status window index
if status_window
$scene = call.new(@status_window.index)
else
$scene = call.new
end
# If call is a number, treat as a Common Event ID
elsif call.is_a?(Integer) and call > 0
# Common event call reservation
$game_temp.common_event_id = call
# Switch to map screen
$scene = Scene_Map.new
return
end
end
#--------------------------------------------------------------------------
# * Create Windows
#--------------------------------------------------------------------------
def create_windows
create_command_window
create_status_window
create_gold_window
create_background_sprite
end
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
commands = COMMAND_ORDER.collect { |cmd| COMMAND_NAMES[cmd] }
# Make command window
@command_window = Window_Command.new(160, commands)
@command_window.index = @menu_index
@command_window.opacity = MENU_OPACITY
end
#--------------------------------------------------------------------------
# * Create Status Window
#--------------------------------------------------------------------------
def create_status_window
# Make status window
@status_window = Window_MenuStatus.new
@status_window.x = 160
@status_window.y = 0
@status_window.opacity = MENU_OPACITY
end
#--------------------------------------------------------------------------
# * Create Gold Window
#--------------------------------------------------------------------------
def create_gold_window
# Make gold window
@gold_window = Window_Gold.new
@gold_window.x = 0
@gold_window.y = 416
@gold_window.opacity = MENU_OPACITY
end
#--------------------------------------------------------------------------
# * Create Background Sprite
#--------------------------------------------------------------------------
def create_background_sprite
@background_sprite = Sprite.new
@background_sprite.bitmap = $game_temp.background_sprite
@background_sprite.color = BACKGROUND_BLENDING_COLOR
end
#--------------------------------------------------------------------------
# * Dispose Windows
#--------------------------------------------------------------------------
def dispose_windows
# Dispose of windows
@command_window.dispose
@gold_window.dispose
@status_window.dispose
@background_sprite.dispose
end
#--------------------------------------------------------------------------
# * Disable On Zero Party
#--------------------------------------------------------------------------
def disable_on_zero_party?
# If number of party members is 0
if $game_party.actors.size == 0
# Disable all items in command_actor_required
COMMAND_ACTOR_REQUIRED.each { |cmd_key| disable_command(cmd_key) }
end
end
#--------------------------------------------------------------------------
# * Disable Save?
#--------------------------------------------------------------------------
def disable_save?
# If save is forbidden
if $game_system.save_disabled
# Disable save
save_command_key = SAVE_COMMAND
disable_command(save_command_key)
end
end
#--------------------------------------------------------------------------
# * Disable Command
#--------------------------------------------------------------------------
def disable_command(key)
# Get command index
index = command_key_to_index(key)
# Set text to disabled
@command_window.disable_item(index)
# Add index to disabled commands
@disabled_commands.push(index).uniq!
end
#--------------------------------------------------------------------------
# * Enable Command
#--------------------------------------------------------------------------
def enable_command(key)
# Get comand index
index = command_key_to_index(key)
# Set text to disabled
@command_window.disable_item(index)
# Add index to disabled commands
@disabled_commands.delete(index)
end
#--------------------------------------------------------------------------
# * Command Disabled?
#--------------------------------------------------------------------------
def command_disabled?(index)
return @disabled_commands.include?(index)
end
#--------------------------------------------------------------------------
# * Command Key to Index
#--------------------------------------------------------------------------
def command_key_to_index(key)
return COMMAND_ORDER.index(key)
end
#--------------------------------------------------------------------------
# * Command Index to Key
#--------------------------------------------------------------------------
def command_index_to_key(index)
return COMMAND_ORDER.at(index)
end
#--------------------------------------------------------------------------
# * Determine Starting Menu Index
#--------------------------------------------------------------------------
def determine_starting_menu_index(menu_index)
# Get the previous scene type
last_scene = $scene.class
# Does the previous scene type match one
# of the command calls that we know?
if COMMAND_CALLS.has_value?(last_scene)
# Get the key for that scene type
key = COMMAND_CALLS.index(last_scene)
# Use key to get menu index
return COMMAND_ORDER.index(key)
else
# return whatever was passed/the default value of 0
return menu_index
end
end
=begin
#--------------------------------------------------------------------------
# * Name Error Print -- Informs users of error with class names
#--------------------------------------------------------------------------
def name_error_print(error, key)
message = error.message
message2 = "Please check the script call for command key #{key} in " +
"the configuration section of the Menu Command Manager " +
"(the COMMAND_CALLS section specifically)"
print(message + "\n" + message2)
end
=end
end
#==============================================================================
# ** Game_Temp
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :background_sprite # for saving a snapshot of the game map
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias mobius_initialize initialize
def initialize
mobius_initialize
@background_sprite = nil
end
end
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# * Menu Call
#--------------------------------------------------------------------------
alias mobius_call_menu call_menu
def call_menu
mobius_call_menu
$game_temp.background_sprite = Graphics.snap_to_bitmap
end
end
# Bitmap Export v5.4 for XP, VX and VXace by Zeus81
# Free for commercial use
# Licence : http://creativecommons.org/licenses/by/4.0/
# Contact : zeusex81@gmail.com
# Original script trimmed to just 'Graphics.snap_to_bitmap'
module Graphics
FindWindow = Win32API.new('user32', 'FindWindow' , 'pp' , 'i')
GetDC = Win32API.new('user32', 'GetDC' , 'i' , 'i')
ReleaseDC = Win32API.new('user32', 'ReleaseDC' , 'ii' , 'i')
BitBlt = Win32API.new('gdi32' , 'BitBlt' , 'iiiiiiiii', 'i')
CreateCompatibleBitmap = Win32API.new('gdi32' , 'CreateCompatibleBitmap', 'iii' , 'i')
CreateCompatibleDC = Win32API.new('gdi32' , 'CreateCompatibleDC' , 'i' , 'i')
DeleteDC = Win32API.new('gdi32' , 'DeleteDC' , 'i' , 'i')
DeleteObject = Win32API.new('gdi32' , 'DeleteObject' , 'i' , 'i')
GetDIBits = Win32API.new('gdi32' , 'GetDIBits' , 'iiiiipi' , 'i')
SelectObject = Win32API.new('gdi32' , 'SelectObject' , 'ii' , 'i')
def self.snap_to_bitmap
bitmap = Bitmap.new(width, height)
info = [40,width,height,1,32,0,0,0,0,0,0].pack('LllSSLLllLL')
hDC = GetDC.call(hwnd)
bmp_hDC = CreateCompatibleDC.call(hDC)
bmp_hBM = CreateCompatibleBitmap.call(hDC, width, height)
bmp_obj = SelectObject.call(bmp_hDC, bmp_hBM)
BitBlt.call(bmp_hDC, 0, 0, width, height, hDC, 0, 0, 0xCC0020)
GetDIBits.call(bmp_hDC, bmp_hBM, 0, height, bitmap.last_row_address, info, 0)
SelectObject.call(bmp_hDC, bmp_obj)
DeleteObject.call(bmp_hBM)
DeleteDC.call(bmp_hDC)
ReleaseDC.call(hwnd, hDC)
bitmap
end
class << self
def hwnd() @hwnd ||= FindWindow.call('RGSS Player', nil) end
def width() 640 end unless method_defined?(:width)
def height() 480 end unless method_defined?(:height)
end
end
class Bitmap
RtlMoveMemory = Win32API.new('kernel32', 'RtlMoveMemory', 'ppi', 'i')
def last_row_address
return 0 if disposed?
RtlMoveMemory.call(buf=[0].pack('L'), __id__*2+16, 4)
RtlMoveMemory.call(buf, buf.unpack('L')[0]+8 , 4)
RtlMoveMemory.call(buf, buf.unpack('L')[0]+16, 4)
buf.unpack('L')[0]
end
end
FAQ
Q. Can this do _______?
A. Maybe! Leave a post on the forum, and I might just add the feature if it can't already do it.
Q. My persistent states don't work properly anymore. Help!
A. This was a known bug in previous versions. This was fixed in version 1.6; update to it to fix this problem!
Credits and Thanks
- MobiusXVI, author
- Zeus81, for his 'Bitmap Export' script
License
This script is available in its entirety for commercial and non-commercial use. View the full license terms in the script header.
Last edited: