Made instances list global

This commit is contained in:
Samuel Walker 2024-11-01 05:55:41 -06:00
parent 9d23d503e2
commit 27c97010ae
5 changed files with 64 additions and 60 deletions

View File

@ -80,7 +80,7 @@ func (i *InstanceManager)checkJavaVersion(instance Instance){
for _, comp := range data.Components { for _, comp := range data.Components {
if comp.Uid == "net.minecraft" { if comp.Uid == "net.minecraft" {
mc_version = comp.Version mc_version = comp.Version
break; break
} }
} }
fmt.Printf("MC Version: %s", mc_version) fmt.Printf("MC Version: %s", mc_version)
@ -216,8 +216,12 @@ func (i *InstanceManager)InstallVanilla(version string, instanceName string) {
return return
} }
func (i *InstanceManager)GetInstances() []Instance{ func (i *InstanceManager) GetInstances() []string {
return i.instances names := []string{}
for _, inst := range i.instances {
names = append(names, inst.InstanceName)
}
return names
} }
func (i *InstanceManager) CheckUpdate(instance Instance) { func (i *InstanceManager) CheckUpdate(instance Instance) {
@ -294,8 +298,6 @@ func (i *InstanceManager)LaunchInstance(instance string) {
fmt.Printf("Command Output: %s\n", data) fmt.Printf("Command Output: %s\n", data)
} }
func (i *InstanceManager) InstallFabric(instance string, fabricVersion string) { func (i *InstanceManager) InstallFabric(instance string, fabricVersion string) {
i.app.Status("Installing Fabric") i.app.Status("Installing Fabric")
instanceObject, err := i.GetInstance(instance) instanceObject, err := i.GetInstance(instance)

View File

@ -5,12 +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} from './global' import {loading, addingInstance, instances} 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 let instance: string
let name: string = "New Modpack" let name: string = "New Modpack"
let loader: string = "none" let loader: string = "none"
@ -29,8 +29,8 @@
updateLoaders() updateLoaders()
}) })
GetInstances().then((result) => { GetInstances().then((result) => {
instances = result $instances = result
instance = instances[0].InstanceName instance = $instances[0]
}) })
} }
@ -109,8 +109,8 @@
<main> <main>
<select bind:value={instance} name="pack">Select a Modpack: <select bind:value={instance} name="pack">Select a Modpack:
{#each instances as instance} {#each $instances as instance}
<option value={instance.InstanceName}>{instance.InstanceName}</option> <option value={instance}>{instance}</option>
{/each} {/each}
</select> </select>
<button on:click={onclick}>Launch</button> <button on:click={onclick}>Launch</button>

View File

@ -1,4 +1,5 @@
<script lang="ts"> <script lang="ts">
import {instances} from './global'
var testArray = ["test","test2","test3"]; var testArray = ["test","test2","test3"];
</script> </script>
@ -6,8 +7,8 @@
<main> <main>
<div class="testLinks"> <div class="testLinks">
{#each {length: testArray.length} as _, i} {#each $instances as i}
<li>{testArray[i]}</li> <li>{i}</li>
{/each} {/each}
</div> </div>
</main> </main>

View File

@ -2,3 +2,4 @@ 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 testPage = writable(false)
export const instances = writable([])

View File

@ -6,7 +6,7 @@ export function CheckUpdate(arg1:main.Instance):Promise<void>;
export function GetInstance(arg1:string):Promise<main.Instance>; export function GetInstance(arg1:string):Promise<main.Instance>;
export function GetInstances():Promise<Array<main.Instance>>; export function GetInstances():Promise<Array<string>>;
export function InstallFabric(arg1:string,arg2:string):Promise<void>; export function InstallFabric(arg1:string,arg2:string):Promise<void>;