-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_dir_data.php
141 lines (130 loc) · 3.05 KB
/
get_dir_data.php
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
<?php
// $GAME = 'attila';
// $GAME = 'rome_2';
// $GAME = 'three_kingdoms';
// $GAME = 'thrones_of_britannia';
// $GAME = 'troy';
// $GAME = 'warhammer';
$GAME = 'warhammer_2';
$dir = 'ui';
// $dir = 'ui-'. $GAME;
$DIR_DATA = array(
'battle' => array(
'NAME' => 'Battle UI',
'FOLDER' => $dir. '/battle ui/',
'FILES' => array()
),
'campaign' => array(
'NAME' => 'Campaign UI',
'FOLDER' => $dir. '/campaign ui/',
'FILES' => array()
),
'common' => array(
'NAME' => 'Common UI',
'FOLDER' => $dir. '/common ui/',
'FILES' => array()
),
'frontend' => array(
'NAME' => 'Frontend UI',
'FOLDER' => $dir. '/frontend ui/',
'FILES' => array()
),
'historical_battles' => array(
'NAME' => 'Historical Battles',
'FOLDER' => $dir. '/historical_battles/',
'FILES' => array()
),
'loading' => array(
'NAME' => 'Loading UI',
'FOLDER' => $dir. '/loading_ui/',
'FILES' => array()
),
'lcd' => array(
'NAME' => 'LCD',
'FOLDER' => $dir. '/lcd/',
'FILES' => array()
),
'templates' => array(
'NAME' => 'Templates',
'FOLDER' => $dir. '/templates/',
'FILES' => array()
),
'tech_trees' => array(
'NAME' => 'Tech Trees',
'FOLDER' => $dir. '/tech_trees/',
'FILES' => array()
)
);
$dirs = null;
if (!isset($GAME)){ $GAME = null; }
switch ($GAME){
case 'attila':
case 'rome_2':
$dirs = array('battle', 'campaign', 'common', 'frontend', 'lcd', 'loading');
break;
case 'troy':
case 'warhammer':
case 'warhammer_2':
$dirs = array('battle', 'campaign', 'common', 'frontend', 'loading', 'templates');
break;
case 'thrones_of_britannia':
$dirs = array('battle', 'campaign', 'common', 'frontend', 'loading');
break;
case 'three_kingdoms':
$dirs = array('battle', 'campaign', 'common', 'frontend', 'historical_battles', 'loading', 'templates', 'tech_trees');
break;
}
if ($dirs !== null){
$unset = array_diff(array_keys($DIR_DATA), $dirs);
foreach ($unset as $key){
unset($DIR_DATA[ $key ]);
}
}
$DIR_DATA['export'] = array(
'NAME' => 'Export',
'DIR' => __DIR__ .'/export/',
'FILES' => array()
);
// $DIR_DATA['export_CSQ'] = array(
// 'NAME' => 'Export CSQ',
// 'DIR' => __DIR__ .'/export_CSQ/',
// 'FILES' => array()
// );
unset($a);
foreach ($DIR_DATA as &$a){
if (!isset($a['DIR'])){
$a['DIR'] = __DIR__ .'/game/'. $a['FOLDER'];
}
else{
$b = explode('/', $a['DIR']);
if (empty($b[ sizeof($b) - 1 ])){ $b = $b[ sizeof($b) - 2 ]; }
else{ $b = $b[ sizeof($b) - 1 ]; }
$a['FOLDER'] = $b;
}
}
unset($a);
$all = array();
unset($arr);
foreach ($DIR_DATA as $dir_key => &$arr){
$dir = $arr['DIR'];
foreach (scandir($dir) as $file){
if ($file === '.' || $file === '..' || is_dir($dir . $file) || strpos($file, '.') !== false){ continue; }
$path = $dir . $file;
$h = fopen($path, 'r');
if (!$h){ continue; }
$version = fread($h, 10);
if (!feof($h)){
$v = (int)substr($version, 7);
if ($v < 70 || $v > 133){
var_dump('Unsupported Version'. $v.': '. $arr['FOLDER'] . $file);
continue;
}
$arr['FILES'][ $file ] = $v;
$all[] = array($path, $file, $v);
}
fclose($h);
$h = null;
}
}
unset($arr);
return $all;