2015-07-16 19:53:53 -04:00
|
|
|
//
|
|
|
|
// AppDelegate.swift
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 16/07/2015.
|
2018-05-13 15:19:52 -04:00
|
|
|
// Copyright 2015 Thomas Harte. All rights reserved.
|
2015-07-16 19:53:53 -04:00
|
|
|
//
|
|
|
|
|
|
|
|
import Cocoa
|
|
|
|
|
|
|
|
@NSApplicationMain
|
|
|
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
|
|
2021-04-19 20:55:25 -04:00
|
|
|
private var failedMetalCheck = false
|
|
|
|
func applicationDidFinishLaunching(_ notification: Notification) {
|
2019-08-04 21:34:30 -04:00
|
|
|
// Insert code here to initialize your application.
|
2015-07-16 19:53:53 -04:00
|
|
|
|
2021-04-19 20:55:25 -04:00
|
|
|
// Check for at least one Metal-capable GPU; this check
|
|
|
|
// will become unnecessary if/when the minimum OS version
|
|
|
|
// that this project supports reascends to 10.14.
|
|
|
|
if (MTLCopyAllDevices().count == 0) {
|
|
|
|
self.failedMetalCheck = true
|
|
|
|
|
|
|
|
let alert = NSAlert()
|
|
|
|
alert.messageText = "This application requires a Metal-capable GPU"
|
|
|
|
alert.addButton(withTitle: "Exit")
|
|
|
|
alert.runModal()
|
|
|
|
|
|
|
|
let application = notification.object as! NSApplication
|
|
|
|
application.terminate(self)
|
|
|
|
}
|
2015-07-16 19:53:53 -04:00
|
|
|
}
|
|
|
|
|
2019-09-22 13:59:31 -04:00
|
|
|
private var hasShownOpenDocument = false
|
2016-09-15 22:12:12 -04:00
|
|
|
func applicationShouldOpenUntitledFile(_ sender: NSApplication) -> Bool {
|
2019-09-21 18:01:16 -04:00
|
|
|
// Decline to show the 'New...' selector by default; the 'Open...'
|
|
|
|
// dialogue has already been shown if this application was started
|
|
|
|
// without a file.
|
2019-08-04 21:34:30 -04:00
|
|
|
//
|
|
|
|
// Obiter: I dislike it when other applications do this for me, but it
|
|
|
|
// seems to be the new norm, and I've had user feedback that showing
|
|
|
|
// nothing is confusing. So here it is.
|
2019-09-22 13:59:31 -04:00
|
|
|
if !hasShownOpenDocument {
|
|
|
|
NSDocumentController.shared.openDocument(self)
|
|
|
|
hasShownOpenDocument = true
|
|
|
|
}
|
2016-01-06 21:09:49 -05:00
|
|
|
return false
|
|
|
|
}
|
2015-07-16 19:53:53 -04:00
|
|
|
}
|