Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
Darkness

Script that allow you to listening to BGM in the game

Recommended Posts

Just like what this script can do.

 

http://www.rmxpunlim...module-xpvxvxa/

 

But, it seems that script is for the better purposes.not just listening to BGM only.

 

I just want the script that I can listen the music in the game.

Edited by Darkness

Share this post


Link to post
Share on other sites

I don't think you need a scrip for that. I mean you would but it is already in the game maker. You can set music to the map. If you want to attach the music to something in the game you can create an event and place the music through an event (The Chrono Trigger monster behind the piano comes to mind). If you just want to be able to control the music wherever you want in game then you would need some sort of sound test script that was placed in the menu, which would look much like the script by ForeverZer0 you linked.

Share this post


Link to post
Share on other sites

I don't think you need a scrip for that. I mean you would but it is already in the game maker. You can set music to the map. If you want to attach the music to something in the game you can create an event and place the music through an event (The Chrono Trigger monster behind the piano comes to mind). If you just want to be able to control the music wherever you want in game then you would need some sort of sound test script that was placed in the menu, which would look much like the script by ForeverZer0 you linked.

 

Thanks for your reply. Ah, yes. I know that I can set the music for listening in the game. But, I want a script that allow me to choose the song freely like in the link, like in Golden Sun : The Lost Age after you completed the game. (If you used to played). Like this (for other guys).

 

AudioPlayerSample.png

 

If there's no script like that any more, maybe I should deal with ForeverZer0's script.

 

*Post Script - Mr.ForeverZer0 said that his script was incompleted and used for demo purposed only (not good use for the game) and he was already dropped it. So,I don't want to use it in my game.In other word, I need simpler and already complete script.

 

If anyone knows, you can reply me anytime.

Edited by Darkness

Share this post


Link to post
Share on other sites

i have been playing around a little and this is what i have so far:

 

 

#===============================================================================
# ** RTP ****Credits to ForeverZer0****
#-------------------------------------------------------------------------------
# Provides functions for getting the games RTP path(s) and files
#===============================================================================
module RTP
# RMXP
SUBFOLDERS = [
 'Graphics/Animations', 'Graphics/Autotiles', 'Graphics/Battlebacks',
 'Graphics/Battlers', 'Graphics/Characters', 'Graphics/Fogs',
 'Graphics/Gameovers', 'Graphics/Icons', 'Graphics/Panoramas',
 'Graphics/Pictures', 'Graphics/Tilesets', 'Graphics/Titles',
 'Graphics/Transitions', 'Graphics/Windowskins', 'Audio/BGM',
 'Audio/BGS', 'Audio/ME', 'Audio/SE'
]
#-----------------------------------------------------------------------------
# * Object initialization
#-----------------------------------------------------------------------------
def self.init
@ini = Win32API.new('kernel32', 'GetPrivateProfileStringA', 'PPPPLP', 'L')
@library = "\0" * 256
@ini.call('Game', 'Library', '', @library, 256, '.\\Game.ini')
@library.delete!("\0")
@rtp_path = Win32API.new(@library, 'RGSSGetRTPPath', 'L', 'L')
@path_with_rtp = Win32API.new(@library, 'RGSSGetPathWithRTP', 'L', 'P')
@directories = {}
SUBFOLDERS.each {|folder| @directories[folder] = entries(folder) }
@initialized = true
end
#-----------------------------------------------------------------------------
# * Returns an array of the full paths of all the game's installed RTPs
#-----------------------------------------------------------------------------
def self.paths
paths = [1, 2, 3].collect {|id| @path_with_rtp.call(@rtp_path.call(id)) }
paths = paths.find_all {|path| path != '' }
# This is kind of a crappy way of doing this until the RMVX call works...
common = File.join(ENV['CommonProgramFiles'], 'Enterbrain')
common = File.join(common, 'RGSS', 'Standard')
if !paths.include?(common) && File.directory?(common)
 paths.push(common)
end
return paths
end
#-----------------------------------------------------------------------------
# * Gives hash-like access to the RTP subfolders
#-----------------------------------------------------------------------------
def self.[](folder)
return subfolder?(folder) ? @directories[folder] : []
end
#-----------------------------------------------------------------------------
# * Returns true/false if the given subfolder exists
#-----------------------------------------------------------------------------
def self.subfolder?(folder)
return @directories.has_key?(folder)
end
#-----------------------------------------------------------------------------
# * Get a complete list of full paths of files found in the given subfolder
# subfolder : The RTP folder whose files you want to get
#-----------------------------------------------------------------------------
def self.entries(subfolder)
files = []
paths.each {|path|
 dir = path + '\\' + subfolder
 if File.directory?(dir)
 files = (Dir.entries(dir) - ['.', '..']).collect {|f| dir + '\\' + f }
 end
}
return files
end
end
RTP.init
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
class Scene_Bgm_Choice
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
def main
dir = 'Audio/BGM'
@data = RTP[dir]
@files = []
for i in 0...@data.size
 item = @data[i]
 ext = File.extname(item)
 file = File.basename(item, ext)
 @files += [file]
end
@bgm_window = Window_Command.new(640, @files, 480)
Graphics.transition
loop { Graphics.update; Input.update; update; break if $scene != self }
@bgm_window.dispose
end
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
def update
@bgm_window.update
$scene = Scene_Map.new if Input.trigger?(Input::B)
if Input.trigger?(Input::C)
 sound = @files[@bgm_window.index]
 Audio.bgm_play("Audio/BGM/" + sound, 100, 100)
end
end
end
#
#
#
class Window_Command < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#	 width : window width
#	 commands : command text string array
#	 height(optional) : window height
#--------------------------------------------------------------------------
def initialize(width, commands, height=nil)
# Compute window height from command quantity
super(0, 0, width, height) if height != nil
super(0, 0, width, commands.size * 32 + 32) if height == nil
@item_max = commands.size
@commands = commands
self.contents = Bitmap.new(width - 32, @item_max * 32)
refresh
self.index = 0
end
end

 

 

to call the script use this: $scene = Scene_Bgm_Choice.new

i have stolen the rtp module from foreverzero tongue.png mainly because im not entirely sure how to grab all the directories content, my main question is do you want anything else adding/changing? like description window or volume and pitch control ect, this is not the final thing bear that in mind biggrin.png

Edited by diagostimo

Share this post


Link to post
Share on other sites

bump, i made a little more progress on this, i tidied up the script and added a config for sound names so you can rename those craply named rtp sounds, i also added a play window with volume and pitch control, cant really think of anything else to add :

 

 

#===============================================================================
#  -----credits-----
#  * ForeverZer0 for the RTP Module (used to gain paths to rtp files)
#  * Diagostimo for composing this script
#
#  ------Notes------
#  * this script will only play BGM music.
#  * to call the script use this script call: "$scene = Scene_Bgm_Choice.new"
#  * replicate names can be given to sounds that are displayed in the window,
#    see below for further details.
#
#===============================================================================
module Audio
 # Enter the code for the version of RPG Maker you are using this script for.
 #   RMXP  = 0
 #   RMVX  = 1
 #   RMVXA = 2
 RPG_VERSION = 0

 #replicate names config
 def self.replicate_names(name)
   case name
 #------------------------------------------#
 # * CONFIGURE REPLICATE NAMES FOR SOUNDS * #
 #------------------------------------------#
 # WHEN "SOUND_NAME" then "REPLACEMENT_NAME"
   when "001-Battle01" then "replacement"
   when "" then ""
 # etc
 #------------------------------------------#
 # * END OF REPLICATE NAMES CONFIGURATION * #
 #------------------------------------------#
   else ''
   end
 end
end
#===============================================================================
# ** RTP
#-------------------------------------------------------------------------------
# Provides functions for getting the games RTP path(s) and files
#===============================================================================
module RTP

 # RMXP
 if Audio::RPG_VERSION == 0
   SUBFOLDERS = [
  'Graphics/Animations', 'Graphics/Autotiles', 'Graphics/Battlebacks',
  'Graphics/Battlers', 'Graphics/Characters', 'Graphics/Fogs',
  'Graphics/Gameovers', 'Graphics/Icons', 'Graphics/Panoramas',
  'Graphics/Pictures', 'Graphics/Tilesets', 'Graphics/Titles',
  'Graphics/Transitions', 'Graphics/Windowskins', 'Audio/BGM',
  'Audio/BGS', 'Audio/ME', 'Audio/SE'
   ]
 # RMVX
 elsif Audio::RPG_VERSION == 1
   SUBFOLDERS = [
  'Graphics/Animations', 'Graphics/Battlers', 'Graphics/Characters',
  'Graphics/Faces', 'Graphics/Parallaxes', 'Graphics/Pictures',
  'Graphics/System', 'Audio/BGM', 'Audio/BGS', 'Audio/ME', 'Audio/SE'
   ]
 # RMVXA
 elsif Audio::RPG_VERSION == 2
   SUBFOLDERS = [
  'Graphics/Animations', 'Graphics/Battlers', 'Graphics/Characters',
  'Graphics/Faces', 'Graphics/Parallaxes', 'Graphics/Pictures',
  'Graphics/System', 'Audio/BGM', 'Audio/BGS', 'Audio/ME', 'Audio/SE'
   ]
 end
 #-----------------------------------------------------------------------------
 # * Object initialization
 #-----------------------------------------------------------------------------
 def self.init
   @ini = Win32API.new('kernel32', 'GetPrivateProfileStringA', 'PPPPLP', 'L')
   @library = "\0" * 256
   @ini.call('Game', 'Library', '', @library, 256, '.\\Game.ini')
   @library.delete!("\0")
   @rtp_path = Win32API.new(@library, 'RGSSGetRTPPath', 'L', 'L')
   @path_with_rtp = Win32API.new(@library, 'RGSSGetPathWithRTP', 'L', 'P')
   @directories = {}
   SUBFOLDERS.each {|folder| @directories[folder] = entries(folder) }
   @initialized = true
 end
 #-----------------------------------------------------------------------------
 # * Returns an array of the full paths of all the game's installed RTPs
 #-----------------------------------------------------------------------------
 def self.paths
   paths = [1, 2, 3].collect {|id| @path_with_rtp.call(@rtp_path.call(id)) }
   paths = paths.find_all {|path| path != '' }
   # This is kind of a crappy way of doing this until the RMVX call works...
   common = File.join(ENV['CommonProgramFiles'], 'Enterbrain')
   common = case Audio::RPG_VERSION
   when 0 then File.join(common, 'RGSS', 'Standard')
   when 1 then File.join(common, 'RGSS2', 'RPGVX')
   when 2 then File.join(common, 'RGSS3', 'RPGVXAce')
   end
   if !paths.include?(common) && File.directory?(common)
  paths.push(common)
   end
   return paths
 end
 #-----------------------------------------------------------------------------
 # * Gives hash-like access to the RTP subfolders
 #-----------------------------------------------------------------------------
 def self.[](folder)
   return subfolder?(folder) ? @directories[folder] : []
 end
 #-----------------------------------------------------------------------------
 # * Returns true/false if the given subfolder exists
 #-----------------------------------------------------------------------------
 def self.subfolder?(folder)
   return @directories.has_key?(folder)
 end
 #-----------------------------------------------------------------------------
 # * Get a complete list of full paths of files found in the given subfolder
 #   subfolder   : The RTP folder whose files you want to get
 #-----------------------------------------------------------------------------
 def self.entries(subfolder)
   files = []
   paths.each {|path|
  dir = path + '\\' + subfolder
  if File.directory?(dir)
    files = (Dir.entries(dir) - ['.', '..']).collect {|f| dir + '\\' + f }
  end
   }
   return files
 end
