[XP] Music Player (Jukebox)

Started by Orici, October 09, 2009, 10:07:10 pm

Previous topic - Next topic

Orici

October 09, 2009, 10:07:10 pm Last Edit: October 10, 2009, 11:21:09 am by Orici
Music Player (Jukebox)
Authors: Tonyryu
Version: 1.0
Type:Music Player
Key Term: Misc Add-on



Introduction
This script creates a menu form where you can listen to any song you want.



Features


  • Reproduces BGM, BGS, ME and SE



Screenshots
Not needed


Demo
http://www.4shared.com/file/139862991/b887f975/Music_Player.html


Script

Spoiler: ShowHide

Place above MAIN

#==============================================================================
# ■ Window_JBliste
#------------------------------------------------------------------------------
# Script permettant d'afficher la liste des musiques du jukebox
# Créateur : Tonyryu
# Date : 12/10/2006
#==============================================================================
class Window_JBliste < Window_Selectable
 
 #--------------------------------------------------------------------------
 # ● initialize
 #--------------------------------------------------------------------------
 def initialize
   super(0, 100, 640, 380)
   
   # Add your music here [ "name_to_display", type, "file_without_extension"]
   # type : 1 : BGM
   #        2 : BGS
   #        3 : ME
   #        4 : SE
   @tabMusiques = [[ "Introduction" , 1, "034-Heaven01"],
                   [ "Theme Alex", 1, "014-Theme03"],
                   [ "Combat 1", 1, "002-Battle02"],
                   [ "Bruit de l'eau", 2 , "010-River01"] ]

   # Spécifier la fenêtre de sélection
   @column_max = 2
   # Récupérer le nombre de musique
   @item_max = @tabMusiques.size
   
   # Initialiser la Zone Bitmap avec une taille adapté au nombre de musique
   self.contents = Bitmap.new(width - 32, row_max * 32)
   # Définir la police d'écriture par défaut
   self.contents.font.name = $fontface
   self.contents.font.size = $fontsize
   self.index = 0
   
   refresh
 end
 
 #--------------------------------------------------------------------------
 # ● refresh
 #--------------------------------------------------------------------------
 def refresh
   # Effacer la zone Bitmap
   self.contents.clear

   # Pour toutes les musiques
   for i in 0..@item_max - 1
     x = 4 + i % 2 * (288 + 32)
     y = i / 2 * 32
     # Afficher les musique en 2 colonnes
     self.contents.draw_text(x , y, 212, 32, @tabMusiques[i][0], 0)
   end
 end
 
 #--------------------------------------------------------------------------
 # ● fichierMusique
 #--------------------------------------------------------------------------
 def fichierMusique
   return [@tabMusiques[@index][1] , @tabMusiques[@index][2]]
 end

end


#==============================================================================
# ■ Window_JBtitre
#------------------------------------------------------------------------------
# Script permettant d'afficher le titre jukebox
# Créateur : Tonyryu
# Date : 12/10/2006
# Version : 1.00
#==============================================================================
class Window_JBtitre < Window_Base
 
 #--------------------------------------------------------------------------
 # ● initialize
 #--------------------------------------------------------------------------
 def initialize
   super(0, 0, 640, 100)
   # Initialiser la Zone Bitmap
   self.contents = Bitmap.new(width - 32, height - 32)
   # Définir la police d'écriture
   self.contents.font.name = $fontface
   self.contents.font.size = 30
   self.contents.font.italic = true
   
   refresh
 end
 
 #--------------------------------------------------------------------------
 # ● refresh
 #--------------------------------------------------------------------------
 def refresh
   # Effacer la zone Bitmap
   self.contents.clear
   # Ecrire le titre
   self.contents.draw_text(0, 10, 608, 50, "Jukebox", 1)
 end

end

