注册会员 登录
Project1 返回首页

鼠窝 https://rpg.blue/?335626 [收藏] [复制] [分享] [RSS] ~外站脚本图书馆~

日志

自定义菜单背景

已有 369 次阅读2014-5-17 13:36 |个人分类:外站脚本

#=============================================================================== 
# **Custom Menu Backgrounds** 
#=============================================================================== 

# Version:      1.1 
# Datum:        24.04.2014 
# Author:       eugene222 
#  
#=============================================================================== 
#   CHANGELOG: 
#
#   Version 1.1  ,  24.04.2014:   layouts added 
#   Version 1.01 ,  21.03.2014:   code optimized
#   Version 1.0  ,  02.03.2014:   Script created 

#=============================================================================== 
# Description:
#  With this script you can add custom backgrounds and layouts for all of your 
#  scenes.
#  You can also change the Opacity of the Windows in the Scenes  
#=============================================================================== 
# Installation: 
#
#  Place this script below all of your Menu Scene Scripts  
#
#  The background and layout pictures have to be in "Graphics\Menu" 
#   => Create the Folder if you dont have one.

#=============================================================================== 
module SceneBG
    #--------------------------------------------------------------------------- 
    # SAME_BG: 
    #  If SAME_BG is true, the same background picture will be used for all scenes
    # 
    #  Example: 
    #   Different backgrounds for all scenes: 
    #       SAME_BG = false  
    #   Same background for all scenes
    #       SAME_BG = "name_of_bg" 
    #--------------------------------------------------------------------------- 
         
    SAME_BG = false
     
    #--------------------------------------------------------------------------- 
    # SAME_Layout: 
    #  If SAME_LAYOUT is true, the same layout picture will be used for all scenes
    #  The layout is placed above the background picture
    #
    #  Example: 
    #   Different layouts for all scenes: 
    #       SAME_LAYOUT = false  
    #   Same background for all scenes
    #       SAME_LAYOUT = "name_of_layout" 
    #--------------------------------------------------------------------------- 
    SAME_LAYOUT = false
     
    #--------------------------------------------------------------------------- 
    #   Different window opacities if: 
    #       SAME_OPACITY = false 
    #   All windows in each scene will have this opacity:
    #       SAME_OPACITY = 120    
    # 
    #--------------------------------------------------------------------------- 
         
    SAME_OPACITY = false
         
    #--------------------------------------------------------------------------- 
    SCENE = { # Diese Zeile nicht verändern 
    #--------------------------------------------------------------------------- 
    # Default: 
    #   Name_Of_Scene => {background: "name", layout: "name", opacity: value},
    # 
    #   You can also add custom scenes, if you know the name of the custom scene
    #--------------------------------------------------------------------------- 
     
    Scene_Menu =>   {background: "BG",  layout: false, opacity: 128},  
    Scene_Item =>   {background: "BG",  layout: false, opacity: 128},  
    Scene_Skill =>  {background: "BG",  layout: false, opacity: 128}, 
    Scene_Equip =>  {background: "BG",  layout: false, opacity: 128}, 
    Scene_Status => {background: "BG",  layout: false, opacity: 128}, 
    Scene_Save =>   {background: "BG",  layout: false, opacity: 128}, 
    Scene_Load =>   {background: "BG",  layout: false, opacity: 128}, 
    Scene_End =>    {background: "BG",  layout: false, opacity: 128},
         
    #--------------------------------------------------------------------------- 
    # CONFIG END
    #---------------------------------------------------------------------------   
    }
end
#=============================================================================== 
# ** Change Scenes 
#=============================================================================== 
SceneBG::SCENE.each_key do | scene | 
  next unless scene.ancestors.include? Scene_MenuBase 
  scene.class_eval do
    #--------------------------------------------------------------------------- 
    alias :old_start_e222   :start
    #--------------------------------------------------------------------------- 
    def start 
      old_start_e222 
      change_opacity
      create_layout
    end
    #--------------------------------------------------------------------------- 
    # Scene_File has an array with windows, it needs a special treatment 
    #--------------------------------------------------------------------------- 
    def opacity_for_scene_file 
      @savefile_windows.each do |window|  
        window.opacity = determine_opacity 
      end
    end
    #--------------------------------------------------------------------------- 
    # iterate through all instance variables 
    # if an instance variable is a window => change the opacity of that window 
    #--------------------------------------------------------------------------- 
    def opacity_for_all_scenes 
      instance_variables.each do |name| 
        instance = instance_variable_get(name) 
        instance.opacity = determine_opacity if instance.is_a?(Window) 
      end
    end
    #--------------------------------------------------------------------------- 
    # no changes to opacity if the user has made some mistakes in the config 
    #--------------------------------------------------------------------------- 
    def change_opacity 
      opacity_for_scene_file if self.class.superclass == Scene_File 
      opacity_for_all_scenes 
    end
    #--------------------------------------------------------------------------- 
    # returns the opacity number, that was defined by user in the config section 
    #--------------------------------------------------------------------------- 
    def determine_opacity 
      return SceneBG::SAME_OPACITY if SceneBG::SAME_OPACITY
      SceneBG::SCENE[self.class][:opacity] 
    end
    #--------------------------------------------------------------------------- 
    # returns the bg name, that was defined by user in the config section 
    #--------------------------------------------------------------------------- 
    def determine_background 
      return SceneBG::SAME_BG if SceneBG::SAME_BG
      SceneBG::SCENE[self.class][:background] 
    end
    #--------------------------------------------------------------------------- 
    # returns the layout name, that was defined by user in the config section 
    #--------------------------------------------------------------------------- 
    def determine_layout
      return SceneBG::SAME_LAYOUT if SceneBG::SAME_LAYOUT
      SceneBG::SCENE[self.class][:layout]
    end
    #--------------------------------------------------------------------------- 
    # sets the background to the image file defined by the user 
    #--------------------------------------------------------------------------- 
    def new_create_background 
      @background_sprite = Sprite.new
      @background_sprite.bitmap = Cache.menu(determine_background) 
    end
    #--------------------------------------------------------------------------- 
    alias :old_create_background_e222     :create_background
    #--------------------------------------------------------------------------- 
    def create_background 
      return new_create_background if determine_background
      old_create_background_e222 
    end
    #--------------------------------------------------------------------------- 
    # creates layout
    #--------------------------------------------------------------------------- 
    def create_layout
      return unless determine_layout
      @layout_sprite = Sprite.new
      @layout_sprite.bitmap = Cache.menu(determine_layout)
    end
    #--------------------------------------------------------------------------- 
    # dispose layout
    #--------------------------------------------------------------------------- 
    def dispose_layout
      return unless @layout_sprite
      @layout_sprite.bitmap.dispose
      @layout_sprite.dispose
    end
    #--------------------------------------------------------------------------- 
    alias :old_terminate_e222             :terminate
    #---------------------------------------------------------------------------
    def terminate
      old_terminate_e222
      dispose_layout
    end
    #--------------------------------------------------------------------------- 
  end # /class_eval 
end # /each 
#=============================================================================== 
# ** Cache 
#=============================================================================== 
module Cache 
  #----------------------------------------------------------------------------- 
  def self.menu(filename) 
    load_bitmap("Graphics/Menu/", filename) 
  end
  #----------------------------------------------------------------------------- 
end
#=============================================================================== 
# END 
#===============================================================================

鸡蛋

鲜花

评论 (0 个评论)

facelist doodle 涂鸦笔

您需要登录后才可以评论 登录 | 注册会员

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-28 11:18

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

返回顶部