end
RTP.init
#
#
#
class Window_Confirm < Window_Selectable
 attr_accessor :volume
 attr_accessor :pitch
 #--------------------------------------------------------------------------
 # * Object Initialization
 #	 width    : window width
 #--------------------------------------------------------------------------
 def initialize(width)
   @volume = 100
   @pitch = 100
   item_max = 3
   super(0, 0, width, 32 + (item_max * 32))
   @item_max = item_max
   self.contents = Bitmap.new(width - 32, @item_max * 32)
   refresh
 end
 #
 #
 #
 def update
   super
   refresh
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   for i in 0...@item_max
  text = "Volume:" if i == 0
  text2 = " #{@volume}%" if i == 0
  text = "Pitch:" if i == 1
  text2 = " #{@pitch}%" if i == 1
  text = "Play" if i == 2
  cx = self.contents.text_size(text).width
  cx2 = self.contents.text_size(text2).width
  x = 0 if i <= 1
  x = (self.contents.width - cx) / 2 if i == 2
  x2 = self.contents.width - cx2
  y = i * 32
  self.contents.draw_text(x, y, cx, 32, text)
  self.contents.draw_text(x2, y, cx2, 32, text2) if i <= 1
   end
 end
end
#==============================================================================
# ** Scene_Bgm_Choice
#------------------------------------------------------------------------------
#  This scene deals with the selection of bgm to play
#==============================================================================
class Scene_Bgm_Choice
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   dir = 'Audio/BGM'
   @files = []
   for i in 0...RTP[dir].size
  item = RTP[dir][i]
  ext = File.extname(item)
  file = File.basename(item, ext)
  @files += [file]
   end
   if File.directory?(dir)
  @files += (Dir.entries(dir) - ['.', '..'])
   end
   @bgm_window = Window_Command.new(320, @files, 480)
   @confirm_window = Window_Confirm.new(320)
   @confirm_window.x = 320
   @confirm_window.index = -1
   @confirm_window.active = false
   Graphics.transition
   loop { Graphics.update; Input.update; update; break if $scene != self }
   @bgm_window.dispose
   @confirm_window.dispose
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   if @bgm_window.active
  @bgm_window.update
  $scene = Scene_Map.new if Input.trigger?(Input::B)
  if Input.trigger?(Input::C)
    @sound = @files[@bgm_window.index]
    @bgm_window.active = false
    @bgm_index = @bgm_window.index
    @bgm_window.index = -1
    @confirm_window.index = 0
    @confirm_window.active = true
  end
   else
  @confirm_window.update
  if Input.trigger?(Input::B)
    @confirm_window.volume = 100
    @confirm_window.pitch = 100
    @confirm_window.index = -1
    @confirm_window.active = false
    @bgm_window.index = @bgm_index
    @bgm_window.active = true
    @confirm_window.refresh
  end
  if Input.trigger?(Input::C) && @confirm_window.index == 2
    volume = @confirm_window.volume
    pitch = @confirm_window.pitch
    Audio.bgm_play("Audio/BGM/" + @sound, volume, pitch)
  end
  if Input.repeat?(Input::LEFT)
    case @confirm_window.index
    when 0
	  if @confirm_window.volume > 0
	    @confirm_window.volume -= 1
	    $game_system.se_play($data_system.cursor_se)
	  else
	    $game_system.se_play($data_system.buzzer_se)
	  end
    when 1
	  if @confirm_window.pitch > 50
	    @confirm_window.pitch -= 1
	    $game_system.se_play($data_system.cursor_se)
	  else
	    $game_system.se_play($data_system.buzzer_se)
	  end
    end
  end
  if Input.repeat?(Input::RIGHT)
    case @confirm_window.index
    when 0
	  if @confirm_window.volume < 100
	    @confirm_window.volume += 1
	    $game_system.se_play($data_system.cursor_se)
	  else
	    $game_system.se_play($data_system.buzzer_se)
	  end
    when 1
	  if @confirm_window.pitch < 150
	    @confirm_window.pitch += 1
	    $game_system.se_play($data_system.cursor_se)
	  else
	    $game_system.se_play($data_system.buzzer_se)
	  end
    end
  end
   end
 end
end
#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
#  This window deals with general command choices.
#==============================================================================
class Window_Command < Window_Selectable
 #--------------------------------------------------------------------------
 # * Object Initialization
 #	 width    : window width
 #	 commands : command text string array
 #--------------------------------------------------------------------------
 def initialize(width, commands, height=nil)
   # Compute window height from command quantity
   super(0, 0, width, height) if height != nil
   super(0, 0, width, commands.size * 32 + 32) if height == nil
   @item_max = commands.size
   @commands = commands
   self.contents = Bitmap.new(width - 32, @item_max * 32)
   refresh
   self.index = 0
 end
 #--------------------------------------------------------------------------
 # * Draw Item
 #	 index : item number
 #	 color : text color
 #--------------------------------------------------------------------------
 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))
   #checks to see if the scene is a bgm choice and a replicate name is needed
   replicate_name = Audio.replicate_names(@commands[index])
   if $scene.is_a?(Scene_Bgm_Choice) && replicate_name != ''
  text = replicate_name
   else
  text = @commands[index]
   end
   #draws the given text
   self.contents.draw_text(rect, text)
 end
end

 

 

Share this post


Link to post
Share on other sites

Thank you very much!!! I've tried that and it's really good! But, is there any way to stop the song after I've cancel the bgm choice window?

Share this post


Link to post
Share on other sites

so you just want the menu as a way to sample the bgm songs? i can easilly do that, my only question is do you want it to play the maps auto bgm when closing the window? also as for the unused corner, i can add a background image or make the background the map, your choice

Edited by diagostimo

Share this post


Link to post
Share on other sites

my only question is do you want it to play the maps auto bgm when closing the window?

 

Ah... I'm not sure about this "play the maps auto bgm when closing the window" part because I'm not expert at English. But, If I'm correct, It means that you were asking me for the music would still playing after I closed the window. If so, I want the music to be stopped after I closed the music window.

 

 

 

i can add a background image or make the background the map.

 

