From 61bd70f803ccf4c083c3817cbf649447deac936e Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Sat, 10 Apr 2021 03:46:52 +0000 Subject: [PATCH] Implement some of edit text tags. --- bemani/format/afp.py | 66 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 3 deletions(-) diff --git a/bemani/format/afp.py b/bemani/format/afp.py index c8577a5..f5cd0f4 100644 --- a/bemani/format/afp.py +++ b/bemani/format/afp.py @@ -162,6 +162,25 @@ class Point: return f"x: {round(self.x, 5)}, y: {round(self.y, 5)}" +class Rectangle: + def __init__(self, left: float, top: float, bottom: float, right: float) -> None: + self.left = left + self.top = top + self.bottom = bottom + self.right = right + + def as_dict(self) -> Dict[str, Any]: + return { + 'left': self.left, + 'top': self.top, + 'bottom': self.bottom, + 'right': self.right, + } + + def __repr__(self) -> str: + return f"left: {round(self.left, 5)}, top: {round(self.top, 5)}, bottom: {round(self.bottom, 5)}, right: {round(self.right, 5)}" + + class AP2Tag: END = 0x0 SHOW_FRAME = 0x1 @@ -317,7 +336,7 @@ class AP2Tag: cls.AP2_VIDEO: 'AP2_VIDEO', } - return resources.get(tagid, f"") + return resources.get(tagid, f"") class AP2Action: @@ -2710,7 +2729,7 @@ class AP2PropertyType: for i, p in cls.__PROPERTIES: if i == propid: return p - return f"" + return f"" class SWF: @@ -3410,8 +3429,49 @@ class SWF: object_id, depth = struct.unpack("> 8) & 0xFF) / 255.0, + b=((rgba >> 16) & 0xFF) / 255.0, + a=((rgba >> 24) & 0xFF) / 255.0, + ) + vprint(f"{prefix} Text Color: {color}") + + vprint(f"{prefix} Unk1: {unk1}, Unk2: {unk2}, Unk3: {unk3}, Unk4: {unk4}") + + # flags & 0x20 means something with offset 16-18. + # flags & 0x200 is unk str below is a HTML tag. + + if flags & 0x80: + # Has some sort of string pointer. + default_text = self.__get_string(default_text_offset) or None + vprint(f"{prefix} Default Text: {default_text}") else: - raise Exception(f"Unimplemented tag {tagid}!") + raise Exception(f"Unimplemented tag {hex(tagid)}!") def __parse_tags(self, ap2_version: int, afp_version: int, ap2data: bytes, tags_base_offset: int, prefix: str = "", verbose: bool = False) -> None: # Suppress debug text unless asked