Updated resources map with the files that describe the resource
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2922 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
+1024
-1024
File diff suppressed because it is too large
Load Diff
@@ -55,8 +55,11 @@ def parse_resmap():
|
||||
xs = [x.strip() for x in line.split('=', 1)]
|
||||
if len (xs) == 2:
|
||||
if ':' in xs[1]:
|
||||
vt = xs[1][:xs[1].index(':')]
|
||||
xs[1] = xs[1][xs[1].index(':')+1:]
|
||||
result[xs[0]] = xs[1]
|
||||
else:
|
||||
vt = "UNKNOWN_RES"
|
||||
result[xs[0]] = (vt, xs[1])
|
||||
return result
|
||||
|
||||
def get_index_from_header (h):
|
||||
@@ -76,23 +79,26 @@ def parse_headers(pkgdata, fnamemap):
|
||||
headerdata = [(x, explorer.read_header(x)) for x in headernames]
|
||||
for (name, defines) in headerdata:
|
||||
index = get_index_from_header (name)
|
||||
name = name[len(srcdir)+1:]
|
||||
if index in pkgdata:
|
||||
resmap = pkgdata[index]
|
||||
for (sym, val) in defines:
|
||||
try:
|
||||
trueval = res_encode (*res_decode_str (val))
|
||||
(vp, vi, vt) = res_decode_str (val)
|
||||
trueval = res_encode (vp, vi, vt)
|
||||
used_indices[trueval]=True
|
||||
if trueval in resmap:
|
||||
res_id = resmap[trueval]
|
||||
used_ids[res_id]=True
|
||||
if res_id in fnamemap:
|
||||
fname = fnamemap[res_id]
|
||||
(res_type, fname) = fnamemap[res_id]
|
||||
else:
|
||||
fname = '--'
|
||||
res_type = '--'
|
||||
else:
|
||||
res_id = '--'
|
||||
fname = '--'
|
||||
result.append((sym, val, res_id, fname))
|
||||
result.append((name, index, sym, vp,vi,vt, res_id, res_type, fname))
|
||||
except ValueError:
|
||||
# This was something that wasn't a resource index
|
||||
pass
|
||||
@@ -108,7 +114,8 @@ def parse_headers(pkgdata, fnamemap):
|
||||
fname = fnamemap[res_id]
|
||||
else:
|
||||
fname = '--'
|
||||
result.append(('--', res_encode_str (res_decode (id)), res_id, fname))
|
||||
(vp, vi, vt) = res_decode(id)
|
||||
result.append(('--', '--', '--', vp, vi, vt, res_id, fname))
|
||||
for id in fnamemap:
|
||||
if id not in used_ids:
|
||||
result.append(('--', '--', id, fnamemap[id]))
|
||||
@@ -128,36 +135,26 @@ def dump_html(vals):
|
||||
<p>This table lists all of the various <tt>#define</tt>s used in the UQM code, the 32-bit RESOURCE index, the values it ultimately maps to.</p>
|
||||
|
||||
<table>
|
||||
<tr><th>Constant</th><th>Resource Number</th><th>Resource Name</th><th>Default filename</th></tr>"""
|
||||
<tr><th>Header file</th><th>Resource File</th><th>Constant</th><th>Resource Number</th><th>Resource Name</th><th>Resource Type</th><th>Default filename</th></tr>"""
|
||||
for x in vals:
|
||||
print " <tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>" % x
|
||||
print " <tr><td>%s</td><td>%s</td><td>%s</td><td>%d,%d,%d</td><td>%s</td><td>%s</td><td>%s</td></tr>" % x
|
||||
print """ </table>
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
def dump_csv(vals):
|
||||
for x in vals:
|
||||
print "%s,%s,%s,%s" % x
|
||||
|
||||
def dump_header(vals):
|
||||
print """// This file was AUTO-GENERATED by scan_defines.py
|
||||
|
||||
#ifndef RESINDEX_H_"""
|
||||
for x in vals:
|
||||
print "extern const char *%s;" % x[0]
|
||||
print "#endif // RESINDEX_H_"
|
||||
|
||||
def dump_c_file(vals):
|
||||
print """// This file was AUTO-GENERATED by scan_defines.py"
|
||||
"""
|
||||
for x in vals:
|
||||
print "const char *%s = \"%s\";" % (x[0], x[2])
|
||||
# Header file this belongs to
|
||||
# Resource file this belongs to
|
||||
# Source constant
|
||||
# package, instance, type
|
||||
# Resource id string
|
||||
# Resource type string - must be consistant with type above
|
||||
# filename
|
||||
print "%s,%s,%s,%d,%d,%d,%s,%s,%s" % x
|
||||
|
||||
if __name__ == '__main__':
|
||||
vs = collect_data()
|
||||
#dump_csv(vs)
|
||||
# print "--------"
|
||||
# dump_header(vs)
|
||||
# print "--------"
|
||||
dump_c_file(vs)
|
||||
|
||||
# dump_csv(vs)
|
||||
# print "--------"
|
||||
dump_html(vs)
|
||||
|
||||
Reference in New Issue
Block a user