About that, you can do it if you want to. For me the default is enough and I'm asking you too much right now.

 

 

Well, Thank you for everything you've done for me. I'll be back here tomorrow.

 

PS. - Maybe this's too much. but, Can I ask you one thing before I go? When I use your script, My game menu language has changed into the square. Sorry, I don't have much time to capture and upload the pic now. I'm using RMXP 1.01 Translate version (Spanish,Thai etc.).

Share this post


Link to post
Share on other sites

i have just read some info on the translated versions, apparently they have some font issues, im not sure if it applies to your version, could you post a link to your version? and why do you need the translate? is it for readability in the editor or making your games in your national language?

when i said "play the maps auto bgm when closing the window" go to a maps properties and you will see that you can tick auto change bgm to give each map there own bgm "back ground sound" what i meant is if you have a sound setup for the map do you want it to start playing it again?

Share this post


Link to post
Share on other sites

when i said "play the maps auto bgm when closing the window" go to a maps properties and you will see that you can tick auto change bgm to give each map there own bgm "back ground sound" what i meant is if you have a sound setup for the map do you want it to start playing it again?

 

Oh! so, that's it. Yes,I want the original map's music to start playing back again after I cancel the Listen-BGM window. Sorry for my misunderstood yesterday.

 

About the translation problem, I'm trying to ask about it in my own country webboard. If you want the link, it's here.

http://www.thaigamin...unity/94200.htm. This's not where I download it but the version is the same. I need to make my game 2 version, my own language and international (actually English).

 

Here's the picture.

 

http://imageshack.us...545/fgfdgk.png/

 

If you know anything,please tell me.

Edited by Darkness

Share this post


Link to post
Share on other sites

here it is:

 

 

 

#===============================================================================

# -----credits-----

# * ForeverZer0 for the RTP Module (used to gain paths to rtp files)

# * Diagostimo for composing this script

#

# ------Notes------

# * this script will only play BGM music.

# * to call the script use this script call: "$scene = Scene_Bgm_Choice.new"

# * replicate names can be given to sounds that are displayed in the window,

# see below for further details.

#

#===============================================================================

module Audio

# set filename for background image, if left '' the map will be drawn instead

#the image must be in the pictures directory

BACK_IMAGE = ''

 

# Enter the code for the version of RPG Maker you are using this script for.

# RMXP = 0

# RMVX = 1

# RMVXA = 2

RPG_VERSION = 0

 

#replicate names config

def self.replicate_names(name)

case name

#------------------------------------------#

# * CONFIGURE REPLICATE NAMES FOR SOUNDS * #

#------------------------------------------#

# WHEN "SOUND_NAME" then "REPLACEMENT_NAME"

when "001-Battle01" then "replacement"

when "" then ""

# etc

#------------------------------------------#

# * END OF REPLICATE NAMES CONFIGURATION * #

#------------------------------------------#

else ''

end

end

end

#===============================================================================

# ** RTP

#-------------------------------------------------------------------------------

# Provides functions for getting the games RTP path(s) and files

#===============================================================================

 

module RTP

 

# RMXP

if Audio::RPG_VERSION == 0

SUBFOLDERS = [

'Graphics/Animations', 'Graphics/Autotiles', 'Graphics/Battlebacks',

'Graphics/Battlers', 'Graphics/Characters', 'Graphics/Fogs',

'Graphics/Gameovers', 'Graphics/Icons', 'Graphics/Panoramas',

'Graphics/Pictures', 'Graphics/Tilesets', 'Graphics/Titles',

'Graphics/Transitions', 'Graphics/Windowskins', 'Audio/BGM',

'Audio/BGS', 'Audio/ME', 'Audio/SE'

]

# RMVX

elsif Audio::RPG_VERSION == 1

SUBFOLDERS = [

'Graphics/Animations', 'Graphics/Battlers', 'Graphics/Characters',

'Graphics/Faces', 'Graphics/Parallaxes', 'Graphics/Pictures',

'Graphics/System', 'Audio/BGM', 'Audio/BGS', 'Audio/ME', 'Audio/SE'

]

# RMVXA

elsif Audio::RPG_VERSION == 2

SUBFOLDERS = [

'Graphics/Animations', 'Graphics/Battlers', 'Graphics/Characters',

'Graphics/Faces', 'Graphics/Parallaxes', 'Graphics/Pictures',

'Graphics/System', 'Audio/BGM', 'Audio/BGS', 'Audio/ME', 'Audio/SE'

]

end

#-----------------------------------------------------------------------------

# * Object initialization

#-----------------------------------------------------------------------------

def self.init

@ini = Win32API.new('kernel32', 'GetPrivateProfileStringA', 'PPPPLP', 'L')

@library = "\0" * 256

@ini.call('Game', 'Library', '', @library, 256, '.\\Game.ini')

@library.delete!("\0")

@rtp_path = Win32API.new(@library, 'RGSSGetRTPPath', 'L', 'L')

@path_with_rtp = Win32API.new(@library, 'RGSSGetPathWithRTP', 'L', 'P')

@directories = {}

SUBFOLDERS.each {|folder| @directories[folder] = entries(folder) }

@initialized = true

end

#-----------------------------------------------------------------------------

# * Returns an array of the full paths of all the game's installed RTPs

#-----------------------------------------------------------------------------

def self.paths

paths = [1, 2, 3].collect {|id| @path_with_rtp.call(@rtp_path.call(id)) }

paths = paths.find_all {|path| path != '' }

# This is kind of a crappy way of doing this until the RMVX call works...

common = File.join(ENV['CommonProgramFiles'], 'Enterbrain')

common = case Audio::RPG_VERSION

when 0 then File.join(common, 'RGSS', 'Standard')

when 1 then File.join(common, 'RGSS2', 'RPGVX')

when 2 then File.join(common, 'RGSS3', 'RPGVXAce')

end

if !paths.include?(common) && File.directory?(common)

paths.push(common)

end

return paths

end

#-----------------------------------------------------------------------------

