I am sorry to bother you again modern
but I just put a new script that has an options menu, so they had to replace the menu.It is sweeet, but isn't compatible with this awsome inventory, I was wondering if you could help me make them compatible. I have already made it so that the script can load the inventory or wooden chest. But the problem is whenever I unequip a piece of gear or anything goes into either the inventory of the player or the wooden chest it will have an error that says "Script 'Grid Inventory' line 142: NoMethodError occurred. undefined method 'width' for nil:NilClass". I'm sorry for being a trouble but could you please help me compatiblize the script?
All four parts of the script are:
#===============================================================================
# ** Registry
#-------------------------------------------------------------------------------
# This class reads the windows registry.
#===============================================================================
module Win32
class Registry
module Constants
HKEY_CLASSES_ROOT = 0x80000000
HKEY_CURRENT_USER = 0x80000001
HKEY_LOCAL_MACHINE = 0x80000002
HKEY_USERS = 0x80000003
HKEY_PERFORMANCE_DATA = 0x80000004
HKEY_PERFORMANCE_TEXT = 0x80000050
HKEY_PERFORMANCE_NLSTEXT = 0x80000060
HKEY_CURRENT_CONFIG = 0x80000005
HKEY_DYN_DATA = 0x80000006
REG_NONE = 0
REG_SZ = 1
REG_EXPAND_SZ = 2
REG_BINARY = 3
REG_DWORD = 4
REG_DWORD_LITTLE_ENDIAN = 4
REG_DWORD_BIG_ENDIAN = 5
REG_LINK = 6
REG_MULTI_SZ = 7
REG_RESOURCE_LIST = 8
REG_FULL_RESOURCE_DESCRIPTOR = 9
REG_RESOURCE_REQUIREMENTS_LIST = 10
REG_QWORD = 11
REG_QWORD_LITTLE_ENDIAN = 11
STANDARD_RIGHTS_READ = 0x00020000
STANDARD_RIGHTS_WRITE = 0x00020000
KEY_QUERY_VALUE = 0x0001
KEY_SET_VALUE = 0x0002
KEY_CREATE_SUB_KEY = 0x0004
KEY_ENUMERATE_SUB_KEYS = 0x0008
KEY_NOTIFY = 0x0010
KEY_CREATE_LINK = 0x0020
KEY_READ = STANDARD_RIGHTS_READ |
KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY
KEY_WRITE = STANDARD_RIGHTS_WRITE |
KEY_SET_VALUE | KEY_CREATE_SUB_KEY
KEY_EXECUTE = KEY_READ
KEY_ALL_ACCESS = KEY_READ | KEY_WRITE | KEY_CREATE_LINK
REG_OPTION_RESERVED = 0x0000
REG_OPTION_NON_VOLATILE = 0x0000
REG_OPTION_VOLATILE = 0x0001
REG_OPTION_CREATE_LINK = 0x0002
REG_OPTION_BACKUP_RESTORE = 0x0004
REG_OPTION_OPEN_LINK = 0x0008
REG_LEGAL_OPTION = REG_OPTION_RESERVED |
REG_OPTION_NON_VOLATILE | REG_OPTION_CREATE_LINK |
REG_OPTION_BACKUP_RESTORE | REG_OPTION_OPEN_LINK
REG_CREATED_NEW_KEY = 1
REG_OPENED_EXISTING_KEY = 2
REG_WHOLE_HIVE_VOLATILE = 0x0001
REG_REFRESH_HIVE = 0x0002
REG_NO_LAZY_FLUSH = 0x0004
REG_FORCE_RESTORE = 0x0008
MAX_KEY_LENGTH = 514
MAX_VALUE_LENGTH = 32768
end
include Constants
include Enumerable
class Error < ::StandardError
FormatMessageA=Win32API.new('kernel32.dll','FormatMessageA','LPLLPLP','L')
def initialize(code)
@code = code
msg = "\0" * 1024
len = FormatMessageA.call(0x1200, 0, code, 0, msg, 1024, 0)
super msg[0, len].tr("\r", '').chomp
end
attr_reader :code
end
class PredefinedKey < Registry
def initialize(hkey, keyname)
@hkey = hkey
@parent = nil
@keyname = keyname
@disposition = REG_OPENED_EXISTING_KEY
end
def close
raise Error.new(5)
end
def class
Registry
end
Constants.constants.grep(/^HKEY_/) do |c|
Registry.const_set c, new(Constants.const_get(c), c)
end
end
module API
[
%w/RegOpenKeyExA LPLLP L/,
%w/RegCreateKeyExA LPLLLLPPP L/,
%w/RegEnumValueA LLPPPPPP L/,
%w/RegEnumKeyExA LLPPLLLP L/,
%w/RegQueryValueExA LPLPPP L/,
%w/RegSetValueExA LPLLPL L/,
%w/RegFlushKey L L/,
%w/RegCloseKey L L/,
%w/RegQueryInfoKey LPPPPPPPPPPP L/,
].each do |fn|
const_set fn[0].intern, Win32API.new('advapi32.dll', *fn)
end
module_function
def check(result)
raise Error, result, caller(2) if result != 0
end
def packdw(dw)
[dw].pack('V')
end
def unpackdw(dw)
dw +=
dw.unpack('V')[0]
end
def packqw(qw)
[ qw & 0xFFFFFFFF, qw >> 32 ].pack('VV')
end
def unpackqw(qw)
qw = qw.unpack('VV')
(qw[1] << 32) | qw[0]
end
def OpenKey(hkey, name, opt, desired)
result = packdw(0)
check RegOpenKeyExA.call(hkey, name, opt, desired, result)
unpackdw(result)
end
def CreateKey(hkey, name, opt, desired)
result = packdw(0)
disp = packdw(0)
check RegCreateKeyExA.call(hkey, name, 0, 0, opt, desired,
0, result, disp)
[ unpackdw(result), unpackdw(disp) ]
end
def EnumValue(hkey, index)
name = ' ' * Constants::MAX_KEY_LENGTH
size = packdw(Constants::MAX_KEY_LENGTH)
check RegEnumValueA.call(hkey, index, name, size, 0, 0, 0, 0)
name[0, unpackdw(size)]
end
def EnumKey(hkey, index)
name = ' ' * Constants::MAX_KEY_LENGTH
size = packdw(Constants::MAX_KEY_LENGTH)
wtime = ' ' * 8
check RegEnumKeyExA.call(hkey, index, name, size, 0, 0, 0, wtime)
[ name[0, unpackdw(size)], unpackqw(wtime) ]
end
def QueryValue(hkey, name)
type = packdw(0)
size = packdw(0)
check RegQueryValueExA.call(hkey, name, 0, type, 0, size)
data = ' ' * unpackdw(size)
check RegQueryValueExA.call(hkey, name, 0, type, data, size)
[ unpackdw(type), data[0, unpackdw(size)] ]
end
def SetValue(hkey, name, type, data, size)
check RegSetValueExA.call(hkey, name, 0, type, data, size)
end
def FlushKey(hkey)
check RegFlushKey.call(hkey)
end
def CloseKey(hkey)
check RegCloseKey.call(hkey)
end
def QueryInfoKey(hkey)
subkeys = packdw(0)
maxsubkeylen = packdw(0)
values = packdw(0)
maxvaluenamelen = packdw(0)
maxvaluelen = packdw(0)
secdescs = packdw(0)
wtime = ' ' * 8
check RegQueryInfoKey.call(hkey, 0, 0, 0, subkeys, maxsubkeylen, 0,
values, maxvaluenamelen, maxvaluelen, secdescs, wtime)
[ unpackdw(subkeys), unpackdw(maxsubkeylen), unpackdw(values),
unpackdw(maxvaluenamelen), unpackdw(maxvaluelen),
unpackdw(secdescs), unpackqw(wtime) ]
end
end
def self.expand_environ(str)
str.gsub(/%([^%]+)%/) { ENV[$1] || $& }
end
@@type2name = { }
%w[
REG_NONE REG_SZ REG_EXPAND_SZ REG_BINARY REG_DWORD
REG_DWORD_BIG_ENDIAN REG_LINK REG_MULTI_SZ
REG_RESOURCE_LIST REG_FULL_RESOURCE_DESCRIPTOR
REG_RESOURCE_REQUIREMENTS_LIST REG_QWORD
].each do |type|
@@type2name[Constants.const_get(type)] = type
end
def self.type2name(type)
@@type2name[type] || type.to_s
end
def self.wtime2time(wtime)
Time.at((wtime - 116444736000000000) / 10000000)
end
def self.time2wtime(time)
time.to_i * 10000000 + 116444736000000000
end
private_class_method :new
def self.open(hkey, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)
subkey = subkey.chomp('\\')
newkey = API.OpenKey(hkey.hkey, subkey, opt, desired)
obj = new(newkey, hkey, subkey, REG_OPENED_EXISTING_KEY)
if block_given?
begin
yield obj
ensure
obj.close
end
else
obj
end
end
def self.create(hkey, subkey, desired = KEY_ALL_ACCESS, opt = 0x0000)
newkey, disp = API.CreateKey(hkey.hkey, subkey, opt, desired)
obj = new(newkey, hkey, subkey, disp)
if block_given?
begin
yield obj
ensure
obj.close
end
else
obj
end
end
@@final = proc { |hkey| proc { API.CloseKey(hkey[0]) if hkey[0] } }
def initialize(hkey, parent, keyname, disposition)
@hkey = hkey
@parent = parent
@keyname = keyname
@disposition = disposition
@hkeyfinal = [ hkey ]
ObjectSpace.define_finalizer self, @@final.call(@hkeyfinal)
end
attr_reader :hkey, :parent, :keyname, :disposition
def created?
@disposition == REG_CREATED_NEW_KEY
end
def open?
!@hkey.nil?
end
def name
parent = self
name = @keyname
while parent = parent.parent
name = parent.keyname + '\\' + name
end
name
end
def inspect
"\#<Win32::Registry key=#{name.inspect}>"
end
def _dump(depth)
raise TypeError, "can't dump Win32::Registry"
end
def open(subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED, &blk)
self.class.open(self, subkey, desired, opt, &blk)
end
def create(subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED, &blk)
self.class.create(self, subkey, desired, opt, &blk)
end
def close
API.CloseKey(@hkey)
@hkey = @parent = @keyname = nil
@hkeyfinal[0] = nil
end
def each_value
index = 0
while true
begin
subkey = API.EnumValue(@hkey, index)
rescue Error
break
end
begin
type, data = read(subkey)
rescue Error
next
end
yield subkey, type, data
index += 1
end
index
end
alias each each_value
def each_key
index = 0
while true
begin
subkey, wtime = API.EnumKey(@hkey, index)
rescue Error
break
end
yield subkey, wtime
index += 1
end
index
end
def keys
keys_ary = []
each_key { |key,| keys_ary << key }
keys_ary
end
def read(name, *rtype)
type, data = API.QueryValue(@hkey, name)
unless rtype.empty? or rtype.include?(type)
string = "Type mismatch (expect #{rtype.inspect} but #{type} present)"
raise TypeError, string
end
case type
when REG_SZ, REG_EXPAND_SZ
[ type, data.chop ]
when REG_MULTI_SZ
[ type, data.split(/\0/) ]
when REG_BINARY
[ type, data ]
when REG_DWORD
[ type, API.unpackdw(data) ]
when REG_DWORD_BIG_ENDIAN
[ type, data.unpack('N')[0] ]
when REG_QWORD
[ type, API.unpackqw(data) ]
else
raise TypeError, "Type #{type} is not supported."
end
end
def [](name, *rtype)
type, data = read(name, *rtype)
case type
when REG_SZ, REG_DWORD, REG_QWORD, REG_MULTI_SZ
data
when REG_EXPAND_SZ
Registry.expand_environ(data)
else
raise TypeError, "Type #{type} is not supported."
end
end
def read_s(name)
read(name, REG_SZ)[1]
end
def read_s_expand(name)
type, data = read(name, REG_SZ, REG_EXPAND_SZ)
if type == REG_EXPAND_SZ
Registry.expand_environ(data)
else
data
end
end
def read_i(name)
read(name, REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD)[1]
end
def read_bin(name)
read(name, REG_BINARY)[1]
end
def write(name, type, data)
case type
when REG_SZ, REG_EXPAND_SZ
data = data.to_s + "\0"
when REG_MULTI_SZ
data = data.to_a.join("\0") + "\0\0"
when REG_BINARY
data = data.to_s
when REG_DWORD
data = API.packdw(data.to_i)
when REG_DWORD_BIG_ENDIAN
data = [data.to_i].pack('N')
when REG_QWORD
data = API.packqw(data.to_i)
else
raise TypeError, "Unsupported type #{type}"
end
API.SetValue(@hkey, name, type, data, data.length)
end
def []=(name, rtype, value = nil)
if value
write name, rtype, value
else
case value = rtype
when Integer
write name, REG_DWORD, value
when String
write name, REG_SZ, value
when Array
write name, REG_MULTI_SZ, value
else
raise TypeError, "Unexpected type #{value.class}"
end
end
value
end
def write_s(name, value)
write name, REG_SZ, value.to_s
end
def write_i(name, value)
write name, REG_DWORD, value.to_i
end
def write_bin(name, value)
write name, REG_BINARY, value.to_s
end
def flush
API.FlushKey @hkey
end
def info
API.QueryInfoKey(@hkey)
end
%w[
num_keys max_key_length
num_values max_value_name_length max_value_length
descriptor_length wtime
].each_with_index do |s, i|
eval <<-__END__
def #{s}
info[#{i}]
end
__END__
end
end
end
=begin -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Aleworks Options Menu(AO)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Created by: Aleworks
Version: 2.50
Date: 26/12/06
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
History of the version:
-1.00
First version
-2.00
Better code
New interface
More options
-2.10
Font changing improved
Game speed bug fixed
Autosaving bug fixed
Lag reduction
-2.50
Font changing improved
Autosaving improved
Windowskin change bug fixed
Scene_Options improved
New options: Font Color, Font Brightness, Font Opacity, Windowskin Color,
Brightness, Battle Animations, Difficulty
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
*** How to use ***
- For call the menu use:
$scene = Scene_AOptions.new($scene)
- For edit the initial options and the menu options see ** Editable options **
and ** Types of options **
- For refer to AOptions use: $ao
- For edit the values of AO, while playing the game, use:
$ao.something
something can be a method or a variable
For a list of the editable variables see the attr_accessors down the AOptions.
- For add a new option, see in the script, there are the instructions.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
*** AO RGSS Classes and Modules definitions edits ***
*** Color ***
replace: initialize
*** Font ***
alias: initialize; alias name: aleworks_optionsmenu_font_initialize
*** RPG::Cache ***
replace: self.windowskin
*** Win32::Registry ***
add: value_time_index
*** Game_Enemy ***
replace: base_maxhp
replace: base_maxsp
replace: base_str
replace: base_dex
replace: base_agi
replace: base_int
replace: base_atk
replace: base_pdef
replace: base_mdef
replace: base_eva
*** Game_System ***
replace: bgm_play
replace: bgs_play
replace: me_play
replace: se_play
*** Sprite_Battler ***
replace: update
*** Window_Base ***
alias: normal_color, alias name: aleworks_optionsmenu_window_base_normal_color
replace: initialize
replace: dispose
replace: update
add: hue_to_color
*** Window_SaveFile ***
replace: initialize
replace: refresh
*** Scene_Title ***
replace: main
*** Scene_Map ***
alias: update; alias name: aleworks_optionsmenu_scene_map_update
alias: transfer_player; alias name: aleworks_optionsmenu_scene_map_transfer
*** Scene_Load ***
alias: on_decision; alias name: aleworks_optionsmenu_load_on_decision
*** Scene_File ***
replace: main
replace: update
replace: make_filename
add: make_name
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=end
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# *** AO class ***
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
class AOptions
attr_accessor :options
attr_accessor :font_size_range
attr_accessor :audio_volume_range
attr_accessor :audio_speed_range
attr_accessor :game_speed_range
attr_accessor :opacity_range
attr_accessor :color_range
attr_accessor :brightness_range
attr_accessor :fonts
attr_accessor :font_name
attr_accessor :font_size
attr_accessor :font_color
attr_accessor :font_brightness
attr_accessor :font_opacity
attr_accessor :winskin
attr_accessor :windowskin_color
attr_accessor :window_opacity
attr_accessor :winskin_rtp
attr_accessor :brightness
attr_accessor :brightness_class
attr_accessor :bgm_volume
attr_accessor :bgs_volume
attr_accessor :me_volume
attr_accessor :se_volume
attr_accessor :bgm_speed
attr_accessor :bgs_speed
attr_accessor :me_speed
attr_accessor :se_speed
attr_accessor :game_speed
attr_accessor :auto_save
attr_accessor :auto_save_count
attr_accessor :auto_save_file
attr_accessor :auto_save_status
attr_accessor :window_autosave
attr_accessor :window_autosave_timer
attr_accessor :battle_animations
attr_accessor :difficulty
attr_accessor :difficulty_values
attr_accessor :difficulty_names
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ** AO initilize **
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def initialize
$data_system = load_data('Data/System.rxdata')
@options = []
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ** Editable options **
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# * Menu groups options *
# @options
# - @options
- , where # determinates the number of the group of options
# - A is the name of the group of options
# - [B,C] is a option of the group of options
# - B is the name of the option
# - C is the type of option (See Type of options for more info)
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@options[0] = ['Visual', [ ['Font', 0],
['Letters Size', 1],
['Letters Color', 10],
['Letters Brightness', 11],
['Letters Opacity', 12],
['Windowskin', 2],
['Windowskin Color', 13],
['Window Opacity', 3],
['Brightness', 14]
] ]
@options[1] = ['Audio', [ ['Music volume', 4],
['Sound volume', 5],
['Music Speed', 6],
['Sound speed', 7]
] ]
@options[2] = ['Game', [ ['Game speed', 9],
['Autosave', 8],
['Battle Animations', 15],
['Difficulty', 16]
] ]
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# If it is true AO, will include the 001-Blue01.png skin of the Standart RTP
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@winskin_rtp = true
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# * Selectable fonts *
# You have to put the names of the selectable fonts here.
# If you want that all font be selectable, put:
# @fonts = fonts_entries
# If you want to specify the fonts put an Array. It may be like this:
# @fonts = ['Comic Sans MS', 'Lucida Sans', 'Times New Roman']
# ~~~~~ Warning ~~~~~~
# If you use 'fonts_entries', some fonts maybe dont work well, and in some
# systems, maybe the script cant read the fonts.
# Tested only in Window XP.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@fonts = ['Comic Sans MS', 'Lucida Sans', 'Times New Roman']
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# * Selectable Ranges => [Min,Max] *
# ~~~~~ Warning ~~~~~~
# It may throw errors, if the ranges are out of the max. and min.
# All the defaults ranges will not throw errors.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@font_size_range = [6, 36] # Letter Size Min = 6 Max = 96
@audio_volume_range = [0, 150] # Audio Volume(in %) Min = 0 Max = 150
@audio_speed_range = [1, 500] # Audio Speed(in %) Min = 0 Max = ?
@game_speed_range = [10, 120] # Game Speed(in frames) Min = 10 Max = 120
@opacity_range = [0, 100] # Opacity Min = 0 Max = 100
@color_range = [-1, 360] # Hue color Min = 0 Max = 360
@brightness_range = [-255, 255] # Brightness Min = -255 Max = 255
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# * Auto save options *
# There are two types of autosaving, one that save after some time and one
# that save after somes changes of maps.
# For the first form, use:
# @auto_save = ['map', #]
# - Where # is the number of map changes for save.
# For the second form, use:
# @auto_save = ['time', #]
# - Where # is the number of seconds that need to pass for save.
# You can put too, any other thing like nil, and call the autosave when
# you want.
# It may be like:
# @auto_save = [nil, 0]
# And dor call autosave:
# $ao.autosave
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@auto_save = ['map', 2]
@auto_save_file = 'Autosave.rxdata' # Name of thme autosave file.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# * Dificulty options *
# @difficulty_values
# This values are the percentage of the atributes of the enemies.
# @difficulty_names
# This are the names of the corresponding percentages of @difficulty_values
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@difficulty_values = [60, 85, 100, 115, 130, 200]
@difficulty_names = ['Very Easy', 'Easy', 'Normal', 'Hard', 'Hardest',
'Imposible']
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# * Initials values of the options *
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@font_name = "Lucida Console" # Font name
@font_size = 22 # Size of the letters
@font_color = -1 # Color of the Window_Base normal_color (-1 = Normal Color)
@font_brightness = 0 # Brightness of the letters
@font_opacity = 100 # Opacity of the letters
@winskin = $data_system.windowskin_name # Windowskin
@window_opacity = 100 # Opacity of windows
@windowskin_color = -1 # Color of the windows (-1 = Normal Color)
@brightness = 0 # Brightness of all sprites
@bgm_volume = 80 # Volume of BGM
@bgs_volume = 100 # Volume of BGS
@me_volume = 80 # Volume of ME
@se_volume = 100 # Volume of SE
@bgm_speed = 100 # Speed of BGM
@bgs_speed = 100 # Speed of BGS
@me_speed = 100 # Speed of ME
@se_speed = 100 # Speed of SE
@auto_save_status = false # The status of the autosave
@game_speed = 40 # Speed of the game(Frames)
@battle_animations = true # Animations of Battle
@difficulty = 100 # Difficulty of the game
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ** Internal variables **
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$defaultfonttype = $fontface = $fontname=Font.default_name = @font_name
$defaultfontsize = $fontsize = Font.default_size = @font_size
@brightness_class = Brightness.new(@brightness)
@auto_save_count = @auto_save[1]
@window_autosave = nil
@window_autosave_timer = 0
end
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ** Types of options **
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# For easy editing, the AO options are divided by types. You can edit, add
# or remove types for your own options.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def win_options(e)
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# * Types values *
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Here you can edit the value that each type of option shows.
# options.push([i[0],A])
#
# You only need to edit A, options.push and i[0], have to be ever the same
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
options = []
for i in e
case i[1]
when 0 # Type 0 (Font)
options.push([i[0], @font_name])
when 1 # Type 1 (Size of letters)
options.push([i[0], @font_size])
when 2 # Type 2 (Windoskin)
options.push([i[0], @winskin])
when 3 # Type 3 (Opacity of windows)
options.push([i[0], "#{@window_opacity} %"])
when 4 # Type 4 (BGM & ME volume)
options.push([i[0], "#{@bgm_volume} %"])
when 5 # Type 5 (BGS & SE volume)
options.push([i[0], "#{@bgs_volume} %"])
when 6 # Type 6 (BGM & ME speed)
options.push([i[0], "#{@bgm_speed} %"])
when 7 # Type 7 (BGS & SE speed)
options.push([i[0], "#{@bgs_speed} %"])
when 8 # Type 8 (Autosave)
if @auto_save_status
a = 'ON'
else
a = 'OFF'
end
options.push([i[0], a])
when 9 # Type 9 (Game speed)
options.push([i[0], @game_speed])
when 10 # Type 10 (Font Color)
a = @font_color
a = 'Normal' if @font_color == -1
options.push([i[0], a])
when 11 # Type 11 (Font Brightness)
a = "- #{@font_brightness.abs}" if @font_brightness < 0
a = 'Normal' if @font_brightness == 0
a = "+ #{@font_brightness}" if @font_brightness > 0
options.push([i[0], a])
when 12 # Type 12 (Font Opacity)
options.push([i[0], "#{@font_opacity} %"])
when 13 # Type 13 (Windowskin Color)
a = @windowskin_color
a = 'Normal' if @windowskin_color == -1
options.push([i[0], a])
when 14 # Type 14 (Brightness)
a = '- #{@brightness.abs}' if @brightness < 0
a = 'Normal' if @brightness == 0
a = '+ #{@brightness}' if @brightness > 0
options.push([i[0], @brightness])
when 15 # Type 15 (Battle Animations)
if @battle_animations
a = 'ON'
else
a = 'OFF'
end
options.push([i[0], a])
when 16 # Type 16 (Game Difficulty)
a = @difficulty_names[@difficulty_values.index(@difficulty)]
options.push([i[0], a])
end
end
return options
end
def command_options(index, index_com, type)
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# * Types effect *
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Here you can edit what each type will do when the player change it.
# - If your option is a switch, you can put:
# if @switch
# @switch = false
# else
# @switch = true
# end
# - If your option is a range of numbers
# @variable = range(@variable, [min, max], type)
# For more info see range
# - If your option has differents strings values, like the font type, use:
# if @option_value == nil or Arraywithstrings.include?(@option_value) == false
# @font_name = Arraywithstrings[0]
# return
# end
# if type == -1
# if @option_value == Arraywithstrings[0]
# @option_value = Arraywithstrings[Arraywithstrings.size - 1]
# else
# @option_value = Arraywithstrings[Arraywithstrings.index(@option_value) - 1]
# end
# elsif type == 1
# if @option_value == Arraywithstrings[Arraywithstrings.size - 1]
# @option_value = Arraywithstrings[0]
# else
# @option_value = Arraywithstrings[Arraywithstrings.index(@option_value) + 1]
# end
# end
# - If your option need to refresh the options group window use:
# $scene.command_left.refresh
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
case @options[index][1][index_com][1]
when 0 # Type 0 (Font)
return nil if type < -1 and type > 1 or type == 0
if @font_name == nil or @fonts.include?(@font_name) == false
@font_name = @fonts[0]
return
end
if type == -1
if @font_name == @fonts[0]
@font_name = @fonts[@fonts.size - 1]
else
@font_name = @fonts[@fonts.index(@font_name) - 1]
end
elsif type == 1
if @font_name == @fonts[@fonts.size - 1]
@font_name = @fonts[0]
else
@font_name = @fonts[@fonts.index(@font_name) + 1]
end
end
$defaultfonttype = $fontface = $fontname=Font.default_name = @font_name
$scene.command_left_refresh
when 1 # Type 1 (Size of letters)
return nil if type == 0
@font_size = range(@font_size, @font_size_range, type)
$defaultfontsize = $fontsize = Font.default_size = @font_size
$scene.command_left_refresh
when 2 # Type 2 (Windoskin)
return nil if type < -1 and type > 1 or type == 0
w = ws_entries
w.push('001-Blue01') if @winskin_rtp == true
winskin=@winskin
if ws_entries.size == 0
@winskin = winskin
return
end
if type == -1 and w.size >= 1
if @winskin == nil or w.include?(@winskin) == false or @winskin == w[0]
winskin = w[w.size - 1] unless w[w.size - 1] == nil
elsif w[w.index(@winskin)-1] != nil
winskin = w[w.index(@winskin) - 1]
end
elsif type == 1 and w.size >= 1
if @winskin == nil or w.include?(@winskin) == false or
@winskin == w[w.size - 1]
winskin=w[0] unless w[0] == nil
elsif w[w.index(@winskin) + 1] != nil
winskin=w[w.index(@winskin) + 1]
end
end
@winskin = winskin
when 3 # Type 3 (Opacity of windows)
return nil if type == 0
@window_opacity = range(@window_opacity, @opacity_range, type)
$scene.command_left_refresh
when 4 # Type 4 (BGM & ME volume)
return nil if type == 0
@bgm_volume = range(@bgm_volume, @audio_volume_range, type)
@me_volume = range(@me_volume, @audio_volume_range, type)
$game_system.bgm_memorize
$game_system.bgm_restore
when 5 # Type 5 (BGS & SE volume)
return nil if type == 0
@bgs_volume = range(@bgs_volume, @audio_volume_range, type)
@se_volume = range(@se_volume, @audio_volume_range, type)
$game_system.bgs_memorize
$game_system.bgs_restore
when 6 # Type 6 (BGM & ME speed)
return nil if type == 0
@bgm_speed = range(@bgm_speed, @audio_speed_range, type)
@me_speed = range(@me_speed, @audio_speed_range, type)
$game_system.bgm_memorize
$game_system.bgm_restore
when 7 # Type 7 (BGS & SE speed)
return nil if type == 0
@bgs_speed = range(@bgs_speed, @audio_speed_range, type)
@se_speed = range(@se_speed, @audio_speed_range, type)
$game_system.bgs_memorize
$game_system.bgs_restore
when 8 # Type 8 (Autosave)
return nil if type != 0
if @auto_save_status
@auto_save_status = false
else
@auto_save_status = true
end
when 9 # Type 9 (Game speed)
return nil if type == 0
@game_speed = range(@game_speed , @game_speed_range, type)
Graphics.frame_rate = @game_speed
when 10 # Type 10 (Font Color)
return nil if type == 0
@font_color = range(@font_color , @color_range, type)
$scene.command_left_refresh
when 11 # Type 11 (Font Brightness)
return nil if type == 0
@font_brightness = range(@font_brightness , @brightness_range, type)
$scene.command_left_refresh
when 12 # Type 12 (Font Opacity)
return nil if type == 0
@font_opacity = range(@font_opacity , @opacity_range, type)
$scene.command_left_refresh
when 13 # Type 13 (Windowskin Color)
return nil if type == 0
@windowskin_color = range(@windowskin_color , @color_range, type)
when 14 # Type 14 (Brightness)
return nil if type == 0
@brightness = range(@brightness , @brightness_range, type)
@brightness_class.refresh
when 15 # Type 15 (Battle Animations)
return nil if type != 0
if @battle_animations
@battle_animations = false
else
@battle_animations = true
end
when 16 # Type 16 (Game Difficulty)
return nil if type < -1 and type > 1 or type == 0
d = @difficulty_values
difficulty = @difficulty
if d.size == 0
@difficulty = difficulty
return
end
if type == -1 and d.size >= 1
if @difficulty == d[0]
difficulty = d[d.size - 1] unless d[d.size - 1] == nil
elsif d[d.index(@difficulty)-1] != nil
difficulty = d[d.index(@difficulty) - 1]
end
elsif type == 1 and d.size >= 1
if @difficulty == nil or d.include?(@difficulty) == false or
@difficulty == d[d.size - 1]
difficulty = d[0] unless d[0] == nil
elsif d[d.index(@difficulty) + 1] != nil
difficulty = d[d.index(@difficulty) + 1]
end
end
@difficulty = difficulty
end
return true
end
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ** Range **
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# range(value,range,cant)
# - value is the actual value of the variable
# - range is the min and the max value of the range
# - cant is the cant that will be modified. The AO menu, use for the right
# and left arrowkey +1 and -1, and for the R and L buttons, +10 and -10.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def range(value, range, cant)
value += cant
if cant < -1 and value < range[0] and value != range[0] + cant
value = range[0]
elsif cant > 1 and value > range[1] and value != range[1] + cant
value = range[1]
elsif value < range[0]
value = range[1]
elsif value > range[1]
value = range[0]
end
return value
end
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ** Windowskin entries **
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Return the name of all the windowskins
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def ws_entries
skin = Dir.entries('Graphics/Windowskins')
skin.delete_at(0)
skin.delete_at(0)
skin.sort!
c = 0
for i in 0..skin.size - 1
n=File.extname(skin[i - c])
if n != '.bmp' and n != '.png' and n != '.jpg' and n != '.jpge' and
n != '.jif'
skin.delete_at(i - c)
c += 1
end
end
for i in 0..skin.size - 1
size = File.extname(skin
).size
skin.slice!(skin.size - size, size)
end
return skin
end
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ** Autosave **
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def load_game(file)
if @auto_save[0] == 'map' or @auto_save[0] == 'time'
@auto_save_count = @auto_save[1]
end
@auto_save_count *= @game_speed if @auto_save[0] == 'time'
end
def autosave
return if @auto_save_file == nil
@auto_save_count = @auto_save[1]
@auto_save_count *= @game_speed if @auto_save[0] == 'time'
scene = $scene
a = Scene_Save.new
file = File.open(@auto_save_file, 'wb')
a.write_save_data(file)
file.close
$scene = scene
@window_autosave = Window_Help.new
@window_autosave.x = 505
@window_autosave.y = -16
@window_autosave.width = 160
@window_autosave.height = 64
@window_autosave.opacity = 0
@window_autosave.back_opacity = 0
@window_autosave.set_text('Autosaving')
@window_autosave_timer = @game_speed * 2.5
end
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# ** Fonts entries **
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Return the name of all fonts
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def fonts_entries
fonts = []
dir = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts'
Win32::Registry::HKEY_LOCAL_MACHINE.open(dir) do |reg|
entries_count = reg.each_value { | | }
for index in 0..entries_count-1
fonts.push(reg.value_time_index(index))
end
end
c=0
for i in 0..fonts.size-1
n = fonts.scan(/ (TrueType)/)
if n == nil
fonts.delete_at(i - c)
c += 1
end
end
for i in 0..fonts.size - 1
fonts.slice!(fonts.size - 11,11)
end
return fonts.sort
end
end
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# *** Load/Save options data ***
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
module AO
def AO.load
file=File.open('Options.rxdata', 'rb')
$ao = Marshal.load(file)
file.close
Graphics.frame_rate = $ao.game_speed
$defaultfonttype = $fontface = $fontname = Font.default_name = $ao.font_name
$defaultfontsize = $fontsize = Font.default_size = $ao.font_size
$ao.brightness_class = Brightness.new($ao.brightness)
end
def AO.save
$ao.brightness_class.dispose
$ao.brightness_class = nil
file = File.open('Options.rxdata', 'wb')
Marshal.dump($ao, file)
file.close
$ao.brightness_class = Brightness.new($ao.brightness)
end
end
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# *** Menu of Options ***
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
class Scene_AOptions
attr_accessor :command_left
attr_accessor :index
attr_accessor :scene
def initialize(scene)
@scene = scene
end
def main
o = []
for i in $ao.options
o.push(i[0])
end
@command_left = Window_Command.new(140, o)
@command_left.width = 140
@command_left.height = o.size * 32 + 32
@command_left.x = 0
@command_left.y = 0
@index = 0
@window_right = Window_AOptions.new
options = $ao.win_options($ao.options[@command_left.index][1])
@window_right.refresh(options, @index)
@window_right.cursor_rect.set(0, -32, 16, 16)
Graphics.transition
while $scene == self
Graphics.update
Input.update
update_left if @command_left.active
update_right if @command_left.active == false
end
Graphics.freeze
AO.save
@command_left.dispose
@window_right.dispose
end
def update_left
@command_left.update
options = $ao.win_options($ao.options[@command_left.index][1])
@window_right.refresh(options, @index)
@window_right.cursor_rect.set(0, -32, 16, 16)
if Input.trigger?(Input::C)
@command_left.active = false
$game_system.se_play($data_system.decision_se)
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = @scene
end
end
def update_right
@window_right.update
@command_left.update
options_size = $ao.options[@command_left.index][1].size - 1
if Input.trigger?(Input::C)
sound = $ao.command_options(@command_left.index, @index, 0)
$game_system.se_play($data_system.decision_se) if sound == true
options = $ao.win_options($ao.options[@command_left.index][1])
@window_right.refresh(options, @index)
return
end
if Input.repeat?(Input::UP)
if Input.trigger?(Input::UP) or @index > 0
$game_system.se_play($data_system.cursor_se)
if @index == 0
@index = options_size
else
@index -= 1
end
options = $ao.win_options($ao.options[@comman