Skip to content

Commit

Permalink
Fix non-style indents added by swiftlint.
Browse files Browse the repository at this point in the history
  • Loading branch information
vapidinfinity committed Dec 11, 2023
1 parent d9eb0c6 commit eca3f67
Show file tree
Hide file tree
Showing 29 changed files with 345 additions and 344 deletions.
62 changes: 31 additions & 31 deletions Mythic/Controllers/Base/Legendary/Extensions/LegendaryExt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,128 +18,128 @@ extension Legendary {
case stdout
case stderr
}

/// Enumeration to specify image types.
enum ImageType {
case normal
case tall
}

/// Enumeration containing the activities legendary does that require a data lock.
enum DataLockUse {
case installing
case removing
case moving
case none
}

/// Enumeration containing the two different platforms legendary can download games for.
enum GamePlatform {
case macOS
case windows
}

/// Error for image errors
enum ImageError: Error {
/// Failure to get an image from source.
case get

/// Failure to load an image to Mythic or storage.
case load
}

/* Until more validation errors become available.
enum UserValidationError: Error {
case notSignedIn
}
*/

/// Your father.
enum DoesNotExistError: Error {
case game
case aliases
case file(file: URL)
case directory(directory: String)
}

/// Struct to store games.
struct Game: Hashable {
var appName: String
var title: String
}

/// A struct to hold closures for handling stdout and stderr output.
struct OutputHandler {
/// A closure to handle stdout output.
let stdout: (String) -> Void

/// A closure to handle stderr output.
let stderr: (String) -> Void
}

/// Represents a condition to be checked for in the output streams before input is appended.
struct InputIfCondition {
/// The stream to be checked (stdout or stderr).
let stream: Stream

/// The string pattern to be matched in the selected stream's output.
let string: String
}

@available(*, message: "This error will be deprecated soon, in favour of UserValidationError")
/// Error when legendary is signed out on a command that enforces signin.
struct NotSignedInError: Error { }

/// Installation error with message, see ``Legendary.install()``
struct InstallationError: Error {
let message: String

init(_ message: String) {
self.message = message
}
}

/// Whether legendary is currently modifying (installing, removing, moving) a game/service.
static var dataLockInUse: (value: Bool, inUse: DataLockUse) = (true, .installing) // temporarily

// Installing

struct Progress {
var percentage: Double
var downloaded: Int
var total: Int
var runtime: Substring
var eta: Substring
}

struct Download {
var downloaded: Double
var written: Double
}

struct Cache {
var usage: Double
var activeTasks: Int
}

struct DownloadAdvanced {
var raw: Double
var decompressed: Double
}

struct Disk {
var write: Double
var read: Double
}

/// Structure to define legendary's installing output status.
struct InstallStatus {
var progress: Progress?
var download: Download?
var cache: Cache?
var downloadAdvanced: DownloadAdvanced?
var disk: Disk?

init() {
self.progress = nil
self.download = nil
Expand All @@ -148,7 +148,7 @@ extension Legendary {
self.disk = nil
}
}

/// Class with information on if legendary is currently installing a game/service.
class Installing: ObservableObject {
// swiftlint:disable identifier_name
Expand All @@ -157,9 +157,9 @@ extension Legendary {
@Published var _game: Game?
@Published var _status: InstallStatus = InstallStatus()
// swiftlint:enable identifier_name

static var shared = Installing()

static var value: Bool {
get { return shared._value }
set {
Expand All @@ -168,7 +168,7 @@ extension Legendary {
}
}
}

static var finished: Bool {
get { return shared._finished }
set {
Expand All @@ -177,7 +177,7 @@ extension Legendary {
}
}
}

static var game: Game? {
get { return shared._game }
set {
Expand All @@ -186,7 +186,7 @@ extension Legendary {
}
}
}

static var installStatus: InstallStatus {
get { return shared._status }
set {
Expand All @@ -195,7 +195,7 @@ extension Legendary {
}
}
}

func reset() {
Legendary.dataLockInUse = (false, .none)
Installing.value = false
Expand Down
148 changes: 74 additions & 74 deletions Mythic/Controllers/Base/Legendary/Legendary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -381,81 +381,81 @@ class Legendary {
// Throwing an error directly to install() is preferable.
if let error = errorThrownExternally { Installing.shared.reset(); throw error }
}

/*
static func play(game: Game, bottle: WhiskyInterface.Bottle) async {
var environmentVariables: [String: String] = Dictionary()
environmentVariables["WINEPREFIX"] = "/Users/blackxfiied/Library/Containers/xyz.blackxfiied.Mythic/Bottles/Test" // in containers, libraries in applicaiton support
if let dxvkConfig = bottle.metadata["dxvkConfig"] as? [String: Any] {
if let dxvk = dxvkConfig["dxvk"] as? Bool {
print("dxvk: \(dxvk)")
}
if let dxvkAsync = dxvkConfig["dxvkAsync"] as? Bool {
print("dxvkAsync: \(dxvkAsync)")
}
if let dxvkHud = dxvkConfig["dxvkHud"] as? [String: Any] {
if let fps = dxvkHud["fps"] as? [String: Any] {
print("fps: \(fps)")
}
}
}
if let fileVersion = bottle.metadata["fileVersion"] as? [String: Any] {
if let major = fileVersion["major"] as? Int {
print("fileVersion major: \(major)")
}
if let minor = fileVersion["minor"] as? Int {
print("fileVersion minor: \(minor)")
}
}
if let metalConfig = bottle.metadata["metalConfig"] as? [String: Any] {
if let metalHud = metalConfig["metalHud"] as? Bool,
metalHud == true {
environmentVariables["MTL_HUD_ENABLED"] = "1"
}
if let metalTrace = metalConfig["metalTrace"] as? Bool {
print("metal trace: \(metalTrace)")
}
}
if let wineConfig = bottle.metadata["wineConfig"] as? [String: Any] {
if let msync = wineConfig["msync"] as? Bool,
msync == true {
environmentVariables["WINEMSYNC"] = "1"
}
if let windowsVersion = wineConfig["windowsVersion"] as? String {
print("windowsVersion: \(windowsVersion.trimmingPrefix("win"))")
}
if let wineVersion = wineConfig["wineVersion"] as? [String: Any] {
if let major = wineVersion["major"] as? Int {
print("wineVersion major: \(major)")
}
if let minor = wineVersion["minor"] as? Int {
print("wineVersion minor: \(minor)")
}
if let patch = wineVersion["patch"] as? Int {
print("wineVersion patch: \(patch)")
}
}
}
_ = await command(args: [
"launch",
game.appName,
"--wine",
"/Users/blackxfiied/Library/Application Support/com.isaacmarovitz.Whisky/Libraries/Wine/bin/wine64"
]
.compactMap { $0 },
useCache: false,
additionalEnvironmentVariables: environmentVariables
)
}
static func play(game: Game, bottle: WhiskyInterface.Bottle) async {
var environmentVariables: [String: String] = Dictionary()
environmentVariables["WINEPREFIX"] = "/Users/blackxfiied/Library/Containers/xyz.blackxfiied.Mythic/Bottles/Test" // in containers, libraries in applicaiton support

if let dxvkConfig = bottle.metadata["dxvkConfig"] as? [String: Any] {
if let dxvk = dxvkConfig["dxvk"] as? Bool {
print("dxvk: \(dxvk)")
}
if let dxvkAsync = dxvkConfig["dxvkAsync"] as? Bool {
print("dxvkAsync: \(dxvkAsync)")
}
if let dxvkHud = dxvkConfig["dxvkHud"] as? [String: Any] {
if let fps = dxvkHud["fps"] as? [String: Any] {
print("fps: \(fps)")
}
}
}

if let fileVersion = bottle.metadata["fileVersion"] as? [String: Any] {
if let major = fileVersion["major"] as? Int {
print("fileVersion major: \(major)")
}
if let minor = fileVersion["minor"] as? Int {
print("fileVersion minor: \(minor)")
}
}

if let metalConfig = bottle.metadata["metalConfig"] as? [String: Any] {
if let metalHud = metalConfig["metalHud"] as? Bool,
metalHud == true {
environmentVariables["MTL_HUD_ENABLED"] = "1"
}
if let metalTrace = metalConfig["metalTrace"] as? Bool {
print("metal trace: \(metalTrace)")
}
}

if let wineConfig = bottle.metadata["wineConfig"] as? [String: Any] {
if let msync = wineConfig["msync"] as? Bool,
msync == true {
environmentVariables["WINEMSYNC"] = "1"
}

if let windowsVersion = wineConfig["windowsVersion"] as? String {
print("windowsVersion: \(windowsVersion.trimmingPrefix("win"))")
}

if let wineVersion = wineConfig["wineVersion"] as? [String: Any] {
if let major = wineVersion["major"] as? Int {
print("wineVersion major: \(major)")
}
if let minor = wineVersion["minor"] as? Int {
print("wineVersion minor: \(minor)")
}
if let patch = wineVersion["patch"] as? Int {
print("wineVersion patch: \(patch)")
}
}
}

_ = await command(args: [
"launch",
game.appName,
"--wine",
"/Users/blackxfiied/Library/Application Support/com.isaacmarovitz.Whisky/Libraries/Wine/bin/wine64"
]
.compactMap { $0 },
useCache: false,
additionalEnvironmentVariables: environmentVariables
)
}
*/

/// Wipe legendary's command cache. This will slow most legendary commands until cache is rebuilt.
static func clearCommandCache() {
commandCache = Dictionary()
Expand Down Expand Up @@ -661,7 +661,7 @@ class Legendary {
}

/* // // // // // // // // // // // // // // // //
___ _ _ _ ___ ___ ___ _______ _ _ ___
___ _ _ _ ___ ___ ___ _______ _ _ ___
| \ /_\ | \| |/ __| __| _ \ |_ / _ \| \| | __|
| |) / _ \| .` | (_ | _|| / / / (_) | .` | _|
|___/_/ \_\_|\_|\___|___|_|_\ /___\___/|_|\_|___|
Expand Down
2 changes: 1 addition & 1 deletion Mythic/Controllers/Base/Local.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
import Foundation

class LocalGames {

}
Loading

0 comments on commit eca3f67

Please sign in to comment.