Akianzax

Akián~RGSS3 Sala Músical

May 30th, 2014
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 32.99 KB | None | 0 0
  1. #===============================================================================
  2. #                          ~  Akián RGSS3 ~                    
  3. # Autor: Akián RGSS3
  4. # Fecha: 30/05/2014
  5. # Nombre del script: Sala músical
  6. # Requiere: Las imagenes alojadas en la demo Graphics\Pictures y Graphics\System
  7. # Versión: 1.5
  8. #===============================================================================
  9.  
  10. # Historial 1.0 Comienzo del script
  11. #           1.1 Métodos de alias
  12. #           1.2 Posibilidad de edición
  13. #           1.3 Wiindowskin y Background srcoll editables
  14. #           1.4 Correjido switch que habilita las canciones
  15. #           1.5 Mejora del modulo
  16.  
  17. #===============================================================================
  18. # Este script te da la posibilidad de llamar a una scene (o tenerla en el menú)
  19. # con canciones que tengas en tu carpeta de BGM's
  20. # Sirve para tener una sala músical dónde puedes manipular el volumen
  21. # el pitch y la posición en la que se escuchara (esto último solo para audios
  22. # OGG y WAV)
  23. # Muchisimas cosas editables, de manejo fácil para aquellos que no scriptean.
  24. #===============================================================================
  25.  
  26. #===============================================================================
  27. # Condiciones de uso:
  28. # Puedes usar libremente este script en proyectos comerciales y no comerciales
  29. # Los créditos son requeridos, por el trabajo, el esfuerzo, el sudor, bueno no
  30. # tanto por el sudor.
  31. # Si posteas este script en algún foro debes señalar la página oficial
  32. # http://akianzax.wix.com/akian-rgss3
  33. # También nombrar la página en los créditos si lo usas para un proyecto.
  34. #===============================================================================
  35.  
  36. $imported = {} if $imported.nil?
  37. $imported["AR3_SalaMusical"] = true
  38.  
  39. #===============================================================================
  40. # Modulo
  41. #===============================================================================
  42. module AKIAN_BGM    
  43.   module SOUND_TEST
  44. #===============================================================================
  45. #
  46. #                                REGION EDITABLE
  47. #
  48. #===============================================================================
  49.  
  50.     MENUCOMMAND     = "Sala Musical"   # Nombre del comando en el menu
  51.     SOUND_SELECT_WH = "Reproduce tus listas de música favoritas
  52. Presiona X para salir." #Descripción de ayuda | las lineas se mostrarán
  53. # tal cual estan.
  54.     MENU_ACCES = false     # true para que se pueda entrar desde el menu
  55.                            # false para que no aparesca en el menu
  56.                          
  57. # Si lo dejas en false puedes llamar la escena mediante el siguiente comando
  58. # en los scripts (3ra página de los eventos, Scripts)
  59. #
  60. # SceneManager.call(Scene_Sound)
  61. #
  62. # Solo por si no quieres que este la música disponible todo el tiempo
  63.  
  64.     BACKGROUND_SCROLL     = true  # true activa el background en movimiento
  65.                                   # false lo desactiva
  66.                                  
  67.     SCROLL_MOVE           = 3     # velocidad del scroll
  68.                          
  69.     WINDOW_SKIN           = "Window2" # Nombre del windowskin que usarán
  70. # Por default el skin de rpgmaker es "Window" pero pueden usar otro, como
  71. # el la demo que tiene el nombre de "Window2"
  72.  
  73. #===============================================================================
  74. # Texto mostrado en la ventana de ayuda al seleccionar "Reproducir"  
  75. #===============================================================================
  76.     SOUND_SELECT_WH_PLAY      = "Reproducir"
  77.     SOUND_SELECT_WH_PLAY2     = "(Volumen y pitch por defecto)"
  78. #===============================================================================
  79. # Texto mostrado en la ventana de ayuda al seleccionar "Volumen"
  80. #===============================================================================    
  81.     VOLUMEN_SELECT_WH_PLAY    = "Elije el volumen"
  82.     VOLUMEN_SELECT_WH_PLAY2   = ""
  83.  
  84. #===============================================================================
  85. # Texto mostrado en la ventana de ayuda al seleccionar "Pitch"
  86. #===============================================================================        
  87.     PITCH_SELECT_WH_PLAY      = "Selecciona el pitch"
  88.  
  89. #===============================================================================
  90. # Texto mostrado en la ventana de ayuda al seleccionar "Posición"
  91. #===============================================================================        
  92.     POSITION_SELECT_WH_PLAY   = "Reproduce en la posición ¿?"
  93.     POSITION_SELECT_WH_PLAY2   = "(Solo funciona para OGG)"
  94.    
  95. #===============================================================================
  96. # Aquí puedes editar las canciones que vas a permitir que aparescan dentro de
  97. # la sala músical
  98. #===============================================================================        
  99.     NUMBER_INPUT_HELP         = "Elije un valor
  100. Z para reproducir"  # Vetana de información
  101.  
  102. # Como recomendación usen este template
  103.  
  104. #     "Nombre de la cancion en la carpeta BGM" =>
  105. #     {
  106. #     :display_name => "Nombre que se mostrará",
  107. #     :default_volume => 100,
  108. #     :default_pitch => 100,
  109. #     :conditional_switch => 0,
  110. #     :info_line1 => "Información en la linea 1",
  111. #     :info_line2 => "Información en la linea 2",
  112. #     :info_line3 => "Información en la linea 3",
  113. #     :info_line4 => "Información en la linea 4",
  114. #     },
  115.  
  116.     SONIDOS = { # No tocar este simbolo
  117.  
  118. #===============================================================================
  119. # Debes borrar las canciones aquí debajo puesto que son las que yo tengo
  120. # en mi carpeta de BGM, solo muestran cómo se debe colocar correctamente para
  121. # que aparesca en la pantalla de la escena
  122. #===============================================================================
  123.  
  124.     "Guilty Crown - Ending" =>
  125.     {
  126.     :display_name => "Guilty Crown Ending",
  127.     :default_volume => 100,
  128.     :default_pitch => 100,
  129.     :conditional_switch => 0,
  130.     :info_line1 => "Autor: SuperCell",
  131.     :info_line2 => "Anime: Guilty Crown",
  132.     :info_line3 => "Ending 1",
  133.     :info_line4 => "Cd: Departures",
  134.     },
  135.    
  136.     "Guilty Crown ending 2" =>
  137.     {
  138.     :display_name => "Guilty Crown Ending 2",
  139.     :default_volume => 100,
  140.     :default_pitch => 100,
  141.     :conditional_switch => 0,
  142.     :info_line1 => "Autor: SuperCell",
  143.     :info_line2 => "Anime: Guilty Crown",
  144.     :info_line3 => "Ending 2",
  145.     :info_line4 => "Cd: Departures",
  146.     },
  147.    
  148.         "Tetris - Hardstyle ( Remix ) NEW 2009-[www.flv2mp3.com]" =>
  149.     {
  150.     :display_name => "Tetris Hardstyle Remix",
  151.     :default_volume => 100,
  152.     :default_pitch => 100,
  153.     :conditional_switch => 0,
  154.     :info_line1 => "Autor: Desconocido",
  155.     :info_line2 => "Remix de Tetris",
  156.     :info_line3 => "Plataforma: Family",
  157.     :info_line4 => "Cd: - - - -",
  158.     },
  159.  
  160.    
  161.     } # No tocar este simbolo
  162.    
  163. #==============================================================================
  164. #
  165. #                       FIN DE LA REGION EDITABLE
  166. #
  167. #==============================================================================
  168.   end
  169. end
  170.  
  171. # Vas a editar a partir de acá? OMG
  172. # Muere pium pium
  173.  
  174. class Sonido_Test_Sonido
  175. include  AKIAN_BGM::SOUND_TEST
  176. #=============================================================================
  177. # Public instances variables / variables de instancia pública
  178. #=============================================================================
  179. attr_accessor  :name
  180. attr_accessor  :volume
  181. attr_accessor  :pitch
  182.  
  183. def initialize( name, volume, pitch )
  184.   @name        = name
  185.   @volume      = volume
  186.   @pitch       = pitch
  187. end
  188. #=============================================================================
  189. # Play Sound / Reproduce el bgm
  190. #=============================================================================
  191. def play
  192.   RPG::BGM.stop
  193.   RPG::BGM.new( name, volume, pitch ).play
  194. end
  195.  
  196. #=============================================================================
  197. # Play at position / reproduce en la posición
  198. #=============================================================================
  199. def play_position( position )
  200.    RPG::BGM.stop
  201.    RPG::BGM.new( name, volume, pitch ).play( position )
  202. end
  203.  
  204. #=============================================================================
  205. # Play Default Sound / Reproduce el bgm default
  206. #=============================================================================
  207. def default_play
  208.     RPG::BGM.stop
  209.     RPG::BGM.new( name, SONIDOS[name][:default_volume], SONIDOS[name][:default_pitch] ).play
  210.   end
  211. end
  212.  
  213.  
  214.  
  215. #=============================================================================
  216. # Scene Sound
  217. #=============================================================================
  218. class Scene_Sound < Scene_Base
  219.   include AKIAN_BGM::SOUND_TEST
  220. #--------------------------------------------------------------------------
  221. # ▼ Proceso de comienzo
  222. #--------------------------------------------------------------------------
  223.   def start
  224.      super()
  225.      # BGM reproducido en mapa
  226.      @bgm_map_sound     =   RPG::BGM.last
  227.      create_soundbgm_file_array()
  228.      
  229.      bgm_play_windows()
  230.      
  231.      create_help_windows()
  232.      
  233.     # Window_Playbgm_Number < Window_NumberInput
  234.     # Seteando number input
  235.       @input_window               = Window_Playbgm_Number.new
  236.       @input_window.z             = 200
  237.      
  238.     # Symbolo señalado actualmente (canción sobre la que esta el cursor)
  239.      @sound_current_symbol          = nil
  240.      
  241.     # Input variables
  242.      set_input_variables()
  243.      
  244.     # Creando Fondo y Scroll
  245.      create_background
  246.      background_scroll
  247.    
  248.   end
  249.  
  250.  
  251. #===============================================================================
  252. # Post proceso de comienzo
  253. #===============================================================================
  254.   def post_start
  255.     super()
  256.   end
  257. #===============================================================================
  258. # Actualización de frames
  259. #===============================================================================
  260.   def update
  261.     super()
  262.      update_window_text()
  263.      update_help_text()
  264.      
  265.      return_scene && Sound.play_cancel                       if Input.trigger?(:B) && @sound_select.active
  266.      deactivate_soundplaycommand_window && Sound.play_cancel if Input.trigger?(:B) && @reproduce_musica_ventana.active
  267.      
  268.      check_user_input()
  269.  
  270. end
  271. #===============================================================================
  272. # Actualización de frames básica
  273. #===============================================================================
  274.   def update_basic
  275.     super()
  276.     @sound_help.x               -= 10  if @sound_help.x > 0
  277.     @background.ox              += background_scroll if BACKGROUND_SCROLL
  278.     Graphics.update
  279.   end
  280. #===============================================================================
  281. # Pre Temrminado
  282. #===============================================================================  
  283.   def pre_terminate
  284.    super()
  285.    @bgm_map_sound.replay  
  286.   end  
  287. #===============================================================================
  288. # Proceso de terminado
  289. #===============================================================================
  290.   def terminate
  291.     super()
  292.   execute_dispose
  293. end
  294. #===============================================================================
  295. # Creando ventanas de ayuda
  296. #===============================================================================
  297.     def create_help_windows()
  298.      # Ventana de ayuda
  299.      @sound_help    = Window_Ayuda.new    
  300.      @sound_help.x  = 250
  301.      @sound_help.set_text(SOUND_SELECT_WH)
  302.      @sound_help.opacity = 170
  303.      
  304.  
  305.      
  306.     # Ventana de descipcion de la reproducción actual
  307.      @sound_description           = Scene_Sala_Musical.new
  308.      @sound_description.x         = Graphics.width * 0.5
  309.      @sound_description.y         = 192
  310.      @sound_description.open
  311.      @sound_description.opacity   = 170
  312.      
  313.     end
  314.    
  315. #===============================================================================
  316. # Creando BGM.stop BGM.replay para detener y reanudar los BGM's del mapa
  317. #===============================================================================
  318.     def bgm_play_windows()
  319.      sound_window_y = 72 # Posición Y de la ventana para seleccionar Música
  320.      sound_window_x = 0  # Posición X de la ventana para seleccionar Música        
  321.    
  322.     # Ventana de selección de música
  323.      @sound_select = Sala_Musical.new(sound_window_x, sound_window_y)
  324.      @sound_select.height = Graphics.height - sound_window_y
  325.      @sound_select.opacity = 170
  326.      
  327.      command_window_set_handler
  328.     # Ventana de comandos para reproducir
  329.    
  330.      @reproduce_musica_ventana = Sala_Musical_Seleccion.new(Graphics.width * 0.5, sound_window_y)
  331.      @reproduce_musica_ventana.deactivate    # desactivar ventana principal
  332.      @reproduce_musica_ventana.opacity = 170
  333.      command_playsound_set_handler()
  334.    end
  335.    
  336. # Set command handler / Seteando el manejador de comandos
  337.     def command_window_set_handler()
  338.     SONIDOS.each_key do |key_name|
  339.    @sound_select.set_handler(key_name.to_sym,      method(:deactivate_soundcommand_window))
  340.   end
  341. end
  342.  
  343. # Set sound handler / Seteando manejador de sonidos
  344.     def command_playsound_set_handler()
  345.   @reproduce_musica_ventana.set_handler(:reproduce_musica, method(:play_sound_cmmd))  
  346.   @reproduce_musica_ventana.set_handler(:volume,           method(:play_sound_at_volume))
  347.   @reproduce_musica_ventana.set_handler(:pitch,            method(:play_sound_at_pitch))
  348.   @reproduce_musica_ventana.set_handler(:position,         method(:play_sound_at_position))
  349. end
  350.  
  351. # Play sound command / Comando de reproducción
  352.    def play_sound_cmmd()
  353.      @sound_files_hash[@sound_current_symbol.to_s].default_play  
  354.      @reproduce_musica_ventana.activate
  355.      
  356.    end
  357.    def check_user_input()
  358.       if @user_current_value  && @input_window.completed  
  359.      recive_volume_value     if @current_volume_value
  360.      recive_pitch_value      if @current_pitch_value
  361.      recive_position_value   if @current_position_value
  362.    end
  363.  end
  364.  
  365. #===============================================================================
  366. # Play Sound At Volume / Reproduce sonido y volumen
  367. #===============================================================================
  368.    def play_sound_at_volume
  369.      deactivate_soundcommand_windows()
  370.      @user_current_value = true
  371.      @current_volume_value = true
  372.      number = @sound_files_hash[@sound_current_symbol.to_s].volume
  373.      @input_window.start( number , 3 )
  374.    end
  375. #===============================================================================
  376. # Play Sound At Pitch / Reproduce sonido y pitch
  377. #===============================================================================
  378.    def play_sound_at_pitch
  379.      deactivate_soundcommand_windows()
  380.      @user_current_value = true
  381.      @current_pitch_value = true
  382.      number = @sound_files_hash[@sound_current_symbol.to_s].pitch
  383.      @input_window.start( number , 3 )
  384.    end
  385. #===============================================================================
  386. # Play Sound At Position / Reproduce sonido en la posición
  387. #===============================================================================
  388.    def play_sound_at_position
  389.      deactivate_soundcommand_windows()
  390.      @user_current_value = true
  391.      @current_position_value = true
  392.      @input_window.start( 0 , 9 )
  393.    end  
  394.    
  395. #===============================================================================
  396. # Recive volume value / Recibe Valor al volumen
  397. #===============================================================================
  398.    def recive_volume_value
  399.    if @input_window.procces_ok
  400.  
  401.     @sound_files_hash[@sound_current_symbol.to_s].volume = @input_window.result
  402.     @sound_files_hash[@sound_current_symbol.to_s].play
  403.    end
  404.    @reproduce_musica_ventana.activate
  405.    set_input_variables()
  406.  end
  407. #===============================================================================
  408. # Recive pitch value / Recibe Valor al pitch
  409. #===============================================================================
  410.    def recive_pitch_value
  411.    if @input_window.procces_ok
  412.  
  413.     @sound_files_hash[@sound_current_symbol.to_s].pitch = @input_window.result
  414.     @sound_files_hash[@sound_current_symbol.to_s].play
  415.   end  
  416.     @reproduce_musica_ventana.activate
  417.      set_input_variables()
  418. end
  419.  
  420. #===============================================================================
  421. # Recive position value / Recibe Valor a la  posición
  422. #===============================================================================
  423.    def recive_position_value
  424.    if @input_window.procces_ok
  425.    @sound_files_hash[@sound_current_symbol.to_s].play_position( @input_window.result )
  426.  end
  427.     @reproduce_musica_ventana.activate
  428.      set_input_variables()
  429. end  
  430. #===============================================================================
  431. # deactivate sound command window / Desactivar comandos en la ventana de sonidos
  432. #===============================================================================
  433.    def deactivate_soundcommand_windows()
  434.    @sound_select.deactivate()
  435.    @reproduce_musica_ventana.deactivate()
  436.  end
  437.  
  438. # Set command handler deactivate  
  439.  
  440.    def deactivate_soundcommand_window()
  441.    @sound_select.deactivate()
  442.    @reproduce_musica_ventana.activate()
  443.  end
  444.  
  445. # Set command handler deactivate soundplay
  446.  
  447.    def deactivate_soundplaycommand_window()
  448.    @sound_select.activate()
  449.    @reproduce_musica_ventana.deactivate()
  450.  end
  451.  
  452.    
  453. # Create background  
  454.    def create_background
  455.     @background                 = Plane.new
  456.     @background.bitmap          = Cache.picture("Background_M")
  457.     @background.z               = 2
  458.   end
  459.  
  460. #  Backgroun scroll  
  461.   def background_scroll
  462.     back_x                      = SCROLL_MOVE
  463.   end
  464.  
  465. #===============================================================================
  466. # Actualización de la ventana de texto
  467. #===============================================================================  
  468.   def update_window_text()
  469.   if @sound_current_symbol != @sound_select.current_symbol
  470.      @sound_current_symbol  = @sound_select.current_symbol
  471.   text  = SONIDOS[@sound_current_symbol.to_s][:info_line1].gsub("\n", "") + "\n"
  472.   text += SONIDOS[@sound_current_symbol.to_s][:info_line2].gsub("\n", "") + "\n"
  473.   text += SONIDOS[@sound_current_symbol.to_s][:info_line3].gsub("\n", "") + "\n"
  474.   text += SONIDOS[@sound_current_symbol.to_s][:info_line4].gsub("\n", "")
  475.   @sound_description.draw_text_sound_info(text)
  476.   end
  477.  end
  478.  
  479. #===============================================================================
  480. # Crear metodo en array
  481. #===============================================================================  
  482.   def create_soundbgm_file_array  
  483.    @sound_files_hash    = {}
  484.    SONIDOS.each_key do |key_name|
  485.    @sound_files_hash[key_name] = Sonido_Test_Sonido.new(key_name, SONIDOS[key_name][:default_volume], SONIDOS[key_name][:default_pitch])
  486.   end
  487. end
  488.  
  489. #===============================================================================
  490. # Actualización de la ventana ayuda
  491. #===============================================================================  
  492.   def update_help_text()  
  493.   # Si Sound_Select esta activo
  494.    if @sound_select.active
  495.    @sound_help.set_text(SOUND_SELECT_WH)
  496.   # Si input_window esta activo
  497.   elsif @input_window.active
  498.     @sound_help.set_text(NUMBER_INPUT_HELP)
  499.   # Si reproduce_music
  500.   elsif @reproduce_musica_ventana.current_symbol == :reproduce_musica
  501.     @sound_help.set_text(SOUND_SELECT_WH_PLAY + "\n" + SOUND_SELECT_WH_PLAY2)
  502.   # Si volumen
  503.   elsif @reproduce_musica_ventana.current_symbol  == :volume
  504.     @sound_help.set_text(VOLUMEN_SELECT_WH_PLAY + "\n" + VOLUMEN_SELECT_WH_PLAY2)
  505.   # Si pitch
  506.   elsif @reproduce_musica_ventana.current_symbol == :pitch
  507.     @sound_help.set_text(PITCH_SELECT_WH_PLAY)
  508.   # Si position
  509.   else
  510.     @sound_help.set_text(POSITION_SELECT_WH_PLAY+ "\n" + POSITION_SELECT_WH_PLAY2)
  511.   end
  512.    
  513. end
  514.  
  515. #===============================================================================
  516. # Set input variables / Seteando variables
  517. #===============================================================================  
  518.  def set_input_variables()
  519.    
  520.      @user_current_value            = false
  521.      @current_volume_value          = false
  522.      @current_pitch_value           = false
  523.      @current_position_value        = false
  524.   end
  525.  
  526. #===============================================================================
  527. # Ejecutar el dispose de todo lo creado a menos que ya este disposed
  528. #===============================================================================  
  529.    def execute_dispose
  530.     @background.bitmap.dispose        unless @background.bitmap.disposed?
  531.     @background.dispose               unless @background.disposed?
  532.     @sound_select.dispose             unless @sound_select.disposed?
  533.     @sound_help.dispose                                 unless @sound_help.disposed?
  534.     @sound_description.dispose                          unless @sound_description.disposed?
  535.     @reproduce_musica_ventana.dispose unless @reproduce_musica_ventana.disposed?
  536.     @input_window.dispose             unless @input_window.disposed?
  537.   end
  538. end
  539.  
  540. if AKIAN_BGM::SOUND_TEST::MENU_ACCES
  541.  
  542. #==============================================================================
  543. # Clase Window
  544. #==============================================================================
  545.  
  546. class Window_MenuCommand < Window_Command
  547.  
  548. #=============================================================================
  549. #  Método de alias
  550. #=============================================================================
  551. alias akian_salamusical_zack      add_game_end_command
  552. #--------------------------------------------------------------------------
  553. # ▼ Añadiendo Sala de Música a los comandos
  554. #--------------------------------------------------------------------------
  555.   def add_game_end_command
  556.     add_command(AKIAN_BGM::SOUND_TEST::MENUCOMMAND,   :musica,   true)
  557.    
  558.     akian_salamusical_zack   # Método de Alias
  559.     end
  560.   end
  561. end
  562.  
  563. #===============================================================================
  564. # Scene Menu < Scene_MenuBase añadiendo comando a la escena
  565. #===============================================================================
  566. class Scene_Menu
  567.   alias akian_addcommand_musica_zack  create_command_window
  568.   def create_command_window
  569.     akian_addcommand_musica_zack
  570.     @command_window.set_handler(:musica,      method(:command_musica))
  571.   end
  572.  
  573.   def command_musica
  574.     SceneManager.call(Scene_Sound)
  575.   end
  576. end
  577.  
  578. #===============================================================================
  579. # Sala musical commando
  580. #===============================================================================
  581.  
  582. class Sala_Musical < Window_Command
  583.       include AKIAN_BGM::SOUND_TEST
  584.      
  585. #===============================================================================
  586. # Ancho de la ventana
  587. #===============================================================================
  588.     def window_width
  589.     return Graphics.width  * 0.5
  590.   end
  591.  
  592.     def update_tone
  593.     self.windowskin  = Cache.system(WINDOW_SKIN)
  594.     self.tone.set($game_system.window_tone) unless WINDOW_SKIN != "Window"
  595.   end
  596. #===============================================================================
  597. # Lista de comando
  598. #===============================================================================  
  599.    
  600. def make_command_list  
  601.    
  602.     SONIDOS.each_key do |key_name|
  603.      
  604.     sounds_id = SONIDOS[key_name][:conditional_switch]
  605.    
  606.     next unless $game_switches [sounds_id] || sounds_id == 0
  607.    
  608.     add_command(SONIDOS[key_name][:display_name], key_name.to_sym)
  609.  
  610.      
  611.     end
  612.   end  
  613.  
  614. end
  615. #===============================================================================
  616. # Clase Sala_Musical_Seleccion < Window_Command
  617. #===============================================================================
  618.  
  619. class Sala_Musical_Seleccion < Window_Command
  620.       include AKIAN_BGM::SOUND_TEST
  621.      
  622.   def update_tone
  623.     self.windowskin  = Cache.system(WINDOW_SKIN)
  624.     self.tone.set($game_system.window_tone) unless WINDOW_SKIN != "Window"
  625.   end
  626.  
  627.  
  628. #===============================================================================
  629. # Ancho de la ventana
  630. #===============================================================================
  631.     def window_width
  632.     return Graphics.width  * 0.5
  633.   end
  634.  
  635. #===============================================================================
  636. # Lista de comando
  637. #===============================================================================  
  638.    
  639. def make_command_list  
  640.  
  641.   add_command("Reproduce tu música", :reproduce_musica)
  642.   add_command("Volumen",             :volume)
  643.   add_command("Pitch",               :pitch)
  644.   add_command("Posición",            :position)
  645.  
  646.   end
  647. end
  648.  
  649. #==============================================================================
  650. #  Esta ventana se usa para mostrar el texto de la Sala Musical
  651. #==============================================================================
  652.  
  653. class Scene_Sala_Musical < Window_Message
  654.   include  AKIAN_BGM::SOUND_TEST
  655.  
  656.   def initialize
  657.     super()
  658.     self.windowskin  = Cache.system(WINDOW_SKIN)
  659.   end
  660.  
  661.   def update_tone
  662.     self.tone.set($game_system.window_tone) unless WINDOW_SKIN != "Window"
  663.   end
  664.  
  665. #===============================================================================
  666. # ▼  Set Fond
  667. #===============================================================================  
  668.   def set_fond
  669.     contents.font.size = 22
  670.     contents.font.italic = true    
  671.   end
  672.  
  673. #==============================================================================
  674. #  ▼ Ancho de la ventana
  675. #==============================================================================
  676.   def window_width
  677.     return Graphics.width * 0.5
  678.   end       #End Def
  679. #==============================================================================
  680. #  ▼ Alto de la ventana
  681. #==============================================================================
  682.   def window_height
  683.     return Graphics.height - 192
  684.   end #End Def
  685. #==============================================================================
  686. #  ▼ Texto de la ventana de descripción
  687. #==============================================================================
  688.   def draw_text_sound_info(text)
  689.     contents.clear  # Borra el contenido al pasar al siguiente objeto
  690.     set_fond
  691.     draw_text_ex(0 , 0, word_wrapping(text))
  692.   end         #End Def
  693.  
  694. #==============================================================================
  695. #  ▼ Para que no resetee el font.
  696. #==============================================================================  
  697.   def draw_text_ex(x, y, text)
  698.     text = convert_escape_characters(text)
  699.     pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
  700.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  701.   end  
  702. #===============================================================================
  703. # ▼  Para no usar metodos.
  704. #===============================================================================  
  705.     def wait_for_one_character()    
  706.     end        # End Def
  707.    
  708. #===============================================================================
  709. # ▼  Word Wrapping
  710. #===============================================================================
  711.     def word_wrapping(text, pos = 0)
  712.      
  713.       # Current Text Position
  714.       current_text_position = 0    
  715.        
  716.       for i in 0..(text.length - 1)
  717.        
  718.         if text[i] == "\n"
  719.           current_text_position = 0
  720.           next
  721.         end
  722.        
  723.   # Current Position += character width
  724.    current_text_position += contents.text_size(text[i]).width
  725.        
  726.     # If Current Position > Window Width
  727.     if current_text_position >= contents.width
  728.     # Then Format the Sentence to fit Line
  729.       current_element = i
  730.       while(text[current_element] != " ")
  731.       break if current_element == 0
  732.       current_element -= 1
  733.       end
  734.          
  735.       temp_text = ""
  736.       for j in 0..(text.length - 1)
  737.       temp_text += text[j]
  738.       temp_text += "\n" if j == current_element
  739.       end
  740.       text = temp_text
  741.       i = current_element
  742.       current_text_position = 0
  743.     end
  744.   end
  745. return text      
  746.         # End Class
  747.   end
  748. end
  749.  
  750. #==============================================================================
  751. # ▼ Window_NumberInput
  752. #==============================================================================
  753.  
  754. #==============================================================================
  755. #  Class Window_Playbgm_Number < Window_NumberInput
  756. #==============================================================================
  757.  
  758. class Window_Playbgm_Number < Window_NumberInput
  759.  include AKIAN_BGM::SOUND_TEST
  760. #==============================================================================
  761. # ▼ Public Instances variables / Variables de instancia publica
  762. #==============================================================================
  763.    attr_reader  :result     # El resultado del input del usuario
  764.    attr_reader  :completed  # User finish input procesing
  765.    attr_reader  :procces_ok # User Finish Input
  766.    
  767. #==============================================================================
  768. # ▼ Inicializando el objeto
  769. #==============================================================================
  770.  
  771.   def initialize()
  772.     super( self )
  773.     self.windowskin = Cache.system(WINDOW_SKIN)
  774.     @result      = 0
  775.     @completed   = true
  776.     @procces_ok  = false
  777.   end
  778.  
  779.   def update_tone
  780.     self.tone.set($game_system.window_tone) unless WINDOW_SKIN != "Window"
  781.   end
  782.  
  783. #==============================================================================
  784. # ▼ Comenzando el proceso de Number Input
  785. #==============================================================================
  786.   def start( number, digits )
  787.     @digits_max = digits
  788.     @number     = number
  789.     @index      = 0
  790.     @completed  = false
  791.     update_placement
  792.     create_contents
  793.     refresh
  794.     open
  795.     activate
  796.   end
  797.  
  798.     def update_placement
  799.     self.width  = @digits_max * 20 + padding * 2
  800.     self.height = fitting_height(1)
  801.     self.x      = (Graphics.width - width) / 2
  802.     self.y      = 192
  803.   end
  804. #==============================================================================
  805. # ▼ Proceso cuando el boton de ok esta siendo presionado
  806. #==============================================================================
  807.   def process_ok
  808.     Sound.play_ok
  809.     @result          = @number
  810.     @completed       = true
  811.     @procces_ok      = true
  812.     deactivate
  813.     close
  814.   end
  815. #==============================================================================
  816. # ▼ Proceso cuando el boton de cancelar esta siendo presionado
  817. #==============================================================================
  818.   def process_cancel
  819.     @completed   = true
  820.     @procces_ok  = false
  821.     deactivate
  822.     close
  823.   end  
  824. end
  825.  
  826. #==============================================================================
  827. #  Seteando ventana de ayuda
  828. #==============================================================================
  829.  
  830. class Window_Ayuda < Window_Base
  831.   include AKIAN_BGM::SOUND_TEST
  832.   #--------------------------------------------------------------------------
  833.   # * Object Initialization
  834.   #--------------------------------------------------------------------------
  835.   def initialize(line_number = 2)
  836.     super(0, 0, Graphics.width, fitting_height(line_number))
  837.     self.windowskin  = Cache.system(WINDOW_SKIN)
  838.   end
  839.  
  840.   def update_tone
  841.     self.tone.set($game_system.window_tone) unless WINDOW_SKIN != "Window"
  842.   end  
  843.   #--------------------------------------------------------------------------
  844.   # * Set Text
  845.   #--------------------------------------------------------------------------
  846.   def set_text(text)
  847.     if text != @text
  848.       @text = text
  849.       refresh
  850.     end
  851.   end
  852.   #--------------------------------------------------------------------------
  853.   # * Clear
  854.   #--------------------------------------------------------------------------
  855.   def clear
  856.     set_text("")
  857.   end
  858.   #--------------------------------------------------------------------------
  859.   # * Set Item
  860.   #     item : Skills and items etc.
  861.   #--------------------------------------------------------------------------
  862.   def set_item(item)
  863.     set_text(item ? item.description : "")
  864.   end
  865.   #--------------------------------------------------------------------------
  866.   # * Refresh
  867.   #--------------------------------------------------------------------------
  868.   def refresh
  869.     contents.clear
  870.     draw_text_ex(4, 0, @text)
  871.   end
  872. end
  873.  
  874. #===============================================================================
  875. #
  876. #                 ▼ Fin del mundo, acá se acaba todo
  877. #                         ~  Akián RGSS3 ~
  878. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment