Преглед на файлове

another OS X patch from stopiccot

Ivan Savenko преди 13 години
родител
ревизия
e023b7d6bc

+ 3 - 1
CMakeLists.txt

@@ -17,7 +17,7 @@ option(DISABLE_ERM "Disable compilation of ERM scripting module" ON)
 
 if (APPLE)
 	# Default location for thirdparty libs
-	set(CMAKE_INCLUDE_PATH "../include ${CMAKE_OSX_SYSROOT}/usr/include")
+	set(CMAKE_INCLUDE_PATH "../include" "${CMAKE_OSX_SYSROOT}/usr/include")
 	set(CMAKE_LIBRARY_PATH "../lib")
 	set(CMAKE_FRAMEWORK_PATH "../Frameworks")
 	set(BOOST_ROOT "../")
@@ -155,6 +155,8 @@ if(WIN32)
 	set(CPACK_GENERATOR ZIP) # just use zip? CPack has some GUI install as well
 elseif(APPLE)
 	set(CPACK_GENERATOR DragNDrop)
+	set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/osx/dmg_background.png")
+	set(CPACK_DMG_DS_STORE "${CMAKE_SOURCE_DIR}/osx/dmg_DS_Store")
 else()
 	set(CPACK_GENERATOR TGZ)
 endif()

+ 1 - 0
client/CMakeLists.txt

@@ -67,6 +67,7 @@ elseif(APPLE)
         cp ${CMAKE_HOME_DIRECTORY}/bin/$(CONFIGURATION)/libStupidAI.dylib ${BUNDLE_PATH}/MacOS/AI/libStupidAI.dylib &&
         cp ${CMAKE_HOME_DIRECTORY}/bin/$(CONFIGURATION)/libEmptyAI.dylib ${BUNDLE_PATH}/MacOS/AI/libEmptyAI.dylib &&
         cp ${CMAKE_HOME_DIRECTORY}/bin/$(CONFIGURATION)/libBattleAI.dylib ${BUNDLE_PATH}/MacOS/AI/libBattleAI.dylib &&
+        cp -r ${CMAKE_HOME_DIRECTORY}/osx/vcmibuilder.app ${BUNDLE_PATH}/MacOS/vcmibuilder.app &&
 
         # Copy frameworks
         cp -r ${CMAKE_HOME_DIRECTORY}/${CMAKE_FRAMEWORK_PATH} ${BUNDLE_PATH}/Frameworks &&

BIN
osx-vcmibuilder/innoextract


BIN
osx/dmg_DS_Store


BIN
osx/dmg_background.png


BIN
osx/dmg_background.psd


BIN
osx/osx-vcmibuilder/innoextract


+ 0 - 0
osx-vcmibuilder/unshield → osx/osx-vcmibuilder/unshield


+ 0 - 0
osx-vcmibuilder/vcmibuilder.icns → osx/osx-vcmibuilder/vcmibuilder.icns


+ 0 - 0
osx-vcmibuilder/vcmibuilder.xcodeproj/project.pbxproj → osx/osx-vcmibuilder/vcmibuilder.xcodeproj/project.pbxproj


+ 4 - 0
osx-vcmibuilder/vcmibuilder/AppDelegate.h → osx/osx-vcmibuilder/vcmibuilder/AppDelegate.h

@@ -5,6 +5,8 @@
     NSString* outputDir;
     NSString* tempDir;
     NSString* dataDir;
+    NSString* currentArchiveName;
+    NSString* currentArchiveFilename;
     
     NSMutableArray* actions;
     
@@ -38,6 +40,8 @@
 
 - (void)downloadWogArchive;
 - (void)unzipWogArchive;
+- (void)downloadVcmiArchive;
+- (void)unzipVcmiArchive;
 - (void)extractGameData;
 - (void)innoexctract;
 - (NSString*)attachDiskImage:(NSString*)path;

+ 41 - 12
osx-vcmibuilder/vcmibuilder/AppDelegate.m → osx/osx-vcmibuilder/vcmibuilder/AppDelegate.m

