def do_model(self):
        old_name = f'Actor/ModelList/{self.base}.bmodellist'
        new_name = f'Actor/ModelList/{self.name}.bmodellist'
        pio = get_raw_data(self.data.data_sarc, old_name)

        pio.lists['ModelData'].lists['ModelData_0'].objects['Base'].params['Folder'] \
            = FixedSafeString64(self.name)
        pio.lists['ModelData'].lists['ModelData_0'].lists['Unit'].objects['Unit_0'].params['UnitName'] \
            = FixedSafeString64(self.name)

        #print_aamp(pio)
        update_sarc(pio, self.data, old_name, new_name)
Beispiel #2
0
def make_shopdata(pio: ParameterIO) -> ParameterList:
    shopdata = ParameterList()
    tables: List[Parameter] = [
        str(t.v) for _, t in pio.objects["Header"].params.items() if is_string(t)
    ]
    if not tables:
        raise InvalidDataError("A shop file is invalid: has no tables")
    shopdata.objects["TableNames"] = ParameterObject()
    for table in tables:
        table_plist = ParameterList()
        shopdata.objects["TableNames"].params[table] = Parameter(FixedSafeString64(table))
        table_hash = crc32(table.encode())
        items: Dict[str, List[int]] = {
            str(p.v): [k.hash, i]
            for i, (k, p) in enumerate(pio.objects[table_hash].params.items())
            if is_string(p)
        }
        for item in items.keys():
            item_no = int(
                name_table.get_name(items[item][0], items[item][1], table_hash).replace(
                    "ItemName", ""
                )
            )
            item_obj = ParameterObject()
            for shop_key in shop_keys:
                try:
                    item_obj.params[shop_key] = pio.objects[table_hash].params[
                        f"{shop_key}{item_no:03d}"
                    ]
                except KeyError:
                    raise KeyError(f"{shop_key}{item_no:03d}")
            table_plist.objects[item] = item_obj
        if table_plist.objects:
            shopdata.lists[table_hash] = table_plist
    return shopdata
Beispiel #3
0
 def make_bshop(plist: ParameterList) -> ParameterIO:
     bshop = ParameterIO()
     bshop.type = "xml"
     tables: List[str] = [
         str(t.v) for _, t in plist.objects["TableNames"].params.items()
     ]
     bshop.objects["Header"] = ParameterObject()
     bshop.objects["Header"].params["TableNum"] = Parameter(len(tables))
     for i, table in enumerate(tables, 1):
         table_hash = crc32(table.encode())
         bshop.objects["Header"].params[f"Table{i:02d}"] = Parameter(
             FixedSafeString64(table)
         )
         table_pobj = ParameterObject()
         table_pobj.params["ColumnNum"] = Parameter(
             len(plist.lists[table_hash].objects)
         )
         for j, item in enumerate(
             [item for _, item in plist.lists[table_hash].objects.items()], 1
         ):
             table_pobj.params[f"ItemSort{j:03d}"] = Parameter(j - 1)
             for shop_key in shop_keys:
                 table_pobj.params[f"{shop_key}{j:03d}"] = item.params[shop_key]
         if table_pobj.params:
             bshop.objects[table_hash] = table_pobj
     return bshop
Beispiel #4
0
 def merge_addres(plist: ParameterList, other_plist: ParameterList):
     bfres: List[str] = []
     for _, pobj in plist.objects.items():
         bfres.append(str(pobj.params["Anim"].v))
     for _, other_pobj in other_plist.objects.items():
         bfres.append(str(other_pobj.params["Anim"].v))
     for i, v in enumerate(list(dict.fromkeys(bfres))):
         key = f"AddRes_{i}"
         if not key in plist.objects:
             plist.objects[key] = ParameterObject()
         plist.objects[key].params["Anim"] = Parameter(FixedSafeString64(v))
Beispiel #5
0
 def diff_asdefine(asdef: ParameterList,
                   ref_asdef: ParameterList) -> ParameterList:
     diff = ParameterList()
     defs: Dict[str, str] = {}
     for _, pobj in asdef.objects.items():
         defs[str(pobj.params["Name"].v)] = str(pobj.params["Filename"].v)
     for _, ref_pobj in ref_asdef.objects.items():
         try:
             if (defs[str(ref_pobj.params["Name"].v)] == str(
                     ref_pobj.params["Filename"].v)):
                 defs.pop(str(ref_pobj.params["Name"].v))
         except (ValueError, KeyError):
             continue
     for i, (k, v) in enumerate(defs.items()):
         key = f"ASDefine_{i}"
         diff.objects[key] = ParameterObject()
         diff.objects[key].params["Name"] = Parameter(FixedSafeString64(k))
         diff.objects[key].params["Filename"] = Parameter(
             FixedSafeString64(v))
     return diff
Beispiel #6
0
 def merge_asdefine(plist: ParameterList, other_plist: ParameterList):
     defs: Dict[str, str] = {}
     for _, pobj in plist.objects.items():
         defs[str(pobj.params["Name"].v)] = pobj.params["Filename"].v
     for _, other_pobj in other_plist.objects.items():
         defs[str(
             other_pobj.params["Name"].v)] = other_pobj.params["Filename"].v
     for i, (k, v) in enumerate(defs.items()):
         key = f"ASDefine_{i}"
         if not key in plist.objects:
             plist.objects[key] = ParameterObject()
         plist.objects[key].params["Name"] = Parameter(FixedSafeString64(k))
         plist.objects[key].params["Filename"] = Parameter(v)