From 61bfc01b81aeca71103cb9da48b034e3255e38df Mon Sep 17 00:00:00 2001 From: Mircea Roata Date: Fri, 29 Dec 2023 00:34:39 +0200 Subject: [PATCH] Add "open game directory" button --- backend/bindings/app.go | 8 ++++++ .../lib/components/left-bar/LeftBar.svelte | 27 +++++++++++-------- go.mod | 2 +- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/backend/bindings/app.go b/backend/bindings/app.go index ce27785f..9a5f2746 100644 --- a/backend/bindings/app.go +++ b/backend/bindings/app.go @@ -6,6 +6,7 @@ import ( "strings" "time" + "github.com/pkg/browser" "github.com/pkg/errors" "github.com/spf13/viper" wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime" @@ -164,6 +165,13 @@ func (a *App) Show() { wailsRuntime.Show(a.ctx) } +func (a *App) OpenExternal(input string) { + err := browser.OpenFile(input) + if err != nil { + slog.Error("failed to open external", slog.Any("error", err), slog.String("path", input)) + } +} + func (a *App) GetAPIEndpoint() string { return viper.GetString("api-base") + viper.GetString("graphql-api") } diff --git a/frontend/src/lib/components/left-bar/LeftBar.svelte b/frontend/src/lib/components/left-bar/LeftBar.svelte index c9e6266d..d5f8eb4e 100644 --- a/frontend/src/lib/components/left-bar/LeftBar.svelte +++ b/frontend/src/lib/components/left-bar/LeftBar.svelte @@ -4,7 +4,7 @@ import Dialog, { Title, Content, Actions } from '@smui/dialog'; import TextField from '@smui/textfield'; import Tooltip, { Wrapper } from '@smui/tooltip'; - import { mdiCheckCircle, mdiCloseCircle, mdiDownload, mdiHelpCircle, mdiPencil, mdiPlusCircle, mdiTrashCan, mdiUpload, mdiWeb } from '@mdi/js'; + import { mdiCheckCircle, mdiCloseCircle, mdiDownload, mdiFolderOpen, mdiHelpCircle, mdiPencil, mdiPlusCircle, mdiTrashCan, mdiUpload, mdiWeb } from '@mdi/js'; import { siDiscord, siGithub } from 'simple-icons/icons'; import HelperText from '@smui/textfield/helper-text'; import LinearProgress from '@smui/linear-progress'; @@ -18,7 +18,7 @@ import { installs, profiles, canModify, selectedInstall, selectedInstallPath, selectedProfile, modsEnabled, progress } from '$lib/store/ficsitCLIStore'; import { error, siteURL } from '$lib/store/generalStore'; import { BrowserOpenURL, EventsOn } from '$wailsjs/runtime/runtime'; - import { OpenFileDialog } from '$wailsjs/go/bindings/App'; + import { OpenExternal, OpenFileDialog } from '$wailsjs/go/bindings/App'; import type { ficsitcli } from '$wailsjs/go/models'; import { AddProfile, DeleteProfile, RenameProfile, ImportProfile, ExportCurrentProfile, ReadExportedProfileMetadata } from '$wailsjs/go/ficsitcli/FicsitCLI'; @@ -217,15 +217,20 @@ disabled={!$canModify} > {#each $installs as install} - - - - - {install?.path} - - + {/each}
diff --git a/go.mod b/go.mod index b474f722..0de7a625 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/lmittmann/tint v1.0.3 github.com/minio/selfupdate v0.6.0 github.com/mitchellh/go-ps v1.0.0 + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 github.com/pkg/errors v0.9.1 github.com/samber/slog-multi v1.0.2 github.com/satisfactorymodding/ficsit-cli v0.5.0 @@ -53,7 +54,6 @@ require ( github.com/mircearoata/pubgrub-go v0.3.3 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/pelletier/go-toml/v2 v2.1.1 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/pkg/sftp v1.13.6 // indirect github.com/pterm/pterm v0.12.72 // indirect github.com/puzpuzpuz/xsync/v3 v3.0.2 // indirect