diff --git a/backend/app/app.go b/backend/app/app.go index c613593..d85608d 100644 --- a/backend/app/app.go +++ b/backend/app/app.go @@ -37,11 +37,23 @@ func NewUtils() *Utils { return &Utils{} } -func (util *Utils) WalkDirExt(root string, exts []string) ([]string, error) { +func (u *Utils) ExistsInDir(dir, item string) (bool, error) { + return backend.ExistsInDir(dir, item) +} + +func (u Utils) ExistsAtPath(path string, clean bool) (bool, error) { + if clean { + path = filepath.Clean(path) + } + + return backend.ExistsAtPath(path) +} + +func (u *Utils) WalkDirExt(root string, exts []string) ([]string, error) { return backend.WalkDirExt(root, exts) } -func (util *Utils) ReadFile(path string) (*string, error) { +func (u *Utils) ReadFile(path string) (*string, error) { return backend.ReadFile(path) } diff --git a/backend/app/persistence.go b/backend/app/persistence.go index 1488107..b4102a9 100644 --- a/backend/app/persistence.go +++ b/backend/app/persistence.go @@ -49,38 +49,42 @@ func (persistence *Persistence) Save() error { } // The frontend must still be loaded to call these runtime methods. -func (ws *Persistence) ApplyCurrentWindowState(ctx context.Context) { - ws.SetMaximized(wRuntime.WindowIsMaximised(ctx)) +func (persistence *Persistence) ApplyCurrentWindowState(ctx context.Context) { + maximized := wRuntime.WindowIsMaximised(ctx) + persistence.SetMaximized(maximized) - w, h := wRuntime.WindowGetSize(ctx) - ws.SetWindowWidth(uint16(w)) - ws.SetWindowHeight(uint16(h)) + if !maximized { + w, h := wRuntime.WindowGetSize(ctx) + x, y := wRuntime.WindowGetPosition(ctx) - x, y := wRuntime.WindowGetPosition(ctx) - ws.SetWindowX(x) - ws.SetWindowY(y) + persistence.SetWindowWidth(uint16(w)) + persistence.SetWindowHeight(uint16(h)) + + persistence.SetWindowX(x) + persistence.SetWindowY(y) + } } -func (ws *Persistence) SetWindowWidth(width uint16) { - ws.Window.Width = width +func (persistence *Persistence) SetWindowWidth(width uint16) { + persistence.Window.Width = width } -func (ws *Persistence) SetWindowHeight(height uint16) { - ws.Window.Height = height +func (persistence *Persistence) SetWindowHeight(height uint16) { + persistence.Window.Height = height } -func (ws *Persistence) SetWindowX(xPos int) { - ws.Window.X = xPos +func (persistence *Persistence) SetWindowX(xPos int) { + persistence.Window.X = xPos } -func (ws *Persistence) SetWindowY(yPos int) { - ws.Window.Y = yPos +func (persistence *Persistence) SetWindowY(yPos int) { + persistence.Window.Y = yPos } -func (ws *Persistence) SetMaximized(maximized bool) { - ws.Window.Maximized = maximized +func (persistence *Persistence) SetMaximized(maximized bool) { + persistence.Window.Maximized = maximized } -func (ws *Persistence) SetFavouriteGames(identifiers []string) { - ws.FavouriteGames = identifiers +func (persistence *Persistence) SetFavouriteGames(identifiers []string) { + persistence.FavouriteGames = identifiers } diff --git a/frontend/src/mocks/GameService.ts b/frontend/src/mocks/GameService.ts index cedea55..0697c43 100644 --- a/frontend/src/mocks/GameService.ts +++ b/frontend/src/mocks/GameService.ts @@ -4,7 +4,7 @@ export const mockGameList: ThunderstoreGame[] = [{ title: "Lethal Company", identifier: 'lethal-company', image: "LethalCompany.png", - path: "E:\\SteamLibrary\\steamapps\\common\\Lethal Company", + path: "E:/SteamLibrary/steamapps/common/Lethal Company", aliases: ["LC", "LethalCompany"], steamID: 1966720 }, { diff --git a/frontend/src/stores/game.ts b/frontend/src/stores/game.ts index 4079d4d..353e05c 100644 --- a/frontend/src/stores/game.ts +++ b/frontend/src/stores/game.ts @@ -7,6 +7,8 @@ import { thunderstore } from '@backend/models.js' import { GetPersistence } from '@backend/app/Application.js' import { BepinexInstalled } from '@backend/game/GameManager.js' +import { ExistsAtPath } from '@backend/app/Utils.js' + export interface GameState { selectedGame: ThunderstoreGame, games: Map @@ -69,7 +71,9 @@ export const useGameStore = defineStore('GameStore', () => { // Init game props. for (const game of gameList) { game.favourited = await persistence.favourite_games.includes(game.identifier) - game.installed = !!game.path // TODO: Check game executable exists. For now, assume installed if path specified. + + // TODO: Check game executable exists. For now, assume installed if game path is specified and exists. + game.installed = !game.path ? false : await ExistsAtPath(game.path, true) if (game.path) { game.bepinexSetup = await BepinexInstalled(game.path) diff --git a/frontend/src/views/GameSelection.vue b/frontend/src/views/GameSelection.vue index 4fe8ab5..c813931 100644 --- a/frontend/src/views/GameSelection.vue +++ b/frontend/src/views/GameSelection.vue @@ -306,7 +306,7 @@ onMounted(async () => {