Major reworking of how addon packs work.
Addon packs now provide additional files instead of overriding UIO. They must provide .rmp files to do the necessary overrides. The addons directory has also been moved outside of packages/ and into content/ directly. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2869 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import sys
|
||||
import os
|
||||
import os.path
|
||||
import explorer
|
||||
import mastermap
|
||||
import relst
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
basedir = os.path.join(os.path.pardir, os.path.pardir, "sc2", "content")
|
||||
else:
|
||||
basedir = sys.argv[1]
|
||||
|
||||
verbose = True
|
||||
|
||||
def deploy_map():
|
||||
target = os.path.join(basedir, "uqm.rmp")
|
||||
outfile = file(target, 'wt')
|
||||
if verbose:
|
||||
print "Writing %s..." % target
|
||||
for l in mastermap.create_map(basedir):
|
||||
print>>outfile, l
|
||||
outfile.close()
|
||||
|
||||
def deploy_ls2(name, pkg):
|
||||
newpkg = os.path.splitext(name)[0]+'.ls2'
|
||||
newvals = relst.process(pkg)
|
||||
outfile = file(newpkg, 'wt')
|
||||
print "Writing %s..." % newpkg
|
||||
for l in newvals:
|
||||
print>>outfile, l
|
||||
outfile.close()
|
||||
|
||||
def deploy_ls2s():
|
||||
pkgnames = explorer.get_lists(basedir)
|
||||
packages = [(x, explorer.read_list(x)) for x in pkgnames]
|
||||
for (name, pkg) in packages:
|
||||
deploy_ls2(name, pkg)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
deploy_map()
|
||||
deploy_ls2s()
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ import sys
|
||||
import os
|
||||
import os.path
|
||||
|
||||
def get_lists(d):
|
||||
def collect_extension(d, ext):
|
||||
result = []
|
||||
for (dirpath, dirnames, filenames) in os.walk(d):
|
||||
for l in [f for f in filenames if f.endswith('.lst')]:
|
||||
for l in [f for f in filenames if f.endswith(ext)]:
|
||||
result.append(os.path.join(dirpath, l))
|
||||
return result
|
||||
|
||||
|
||||
+33
-13
@@ -5,6 +5,8 @@ import os.path
|
||||
import explorer
|
||||
import stridgen
|
||||
|
||||
from optparse import OptionParser
|
||||
|
||||
def process (res):
|
||||
result = []
|
||||
for line in res:
|
||||
@@ -24,22 +26,31 @@ def process (res):
|
||||
result.sort()
|
||||
return result
|
||||
|
||||
def get_resources(d):
|
||||
def get_lists(d, ext):
|
||||
result = []
|
||||
packages = [explorer.read_list(x) for x in explorer.get_lists(d)]
|
||||
packages = [explorer.read_list(x) for x in explorer.collect_extension(d, ext)]
|
||||
for package in packages:
|
||||
for line in package:
|
||||
if line[1] not in result:
|
||||
result.append(line[1])
|
||||
return result
|
||||
|
||||
def create_map(d):
|
||||
resources = get_resources(d)
|
||||
def get_resources(d, ext):
|
||||
result = []
|
||||
if not d.endswith(os.path.sep):
|
||||
d += os.path.sep
|
||||
for res in explorer.collect_extension (d, ext):
|
||||
res = res[len(d):]
|
||||
if res not in result:
|
||||
result.append(res)
|
||||
return result
|
||||
|
||||
def create_map(resources):
|
||||
resmap = process(resources)
|
||||
keys = []
|
||||
result = []
|
||||
for r in resmap:
|
||||
key = r.split(':')[0]
|
||||
key = r.split('=')[0].strip()
|
||||
if key in keys:
|
||||
result.append("# ERROR: DUPLICATE KEY %s" % key)
|
||||
else:
|
||||
@@ -48,12 +59,21 @@ def create_map(d):
|
||||
return result
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
d = os.path.join(os.path.pardir, os.path.pardir, "sc2", "content")
|
||||
opts = OptionParser(usage="usage: %prog [options]")
|
||||
opts.add_option("-d", "--content-dir", dest="d",
|
||||
help="Directory to search for resources",
|
||||
default=os.path.join(os.path.pardir, os.path.pardir, "sc2", "content"))
|
||||
opts.add_option("-r", "--raw", action="store_true", default=False,
|
||||
dest="raw", help="do not treat target resources as lists")
|
||||
opts.add_option("-e", "--extension", dest="ext",
|
||||
help="Extension for files to search", default=".lst")
|
||||
|
||||
(options, args)=opts.parse_args()
|
||||
|
||||
if options.raw:
|
||||
l = get_resources(options.d, options.ext)
|
||||
else:
|
||||
d = sys.argv[1]
|
||||
target = os.path.join(d, "uqm.rmp")
|
||||
print target
|
||||
print "-"*len(target)
|
||||
for l in create_map(d):
|
||||
print l
|
||||
l = get_lists(options.d, options.ext)
|
||||
|
||||
for line in create_map(l):
|
||||
print line
|
||||
|
||||
@@ -27,8 +27,10 @@ patterns = [("comm/(.*)/(.*)\.mod", lambda m: "comm.%s.music" % m.group(1)),
|
||||
("ipanims/(.*)\.fon", lambda m: "font.%s" % m.group(1)),
|
||||
("ipanims/(.*)\.snd", lambda m: "sounds.%s" % m.group(1)),
|
||||
("ipanims/(.*)\.mod", lambda m: "music.%s" % m.group(1)),
|
||||
("ipanims/(.*)\.ogg", lambda m: "music.%s" % m.group(1)),
|
||||
("lbm/(.*)\.ani", lambda m: "graphics.%s" % m.group(1)),
|
||||
("lbm/(.*)\.mod", lambda m: "music.%s" % m.group(1)),
|
||||
("lbm/(.*)\.ogg", lambda m: "music.%s" % m.group(1)),
|
||||
("lbm/(.*)\.ct", lambda m: "colortable.%s" % m.group(1)),
|
||||
("lbm/(.*)\.fon", lambda m: "font.%s" % m.group(1)),
|
||||
("lbm/(.*)snd\.snd", lambda m: "sounds.%s" % m.group(1)),
|
||||
@@ -43,6 +45,7 @@ patterns = [("comm/(.*)/(.*)\.mod", lambda m: "comm.%s.music" % m.group(1)),
|
||||
("(.*)/(.*)\.cod", lambda m: "ship.%s.code" % m.group(1)),
|
||||
("(.*)/(.*)\.snd", lambda m: "ship.%s.sounds" % m.group(1)),
|
||||
("(.*)/(.*)\.mod", lambda m: "ship.%s.ditty" % m.group(1)),
|
||||
("(.*)/(.*)\.ogg", lambda m: "ship.%s.ditty" % m.group(1)),
|
||||
("(.*)/(.*)\.txt", lambda m: "ship.%s.text" % m.group(1)),
|
||||
("(.*)/(.*)cap\.ani", lambda m: "ship.%s.graphics.captain" % m.group(1)),
|
||||
("(.*)/(.*)big.*", lambda m: "ship.%s.graphics.%s.large" % (m.group(1), stripdots(m.group(2)))),
|
||||
|
||||
Reference in New Issue
Block a user