示例#1
0
func loadCasPartNames(folder string) (map[int]string, error) {
	infos, err := ioutil.ReadDir(folder)
	if err != nil {
		return nil, err
	}

	addons := make([]string, 0)
	for _, info := range infos {
		if !info.IsDir() {
			continue
		}
		if isPack(info.Name()) {
			addons = append(addons, info.Name())
		}
	}

	filter := &keys.Filter{[]uint32{consts.ResourceTypeCasPart}, nil, nil}

	pack, err := dbpf.Open(fmt.Sprintf("%v/Data/Client/ClientFullBuild0.package", folder))
	if err != nil {
		return nil, err
	}
	list := pack.ListResources(filter, nil, nil)
	pack, err = dbpf.Open(fmt.Sprintf("%v/Data/Client/ClientDeltaBuild0.package", folder))
	if err != nil {
		return nil, err
	}
	list = pack.ListResources(filter, nil, list)

	for _, addon := range addons {
		pack, err = dbpf.Open(fmt.Sprintf("%v/%v/ClientFullBuild0.package", folder, addon))
		if err != nil {
			fmt.Println(err)
			continue
		}
		list = pack.ListResources(filter, nil, list)
		pack, err = dbpf.Open(fmt.Sprintf("%v/Delta/%v/ClientDeltaBuild0.package", folder, addon))
		if err != nil {
			fmt.Println(err)
			continue
		}
		list = pack.ListResources(filter, nil, list)
	}

	names := make(map[int]string)

	for k, r := range list {
		data, err := r.ToBytes()
		if err != nil {
			fmt.Println(err)
			continue
		}
		part, err := caspart.Read(data)
		if err != nil {
			fmt.Println(err)
			continue
		}
		names[int(k.Instance)] = part.Name
	}

	return names, nil
}
示例#2
0
func (d *Data) Export() {
	if d.CasPartFile == "" {
		d.inform(casPartFileMissing)
		return
	}

	if d.ThumbFile == "" {
		d.inform(thumbFileMissing)
		return
	}

	if d.ExportDir == "" {
		d.inform(exportDirMissing)
		return
	}

	casPartPack, err := dbpf.Open(trimPath(d.CasPartFile))
	if err != nil {
		d.report(err)
		return
	}

	thumbPack, err := dbpf.Open(trimPath(d.ThumbFile))
	if err != nil {
		d.report(err)
		return
	}

	folder := trimPath(d.ExportDir)

	casParts := make([]uint64, 0)
	casPartNames := make(map[uint64]string)
	for k, r := range casPartPack.ListResources(&keys.Filter{[]uint32{consts.ResourceTypeCasPart}, nil, nil}, nil, nil) {
		data, err := r.ToBytes()
		if err != nil {
			d.report(err)
			return
		}
		casPart, err := caspart.Read(data)
		if err != nil {
			d.report(err)
			return
		}
		casParts = append(casParts, k.Instance)
		casPartNames[k.Instance] = casPart.Name
	}

	count := 0
	for k, r := range thumbPack.ListResources(&keys.Filter{nil, []uint32{consts.ResourceGroupPortraitFemale, consts.ResourceGroupPortraitMale}, casParts}, nil, nil) {
		data, err := r.ToBytes()
		if err != nil {
			d.report(err)
			return
		}
		thumb, err := thumbnail.Convert(data)
		if err != nil {
			d.report(err)
			return
		}
		file, err := os.Create(fmt.Sprintf("%v/%v_%x.png", folder, casPartNames[k.Instance], k.Group))
		if err != nil {
			d.report(err)
			return
		}
		_, err = file.Write(thumb)
		if err != nil {
			d.report(err)
			file.Close()
			return
		}
		file.Close()
		count++
	}

	d.inform(fmt.Sprintf("Extraction completed, %v thumbnails extracted.", count))
}
示例#3
0
func loadStrings(folder string) (map[int]string, error) {
	infos, err := ioutil.ReadDir(folder)
	if err != nil {
		return nil, err
	}

	addons := make([]string, 0)
	for _, info := range infos {
		if !info.IsDir() {
			continue
		}
		if isPack(info.Name()) {
			addons = append(addons, info.Name())
		}
	}

	strs := make(map[int]string)

	pack, err := dbpf.Open(fmt.Sprintf("%v/Data/Client/Strings_ENG_US.package", folder))
	if err != nil {
		return nil, err
	}
	for _, r := range pack.ListResources(nil, nil, nil) {
		data, err := r.ToBytes()
		if err != nil {
			return nil, err
		}
		table, err := stbl.Read(data)
		if err != nil {
			return nil, err
		}
		for _, e := range table.Entries {
			strs[int(e.Key)] = e.String
		}
	}

	for _, addon := range addons {
		pack, err := dbpf.Open(fmt.Sprintf("%v/Delta/%v/Strings_ENG_US.package", folder, addon))
		if err != nil {
			pack, err = dbpf.Open(fmt.Sprintf("%v/%v/Strings_ENG_US.package", folder, addon))
			if err != nil {
				continue
			}
		}
		for _, r := range pack.ListResources(nil, nil, nil) {
			data, err := r.ToBytes()
			if err != nil {
				return nil, err
			}
			table, err := stbl.Read(data)
			if err != nil {
				return nil, err
			}
			for _, e := range table.Entries {
				strs[int(e.Key)] = e.String
			}
		}
	}

	return strs, nil
}