# * Gives hash-like access to the RTP subfolders

#-----------------------------------------------------------------------------

def self.[](folder)

return subfolder?(folder) ? @directories[folder] : []

end

#-----------------------------------------------------------------------------

# * Returns true/false if the given subfolder exists

#-----------------------------------------------------------------------------

def self.subfolder?(folder)

return @directories.has_key?(folder)

end

#-----------------------------------------------------------------------------

# * Get a complete list of full paths of files found in the given subfolder

# subfolder : The RTP folder whose files you want to get

#-----------------------------------------------------------------------------

def self.entries(subfolder)

files = []

paths.each {|path|

dir = path + '\\' + subfolder

if File.directory?(dir)

files = (Dir.entries(dir) - ['.', '..']).collect {|f| dir + '\\' + f }

end

}

return files

end

end

RTP.init

 

#

#

#

class Window_Confirm < Window_Selectable

attr_accessor :volume

attr_accessor :pitch

#--------------------------------------------------------------------------

# * Object Initialization

# width : window width

#--------------------------------------------------------------------------

def initialize(width)

@volume = 100

@pitch = 100

item_max = 3

super(0, 0, width, 32 + (item_max * 32))

@item_max = item_max

self.contents = Bitmap.new(width - 32, @item_max * 32)

refresh

end

#

#

#

def update

super

refresh

end

#--------------------------------------------------------------------------

# * Refresh

#--------------------------------------------------------------------------

def refresh

self.contents.clear

for i in 0...@item_max

text = "Volume:" if i == 0

text2 = " #{@volume}%" if i == 0

text = "Pitch:" if i == 1

text2 = " #{@pitch}%" if i == 1

text = "Play" if i == 2

cx = self.contents.text_size(text).width

cx2 = self.contents.text_size(text2).width

x = 0 if i <= 1

x = (self.contents.width - cx) / 2 if i == 2

x2 = self.contents.width - cx2

y = i * 32

self.contents.draw_text(x, y, cx, 32, text)

self.contents.draw_text(x2, y, cx2, 32, text2) if i <= 1

end

end

end

#==============================================================================

# ** Scene_Bgm_Choice

#------------------------------------------------------------------------------

# This scene deals with the selection of bgm to play

#==============================================================================

class Scene_Bgm_Choice

#--------------------------------------------------------------------------

# * Main Processing

#--------------------------------------------------------------------------

def main

$game_system.bgm_stop

dir = 'Audio/BGM'

@files = []

for i in 0...RTP[dir].size

item = RTP[dir]

ext = File.extname(item)

file = File.basename(item, ext)

@files += [file]

end

if File.directory?(dir)

@files += (Dir.entries(dir) - ['.', '..'])

end

if Audio::BACK_IMAGE != ''

@sprite = Sprite.new

@sprite.bitmap = RPG::Cache.picture(Audio::BACK_IMAGE)

else

@sprite = Spriteset_Map.new

end

@bgm_window = Window_Command.new(320, @files, 480)

@confirm_window = Window_Confirm.new(320)

@confirm_window.x = 320

@confirm_window.index = -1

@confirm_window.active = false

Graphics.transition

loop { Graphics.update; Input.update; update; break if $scene != self }

@sprite.dispose

@bgm_window.dispose

@confirm_window.dispose

end

#--------------------------------------------------------------------------

# * Frame Update

#--------------------------------------------------------------------------

def update

if @bgm_window.active

@bgm_window.update

if Input.trigger?(Input::B)

$scene = Scene_Map.new

$game_map.autoplay

end

if Input.trigger?(Input::C)

@sound = @files[@bgm_window.index]

@bgm_window.active = false

@bgm_index = @bgm_window.index

@bgm_window.index = -1

@confirm_window.index = 0

@confirm_window.active = true

end

else

@confirm_window.update

if Input.trigger?(Input::B)

@confirm_window.volume = 100

@confirm_window.pitch = 100

@confirm_window.index = -1

@confirm_window.active = false

@bgm_window.index = @bgm_index

@bgm_window.active = true

@confirm_window.refresh

end

if Input.trigger?(Input::C) && @confirm_window.index == 2

volume = @confirm_window.volume

pitch = @confirm_window.pitch

Audio.bgm_play("Audio/BGM/" + @sound, volume, pitch)

end

if Input.repeat?(Input::LEFT)

case @confirm_window.index

when 0

if @confirm_window.volume > 0

@confirm_window.volume -= 1

$game_system.se_play($data_system.cursor_se)

else

$game_system.se_play($data_system.buzzer_se)

end

when 1

if @confirm_window.pitch > 50

@confirm_window.pitch -= 1

$game_system.se_play($data_system.cursor_se)

else

$game_system.se_play($data_system.buzzer_se)

end

end

end

if Input.repeat?(Input::RIGHT)

case @confirm_window.index

when 0

if @confirm_window.volume < 100

@confirm_window.volume += 1

$game_system.se_play($data_system.cursor_se)

else

$game_system.se_play($data_system.buzzer_se)

end

when 1

if @confirm_window.pitch < 150

@confirm_window.pitch += 1

$game_system.se_play($data_system.cursor_se)

else

$game_system.se_play($data_system.buzzer_se)

end

end

end

end

end

end

 

#==============================================================================

# ** Window_Command

#------------------------------------------------------------------------------

# This window deals with general command choices.

#==============================================================================

class Window_Command < Window_Selectable

#--------------------------------------------------------------------------

# * Object Initialization

# width : window width

# commands : command text string array

#--------------------------------------------------------------------------

def initialize(width, commands, height=nil)

# Compute window height from command quantity

super(0, 0, width, height) if height != nil

super(0, 0, width, commands.size * 32 + 32) if height == nil

@item_max = commands.size

@commands = commands

self.contents = Bitmap.new(width - 32, @item_max * 32)

refresh

self.index = 0

end

#--------------------------------------------------------------------------

# * Draw Item

# index : item number

# color : text color

#--------------------------------------------------------------------------

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))

