From c3a1afd634fa0b76ba4e3e88521da2818fbaa48e Mon Sep 17 00:00:00 2001 From: NTBlok Date: Thu, 16 Jun 2016 20:01:47 -0700 Subject: [PATCH 1/6] Added image key for filename in json meta for TexturePacker-like format. --- glue/formats/jsonformat.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/glue/formats/jsonformat.py b/glue/formats/jsonformat.py index ea32a08..e0c4f10 100644 --- a/glue/formats/jsonformat.py +++ b/glue/formats/jsonformat.py @@ -57,7 +57,8 @@ def get_context(self, *args, **kwargs): 'sprite_path': context['sprite_path'], 'sprite_filename': context['sprite_filename'], 'width': context['width'], - 'height': context['height']}) + 'height': context['height'] + 'image': context['sprite_filename']}) if self.sprite.config['json_format'] == 'array': data['frames'] = frames.values() From 67fe44f427b17a09296c233f621936123e84e483 Mon Sep 17 00:00:00 2001 From: NTBlok Date: Thu, 16 Jun 2016 20:58:06 -0700 Subject: [PATCH 2/6] Added image key for filename in json meta for TexturePacker-like format. --- glue/formats/jsonformat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glue/formats/jsonformat.py b/glue/formats/jsonformat.py index e0c4f10..11be683 100644 --- a/glue/formats/jsonformat.py +++ b/glue/formats/jsonformat.py @@ -57,7 +57,7 @@ def get_context(self, *args, **kwargs): 'sprite_path': context['sprite_path'], 'sprite_filename': context['sprite_filename'], 'width': context['width'], - 'height': context['height'] + 'height': context['height'], 'image': context['sprite_filename']}) if self.sprite.config['json_format'] == 'array': From 491197e3adf1379b48267fc96ed6a8614b5c75ef Mon Sep 17 00:00:00 2001 From: NTBlok Date: Sat, 25 Jun 2016 20:45:36 -0700 Subject: [PATCH 3/6] Create new jsonformat 'txtpkr' --- glue/formats/jsonformat.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/glue/formats/jsonformat.py b/glue/formats/jsonformat.py index 11be683..1906095 100644 --- a/glue/formats/jsonformat.py +++ b/glue/formats/jsonformat.py @@ -31,8 +31,8 @@ def populate_argument_parser(cls, parser): metavar='NAME', type=unicode, default=os.environ.get('GLUE_JSON_FORMAT', 'array'), - choices=['array', 'hash'], - help=("JSON structure format (array, hash)")) + choices=['array', 'hash','txtpkr'], + help=("JSON structure format (array, hash, txtpkr)")) def get_context(self, *args, **kwargs): context = super(JSONFormat, self).get_context(*args, **kwargs) @@ -64,5 +64,14 @@ def get_context(self, *args, **kwargs): data['frames'] = frames.values() else: data['frames'] = frames + if self.sprite.config['json_format'] == 'txtpkr': + for d in data['frames']: + x = d['frame']['x'] + y = d['frame']['y'] + # Make the x,y coordinates grow in positive numbers + d['frame']['x'] = x*-1 + d['frame']['y'] = y*-1 + d['spriteSourceSize']['x'] = x*-1 + d['spriteSourceSize']['y'] = y*-1 return data From 2798ddc42e94f7936957bc362c05e26004f751d5 Mon Sep 17 00:00:00 2001 From: NTBlok Date: Sat, 25 Jun 2016 21:10:13 -0700 Subject: [PATCH 4/6] Create new jsonformat 'txtpkr' - bug fix. --- glue/formats/jsonformat.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glue/formats/jsonformat.py b/glue/formats/jsonformat.py index 1906095..da4cc37 100644 --- a/glue/formats/jsonformat.py +++ b/glue/formats/jsonformat.py @@ -66,8 +66,8 @@ def get_context(self, *args, **kwargs): data['frames'] = frames if self.sprite.config['json_format'] == 'txtpkr': for d in data['frames']: - x = d['frame']['x'] - y = d['frame']['y'] + x = int(d['frame']['x']) + y = int(d['frame']['y']) # Make the x,y coordinates grow in positive numbers d['frame']['x'] = x*-1 d['frame']['y'] = y*-1 From 7b6cdd0b8f714aefc02394310904fa1fb3e7e87d Mon Sep 17 00:00:00 2001 From: NTBlok Date: Sat, 25 Jun 2016 21:53:18 -0700 Subject: [PATCH 5/6] Create new jsonformat 'txtpkr' - bug fix. --- glue/formats/jsonformat.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/glue/formats/jsonformat.py b/glue/formats/jsonformat.py index da4cc37..ee22426 100644 --- a/glue/formats/jsonformat.py +++ b/glue/formats/jsonformat.py @@ -62,16 +62,17 @@ def get_context(self, *args, **kwargs): if self.sprite.config['json_format'] == 'array': data['frames'] = frames.values() - else: + elif self.sprite.config['json_format'] == 'hash': + data['frames'] = frames + else: + for k,v in frames: + x = frames[k]['frame']['x'] + y = frames[k]['frame']['y'] + # Make the x,y coordinates grow in positive numbers + frames[k]['frame']['x'] = x*-1 + frames[k]['frame']['y'] = y*-1 + frames[k]['spriteSourceSize']['x'] = x*-1 + frames[k]['spriteSourceSize']['y'] = y*-1 data['frames'] = frames - if self.sprite.config['json_format'] == 'txtpkr': - for d in data['frames']: - x = int(d['frame']['x']) - y = int(d['frame']['y']) - # Make the x,y coordinates grow in positive numbers - d['frame']['x'] = x*-1 - d['frame']['y'] = y*-1 - d['spriteSourceSize']['x'] = x*-1 - d['spriteSourceSize']['y'] = y*-1 return data From bb5fc58dc6ee34078db19f28c90f527f9358b424 Mon Sep 17 00:00:00 2001 From: NTBlok Date: Sat, 25 Jun 2016 21:59:51 -0700 Subject: [PATCH 6/6] Create new jsonformat 'txtpkr' - bug fix. --- glue/formats/jsonformat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glue/formats/jsonformat.py b/glue/formats/jsonformat.py index ee22426..5e86e28 100644 --- a/glue/formats/jsonformat.py +++ b/glue/formats/jsonformat.py @@ -65,7 +65,7 @@ def get_context(self, *args, **kwargs): elif self.sprite.config['json_format'] == 'hash': data['frames'] = frames else: - for k,v in frames: + for k,v in frames.items(): x = frames[k]['frame']['x'] y = frames[k]['frame']['y'] # Make the x,y coordinates grow in positive numbers