じ☆ve冰风 发表于 2026-7-26 09:47:21

Resource Sifter

Resource Sifter
Version: 1.0​


Introduction

This script is a resource management utility tool designed to search your productand list any audio or graphic resoures no longer in use,or not being used by the base RPGMaker database and map system to be specific.

It does not have the capabilityto compare resources to content defined within custom scripts.Only that of the based/default systems and database are recognized.



Screenshots




There.... It's shot....



Demo

Nope.



Script

Spoiler: Here ya go                Code:       
#==============================================================================
# ** Resource Sifter (XP)
#------------------------------------------------------------------------------
#    by DerVVulfman
#    version 1.0
#    08-07-2024 (MM-DD-YYYY)
#    RGSS / RPGMaker XP
#==============================================================================
#
#INTRODUCTION
#============
#
#    This script is a resource management utility tool designed to search your
#    productand list any audio or graphic resoures no longer in use,or not
#    being used by the base RPGMaker database and map system to be specific.
#
#    It does not have the capabilityto compare resources to content defined
#    within custom scripts.Only that of the based/default systems and data-
#    base are recognized.
#
#
#    -------------------------------------------------------------------------
#
#INSTRUCTIONS
#============
#
#    Place below Scene_Debug and above Main.If necessary,the configuration
#    section is available to alter titles and headings if language differences
#    exit. After that, just execute/run your project.
#
#    There will be a temporary pause as the script gathers all your resources
#    and stores them in memory. After that, it will go through your project's
#    database and mapsand erase from the memorized resource lists any files
#    that match.
#
#    When all searching hase been completed, a report will appear within your
#    project's root folder, typically "Sifted Resources.txt" by default. This
#    report will list all of the files that could not be found,and thus not
#    used by your project.
#
#
#    -------------------------------------------------------------------------
#
#WARNING
#=======
#
#    Some filenames may contain characters of which this script cannot account
#    and will be unable to test.If any such files are encountered, they will
#    be separated and may be found on the bottom of the report. The header for
#    these files is "Cannot be used" by the configuration's default.
#
#    The script will gather all your game's resources and store them in memo-
#    ry before comparing themto resources defined/referencedin your game.
#
#    Any resources in your project that are not defined in your game will be
#    project folder for "Audio" not used in your game. That is to say, it will
#    find if you have any extra/unnecessary audio files.
#
#
#    -------------------------------------------------------------------------
#
#COMPATABILITY
#=============
#
#    Designed for RPGMaker XP and its default system/database layout.Custom
#    scripts and systems other than RPGMaker XP are not taken into account.
#
#
#==============================================================================
#
#CREDITS AND TERMS:
#==================
#
#    This is a free-for-use design tool. However, due credit for its use would
#    be appreciated.
#
#    If ported to any other system by a scripter other than myself, I only ask
#    for credit of the original concept,and a link be provides to this topic
#    of origin:https://www.save-point.org/thread-8991.html
#
#
#==============================================================================



#==============================================================================
# ** Resource_Sifter
#------------------------------------------------------------------------------
#This portion of the Resource Sifter module holds the words/dialogue used
#within the generated report.
#==============================================================================

module Resource_Sifter


# FILENAME
# ========
# This is the name of the file generated and saved in your project's folder.
# --------------------------------------------------------------------------
#
    FILENAME= "Sifted Resources.txt"


# NO CONTENT FOUND TEXT
# =====================
# This is a single line of text that will appear in the report if the script
# cannot find any resources unused by your project.
# --------------------------------------------------------------------------
#
    WORDS_NO_CONTENT= "No content to report"      # Text if all checks out


# MAIN DOCUMENT HEADINGS
# ======================
# This is where you define the title of the reportas it will appear at the
# top, and the smaller headings for the Audio and Graphic resources found.
# --------------------------------------------------------------------------
#
    WORDS_TITLE       = "SIFTED RESOURCES REPORT"   # Report title/header
    WORDS_AUDIO       = "Audio"                     # Audio resources header
    WORDS_GRAPHICS    = "Graphics"                  # Graphic resources header


# EDITABLE HEADINGS: AUDIO
# ========================
# This is whereyou define the headingsfor the individual audio resources
# that may still exist within your project,but are unused.These headings
# should basically conform to the subfolders in the project's Audio folder.
# --------------------------------------------------------------------------
#
    WORDS_BGM         = "Background Music"
    WORDS_BGS         = "Background/Ambient Sound"
    WORDS_ME          = "Music Effects"
    WORDS_SE          = "Sound Effects"


