Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- ==============================================================================
- ■ Transizioni del menu di Holy87
- versione 1.01
- Difficoltà utente: ★
- Licenza: CC. Chiunque può scaricare, modificare, distribuire e utilizzare
- lo script nei propri progetti, sia amatoriali che commerciali. Vietata
- l'attribuzione impropria.
- ==============================================================================
- Questo script mostra delle animazioni di transizione dei menu, spostando
- le finestre dall'esterno dello schermo alla loro posizione e viceversa. È
- studiato per essere compatibile il più possibile anche con gli script di
- terzi.
- ==============================================================================
- ■ Compatibilità
- * Nessun alias e/o override
- ==============================================================================
- ■ Installazione
- Installare questo script sotto Materials e prima del Main. Configurare le
- opzioni di base in basso se si vuole personalizzare ulteriormente lo script.
- =end
- #==============================================================================
- # ** IMPOSTAZIONI
- #------------------------------------------------------------------------------
- # Puoi modificare le preferenze dello script in queste due righe.
- #==============================================================================
- module TRANSITION_SETTINGS
- #--------------------------------------------------------------------------
- # * Inserisci nell'array le scene in cui non vuoi l'animazione.
- #--------------------------------------------------------------------------
- Excluded_Scenes = [Scene_File, Scene_End]
- #--------------------------------------------------------------------------
- # * Imposta la velocità predefinita di animazione (da 1 a 5)
- #--------------------------------------------------------------------------
- SPEED = 3 #1: lentissimo, 2: lento, 3: medio, 4: veloce, 5: velocissimo
- #==============================================================================
- # ** FINE CONFIGURAZIONE
- #------------------------------------------------------------------------------
- # - ATTENZIONE: NON MODIFICARE OLTRE! -
- #==============================================================================
- end
- $imported = {} if $imported == nil
- $imported["H87_SmoothMenuTransition"] = 1.01
- #==============================================================================
- # ** Classe Window_Base
- #------------------------------------------------------------------------------
- # Inclusione del modulo smooth_movement
- #==============================================================================
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # * Prepara l'oggetto alla transizione in entrata
- #--------------------------------------------------------------------------
- def hide_position(speed = move_speed)
- nx = self.x
- ny = self.y
- if must_move?
- if (xy_movement && moveby_x) || (!xy_movement && attached_lateral?)
- if self.x <= 0
- nx = 0
- self.x = 0 - self.width
- move = true
- elsif self.x >= Graphics.width - self.width
- nx = Graphics.width - self.width
- self.x = Graphics.width
- move = true
- end
- else
- if self.y <= 0
- ny = 0
- self.y = 0 - self.height
- move = true
- elsif self.y >= Graphics.height - self.height
- ny = Graphics.height - self.height
- self.y = Graphics.height
- move = true
- end
- end
- smooth_move(nx, ny, speed) if move
- end
- end
- #--------------------------------------------------------------------------
- # * Prepara l'oggetto alla transizione in uscita
- #--------------------------------------------------------------------------
- def exit_from_screen(speed = move_speed)
- move = false
- nx = self.x
- ny = self.y
- if must_move?
- if (xy_movement && moveby_x) || (!xy_movement && attached_lateral?)
- if self.x <= 0
- nx = 0 - self.width
- move = true
- elsif self.x >= Graphics.width - self.width
- nx = Graphics.width
- move = true
- end
- else
- if self.y <= 0
- ny = 0 - self.height
- move = true
- elsif self.y >= Graphics.height - self.height
- ny = Graphics.height
- move = true
- end
- end
- smooth_move(nx, ny, speed) if move
- end
- end
- #--------------------------------------------------------------------------
- # * Restituisce true se l'oggetto è attaccato su un angolo
- #--------------------------------------------------------------------------
- def xy_movement
- return attached_lateral? && attached_up_bott?
- end
- #--------------------------------------------------------------------------
- # * Restituisce true se l'oggetto è attaccato ad un lato dello schermo
- #--------------------------------------------------------------------------
- def must_move?
- return attached_lateral? || attached_up_bott?
- end
- #--------------------------------------------------------------------------
- # * Restituisce true se l'oggetto è attaccato ai lati dx e sx dello schermo
- #--------------------------------------------------------------------------
- def attached_lateral?
- return self.x <= 0 || self.x >= Graphics.width - self.width
- end
- #--------------------------------------------------------------------------
- # * Restituisce true se l'oggetto è attaccato sopra o sotto lo schermo
- #--------------------------------------------------------------------------
- def attached_up_bott?
- return self.y <= 0 || self.y >= Graphics.height - self.height
- end
- #--------------------------------------------------------------------------
- # * Restituisce true se l'oggetto si deve muovere in orizontale, false se
- # in verticale
- #--------------------------------------------------------------------------
- def moveby_x
- return self.height >= self.width
- end
- end
- #==============================================================================
- # ** Classe Scene_MenuBase
- #------------------------------------------------------------------------------
- # Imposta le animazioni di entrata ed uscita delle finestre
- #==============================================================================
- class Scene_MenuBase < Scene_Base
- #--------------------------------------------------------------------------
- # * Metodo post_start
- #--------------------------------------------------------------------------
- def post_start
- alter_window_position unless excluded_scene?
- super
- end
- #--------------------------------------------------------------------------
- # * Prepara le finestre alla transizione in entrata
- #--------------------------------------------------------------------------
- def alter_window_position
- instance_variables.each do |varname|
- ivar = instance_variable_get(varname)
- ivar.hide_position(get_transition_speed) if ivar.is_a?(Window)
- end
- end
- #--------------------------------------------------------------------------
- # * Prepara le finestre alla transizione in uscita
- #--------------------------------------------------------------------------
- def hide_windows_for_transition
- instance_variables.each do |varname|
- ivar = instance_variable_get(varname)
- ivar.exit_from_screen(get_transition_speed) if ivar.is_a?(Window)
- end
- end
- #--------------------------------------------------------------------------
- # * Metodo pre_terminate
- #--------------------------------------------------------------------------
- def pre_terminate
- hide_windows_for_transition unless excluded_scene?
- update_transition
- super
- end
- #--------------------------------------------------------------------------
- # * Aggiorna la transizione
- #--------------------------------------------------------------------------
- def update_transition
- loop {update_basic; break if all_windows_moved}
- end
- #--------------------------------------------------------------------------
- # * Restituisce true se tutte le finestre hanno terminato il movimento
- #--------------------------------------------------------------------------
- def all_windows_moved
- instance_variables.each do |varname|
- ivar = instance_variable_get(varname)
- if ivar.is_a?(Window) && !ivar.move_end?
- return false
- end
- end
- return true
- end
- #--------------------------------------------------------------------------
- # * Restituisce true se la schermata è tra quelle eslcuse
- #--------------------------------------------------------------------------
- def excluded_scene?
- for scene in get_excluded_scenes
- return true if self.is_a?(scene)
- end
- return false
- end
- #--------------------------------------------------------------------------
- # * Restituisce le schermate escluse
- #--------------------------------------------------------------------------
- def get_excluded_scenes
- return TRANSITION_SETTINGS::Excluded_Scenes
- end
- def get_transition_speed
- return TRANSITION_SETTINGS::SPEED
- end
- end #fine dello script
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement