Skip to content

Commit

Permalink
Add "open game directory" button
Browse files Browse the repository at this point in the history
  • Loading branch information
mircearoata committed Dec 28, 2023
1 parent 6e5c99a commit 61bfc01
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
8 changes: 8 additions & 0 deletions backend/bindings/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
}
Expand Down
27 changes: 16 additions & 11 deletions frontend/src/lib/components/left-bar/LeftBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -217,15 +217,20 @@
disabled={!$canModify}
>
{#each $installs as install}
<Wrapper>
<Option value={install.path}>
<Label>{install?.branch} ({install?.launcher})</Label>
</Option>

<Tooltip surface$class="max-w-lg text-base">
{install?.path}
</Tooltip>
</Wrapper>
<Option value={install.path}>
<Label class="mdc-deprecated-list-item__text">{install?.branch} ({install?.launcher})</Label>
<div class="!p-4 !m-0 !ml-auto !h-full" on:click={(e) => {
e.stopPropagation();
OpenExternal(install.path);
}}>
<Wrapper>
<SvgIcon icon={mdiFolderOpen} class="!w-full !h-full"/>
<Tooltip surface$class="max-w-lg text-base">
{install?.path}
</Tooltip>
</Wrapper>
</div>
</Option>
{/each}
</Select>
<div class="flex w-full mt-2">
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 61bfc01

Please sign in to comment.