FCLauncher/fclauncher/frontend/src/Modpacks.svelte

41 lines
1.1 KiB
Svelte
Raw Normal View History

2024-11-25 12:36:29 -07:00
<script lang="ts">
import {onMount} from 'svelte'
import {GetModpacks} from '../wailsjs/go/main/ModpackManager.js'
import {ImportModpack} from '../wailsjs/go/main/InstanceManager.js'
2024-11-25 12:36:29 -07:00
import { main } from '../wailsjs/go/models';
import {loading} from './global.js'
2024-11-25 12:36:29 -07:00
let modpacks: main.Modpack[] = []
let pack: main.Modpack
2024-11-26 10:22:37 -07:00
export let UpdateInstances
let name: string = "New Modpack"
2024-11-25 12:36:29 -07:00
onMount(() => {
GetModpacks().then((result) => {
modpacks = result
pack = result[0]
2024-11-26 10:22:37 -07:00
name = pack.Name
2024-11-25 12:36:29 -07:00
})
})
function AddModpack(){
$loading = true
2024-11-26 10:22:37 -07:00
ImportModpack(pack, name).then(() => {
UpdateInstances()
})
}
2024-11-26 10:22:37 -07:00
function onchange(event){
name = pack.Name
}
2024-11-25 12:36:29 -07:00
</script>
<main>
2024-11-26 10:22:37 -07:00
<select id="pack" bind:value={pack} on:change={onchange} name="pack">Select a Modpack:
2024-11-25 12:36:29 -07:00
{#each modpacks as pack}
<option value={pack}>{pack.Name}</option>
{/each}
</select>
2024-11-26 10:22:37 -07:00
<input bind:value={name} />
<button on:click={AddModpack}>Add Modpack</button>
2024-11-25 12:36:29 -07:00
</main>