1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
| #=================================
# 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 |