Advertisement
Holy87

Info gioco - ACE

Feb 9th, 2015
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 12.64 KB | None | 0 0
  1. $imported = {} if $imported == nil
  2. $imported["H87A_Infos"] = true
  3. #===============================================================================
  4. # Info Gioco di Holy87 - Ace
  5. # Versione 1.1
  6. # 11/02/2014 -> Aggiornamento v. 1.1
  7. # 24/08/2012 -> Script convertito per VX Ace
  8. #===============================================================================
  9. # Questo script permette di visualizzare informazioni e crediti nella schermata
  10. # del titolo del tuo gioco. Comprende lo scroll cinetico, visualizza il numero
  11. # di versione (nel caso tu abbia lo script Game Updater) e il titolo del gioco.
  12. #===============================================================================
  13. # Istruzioni: Piazzare lo script sotto Materials, prima del Main.
  14. # Crea un file di testo all'interno della cartella del progetto, ad esempio
  15. # Info.ini, e scrivi tutte le informazioni che vuoi metterci.
  16. # Puoi inserire nel testo dei tag speciali che facciano apparire dei simboli:
  17. # [S] → ★
  18. # [B] → ●
  19. # [R] → ®
  20. # [C] → ©
  21. # [L] → ♥
  22. #===============================================================================
  23. # CONFIGURAZIONE
  24. #===============================================================================
  25. module H87_Infos
  26.   #Vuoi mostrare la versione del gioco? (funziona solo se hai Game Updater)
  27.   Mostra_Versione = true
  28.   #Vuoi mostrare il titolo del gioco?
  29.   Mostra_Titolo = true
  30.   #Inserisci il nome del file che conterrà le informazioni
  31.   Nome_File = "Info.ini"
  32.   #Inserisci la larghezza della pagina del testo
  33.   Larghezza = 500
  34.  
  35.   #Opzioni barra di scorrimento
  36.  
  37.   #Vuoi mostrare la barra di scorrimento?
  38.   Attiva_Barra = true
  39.   #Imposta la larghezza della barra di scorrimento
  40.   Lar_Barra = 10
  41.   #Imposta la distanza della barra dal margine destro dello schermo
  42.   X = 10
  43.   #imposta la distanza della barra dal margine superiore e inferiore dello schermo
  44.   Y = 10
  45.   #vuoi che la barra si nasconda automaticamente se non si scorre il testo?
  46.   Nascondi_Barra = true
  47.  
  48.   #Nel caso non sia installato lo script Menu Titolo Animato:
  49.   IconaInfo = "T_Info"    #icona del comando del menu titolo
  50.   TestoInfo = "B_Info"   #fumetto del comando del menu titolo
  51. end
  52. #===============================================================================
  53. # FINE CONFIGURAZIONE
  54. # Non modificare oltre lo script, se non sai cosa stai facendo!
  55. #===============================================================================
  56.  
  57. #===============================================================================
  58. # Classe Scene_GameInfo
  59. #===============================================================================
  60. class Scene_GameInfo < Scene_Base
  61.   include H87_Infos #include il modulo
  62.  
  63.   #-----------------------------------------------------------------------------
  64.   # * Start
  65.   #-----------------------------------------------------------------------------
  66.   def start
  67.     super
  68.     create_background
  69.     @speed = 0    #La velocità di scorrimento del testo
  70.     @pressione = 0  #Indica se e quale tasto è premuto
  71.     carica_testo
  72.     crea_finestra
  73.     crea_barra if barra_visibile?
  74.   end
  75.  
  76.   #-----------------------------------------------------------------------------
  77.   # * Carica il testo dal file
  78.   #-----------------------------------------------------------------------------
  79.   def carica_testo
  80.     if File.exist? (Nome_File) #apre il file in sola lett.
  81.       array = []
  82.       File.open(Nome_File,"r") do |f|
  83.         f.each_line {|riga| array.push(riga.to_s)}
  84.         @testo = array
  85.       end
  86.     else
  87.       msgbox("File non trovato")
  88.       @testo = "Vuoto"
  89.     end
  90.   end
  91.  
  92.   #-----------------------------------------------------------------------------
  93.   # * Crea la finestra del testo
  94.   #-----------------------------------------------------------------------------
  95.   def crea_finestra
  96.     @quadrato = Viewport.new(0,0,Graphics.width,Graphics.height)
  97.     @finestra = Window_Infos.new(@testo)
  98.     @finestra.viewport = @quadrato
  99.     @finestra.x = (Graphics.width-@finestra.width)/2 #finestra centrata
  100.     @finestra.opacity = 0
  101.     #calcolo del margine di scorrimento ai bordi
  102.     if @finestra.height <= Graphics.height+32
  103.       @calc = -32
  104.     else
  105.       @calc = Graphics.height-@finestra.height-32
  106.     end
  107.   end
  108.  
  109.   #-----------------------------------------------------------------------------
  110.   # * Aggiornamento
  111.   #-----------------------------------------------------------------------------
  112.   def update
  113.     super
  114.     muovi_giu if Input.press?(:DOWN)
  115.     muovi_su  if Input.press?(:UP)
  116.     esci if Input.trigger?(:B)
  117.     muovi_testo
  118.     muovi_barra if barra_visibile?
  119.   end
  120.  
  121.   #-----------------------------------------------------------------------------
  122.   # * Muovi giù
  123.   #-----------------------------------------------------------------------------
  124.   def muovi_giu
  125.     return if @finestra.y < @calc
  126.     @pressione=1
  127.     @speed = 0 if @speed < 0
  128.     @speed += 0.5
  129.     @speed = 50 if @speed > 50
  130.     if barra_visibile?
  131.       @barra.opacity += 50
  132.       @rettangolo.opacity += 50
  133.     end
  134.   end
  135.  
  136.   #-----------------------------------------------------------------------------
  137.   # * Muovi su
  138.   #-----------------------------------------------------------------------------
  139.   def muovi_su
  140.     return if @finestra.y > 32
  141.     @pressione=2
  142.     @speed = 0 if @speed > 0
  143.     @speed -= 0.5
  144.     @speed = -50 if @speed < -50
  145.     if barra_visibile?
  146.       @barra.opacity += 50
  147.       @rettangolo.opacity += 50
  148.     end
  149.   end
  150.  
  151.   #-----------------------------------------------------------------------------
  152.   # * Esci
  153.   #-----------------------------------------------------------------------------
  154.   def esci
  155.     Sound.play_cancel
  156.     SceneManager.return
  157.   end
  158.  
  159.   #-----------------------------------------------------------------------------
  160.   # * Muovi il testo
  161.   #-----------------------------------------------------------------------------
  162.   def muovi_testo
  163.     if @pressione == 0 #se non viene premuto su o giù, la velocità diminuisce
  164.       @finestra.y += 2 if @finestra.y < 0        #torna se è sul bordo
  165.       @finestra.y -= 2 if @finestra.y > @calc+32
  166.       if @speed > 0
  167.         @speed -= 0.5
  168.       elsif @speed < 0
  169.         @speed += 0.5
  170.       end
  171.     end
  172.     @finestra.y -= @speed/4
  173.     if @finestra.y < @calc-32;@finestra.y = @calc-32;@speed=0;end
  174.     if @finestra.y > 32*2;@finestra.y = 32*2;@speed=0;end
  175.     @pressione = 0
  176.   end
  177.  
  178.   #-----------------------------------------------------------------------------
  179.   # * Crea la barra
  180.   #-----------------------------------------------------------------------------
  181.   def crea_barra
  182.     larghezza = Lar_Barra
  183.     x = Graphics.width-larghezza-X
  184.     y = Y
  185.     altezza = Graphics.height-y-10
  186.     colore_retro = Color.new(0,0,0,100)
  187.     immagine = Bitmap.new(larghezza,altezza)
  188.     immagine.fill_rect(0,0,larghezza,altezza,colore_retro)
  189.     @rettangolo = Sprite.new
  190.     @rettangolo.bitmap = immagine
  191.     @rettangolo.x = x
  192.     @rettangolo.y = y
  193.     bianco = Color.new(255,255,255,200)
  194.     grigio = Color.new(200,200,200,200)
  195.     calcola_alt = altezza*(Graphics.height.to_f/@finestra.height.to_f)
  196.     immaginebarra = Bitmap.new(larghezza,calcola_alt)
  197.     immaginebarra.gradient_fill_rect(0,0,larghezza,calcola_alt,bianco,grigio)
  198.     immaginebarra.blur
  199.     @barra = Sprite.new
  200.     @barra.bitmap = immaginebarra
  201.     @barra.x = x
  202.     @barra.y = y
  203.   end
  204.  
  205.   #-----------------------------------------------------------------------------
  206.   # * Calcola la prossima coordinata della barra di scorrimento
  207.   #-----------------------------------------------------------------------------
  208.   def calcola_destinazione
  209.     minimo = Y
  210.     massimo = minimo + @rettangolo.height - @barra.height
  211.     lunghezza = massimo-minimo
  212.     lung_finestra = @finestra.height
  213.     proporzione = lunghezza.to_f/(lung_finestra-Graphics.height).to_f
  214.     destinazione = @finestra.y.to_f*(-1.0)*proporzione
  215.     destinazione = minimo if destinazione < minimo
  216.     destinazione = massimo if destinazione > massimo
  217.     return destinazione.to_i
  218.   end
  219.  
  220.   #-----------------------------------------------------------------------------
  221.   # * Aggiorna la grafica della barra
  222.   #-----------------------------------------------------------------------------
  223.   def muovi_barra
  224.     @barra.y = calcola_destinazione
  225.     if Nascondi_Barra
  226.       @barra.opacity -= 2
  227.       @rettangolo.opacity -= 2
  228.     end
  229.   end
  230.  
  231.   #-----------------------------------------------------------------------------
  232.   # * Elimina le barre una volta che si torna indietro
  233.   #-----------------------------------------------------------------------------
  234.   def elimina_barre
  235.     @rettangolo.dispose
  236.     @rettangolo.bitmap.dispose
  237.     @barra.dispose
  238.     @barra.bitmap.dispose
  239.   end
  240.  
  241.   #-----------------------------------------------------------------------------
  242.   # * Restituisce true se la barra è attiva
  243.   #-----------------------------------------------------------------------------
  244.   def barra_visibile?
  245.     return false if Attiva_Barra == false or @barra == nil
  246.     #return false if Graphics.height+32 >= @finestra.height
  247.     return true
  248.   end
  249.  
  250.   #-----------------------------------------------------------------------------
  251.   # * Termina
  252.   #-----------------------------------------------------------------------------
  253.   def terminate
  254.     super
  255.     elimina_barre if barra_visibile?
  256.     @finestra.dispose
  257.     @quadrato.dispose
  258.     dispose_background
  259.   end
  260.  
  261.   #-----------------------------------------------------------------------------
  262.   # * Crea Sfondo
  263.   #-----------------------------------------------------------------------------
  264.   def create_background
  265.     @background_sprite = Sprite.new
  266.     @background_sprite.bitmap = SceneManager.background_bitmap
  267.     @background_sprite.color.set(16, 16, 16, 128)
  268.   end
  269.  
  270.   #--------------------------------------------------------------------------
  271.   # * Elimina lo sfondo
  272.   #--------------------------------------------------------------------------
  273.   def dispose_background
  274.     @background_sprite.dispose
  275.   end
  276. end
  277.  
  278. #===============================================================================
  279. # Classe Window_Infos
  280. #===============================================================================
  281. class Window_Infos < Window_Base
  282.   def initialize(testo)
  283.     alt = (line_height*(testo.size+1))+32
  284.     super((Graphics.width-H87_Infos::Larghezza)/2,0,H87_Infos::Larghezza,alt)
  285.     @testo = testo
  286.     @righe = @testo.size+1
  287.     refresh
  288.   end
  289.  
  290.   #-----------------------------------------------------------------------------
  291.   # Refresh
  292.   #-----------------------------------------------------------------------------
  293.   def refresh
  294.     self.contents.clear
  295.     colore = Color.new(255,255,255,100) #colore bianco
  296.     self.contents.fill_rect(4, 0, self.width-32, 1,colore) #linea superiore
  297.     if H87_Infos::Mostra_Titolo
  298.       self.contents.draw_text(4,0,self.width-32,line_height,$data_system.game_title)
  299.     end
  300.     if H87_Infos::Mostra_Versione and $imported["H87A_Updater"]#Updater
  301.       vers = "Versione: "+Updater.current_version.to_s
  302.       self.contents.draw_text(4,0,self.width-40,line_height,vers,2)
  303.     end
  304.     for i in 1..@righe-1
  305.       @testo[i-1].gsub!("\n","") if @testo[i-1].gsub("\n","") != nil
  306.       @testo[i-1].gsub!("[R]","®")
  307.       @testo[i-1].gsub!("[C]","©")
  308.       @testo[i-1].gsub!("[L]","♥")
  309.       @testo[i-1].gsub!("[S]","★")
  310.       @testo[i-1].gsub!("[B]","●")
  311.       self.contents.draw_text(4,line_height*i,self.width-32,line_height,@testo[i-1],1)
  312.     end
  313.     self.contents.fill_rect(4,(line_height*@righe)-1, self.width-32, 1,colore) #linea inf
  314.   end
  315. end
  316.  
  317. #===============================================================================
  318. # Classe Scene_Title
  319. #===============================================================================
  320. class Scene_Title < Scene_Base
  321.   #-----------------------------------------------------------------------------
  322.   # * Comando per accedere alle info
  323.   #-----------------------------------------------------------------------------
  324.   def command_infos
  325.     Sound.play_ok
  326.     SceneManager.call(Scene_GameInfo)
  327.   end
  328.  
  329.   if $imported["H87_TitleMenu"]
  330.   alias metodo_aliasato crea_contenuti_personalizzati
  331.   def crea_contenuti_personalizzati
  332.     metodo_aliasato
  333.     add_cursor(:info, "command_infos",H87_Infos::IconaInfo,H87_Infos::TestoInfo)
  334.   end;end
  335.  
  336. unless $imported["H87_TitleMenu"]
  337.   alias nuovo_command_window create_command_window unless $@
  338.   def create_command_window
  339.     nuovo_command_window
  340.     @command_window.set_handler(:info, method(:command_infos))
  341.   end
  342. end
  343. end
  344.  
  345. class Window_TitleCommand < Window_Command
  346.   alias nuovo_command_list make_command_list unless $@
  347.   def make_command_list
  348.     nuovo_command_list
  349.     add_command(H87_Infos::TestoInfo, :info)
  350.   end
  351.  
  352. end #scene_title
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement