-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Josh <36625023+JoshuaBrest@users.noreply.github.com>
- Loading branch information
1 parent
22639be
commit 2abd633
Showing
22 changed files
with
1,613 additions
and
39 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// AppDelegate.swift | ||
// Mythic | ||
// | ||
// Created by Josh on 10/23/24. | ||
// | ||
|
||
import Foundation | ||
import AppKit | ||
|
||
public class AppDelegate: NSObject, NSApplicationDelegate { | ||
public static let shared = AppDelegate() | ||
|
||
private let logger = AppLogger(category: AppDelegate.self) | ||
|
||
private let setupWindowController = SetupWindowController() | ||
private let mainWindowController = MainWindowController() | ||
|
||
/// Show the setup window | ||
private func showSetupWindow() { | ||
setupWindowController.show() | ||
} | ||
|
||
/// Hide the setup window | ||
private func hideSetupWindow() { | ||
setupWindowController.hide() | ||
} | ||
|
||
/// Show the main window | ||
private func showMainWindow() { | ||
mainWindowController.show() | ||
} | ||
|
||
/// Hide the main window | ||
private func hideMainWindow() { | ||
mainWindowController.hide() | ||
} | ||
|
||
/// Set the onboarding state | ||
public func setOnboardingState(inOnboarding: Bool) { | ||
if inOnboarding { | ||
logger.info("Showing onboarding window...") | ||
showSetupWindow() | ||
hideMainWindow() | ||
} else { | ||
logger.info("Showing main window...") | ||
hideSetupWindow() | ||
showMainWindow() | ||
} | ||
} | ||
|
||
public func applicationDidFinishLaunching(_ notification: Notification) { | ||
NSApplication.shared.setActivationPolicy(.regular) | ||
|
||
// TODO: A lot of work... | ||
setOnboardingState(inOnboarding: true) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// | ||
// AppLogger.swift | ||
// Mythic | ||
// | ||
// Created by Josh on 10/23/24. | ||
// | ||
|
||
import Foundation | ||
import OSLog | ||
|
||
public struct AppLogger { | ||
static let subsystem = Bundle.main.bundleIdentifier ?? "Mythic" | ||
#if DEBUG | ||
static let logLevel = LogLevel.debug | ||
#else | ||
static let logLevel = LogLevel.info | ||
#endif | ||
|
||
enum LogLevel: Int { | ||
case debug = 0 | ||
case info = 1 | ||
case warning = 2 | ||
case error = 3 | ||
} | ||
|
||
#if !DEBUG | ||
private var logger: Logger | ||
#endif | ||
private var category: String | ||
|
||
/// The category should be Class.self | ||
public init(category: Any) { | ||
self.category = "\(category)" | ||
#if !DEBUG | ||
self.logger = Logger(subsystem: AppLogger.subsystem, category: String(describing: category)) | ||
#endif | ||
} | ||
|
||
#if DEBUG | ||
private func log(_ message: String, level: LogLevel) { | ||
if level.rawValue <= AppLogger.logLevel.rawValue { return } | ||
switch level { | ||
case .debug: | ||
print("\033[0;1;34m[🐞DEBUG \(self.category)]\033[0;34m \(message)") | ||
case .info: | ||
print("\033[0;1;32m[ℹ️INFO \(self.category)]\033[0;32m \(message)") | ||
case .warning: | ||
print("\033[0;1;33m[⚠️WARNING \(self.category)]\033[0;33m \(message)") | ||
case .error: | ||
print("\033[0;1;31m[🚨ERROR \(self.category)]\033[0;31m \(message)") | ||
} | ||
} | ||
#else | ||
private func log(_ message: String, level: LogLevel) { | ||
if level.rawValue < AppLogger.logLevel.rawValue { return } | ||
switch level { | ||
case .debug: | ||
logger.debug("\(message)") | ||
case .info: | ||
logger.info("\(message)") | ||
case .warning: | ||
logger.warning("\(message)") | ||
case .error: | ||
logger.error("\(message)") | ||
} | ||
} | ||
#endif | ||
|
||
public func debug(_ message: String) { | ||
log(message, level: .debug) | ||
} | ||
|
||
public func info(_ message: String) { | ||
log(message, level: .info) | ||
} | ||
|
||
public func warning(_ message: String) { | ||
log(message, level: .warning) | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// main.swift | ||
// Mythic | ||
// | ||
// Created by Josh on 10/23/24. | ||
// | ||
|
||
import Foundation | ||
import Cocoa | ||
|
||
let app = NSApplication.shared | ||
let delegate = AppDelegate() | ||
|
||
app.delegate = delegate | ||
|
||
_ = NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// main.swift | ||
// Mythic | ||
// | ||
// Created by Josh on 10/23/24. | ||
// | ||
|
||
import Foundation | ||
import Cocoa | ||
|
||
let app = NSApplication.shared | ||
let delegate = AppDelegate() | ||
|
||
app.delegate = delegate | ||
|
||
_ = NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv) |
Oops, something went wrong.