Skip to content

Commit

Permalink
mount images and arch detection
Browse files Browse the repository at this point in the history
stelzo committed Nov 27, 2024

Verified

This commit was signed with the committer’s verified signature.
sergio-costas Sergio Costas
1 parent 31d67d1 commit ed6ef1e
Showing 5 changed files with 66 additions and 8 deletions.
49 changes: 46 additions & 3 deletions images.go
Original file line number Diff line number Diff line change
@@ -133,6 +133,7 @@ func cleanImages(dir string, resolution int) error {
func DownloadImagesLauncher(hashJson *ankabuffer.Manifest, bin int, version int, dir string, headless bool) error {
inPath := filepath.Join(dir, "tmp")
outPath := filepath.Join(dir, "img", "item")
outPathMounts := filepath.Join(dir, "img", "mount")

if version == 2 {
fileNames := []HashFile{
@@ -170,15 +171,24 @@ func DownloadImagesLauncher(hashJson *ankabuffer.Manifest, bin int, version int,
fileNames := []HashFile{
{Filename: "Dofus_Data/StreamingAssets/Content/Picto/Items/item_assets_1x.bundle", FriendlyName: "item_images_1.imagebundle"},
{Filename: "Dofus_Data/StreamingAssets/Content/Picto/Items/item_assets_2x.bundle", FriendlyName: "item_images_2.imagebundle"},
//{Filename: "Dofus_Data/StreamingAssets/Content/Picto/UI/mount_.bundle", FriendlyName: "mount_images.bundle"},
{Filename: "Dofus_Data/StreamingAssets/Content/Picto/UI/mount_assets_.bundle", FriendlyName: "mount_images.imagebundle"},
}

err := PullImages([]string{"stelzo/assetstudio-cli:latest"}, false, headless)
err := PullImages([]string{"stelzo/assetstudio-cli:" + ARCH}, false, headless)
if err != nil {
return err
}

err = DownloadUnpackFiles("Images", bin, hashJson, "picto", fileNames, dir, outPath, true, "", headless, false)
err = DownloadUnpackFiles("Item Images", bin, hashJson, "picto", fileNames, dir, outPath, true, "", headless, false)
if err != nil {
return err
}

fileNames = []HashFile{
{Filename: "Dofus_Data/StreamingAssets/Content/Picto/UI/mount_assets_.bundle", FriendlyName: "mount_images.imagebundle"},
}

err = DownloadUnpackFiles("Mount Images", bin, hashJson, "picto", fileNames, dir, outPathMounts, true, "", headless, false)
if err != nil {
return err
}
@@ -199,6 +209,23 @@ func DownloadImagesLauncher(hashJson *ankabuffer.Manifest, bin int, version int,

feedbacks <- "cleaning"

// -- mounts cleaning --
err = os.Rename(filepath.Join(outPathMounts, "Assets", "BuiltAssets", "mounts", "small"), filepath.Join(outPathMounts, "small"))
if err != nil {
return err
}

err = os.Rename(filepath.Join(outPathMounts, "Assets", "BuiltAssets", "mounts", "big"), filepath.Join(outPathMounts, "big"))
if err != nil {
return err
}

err = os.RemoveAll(filepath.Join(outPathMounts, "Assets"))
if err != nil {
return err
}

// -- items cleaning --
err = os.Rename(filepath.Join(outPath, "Assets", "BuiltAssets", "items", "1x"), filepath.Join(outPath, "1x"))
if err != nil {
return err
@@ -216,6 +243,22 @@ func DownloadImagesLauncher(hashJson *ankabuffer.Manifest, bin int, version int,

var wg sync.WaitGroup

wg.Add(1)
go func() {
defer wg.Done()
if cleanImages(filepath.Join(outPathMounts, "small"), 64) != nil {
log.Error("Error cleaning images", "err", err)
}
}()

wg.Add(1)
go func() {
defer wg.Done()
if cleanImages(filepath.Join(outPathMounts, "big"), 256) != nil {
log.Error("Error cleaning images", "err", err)
}
}()

wg.Add(1)
go func() {
defer wg.Done()
7 changes: 5 additions & 2 deletions items.go
Original file line number Diff line number Diff line change
@@ -40,14 +40,17 @@ func DownloadItems(hashJson *ankabuffer.Manifest, bin int, version int, dir stri
{Filename: "Dofus_Data/StreamingAssets/Content/Data/data_assets_dungeonsroot.asset.bundle", FriendlyName: "dungeons.asset.bundle"},
}

err := PullImages([]string{"stelzo/doduda-umbu:latest"}, false, headless)
err := PullImages([]string{"stelzo/doduda-umbu:" + ARCH}, false, headless)
if err != nil {
return err
}

err = DownloadUnpackFiles("Items", bin, hashJson, "data", fileNames, dir, outPath, true, indent, headless, false)
return err
if err != nil {
return err
}

return nil
} else if version == 2 {
fileNames := []HashFile{
{Filename: "data/common/Items.d2o", FriendlyName: "items.d2o"},
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
"runtime"
"strconv"
"strings"
"sync"
@@ -21,6 +22,7 @@ var (
DodudaShort = "doduda - Unofficial Ankama Launcher CLI"
DodudaLong = "The Ankama Launcher Terminal Client for Developers."
DodudaVersionHelp = DodudaShort + "\n" + DodudaVersion + "\nhttps://github.com/dofusdude/doduda"
ARCH string

rootCmd = &cobra.Command{
Use: "doduda",
@@ -70,6 +72,16 @@ var (
)

func main() {
switch runtime.GOARCH {
case "arm64":
ARCH = "arm64"
case "amd64":
ARCH = "amd64"
default:
fmt.Printf("Error: Unsupported architecture %s\n", runtime.GOARCH)
os.Exit(1)
}

viper.SetDefault("LOG_LEVEL", "warn")
viper.AutomaticEnv()
parsedLevel, err := log.ParseLevel(viper.GetString("LOG_LEVEL"))
2 changes: 1 addition & 1 deletion quests.go
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ func DownloadQuests(hashJson *ankabuffer.Manifest, bin int, version int, dir str
{Filename: "Dofus_Data/StreamingAssets/Content/Data/data_assets_almanaxcalendarsroot.asset.bundle", FriendlyName: "almanax.asset.bundle"},
}

err := PullImages([]string{"stelzo/doduda-umbu:latest"}, false, headless)
err := PullImages([]string{"stelzo/doduda-umbu:" + ARCH}, false, headless)
if err != nil {
return err
}
4 changes: 2 additions & 2 deletions update.go
Original file line number Diff line number Diff line change
@@ -513,7 +513,7 @@ func UnpackUnityBundle(category string, inputPath string, outputPath string, mut

ctx := context.Background()
resp, err := cli.ContainerCreate(ctx, &container.Config{
Image: "stelzo/doduda-umbu:latest",
Image: "stelzo/doduda-umbu:" + ARCH,
Cmd: cmd,
Volumes: map[string]struct{}{
"/app/data": {},
@@ -585,7 +585,7 @@ func UnpackUnityImages(inputDir string, outputDir string, muteSpinner bool, head
}
defer cli.Close()

imageName := "stelzo/assetstudio-cli:latest"
imageName := "stelzo/assetstudio-cli:" + ARCH

ctx := context.Background()
bundles, err := os.ReadDir(inputDir)

0 comments on commit ed6ef1e

Please sign in to comment.