1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-20 20:23:03 +02:00
This commit is contained in:
Michał W. Urbańczyk 2013-02-04 23:12:43 +00:00
parent a9d458c8f4
commit 59abcac7da
2 changed files with 30 additions and 3 deletions

View File

@ -17,7 +17,6 @@
using namespace boost::filesystem; using namespace boost::filesystem;
#endif #endif
/// Where to find the various VCMI files. This is mostly useful for linux. /// Where to find the various VCMI files. This is mostly useful for linux.
class VCMIDirs { class VCMIDirs {
public: public:
@ -31,10 +30,21 @@ public:
try { try {
#ifdef ANDROID #ifdef ANDROID
UserPath = DATA_DIR; UserPath = DATA_DIR;
#elif defined(__APPLE__)
// This is Cocoa code that should be normally used to get path to Application Support folder but can't use it here for now...
// NSArray* urls = [[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask];
// UserPath = path([urls[0] path] + "/vcmi").string();
// ...so here goes a bit of hardcode instead
std::string home_dir = ".";
if (getenv("HOME") != NULL )
home_dir = getenv("HOME");
UserPath = path(home_dir + "/Library/Application Support/vcmi").string();
#else #else
// Find vcmi user directory and create it if necessary // Find vcmi user directory and create it if necessary
std::string home_dir = "."; std::string home_dir = ".";
if( getenv("HOME") != NULL ) if (getenv("HOME") != NULL )
home_dir = getenv("HOME"); home_dir = getenv("HOME");
UserPath = path(home_dir + "/.vcmi").string(); UserPath = path(home_dir + "/.vcmi").string();

View File

@ -7,6 +7,10 @@
installationCompleted = NO; installationCompleted = NO;
outputDir = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/../../Data"]; outputDir = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/../../Data"];
tempDir = NSTemporaryDirectory(); tempDir = NSTemporaryDirectory();
// Output to Application Support
//NSArray* appSupportDirs = [[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask];
//outputDir = [[appSupportDirs[0] path] stringByAppendingString:@"/vcmi"];
} }
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)sender - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)sender
@ -243,7 +247,20 @@
[self.installButton setTitle:@"Run VCMI"]; [self.installButton setTitle:@"Run VCMI"];
[self.progressIndicator stopAnimation:self]; [self.progressIndicator stopAnimation:self];
[NSApp requestUserAttention:NSCriticalRequest]; // Notify user that installation completed
NSUserNotification* notification = [[NSUserNotification alloc] init];
if (notification != nil) {
// On OS X 10.8 and newer use notification center
[notification setTitle:@"VCMI"];
[notification setInformativeText:@"Installation completed"];
[notification setDeliveryDate:[NSDate dateWithTimeInterval:0 sinceDate:[NSDate date]]];
[notification setSoundName:NSUserNotificationDefaultSoundName];
NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
[center scheduleNotification:notification];
} else {
// On older OS X version force dock icon to jump
[NSApp requestUserAttention:NSCriticalRequest];
}
// Hide all progress related controls // Hide all progress related controls
[self.progressIndicator setHidden:YES]; [self.progressIndicator setHidden:YES];