# EDITABLE HEADINGS: GRAPHICS
# ===========================
# This is where you define the headings for the individual graphic resources
# that may still exist within your project,but are unused.These headings
# should basically conform to the subfolders in the project's Graphic folder.
# --------------------------------------------------------------------------
#
    WORDS_ANIMATIONS= "Animation(s)"
    WORDS_AUTOTILES   = "Map Auto-Tile(s)"
    WORDS_BATTLEBACKS = "Battleback(s)"
    WORDS_BATTLERS    = "Battler(s)"
    WORDS_CHARACTERS= "Character Set(s)"
    WORDS_FOGS      = "Fog(s)"
    WORDS_GAMEOVERS   = "Gameover screen(s)"
    WORDS_ICONS       = "Icon(s)"
    WORDS_PANORAMAS   = "Panorama(s)"
    WORDS_PICTURES    = "Picture(s)"
    WORDS_TILESETS    = "Map Tileset(s)"
    WORDS_TITLES      = "Title Screen(s)"
    WORDS_TRANSITIONS = "Transition(s)"
    WORDS_WINDOWSKINS = "Windowskin(s)"


# EDITABLE HEADINGS: INVALID
# ==========================
# This is whereyou define the headingsfor the individual resources whose
# filename may contain illegal characters that this script is unable to test.
# --------------------------------------------------------------------------
#
    WORDS_INVALID   = "Cannot be used"


end


#==============================================================================
#                            DO NOT PROCEED FURTHER
#==============================================================================



#==============================================================================
# ** Resource_Sifter
#------------------------------------------------------------------------------
#This portion of the Resource Sifter module is the executable code. It is not
#to be altered or edited.All editing takes place in the above section.
#==============================================================================

module Resource_Sifter


#--------------------------------------------------------------------------
# * Invariables
#--------------------------------------------------------------------------
GFX = ['@system_l.gameover_name',          '@system_l.title_name',
         '@system_l.battle_transition',      '@system_l.windowskin_name',
         '@system_l.title_bgm.name',         '@system_l.battle_bgm.name',
         '@system_l.battle_end_me.name',   '@system_l.gameover_me.name']
         
SFX = ['@system_l.cursor_se.name',         '@system_l.decision_se.name',
         '@system_l.cancel_se.name',         '@system_l.buzzer_se.name',
         '@system_l.equip_se.name',          '@system_l.shop_se.name',
         '@system_l.save_se.name',         '@system_l.load_se.name',
         '@system_l.battle_start_se.name',   '@system_l.escape_se.name',   
         '@system_l.actor_collapse_se.name', '@system_l.enemy_collapse_se.name']



#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def self.main
    #
    setup                                     # Setup data
    update                                    # Update/Process tests
    output                                    # Output result(s)
    #
end



#--------------------------------------------------------------------------
# * Main Proccing Commands
#--------------------------------------------------------------------------

#--------------------------------------------------------------------------
# * Setup
#--------------------------------------------------------------------------
def self.setup
    #
    setup_database                            # Load editor database
    setup_arrays                              # Create resource arrays
    setup_files                               # Load resources
    #
end
#--------------------------------------------------------------------------
# * Update and perform searches
#--------------------------------------------------------------------------
def self.update
    #
    search_actors                           # Search actor database
    search_animations                         # Search animations database
    search_common                           # Search common events
    search_enemy                              # Search enemy database
    search_icons                              # Search databases for Icons
    search_map                              # Search map content
    search_se                                 # Search databased for SE
    search_system                           # Search system database
    search_tiles                              # Search tileset database
    #
end
#--------------------------------------------------------------------------
# * Output Content
#--------------------------------------------------------------------------
def self.output
    #
    # Open the file with the defined filename
    filename= Resource_Sifter::FILENAME
    f         = File.new(filename,"w+")            
    #
    # Generate Title Header
    output_header(f, Resource_Sifter::WORDS_TITLE, true )
    #
    #
    # Empty report if no viable content
    unless output_test
      output_text(f, "")
      output_text(f, Resource_Sifter::WORDS_NO_CONTENT)
      return
    end
    #
    #
    output_body(f)
    #
    f.close
    #
end



#--------------------------------------------------------------------------
# * Setup Commands
#--------------------------------------------------------------------------

#--------------------------------------------------------------------------
# * Setup (when gaining access to the RMXP database)
#--------------------------------------------------------------------------
def self.setup_database
    #
    @actor_l    = load_data("Data/Actors.rxdata")
    @anim_l   = load_data("Data/Animations.rxdata")
    @armor_l    = load_data("Data/Armors.rxdata")
    @common_l   = load_data("Data/CommonEvents.rxdata")
    @enemy_l    = load_data("Data/Enemies.rxdata")
    @item_l   = load_data("Data/Items.rxdata")
    @skill_l    = load_data("Data/Skills.rxdata")
    @tiles_l    = load_data("Data/Tilesets.rxdata")
    @troop_l    = load_data("Data/Troops.rxdata")
    @map_l      = load_data("Data/MapInfos.rxdata")
    @system_l   = load_data("Data/System.rxdata")
    @weapon_l   = load_data("Data/Weapons.rxdata")
    #
end
#--------------------------------------------------------------------------
# * Setup (when creating the empty resource arrays)
#--------------------------------------------------------------------------
def self.setup_arrays
    #
    # Audio
    @root_bgm       = []    # Background music
    @root_bgs       = []    # Ambient background sound
    @root_me      = []    # Music effects
    @root_se      = []    # Sound effects
    #
    # Graphics
    @root_anims   = []   # Animations
    @root_auto      = []   # Autotiles
    @root_backs   = []   # Battlebacks
    @root_batt      = []   # Battlers
    @root_chars   = []   # Characters
    @root_fogs      = []   # Fogs
    @root_g_over    = []   # Game Over
    @root_icons   = []   # Icons
    @root_pan       = []   # Panoramas
    @root_pics      = []   # Pictures
    @root_tiles   = []   # Tilesets
    @root_title   = []   # Title
    @root_trans   = []   # Transition
    @root_w_skin    = []   # Windowskin
    #
    @invalid      = []   # Cannot be validated
    #
end
#--------------------------------------------------------------------------
# * Setup (when loading all resource content)
#--------------------------------------------------------------------------
def self.setup_files
    #
    # Audio
    setup_file_load(@root_bgm,      "Audio/BGM/*")
    setup_file_load(@root_bgs,      "Audio/BGS/*")
    setup_file_load(@root_me,       "Audio/ME/*")
    setup_file_load(@root_se,       "Audio/SE/*")
    #
    # Graphics
    setup_file_load(@root_anims,    "Graphics/Animations/*")
    setup_file_load(@root_auto,   "Graphics/Autotiles/*")
    setup_file_load(@root_backs,    "Graphics/Battlebacks/*")
    setup_file_load(@root_batt,   "Graphics/Battlers/*")
    setup_file_load(@root_chars,    "Graphics/Characters/*")
    setup_file_load(@root_fogs,   "Graphics/Fogs/*")
    setup_file_load(@root_g_over,   "Graphics/Gameovers/*")
    setup_file_load(@root_icons,    "Graphics/Icons/*")
    setup_file_load(@root_pan,      "Graphics/Panoramas/*")
    setup_file_load(@root_pics,   "Graphics/Pictures/*")
    setup_file_load(@root_tiles,    "Graphics/Tilesets/*")
    setup_file_load(@root_title,    "Graphics/Titles/*")
    setup_file_load(@root_trans,    "Graphics/Transitions/*")
    setup_file_load(@root_w_skin,   "Graphics/Windowskins/*")
    #
end
#--------------------------------------------------------------------------
# * Setup (when acquiring files from a game resource folder)
#   pathway_list : pathway specific resource array
#   path_test    : the folder path for a resource
#--------------------------------------------------------------------------
def self.setup_file_load(pathway_list, path_test)
    #
    path_len= (path_test.length) -1         # Get pathway length (minus *)
    #
    for name in Dir                # Cycle through root folder
      #
      unless FileTest.exist?(name)            # If cannot be tested
      @invalid.push(name)                   # Push into untestable array
      next                                  # And skip to next
      end
      #
      next if File.stat(name).directory?      # If NOT a subfolder
      name_len = name.length                  # Get filename's length
      name_len -= path_len                  # Shorten length by path length
      name = name.slice(path_len, name_len)   # Trim the audio name
      pathway_list.push(name)               # Push into the root path list
    end
    #
end



#--------------------------------------------------------------------------
# * Update Search Commands
#--------------------------------------------------------------------------

#--------------------------------------------------------------------------
# * Actor Database Search
#--------------------------------------------------------------------------
def self.search_actors
    #
    for actor in @actor_l                     # Cycle through actors
      #
      next if actor.nil?                      # Skip invalid actor
      test_char(actor.character_name)         # Test Character
      test_battler(actor.battler_name)      # Test Battler      
      #
    end
    #
end
#--------------------------------------------------------------------------
# * Animation Database Search
#--------------------------------------------------------------------------
def self.search_animations
    #
    for anim in @anim_l                     # Cycle through animations
      #
      next if anim.nil?                     # Skip invalid animation
      test_anim(anim.animation_name)          # Test animation
      #
      times = anim.timings                  # Acquire timing for animation
      for timed in times                      # Cycle through timing
      next if timed.nil?                  # Skip invalid timing
      test_se(timed.se.name)                # Test SE
      end
      #
    end
    #
end
#--------------------------------------------------------------------------
# * Common Events Database Search
#--------------------------------------------------------------------------
def self.search_common
    #
    for event in @common_l                  # Cycle through all common events
      next if event.nil?                      # Skip invalid event
      list = event.list                     # Get list of commands
      search_events(list)                     #`Search every item in the event
    end
    #
end
#--------------------------------------------------------------------------
# * Enemy Database Search
#--------------------------------------------------------------------------
def self.search_enemy
    #
    for enemy in @enemy_l                     # Cycle through enemies
      #
      next if enemy.nil?                      # Skip invalid enemy
      test_battler(enemy.battler_name)      # Test Battler      
      #
    end
    #
end
#--------------------------------------------------------------------------
# * Icons Search (Multiple Databases)
#--------------------------------------------------------------------------
def self.search_icons
    #
    sift_icons(@armor_l)                      # Armor database
    sift_icons(@item_l)                     # Item database
    sift_icons(@skill_l)                      # Skill database
    sift_icons(@weapon_l)                     # Weapon database
    #
end
#--------------------------------------------------------------------------
# * Map Database Search
#--------------------------------------------------------------------------
def self.search_map
    #
    for map in @map_l                         # Cycle through all maps
      #
      id      = map                      # Get the map ID
      text      = "Data/Map%03d.rxdata"       # Define the Map file structure
      filename= sprintf(text, id)         # Get the formatted map filename
      map_data= load_data(filename)         # Get the map data
      #
      sift_map_params(map_data)               # Search through map parameters
      sift_map_events(map_data)               # Search through map events
      #
    end
    #
end
#--------------------------------------------------------------------------
# * SE Search (Multiple Databases)
#--------------------------------------------------------------------------
def self.search_se
    #
    sift_se(@item_l)                        # Item Database
    sift_se(@skill_l)                         # Skill Database
    #
end
#--------------------------------------------------------------------------
# * System Database Search
#--------------------------------------------------------------------------
def self.search_system
    #
    test_gameover(eval(GFX))               # Test Gameover screen
    test_title(eval(GFX))                  # Test Title screen
    test_trans(eval(GFX))                  # Test Transitions
    test_windowskin(eval(GFX))             # Test Windowskin
    #
    test_bgm(eval(GFX))                  # Test Title Screen BGM
    test_bgm(eval(GFX))                  # Test Battle BGM
    test_me(eval(GFX))                     # Test Battle End ME
    test_me(eval(GFX))                     # Test Gameover ME
    #
    for item in SFX                           # Cycle through all System Sfx
      test_se(eval(item))                     # Test each Sound Effect
    end
    #
end
#--------------------------------------------------------------------------
# * Tileset Database Search
#--------------------------------------------------------------------------
def self.search_tiles
    #
    for tile in @tiles_l                      # Cycle through all tilesets
      #
      next if tile.nil?                     # Skip if no tile data
      autotiles = tile.autotile_names         # Grab autotile names
      for auto in autotiles                   # Cycle through all autotiles
      test_auto(auto)                     # Test autotile
      end
      test_panoramas(tile.panorama_name)      # Test Panorama
      test_fogs(tile.fog_name)                # Test Fogs
      test_battlebacks(tile.battleback_name)# Test Battlebacks
      test_tiles(tile.tileset_name)         # Test Tileset
      #
    end
    #
end



#--------------------------------------------------------------------------
# * Update Sift Commands (executed by searches)
#--------------------------------------------------------------------------

#--------------------------------------------------------------------------
# * Sift through database Icons
#   list : list of database objects
#--------------------------------------------------------------------------
def self.sift_icons(list)
    #
    for list_item in list                     # Cycle through all items in list
      next if list_item.nil?                  # Skip if item invalid
      test_icons(list_item.icon_name)         # Test Icon
    end
    #
end
#--------------------------------------------------------------------------
# * Sift through map events
#   map_data : data acquired from a single map
#--------------------------------------------------------------------------
def self.sift_map_events(map_data)
    #
    events = {}                               # Create the Event hash array
    for i in map_data.events.keys             # Sort through map events
      events = map_data.events          # Fill testable Event hash array
    end
    #
    for event in events                     # Sort through the Event array
      for page in event.pages.reverse      # Sort through Event Pages
      char = page.graphic.character_name    # Get character
      test_char(char)                     # Test Character
      list = page.list                      # Get the list of commands
      search_events(list)                   # Execute resource item search
      end
    end
    #
end
#--------------------------------------------------------------------------
# * Sift through map parameters
#   map_data : data acquired from a single map
#--------------------------------------------------------------------------
def self.sift_map_params(map_data)
    #
    test_bgm(map_data.bgm.name)               # Test the map's auto-run BGM
    test_bgs(map_data.bgs.name)               # Test the map's auto-run BGS
    #
end
#--------------------------------------------------------------------------
# * Sift through database SEs
#   list : list of database objects
#--------------------------------------------------------------------------
def self.sift_se(list)
    #
    for list_item in list                     # Cycle through all items in list
      next if list_item.nil?                  # Skip if item invalid
      test_se(list_item.menu_se.name)         # Test SE
    end
    #
end



#--------------------------------------------------------------------------
# * Update Map Event Search
#--------------------------------------------------------------------------

#--------------------------------------------------------------------------
# * Map Database Search (when sifting through each event command)
#--------------------------------------------------------------------------
def self.search_events(list)
    #
    for list_item in list                     # Cycle through all items in list
      item_0 = list_item.parameters      # Get the item
      item_1 = list_item.parameters      # Get the item
      case list_item.code                     # Branch by item's event code
      #
      when 131 ; test_windowskin(item_0)    # Test Windowskin
      when 132 ; test_bgm(item_0.name)      # Test Battle BGM
      when 133 ; test_me(item_0.name)       # Test Battle End ME
      when 204 ; search_ev_204(list_item)   # Test Map Settings
      when 209 ; search_ev_209(list_item)   # Test Move Route
      when 222 ; test_trans(item_0)         # Test Transition
      when 231 ; test_pictures(item_1)      # Test Picture
      when 241 ; test_bgm(item_0.name)      # Test BGM
      when 245 ; test_bgs(item_0.name)      # Test BGS
      when 249 ; test_me(item_0.name)       # Test ME
      when 250 ; test_se(item_0.name)       # Test SE
      when 322 ; search_ev_322(list_item)   # Test Actor Graphic
      #
      end
    end
end
#--------------------------------------------------------------------------
# * Map Database Search (when changing the map settings)
#--------------------------------------------------------------------------
def self.search_ev_204(list_item)
    #
    item_0 = list_item.parameters      # Get the item
    item_1 = list_item.parameters      # Get the item
    #   
    case item_0
      when 0; test_panoramas(item_1)      # Test Panoramas
      when 1; test_fogs(item_1)         # Test Fogs
      when 2; test_battlebacks(item_1)    # Test Battlebacks
    end
    #
end
#--------------------------------------------------------------------------
# * Map Database Search (when sifting through the move route command)
#--------------------------------------------------------------------------
def self.search_ev_209(list_item)
    #
    move_l = list_item.parameters.list   # Get the move route command list
    for move_item in move_l                   # Cycle through
      item_0 = move_item.parameters      # Get the item
      case move_item.code                     # Branch by item's event code
      when 41 ; test_char(item_0)         # Test Characterset
      when 44 ; test_se(item_0.name)      # Test SE
      end
    end
    #
end
#--------------------------------------------------------------------------
# * Map Database Search (when sifting through the change actor command)
#--------------------------------------------------------------------------
def self.search_ev_322(list_item)
    #
    move_l = list_item.parameters.list   # Get the character
    move_3 = list_item.parameters.list   # Get the battler
    #
    test_char(item_1)                         # Test Character
    test_battler(item_3)                      # Test Battler
    #
end



#--------------------------------------------------------------------------
# * Tests : Audio
#--------------------------------------------------------------------------

#--------------------------------------------------------------------------
# * Test BGM Audio resource and remove from list
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_bgm(filename)
    #
    return if filename.nil?                   # Exit if no file
    return if filename. == ''               # Exit if empty filename
    test_resource(@root_bgm, filename)      # Perform resource test
    #
end
#--------------------------------------------------------------------------
# * Test BGS Audio resource and remove from list
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_bgs(filename)
    #
    return if filename.nil?                   # Exit if no file
    return if filename. == ''               # Exit if empty filename
    test_resource(@root_bgs, filename)      # Perform resource test
    #
end
#--------------------------------------------------------------------------
# * Test ME Audio resource and remove from list
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_me(filename)
    #
    return if filename.nil?                   # Exit if no file
    return if filename. == ''               # Exit if empty filename
    test_resource(@root_me, filename)         # Perform resource test
    #
end
#--------------------------------------------------------------------------
# * Test SE Audio resource and remove from list
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_se(filename)
    #
    return if filename.nil?                   # Exit if no file
    return if filename. == ''               # Exit if empty filename
    test_resource(@root_se, filename)         # Perform resource test
    #
end

#--------------------------------------------------------------------------
# * Tests : Graphic
#--------------------------------------------------------------------------

#--------------------------------------------------------------------------
# * Test Animation Graphic resource and remove from list
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_anim(filename)
    #
    return if filename.nil?                   # Exit if no file
    return if filename. == ''               # Exit if empty filename
    test_resource(@root_anims, filename)      # Perform resource test
    #
end
#--------------------------------------------------------------------------
# * Test Pictures Graphic resource and remove from list
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_auto(filename)
    #
    return if filename.nil?                   # Exit if no file
    return if filename. == ''               # Exit if empty filename
    test_resource(@root_auto, filename)       # Perform resource test
    #
end
#--------------------------------------------------------------------------
# * Test Pictures Graphic resource and remove from list
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_battlebacks(filename)
    #
    return if filename.nil?                   # Exit if no file
    return if filename. == ''               # Exit if empty filename
    test_resource(@root_backs, filename)      # Perform resource test
    #
end
#--------------------------------------------------------------------------
# * Test Battler Graphic resource and remove from list
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_battler(filename)
    #
    return if filename.nil?                   # Exit if no file
    return if filename. == ''               # Exit if empty filename
    test_resource(@root_batt, filename)       # Perform resource test
    #
end
#--------------------------------------------------------------------------
# * Test Character Graphic resource and remove from list
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_char(filename)
    #
    return if filename.nil?                   # Exit if no file
    return if filename. == ''               # Exit if empty filename
    test_resource(@root_chars, filename)      # Perform resource test
    #
end
#--------------------------------------------------------------------------
# * Test Fog Graphic resource and remove from list
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_fogs(filename)
    #
    return if filename.nil?                   # Exit if no file
    return if filename. == ''               # Exit if empty filename
    test_resource(@root_fogs, filename)       # Perform resource test
    #
end
#--------------------------------------------------------------------------
# * Test GameOver Graphic resource and remove from list
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_gameover(filename)
    #
    return if filename.nil?                   # Exit if no file
    return if filename. == ''               # Exit if empty filename
    test_resource(@root_g_over, filename)   # Perform resource test
    #
end
#--------------------------------------------------------------------------
# * Test Icon Graphic resource and remove from list
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_icons(filename)
    #
    return if filename.nil?                   # Exit if no file
    return if filename. == ''               # Exit if empty filename
    test_resource(@root_icons, filename)      # Perform resource test
    #
end
#--------------------------------------------------------------------------
# * Test Panorama Graphic resource and remove from list
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_panoramas(filename)
    #
    return if filename.nil?                   # Exit if no file
    return if filename. == ''               # Exit if empty filename
    test_resource(@root_pan, filename)      # Perform resource test
    #
