- crackerwoodMembre
- Nombre de messages : 364
Age : 39
Localisation : Derrière son pc y parait
Distinction : aucune
Date d'inscription : 03/08/2008
Scanner de ressource
Mar 27 Aoû 2013 - 17:40
Voici un script de Zeus81 qui permet de scanner les ressources.
Le script, une fois lancé, va scanner les ressources utilisées par votre projet RMXP et écrire dans un fichier texte les ressources qui servent et celle qui ne servent pas. Ca va vous permettre d'alléger votre projet et aussi de ne pas avoir de bug à cause d'un manque de ressources quelconque.
Le script, une fois lancé, va scanner les ressources utilisées par votre projet RMXP et écrire dans un fichier texte les ressources qui servent et celle qui ne servent pas. Ca va vous permettre d'alléger votre projet et aussi de ne pas avoir de bug à cause d'un manque de ressources quelconque.
- Code:
#=================================
# Resource Scanner v2.3
# Script créé par Zeus81
#=================================
#
#
# Pour l'utiliser faire insérer un script et écrire :
# $scene = Scene_Resource_Scan.new
# Sinon vous pouvez aussi l'écrire en dessous de $scene = Scene_Title.new
# dans le Main pour qu'il se lance automatiquement au démarrage
# comme ça c'est plus rapide !
class Window_Help_Scroll < Window_Base
SPACE = " " * 8
def initialize
super(0, 428, 640, 64)
self.contents = Bitmap.new(1, 1)
self.contents.font = Font.new("Comic Sans MS", 20)
self.windowskin = nil
@wait_count = @text_width = 0
end
def set_text(text, align = 0)
if text != @text or align != @align
@text, @align, @wait_count, self.ox, font = text, align, 100, 0, self.contents.font
if (w = self.contents.text_size(text).width) >= width-32
text += SPACE + text
w += (@text_width = self.contents.text_size(SPACE).width + w)
else @text_width, w = 0, width-32
end
self.contents.dispose
self.contents = Bitmap.new(w, 32)
self.contents.font = font
self.contents.draw_text(self.contents.rect, text, align)
end
self.ox = (self.ox >= @text_width ? 0 : self.ox+1) if @text_width > 0 and (@wait_count -= 1) < 0
end
end
class Window_Resource_Scan < Window_Selectable
attr_reader :options
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font = Font.new("Comic Sans MS", 22)
@item_max = 30
@index = 0
refresh
end
def refresh
self.contents.clear
self.contents.fill_rect(0, 32, 608, 1, normal_color)
self.contents.fill_rect(256, 32, 1, 416, normal_color)
self.contents.fill_rect(256, 240, 352, 1, normal_color)
self.contents.fill_rect(256, 420, 352, 1, normal_color)
self.contents.font.size = 28
self.contents.font.color = knockout_color
self.contents.draw_text(0, -8, 608, 32, "Resource Scanner", 1)
self.contents.font.size = 20
self.contents.font.color = crisis_color
self.contents.draw_text(0, 32, 256, 32, "Fichiers à analyser", 1)
self.contents.draw_text(256, 32, 352, 32, "Options de configuration", 1)
self.contents.draw_text(256, 240, 352, 32, "Commandes", 1)
self.contents.font.color = normal_color
self.contents.draw_text(0, 64, 128, 32, "Audio", 1)
self.contents.draw_text(0, 96, 128, 32, "BGM", 1)
self.contents.draw_text(0, 120, 128, 32, "BGS", 1)
self.contents.draw_text(0, 144, 128, 32, "ME", 1)
self.contents.draw_text(0, 168, 128, 32, "SE", 1)
self.contents.draw_text(128, 64, 128, 32, "Graphics", 1)
self.contents.draw_text(128, 96, 128, 32, "Animations", 1)
self.contents.draw_text(128, 120, 128, 32, "Autotiles", 1)
self.contents.draw_text(128, 144, 128, 32, "Battlebacks", 1)
self.contents.draw_text(128, 168, 128, 32, "Battlers", 1)
self.contents.draw_text(128, 192, 128, 32, "Characters", 1)
self.contents.draw_text(128, 216, 128, 32, "Fogs", 1)
self.contents.draw_text(128, 240, 128, 32, "Gameovers", 1)
self.contents.draw_text(128, 264, 128, 32, "Icons", 1)
self.contents.draw_text(128, 288, 128, 32, "Panoramas", 1)
self.contents.draw_text(128, 312, 128, 32, "Pictures", 1)
self.contents.draw_text(128, 336, 128, 32, "Tilesets", 1)
self.contents.draw_text(128, 360, 128, 32, "Titles", 1)
self.contents.draw_text(128, 384, 128, 32, "Transitions", 1)
self.contents.draw_text(128, 408, 128, 32, "Windowskins", 1)
self.contents.draw_text(280, 64, 328, 32, "Afficher les fichiers utiles")
self.contents.draw_text(280, 88, 328, 32, "Afficher les fichiers manquants")
self.contents.draw_text(280, 112, 328, 32, "Afficher les fichiers inutiles")
self.contents.draw_text(280, 144, 328, 32, "Calculer le poids des fichiers")
self.contents.draw_text(280, 168, 328, 32, "Afficher les emplacements")
self.contents.draw_text(280, 200, 328, 32, "Afficher les éléments inutiles de la BDD")
self.contents.draw_text(256, 272, 352, 32, "Tout sélectionner", 1)
self.contents.draw_text(256, 296, 352, 32, "Tout désélectionner", 1)
self.contents.draw_text(256, 328, 352, 32, "Commencer l'analyse", 1)
self.contents.draw_text(256, 352, 352, 32, "Quitter", 1)
self.contents.font.size = 16
self.contents.draw_text(260, 418, 64, 20, "Aide")
end
def draw_states(options)
draw_state(0, 64, options[0])
4.times {|i| draw_state(0, 96+i*24, options[i+1])}
draw_state(128, 64, options[5])
14.times {|i| draw_state(128, 96+i*24, options[i+6])}
3.times {|i| draw_state(264, 64+i*24, options[i+20])}
2.times {|i| draw_state(264, 144+i*24, options[i+23])}
draw_state(264, 200, options[25])
end
def draw_state(x, y, state)
self.contents.fill_rect(x+3, y+11, 10, 10, Color.new(29, 82, 129))
self.contents.fill_rect(x+4, y+12, 8, 8, Color.new(255, 255, 255))
self.contents.fill_rect(x+5, y+13, 6, 6, state ? Color.new(34, 161, 34) : Color.new(128, 128, 128))
end
def update_cursor_rect
x, y, w = case @index
when 0 ; [ 0, 68, 120]
when 1..4 ; [ 0, (@index-1 )*24+100, 120]
when 5 ; [128, 68, 120]
when 6..19; [128, (@index-6 )*24+100, 120]
when 20..22; [264, (@index-20)*24+68 , 344]
when 23, 24; [264, (@index-23)*24+148, 344]
when 25; [264, 204, 344]
when 26, 27; [348, (@index-26)*24+276, 172]
when 28, 29; [348, (@index-28)*24+332, 172]
end
self.cursor_rect.set(x, y, w, 24)
end
def update_help
@help_window.set_text case @index
when 0..19; "Sélectionnez les fichiers à analyser ou pas."
when 20; "Fichiers utilisés dans le jeu et présents dans les dossiers du projet."
when 21; "Fichiers utilisés dans le jeu mais absents des dossiers du projet."
when 22; "Fichiers non utilisés dans le jeu mais présents dans les dossiers du projet."
when 23; "Allonge de façon plus ou moins négligeable le temps d'analyse selon le nombre de fichiers."
when 24; "Pour chaque fichier, la liste des commandes l'utilisant est affichée."
when 25; "Liste les éléments de la base de données non utilisés dans le jeu " <<
"(leurs ressources sont considérées comme inutiles)."
when 26; "Active toutes les options."
when 27; "Désactive toutes les options."
when 28; "L'analyse est infaillible si vous n'utilisez pas de scripts et/ou insertions de scripts, " <<
"dans le cas contraire vérifiez que les scripts en question n'utilisent pas des fichiers " <<
"marqués comme inutiles avant de les supprimer."
when 29; "Ferme le jeu."
end, 1
end
end
class Scene_Resource_Scan
def main
unless $game_system
$data_actors = load_data("Data/Actors.rxdata")
$data_classes = load_data("Data/Classes.rxdata")
$data_skills = load_data("Data/Skills.rxdata")
$data_items = load_data("Data/Items.rxdata")
$data_weapons = load_data("Data/Weapons.rxdata")
$data_armors = load_data("Data/Armors.rxdata")
$data_enemies = load_data("Data/Enemies.rxdata")
$data_troops = load_data("Data/Troops.rxdata")
$data_states = load_data("Data/States.rxdata")
$data_animations = load_data("Data/Animations.rxdata")
$data_tilesets = load_data("Data/Tilesets.rxdata")
$data_common_events = load_data("Data/CommonEvents.rxdata")
$data_system = load_data("Data/System.rxdata")
$game_system = Game_System.new
end
@main_window = Window_Resource_Scan.new
@help_window = Window_Help_Scroll.new
@help_window.x, @help_window.width = 272, 368
@main_window.help_window = @help_window
@options = Array.new(26, true)
@options[24] = @options[25] = false
@main_window.draw_states(@options)
Graphics.transition
while ($scene == self)
Graphics.update
Input.update
update
end
Graphics.freeze
@help_window.dispose
@main_window.dispose
end
def update
@main_window.update
if Input.repeat?(Input::LEFT) or Input.repeat?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
@main_window.index = case @main_window.index
when 0..4 ; Input.repeat?(Input::LEFT) ? 26 : 5
when 5..19; Input.repeat?(Input::LEFT) ? 0 : 20
when 20..25; Input.repeat?(Input::LEFT) ? 5 : 26
else Input.repeat?(Input::LEFT) ? 20 : 0
end
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
case @main_window.index
when 0..25
@options[@main_window.index] = !@options[@main_window.index]
case @main_window.index
when 0; 4.times {|i| @options[i+1] = @options[0]}
when 5; 14.times {|i| @options[i+6] = @options[5]}
when 1..4
@options[0] = false
4.times {|i| @options[0] ||= @options[i+1]}
when 6..19
@options[5] = false
14.times {|i| @options[5] ||= @options[i+6]}
end
when 26; @options.each_index {|i| @options[i] = true}
when 27; @options.each_index {|i| @options[i] = false}
when 28
if resource_scan? or @options[25]
then start_scan
else print("Inutile de lancer un scan vide.")
end
when 29; $scene = nil
end
@main_window.draw_states(@options)
elsif Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@main_window.index = 29
end
end
def resource_scan?
(@options[20] or @options[21] or @options[22]) and
(@options[0] or @options[5])
end
def get_path(type)
case type
when 1; "Audio/BGM/"
when 2; "Audio/BGS/"
when 3; "Audio/ME/"
when 4; "Audio/SE/"
when 6; "Graphics/Animations/"
when 7; "Graphics/Autotiles/"
when 8; "Graphics/Battlebacks/"
when 9; "Graphics/Battlers/"
when 10; "Graphics/Characters/"
when 11; "Graphics/Fogs/"
when 12; "Graphics/Gameovers/"
when 13; "Graphics/Icons/"
when 14; "Graphics/Panoramas/"
when 15; "Graphics/Pictures/"
when 16; "Graphics/Tilesets/"
when 17; "Graphics/Titles/"
when 18; "Graphics/Transitions/"
when 19; "Graphics/Windowskins/"
end
end
MultiByteToWideChar = Win32API.new('kernel32', 'MultiByteToWideChar', 'iipipi', 'i')
WideCharToMultiByte = Win32API.new('kernel32', 'WideCharToMultiByte', 'iipipipp', 'i')
GetShortPathName = Win32API.new('kernel32', 'GetShortPathName', 'ppi', 'i')
def lpath_to_spath(string)
@utf16_buff ||= "\0" * 512
@ansi_buff ||= "\0" * 256
@spath_buff ||= "\0" * 256
MultiByteToWideChar.call(65001, 0, string, -1, @utf16_buff, 256) # utf8 => utf16
WideCharToMultiByte.call(0, 0, @utf16_buff, -1, @ansi_buff, 256, 0, 0) # utf16 => ansi
l = GetShortPathName.call(@ansi_buff, @spath_buff, 256)
return @spath_buff[0,l]
end
def get_size(path)
return 0 unless @options[23]
if FileTest.directory?(spath=lpath_to_spath(path))
entries = Dir.entries(spath)
2.times {entries.shift}
size = 0
entries.each {|entry| size += get_size("#{path}/#{entry}")}
return size
else return FileTest.size(spath)
end
end
def get_size_text(size)
if size >= 1000000
then "%0.2f Mo" % (size / 1048576.0)
elsif size >= 1000
then "%0.2f Ko" % (size / 1024.0)
else "#{size} octets"
end
end
def add_used_file(type, file_name, command_name)
if @options[type] and !file_name.empty?
id = -1
for gf in @data[:game_files][type]
if gf[0] == file_name
id = @data[:game_files][type].index(gf)
break
end
end
@data[:game_files][type] << [file_name] if id == -1
@data[:game_files][type][id] << command_name if @options[24]
end
end
def start_scan
initialize_scan
scan_files if resource_scan?
scan_maps
scan_common_events
scan_troops
scan_tilesets
scan_systems
scan_enemies
scan_actors
scan_classes
scan_skills
scan_items
scan_weapons
scan_armors
scan_states
scan_animations
sort_data if resource_scan?
write_data
finalize_scan
end
def initialize_scan
@thread = Thread.new {loop {Graphics.update; sleep(5)}}
@data = {}
@data[:project_files] = Array.new(20) {[]}
@data[:game_files] = Array.new(20) {[]}
@data[:usefull_files] = Array.new(20) {[]}
@data[:missing_files] = Array.new(20) {[]}
@data[:useless_files] = Array.new(20) {[]}
@data[:actors] = []
@data[:animations] = []
@data[:armors] = []
@data[:classes] = []
@data[:enemies] = []
@data[:items] = []
@data[:skills] = []
@data[:states] = []
@data[:tilesets] = []
@data[:troops] = []
@data[:weapons] = []
end
def finalize_scan
@thread.kill
@data = @thread = nil
print("L'analyse est terminée !")
Thread.new {system("explorer.exe Scan.log")}
end
def scan_files
for type in 1...20
next if !@options[type] or type == 5 or !FileTest.exist?(path = get_path(type))
@data[:project_files][type] = Dir.entries(path)
2.times {@data[:project_files][type].shift}
for i in 0...@data[:project_files][type].size
fn = @data[:project_files][type][i]
@data[:project_files][type][i] = [File.basename(fn, ".*"), fn, get_size(path+fn)]
end
end
end
def scan_command(command, name)
case command.code
when 41; add_used_file(10, command.parameters[0], name)
when 131; add_used_file(19, command.parameters[0], name)
when 204; add_used_file(14-3*command.parameters[0], command.parameters[1], name)
when 222; add_used_file(18, command.parameters[0], name)
when 231; add_used_file(15, command.parameters[1], name)
when 241, 132; add_used_file(1, command.parameters[0].name, name)
when 245 ; add_used_file(2, command.parameters[0].name, name)
when 249, 133; add_used_file(3, command.parameters[0].name, name)
when 250, 44; add_used_file(4, command.parameters[0].name, name)
when 322; add_used_file(10, command.parameters[1], name)
add_used_file( 9, command.parameters[3], name)
when 126; @data[:items] << command.parameters[0] if command.parameters[1] == 0
when 127; @data[:weapons] << command.parameters[0] if command.parameters[1] == 0
when 128; @data[:armors] << command.parameters[0] if command.parameters[1] == 0
when 129; @data[:actors] << command.parameters[0] if command.parameters[1] == 0
when 207; @data[:animations] << command.parameters[1]
when 301; @data[:troops] << command.parameters[0]
when 302, 605
case command.parameters[0]
when 0; @data[:items] << command.parameters[1]
when 1; @data[:weapons] << command.parameters[1]
when 2; @data[:armors] << command.parameters[1]
end
when 313, 333; @data[:states] << command.parameters[2] if command.parameters[1] == 0
when 318; @data[:skills] << command.parameters[2] if command.parameters[1] == 0
when 321; @data[:classes] << command.parameters[1]
when 336; @data[:enemies] << command.parameters[1]
when 337; @data[:animations] << command.parameters[2]
when 339; @data[:skills] << command.parameters[3] if command.parameters[2] == 1
when 509; scan_command(command.parameters[0], name)
end
end
def scan_maps
map_infos = load_data("Data/MapInfos.rxdata")
for map_id in map_infos.keys.sort
map = load_data("Data/Map%03d.rxdata" % map_id)
@data[:tilesets] << map.tileset_id
@data[:troops] += map.encounter_list
name = "Map %03d #{map_infos[map_id].name} " % map_id
add_used_file(1, map.bgm.name, "#{name}BGM automatique") if map.autoplay_bgm
add_used_file(2, map.bgs.name, "#{name}BGS automatique") if map.autoplay_bgs
for event in map.events.values
for i in 0...event.pages.size
namei = "#{name}Événement %03d Page #{i+1} " % event.id
add_used_file(10, event.pages[i].graphic.character_name, "#{namei}Apparence")
for j in 0...event.pages[i].list.size
scan_command(event.pages[i].list[j], "#{namei}Commande #{j+1}")
end
for j in 0...event.pages[i].move_route.list.size
scan_command(event.pages[i].move_route.list[j], "#{namei}Déplacement #{j+1}")
end
end
end
end
end
def scan_common_events
for common_event_id in 1...$data_common_events.size
name = "Événement commun %03d Commande " % common_event_id
for i in 0...$data_common_events[common_event_id].list.size
scan_command($data_common_events[common_event_id].list[i], "#{name}#{i+1}")
end
end
end
def scan_troops
@data[:troops].uniq!
@data[:troops].delete(0)
for troop_id in @data[:troops]
$data_troops[troop_id].members.each {|member| @data[:enemies] << member.enemy_id}
name = "Groupe d'ennemis %03d Événement de combat Page %d Commande %d"
for i in 0...$data_troops[troop_id].pages.size
for j in 0...$data_troops[troop_id].pages[i].list.size
scan_command($data_troops[troop_id].pages[i].list[j], name % [troop_id, i+1, j+1])
end
end
end
end
def scan_tilesets
@data[:tilesets].uniq!
@data[:tilesets].delete(0)
if @options[5]
for i in @data[:tilesets]
add_used_file(16, $data_tilesets[i].tileset_name, "Tileset %03d Fichier du Tileset" % i)
for j in 0...$data_tilesets[i].autotile_names.size
add_used_file(7, $data_tilesets[i].autotile_names[j], "Tileset %03d Autotile #{j+1}" % i)
end
add_used_file(14, $data_tilesets[i].panorama_name, "Tileset %03d Panorama" % i)
add_used_file(11, $data_tilesets[i].fog_name, "Tileset %03d Brouillard" % i)
add_used_file( 8, $data_tilesets[i].battleback_name, "Tileset %03d Fond de combat" % i)
end
end
end
def scan_systems
@data[:actors] += $data_system.party_members
if @options[0]
add_used_file(1, $data_system.title_bgm.name, "Système Musique de l'écran titre")
add_used_file(1, $data_system.battle_bgm.name, "Système Musique des combats")
add_used_file(3, $data_system.battle_end_me.name, "Système Musique de victoire")
add_used_file(3, $data_system.gameover_me.name, "Système Musique de gameover")
add_used_file(4, $data_system.cursor_se.name, "Système Effet sonore du curseur")
add_used_file(4, $data_system.decision_se.name, "Système Effet sonore de validation")
add_used_file(4, $data_system.cancel_se.name, "Système Effet sonore d'annulation")
add_used_file(4, $data_system.buzzer_se.name, "Système Effet sonore du buzzer")
add_used_file(4, $data_system.equip_se.name, "Système Effet sonore d'équipement")
add_used_file(4, $data_system.shop_se.name, "Système Effet sonore d'achat")
add_used_file(4, $data_system.save_se.name, "Système Effet sonore de sauvegarde")
add_used_file(4, $data_system.load_se.name, "Système Effet sonore de chargement")
add_used_file(4, $data_system.battle_start_se.name, "Système Effet sonore de début de combat")
add_used_file(4, $data_system.escape_se.name, "Système Effet sonore de fuite")
add_used_file(4, $data_system.actor_collapse_se.name, "Système Effet sonore de mort d'un allié")
add_used_file(4, $data_system.enemy_collapse_se.name, "Système Effet sonore de mort d'un ennemi")
end
if @options[5]
add_used_file(12, $data_system.gameover_name, "Système Ecran de gameover")
add_used_file(17, $data_system.title_name, "Système Ecran titre")
add_used_file(18, $data_system.battle_transition, "Système Transition vers les combats")
add_used_file(19, $data_system.windowskin_name, "Système Apparence des fenêtres")
end
end
def scan_enemies
@data[:enemies].uniq!
@data[:enemies].delete(0)
for i in @data[:enemies]
@data[:animations] << $data_enemies[i].animation1_id
@data[:animations] << $data_enemies[i].animation2_id
@data[:items] << $data_enemies[i].item_id
@data[:weapons] << $data_enemies[i].weapon_id
@data[:armors] << $data_enemies[i].armor_id
$data_enemies[i].actions.each {|action| @data[:skills] << action.skill_id if action.kind == 1}
add_used_file(9, $data_enemies[i].battler_name, "Ennemi %03d Apparence" % i)
end
end
def scan_actors
@data[:actors].uniq!
@data[:actors].delete(0)
for i in @data[:actors]
@data[:classes] << $data_actors[i].class_id
@data[:weapons] << $data_actors[i].weapon_id
@data[:armors] << $data_actors[i].armor1_id
@data[:armors] << $data_actors[i].armor2_id
@data[:armors] << $data_actors[i].armor3_id
@data[:armors] << $data_actors[i].armor4_id
add_used_file(10, $data_actors[i].character_name, "Allié %03d Apparence sur la carte" % i)
add_used_file( 9, $data_actors[i].battler_name, "Allié %03d Apparence en combat" % i)
end
end
def scan_classes
@data[:classes].uniq!
@data[:classes].delete(0)
for i in @data[:classes]
$data_classes[i].learnings.each {|learning| @data[:skills] << learning.skill_id}
end
end
def scan_skills
@data[:skills].uniq!
@data[:skills].delete(0)
for i in @data[:skills]
@data[:animations] << $data_skills[i].animation1_id
@data[:animations] << $data_skills[i].animation2_id
@data[:states] += $data_skills[i].plus_state_set
add_used_file( 4, $data_skills[i].menu_se.name, "Compétence %03d Effet sonore dans le menu" % i)
add_used_file(13, $data_skills[i].icon_name, "Compétence %03d Icône" % i)
end
end
def scan_items
@data[:items].uniq!
@data[:items].delete(0)
for i in @data[:items]
@data[:animations] << $data_items[i].animation1_id
@data[:animations] << $data_items[i].animation2_id
@data[:states] += $data_items[i].plus_state_set
add_used_file( 4, $data_items[i].menu_se.name, "Objet %03d Effet sonore dans le menu" % i)
add_used_file(13, $data_items[i].icon_name, "Objet %03d Icône" % i)
end
end
def scan_weapons
@data[:weapons].uniq!
@data[:weapons].delete(0)
for i in @data[:weapons]
@data[:animations] << $data_weapons[i].animation1_id
@data[:animations] << $data_weapons[i].animation2_id
@data[:states] += $data_weapons[i].plus_state_set
add_used_file(13, $data_weapons[i].icon_name, "Arme %03d Icône" % i)
end
end
def scan_armors
@data[:armors].uniq!
@data[:armors].delete(0)
for i in @data[:armors]
@data[:states] << $data_armors[i].auto_state_id
add_used_file(13, $data_armors[i].icon_name, "Armure %03d Icône" % i)
end
end
def scan_states
@data[:states].uniq!
@data[:states].delete(0)
for i in @data[:states]
@data[:animations] << $data_states[i].animation_id
end
end
def scan_animations
@data[:animations].uniq!
@data[:animations].delete(0)
for i in @data[:animations]
add_used_file(6, $data_animations[i].animation_name, "Animation %03d Fichier d'animation" % i)
for j in 0...$data_animations[i].timings.size
add_used_file(4, $data_animations[i].timings[j].se.name, "Animation %03d Effet sonore #{j+1}" % i)
end
end
end
def sort_data
for type in 1...20
next if !@options[type] or type == 5
pf = gf = nil
@data[:game_files][type].sort!
for gf in @data[:game_files][type]
if @data[:project_files][type].any? {|pf| pf[0] == gf[0]}
then @data[:usefull_files][type] << [pf, gf]
else @data[:missing_files][type] << gf
end
end
for pf in @data[:project_files][type]
@data[:useless_files][type] << pf unless @data[:game_files][type].any? {|gf| pf[0] == gf[0]}
end
for i in 1...@data[:project_files][type].size
if @data[:project_files][type][i][0] == @data[:project_files][type][i-1][0]
@data[:useless_files][type] << @data[:project_files][type][i]
end
end
@data[:useless_files][type].sort!.uniq!
end
end
def write_data
statistics = [0, 0, 0, 0, 0, 0]
file = File.open("Scan.log", "w")
file.write("\t\t\t\t- = RESULTAT DU SCAN = -\n\n\n")
write_resource(file, statistics) if resource_scan?
write_database(file, statistics) if @options[25]
write_statistics(file, statistics)
file.close
end
def write_resource(file, statistics)
for type in 1...20
next if !@options[type] or type == 5
res_stats = [0, 0, 0, 0, 0]
file.write("\n#{get_path(type)}\n")
if @options[20]
res_stats[0] += @data[:usefull_files][type].size
@data[:usefull_files][type].each {|pf_gf| res_stats[1] += pf_gf[0][2]} if @options[23]
size = @options[23] ? "\t[#{get_size_text(res_stats[1])}]" : ""
file.write("\n\t\tFichiers utiles :\t#{res_stats[0]}#{size}\n")
if !@data[:usefull_files][type].empty?
for pf_gf in @data[:usefull_files][type]
pf, gf = pf_gf
file.write("\t\t\t#{pf[1].ljust(31)}")
file.write("\t[#{get_size_text(pf[2])}]") if @options[23]
(1...gf.size).each {|i| file.write("\t- #{gf[i]}")} if @options[24]
file.write("\n")
end
else file.write("\t\t\t-\n")
end
end
if @options[21]
res_stats[2] += @data[:missing_files][type].size
file.write("\n\t\tFichiers manquants :\t#{res_stats[2]}\n")
if !@data[:missing_files][type].empty?
for gf in @data[:missing_files][type]
file.write("\t\t\t#{gf[0].ljust(31)}")
(1...gf.size).each {|i| file.write("\t- #{gf[i]}")} if @options[24]
file.write("\n")
end
else file.write("\t\t\t-\n")
end
end
if @options[22]
res_stats[3] += @data[:useless_files][type].size
@data[:useless_files][type].each {|pf| res_stats[4] += pf[2]} if @options[23]
size = @options[23] ? "\t[#{get_size_text(res_stats[4])}]" : ""
file.write("\n\t\tFichiers inutiles :\t#{res_stats[3]}#{size}\n")
if !@data[:useless_files][type].empty?
for pf in @data[:useless_files][type]
file.write("\t\t\t#{pf[1].ljust(31)}")
file.write("\t[#{get_size_text(pf[2])}]") if @options[23]
file.write("\n")
end
else file.write("\t\t\t-\n")
end
end
5.times {|i| statistics[i] += res_stats[i]}
end
file.write("\n\n")
end
def write_database(file, statistics)
db = [["Alliés :", $data_actors, :actors], ["Classes :", $data_classes, :classes],
["Compétences :", $data_skills, :skills], ["Objets :", $data_items, :items],
["Armes :", $data_weapons, :weapons], ["Armures :", $data_armors, :armors],
["Ennemis :", $data_enemies, :enemies], ["Groupes :", $data_troops, :troops],
["Statuts :", $data_states, :states], ["Animations :", $data_animations, :animations],
["Tilesets :", $data_tilesets, :tilesets]]
file.write("\nÉléments inutiles de la base de données :")
for d in db
pos, elements = 0, d[1].size-1-@data[d[2]].size
file.write("\n\n\t#{d[0].ljust(15)}\t#{elements}")
if elements != 0
for i in 1...d[1].size
next if @data[d[2]].include?(i)
file.write("\n\t") if (pos+=1)%3 == 1
file.write("\t%03d-#{d[1][i].name.ljust(31)}" % i)
end
statistics[5] += elements
else file.write("\n\t\t-")
end
end
file.write("\n\n\n")
end
def write_statistics(file, statistics)
file.write("\nStatistiques :\n\n")
if resource_scan?
size = @options[23] ? "\t[#{get_size_text(statistics[1])}]" : "" if @options[20]
file.write("\tFichiers utiles :\t#{statistics[0]}#{size}\n") if @options[20]
file.write("\tFichiers manquants :\t#{statistics[2]}\n") if @options[21]
size = @options[23] ? "\t[#{get_size_text(statistics[4])}]" : "" if @options[22]
file.write("\tFichiers inutiles :\t#{statistics[3]}#{size}\n") if @options[22]
end
file.write("\tÉléments BDD inutiles :\t#{statistics[5]}\n") if @options[25]
end
end
- Ti-MaxMembre
- Nombre de messages : 1100
Localisation : Canada/Québec
Distinction : Poisson 2018 [Amal']
Date d'inscription : 02/09/2009
Re: Scanner de ressource
Mer 28 Aoû 2013 - 3:22
À chaque fois que je demande une analyse, la même erreur affiche à la ligne 772 string arrow quelque chose.
Ça fonctionne sur ton projet ?
Ça fonctionne sur ton projet ?
- crackerwoodMembre
- Nombre de messages : 364
Age : 39
Localisation : Derrière son pc y parait
Distinction : aucune
Date d'inscription : 03/08/2008
Re: Scanner de ressource
Mer 28 Aoû 2013 - 13:04
Désolé en fait j'ai fais une bétise en le copiant. Je corrige le premier post.
- Elisa'Staffeux retraité
- Nombre de messages : 2924
Age : 26
Localisation : Par là-bas !
Distinction : Mon héritière que je chéris
[Coco' ]
Plus que 2 ans avant d'épouser Coco' ! Compte à rebours lancé !
[Auto-distinction]
Adepte du "Je le savais" alors qu'elle le savait pas.
Date d'inscription : 30/05/2009
Re: Scanner de ressource
Mer 28 Aoû 2013 - 15:57
+1 point de participation, merci du partage !
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum