Skip to content

Commit

Permalink
refactor: create method for prettifying semantic versions
Browse files Browse the repository at this point in the history
  • Loading branch information
blackxfiied committed Nov 12, 2024
1 parent e7bbcec commit a325ade
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 16 deletions.
8 changes: 6 additions & 2 deletions Mythic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
6A2961032CE1DD6200917E90 /* FirebaseAnalytics in Frameworks */ = {isa = PBXBuildFile; productRef = 6A2961022CE1DD6200917E90 /* FirebaseAnalytics */; };
6A2961052CE1DD6200917E90 /* FirebaseCore in Frameworks */ = {isa = PBXBuildFile; productRef = 6A2961042CE1DD6200917E90 /* FirebaseCore */; };
6A2961072CE1DD6200917E90 /* FirebaseCrashlytics in Frameworks */ = {isa = PBXBuildFile; productRef = 6A2961062CE1DD6200917E90 /* FirebaseCrashlytics */; };
6A31421C2CE39911006838CC /* SemanticVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A31421B2CE3990B006838CC /* SemanticVersion.swift */; };
6A34366E2B8D7F1200D35BCA /* Shimmer in Frameworks */ = {isa = PBXBuildFile; productRef = 6A34366D2B8D7F1200D35BCA /* Shimmer */; };
6A371B592AE7DFBF0054BF7A /* ZIPFoundation in Frameworks */ = {isa = PBXBuildFile; productRef = 6A371B582AE7DFBF0054BF7A /* ZIPFoundation */; };
6A448E0E2CC4A53A001E9F47 /* GameListCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A448E0D2CC4A531001E9F47 /* GameListCard.swift */; };
Expand Down Expand Up @@ -192,6 +193,7 @@
6A2960FB2CE0ED0700917E90 /* EpicWebAuthView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EpicWebAuthView.swift; sourceTree = "<group>"; };
6A2960FD2CE1017700917E90 /* NSApplication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSApplication.swift; sourceTree = "<group>"; };
6A2960FF2CE1033000917E90 /* NSWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSWindow.swift; sourceTree = "<group>"; };
6A31421B2CE3990B006838CC /* SemanticVersion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SemanticVersion.swift; sourceTree = "<group>"; };
6A448E0D2CC4A531001E9F47 /* GameListCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameListCard.swift; sourceTree = "<group>"; };
6A448E0F2CC4BC50001E9F47 /* GameCardVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameCardVM.swift; sourceTree = "<group>"; };
6A496A722C1AF75600FD637B /* Game.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Game.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -468,6 +470,7 @@
6AD44DE52C0A29BF00824C06 /* Built-in */ = {
isa = PBXGroup;
children = (
6A31421B2CE3990B006838CC /* SemanticVersion.swift */,
6A2960FF2CE1033000917E90 /* NSWindow.swift */,
6A2960FD2CE1017700917E90 /* NSApplication.swift */,
6A2934B32BFCFAFD0035CE4B /* Bundle.swift */,
Expand Down Expand Up @@ -755,6 +758,7 @@
EB90A3662CD941EF001F0871 /* OnboardingEpicGamesLoginStepView.swift in Sources */,
6A29355A2BFCFAFD0035CE4B /* ContainerSettingsView.swift in Sources */,
6A448E0E2CC4A53A001E9F47 /* GameListCard.swift in Sources */,
6A31421C2CE39911006838CC /* SemanticVersion.swift in Sources */,
6A2935572BFCFAFD0035CE4B /* GameInstallProgressView.swift in Sources */,
6A29353B2BFCFAFD0035CE4B /* URL.swift in Sources */,
6A2935382BFCFAFD0035CE4B /* Logger.swift in Sources */,
Expand Down Expand Up @@ -945,7 +949,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3259;
CURRENT_PROJECT_VERSION = 3262;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Sources/Preview Content\"";
DEVELOPMENT_TEAM = "";
Expand Down Expand Up @@ -992,7 +996,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3259;
CURRENT_PROJECT_VERSION = 3262;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Sources/Preview Content\"";
DEVELOPMENT_TEAM = "";
Expand Down
15 changes: 6 additions & 9 deletions Sources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -3079,6 +3079,7 @@
}
},
"%@ %@ (%@)" : {
"extractionState" : "stale",
"localizations" : {
"af" : {
"stringUnit" : {
Expand Down Expand Up @@ -31732,19 +31733,15 @@
}
}
}
},
"Mythic %@" : {

},
"Mythic Engine" : {

},
"Mythic Engine %lld.%lld.%lld (%@)" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Mythic Engine %1$lld.%2$lld.%3$lld (%4$@)"
}
}
}
"Mythic Engine %@" : {

},
"Mythic Engine is Mythic's implementation of Apple's game porting toolkit (GPTK),\nwhich combines wine and D3DMetal, to create a windows gaming experience on macOS.\nSimilar to Proton, Mythic Engine attempts to be an emulator-like experience that\nenables native Windows games to be playable on macOS, while coming closer to native\nperformance than ever before. (performance will vary between games)" : {
"extractionState" : "stale",
Expand Down
24 changes: 24 additions & 0 deletions Sources/Utilities/Extensions/Built-in/SemanticVersion.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// SemanticVersion.swift
// Mythic
//
// Created by Esiayo Alegbe on 11/12/24.
//

import SemanticVersion

extension SemanticVersion {
var prettyString: String {
var versionString = "\(major).\(minor).\(patch)"

if !preRelease.isEmpty {
versionString += "-\(preRelease)"
}

if !build.isEmpty {
versionString += " (\(build))"
}

return versionString
}
}
11 changes: 6 additions & 5 deletions Sources/Views/Navigation/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Foundation
import OSLog
import Combine
import WhatsNewKit
import SemanticVersion

struct MainView: View {
@EnvironmentObject var networkMonitor: NetworkMonitor
Expand Down Expand Up @@ -81,14 +82,14 @@ struct MainView: View {

#if DEBUG
VStack {
if let displayName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String,
let shortVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String,
let bundleVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String {
Text("\(displayName) \(shortVersion) (\(bundleVersion))")
if let shortVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String,
let bundleVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String,
let mythicVersion: SemanticVersion = .init("\(shortVersion)+\(bundleVersion)") {
Text("Mythic \(mythicVersion.prettyString)")
}

if let engineVersion = Engine.version {
Text("Mythic Engine \(engineVersion.major).\(engineVersion.minor).\(engineVersion.patch) (\(engineVersion.build))")
Text("Mythic Engine \(engineVersion.prettyString)")
}
}
.font(.footnote)
Expand Down

0 comments on commit a325ade

Please sign in to comment.