Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $imported = {} if $imported == nil
- $imported["H87_DebugConsolle"] = true
- #===============================================================================
- # TERMINALE DI DEBUG
- #===============================================================================
- # Autore: Holy87
- # Versione: 1.0
- #-------------------------------------------------------------------------------
- # Questo script è indirizzato fondamentalmente a scripters e a eventer esperti
- # quando per testare i loro script hanno bisogno di avere sotto controllo alcuni
- # parametri. Su VX Ace è già presente nativamente la finestra di terminale, con
- # cui vedere i messaggi nello script stampati con la funzione print(). Nel VX,
- # la funzione print() fa uscire un menu di popup che però interrompe il gioco,
- # e per messaggi multipli può essere piuttosto fastidioso. Questo script mostra
- # messaggi dagli script direttamente su schermo senza interrompere il gioco.
- #-------------------------------------------------------------------------------
- # Istruzioni:
- # Copiare lo script sotto Materials, prima del Main. Inserire negli script la
- # funzione DF.print("messaggio") per far mostrare una stringa sullo schermo.
- # Se scrivi DF.print("messaggio",true) la stringa sarà
- # di colore rosso (per evidenziare i messaggi che ritieni importanti)
- #-------------------------------------------------------------------------------
- # Note:
- # Questo script fa tutto e niente. Sbizzarritevi!
- # Il terminale viene mostrato solo se il gioco viene avviato in modalità Test.
- #-------------------------------------------------------------------------------
- # Compatibilità:
- # Scene_Base
- # - alias start, update, terminate
- #-------------------------------------------------------------------------------
- module DF
- module SETTINGS
- #===============================================================================
- # ** CONFIGURAZIONE **
- #===============================================================================
- #Righe massime da mostrare. Oltre questo numero quelli precedenti verranno
- # eliminati.
- Max = 25
- #Tempo di scomparsa del terminale se non viene mostrato alcun messaggio.
- FadeTime = 2200#in frame
- #Impostazioni del testo
- Size = 15 #grandezza del testo
- Line = 17 #altezza della riga
- end
- #===============================================================================
- # ** FINE CONFIGURAZIONE **
- # Attenzione: Non modificare ciò che c'è oltre, a meno che tu non sappia ciò che
- # fai! C'è gente che si è suicidata per molto meno, fidati.
- #===============================================================================
- def self.activated?
- return $TEST
- end
- #-----------------------------------------------------------------------------
- # *chiamata
- #-----------------------------------------------------------------------------
- def self.print(line,red = false)
- line.inspect.split(/[\r\n]+/).each { |riga|
- $scene.push_debug_text(riga,red)
- }
- end
- end
- #===============================================================================
- # ** Classe DebugFrame
- #===============================================================================
- class DebugFrame
- #-----------------------------------------------------------------------------
- # * inizializzazione
- #-----------------------------------------------------------------------------
- def initialize(viewport)
- if DF.activated?
- @text = []
- @sprite = Sprite.new(viewport)
- @sprite.bitmap = nuovo_bitmap
- @visible = true
- else
- @visible = false
- end
- end
- #-----------------------------------------------------------------------------
- # * creazione della bitmap
- #-----------------------------------------------------------------------------
- def nuovo_bitmap(text = nil,red=false)
- @timer = 0
- @sprite.opacity = 255
- bitmap = Bitmap.new(Graphics.width,Graphics.height)
- bitmap.font.size = DF::SETTINGS::Size
- line = DF::SETTINGS::Line
- if text != nil and text != ""
- bitmap.gradient_fill_rect(0,0,Graphics.width/2,line*@text.size,Color.new(0,0,0,150),Color.new(0,0,0,0))
- for i in 0..text.size-1
- if red
- bitmap.font.color = Color.new(255,0,0)
- else
- bitmap.font.color = Color.new(255,255,255)
- end
- bitmap.draw_text(4,line*i,Graphics.width,line,text[i])
- end
- end
- return bitmap
- end
- #-----------------------------------------------------------------------------
- # * aggiornamento
- #-----------------------------------------------------------------------------
- def update
- return if DF::SETTINGS::FadeTime == 0
- @timer += 1
- if @timer > DF::SETTINGS::FadeTime
- @sprite.opacity -= 1
- end
- end
- #-----------------------------------------------------------------------------
- # * eliminazione
- #-----------------------------------------------------------------------------
- def dispose
- @sprite.bitmap.dispose
- @sprite.dispose
- end
- #-----------------------------------------------------------------------------
- # * inserimento di una nuova riga
- #-----------------------------------------------------------------------------
- def push_text(line,red=false)
- return unless DF.activated?
- if @text.size < DF::SETTINGS::Max
- @text.push(line.to_s)
- else
- for i in 1..@text.size-1
- @text[i-1]=@text[i]
- end
- @text[i] = line
- end
- @sprite.bitmap = nuovo_bitmap(@text,red)
- end
- #-----------------------------------------------------------------------------
- # * layer z
- #-----------------------------------------------------------------------------
- def z=(value)
- @sprite.z = value
- end
- end
- #===============================================================================
- # ** Classe Scene_Base
- #===============================================================================
- class Scene_Base
- #-----------------------------------------------------------------------------
- # * alias di start
- #-----------------------------------------------------------------------------
- alias h87_df_start start unless $@
- def start
- h87_df_start
- if DF.activated?
- @debugViewport = Viewport.new(0,0,Graphics.width,Graphics.height)
- @debugframe = DebugFrame.new(@debugViewport)
- @debugViewport.z = 999
- end
- end
- #-----------------------------------------------------------------------------
- # * inserimento del debug_text
- #-----------------------------------------------------------------------------
- def push_debug_text(line,red=false)
- return if @debugframe == nil
- @debugframe.push_text(line,red)
- end
- #-----------------------------------------------------------------------------
- # * aggiornamento
- #-----------------------------------------------------------------------------
- alias h87_df_update update unless $@
- def update
- h87_df_update
- @debugframe.update if DF.activated?
- end
- #-----------------------------------------------------------------------------
- # * terminazione
- #-----------------------------------------------------------------------------
- alias h87_df_terminate terminate unless $@
- def terminate
- h87_df_terminate
- if DF.activated?
- @debugframe.dispose
- @debugViewport.dispose
- end
- end
- end #scene_base
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement