rusted_71 Scripter Karatan
Posts : 392 Thanked : 11 Engine : RMVX Skill : Beginner Type : Scripter
| Subyek: [XP]Unused File Logger 2011-02-08, 10:55 | |
| Unused File Logger Versi: 1.0 Tipe: Development Tools Add-on PengenalanKarena sering rombak ulang projek, akhirnya banyak file-file sampah di projek gw, jadi buat ngerapihinnya gw bikin script ini Fiturv1.0
- ngecek semua file (graphic dan sound) yang dipakai di database projek kamu...
- ngecek semua file (graphic dan sound) yang dipakai di semua event di semua map yang ada di projek kamu
Screenshotsmasa logger ada screenshotnya, kan hasilnya berupa file .txt atau .doc Scripts- Spoiler:
- Code:
-
=begin ================================================================================ Unused File Logger -------------------------------------------------------------------------------- Version 1.0 by rusted_71 -------------------------------------------------------------------------------- Version History:
1.0 First Version (2 February 2011) -------------------------------------------------------------------------------- Description:
This script is intended to make note of the files (not the RTP files) that are not used in a project. This script checks all files that are used in all events and databases in RPG Maker XP. This script is recommended for use on project development stage, so before compiling the project it is better to remove this script -------------------------------------------------------------------------------- Compatibility:
Should be compatible with almost everything. -------------------------------------------------------------------------------- Instructions: Place this script anywhere above "Main" you can write the log into the file with the following code: print_log in the script command at any event in your project UNUSED_FILE_LOGGER::print_log in the script editor to see the log, you just have to open the file in your project directory -------------------------------------------------------------------------------- Credits and Thanks:
Credits: rusted_71 for making this. -------------------------------------------------------------------------------- Note:
Logs will only be recorded if the above command is executed, so if your project is closed before that command is executed, logs will be not recorded
Every time you record the logs, the file will be overwritten This script does not check the custom scripts used in the project. So to check the custom script, you have to run that custom scripts in the testing of the project. If you have any questions, suggestions or comments, you can find me (rusted_71) at rmid.forumotion.net ================================================================================ =end #=============================================================================== # CONFIGURATION #------------------------------------------------------------------------------- module UNUSED_FILE_LOGGER #the log file name, the file name must with an extension (.txt, .doc) DEF_FILE = "Unused File Log.txt" end #------------------------------------------------------------------------------- # END OF CONFIGURATION #=============================================================================== class Scene_Title alias def_main main def main $unused_file = {} if !FileTest.exist?(UNUSED_FILE_LOGGER::DEF_FILE) new_hash elsif FileTest.size(UNUSED_FILE_LOGGER::DEF_FILE) == 0 new_hash else open_hash end def_main end def open_hash file = File.open(UNUSED_FILE_LOGGER::DEF_FILE, "r") key = "" file.each_line do |line| line[-1,1] = "" if line[/Graphics|Audio/] != nil && key != line key = line $unused_file[key] = [] end $unused_file[key].push(line) if line[/Graphics|Audio|====|----|Writed/] == nil end file.close end def new_hash list = [] Dir.foreach("Graphics/") do |entry| list.push("Graphics/"+entry+"/") if FileTest.directory?("Graphics/"+entry) and entry != "." and entry != ".." end Dir.foreach("Audio/") do |entry| list.push("Audio/"+entry+"/") if FileTest.directory?("Audio/"+entry) and entry != "." and entry != ".." end list.sort list.each do |i| $unused_file[i] = [] Dir.foreach(i) do |entry| entry[-4,4] = "" if entry[/[Pp][Nn][Gg]|[Jj][Pp][Gg]|[Mm][Ii][Dd]|[Oo][Gg][Gg]|[Ww][Mm][Aa]|[Mm][Pp]3|[Ww][Aa][Vv]/] != nil entry[-5,5] = "" if entry[/[Jj][Pp][Ee][Gg]/] != nil $unused_file[i].push(entry) if entry != "." and entry != ".." and entry != "Thumbs.db" end end end end class Interpreter def print_log UNUSED_FILE_LOGGER::print_log end end module Audio class << self alias def_bgm_play bgm_play alias def_bgs_play bgs_play alias def_me_play me_play alias def_se_play se_play def bgm_play(filename, volume = 100, pitch = 100) def_bgm_play(filename, volume, pitch) filename.gsub!("Audio/BGM/","") $unused_file["Audio/BGM/"].delete(filename) end def bgs_play(filename, volume = 80, pitch = 100) def_bgs_play(filename, volume, pitch) filename.gsub!("Audio/BGS/","") $unused_file["Audio/BGS/"].delete(filename) end def me_play(filename, volume = 100, pitch = 100) def_me_play(filename, volume, pitch) file = filename.gsub!("Audio/ME/","") $unused_file["Audio/ME/"].delete(filename) end def se_play(filename, volume = 80, pitch = 100) def_se_play(filename, volume, pitch) filename.gsub!("Audio/SE/","") $unused_file["Audio/SE/"].delete(filename) end end end module RPG::Cache class << self alias def_load_bitmap load_bitmap def load_bitmap(folder_name, filename, hue = 0) $unused_file[folder_name].delete(filename) def_load_bitmap(folder_name, filename, hue) end end end module UNUSED_FILE_LOGGER def self.print_log check_all_map check_all_database dir_file = UNUSED_FILE_LOGGER::DEF_FILE file = FileTest.exist?(dir_file) ? File.open(dir_file,"w") : File.new(dir_file,"w") time = "Writed at "+Time.now.strftime("%d-%b-%Y, %I:%M:%S") file.puts(time) $unused_file.each_key do |key| file.puts("=============================================================") file.puts(key) file.puts("-------------------------------------------------------------") for data in $unused_file[key] file.puts(data) end end file.close p "Log has recorded, check the log in your project directory." end def self.check_all_map map_id = [] Dir.foreach("Data/") do |entry| if entry[/Map/] != nil and entry[/MapInfos/] == nil entry.gsub!(/\.rxdata/, "") map_id.push(entry) end end for id in map_id sim_id = id[-3,3].to_i map = load_data(sprintf("Data/Map%03d.rxdata", sim_id)) tileset = $data_tilesets[map.tileset_id] $unused_file["Graphics/Tilesets/"].delete(tileset.tileset_name) $unused_file["Graphics/Panoramas/"].delete(tileset.panorama_name) $unused_file["Graphics/Fogs/"].delete(tileset.fog_name) $unused_file["Graphics/Battlebacks/"].delete(tileset.battleback_name) for autotile in tileset.autotile_names $unused_file["Graphics/Autotiles/"].delete(autotile) end for i in map.events.keys event = map.events[i] for page in event.pages if page.move_type == 3 route = page.move_route for com in route.list check_move_route(com) end end for command in page.list check_command(command) end grap_del = page.graphic.character_name next if grap_del == "" $unused_file["Graphics/Characters/"].delete(grap_del) end end end end def self.check_all_database check_actors check_skills check_items check_weapons check_armors check_enemies check_troops check_animations check_common_events check_system end def self.check_actors for actor in $data_actors next if actor == nil $unused_file["Graphics/Characters/"].delete(actor.character_name) $unused_file["Graphics/Battlers/"].delete(actor.battler_name) end end def self.check_skills for skill in $data_skills next if skill == nil $unused_file["Graphics/Icons/"].delete(skill.icon_name) $unused_file["Audio/SE/"].delete(skill.menu_se.name) end end def self.check_items for item in $data_items next if item == nil $unused_file["Graphics/Icons/"].delete(item.icon_name) $unused_file["Audio/SE/"].delete(item.menu_se.name) end end def self.check_weapons for weapon in $data_weapons next if weapon == nil $unused_file["Graphics/Icons/"].delete(weapon.icon_name) end end def self.check_armors for armor in $data_armors next if armor == nil $unused_file["Graphics/Icons/"].delete(armor.icon_name) end end def self.check_enemies for enemy in $data_enemies next if enemy == nil $unused_file["Graphics/Battlers/"].delete(enemy.battler_name) end end def self.check_troops for troop in $data_troops next if troop == nil for page in troop.pages for com in page.list check_command(com) end end end end def self.check_animations for animation in $data_animations next if animation == nil $unused_file["Graphics/Animations/"].delete(animation.animation_name) for timing in animation.timings $unused_file["Audio/SE/"].delete(timing.se.name) end end end def self.check_common_events for event in $data_common_events next if event == nil for com in event.list check_command(com) end end end def self.check_system system = $data_system $unused_file["Graphics/Windowskins/"].delete(system.windowskin_name) $unused_file["Graphics/Titles/"].delete(system.title_name) $unused_file["Graphics/Gameovers/"].delete(system.gameover_name) $unused_file["Graphics/Transitions/"].delete(system.battle_transition) $unused_file["Audio/BGM/"].delete(system.title_bgm.name) $unused_file["Audio/BGM/"].delete(system.battle_bgm.name) $unused_file["Audio/ME/"].delete(system.battle_end_me.name) $unused_file["Audio/ME/"].delete(system.gameover_me.name) $unused_file["Audio/SE/"].delete(system.cursor_se.name) $unused_file["Audio/SE/"].delete(system.decision_se.name) $unused_file["Audio/SE/"].delete(system.cancel_se.name) $unused_file["Audio/SE/"].delete(system.buzzer_se.name) $unused_file["Audio/SE/"].delete(system.equip_se.name) $unused_file["Audio/SE/"].delete(system.shop_se.name) $unused_file["Audio/SE/"].delete(system.save_se.name) $unused_file["Audio/SE/"].delete(system.load_se.name) $unused_file["Audio/SE/"].delete(system.battle_start_se.name) $unused_file["Audio/SE/"].delete(system.escape_se.name) $unused_file["Audio/SE/"].delete(system.actor_collapse_se.name) $unused_file["Audio/SE/"].delete(system.enemy_collapse_se.name) end def self.check_command(com) case com.code when 131 #change windowskin $unused_file["Graphics/Windowskins/"].delete(com.parameters[0]) when 132 #change battle BGM $unused_file["Audio/BGM/"].delete(com.parameters[0].name) when 133 #change battle End ME $unused_file["Audio/ME/"].delete(com.parameters[0].name) when 204 #change map setting case com.parameters[0] when 0 $unused_file["Graphics/Panoramas/"].delete(com.parameters[1]) when 1 $unused_file["Graphics/Fogs/"].delete(com.parameters[1]) when 2 $unused_file["Graphics/Battlebacks/"].delete(com.parameters[1]) end when 209 #set move route route = com.parameters[1] for move in route.list check_move_route(move) end when 231 #show picture $unused_file["Graphics/Pictures/"].delete(com.parameters[1]) when 241 #play BGM $unused_file["Audio/BGM/"].delete(com.parameters[0].name) when 245 #play BGS $unused_file["Audio/BGS/"].delete(com.parameters[0].name) when 249 #play ME $unused_file["Audio/ME/"].delete(com.parameters[0].name) when 250 #play SE $unused_file["Audio/SE/"].delete(com.parameters[0].name) when 322 #change actor graphic $unused_file["Graphics/Characters/"].delete(com.parameters[1]) $unused_file["Graphics/Battlers/"].delete(com.parameters[3]) end end def self.check_move_route(com) case com.code when 41 #change graphic $unused_file["Graphics/Characters/"].delete(com.parameters[0]) when 44 #play SE $unused_file["Audio/SE/"].delete(com.parameters[0].name) end end end
WARNING
- hanya gunakan script ini pada saat tahap development projek kamu, klo dah mau di compress trus di kasih ke player disarankan script ini di apus dulu, klo ga saat loading awal game kamu pasti kerasa lama...
- script ini hanya mengecek database dan event2 di map, jadi klo kamu pake custom script yang ngambil gambar langsung ke directory filenya/bukan dari database (cth: custom face script), file-file itu ga akan automatis dicek (kamu harus jalanin script itu dulu, biar filenya diload baru deh ke cek)
- script ini bukan wat ngecek resource RTP...!!
Credits
- cukup tulis ID yang bikin thread ini di list credit projek kamu
- tolong kasih tau ya kalo ada bug... thx before...
| |
|
LiTTleDRAgo Senior
Posts : 712 Thanked : 27 Engine : RMXP Skill : Skilled Type : Scripter
Trophies
Awards: | Subyek: Re: [XP]Unused File Logger 2011-02-08, 12:18 | |
| ini fungsinya mencatat semua file yg kita ga pake yah? mayan nih buat bersihin size game biar kecilan | |
|
KID_VX Senior
Posts : 959 Thanked : 24 Engine : Multi-Engine User Skill : Very Beginner Type : Developer
| Subyek: Re: [XP]Unused File Logger 2011-02-08, 14:54 | |
| wah nice BTW file yang ga dipakainya langsung dihapus , ga di kasih peringatan dulu / kasih log file di notepad / apalah ??? - Spoiler:
Lumayan dah nambah post 1 :swt:
| |
|
rusted_71 Scripter Karatan
Posts : 392 Thanked : 11 Engine : RMVX Skill : Beginner Type : Scripter
| Subyek: Re: [XP]Unused File Logger 2011-02-08, 17:58 | |
| @little : emang tujuan awal bikin ini ya buat bersih2 projek...
@kid:ini ga ngapus kok, kan hasilnya ntar log dari file2 yang ga kepake, ntar ya di apus manual aja... hehehehe | |
|
Sponsored content
| Subyek: Re: [XP]Unused File Logger | |
| |
|