Code:
class Window_Command < Window_Selectable
#--------------------------------------------------------------------------
# This is all the data for the Menu Bar
#--------------------------------------------------------------------------
def initialize(width, commands)
# This makes the window size, font used and font size
super(0, 65, width, commands.size * 32 + 32)
@item_max = commands.size
@commands = commands
self.contents = Bitmap.new(width - 32, @item_max * 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# This refreshes the command so whenever you see the word refresh it refers back to this point
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
#--------------------------------------------------------------------------
# This sorts out the colour of the font, widths and heights
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index])
end
#--------------------------------------------------------------------------
# If commands are disabled it will change to the disabled colour
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end
#--------------------------------------------------------------------
class Window_Command2 < Window_Selectable
#--------------------------------------------------------------------------
# These are all the same as Window_Command
#--------------------------------------------------------------------------
def initialize(width, commands)
super(220, 180, width, commands.size * 32 + 32)
@item_max = commands.size
@commands = commands
self.contents = Bitmap.new(width - 32, @item_max * 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
refresh
self.index = 0
end
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index])
end
def disable_item(index)
draw_item(index, disabled_color)
end
end
#----------------------------------------------------------
class Scene_PreMenu
#--------------------------------------------------------------------------
# â—? Developed By ChronoCry/Scaboon
#--------------------------------------------------------------------------
def initialize(premenu_index = 0)
@premenu_index = premenu_index
end
#--------------------------------------------------------------------------
# This script makes a multichoice menu appear when you press ESC
#--------------------------------------------------------------------------
def main
# These are the choices that appear on the menu
s1 = "Data Menu"
s2 = "Save Menu"
s3 = "Quit"
@spriteset = Spriteset_Map.new
@command_window = Window_Command2.new(160, [s1, s2, s3])
@command_window.index = @premenu_index
if $game_party.actors.size == 0
# If no-one is in party
@command_window.disable_item(0)
@command_window.disable_item(1)
end
# If saves disabled
if $game_system.save_disabled
# Disables Save Menu command
@command_window.disable_item(1)
end
# This sorts out the transition of the menu
Graphics.transition
loop do
# This updates it if its changed whiles in game
Graphics.update
Input.update
update
if $scene != self
break
end
end
# This actually displays it properly
Graphics.freeze
@command_window.dispose
end
#--------------------------------------------------------------------------
# This updates all the windows if something changes
#--------------------------------------------------------------------------
def update
@command_window.update
if @command_window.active
update_command
return
end
if @status_window.active
update_status
return
end
end
#--------------------------------------------------------------------------
# This sorts what happens when you press certain buttons
#--------------------------------------------------------------------------
def update_command
# This means if you press a cancel button whiles on the menu it takes you back to the map screen
if Input.trigger?(Input::B)
# This goes all the way back to your database and whatever you put for cancel sound will be played
$game_system.se_play($data_system.cancel_se)
# Goes to the map screen
$scene = Scene_Map.new
return
end
# If a accept button is pressed
if Input.trigger?(Input::C)
# If no one is in your party the cursor wil go to the bottom option
if $game_party.actors.size == 0 and @command_window.index < 2
# The sound effect played when some options are not available
$game_system.se_play($data_system.buzzer_se)
return
end
# These call up the scenes of the choices when chosen
case @command_window.index
when 0 # This is the S1 command
# The sound effect played when chosen
$game_system.se_play($data_system.decision_se)
# Goes to the menu screen when chosen
$scene = Scene_Menu.new
when 1 # This is the S2 command
if $game_system.save_disabled
# The sound effect played when chosen
$game_system.se_play($data_system.buzzer_se)
return
end
#The sound effect played when chosen
$game_system.se_play($data_system.decision_se)
# Goes to the save screen when chosen
$scene = Scene_Save.new
when 2 # This is the S3 command
# The sound effect played when chosen
$game_system.se_play($data_system.decision_se)
# Goes to the end game screen when chosen
$scene = Scene_End.new
end
return
end
end
#--------------------------------------------------------------------------
# This updates the status of everything
#--------------------------------------------------------------------------
def update_status
# If a cancel button is pressed
if Input.trigger?(Input::B)
# The sound effect played when chosen
$game_system.se_play($data_system.cancel_se)
# This makes the command menu active
@command_window.active = true
return
end
end
end
class Scene_Menu
#--------------------------------------------------------------------------
# This is the main boring menu lol all i have done is add a title thing
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# The main setting of the script
#--------------------------------------------------------------------------
def main
# These are the commands that appear on the menu bar
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = "Status"
@command_window = Window_Command.new(160, [s1, s2, s3, s4])
@command_window.index = @menu_index
# If there is no characters no of these command become available
if $game_party.actors.size == 0
# This disables them all if no characters
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
# This sorts out the placing of the menu title
@menutitle_window = Window_MenuTitle.new
@menutitle_window.x = 0
@menutitle_window.y = 0
# This sorts out the placing of the playtime window
@playtime_window = Window_PlayTime.new
@playtime_window.x = 0
@playtime_window.y = 224
# This sorts out the placing of the steps window
@steps_window = Window_Steps.new
@steps_window.x = 0
@steps_window.y = 320
# This sorts out the placing of the gold window
@gold_window = Window_Gold.new
@gold_window.x = 0
@gold_window.y = 416
# This sorts out the placing of the menu status window
@status_window = Window_MenuStatus.new
@status_window.x = 160
@status_window.y = 0
# If you read earlier you'll know what this does
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
# This makes the windows dissapear when closed
@command_window.dispose
@menutitle_window.dispose
@playtime_window.dispose
@steps_window.dispose
@gold_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
# This updates the windows if there are any changes
#--------------------------------------------------------------------------
def update
# Updates the windows
@command_window.update
@menutitle_window.update
@playtime_window.update
@steps_window.update
@gold_window.update
@status_window.update
# Updates the command window
if @command_window.active
update_command
return
end
# Updates the status window
if @status_window.active
update_status
return
end
end
#--------------------------------------------------------------------------
# If you read above you'll know what this whole thing does and that is it updates the commands if anything is changed
#--------------------------------------------------------------------------
def update_command
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
if $game_party.actors.size == 0 and @command_window.index < 4
$game_system.se_play($data_system.buzzer_se)
return
end
# This sorts out what happens when the selection is chosen
case @command_window.index
when 0 # This opens up the Item Menu
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item.new
when 1 # This sorts out what happens when the skill command is chosen but does not open up the window (ill explain later)
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # This does the same thing but for equip
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # And this does the same thing yet again but for status
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
end
return
end
end
#--------------------------------------------------------------------------
# This updates the menu status as i have already said
#--------------------------------------------------------------------------
def update_status
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
if Input.trigger?(Input::C)
case @command_window.index
when 1 # This part actually opens the skill menu so that explains what i said above
# This sorts out players data for the skill menu opening
if $game_party.actors[@status_window.index].restriction >= 2
# The chosen sound effect
$game_system.se_play($data_system.buzzer_se)
return
end
# Chosen sound effect
$game_system.se_play($data_system.decision_se)
# Opens the actual skill menu
$scene = Scene_Skill.new(@status_window.index)
when 2 # This opens up the equip menu
# A chosen sound effect
$game_system.se_play($data_system.decision_se)
$scene = Scene_Equip.new(@status_window.index)
when 3 # Opens status menu
# A chosen sound effect
$game_system.se_play($data_system.decision_se)
$scene = Scene_Status.new(@status_window.index)
end
return
end
end
end
class Window_MenuTitle < Window_Base
#--------------------------------------------------------------------------
# This script makes a window appear at top displaying the title
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 65) # This defines the size of the window (x, y, width, height)
self.contents = Bitmap.new(width-32, height-32) # This enables you to display the text on the window
self.contents.font.name = $fontface # Refers to normal font type
self.contents.font.size = $fontsize # Refers to normal font size
self.contents.draw_text(0, 0, 640, 30, "Title") # Change the title to what ever you want
end
end
# End of the coding
class Scene_Map
#--------------------------------------------------------------------------
# This is the same as the normal Scene_Map script from a new project but i have changed one thing
#--------------------------------------------------------------------------
def main
# This makes sure it actually displays the map
@spriteset = Spriteset_Map.new
# When a message command is made this displays it
@message_window = Window_Message.new
# I have already explained this
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@spriteset.dispose
@message_window.dispose
if $scene.is_a?(Scene_Title)
Graphics.transition
Graphics.freeze
end
end
#--------------------------------------------------------------------------
# As said before it updates the scene
#--------------------------------------------------------------------------
def update
loop do
$game_map.update
$game_system.map_interpreter.update
$game_player.update
$game_system.update
$game_screen.update
unless $game_temp.player_transferring
break
end
transfer_player
if $game_temp.transition_processing
break
end
end
@spriteset.update
@message_window.update
if $game_temp.gameover
$scene = Scene_Gameover.new
return
end
if $game_temp.to_title
$scene = Scene_Title.new
return
end
if $game_temp.transition_processing
$game_temp.transition_processing = false
if $game_temp.transition_name == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$game_temp.transition_name)
end
end
if $game_temp.message_window_showing
return
end
# This makes the encounter rate work for that map
if $game_player.encounter_count == 0 and $game_map.encounter_list != []
unless $game_system.map_interpreter.running? or
$game_system.encounter_disabled
n = rand($game_map.encounter_list.size)
troop_id = $game_map.encounter_list[n]
if $data_troops[troop_id] != nil
$game_temp.battle_calling = true
$game_temp.battle_troop_id = troop_id
$game_temp.battle_can_escape = true
$game_temp.battle_can_lose = false
$game_temp.battle_proc = nil
end
end
end
if Input.trigger?(Input::B)
unless $game_system.map_interpreter.running? or
$game_system.menu_disabled
$game_temp.menu_calling = true
$game_temp.menu_beep = true
end
end
# This brings up the debug menu when you press F9
if $DEBUG and Input.press?(Input::F9)
$game_temp.debug_calling = true
end
unless $game_player.moving?
if $game_temp.battle_calling
call_battle
elsif $game_temp.shop_calling
call_shop
elsif $game_temp.name_calling
call_name
elsif $game_temp.menu_calling
call_menu
elsif $game_temp.save_calling
call_save
elsif $game_temp.debug_calling
call_debug
end
end
end
#--------------------------------------------------------------------------
# This sorts out what happens when a battle is called
#--------------------------------------------------------------------------
def call_battle
$game_temp.battle_calling = false
$game_temp.menu_calling = false
$game_temp.menu_beep = false
$game_player.make_encounter_count
# Starts the chosen map music
$game_temp.map_bgm = $game_system.playing_bgm
$game_system.bgm_stop
# Plays the battle start sound
$game_system.se_play($data_system.battle_start_se)
# Starts the chosen battle music
$game_system.bgm_play($game_system.battle_bgm)
$game_player.straighten
# Calls on the battle scene
$scene = Scene_Battle.new
end
#--------------------------------------------------------------------------
# This is what happens when a shop is called up
#--------------------------------------------------------------------------
def call_shop
$game_temp.shop_calling = false
$game_player.straighten
# This calls the shop scene
$scene = Scene_Shop.new
end
#--------------------------------------------------------------------------
# This is what happens when name character is called up
#--------------------------------------------------------------------------
def call_name
$game_temp.name_calling = false
$game_player.straighten
# This opens up the name character menu
$scene = Scene_Name.new
end
#--------------------------------------------------------------------------
# This calls up the PreMenu
#--------------------------------------------------------------------------
def call_menu
$game_temp.menu_calling = false
if $game_temp.menu_beep
# Chosen sound effect
$game_system.se_play($data_system.decision_se)
$game_temp.menu_beep = false
end
$game_player.straighten
# This opens the pre menu
$scene = Scene_PreMenu.new
end
#--------------------------------------------------------------------------
# This opens the save menu
#--------------------------------------------------------------------------
def call_save
$game_player.straighten
# This opens the window
$scene = Scene_Save.new
end
#--------------------------------------------------------------------------
# If F9 is pressed on the map it wil open this
#--------------------------------------------------------------------------
def call_debug
$game_temp.debug_calling = false
# Chosen sound effect
$game_system.se_play($data_system.decision_se)
$game_player.straighten
# Calls up the debug menu
$scene = Scene_Debug.new
end
#--------------------------------------------------------------------------
# This sorts out the character directional movement
#--------------------------------------------------------------------------
def transfer_player
$game_temp.player_transferring = false
# This sorts out where the player is displayed on the map
if $game_map.map_id != $game_temp.player_new_map_id
$game_map.setup($game_temp.player_new_map_id)
end
# This sorts out move event so that they move correctly when commanded
$game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
# These are the directions
case $game_temp.player_new_direction
when 2 # Down
$game_player.turn_down
when 4 # Left
$game_player.turn_left
when 6 # Right
$game_player.turn_right
when 8 # Up
$game_player.turn_up
end
$game_player.straighten
$game_map.update
@spriteset.dispose
@spriteset = Spriteset_Map.new
if $game_temp.transition_processing
$game_temp.transition_processing = false
# The chosen grphics decision will take 2 seconds
Graphics.transition(20)
end
# This autoplays the chosen map music
$game_map.autoplay
# This makes it reset once played through
Graphics.frame_reset
# This updates it
Input.update
end
end
class Scene_Save < Scene_File
#--------------------------------------------------------------------------
# This is the same save menu just changed so that if the cancel button is pressed whiles on it...it will go back to the map
#--------------------------------------------------------------------------
def initialize
super("Which file do you want to save to?")
end
#--------------------------------------------------------------------------
# The basis of saving
#--------------------------------------------------------------------------
def on_decision(filename)
# Save sound effect
$game_system.se_play($data_system.save_se)
# This saves the file into directory
file = File.open(filename, "wb")
write_save_data(file)
file.close
if $game_temp.save_calling
$game_temp.save_calling = false
# If cancel is pressed it goes back to map
$scene = Scene_Map.new
return
end
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# Im getting lazy now lol so basically the rest would just have me repeating myself :D so ill just say the new parts
#--------------------------------------------------------------------------
def on_cancel
$game_system.se_play($data_system.cancel_se)
if $game_temp.save_calling
$game_temp.save_calling = false
$scene = Scene_Map.new
return
end
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# This overwrites a file corectly when chosen to
#--------------------------------------------------------------------------
def write_save_data(file)
# This displays actors in save box
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
characters.push([actor.character_name, actor.character_hue])
end
Marshal.dump(characters, file)
Marshal.dump(Graphics.frame_count, file)
$game_system.save_count += 1
$game_system.magic_number = $data_system.magic_number
# This saves all the data that has currently happened in the game in all categories
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
end
end
class Scene_End
#--------------------------------------------------------------------------
# Slightly edited like the save menu
#--------------------------------------------------------------------------
def main
# The choices displayed on screen
s1 = "Titlescreen"
s2 = "Shutdown"
s3 = "Cancel"
@command_window = Window_Command.new(192, [s1, s2, s3])
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 240 - @command_window.height / 2
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@command_window.dispose
if $scene.is_a?(Scene_Title)
Graphics.transition
Graphics.freeze
end
end
#--------------------------------------------------------------------------
def update
@command_window.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
case @command_window.index
when 0 # Sorts out what heppens when the first choice is chosen
command_to_title
when 1 # Same but for the second choice
command_shutdown
when 2 # And for the third
command_cancel
end
return
end
end
#--------------------------------------------------------------------------
# If titlescreen is chosen this will happen
#--------------------------------------------------------------------------
def command_to_title
$game_system.se_play($data_system.decision_se)
# The bg music, bg sound and music effects fade
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# This brings you back to the title screen
$scene = Scene_Title.new
end
#--------------------------------------------------------------------------
# This is what happens when shutdown is picked
#--------------------------------------------------------------------------
def command_shutdown
$game_system.se_play($data_system.decision_se)
#As you can see the sound things happen again
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# This closes the programme
$scene = nil
end
#--------------------------------------------------------------------------
# And this is for cancel
#--------------------------------------------------------------------------
def command_cancel
$game_system.se_play($data_system.decision_se)
# Brings you back to the Map
$scene = Scene_Map.new
end
end