Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/json format txtpkr #218

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions glue/formats/jsonformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -57,11 +57,22 @@ 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()
else:
elif self.sprite.config['json_format'] == 'hash':
data['frames'] = frames
else:
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
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

return data