end
#--------------------------------------------------------------------------
# * Test Pictures Graphic resource and remove from list
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_pictures(filename)
    #
    return if filename.nil?                   # Exit if no file
    return if filename. == ''               # Exit if empty filename
    test_resource(@root_pics, filename)       # Perform resource test
    #
end
#--------------------------------------------------------------------------
# * Test Pictures Graphic resource and remove from list
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_tiles(filename)
    #
    return if filename.nil?                   # Exit if no file
    return if filename. == ''               # Exit if empty filename
    test_resource(@root_tiles, filename)      # Perform resource test
    #
end
#--------------------------------------------------------------------------
# * Test Title Graphic resource and remove from list
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_title(filename)
    #
    return if filename.nil?                   # Exit if no file
    return if filename. == ''               # Exit if empty filename
    test_resource(@root_title, filename)      # Perform resource test
    #
end
#--------------------------------------------------------------------------
# * Test Transition Graphic resource and remove from list
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_trans(filename)
    #
    return if filename.nil?                   # Exit if no file
    return if filename. == ''               # Exit if empty filename
    test_resource(@root_trans, filename)      # Perform resource test
    #
end
#--------------------------------------------------------------------------
# * Test Windowskin Graphic resource and remove from list
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_windowskin(filename)
    #
    return if filename.nil?                   # Exit if no file
    return if filename. == ''               # Exit if empty filename
    test_resource(@root_w_skin, filename)   # Perform resource test
    #
end

#--------------------------------------------------------------------------
# * Tests : Resource Test
#--------------------------------------------------------------------------

#--------------------------------------------------------------------------
# * Test resource and remove from list
#   pathway_list : pathway specific resource array
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_resource(pathway_list, filename)
    #
    temp_list = pathway_list                  # Create copy of pathway list
    new_list= []                            # Create a new list array
    for item in temp_list                     # Cycle through entire list
      item = test_resource_strip(item)      # Strip file extenions for test
      new_list.push(item)                     # Push the stripped file
    end
    #
    unless new_list.include?(filename)      # If file isn't in the new list
      return pathway_list                     # Exit method with pathway list
    end
    #
    idx = new_list.index(filename)            # Get index position
    pathway_list.delete_at(idx)               # Delete at index position
    return pathway_list                     # Exit with updated pathway list
    #
end
#--------------------------------------------------------------------------
# * Strip extension from filename for testing purposes
#   filename   : name of the resource to test
#--------------------------------------------------------------------------
def self.test_resource_strip(filename)
    #
    return filename if filename.nil?          # Exit if not valid
    return filename if filename == ""         # Exit if empty name
    #
    idx = filename.rindex('.')                # Find extension
    return filename if idx.nil?               # Exit if no extension
    #
    filename = filename.slice(0,idx)          # Strip extension
    return filename                           # Exit with updated filename
    #
end


#--------------------------------------------------------------------------
# * Output text to a file
#   file_id      : ID of file which to write
#   text         : text to output
#   center_just: if text is center justified (in 80 column output)
#--------------------------------------------------------------------------
def self.output_header(file_id, text, center_just=false)
    #
    header      = text
    len         = header.length
    margin      = (80-len)/2
    margin      = 0 unless center_just
    output_txt= (" " * margin) + header
    #
    output_text(file_id, output_txt)
    #
    header      = "=" * len
    margin      = 0 unless center_just
    output_txt= (" " * margin) + header
    #
    output_text(file_id, output_txt)
    #
end
#--------------------------------------------------------------------------
# * Determine if text present to output
#--------------------------------------------------------------------------
def self.output_test
    #
    effective= false
    #
    effective   = true if @root_anims!= []
    effective   = true if @root_auto   != []
    effective   = true if @root_backs!= []
    effective   = true if @root_batt   != []
    effective   = true if @root_chars!= []
    effective   = true if @root_fogs   != []
    effective   = true if @root_g_over != []
    effective   = true if @root_icons!= []
    effective   = true if @root_pan    != []
    effective   = true if @root_pics   != []
    effective   = true if @root_tiles!= []
    effective   = true if @root_title!= []
    effective   = true if @root_trans!= []
    effective   = true if @root_w_skin != []
    effective   = true if @root_bgm    != []
    effective   = true if @root_bgs    != []
    effective   = true if @root_me   != []
    effective   = true if @root_se   != []
    effective   = true if @invalid   != []
    #
    return effective
    #
