diff --git a/fclauncher/Modpack.go b/fclauncher/Modpack.go index 5e8f0f0..9482ff1 100644 --- a/fclauncher/Modpack.go +++ b/fclauncher/Modpack.go @@ -3,6 +3,7 @@ package main import ( "bytes" "encoding/json" + "fmt" "time" ) @@ -10,46 +11,45 @@ type Modpack struct { Name string Id string Last_updated string - Versions []Version + Versions []Version } type Version struct { Version string - Data time.Time - File string + Data time.Time + File string } type ModpackManager struct { - app *App + app *App Modpacks []Modpack } - func (m *ModpackManager) QuerryModpacks() { m.Modpacks = []Modpack{} buff := new(bytes.Buffer) err := HttpDownload("modpacks.json", buff, nil) if err != nil { + fmt.Printf("HTTP error: %s\n", err) return } err = json.Unmarshal(buff.Bytes(), &m.Modpacks) if err != nil { return } - + for ind, pack := range m.Modpacks { buff = new(bytes.Buffer) - err = HttpDownload(pack.Id + "/versions.json", buff, nil) + err = HttpDownload(pack.Id+"/versions.json", buff, nil) if err != nil { - continue + continue } - json.Unmarshal(buff.Bytes(), &pack.Versions) + json.Unmarshal(buff.Bytes(), &pack.Versions) m.Modpacks[ind] = pack } } - -func (m *ModpackManager) GetModpacks() []Modpack{ +func (m *ModpackManager) GetModpacks() []Modpack { return m.Modpacks } diff --git a/fclauncher/frontend/wailsjs/go/models.ts b/fclauncher/frontend/wailsjs/go/models.ts index 985b0d9..159988f 100755 --- a/fclauncher/frontend/wailsjs/go/models.ts +++ b/fclauncher/frontend/wailsjs/go/models.ts @@ -74,7 +74,7 @@ export namespace main { export class FabricMeta { Version: number; Libraries: FabricLibraries; - MainClass: {[key: string]: string}; + MainClass: Record; static createFrom(source: any = {}) { return new FabricMeta(source); @@ -332,7 +332,7 @@ export namespace main { export class QuiltMeta { Version: number; Libraries: QuiltLibraries; - MainClass: {[key: string]: string}; + MainClass: Record; static createFrom(source: any = {}) { return new QuiltMeta(source); diff --git a/fclauncher/frontend/wailsjs/runtime/runtime.d.ts b/fclauncher/frontend/wailsjs/runtime/runtime.d.ts index 94778df..4445dac 100644 --- a/fclauncher/frontend/wailsjs/runtime/runtime.d.ts +++ b/fclauncher/frontend/wailsjs/runtime/runtime.d.ts @@ -134,7 +134,7 @@ export function WindowIsFullscreen(): Promise; // [WindowSetSize](https://wails.io/docs/reference/runtime/window#windowsetsize) // Sets the width and height of the window. -export function WindowSetSize(width: number, height: number): Promise; +export function WindowSetSize(width: number, height: number): void; // [WindowGetSize](https://wails.io/docs/reference/runtime/window#windowgetsize) // Gets the width and height of the window. diff --git a/fclauncher/go.mod b/fclauncher/go.mod index dc5152a..cc0beba 100644 --- a/fclauncher/go.mod +++ b/fclauncher/go.mod @@ -4,7 +4,7 @@ go 1.22.4 toolchain go1.23.2 -require github.com/wailsapp/wails/v2 v2.9.2 +require github.com/wailsapp/wails/v2 v2.10.1 require github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf diff --git a/fclauncher/go.sum b/fclauncher/go.sum index 3740d50..62e0b37 100644 --- a/fclauncher/go.sum +++ b/fclauncher/go.sum @@ -57,8 +57,8 @@ github.com/wailsapp/go-webview2 v1.0.19 h1:7U3QcDj1PrBPaxJNCui2k1SkWml+Q5kvFUFyT github.com/wailsapp/go-webview2 v1.0.19/go.mod h1:qJmWAmAmaniuKGZPWwne+uor3AHMB5PFhqiK0Bbj8kc= github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs= github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o= -github.com/wailsapp/wails/v2 v2.9.2 h1:Xb5YRTos1w5N7DTMyYegWaGukCP2fIaX9WF21kPPF2k= -github.com/wailsapp/wails/v2 v2.9.2/go.mod h1:uehvlCwJSFcBq7rMCGfk4rxca67QQGsbg5Nm4m9UnBs= +github.com/wailsapp/wails/v2 v2.10.1 h1:QWHvWMXII2nI/nXz77gpPG8P3ehl6zKe+u4su5BWIns= +github.com/wailsapp/wails/v2 v2.10.1/go.mod h1:zrebnFV6MQf9kx8HI4iAv63vsR5v67oS7GTEZ7Pz1TY= github.com/zhyee/zipstream v0.0.0-20230625125559-133d8d1afaa0 h1:BcjUUYzMORs7sJtOCWLXaelG7woHMN1QEs4yCB1QZ48= github.com/zhyee/zipstream v0.0.0-20230625125559-133d8d1afaa0/go.mod h1:aaGtAo3dTqYtHjcliPNlyXMIIodvGm8y6uK2KMTYHrk= golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= diff --git a/fclauncher/https.go b/fclauncher/https.go index 25f4a36..90c6089 100644 --- a/fclauncher/https.go +++ b/fclauncher/https.go @@ -2,6 +2,7 @@ package main import ( "context" + "fmt" "io" "net/http" "strings" @@ -13,13 +14,13 @@ const BlockSize = 1024 * 64 func HttpDownload(path string, out io.Writer, ctx context.Context) error { path = strings.ReplaceAll(path, "\\", "/") - res, err := http.Get("https://fclauncher.piwalker.net/fclauncher/" + path) + res, err := http.Get("https://gitea.piwalker.net/fclauncher/" + path) if err != nil { return err } defer res.Body.Close() var read int64 = 0 - for read < res.ContentLength { + for (read < res.ContentLength) || res.ContentLength == -1 { count, err := io.CopyN(out, res.Body, BlockSize) read += count if err != nil { @@ -32,5 +33,6 @@ func HttpDownload(path string, out io.Writer, ctx context.Context) error { if ctx != nil { runtime.EventsEmit(ctx, "download_complete") } + fmt.Printf("Downloaded %d Bytes from %s, expected %d Bytes\n", read, path, res.ContentLength) return nil }