Relegation of integer-based resources to history.
Documentation has been updated and header files have been re-sorted as a result of this. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3024 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -9,29 +9,16 @@ contentdir = os.path.join (basedir, "content")
|
||||
srcdir = os.path.join (basedir, "src")
|
||||
|
||||
class ResEntry(object):
|
||||
def __init__(self, line_num, hfile, ls2file, constant, pkg, inst, typ, res_id, res_type, res_file):
|
||||
def __init__(self, line_num, constant, res_id, hfile, res_type, res_file):
|
||||
self.line_num = line_num
|
||||
self.hfile = hfile
|
||||
self.ls2file = ls2file
|
||||
self.constant = constant
|
||||
self.package = int(pkg)
|
||||
self.instance = int(inst)
|
||||
self.int_type = int(typ)
|
||||
self.res_id = res_id
|
||||
self.res_type = res_type
|
||||
self.res_file = res_file
|
||||
def res_number(self):
|
||||
return res_encode (self.package, self.instance, self.int_type)
|
||||
def csv_line(self):
|
||||
return "%s,%s,%s,%d,%d,%d,%s,%s,%s" % (self.hfile, self.ls2file, self.constant,
|
||||
self.package, self.instance, self.int_type,
|
||||
self.res_id, self.res_type, self.res_file)
|
||||
|
||||
def res_encode(pkg, instance, t):
|
||||
return ((pkg & 0x7ff) << 21) | ((instance & 0x1FFF) << 8) | (t & 0xFF)
|
||||
|
||||
def res_encode_str (pkg, instance, t):
|
||||
return "0x%08xL" % res_encode (pkg, instance, t)
|
||||
return "%s,%s,%s,%s,%s" % (self.constant,self.res_id, self.hfile,
|
||||
self.res_type, self.res_file)
|
||||
|
||||
def read_csv (fname="resources.csv"):
|
||||
result = []
|
||||
@@ -45,11 +32,8 @@ def read_csv (fname="resources.csv"):
|
||||
line = line.strip()
|
||||
if len(line) > 0:
|
||||
data = [x.strip() for x in line.split (',')]
|
||||
if len(data) == 9:
|
||||
try:
|
||||
result.append(ResEntry(linenum, *data))
|
||||
except ValueError:
|
||||
print>>sys.stderr, "Warning: Noninteger P/I/T in line %d" % linenum
|
||||
if len(data) == 5:
|
||||
result.append(ResEntry(linenum, *data))
|
||||
else:
|
||||
print>>sys.strderr, "Warning: Incorrect number of fields in line %d" % linenum
|
||||
return result
|
||||
@@ -62,23 +46,6 @@ def get_headers(l):
|
||||
names.sort()
|
||||
return names
|
||||
|
||||
|
||||
def get_resfiles(l):
|
||||
result = {}
|
||||
for res in l:
|
||||
result[res.ls2file]=True
|
||||
names = result.keys()
|
||||
names.sort()
|
||||
return names
|
||||
|
||||
def ls2_text(index, vals):
|
||||
result = []
|
||||
in_index = [x for x in vals if x.ls2file == index]
|
||||
in_index.sort(lambda x,y: x.res_number() - y.res_number())
|
||||
for entry in in_index:
|
||||
result.append("%3d %3d %3d %s" % (entry.package, entry.instance, entry.int_type, entry.res_id))
|
||||
return result
|
||||
|
||||
def rmp_text(vals):
|
||||
result = []
|
||||
in_index = [x for x in vals if x.res_file != "--"]
|
||||
@@ -91,24 +58,13 @@ def rmp_text(vals):
|
||||
result.append("%s = UNKNOWNRES:%s" % (entry.res_id, entry.res_file))
|
||||
return result
|
||||
|
||||
def h_integer_text(header, vals):
|
||||
def header_text(header, vals):
|
||||
result = ["/* This file was auto-generated by the gen_resfiles utility and",
|
||||
" should not be edited directly. Modify the master resource list",
|
||||
" instead and regenerate. */",
|
||||
""]
|
||||
in_index = [x for x in vals if x.hfile == header]
|
||||
in_index.sort(lambda x,y: x.res_number() - y.res_number())
|
||||
for entry in in_index:
|
||||
result.append("#define %s %s" % (entry.constant, res_encode_str(entry.package, entry.instance, entry.int_type)))
|
||||
return result
|
||||
|
||||
def h_string_text(header, vals):
|
||||
result = ["/* This file was auto-generated by the gen_resfiles utility and",
|
||||
" should not be edited directly. Modify the master resource list",
|
||||
" instead and regenerate. */",
|
||||
""]
|
||||
in_index = [x for x in vals if x.hfile == header]
|
||||
in_index.sort(lambda x,y: x.res_number() - y.res_number())
|
||||
in_index.sort(lambda x,y: cmp(x.constant, y.constant))
|
||||
for entry in in_index:
|
||||
result.append("#define %s \"%s\"" % (entry.constant, entry.res_id))
|
||||
return result
|
||||
@@ -123,25 +79,14 @@ def dump_values(data):
|
||||
print>>outfile, l
|
||||
outfile.close()
|
||||
|
||||
def collate_integer_data(data):
|
||||
result = {}
|
||||
headers = get_headers(data)
|
||||
indices = get_resfiles(data)
|
||||
for index in indices:
|
||||
result[os.path.join(contentdir, *(index.split('/')))] = ls2_text(index, data)
|
||||
for header in headers:
|
||||
result[os.path.join(srcdir, *(header.split('/')))] = h_integer_text(header, data)
|
||||
result[os.path.join(contentdir, 'uqm.rmp')] = rmp_text(data)
|
||||
return result
|
||||
|
||||
def collate_string_data(data):
|
||||
def collate_data(data):
|
||||
result = {}
|
||||
headers = get_headers(data)
|
||||
for header in headers:
|
||||
result[os.path.join(srcdir, *(header.split('/')))] = h_string_text(header, data)
|
||||
result[os.path.join(srcdir, *(header.split('/')))] = header_text(header, data)
|
||||
result[os.path.join(contentdir, 'uqm.rmp')] = rmp_text(data)
|
||||
return result
|
||||
|
||||
if __name__=="__main__":
|
||||
data = collate_string_data(read_csv())
|
||||
data = collate_data(read_csv())
|
||||
dump_values(data)
|
||||
|
||||
Reference in New Issue
Block a user