end
#--------------------------------------------------------------------------
# * Output main body report to the file
#   file_id      : ID of file which to write
#--------------------------------------------------------------------------
def self.output_body(file_id)
    #
    # Generate Audio Header
    output_text(file_id, "")
    output_header(file_id, Resource_Sifter::WORDS_AUDIO)
    output_text(file_id, "")
    #
    output_to_file(file_id, @root_bgm,   Resource_Sifter::WORDS_BGM)
    output_to_file(file_id, @root_bgs,   Resource_Sifter::WORDS_BGS)
    output_to_file(file_id, @root_me,    Resource_Sifter::WORDS_ME)
    output_to_file(file_id, @root_se,    Resource_Sifter::WORDS_SE)
    #
    # Generate Graphic Header
    output_text(file_id, "")
    output_header(file_id, Resource_Sifter::WORDS_GRAPHICS)
    output_text(file_id, "")
    #
    output_to_file(file_id, @root_anims,Resource_Sifter::WORDS_ANIMATIONS)
    output_to_file(file_id, @root_auto,   Resource_Sifter::WORDS_AUTOTILES)
    output_to_file(file_id, @root_backs,Resource_Sifter::WORDS_BATTLEBACKS)
    output_to_file(file_id, @root_batt,   Resource_Sifter::WORDS_BATTLERS)
    output_to_file(file_id, @root_chars,Resource_Sifter::WORDS_CHARACTERS)
    output_to_file(file_id, @root_fogs,   Resource_Sifter::WORDS_FOGS)
    output_to_file(file_id, @root_g_over, Resource_Sifter::WORDS_GAMEOVERS)
    output_to_file(file_id, @root_icons,Resource_Sifter::WORDS_ICONS)
    output_to_file(file_id, @root_pan,    Resource_Sifter::WORDS_PANORAMAS)
    output_to_file(file_id, @root_pics,   Resource_Sifter::WORDS_PICTURES)
    output_to_file(file_id, @root_tiles,Resource_Sifter::WORDS_TILESETS)
    output_to_file(file_id, @root_title,Resource_Sifter::WORDS_TITLES)
    output_to_file(file_id, @root_trans,Resource_Sifter::WORDS_TRANSITIONS)
    output_to_file(file_id, @root_w_skin, Resource_Sifter::WORDS_WINDOWSKINS)
    #
    output_text(file_id, "")
    output_text(file_id, "")
    output_to_file(file_id, @invalid,   Resource_Sifter::WORDS_INVALID)
    #
end
#--------------------------------------------------------------------------
# * Output specific line of text to a file
#   file_id      : ID of file which to write
#   text         : text to output
#--------------------------------------------------------------------------
def self.output_text(file_id, text)
    #
    file_id.puts text                         # Print text to file
    #
end
#--------------------------------------------------------------------------
# * Output generated content to a file
#   file_id      : ID of file which to write
#   pathway_list : pathway specific resource array
#   text         : text to output
#--------------------------------------------------------------------------
def self.output_to_file(file_id, pathway_list, text="")
    #
    return if pathway_list.nil?               # Exit if no list
    return if pathway_list == []            # Exit if empty list
    #
    file_id.puts text                         # Print text to file
    #
    text = "-" * 80                           # Create horizontal dash line
    file_id.puts text                         # Print text to file
    #
    for resource_name in pathway_list         # Cycle through all resources
      file_id.puts resource_name            # Print resource name to file
    end
    file_id.puts " "                        # Print Spacer
    #
end
end



#----------------------------------------------------------------------------
# * Execution Command
#----------------------------------------------------------------------------
Resource_Sifter.main




Instructions

Place below Scene_Debug and above Main.If necessary,the configuration section is available to alter titles and headings if language differences exit. After that, just execute/run your project.



Compatibility

Designed for RPGMaker XP and its default system/database layout.Custom scripts and systems other than RPGMaker XP are not taken into account.



Terms and Conditions

This is a free-for-use design tool. However, due credit for its use would be appreciated.

If ported to any other system by a scripter other than myself, I only ask for credit of the original concept,and a link be provides to this topic of origin:https://www.save-point.org/thread-8991.html



NOTE:
If any do create ports of this script, I would indeed provide links to those ports right here.


本贴来自国际rpgmaker官方论坛作者:DerVVulfman处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/resource-sifter.170937/
页: [1]
查看完整版本: Resource Sifter