diff --git a/Gizmos/T_UI_Giz_Battery.TGA b/Gizmos/T_UI_Giz_Battery.TGA new file mode 100644 index 0000000..2f81a9f Binary files /dev/null and b/Gizmos/T_UI_Giz_Battery.TGA differ diff --git a/Gizmos/T_UI_Giz_Charge.TGA b/Gizmos/T_UI_Giz_Charge.TGA new file mode 100644 index 0000000..3331238 Binary files /dev/null and b/Gizmos/T_UI_Giz_Charge.TGA differ diff --git a/Gizmos/T_UI_Giz_Power.TGA b/Gizmos/T_UI_Giz_Power.TGA new file mode 100644 index 0000000..f0a1073 Binary files /dev/null and b/Gizmos/T_UI_Giz_Power.TGA differ diff --git a/Gizmos/T_UI_Giz_SignalHigh.TGA b/Gizmos/T_UI_Giz_SignalHigh.TGA new file mode 100644 index 0000000..6a14662 Binary files /dev/null and b/Gizmos/T_UI_Giz_SignalHigh.TGA differ diff --git a/Gizmos/T_UI_Giz_SignalLow.TGA b/Gizmos/T_UI_Giz_SignalLow.TGA new file mode 100644 index 0000000..8314635 Binary files /dev/null and b/Gizmos/T_UI_Giz_SignalLow.TGA differ diff --git a/Gizmos/T_UI_Giz_SignalMid.TGA b/Gizmos/T_UI_Giz_SignalMid.TGA new file mode 100644 index 0000000..d8ad958 Binary files /dev/null and b/Gizmos/T_UI_Giz_SignalMid.TGA differ diff --git a/PyTexturePacker/PackerInterface/AtlasInterface.py b/PyTexturePacker/PackerInterface/AtlasInterface.py index ddabe82..6b25c8c 100644 --- a/PyTexturePacker/PackerInterface/AtlasInterface.py +++ b/PyTexturePacker/PackerInterface/AtlasInterface.py @@ -9,7 +9,7 @@ AtlasInterface.py ----------------------------------------------------------------------------""" -from ..Utils import ATLAS_FORMAT_PLIST, ATLAS_FORMAT_JSON +from ..Utils import ATLAS_FORMAT_PLIST, ATLAS_FORMAT_JSON,ATLAS_FORMAT_UNREAL_PAPER2D MAX_RANK = 2 ** 32 MAX_WIDTH = 1024 * 16 @@ -80,6 +80,17 @@ def dump_plist(self, texture_file_name="", input_base_path=None, atlas_format=AT sourceSize=dict(w=image_rect.source_size[0], h=image_rect.source_size[1]) ) + if atlas_format == ATLAS_FORMAT_UNREAL_PAPER2D: + frames[path] = dict( + frame=dict(x=image_rect.x, y=image_rect.y, w=width, h=height), + rotated=bool(image_rect.rotated), + trimed=bool(image_rect.trimmed), + spriteSourceSize=dict( + x=image_rect.source_box[0], y=image_rect.source_box[1], + w=image_rect.source_box[2], h=image_rect.source_box[3]), + sourceSize=dict(w=image_rect.source_size[0], h=image_rect.source_size[1]) + ) + plist_data["frames"] = frames if atlas_format == ATLAS_FORMAT_PLIST: plist_data["metadata"] = dict( @@ -96,6 +107,16 @@ def dump_plist(self, texture_file_name="", input_base_path=None, atlas_format=AT size=dict(w=self.size[0], h=self.size[1]), scale=1, ) + if atlas_format == ATLAS_FORMAT_UNREAL_PAPER2D: + plist_data["meta"] = dict( + app="https://www.codeandweb.com/texturepacker", + target="paper2d", + image=texture_file_name, + format="RGBA8888", + size=dict(w=self.size[0], h=self.size[1]), + scale=1, + ) + return plist_data diff --git a/PyTexturePacker/PackerInterface/PackerInterface.py b/PyTexturePacker/PackerInterface/PackerInterface.py index 10ced70..20f129c 100644 --- a/PyTexturePacker/PackerInterface/PackerInterface.py +++ b/PyTexturePacker/PackerInterface/PackerInterface.py @@ -34,7 +34,7 @@ class PackerInterface(object): def __init__(self, bg_color=0x00000000, texture_format=".png", max_width=4096, max_height=4096, enable_rotated=True, force_square=False, border_padding=2, shape_padding=2, inner_padding=0, trim_mode=0, - reduce_border_artifacts=False, extrude=0, atlas_format=Utils.ATLAS_FORMAT_PLIST): + reduce_border_artifacts=False, extrude=0, atlas_format=Utils.ATLAS_FORMAT_UNREAL_PAPER2D): """ init a packer :param bg_color: background color of output image. diff --git a/PyTexturePacker/Utils.py b/PyTexturePacker/Utils.py index 93cff8e..7ef6c02 100644 --- a/PyTexturePacker/Utils.py +++ b/PyTexturePacker/Utils.py @@ -12,9 +12,10 @@ if sys.version_info.major > 2: xrange = range -SUPPORTED_IMAGE_FORMAT = [".png", ".jpg", ".bmp"] +SUPPORTED_IMAGE_FORMAT = [".png", ".jpg", ".bmp", '.tga'] ATLAS_FORMAT_PLIST = "plist" ATLAS_FORMAT_JSON = "json" +ATLAS_FORMAT_UNREAL_PAPER2D = "unreal_paper2d" def load_images_from_paths(image_path_list): @@ -62,6 +63,8 @@ def get_atlas_data_ext(atlas_format): return '.plist' if atlas_format == ATLAS_FORMAT_JSON: return '.json' + if atlas_format == ATLAS_FORMAT_UNREAL_PAPER2D: + return ".paper2dsprites" def save_atlas_data(data_dict, file_path, atlas_format): @@ -76,6 +79,8 @@ def save_atlas_data(data_dict, file_path, atlas_format): return save_plist(data_dict, file_path) if atlas_format == ATLAS_FORMAT_JSON: return save_json(data_dict, file_path) + if atlas_format == ATLAS_FORMAT_UNREAL_PAPER2D: + return save_unreal_paper2d(data_dict, file_path) def save_json(data_dict, file_path): @@ -90,6 +95,18 @@ def save_json(data_dict, file_path): json.dump(data_dict, fp) +def save_unreal_paper2d(data_dict, file_path): + """ + save a dict as a unreal json file + :param data_dict: dict data + :param file_path: json file path to save + :return: + """ + import json + with open(file_path, 'w') as fp: + json.dump(data_dict, fp) + + def save_plist(data_dict, file_path): """ save a dict as a plist file diff --git a/main.py b/main.py index 28f98c2..b7799dd 100644 --- a/main.py +++ b/main.py @@ -8,7 +8,9 @@ Description: main.py ----------------------------------------------------------------------------""" +import os +import click from PyTexturePacker import Packer @@ -17,10 +19,19 @@ def pack_test(): packer = Packer.create(max_width=2048, max_height=2048, bg_color=0xffffff00) # pack texture images under the directory "test_case/" and name the output images as "test_case". # "%d" in output file name "test_case%d" is a placeholder, which is a multipack index, starting with 0. - packer.pack("test_image/", "test_image%d", "") + packer.pack("Gizmos/", "Gizmos%d", "") -def main(): +def pack(source): + source = os.path.normpath(source) + for root, ds, fs in os.walk(source): + if len(fs) > 0: + dir_name = root.split('\\')[-1] + packer = Packer.create(max_width=2048, max_height=2048, bg_color=0xffffff00) + packer.pack(root, dir_name, root) + + +def main(source): pack_test()