Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #25 from JK3Y/ui-add-boxart
Browse files Browse the repository at this point in the history
Add game artwork to sidebar
  • Loading branch information
JK3Y authored Aug 12, 2018
2 parents 8236d28 + 4990f5e commit 76d5a17
Show file tree
Hide file tree
Showing 45 changed files with 1,737 additions and 1,331 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
# Changelog

## 1.4.0
### Added
- **NOW COMPATIBLE WITH OS 10.10+**
- The side panel is now split horizontally, with the game artwork displayed on the bottom panel. Artwork is taken from Renascene

### Changed
- Database has been changed over from Core Data to Realm. This allows for the database to be Apple-independant and code can be used in future Android and Linux ports.
- Massive code refactoring, cleanup, and optimization

### Fixed
- "Game" label for download checkbox now changes to fileType (DLC, Theme, etc)
- Required FW is now properly formatted to the thousandths place if the FW is missing the second decimal place. Eg. 3.2 -> 3.20

## 1.3.7
### Added
- Downloads/extractions are separated into folders based on console type

### Changed
- Location label in the Preferences window has been changed to "Library Location"
- Removed Update Version column

### Fixed
- Bug where bookmarks weren't being updated properly causing the app to crash.
Expand Down
117 changes: 72 additions & 45 deletions NPS Browser.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

121 changes: 2 additions & 119 deletions NPS Browser/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,19 @@
import Cocoa
import Files
import SwiftyBeaver
import RealmSwift

let log = SwiftyBeaver.self

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDelegate {

lazy var downloadManager: DownloadManager = DownloadManager()
lazy var bookmarkManager: BookmarkManager = BookmarkManager()
lazy var coreDataIO: CoreDataIO = CoreDataIO()

func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
setupSwiftyBeaverLogging()
setupDownloadsDirectory()
populateMasterViewTable()
}

func applicationWillTerminate(_ aNotification: Notification) {
Expand All @@ -34,35 +32,22 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}

func setupSwiftyBeaverLogging() {
let console = ConsoleDestination()
let file = FileDestination()
let cloud = SBPlatformDestination(appID: "Rl12gv", appSecret: "bPi6vxoi2hV7mxnAtlriT3kBXbmofepc", encryptionKey: "qkiqm2IcjwgzuCcmu6itctXna2nxLztf")

log.addDestination(console)
log.addDestination(file)
log.addDestination(cloud)
}

func setupDownloadsDirectory() {
let dlFolder = SettingsManager().getDownloads().library_location
let dlDirName = "NPS Downloads"

try! Folder(path: dlFolder.path).createSubfolderIfNeeded(withName: dlDirName)
log.info("Downloads folder created at \(dlFolder.appendingPathComponent(dlDirName, isDirectory: true).path)")
}

func populateMasterViewTable() {
if (coreDataIO.recordsAreEmpty()) {
NetworkManager().makeHTTPRequest()
} else {
let content = coreDataIO.getRecords()
Helpers().getDataController().setArrayControllerContent(content: content)
}
}


// MARK: - Notifications

func showNotification(title: String, subtitle: String) {
Expand All @@ -79,107 +64,5 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
return true
}

// MARK: - Core Data stack

lazy var persistentContainer: NSPersistentContainer = {
/*
The persistent container for the application. This implementation
creates and returns a container, having loaded the store for the
application to it. This property is optional since there are legitimate
error conditions that could cause the creation of the store to fail.
*/
let container = NSPersistentContainer(name: "NPS_Browser")

container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.

/*
Typical reasons for an error here include:
* The parent directory does not exist, cannot be created, or disallows writing.
* The persistent store is not accessible, due to permissions or data protection when the device is locked.
* The device is out of space.
* The store could not be migrated to the current model version.
Check the error message to determine what the actual problem was.
*/
fatalError("Unresolved error \(error)")
}
})
return container
}()

// MARK: - Core Data Saving and Undo support

@IBAction func saveAction(_ sender: AnyObject?) {
// Performs the save action for the application, which is to send the save: message to the application's managed object context. Any encountered errors are presented to the user.
let context = persistentContainer.viewContext

context.mergePolicy = NSOverwriteMergePolicy

if !context.commitEditing() {
NSLog("\(NSStringFromClass(type(of: self))) unable to commit editing before saving")
}
if context.hasChanges {
do {
try context.save()
} catch {
// Customize this code block to include application-specific recovery steps.
let nserror = error as NSError
NSApplication.shared.presentError(nserror)

debugPrint(nserror)
}
}
}

func windowWillReturnUndoManager(window: NSWindow) -> UndoManager? {
// Returns the NSUndoManager for the application. In this case, the manager returned is that of the managed object context for the application.
return persistentContainer.viewContext.undoManager
}

func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
// Save changes in the application's managed object context before the application terminates.
let context = persistentContainer.viewContext

if !context.commitEditing() {
NSLog("\(NSStringFromClass(type(of: self))) unable to commit editing to terminate")
return .terminateCancel
}

if !context.hasChanges {
return .terminateNow
}

do {
try context.save()
} catch {
let nserror = error as NSError

// Customize this code block to include application-specific recovery steps.
let result = sender.presentError(nserror)
if (result) {
return .terminateCancel
}

let question = NSLocalizedString("Could not save changes while quitting. Quit anyway?", comment: "Quit without saves error question message")
let info = NSLocalizedString("Quitting now will lose any changes you have made since the last successful save", comment: "Quit without saves error question info");
let quitButton = NSLocalizedString("Quit anyway", comment: "Quit anyway button title")
let cancelButton = NSLocalizedString("Cancel", comment: "Cancel button title")
let alert = NSAlert()
alert.messageText = question
alert.informativeText = info
alert.addButton(withTitle: quitButton)
alert.addButton(withTitle: cancelButton)

let answer = alert.runModal()
if answer == .alertSecondButtonReturn {
return .terminateCancel
}
}
// If we got here, it is time to quit.
return .terminateNow
}

}

Loading

0 comments on commit 76d5a17

Please sign in to comment.