@@ -23,37 +23,39 @@
 - (void)download:(NSURLDownload*)download didReceiveDataOfLength:(NSUInteger)length
 {
     self->bytesRecieved += length;
-    [self showProgressText:[NSString stringWithFormat:@"Downloading WoG archive: %3.1f Mb / %3.1f Mb",
+    [self showProgressText:[NSString stringWithFormat:@"Downloading %@ archive: %3.1f Mb / %3.1f Mb", self->currentArchiveName,
                             self->bytesRecieved / 1024.0f / 1024.0f, self->bytesExpected / 1024.0f / 1024.0f]];
 }
 
 - (void)download:(NSURLDownload*)download decideDestinationWithSuggestedFilename:(NSString*)filename
 {
-    [download setDestination:[tempDir stringByAppendingString:@"/wog.zip"] allowOverwrite:YES];
+    [download setDestination:[tempDir stringByAppendingString:currentArchiveFilename] allowOverwrite:YES];
 }
 
 - (void)downloadDidFinish:(NSURLDownload*)download
 {
-    [self showProgressText:@"Downloading WoG archive: completed"];
+    [self showProgressText:[NSString stringWithFormat:@"Downloading %@ archive: completed", self->currentArchiveName]];
     [self nextAction];
 }
 
 - (void)download:(NSURLDownload*)download didFailWithError:(NSError*)error
 {
-    [self showProgressText:@"Downloading WoG archive: failed"];
+    [self showProgressText:[NSString stringWithFormat:@"Downloading %@ archive: failed", self->currentArchiveName]];
     [self showErrorText:[error localizedDescription]];
 }
 
 - (void)nextAction
 {
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-        SEL sel = NSSelectorFromString(actions[0]);
-        [actions removeObjectAtIndex:0];
-        @try {
-            [self performSelector:sel];
-        }
-        @catch (NSException* e) {
-            [self showErrorText:[e name]];
+        if ([actions count] > 0) {
+            SEL sel = NSSelectorFromString(actions[0]);
+            [actions removeObjectAtIndex:0];
+            @try {
+                [self performSelector:sel];
+            }
+            @catch (NSException* e) {
+                [self showErrorText:[e name]];
+            }
         }
     });
 }
@@ -100,6 +102,8 @@
     // First of all we need to download WoG archive
     // Downloading should be done on main thread because of callbacks
     dispatch_async(dispatch_get_main_queue(), ^{
+        self->currentArchiveName = @"WoG";
+        self->currentArchiveFilename = @"/wog.zip";
         NSURL* url = [NSURL URLWithString:@"http://download.vcmi.eu/WoG/wog.zip"];
         self.download = [[NSURLDownload alloc] initWithRequest:[NSURLRequest requestWithURL:url] delegate:self];
     });
@@ -109,13 +113,36 @@
 {
     // Then we unzip downloaded WoG archive
     [self showProgressText:@"Unzipping WoG archive"];
-    if ([self runTask:@"/usr/bin/unzip" withArgs:@[@"-qo", [tempDir stringByAppendingString:@"/wog.zip"], @"-d", outputDir] withWorkingDir:nil withPipe:nil] != 0) {
+    if ([self runTask:@"/usr/bin/unzip" withArgs:@[@"-qo", [tempDir stringByAppendingString:currentArchiveFilename], @"-d", outputDir] withWorkingDir:nil withPipe:nil] != 0) {
         return [self showErrorText:@"Failed to unzip WoG archive"];
     }
     
     [self nextAction];
 }
 
+- (void)downloadVcmiArchive
+{
+    // Than we need to download VCMI archive
+    // Downloading should be done on main thread because of callbacks
+    dispatch_async(dispatch_get_main_queue(), ^{
+        self->currentArchiveName = @"VCMI";
+        self->currentArchiveFilename = @"/core.zip";
+        NSURL* url = [NSURL URLWithString:@"http://download.vcmi.eu/core.zip"];
+        self.download = [[NSURLDownload alloc] initWithRequest:[NSURLRequest requestWithURL:url] delegate:self];
+    });
+}
+
+- (void)unzipVcmiArchive
+{
+    // Then we unzip downloaded VCMI archive
+    [self showProgressText:@"Unzipping VCMI archive"];
+    if ([self runTask:@"/usr/bin/unzip" withArgs:@[@"-qo", [tempDir stringByAppendingString:currentArchiveFilename], @"-d", outputDir, @"-x", @"*.json", @"*.txt", @"*.PAL"] withWorkingDir:nil withPipe:nil] != 0) {
+        return [self showErrorText:@"Failed to unzip VCMI archive"];
+    }
+    
+    [self nextAction];
+}
+
 - (void)extractGameData
 {
     // Then we extract game data from provided iso files using unshield or from innosetup exe
@@ -266,6 +293,8 @@
             @"validateAction",
             @"downloadWogArchive",
             @"unzipWogArchive",
+            @"downloadVcmiArchive",
+            @"unzipVcmiArchive",
             @"extractGameData",
             @"extractionCompleted",
             nil

+ 0 - 0
osx-vcmibuilder/vcmibuilder/en.lproj/InfoPlist.strings → osx/osx-vcmibuilder/vcmibuilder/en.lproj/InfoPlist.strings


+ 0 - 0
osx-vcmibuilder/vcmibuilder/en.lproj/MainMenu.xib → osx/osx-vcmibuilder/vcmibuilder/en.lproj/MainMenu.xib


+ 0 - 0
osx-vcmibuilder/vcmibuilder/main.m → osx/osx-vcmibuilder/vcmibuilder/main.m


+ 0 - 0
osx-vcmibuilder/vcmibuilder/vcmibuilder-Info.plist → osx/osx-vcmibuilder/vcmibuilder/vcmibuilder-Info.plist


+ 0 - 0
osx-vcmibuilder/vcmibuilder/vcmibuilder-Prefix.pch → osx/osx-vcmibuilder/vcmibuilder/vcmibuilder-Prefix.pch