#checks to see if the scene is a bgm choice and a replicate name is needed

replicate_name = Audio.replicate_names(@commands[index])

if $scene.is_a?(Scene_Bgm_Choice) && replicate_name != ''

text = replicate_name

else

text = @commands[index]

end

#draws the given text

self.contents.draw_text(rect, text)

end

end

 

 

you can setup a background image see the config, just bear in mind it will have to be the size of 640 x 480 smile.png

Edited by diagostimo

Share this post


Link to post
Share on other sites

Thank you very much for this script. I've tried it and that's what I want. But, here comes the next problem. (Awww...)

 

After I closed the music window and press the X Button (to open the menu screen), I got an error message.

 

errordex.png

 

Why did this message poped up?

Edited by Darkness

Share this post


Link to post
Share on other sites

sorry, i forgot to dispose the background when closed, iv edited the script so all should be good smile.png

as for making your game in multiple languages, i would avoid taking the route of using translated versions of rpg maker, the odds of making a game more buggy outweigh the benefit, here is a localization script by ForeverZer0: http://forum.chaos-p...ic,12164.0.html, use that with the english version of rpg maker and just make your translations following the config of the script

Edited by diagostimo

Share this post


Link to post
Share on other sites

sorry, i forgot to dispose the background when closed, iv edited the script so all should be good smile.png

as for making your game in multiple languages, i would avoid taking the route of using translated versions of rpg maker, the odds of making a game more buggy outweigh the benefit, here is a localization script by ForeverZer0: http://forum.chaos-p...ic,12164.0.html, use that with the english version of rpg maker and just make your translations following the config of the script

 

Thanks you very much again!! the script worked now!! What's left is my language problem. Well,I'll try your link to fix it. I think it might be solve soon. Thanks again!

Share this post


Link to post
Share on other sites

I wrote this the yesterday, but then forgot to post it. Now it looks like diagostimo already got it. Oh well, here it is anyway.

 

http://pastebin.com/XcvXj5wi

 

Here's a screenshot, too.

SceneAudio.png

 

Your script is good and my language didn't change into the square (still my lang). I would be very pleased to used this. but,Diagostimo's script can make my original's map music playing back after I closed the music window (I mean... There was a map's own music playing before and after I play some music in the window and cancel the window, the music will change back to its original.). Can you do that?

Share this post


Link to post
Share on other sites

Yeah, it's simply 2 lines of code. I can fix after I get home after work.

 

EDIT:

Okay, all fixed. It is the same link, but here it is again:

http://pastebin.com/XcvXj5wi

 

Thank you! It's worked. but,I have got some error like this.

 

ghghgh.png

 

But after I deleted "$game_system.bgs_stop" part, an error has gone.

 

How do you think about this? Is it really okay for me to delete it? Or, Did you have any other ways to fix this without delete it?

Share this post


Link to post
Share on other sites

theres no method called bgs_stop thats why, i think he may have meant to put $game_system.bgm_stop, most likely the case

Edited by diagostimo

Share this post


Link to post
Share on other sites

Alright, Thanks to both of you again about this script. I have something in my mind. Is there any ways to separated the music window? I mean, ummm.... for example, there are three men standing on the map. and, I talk to them to open the music window. The three men have different musics. like,first one has "Battle01".the second has "Battle02". and the other has "Theme01" or else. Sorry if it's make you confused.I dont' know how to explain it. If you can't do this,it's alright. I'm already satisfied with the script.

 

PS. - I tried to change the folder in the script, but what it did was change the whole one. I want it to separated.

Edited by Darkness

Share this post


Link to post
Share on other sites

im rather unsure of what you are asking, if you just want a single choice music selection you can set that up with events, just make a choice selection, and get your sound to play according to the choice

edit:

or are you asking to be able to configure what selections are shown?

edit2:

ok on the last assumption i came up with this:

 

 

#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
# Scene Audio
# Author: ForeverZer0
# Version: 1.0
# Date: 9.2.2012
# Edited by: Diagostimo
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#
# This script is for allowing the player to sample and play the game's audio.
# It has control for allowing adjustement of volume and pitch. All local and RTP
# resources are automatically found and categorized by type.
#
#   To call the scene:  $scene = Scene_Audio.new
#
#   EDIT NOTES
#   ----------
#   * you can still call the script like so: $scene = Scene_Audio.new, calling
#	 it like that will result in all sounds being displayed
#
#   * if you want to call the script to show only configured sounds then use:
#	 $scene = Scene_Audio.new(VALUE)
#
#   * the value will choose sounds defined below for the matching cases, just
#	 add new cases when setting up your sounds to be displayed, the value can
#	 be an interger or a string *"this is a string", although it is easyer to
#	 manage using integers
#
#   * you add all filenames for all categories(bgm, bgs etc...) into the one array,
#	 there is no need to seperate them
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#===============================================================================
# ** Resources
#===============================================================================
module Resources
 #----------------------------------#
 # Configuration for sounds to show #
 #----------------------------------#
 def self.music_choices(value)
   case value
   # when VALUE then return [ ARRAY OF SOUNDS ]
  when 1 then return [
    '001-Battle01', '002-Battle02', '003-Battle03', '004-Battle04', '005-Boss01',
    '006-Boss02', '007-Boss03', '008-Boss04'
    ]
   end
 end
 #-----------------------------------#
 #		 End Configuration		 #
 #-----------------------------------#
 #-----------------------------------------------------------------------------
 # * Constants
 #-----------------------------------------------------------------------------
 AUDIO_EXT = ['.mp3', '.ogg', '.wav', '.mid', '.wma']
 GRAPHIC_EXT = ['.png', '.jpg', '.bmp']
 #-----------------------------------------------------------------------------
 # * Gets an array of the game's RTP paths
 #-----------------------------------------------------------------------------
 def self.rtp_paths
   ini = Win32API.new('kernel32', 'GetPrivateProfileStringA', 'PPPPLP', 'L')
   library = "\0" * 256
   ini.call('Game', 'Library', '', library, 256, '.\\Game.ini')
   library.delete!("\0")
   rtp_path = Win32API.new(library, 'RGSSGetRTPPath', 'L', 'L')
   path_with_rtp = Win32API.new(library, 'RGSSGetPathWithRTP', 'L', 'P')
   paths = [1, 2, 3].collect {|id| path_with_rtp.call(rtp_path.call(id)) }
   return paths.find_all {|path| path != '' && File.directory?(path) }
 end
 #-----------------------------------------------------------------------------
 # * Gets a list of files found in the RTP directories
 #-----------------------------------------------------------------------------
 def self.rtp_files
   if @rtp_files == nil
  @rtp_files = []
  self.rtp_paths.each {|rtp| @rtp_files += Dir.glob(rtp + '/**/*') }
   end
   return @rtp_files
 end
 #-----------------------------------------------------------------------------
 # * Gets a list of files found in the local directories
 #-----------------------------------------------------------------------------
 def self.local_files
   if @local_files == nil
  @local_files = Dir.glob('./**/*')
   end
   return @local_files
 end
 #-----------------------------------------------------------------------------
 # * Gets a list of all audio files found locally and in the RTPs
 #-----------------------------------------------------------------------------
 def self.audio_files
   files = rtp_files.find_all {|f| AUDIO_EXT.include?(File.extname(f)) }
   files += local_files.find_all {|f| AUDIO_EXT.include?(File.extname(f))}
   return files
 end
 #-----------------------------------------------------------------------------
 # * Gets a list of all graphic files found locally and in the RTPs
 #-----------------------------------------------------------------------------
 def self.graphic_files
   files = rtp_files.find_all {|f| GRAPHIC_EXT.include?(File.extname(f)) }
   files += local_files.find_all {|f| GRAPHIC_EXT.include?(File.extname(f))}
   return files
 end
