SHARE
TWEET

Untitled

a guest Aug 24th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #===============================================================================
  2. # ** Custom Menu Backgrounds 2.0 **
  3. #===============================================================================
  4. #
  5. # Version:      2.0
  6. # Datum:        29.06.2014
  7. # Author:       eugene222
  8. #  
  9. #===============================================================================
  10. #   CHANGELOG:
  11. #
  12. #   Version 2.0  ,  29.06.2014:   rewrote the script, added many features
  13. #   Version 1.1a ,  13.05.2014:   improved compatibility
  14. #   Version 1.1  ,  24.04.2014:   layouts added
  15. #   Version 1.01 ,  21.03.2014:   code optimized
  16. #   Version 1.0  ,  02.03.2014:   Script created
  17. #
  18. #===============================================================================
  19. # Features:
  20. #
  21. #   - Custom Background For Every Scene (Custom Scenes should work, too)
  22. #   - Custom Layout Which Will Be Displayed Over The Background
  23. #   - Custom Opacity For The Windows
  24. #   - Particle Effects
  25. #
  26. #===============================================================================
  27. # Installation:
  28. #
  29. #  Place this script above main but below the default scripts
  30. #
  31. #  The background and layout pictures have to be in "Graphics\Menu"
  32. #   => Create the Folder if you dont have one.
  33. #  The particle picture has to be in "Graphics\Menu", too.
  34. #  The size dont matter but I recommend 32x32
  35. #
  36. #===============================================================================
  37. module EVG
  38.   module SceneBG
  39.    
  40.     USED_SCENES = ["Scene_Formation", "Scene_Quest", "Scene_Save", "Scene_Load",
  41.     "Scene_System"]
  42.    
  43.     #---------------------------------------------------------------------------
  44.     # You need to define the default Attributes below
  45.     # All Scenes in USED_SCENES will use these values as their default
  46.     # A little bit more below you can overwrite attributes for certain scenes
  47.     #----------------------------------------------------------------------------
  48.     DEFAULT_CONFIG = {
  49.       #------------------------------------------------------------------------
  50.       # You can set :opacity, :background, :layout and :particle to :disabled
  51.       # This means, that this script wont touch disabled attributes
  52.       # But you can overwrite them for certain scenes.
  53.       #-------------------------------------------------------------------------
  54.      
  55.       # :opacity => value or :disabled,
  56.       :opacity          => :disabled,
  57.      
  58.       # :background => "filename" or :disabled,
  59.       :background       => "Background",
  60.      
  61.       # :layout => "filename" or :disabled,
  62.       :layout           => :disabled,
  63.      
  64.       # :particle => "filename" or :disabled,
  65.       :particle         => :disabled,
  66.      
  67.       # How many particles should be shown on the screen?
  68.       :particle_number  => 0,
  69.      
  70.       # The x-axis speed per frame
  71.       :particle_speed_x => 0,
  72.      
  73.       # The y-axis speed per frame
  74.       :particle_speed_y => 0,
  75.      
  76.       # The angle speed per frame
  77.       :particle_speed_a => 0,
  78.     #---------------------------------------------------------------------------
  79.     } # Diese Zeile nicht verändern
  80.     #---------------------------------------------------------------------------
  81.     # Here you can define individual settings for the used scenes
  82.     # The default attributes get overwriten by this.
  83.     #---------------------------------------------------------------------------
  84.     OVERWRITE = { # Diese Zeile nicht verändern
  85.     #---------------------------------------------------------------------------
  86.     # Custom Scene Config:
  87.     #  - The overwriten attributes needs to be seperated by a comma
  88.     #---------------------------------------------------------------------------
  89.    
  90.     "Scene_Menu"  =>   {
  91.    
  92.       :particle_number => 20,
  93.        
  94.     },  
  95.  
  96.  
  97.     #---------------------------------------------------------------------------
  98.     # CONFIG END
  99.     #---------------------------------------------------------------------------  
  100.     } # Diese Zeile nicht verändern
  101.     #---------------------------------------------------------------------------
  102.   end
  103. end
  104. #===============================================================================
  105. # ** Cache
  106. #===============================================================================
  107. class Scene_MenuBase
  108.   #---------------------------------------------------------------------------
  109.   # Post Start
  110.   #---------------------------------------------------------------------------
  111.   alias :evg_smb_ps_cmb          :post_start
  112.   #---------------------------------------------------------------------------
  113.   def post_start
  114.     if custom_bg_scene?
  115.       change_opacity
  116.       create_layout
  117.       create_particles
  118.     end
  119.     evg_smb_ps_cmb
  120.   end
  121.   #--------------------------------------------------------------------------
  122.   # * Custom Background Scene?
  123.   #--------------------------------------------------------------------------  
  124.   def custom_bg_scene?
  125.     return EVG::SceneBG::USED_SCENES.include?(current_scene)
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # * Current Scene
  129.   #--------------------------------------------------------------------------  
  130.   def current_scene
  131.     return SceneManager.scene.class.to_s
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # * Is type An Overwrite Type?
  135.   #--------------------------------------------------------------------------
  136.   def overwrite_type?(type)
  137.     EVG::SceneBG::OVERWRITE[current_scene.to_s] &&
  138.     EVG::SceneBG::OVERWRITE[current_scene.to_s][type]
  139.   end  
  140.   #--------------------------------------------------------------------------
  141.   # * Create Viewport
  142.   #--------------------------------------------------------------------------
  143.   alias :evg_smb_cmv_cmb      :create_main_viewport
  144.   def create_main_viewport
  145.     evg_smb_cmv_cmb
  146.     w = Graphics.width + 32; h = Graphics.height + 32
  147.     @particle_viewport = Viewport.new(-32, -32, w, h)
  148.     @particle_viewport.z = 5
  149.   end
  150.   #---------------------------------------------------------------------------
  151.   #  Return Value For Type
  152.   #---------------------------------------------------------------------------
  153.   def return_value(type)
  154.     if overwrite_type?(type)
  155.       return EVG::SceneBG::OVERWRITE[current_scene.to_s][type]
  156.     else
  157.       return EVG::SceneBG::DEFAULT_CONFIG[type]
  158.     end
  159.   end
  160.   #---------------------------------------------------------------------------
  161.   # Get Opacity
  162.   #---------------------------------------------------------------------------
  163.   def get_opacity
  164.     return_value(:opacity)
  165.   end
  166.   #---------------------------------------------------------------------------
  167.   # Get Background
  168.   #---------------------------------------------------------------------------
  169.   def get_background
  170.     return_value(:background)
  171.   end
  172.   #---------------------------------------------------------------------------
  173.   # Get Layout
  174.   #---------------------------------------------------------------------------
  175.   def get_layout
  176.     return_value(:layout)
  177.   end
  178.   #---------------------------------------------------------------------------
  179.   # New Create Background
  180.   #---------------------------------------------------------------------------
  181.   def new_create_background
  182.     @background_sprite = Sprite.new
  183.     @background_sprite.bitmap = Cache.menu(get_background)
  184.   end
  185.   #---------------------------------------------------------------------------
  186.   # Create Background
  187.   #---------------------------------------------------------------------------
  188.   alias :evg_smb_cb_cmb          :create_background
  189.   #---------------------------------------------------------------------------
  190.   def create_background
  191.     if custom_bg_scene?
  192.       return evg_smb_cb_cmb if get_background == :disabled
  193.       return new_create_background
  194.     else
  195.       evg_smb_cb_cmb
  196.     end
  197.   end
  198.   #---------------------------------------------------------------------------
  199.   # Create Öayout
  200.   #---------------------------------------------------------------------------
  201.   def create_layout
  202.     return if get_layout == :disabled
  203.     @layout_sprite = Sprite.new
  204.     @layout_sprite.z = @background_sprite.z + 1
  205.     @layout_sprite.bitmap = Cache.menu(get_layout)
  206.   end
  207.   #--------------------------------------------------------------------------
  208.   # Create Particles
  209.   #--------------------------------------------------------------------------  
  210.   def create_particles
  211.     return if return_value(:particle) == :disabled
  212.     dispose_particles
  213.     file = return_value(:particle)
  214.     speed_x = return_value(:particle_speed_x)
  215.     speed_y = return_value(:particle_speed_y)
  216.     speed_a = return_value(:particle_speed_a)
  217.     @particles = Array.new(return_value(:particle_number)) do
  218.       EVGParticle.new(@particle_viewport, speed_x, speed_y, speed_a, file)
  219.     end
  220.   end
  221.   #---------------------------------------------------------------------------
  222.   # Change Opacity
  223.   #---------------------------------------------------------------------------
  224.   def change_opacity
  225.     return if get_opacity == :disabled
  226.     instance_variables.each do |name|
  227.       instance = instance_variable_get(name)
  228.       set_opacity(instance) if instance.is_a?(Window)
  229.     end
  230.     update_file_opacity if @savefile_windows
  231.   end
  232.   #---------------------------------------------------------------------------
  233.   # For Scene File
  234.   #---------------------------------------------------------------------------
  235.   def update_file_opacity
  236.     @savefile_windows.each do |window|  
  237.       set_opacity(window)
  238.     end
  239.   end
  240.   #---------------------------------------------------------------------------
  241.   # Set Window Opacity
  242.   #---------------------------------------------------------------------------
  243.   def set_opacity(window)
  244.     return if window.nil?
  245.     return if window.disposed?
  246.     window.opacity = get_opacity
  247.   end
  248.   #---------------------------------------------------------------------------
  249.   # Update
  250.   #---------------------------------------------------------------------------
  251.   alias :evg_smb_update_cbs            :update
  252.   #---------------------------------------------------------------------------
  253.   def update
  254.     evg_smb_update_cbs
  255.     @particles.each(&:update) if @particles
  256.   end
  257.   #---------------------------------------------------------------------------
  258.   # Dispose Öayout
  259.   #---------------------------------------------------------------------------
  260.   def dispose_layout
  261.     return unless @layout_sprite
  262.     @layout_sprite.bitmap.dispose
  263.     @layout_sprite.dispose
  264.   end
  265.   #---------------------------------------------------------------------------
  266.   # Dispose Particles
  267.   #---------------------------------------------------------------------------
  268.   def dispose_particles
  269.     return unless @particles
  270.     @particles.each(&:dispose)
  271.     @particle_viewport.dispose
  272.     @particles = nil
  273.   end
  274.   #---------------------------------------------------------------------------
  275.   # Terminate
  276.   #---------------------------------------------------------------------------
  277.   alias :evg_smb_terminate_cbs         :terminate
  278.   #---------------------------------------------------------------------------
  279.   def terminate
  280.     evg_smb_terminate_cbs
  281.     dispose_layout
  282.     dispose_particles
  283.   end
  284.   #---------------------------------------------------------------------------
  285. end
  286. #===============================================================================
  287. # ** Particle
  288. #===============================================================================
  289. class EVGParticle < Sprite
  290.   #-----------------------------------------------------------------------------
  291.   # Initialize
  292.   #-----------------------------------------------------------------------------
  293.   def initialize(viewport = nil, speed_x, speed_y, speed_angle, file)
  294.     super(viewport)
  295.     self.bitmap = Cache.menu(file)
  296.     @sx = speed_x
  297.     @sy = speed_y
  298.     @sa = speed_angle
  299.     reset_particle(true)
  300.   end
  301.   #-----------------------------------------------------------------------------
  302.   # Particle Width
  303.   #-----------------------------------------------------------------------------
  304.   def pw
  305.     return self.bitmap.width
  306.   end
  307.   #-----------------------------------------------------------------------------
  308.   # Particle Height
  309.   #-----------------------------------------------------------------------------
  310.   def ph
  311.     return self.bitmap.height
  312.   end
  313.   #-----------------------------------------------------------------------------
  314.   # Particle Visible?
  315.   #-----------------------------------------------------------------------------
  316.   def on_screen?
  317.     self.x.between?(-pw, Graphics.width + pw) &&
  318.     self.y.between?(-ph, Graphics.height + ph)
  319.   end
  320.   #-----------------------------------------------------------------------------
  321.   # Reset Particle
  322.   #-----------------------------------------------------------------------------
  323.   def reset_particle(init = false)
  324.     self.opacity = 0
  325.     reset_zoom
  326.     reset_position(init)
  327.     reset_speed
  328.   end
  329.   #-----------------------------------------------------------------------------
  330.   # Reset Zoom
  331.   #-----------------------------------------------------------------------------
  332.   def reset_zoom
  333.     zoom = (50 + rand(75)) / 100.0
  334.     self.zoom_x = zoom
  335.     self.zoom_y = zoom
  336.   end
  337.   #-----------------------------------------------------------------------------
  338.   # Reset Position
  339.   #-----------------------------------------------------------------------------
  340.   def reset_position(init)
  341.     self.x = rand(Graphics.width)
  342.     self.y = init ? rand(Graphics.height + pw) : Graphics.height + rand(ph + 32)  
  343.   end
  344.   #-----------------------------------------------------------------------------
  345.   # Reset Speed
  346.   #-----------------------------------------------------------------------------
  347.   def reset_speed
  348.     @speed_x = @sx == 0 ? 0 : [[rand(@sx), 20].min, 1].max
  349.     @speed_y = @sy == 0 ? 0 : [[rand(@sy), 20].min, 1].max
  350.     @speed_a = @sa == 0 ? 0 : [[rand(@sa), 20].min, 1].max
  351.   end
  352.   #-----------------------------------------------------------------------------
  353.   # Update
  354.   #-----------------------------------------------------------------------------
  355.   def update
  356.     super
  357.     self.x += @speed_x
  358.     self.y -= @speed_y
  359.     self.angle += @speed_a
  360.     self.opacity += 5
  361.     reset_particle unless on_screen?
  362.   end
  363.   #-----------------------------------------------------------------------------
  364.   # Dispose
  365.   #-----------------------------------------------------------------------------
  366.   def dispose
  367.     self.bitmap.dispose
  368.     super
  369.   end
  370. end
  371. #===============================================================================
  372. # ** Cache
  373. #===============================================================================
  374. module Cache
  375.   #-----------------------------------------------------------------------------
  376.   def self.menu(filename)
  377.     load_bitmap("Graphics/Menus/", filename)
  378.   end
  379.   #-----------------------------------------------------------------------------
  380. end
  381. #===============================================================================
  382. # END
  383. #===============================================================================
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top