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

View File

@ -5,12 +5,12 @@
import {GetQuiltVersions} from '../wailsjs/go/main/Quilt.js'
import {GetForgeVersions} from '../wailsjs/go/main/Forge.js'
import {onMount} from 'svelte'
import {loading, addingInstance} from './global'
import {loading, addingInstance, instances} from './global'
import {slide} from 'svelte/transition'
let modpacks: string[] = []
let pack: string
let instances: Instance[] = []
//let instances: Instance[] = []
let instance: string
let name: string = "New Modpack"
let loader: string = "none"
@ -29,8 +29,8 @@
updateLoaders()
})
GetInstances().then((result) => {
instances = result
instance = instances[0].InstanceName
$instances = result
instance = $instances[0]
})
}
@ -109,8 +109,8 @@
<main>
<select bind:value={instance} name="pack">Select a Modpack:
{#each instances as instance}
<option value={instance.InstanceName}>{instance.InstanceName}</option>
{#each $instances as instance}
<option value={instance}>{instance}</option>
{/each}
</select>
<button on:click={onclick}>Launch</button>

View File

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

View File

@ -2,3 +2,4 @@ import { writable } from "svelte/store"
export const loading = writable(true)
export const addingInstance = 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 GetInstances():Promise<Array<main.Instance>>;
export function GetInstances():Promise<Array<string>>;
export function InstallFabric(arg1:string,arg2:string):Promise<void>;