some random ui polish changes

This commit is contained in:
= 2024-11-26 10:22:37 -07:00
parent ad736787e9
commit d4f9711699
8 changed files with 142 additions and 77 deletions

View File

@ -285,6 +285,7 @@ func (i *InstanceManager) GetInstance(instance string) (Instance, error) {
} }
func (i *InstanceManager) LaunchInstance(instance string) { func (i *InstanceManager) LaunchInstance(instance string) {
i.app.Status(fmt.Sprintf("Launching %s", instance))
dir, err := os.UserConfigDir() dir, err := os.UserConfigDir()
if err != nil { if err != nil {
fmt.Printf("unable to get config directory\n") fmt.Printf("unable to get config directory\n")
@ -367,7 +368,7 @@ common:
instanceObject.MainClass = metadata.LauncherMeta.MainClass["client"] instanceObject.MainClass = metadata.LauncherMeta.MainClass["client"]
instanceObject.FabricVersion = fabricVersion instanceObject.FabricVersion = fabricVersion
dir, _ := os.UserConfigDir() dir, _ := os.UserConfigDir()
InstallFabricLibs(instanceObject.MinecraftVersion, fabricVersion, filepath.Join(dir, "FCLauncher", "lib")) InstallFabricLibs(instanceObject.MinecraftVersion, fabricVersion, filepath.Join(dir, "FCLauncher", "lib"), i.app)
f, _ := os.OpenFile(filepath.Join(dir, "FCLauncher", "instances", instance, "instance.json"), os.O_CREATE|os.O_RDWR, 0755) f, _ := os.OpenFile(filepath.Join(dir, "FCLauncher", "instances", instance, "instance.json"), os.O_CREATE|os.O_RDWR, 0755)
data, _ := json.Marshal(instanceObject) data, _ := json.Marshal(instanceObject)
defer f.Close() defer f.Close()
@ -427,7 +428,7 @@ common:
instanceObject.MainClass = metadata.LauncherMeta.MainClass["client"] instanceObject.MainClass = metadata.LauncherMeta.MainClass["client"]
instanceObject.QuiltVersion = quiltVersion instanceObject.QuiltVersion = quiltVersion
dir, _ := os.UserConfigDir() dir, _ := os.UserConfigDir()
InstallQuiltLibs(instanceObject.MinecraftVersion, quiltVersion, filepath.Join(dir, "FCLauncher", "lib")) InstallQuiltLibs(instanceObject.MinecraftVersion, quiltVersion, filepath.Join(dir, "FCLauncher", "lib"), i.app)
f, _ := os.OpenFile(filepath.Join(dir, "FCLauncher", "instances", instance, "instance.json"), os.O_CREATE|os.O_RDWR, 0755) f, _ := os.OpenFile(filepath.Join(dir, "FCLauncher", "instances", instance, "instance.json"), os.O_CREATE|os.O_RDWR, 0755)
data, _ := json.Marshal(instanceObject) data, _ := json.Marshal(instanceObject)
defer f.Close() defer f.Close()
@ -482,6 +483,7 @@ outer:
} }
func (i *InstanceManager) ImportModpack(modpack Modpack, name string) { func (i *InstanceManager) ImportModpack(modpack Modpack, name string) {
i.app.Status(fmt.Sprintf("Downloading %s", modpack.Name))
buff := new(bytes.Buffer) buff := new(bytes.Buffer)
HttpDownload(filepath.Join(modpack.Id, modpack.Versions[len(modpack.Versions)-1].File), buff, i.app.Ctx) HttpDownload(filepath.Join(modpack.Id, modpack.Versions[len(modpack.Versions)-1].File), buff, i.app.Ctx)
i.ImportMrpack(buff, name) i.ImportMrpack(buff, name)
@ -493,16 +495,19 @@ func (i *InstanceManager) ImportMrpack(data io.Reader, name string) {
InstancePath := filepath.Join(dir, "FCLauncher", "instances", name, "minecraft") InstancePath := filepath.Join(dir, "FCLauncher", "instances", name, "minecraft")
zr := zipstream.NewReader(data) zr := zipstream.NewReader(data)
mrdata := MrData{} mrdata := MrData{}
i.app.Status("Unpacking modpack File")
for { for {
entry, err := zr.GetNextEntry() entry, err := zr.GetNextEntry()
if err == io.EOF { if err == io.EOF {
break break
} }
if entry.Name == "modrinth.index.json" { if entry.Name == "modrinth.index.json" {
i.app.Status("Loading metadata")
file, _ := entry.Open() file, _ := entry.Open()
data, _ := io.ReadAll(file) data, _ := io.ReadAll(file)
json.Unmarshal(data, &mrdata) json.Unmarshal(data, &mrdata)
} else { } else {
i.app.Status(fmt.Sprintf("Unpacking %s", entry.Name))
prefix := strings.Split(entry.Name, "/")[0] prefix := strings.Split(entry.Name, "/")[0]
if prefix == "overrides" || prefix == "client-overrides" { if prefix == "overrides" || prefix == "client-overrides" {
path := strings.SplitN(entry.Name, "/", 2)[1] path := strings.SplitN(entry.Name, "/", 2)[1]
@ -532,7 +537,6 @@ func (i *InstanceManager) ImportMrpack(data io.Reader, name string) {
} }
} }
} }
fmt.Printf("Installing minecraft %s\n", mrdata.Dependencies["minecraft"])
i.InstallVanilla(mrdata.Dependencies["minecraft"], name) i.InstallVanilla(mrdata.Dependencies["minecraft"], name)
if mrdata.Dependencies["forge"] != "" { if mrdata.Dependencies["forge"] != "" {
fmt.Printf("Forge not implemented!") fmt.Printf("Forge not implemented!")
@ -541,21 +545,35 @@ func (i *InstanceManager) ImportMrpack(data io.Reader, name string) {
fmt.Printf("Neoforge not implemented!") fmt.Printf("Neoforge not implemented!")
//implement neoforge //implement neoforge
} else if mrdata.Dependencies["fabric-loader"] != "" { } else if mrdata.Dependencies["fabric-loader"] != "" {
fmt.Printf("Installing fabric %s\n", mrdata.Dependencies["fabric-loader"])
i.InstallFabric(name, mrdata.Dependencies["fabric-loader"]) i.InstallFabric(name, mrdata.Dependencies["fabric-loader"])
} else if mrdata.Dependencies["quilt-loader"] != "" { } else if mrdata.Dependencies["quilt-loader"] != "" {
fmt.Printf("Installing quilt %s\n", mrdata.Dependencies["quilt-loader"])
i.InstallQuilt(name, mrdata.Dependencies["quilt-loader"]) i.InstallQuilt(name, mrdata.Dependencies["quilt-loader"])
} }
i.app.Status("Downloading Mods")
for _, f := range mrdata.Files { for _, f := range mrdata.Files {
fmt.Printf("Downloading %s\n", f.Path) fmt.Printf("Downloading %s\n", f.Path)
i.app.Status(fmt.Sprintf("Downloading %s", f.Path))
resp, err := http.Get(f.Downloads[0]) resp, err := http.Get(f.Downloads[0])
if err != nil { if err != nil {
fmt.Printf("Unable to download file %s\n", err) fmt.Printf("Unable to download file %s\n", err)
continue continue
} }
defer resp.Body.Close() defer resp.Body.Close()
buff := new(bytes.Buffer)
downloaded := 0
for {
count, err := io.CopyN(buff, resp.Body, BlockSize)
if err == io.EOF {
downloaded += int(count)
break
}
if err != nil {
fmt.Printf("Error Downloading libs: %e\n", err)
return
}
downloaded += int(count)
wruntime.EventsEmit(i.app.Ctx, "download", downloaded, f.FileSize)
}
fileDir := "" fileDir := ""
tokens := strings.Split(f.Path, "/") tokens := strings.Split(f.Path, "/")
for ind, token := range tokens { for ind, token := range tokens {
@ -568,6 +586,7 @@ func (i *InstanceManager) ImportMrpack(data io.Reader, name string) {
} }
file, _ := os.OpenFile(filepath.Join(InstancePath, f.Path), os.O_CREATE|os.O_RDWR, 0755) file, _ := os.OpenFile(filepath.Join(InstancePath, f.Path), os.O_CREATE|os.O_RDWR, 0755)
defer file.Close() defer file.Close()
io.Copy(file, resp.Body) io.Copy(file, buff)
wruntime.EventsEmit(i.app.Ctx, "download_complete")
} }
} }

View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"bytes"
"crypto/sha1" "crypto/sha1"
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
@ -10,24 +11,24 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
wruntime "github.com/wailsapp/wails/v2/pkg/runtime"
) )
type Fabric struct { type Fabric struct {
} }
type FabricDefinition struct { type FabricDefinition struct {
Separator string Separator string
Build int Build int
Maven string Maven string
Version string Version string
Stable bool Stable bool
} }
type FabricLibrary struct { type FabricLibrary struct {
Name string Name string
Url string Url string
Sha1 string Sha1 string
} }
@ -38,19 +39,19 @@ type FabricLibraries struct {
} }
type FabricMeta struct { type FabricMeta struct {
Version int Version int
Libraries FabricLibraries Libraries FabricLibraries
MainClass map[string]string MainClass map[string]string
} }
type FabricVersion struct { type FabricVersion struct {
Loader FabricDefinition Loader FabricDefinition
Intermediary FabricDefinition Intermediary FabricDefinition
LauncherMeta FabricMeta LauncherMeta FabricMeta
} }
func (Fabric)GetFabricVersions(mcVersion string) ([]FabricVersion, error) { func (Fabric) GetFabricVersions(mcVersion string) ([]FabricVersion, error) {
resp, err := http.Get("https://meta.fabricmc.net/v2/versions/loader/"+mcVersion) resp, err := http.Get("https://meta.fabricmc.net/v2/versions/loader/" + mcVersion)
if err != nil { if err != nil {
return []FabricVersion{}, fmt.Errorf("Unable to pull fabric version manifest: %s\n", err) return []FabricVersion{}, fmt.Errorf("Unable to pull fabric version manifest: %s\n", err)
} }
@ -74,7 +75,8 @@ func GetFabricMetadata(mcVersion string, fabricVersion string) (FabricVersion, e
return FabricVersion{}, fmt.Errorf("Unable to find requested version.\n") return FabricVersion{}, fmt.Errorf("Unable to find requested version.\n")
} }
func InstallLib(lib FabricLibrary, libDir string) { func InstallLib(lib FabricLibrary, libDir string, a *App) {
a.Status(fmt.Sprintf("Checking %s\n", lib.Name))
path := filepath.Join(ProcessMavenPath(lib.Name), ProcessMavenFilename(lib.Name)) path := filepath.Join(ProcessMavenPath(lib.Name), ProcessMavenFilename(lib.Name))
if _, err := os.Stat(filepath.Join(libDir, path)); err == nil { if _, err := os.Stat(filepath.Join(libDir, path)); err == nil {
f, _ := os.OpenFile(filepath.Join(libDir, path), os.O_RDONLY, 0755) f, _ := os.OpenFile(filepath.Join(libDir, path), os.O_RDONLY, 0755)
@ -85,27 +87,44 @@ func InstallLib(lib FabricLibrary, libDir string) {
return return
} }
} }
resp, err := http.Get(lib.Url+path) a.Status(fmt.Sprintf("Downloading %s\n", lib.Name))
resp, err := http.Get(lib.Url + path)
if err != nil { if err != nil {
return return
} }
defer resp.Body.Close() defer resp.Body.Close()
buff := new(bytes.Buffer)
downloaded := 0
for {
count, err := io.CopyN(buff, resp.Body, BlockSize)
if err == io.EOF {
downloaded += int(count)
break
}
if err != nil {
fmt.Printf("Error Downloading libs: %e\n", err)
return
}
downloaded += int(count)
wruntime.EventsEmit(a.Ctx, "download", downloaded, resp.ContentLength)
}
os.MkdirAll(filepath.Join(libDir, ProcessMavenPath(lib.Name)), 0755) os.MkdirAll(filepath.Join(libDir, ProcessMavenPath(lib.Name)), 0755)
f, _ := os.OpenFile(filepath.Join(libDir, path), os.O_CREATE|os.O_RDWR, 0755) f, _ := os.OpenFile(filepath.Join(libDir, path), os.O_CREATE|os.O_RDWR, 0755)
defer f.Close() defer f.Close()
io.Copy(f, resp.Body) io.Copy(f, buff)
wruntime.EventsEmit(a.Ctx, "download_complete")
} }
func InstallFabricLibs(mcVersion string, fabricVersion string, libDir string) { func InstallFabricLibs(mcVersion string, fabricVersion string, libDir string, a *App) {
metadata, _ := GetFabricMetadata(mcVersion, fabricVersion) metadata, _ := GetFabricMetadata(mcVersion, fabricVersion)
for _, lib := range metadata.LauncherMeta.Libraries.Client { for _, lib := range metadata.LauncherMeta.Libraries.Client {
InstallLib(lib, libDir) InstallLib(lib, libDir, a)
} }
for _, lib := range metadata.LauncherMeta.Libraries.Common { for _, lib := range metadata.LauncherMeta.Libraries.Common {
InstallLib(lib, libDir) InstallLib(lib, libDir, a)
} }
InstallLib(FabricLibrary{Name: metadata.Loader.Maven, Sha1: "", Url: "https://maven.fabricmc.net/"}, libDir) InstallLib(FabricLibrary{Name: metadata.Loader.Maven, Sha1: "", Url: "https://maven.fabricmc.net/"}, libDir, a)
InstallLib(FabricLibrary{Name: metadata.Intermediary.Maven, Sha1: "", Url: "https://maven.fabricmc.net/"}, libDir) InstallLib(FabricLibrary{Name: metadata.Intermediary.Maven, Sha1: "", Url: "https://maven.fabricmc.net/"}, libDir, a)
} }
func ProcessMavenPath(maven string) string { func ProcessMavenPath(maven string) string {
@ -121,5 +140,5 @@ func ProcessMavenFilename(maven string) string {
tokens := strings.Split(maven, ":") tokens := strings.Split(maven, ":")
pack := tokens[1] pack := tokens[1]
version := tokens[2] version := tokens[2]
return pack+"-"+version+".jar" return pack + "-" + version + ".jar"
} }

View File

@ -5,18 +5,29 @@
import Modpacks from './Modpacks.svelte' import Modpacks from './Modpacks.svelte'
import {CheckPrerequisites} from '../wailsjs/go/main/App.js' import {CheckPrerequisites} from '../wailsjs/go/main/App.js'
import { onMount } from 'svelte' import { onMount } from 'svelte'
import { loading, testPage, currentPage } from './global' import { loading, currentPage, instances } from './global'
import { slide } from 'svelte/transition' import { slide } from 'svelte/transition'
import Navbar from './Navbar.svelte' import Navbar from './Navbar.svelte'
import Instancepage from './Instancepage.svelte' import Instancepage from './Instancepage.svelte'
import { set_attributes, set_style } from 'svelte/internal'; import { set_attributes, set_style } from 'svelte/internal';
import {GetInstances} from '../wailsjs/go/main/InstanceManager.js'
let width: number = 10 let width: number = 10
let navMargin = document.getElementById("body") as HTMLElement; let navMargin = document.getElementById("body") as HTMLElement;
let r let r
function UpdateInstances() {
$loading = true
GetInstances().then((result) => {
$instances = result
$loading = false
})
}
onMount(() => { onMount(() => {
CheckPrerequisites().then(() => $loading = false) CheckPrerequisites().then(() => {
UpdateInstances()
})
r = document.getElementById('wrapper'); r = document.getElementById('wrapper');
}) })
function setMargin(){ function setMargin(){
@ -57,11 +68,11 @@
</div> </div>
{:else if $currentPage == 2} {:else if $currentPage == 2}
<div transition:slide="{{duration:100}}" class="central"> <div transition:slide="{{duration:100}}" class="central">
<Instances /> <Instances UpdateInstances={UpdateInstances} />
</div> </div>
{:else if $currentPage == 3} {:else if $currentPage == 3}
<div transition:slide="{{duration:100}}" class="central"> <div transition:slide="{{duration:100}}" class="central">
<Modpacks /> <Modpacks UpdateInstances={UpdateInstances} />
</div> </div>
{/if} {/if}
</body> </body>

View File

@ -5,13 +5,12 @@
import {GetQuiltVersions} from '../wailsjs/go/main/Quilt.js' import {GetQuiltVersions} from '../wailsjs/go/main/Quilt.js'
import {GetForgeVersions} from '../wailsjs/go/main/Forge.js' import {GetForgeVersions} from '../wailsjs/go/main/Forge.js'
import {onMount} from 'svelte' import {onMount} from 'svelte'
import {loading, addingInstance, instances, currentPage} from './global' import {loading, addingInstance} from './global'
import {slide} from 'svelte/transition' import {slide} from 'svelte/transition'
let modpacks: string[] = []
let modpacks: string[] = []
let pack: string let pack: string
//let instances: Instance[] = [] //let instances: Instance[] = []
let instance: string export let UpdateInstances
let name: string = "New Modpack" let name: string = "New Modpack"
let loader: string = "none" let loader: string = "none"
let fabric_ver: string = "" let fabric_ver: string = ""
@ -28,11 +27,8 @@
name = modpacks[0] name = modpacks[0]
updateLoaders() updateLoaders()
}) })
GetInstances().then((result) => { UpdateInstances()
$instances = result }
instance = $instances[0]
})
}
function updateLoaders(){ function updateLoaders(){
GetFabricVersions(pack).then((result) => { GetFabricVersions(pack).then((result) => {
@ -64,13 +60,6 @@
updateLists() updateLists()
}) })
function onclick(event) {
$loading = true
LaunchInstance(instance).then(() => {
$loading = false
})
}
function install(){ function install(){
$loading = true $loading = true
InstallVanilla(pack, name).then(() => { InstallVanilla(pack, name).then(() => {

View File

@ -6,26 +6,36 @@
import {loading} from './global.js' import {loading} from './global.js'
let modpacks: main.Modpack[] = [] let modpacks: main.Modpack[] = []
let pack: main.Modpack let pack: main.Modpack
export let UpdateInstances
let name: string = "New Modpack"
onMount(() => { onMount(() => {
GetModpacks().then((result) => { GetModpacks().then((result) => {
modpacks = result modpacks = result
pack = result[0] pack = result[0]
name = pack.Name
}) })
}) })
function AddModpack(){ function AddModpack(){
$loading = true $loading = true
ImportModpack(pack, pack.Name).then(() => $loading = false) ImportModpack(pack, name).then(() => {
UpdateInstances()
})
} }
function onchange(event){
name = pack.Name
}
</script> </script>
<main> <main>
<select id="pack" bind:value={pack} name="pack">Select a Modpack: <select id="pack" bind:value={pack} on:change={onchange} name="pack">Select a Modpack:
{#each modpacks as pack} {#each modpacks as pack}
<option value={pack}>{pack.Name}</option> <option value={pack}>{pack.Name}</option>
{/each} {/each}
</select> </select>
<input bind:value={name} />
<button on:click={AddModpack}>Add Modpack</button> <button on:click={AddModpack}>Add Modpack</button>
</main> </main>

View File

@ -1,6 +1,6 @@
<script lang="ts" src="https://kit.fontawesome.com/172593a6a5.js" crossorigin="anonymous"> <script lang="ts" src="https://kit.fontawesome.com/172593a6a5.js" crossorigin="anonymous">
import { main } from '../wailsjs/go/models'; import { main } from '../wailsjs/go/models';
import {addingInstance, testPage, navMargin, currentPage} from './global' import {addingInstance, navMargin, currentPage} from './global'
function extend(){ function extend(){
$navMargin = 17; $navMargin = 17;

View File

@ -1,7 +1,6 @@
import { writable } from "svelte/store" import { writable } from "svelte/store"
export const loading = writable(true) export const loading = writable(true)
export const addingInstance = writable(false) export const addingInstance = writable(false)
export const testPage = writable(false)
export const instances = writable([]) export const instances = writable([])
export const navMargin = writable(3) export const navMargin = writable(3)
export const currentPage = writable(1) export const currentPage = writable(1)

View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"bytes"
"crypto/sha1" "crypto/sha1"
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
@ -9,24 +10,24 @@ import (
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
wruntime "github.com/wailsapp/wails/v2/pkg/runtime"
) )
type Quilt struct { type Quilt struct {
} }
type QuiltDefinition struct { type QuiltDefinition struct {
Separator string Separator string
Build int Build int
Maven string Maven string
Version string Version string
Stable bool Stable bool
} }
type QuiltLibrary struct { type QuiltLibrary struct {
Name string Name string
Url string Url string
Sha1 string Sha1 string
} }
@ -37,20 +38,20 @@ type QuiltLibraries struct {
} }
type QuiltMeta struct { type QuiltMeta struct {
Version int Version int
Libraries QuiltLibraries Libraries QuiltLibraries
MainClass map[string]string MainClass map[string]string
} }
type QuiltVersion struct { type QuiltVersion struct {
Loader QuiltDefinition Loader QuiltDefinition
Intermediary QuiltDefinition Intermediary QuiltDefinition
Hashed QuiltDefinition Hashed QuiltDefinition
LauncherMeta QuiltMeta LauncherMeta QuiltMeta
} }
func (Quilt)GetQuiltVersions(mcVersion string) ([]QuiltVersion, error) { func (Quilt) GetQuiltVersions(mcVersion string) ([]QuiltVersion, error) {
resp, err := http.Get("https://meta.quiltmc.org/v3/versions/loader/"+mcVersion) resp, err := http.Get("https://meta.quiltmc.org/v3/versions/loader/" + mcVersion)
if err != nil { if err != nil {
return []QuiltVersion{}, fmt.Errorf("Unable to pull quilt version manifest: %s\n", err) return []QuiltVersion{}, fmt.Errorf("Unable to pull quilt version manifest: %s\n", err)
} }
@ -74,7 +75,8 @@ func GetQuiltMetadata(mcVersion string, quiltVersion string) (QuiltVersion, erro
return QuiltVersion{}, fmt.Errorf("Unable to find requested version.\n") return QuiltVersion{}, fmt.Errorf("Unable to find requested version.\n")
} }
func InstallQuiltLib(lib QuiltLibrary, libDir string) { func InstallQuiltLib(lib QuiltLibrary, libDir string, a *App) {
a.Status(fmt.Sprintf("Checking %s\n", lib.Name))
path := filepath.Join(ProcessMavenPath(lib.Name), ProcessMavenFilename(lib.Name)) path := filepath.Join(ProcessMavenPath(lib.Name), ProcessMavenFilename(lib.Name))
if _, err := os.Stat(filepath.Join(libDir, path)); err == nil { if _, err := os.Stat(filepath.Join(libDir, path)); err == nil {
f, _ := os.OpenFile(filepath.Join(libDir, path), os.O_RDONLY, 0755) f, _ := os.OpenFile(filepath.Join(libDir, path), os.O_RDONLY, 0755)
@ -85,7 +87,8 @@ func InstallQuiltLib(lib QuiltLibrary, libDir string) {
return return
} }
} }
resp, err := http.Get(lib.Url+path) a.Status(fmt.Sprintf("Downloading %s\n", lib.Name))
resp, err := http.Get(lib.Url + path)
if err != nil { if err != nil {
fmt.Printf("unable to find library: %s\n", lib.Url+path) fmt.Printf("unable to find library: %s\n", lib.Url+path)
return return
@ -95,22 +98,37 @@ func InstallQuiltLib(lib QuiltLibrary, libDir string) {
fmt.Printf("unable to find library: %s\n", lib.Url+path) fmt.Printf("unable to find library: %s\n", lib.Url+path)
return return
} }
buff := new(bytes.Buffer)
downloaded := 0
for {
count, err := io.CopyN(buff, resp.Body, BlockSize)
if err == io.EOF {
downloaded += int(count)
break
}
if err != nil {
fmt.Printf("Error Downloading libs: %e\n", err)
return
}
downloaded += int(count)
wruntime.EventsEmit(a.Ctx, "download", downloaded, resp.ContentLength)
}
os.MkdirAll(filepath.Join(libDir, ProcessMavenPath(lib.Name)), 0755) os.MkdirAll(filepath.Join(libDir, ProcessMavenPath(lib.Name)), 0755)
f, _ := os.OpenFile(filepath.Join(libDir, path), os.O_CREATE|os.O_RDWR, 0755) f, _ := os.OpenFile(filepath.Join(libDir, path), os.O_CREATE|os.O_RDWR, 0755)
defer f.Close() defer f.Close()
io.Copy(f, resp.Body) io.Copy(f, buff)
wruntime.EventsEmit(a.Ctx, "download_complete")
} }
func InstallQuiltLibs(mcVersion string, quiltVersion string, libDir string) { func InstallQuiltLibs(mcVersion string, quiltVersion string, libDir string, a *App) {
metadata, _ := GetQuiltMetadata(mcVersion, quiltVersion) metadata, _ := GetQuiltMetadata(mcVersion, quiltVersion)
for _, lib := range metadata.LauncherMeta.Libraries.Client { for _, lib := range metadata.LauncherMeta.Libraries.Client {
InstallQuiltLib(lib, libDir) InstallQuiltLib(lib, libDir, a)
} }
for _, lib := range metadata.LauncherMeta.Libraries.Common { for _, lib := range metadata.LauncherMeta.Libraries.Common {
InstallQuiltLib(lib, libDir) InstallQuiltLib(lib, libDir, a)
} }
InstallQuiltLib(QuiltLibrary{Name: metadata.Loader.Maven, Sha1: "", Url: "https://maven.quiltmc.org/repository/release/"}, libDir) InstallQuiltLib(QuiltLibrary{Name: metadata.Loader.Maven, Sha1: "", Url: "https://maven.quiltmc.org/repository/release/"}, libDir, a)
InstallQuiltLib(QuiltLibrary{Name: metadata.Intermediary.Maven, Sha1: "", Url: "https://maven.fabricmc.net/"}, libDir) InstallQuiltLib(QuiltLibrary{Name: metadata.Intermediary.Maven, Sha1: "", Url: "https://maven.fabricmc.net/"}, libDir, a)
InstallQuiltLib(QuiltLibrary{Name: metadata.Hashed.Maven, Sha1: "", Url: "https://maven.quiltmc.org/repository/release/"}, libDir) InstallQuiltLib(QuiltLibrary{Name: metadata.Hashed.Maven, Sha1: "", Url: "https://maven.quiltmc.org/repository/release/"}, libDir, a)
} }