From 1389b99696d171df6c9858874705dcaad57cb536 Mon Sep 17 00:00:00 2001 From: blackxfiied <41133734+blackxfiied@users.noreply.github.com> Date: Tue, 30 Jan 2024 15:40:33 +0800 Subject: [PATCH] Add 'Show in path' button and other improvements to game settings view --- Mythic.xcodeproj/project.pbxproj | 4 +-- .../GameList/Extensions/GameSettings.swift | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Mythic.xcodeproj/project.pbxproj b/Mythic.xcodeproj/project.pbxproj index 8158a1b7..d840d513 100644 --- a/Mythic.xcodeproj/project.pbxproj +++ b/Mythic.xcodeproj/project.pbxproj @@ -739,7 +739,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 2282; + CURRENT_PROJECT_VERSION = 2283; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"Mythic/Preview Content\""; DEVELOPMENT_TEAM = 67ZBY275P8; @@ -778,7 +778,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 2282; + CURRENT_PROJECT_VERSION = 2283; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"Mythic/Preview Content\""; DEVELOPMENT_TEAM = 67ZBY275P8; diff --git a/Mythic/Views/GameList/Extensions/GameSettings.swift b/Mythic/Views/GameList/Extensions/GameSettings.swift index 8b3b6a97..7f8fd784 100644 --- a/Mythic/Views/GameList/Extensions/GameSettings.swift +++ b/Mythic/Views/GameList/Extensions/GameSettings.swift @@ -33,6 +33,8 @@ extension GameListView { @State private var isWineSectionExpanded: Bool = true @State private var isDXVKSectionExpanded: Bool = true + @State private var gamePath: String? + // MARK: - Body View var body: some View { VStack { @@ -123,6 +125,30 @@ extension GameListView { } } } + .disabled(gamePath == nil) + } + HStack { + VStack { + HStack { + Text("Game location") + Spacer() + } + + HStack { + Text(URL(filePath: (gamePath ?? "[Unknown]")).prettyPath()) // FIXME: 3x repetition is bad + .foregroundStyle(.placeholder) + Spacer() + } + } + + Spacer() + + Button("Show in Finder") { + NSWorkspace.shared.activateFileViewerSelecting( + [URL(filePath: gamePath ?? .init())] + ) + } + .disabled(gamePath == nil) } } @@ -142,6 +168,9 @@ extension GameListView { } .formStyle(.grouped) } + .onAppear { + gamePath = game.isLegendary ? try? Legendary.getGamePath(game: game) : game.path + } .task { if game.isLegendary { metadata = try? Legendary.getGameMetadata(game: game) // FIXME: currently unused