Introduction
The first real AEE script!
This offers you a wide range of features, most of which are optional.
Features
Requirements
Requires: AEE - Data Manager: http://www.planetdev.co.uk/viewtopic.php?f=15&p=371
Place this music player script below AEE - Data Manager
Screenshots

Script
Credits
Credit me if used please!
Not available for use in commercial projects unless i'm contacted about it. Thanks.
The first real AEE script!
This offers you a wide range of features, most of which are optional.
Features
- Locking/Unlocking of tracks
- Cover art
- Locked cover art
- Allow unlocking of music by hearing it in the game
- Allow the player to hear the music on the map
- Ability to add tracks on the fly
- Ability to lock/unlock tracks on the fly
Requirements
Requires: AEE - Data Manager: http://www.planetdev.co.uk/viewtopic.php?f=15&p=371
Place this music player script below AEE - Data Manager
Screenshots

Script
- #===============================================================================
- # * AEE - Music Player
- # * By Crazyninjaguy
- # * http://www.planetdev.co.uk
- # * Part of Cng's Ace Engine Evolution
- # ---------------------------------------------------------------------------
- # * REQUIRES: AEE - Data Manager
- # http://www.planetdev.co.uk/viewtopic.php?f=15&p=371
- # ---------------------------------------------------------------------------
- # * INSTALLATION:
- # Put this script below AEE - Data Manager.
- # ---------------------------------------------------------------------------
- # * USAGE:
- # Follow the instructions in script to set it up properly.
- # To call this from an event command, use SceneManager.goto(Scene_Music)
- # When AEE - Menu is finished, this script will have a menu option.
- # ---------------------------------------------------------------------------
- # * SCRIPT COMMANDS:
- # The following can be used as script commands:
- #
- # $game_music.lock("Track Name")
- # $game_music.unlock("Track Name")
- # $game_music.add("Track Name", unlocked, "Cover Art", "Locked Cover Art")
- # Set the unlocked value to true or false depending on whether you want them
- # to be able to access it straight away.
- #
- #===============================================================================
- $imported = {} if $imported == nil
- $imported["AEE-MusicPlayer"] = true
- module AEE
- module Music
- # Icon ID of the icon relating to Unlocked Items
- UNLOCKED_ICON = 189
- # Icon ID of the icon relating to locked Items
- LOCKED_ICON = 187
- # Show locked tracks in the track selector?
- SHOW_LOCKED_ITEMS = true
- # Unlock music just by hearing it in game?
- UNLOCK_BY_HEARING = true
- # Keep playing the music when the player exits this scene?
- KEEP_PLAYING_ON_EXIT = true
- # Default Cover art filename in Graphics/Pictures 150 pixels x 150 pixels.
- # Used for tracks added by the system.
- DEFAULT_COVER = "Cover"
- # Default locked Cover art filename in Graphics/Pictures 150 pixels x 150 pixels.
- # Used for tracks added by the system.
- DEFAULT_LOCKED = "Cover_locked"
- # Leave the next line alone
- FILES = []
- # These are the tracks available to the player by default.
- # FILES[Index] = ["Filename", unlocked, "Cover Image", "Locked Cover Image"]
- # Set unlocked to true or false, depending on whether you want the player
- # to be able to access it straight away.
- FILES[0] = ["Battle1", true, "Cover", "Cover_locked"]
- FILES[1] = ["Battle2", true, "", "Cover_locked"]
- FILES[2] = ["Battle3", true, "", "Cover_locked"]
- FILES[3] = ["Battle4", true, "", "Cover_locked"]
- FILES[4] = ["Battle5", false, "", "Cover_locked"]
- FILES[5] = ["Battle6", false, "", "Cover_locked"]
- FILES[6] = ["Battle7", false, "", "Cover_locked"]
- FILES[7] = ["Battle8", true, "", "Cover_locked"]
- FILES[8] = ["Battle9", true, "", "Cover_locked"]
- end
- end
- class Game_Music
- include AEE::Music
- attr_accessor :files
- attr_accessor :filenames
- def initialize
- @files = []
- @filenames = []
- for i in 0...FILES.size
- @files.push(Game_MusicFile.new(FILES[i][0], FILES[i][1], FILES[i][2], FILES[i][3]))
- @filenames.push(FILES[i][0])
- end
- end
- def unlock(name)
- for i in [email hidden]
- if @filenames[i] == name
- @files[i].unlocked = true
- end
- end
- end
- def lock(name)
- for i in [email hidden]
- if @filenames[i] == name
- @files[i].unlocked = false
- end
- end
- end
- def add(name, unlocked, image, locked_image)
- if [email protected]?(name)
- @filenames.push(name)
- @files.push(Game_MusicFile.new(name, unlocked, image, locked_image))
- end
- end
- end
- class Game_MusicFile
- attr_accessor :filename
- attr_accessor :unlocked
- attr_accessor :image
- attr_accessor :unlocked_image
- def initialize(filename, unlocked, image, unlocked_image)
- @filename = filename
- @unlocked = unlocked
- @image = image
- @unlocked_image = unlocked_image
- end
- end
- class Scene_Music < Scene_Base
- include AEE::Music
- def start
- super
- create_command_window
- @index = 0
- end
- def terminate
- super
- end
- def update
- super
- if @index != @command_window.index
- if SHOW_LOCKED_ITEMS
- @music_info.refresh($game_music.files[@command_window.index])
- @index = @command_window.index
- else
- @music_info.refresh(@unlocked[@command_window.index])
- @index = @command_window.index
- end
- end
- if Input.trigger?(:B)
- Sound.play_cancel
- if !KEEP_PLAYING_ON_EXIT
- Audio.bgm_stop
- end
- SceneManager.goto(Scene_Map)
- end
- end
- def create_command_window
- @command_window = Window_MusicCommand.new
- @command_window.height = Graphics.height / 2
- @command_window.y = Graphics.height / 2
- @music_info = Window_MusicInfo.new($game_music.files[@command_window.index])
- if !SHOW_LOCKED_ITEMS
- @unlocked = []
- for i in 0...$game_music.files.size
- if $game_music.files[i].unlocked
- @unlocked.push($game_music.files[i])
- end
- end
- end
- end
- end
- class Window_MusicCommand < Window_Command
- include AEE::Music
- def initialize
- super(0, 0)
- end
- def window_width
- return Graphics.width
- end
- def visible_line_number
- item_max
- end
- def make_command_list
- add_main_commands
- end
- def col_max
- return 2
- end
- def add_main_commands
- for i in 0...$game_music.files.size
- if SHOW_LOCKED_ITEMS
- add_command($game_music.files[i].filename, $game_music.files[i].filename, $game_music.files[i].unlocked)
- else
- if $game_music.files[i].unlocked
- add_command($game_music.files[i].filename, $game_music.files[i].filename, $game_music.files[i].unlocked)
- end
- end
- end
- end
- def draw_item(index)
- change_color(normal_color, command_enabled?(index))
- temp = item_rect_for_text(index)
- temp.x += 24
- draw_text(temp, command_name(index), alignment)
- if SHOW_LOCKED_ITEMS
- if $game_music.files[index].unlocked
- draw_icon(UNLOCKED_ICON, temp.x - 24, temp.y)
- else
- draw_icon(LOCKED_ICON, temp.x - 24, temp.y)
- end
- else
- draw_icon(UNLOCKED_ICON, temp.x - 24, temp.y)
- end
- end
- def call_ok_handler
- if handle?(current_symbol)
- call_handler(current_symbol)
- elsif handle?(:ok)
- super
- else
- activate
- Audio.bgm_play("Audio/BGM/#{$game_music.files[index].filename}", 100, 100)
- end
- end
- end
- class AEEDataManager
- alias aee_datamanager_musicplayer_createobjects create_extra_objects
- def create_extra_objects
- aee_datamanager_musicplayer_createobjects
- $game_music = Game_Music.new
- end
- alias aee_datamanager_musicplayer_getfilestosave get_files_to_save
- def get_files_to_save(contents)
- aee_datamanager_musicplayer_getfilestosave(contents)
- contents[:music] = $game_music
- end
- alias aee_datamanager_musicplayer_extractfiles extract_save_contents
- def extract_save_contents(contents)
- aee_datamanager_musicplayer_extractfiles(contents)
- $game_music = contents[:music]
- end
- end
- class Window_MusicInfo < Window_Base
- def initialize(song)
- super(0, 0, Graphics.width, Graphics.height / 2)
- @cover = Sprite_Cover.new(song)
- @cover.z = self.z + 1
- refresh(song)
- end
- def refresh(song)
- self.contents.clear
- @cover.refresh(song)
- if song.unlocked
- self.contents.font.color = power_up_color
- else
- self.contents.font.color = power_down_color
- end
- self.contents.draw_text(0, 0, width - 32, 24, song.filename, 1)
- self.contents.font.color = normal_color
- end
- alias aee_musicinfo_musicplayer_dispose dispose
- def dispose
- aee_musicinfo_musicplayer_dispose
- @cover.dispose
- end
- end
- class Game_Map
- include AEE::Music
- alias aee_gamemap_musicplayer_autoplay autoplay
- def autoplay
- aee_gamemap_musicplayer_autoplay
- if UNLOCK_BY_HEARING
- if !$game_music.filenames.include?(@map.bgm.name)
- $game_music.files.push(Game_MusicFile.new(@map.bgm.name, true, "", ""))
- $game_music.filenames.push(@map.bgm.name)
- end
- end
- end
- end
- class Sprite_Cover < Sprite_Base
- def initialize(file)
- super(nil)
- refresh(file)
- end
- def dispose
- super
- self.bitmap.dispose
- end
- def refresh(file)
- if file.unlocked
- self.bitmap = Cache.picture(file.image)
- else
- self.bitmap = Cache.picture(file.unlocked_image)
- end
- self.x = (Graphics.width - self.bitmap.width) / 2
- self.y = (((Graphics.height / 2) - self.bitmap.width) / 2) + 10
- end
- end
- class Game_Interpreter
- include AEE::Music
- alias aee_interpreter_musicplayer_command241 command_241
- def command_241
- aee_interpreter_musicplayer_command241
- if UNLOCK_BY_HEARING
- if !$game_music.filenames.include?(@params[0].name)
- $game_music.files.push(Game_MusicFile.new(@params[0].name, true, DEFAULT_COVER, DEFAULT_LOCKED))
- $game_music.filenames.push(@params[0].name)
- end
- end
- end
- end
- class Scene_Map < Scene_Base
- include AEE::Music
- alias aee_scenemap_musicplayer_prebattlescene pre_battle_scene
- def pre_battle_scene
- aee_scenemap_musicplayer_prebattlescene
- if UNLOCK_BY_HEARING
- if !$game_music.filenames.include?($game_system.battle_bgm.name)
- $game_music.files.push(Game_MusicFile.new($game_system.battle_bgm.name, true, DEFAULT_COVER, DEFAULT_LOCKED))
- $game_music.filenames.push($game_system.battle_bgm.name)
- end
- end
- end
- end
Expand to see the code.
Credits
Credit me if used please!
Not available for use in commercial projects unless i'm contacted about it. Thanks.