end
#===============================================================================
# ** Window_AudioOptions
#===============================================================================
class Window_AudioOptions < Window_Selectable
 #-----------------------------------------------------------------------------
 # * Object Initialization
 #-----------------------------------------------------------------------------
 def initialize
   super(320, 128, 320, 352)
   @column_max = 1
   @commands = ['BGM Volume', 'BGS Volume', 'ME Volume', 'SE Volume',
  'BGM Pitch', 'BGS Pitch', 'ME Pitch', 'SE Pitch']
   @params = [100, 80, 100, 80, 100, 100, 100, 100]
   @item_max = @commands.size
   refresh
   self.active = false
   self.index = -1
 end
 #-----------------------------------------------------------------------------
 # * Clear and redraw the window contents
 #-----------------------------------------------------------------------------
 def refresh
   if self.contents != nil
  self.contents = self.contents.dispose
   end
   self.contents = Bitmap.new(width - 32, @commands.size * 32)
   @commands.each_index {|i| draw_item(i) }
 end
 #-----------------------------------------------------------------------------
 # * Draw an item on the window
 #-----------------------------------------------------------------------------
 def draw_item(i)
   rect = Rect.new(0, i * 32, self.contents.width, 32)
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   self.contents.font.color = system_color
   self.contents.draw_text(4, i * 32, 280, 32, @commands[i])
   self.contents.font.color = normal_color
   self.contents.draw_text(4, i * 32, 280, 32, @params[i].to_s, 2)
 end
 #-----------------------------------------------------------------------------
 # * Get the volume for the given category
 #-----------------------------------------------------------------------------
 def volume(category)
   return @params[category]
 end
 #-----------------------------------------------------------------------------
 # * Get the pitch for the given category
 #-----------------------------------------------------------------------------
 def pitch(category)
   return @params[category + 4]
 end
 #-----------------------------------------------------------------------------
 # * Frame Update
 #-----------------------------------------------------------------------------
 def update
   super
   mod = nil
   mod = -5 if Input.repeat?(Input::LEFT)
   mod = -1 if Input.trigger?(Input::LEFT)
   mod = 5 if Input.repeat?(Input::RIGHT)
   mod = 1 if Input.trigger?(Input::RIGHT)
   if mod != nil
  i = self.index
  if self.index < 4
    @params[i] = [[@params[i] + mod, 100].min, 0].max
  else
    @params[i] = [[@params[i] + mod, 150].min, 50].max
  end
  $game_system.se_play($data_system.cursor_se)
  draw_item(i)
   end
 end
 #-----------------------------------------------------------------------------
 # * Update Help Text
 #-----------------------------------------------------------------------------
 def update_help
   if @help_window != nil
  @help_window.set_text('Use LEFT and RIGHT to change values')
   end
 end
end
#===============================================================================
# ** Window_AudioCommand
#===============================================================================
class Window_AudioCommand < Window_Selectable
 #-----------------------------------------------------------------------------
 # * Object Initialization
 #-----------------------------------------------------------------------------
 def initialize
   super(0, 64, 640, 64)
   self.contents = Bitmap.new(width - 32, height - 32)
   @item_max = 5
   @column_max = 5
   @commands = ['BGM', 'BGS', 'ME', 'SE', 'Options']
   refresh
   self.index = 0
 end
 #-----------------------------------------------------------------------------
 # * Clear and redraw the window contents
 #-----------------------------------------------------------------------------
 def refresh
   self.contents.clear
   for i in 0...@item_max
  draw_item(i)
   end
 end
 #-----------------------------------------------------------------------------
 # * Draw an item on the window
 #-----------------------------------------------------------------------------
 def draw_item(index)
   x = 4 + index * 128
   self.contents.draw_text(x, 0, 96, 32, @commands[index])
 end
 #-----------------------------------------------------------------------------
 # * Update the help text
 #-----------------------------------------------------------------------------
 def update_help
   text = case self.index
   when 0 then 'Background Music'
   when 1 then 'Background Sounds'
   when 2 then 'Musical Effects'
   when 3 then 'Sound Effects'
   when 4 then 'Change Audio Options'
   else ''
   end
   @help_window.set_text(text)
 end
end
#===============================================================================
# ** Window_Audio
#===============================================================================
class Window_Audio < Window_Selectable
 #-----------------------------------------------------------------------------
 # * Object Initialization
 #-----------------------------------------------------------------------------
 def initialize(filenames, files)
   super(0, 128, 320, 352)
   @filenames = filenames
   @files = files
   @current_files = []
   self.index = -1
   self.active = false
   change_category(0)
 end
 #-----------------------------------------------------------------------------
 # * Clear and redraw the window contents
 #-----------------------------------------------------------------------------
 def refresh
   if @current_files.size != 0
  self.contents = Bitmap.new(width - 32, @current_files.size * 32)
   else
  self.contents = Bitmap.new(width - 32, 32)
   end
   @item_max = @current_files.size
   @current_files.each_index {|i|
  file = File.basename(@current_files[i], File.extname(@current_files[i]))
  self.contents.draw_text(4, i * 32, 288, 32, file)
   }
 end
 #-----------------------------------------------------------------------------
 # * Changes the audio type to list and refresh
 #-----------------------------------------------------------------------------
 def change_category(category)
   @subfolder = case category
   when 0 then 'Audio/BGM'
   when 1 then 'Audio/BGS'
   when 2 then 'Audio/ME'
   when 3 then 'Audio/SE'
   else ''
   end
   if category == 4
  self.contents.clear
  return
   end
   @current_files = []
   files_to_add = @filenames.find_all {|f| f.include?(@subfolder) }
   if @files != nil
  (0...files_to_add.size).each {|i|
    file = File.basename(files_to_add[i], File.extname(files_to_add[i]))
    @current_files.push(files_to_add[i]) if Resources.music_choices(@files).include?(file)
  }
   else
  @current_files = files_to_add
   end
   refresh
 end
 #-----------------------------------------------------------------------------
 # * Get the currently selected filename
 #-----------------------------------------------------------------------------
 def audio_file
   if @subfolder == ''
  return ''
   end
   return @current_files[self.index]
 end

 def update_help
   if audio_file == ''
  @help_window.set_text('')
  return
   end
   @help_window.set_text(@subfolder + '/' + File.basename(audio_file))
 end
end

#===============================================================================
# ** Scene_Audio
#===============================================================================
class Scene_Audio
 def initialize(files=nil)
   @files = files
 end
 #-----------------------------------------------------------------------------
 # * Clear and redraw the window contents
 #-----------------------------------------------------------------------------
 def main
   $game_system.bgm_memorize
   $game_system.bgs_memorize
   $game_system.bgm_stop
   @help_window = Window_Help.new
   @command_window = Window_AudioCommand.new
   @command_window.active = true
   @command_window.help_window = @help_window
   @audio_window = Window_Audio.new(Resources.audio_files, @files)
   @audio_window.help_window = @help_window
   @options_window = Window_AudioOptions.new
   @options_window.help_window = @help_window
   Graphics.transition
   loop { Graphics.update; Input.update; update; break if $scene != self }
   Graphics.freeze
   @audio_window.dispose
   @command_window.dispose
   @options_window.dispose
   @help_window.dispose
   $game_system.bgm_restore
   $game_system.bgs_restore
 end
 #-----------------------------------------------------------------------------
 # * Get the current category index
 #-----------------------------------------------------------------------------
 def category
   return @command_window.index
 end
 #-----------------------------------------------------------------------------
 # * Frame Update
 #-----------------------------------------------------------------------------
 def update
   @help_window.update
   if @command_window.active
  update_command
  return
   elsif @audio_window.active
  update_audio
  return
   elsif @options_window.active
  update_options
  return
   end
 end
 #-----------------------------------------------------------------------------
 # * Update the command window
 #-----------------------------------------------------------------------------
 def update_command
   @command_window.update
   if Input.trigger?(Input::B)
  $game_system.se_play($data_system.cancel_se)
  $scene = Scene_Map.new
   elsif Input.trigger?(Input::C)
  $game_system.se_play($data_system.decision_se)
  @command_window.active = false
  if category == 4
    @options_window.active = true
    @options_window.index = 0
  else
    @audio_window.active = true
    @audio_window.index = 0
  end
   elsif Input.repeat?(Input::LEFT) || Input.repeat?(Input::RIGHT) ||
  Input.trigger?(Input::L) || Input.trigger?(Input::R)
  @audio_window.change_category(category)
   end
 end
 #-----------------------------------------------------------------------------
 # * Update the audio selection window
 #-----------------------------------------------------------------------------
 def update_audio
   @audio_window.update
   if Input.trigger?(Input::B)
  @audio_window.active = false
  @audio_window.index = -1
  @command_window.active = true
  $game_system.se_play($data_system.cancel_se)
   elsif Input.trigger?(Input::C)
  volume = @options_window.volume(category)
  pitch = @options_window.pitch(category)
  file = @audio_window.audio_file
  case category
  when 0 then Audio.bgm_play(file, volume, pitch)
  when 1 then Audio.bgs_play(file, volume, pitch)
  when 2 then Audio.me_play(file, volume, pitch)
  when 3 then Audio.se_play(file, volume, pitch)
  end
   end
 end
 #-----------------------------------------------------------------------------
 # * Update the audio options window
 #-----------------------------------------------------------------------------
 def update_options
   @options_window.update
   if Input.trigger?(Input::B)
  @options_window.active = false
  @options_window.index = -1
  @command_window.active = true
  $game_system.se_play($data_system.cancel_se)
   end
 end
end

 

 

let me know if thats what you mean :D

Edited by diagostimo

Share this post


Link to post
Share on other sites

Thank you! I'll try that after I got home on Saturday. (Now,I'm playing in the computer room at school.)

 

What I actually mean is that I want the song tables being separated by each people. maybe you got it right.

I'll reply after I've tried your script.

 

@ : I've tried that and it was very awesome!!! This was actually what I need! Thank you very much for everything you've done for me!

Edited by Darkness

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...