Created delete instance button, and made minor ui modifications

This commit is contained in:
Samuel Walker 2025-03-10 11:38:27 -06:00
parent 3b6aa14082
commit ce24c0a55d
Signed by: piwalker
GPG Key ID: 616B1928705EA4C9
4 changed files with 40 additions and 26 deletions

View File

@ -174,7 +174,7 @@ func (i *InstanceManager) InstallModpack(modpack Modpack, instanceName string) {
data, _ := json.Marshal(instance)
f.Write(data)
i.checkJavaVersion(instance)
i.SearchInstances()
}
func (i *InstanceManager) InstallVanilla(version string, instanceName string) {
@ -232,8 +232,7 @@ func (i *InstanceManager) InstallVanilla(version string, instanceName string) {
i.app.Status(fmt.Sprintf("Installing Java Version %d", instance.JavaVersion))
i.app.Java.InstallJavaVer(instance.JavaVersion)
}
return
i.SearchInstances()
}
func (i *InstanceManager) GetInstances() []string {
@ -297,7 +296,7 @@ func (i *InstanceManager) LaunchInstance(instance string) {
execName := "java"
suffix := "lin"
if runtime.GOOS == "windows" {
execName = "Java.exe"
execName = "Javaw.exe"
suffix = "win"
}
dir = filepath.Join(dir, "FCLauncher")
@ -605,7 +604,6 @@ func (i *InstanceManager) ImportMrpack(data io.Reader, name string) {
}
func (i *InstanceManager) OpenInstanceFolder(instance string) {
i.app.Status("Installing Fabric")
_, err := i.GetInstance(instance)
if err != nil {
fmt.Printf("Instance does not exist\n")
@ -613,3 +611,14 @@ func (i *InstanceManager) OpenInstanceFolder(instance string) {
dir, _ := os.UserConfigDir()
openbrowser(filepath.Join(dir, "FCLauncher", "instances", instance, "minecraft"))
}
func (i *InstanceManager) DeleteInstance(instance string) {
_, err := i.GetInstance(instance)
if err != nil {
fmt.Printf("Instance does not exist\n")
return
}
dir, _ := os.UserConfigDir()
os.RemoveAll(filepath.Join(dir, "FCLauncher", "instances", instance))
i.SearchInstances()
}

View File

@ -1,9 +1,10 @@
<script lang="ts">
import {instances, loading, navMargin} from './global'
import {OpenInstanceFolder, InstallVanilla, LaunchInstance, GetInstances, InstallForge, InstallQuilt, InstallFabric, CheckUpdate} from '../wailsjs/go/main/InstanceManager.js'
import {OpenInstanceFolder, InstallVanilla, LaunchInstance, GetInstances, InstallForge, InstallQuilt, InstallFabric, CheckUpdate, DeleteInstance} from '../wailsjs/go/main/InstanceManager.js'
import {GetVersions} from '../wailsjs/go/main/App.js'
import {onMount, createEventDispatcher} from 'svelte'
var testArray = ["test","test2","test3"];
export let UpdateInstances
let pack: string = "";
let instance: string
@ -30,6 +31,16 @@ import {onMount, createEventDispatcher} from 'svelte'
})
}
function deleteclick() {
$loading = true
DeleteInstance(radio).then(() => {
GetInstances().then((result) => {
$instances = result
$loading = false
})
})
}
</script>
@ -52,8 +63,9 @@ import {onMount, createEventDispatcher} from 'svelte'
</div>
</div>
<div class="options-container">
<button class="launch-button" on:click={launchclick}>Launch {radio}</button>
<button class="option-button" on:click={() => {OpenInstanceFolder(radio)}}>Open Instance Folder</button>
<button class="instance-button" disabled='{radio == ""}' on:click={launchclick}>Launch {radio}</button>
<button class="instance-button" disabled='{radio == ""}' on:click={() => {OpenInstanceFolder(radio)}}>Open Instance Folder</button>
<button class="instance-button" disabled='{radio == ""}' on:click={deleteclick}>Delete Instance</button>
</div>
</div>
@ -107,7 +119,7 @@ main{
margin-top: 15rem;
gap: 10px;
}
.launch-button{
.instance-button{
min-height: 3rem;
border:solid;
border-radius: 4px;
@ -118,29 +130,16 @@ main{
max-width: 10rem;
max-height: fit-content;
}
.launch-button:hover{
.instance-button:hover:enabled{
color: var(--text-secondary);
}
.launch-button:active{
.instance-button:active:enabled{
opacity: 0.6;
}
.option-button{
min-height: 3rem;
border:solid;
border-radius: 4px;
background-color: var(--bg-secondary);
border-color: var(--bg-secondary);
color: var(--text-primary);
font-size: medium;
max-width: 10rem;
max-height: fit-content;
}
.option-button:hover{
color: var(--text-secondary);
}
.option-button:active{
.instance-button:disabled{
opacity: 0.6;
}
.container{
display: flex;
min-height: fit-content;

View File

@ -5,6 +5,8 @@ import {io} from '../models';
export function CheckUpdate(arg1:main.Instance):Promise<void>;
export function DeleteInstance(arg1:string):Promise<void>;
export function GetInstance(arg1:string):Promise<main.Instance>;
export function GetInstances():Promise<Array<string>>;

View File

@ -6,6 +6,10 @@ export function CheckUpdate(arg1) {
return window['go']['main']['InstanceManager']['CheckUpdate'](arg1);
}
export function DeleteInstance(arg1) {
return window['go']['main']['InstanceManager']['DeleteInstance'](arg1);
}
export function GetInstance(arg1) {
return window['go']['main']['InstanceManager']['GetInstance'](arg1);
}