Skip to content

Commit

Permalink
Move crush_png in global scope
Browse files Browse the repository at this point in the history
  • Loading branch information
Helco committed Oct 23, 2018
1 parent 416aa3f commit f36004b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Utilities/mkpack.py
Expand Up @@ -41,6 +41,8 @@
import os
import sys

crush_png = None # To be imported

TAB_OFS = 0x0C
RES_OFS = 0x200C

Expand Down Expand Up @@ -189,18 +191,17 @@ def sourcedesc(self):
return self.file

class ResourceImage(Resource):
def __init__(self, coll, j, crush_png, palette):
def __init__(self, coll, j, palette):
super(self.__class__, self).__init__(coll, j)

self.file = "{}/{}".format(self.coll.root, j["input"]["file"])
self.crush_png = crush_png
self.palette = palette

def deps(self):
return [self.file]

def data(self):
return self.crush_png(self.file, self.palette)
return crush_png(self.file, self.palette)

def sourcedesc(self):
return "imported image " + self.file
Expand Down Expand Up @@ -231,7 +232,7 @@ class ResourceCollection:
"""

def __init__(self, fname, root = ".", crush_png = None):
def __init__(self, fname, root = "."):
"""
Load in a resource collection from a file, but don't load the
resources associated with it. (That happens later.)
Expand All @@ -258,7 +259,7 @@ def __init__(self, fname, root = ".", crush_png = None):
elif res["input"]["type"] == "resource":
self.resources.append(ResourceRef(self, res))
elif res["input"]["type"] == "image":
self.resources.append(ResourceImage(self, res, crush_png, jdb["palette"]))
self.resources.append(ResourceImage(self, res, jdb["palette"]))
else:
raise ValueError("unknown resource type {}".format(res["type"]))

Expand Down Expand Up @@ -349,7 +350,7 @@ def main():
raise ValueError("could not find pebble sdk, please provide one with --sdk")
crush_png = import_crush_png(sdk_path)

rc = ResourceCollection(args.json, root = args.root[0], crush_png = crush_png)
rc = ResourceCollection(args.json, root = args.root[0])

pbpack_name = "{}.pbpack".format(args.basename)
header_name = "{}.h".format(args.basename)
Expand Down

0 comments on commit f36004b

Please sign in to comment.