#==============================================================================
# ■ Scene_Jukebox
#------------------------------------------------------------------------------
# Script permettant de gérer le jukebox
# Créateur : Tonyryu
# Date : 12/10/2006
# Version : 1.00
#==============================================================================
class Scene_Jukebox
 def main
   
   # Prèparation des fenêtre
   @jbtitre_window = Window_JBtitre.new
   @jbliste_window = Window_JBliste.new

   # Boucle de transition, mise à jour graphique et entré clavier
   Graphics.transition
   # boucle
   loop do
     # Mise à jour graphique
     Graphics.update
     # Mise à jour des entrées clavier
     Input.update
     # Mise à jour de la class
     update

     # Si la scene n'existe plus, alors sortir de la boucle
     if $scene != self
       break
     end
   end
   # figer les graphiques
   Graphics.freeze
   # destruction des objets
   @jbtitre_window.dispose
   @jbliste_window.dispose
 end
 
 #--------------------------------------------------------------------------
 # ● update
 #--------------------------------------------------------------------------
 def update

   # Mettre à jour les fenêtres de groupe et de réserve
   @jbtitre_window.update
   @jbliste_window.update

   # si la touche B est appuyée
   if Input.trigger?(Input::B)
     # Alors, jouer le son "cancel"
     $game_system.se_play($data_system.cancel_se)
     # Revenir soit dans le menu (option 5, changeable), soit sur la map, soit sur le titre
     $scene = Scene_Menu.new(5)
     #$scene = Scene_Map.new
     #$scene = Scene_Title.new

     # Stoper tous les sons
     stopper_audio
     
     return
   end

   # si la touche C est appuyée
   if Input.trigger?(Input::C)
     # Stoper tous les sons
     stopper_audio
     
     # Récuperer le nom du fichier correspondant au choix effectué
     tabFichierMusique = @jbliste_window.fichierMusique
     type = tabFichierMusique[0]
     nomFichier = tabFichierMusique[1]
     
     case type
     when 1
       Audio.bgm_play("Audio/BGM/" + nomFichier,100,100)
     when 2
       Audio.bgs_play("Audio/BGS/" + nomFichier,100,100 )
     when 3
       Audio.me_play("Audio/ME/" + nomFichier,100,100)
     when 4
       Audio.se_play("Audio/SE/" + nomFichier,100,100)
     end
   end
 end
 
 #--------------------------------------------------------------------------
 # ● stopper_audio
 #--------------------------------------------------------------------------
 def stopper_audio
   # Stoper tous les sons
   Audio.bgm_stop
   Audio.bgs_stop
   Audio.me_stop
   Audio.se_stop
 end

 
end




Depending on your Maker version you may need this fix to solve a problem with fonts:
Replace Main with this
Spoiler: ShowHide


#=================================
# Main
#------------------------------------------------------------------
#=================================

begin
 # Change the $fontface variable to change the font style
$defaultfonttype = $fontface = $fontname = Font.default_name = "Times New Roman"
# Font size used
$defaultfontsize = $fontsize = Font.default_size =  18
$showm = Win32API.new 'user32', 'keybd_event', %w(l l l l), ''
unless $DEBUG
$showm.call(18,0,0,0)
$showm.call(13,0,0,0)
$showm.call(13,0,2,0)
$showm.call(18,0,2,0)
end
# Font type
$defaultfonttype = $fontface = $fontname = Font.default_name = "Times New Roman"
# Font size
$defaultfontsize = $fontsize = Font.default_size =  20
Graphics.freeze
$scene = Scene_Title.new
while $scene != nil
$scene.main
end
Graphics.transition(20)
rescue Errno::ENOENT
filename = $!.message.sub("No such file or directory - ", "")
print("Archivo #{filename} no encontrado.")
end




Instructions

To call the scene use
$scene = Scene_Jukebox.new





Compatibility

Not tested with SDK.


Credits and Thanks


  • Tonyryu - for creating it
  • Orici - small translation



Author's Notes
You may find the autor here:
http://rpgmxpstudio.pellnet.ch/

Starrodkirby86

Ooh, interesting find you got there~

If you want this submitted in the Database, then it needs to follow the Script Template exactly. No ifs, ands, or buts.

Here's the template: http://forum.chaos-project.com/index.php?topic=17.0

Also, it might help if you have a Demo showing this. o; Though I think I can see how this works already. Nice find though ^^

What's osu!? It's a rhythm game. Thought I should have a signature with a working rank. ;P It's now clickable!
Still Aqua's biggest fan (Or am I?).




Orici

OK i updated the main post, and I posted a font fix, just in case you are using a different XP version  :)