ProjectData_struct*ProjLoad_loadProjectDataFromSavedProject(const char* projectName) { String plistPath = savedProjectsFolder + '/' + projectName + "/project.plist"; void* plistDict = ProjLoad_loadAllocatedPlist(plistPath); if(plistDict==NULL) { showSimpleMessageBox("Error loading ProjectData", (String)"Problem occured loading project.plist from saved project " + projectName); return NULL; } ProjectData_struct*projData = ProjLoad_loadProjectDataFromNSDictionary(plistDict); if(projData==NULL) { id_release(plistDict); return NULL; } String settingsPath = savedProjectsFolder + '/' + projectName + "/settings.plist"; void* settingsPlist = ProjLoad_loadAllocatedPlist(settingsPath); if(settingsPlist!=NULL) { ProjectSettings_struct* projSettings = ProjLoad_loadProjectSettingsFromNSDictionary(settingsPlist); if(projSettings!=NULL) { ((ProjectData*)projData->data)->getProjectSettings() = *((ProjectSettings*)projSettings->data); String sdk = ProjectSettings_getSDK(projSettings); if(!Global_checkSDKFolderValid(sdk)) { ((ProjectData*)projData->data)->getProjectSettings().setSDK(GlobalPreferences_getDefaultSDK()); } } ProjectSettings_destroyInstance(projSettings); id_release(settingsPlist); } ProjectData_setFolderName(projData, projectName); FileTools::createDirectory(savedProjectsFolder+'/'+projectName+"/src"); FileTools::createDirectory(savedProjectsFolder+'/'+projectName+"/res"); FileTools::createDirectory(savedProjectsFolder+'/'+projectName+"/ext"); FileTools::createDirectory(savedProjectsFolder+'/'+projectName+"/bin"); FileTools::createDirectory(savedProjectsFolder+'/'+projectName+"/bin/build"); FileTools::createDirectory(savedProjectsFolder+'/'+projectName+"/bin/release"); String buildInfoPath = savedProjectsFolder + '/' + projectName + "/bin/build/buildinfo.plist"; void* buildInfoPlist = ProjLoad_loadAllocatedPlist(buildInfoPath); if(buildInfoPlist!=NULL) { ProjectBuildInfo_struct* projBuildInfo = ProjLoad_loadProjectBuildInfoFromNSDictionary(buildInfoPlist); if(projBuildInfo!=NULL) { ((ProjectData*)projData->data)->getProjectBuildInfo() = *((ProjectBuildInfo*)projBuildInfo->data); } ProjectBuildInfo_destroyInstance(projBuildInfo); id_release(buildInfoPlist); } id_release(plistDict); return projData; }
ProjectData_struct*ProjLoad_loadProjectDataFromTemplate(const char*category, const char*templateName, const char*templatesRoot) { String execPath = FileTools_getExecutableDirectory(); String templatePlistPath = /*execPath + "/Project Templates/"*/(String)templatesRoot + '/' + category + '/' + templateName + "/project.plist"; void* plistDict = ProjLoad_loadAllocatedPlist(templatePlistPath); if(plistDict==NULL) { showSimpleMessageBox("Error loading ProjectData", (String)"Problem occured loading project.plist in template " + templateName + " in category " + category + " in templates folder " + templatesRoot); return NULL; } ProjectData_struct*projData = ProjLoad_loadProjectDataFromNSDictionary(plistDict); if(projData==NULL) { id_release(plistDict); return NULL; } ProjectData_setFolderName(projData, templateName); id_release(plistDict); return projData; }
bool GlobalPreferences_save() { String settingsPath = (String)getenv("HOME") + "/Library/Preferences/" + bundleID + ".plist"; void*dict = ProjLoad_loadAllocatedPlist(settingsPath); if(dict==NULL) { dict = NSMutableDictionary_alloc_init(); } if(dict!=NULL) { void*sdk = NSString_stringWithUTF8String(defaultSDK); NSMutableDictionary_setObjectForKey(dict, sdk, "DefaultSDK"); void*editorFont = NSString_stringWithUTF8String(codeEditorFont); NSMutableDictionary_setObjectForKey(dict, editorFont, "EditorFont"); void*editorFontSize = NSNumber_numberWithInt((int)codeEditorFontSize); NSMutableDictionary_setObjectForKey(dict, editorFontSize, "EditorFontSize"); void*syntaxHighlighting = NSNumber_numberWithBool(syntaxHighlightingOn); NSMutableDictionary_setObjectForKey(dict, syntaxHighlighting, "SyntaxHighlighting"); void*installedAppsArray = NSMutableArray_alloc_init(); for(int i=0; i<installedApps.size(); i++) { void*appName = NSString_stringWithUTF8String(installedApps.get(i)); NSMutableArray_addObject(installedAppsArray, appName); } NSMutableDictionary_setObjectForKey(dict, installedAppsArray, "InstalledApps"); id_release(installedAppsArray); void*latestVersion = NSNumber_numberWithDouble(currentVersion); NSMutableDictionary_setObjectForKey(dict, latestVersion, "LatestVersion"); String settingsPath = (String)getenv("HOME") + "/Library/Preferences/" + bundleID + ".plist"; bool success = ProjLoad_savePlist(dict, settingsPath); id_release(dict); return success; } return false; }
bool GlobalPreferences_load() { String settingsPath = (String)getenv("HOME") + "/Library/Preferences/" + bundleID + ".plist"; void*dict = ProjLoad_loadAllocatedPlist(settingsPath); if(dict!=NULL) { void* sdk = NSDictionary_objectForKey(dict, "DefaultSDK"); if(sdk!=NULL) { defaultSDK = NSString_UTF8String(sdk); //make sure sdk is valid if(!Global_checkSDKFolderValid(defaultSDK)) { defaultSDK = ""; } } void* editorFont = NSDictionary_objectForKey(dict, "EditorFont"); if(editorFont!=NULL) { codeEditorFont = NSString_UTF8String(editorFont); //TODO check and make sure font is valid } void* editorFontSize = NSDictionary_objectForKey(dict, "EditorFontSize"); if(editorFontSize!=NULL) { codeEditorFontSize = NSNumber_intValue(editorFontSize); if(codeEditorFontSize < CODEEDITOR_MINFONTSIZE) { codeEditorFontSize = CODEEDITOR_MINFONTSIZE; } else if(codeEditorFontSize > CODEEDITOR_MAXFONTSIZE) { codeEditorFontSize = CODEEDITOR_MAXFONTSIZE; } } void* installedAppsArray = NSDictionary_objectForKey(dict, "InstalledApps"); if(installedAppsArray!=NULL) { installedApps.clear(); for(unsigned int i=0; i<NSArray_count(installedAppsArray); i++) { void*appName = NSArray_objectAtIndex(installedAppsArray, i); installedApps.add(NSString_UTF8String(appName)); } } bool resave = false; void* latestVersion = NSDictionary_objectForKey(dict, "LatestVersion"); if(latestVersion!=NULL) { double version = NSNumber_doubleValue(latestVersion); if(version!=currentVersion) { resave = true; showSimpleMessageBox("miniCode", versionMessage); } } else { resave = true; showSimpleMessageBox("miniCode", versionMessage); } id_release(dict); if(resave) { return GlobalPreferences_save(); } return true; } else { showSimpleMessageBox("miniCode", versionMessage); return GlobalPreferences_save(); } return false; }
void CompilerTools_fillInfoPlist(ProjectData_struct*project) { ProjectData& projData = *((ProjectData*)project->data); String path = ProjLoad_getSavedProjectsFolder(); path += (String)'/' + projData.getFolderName() + "/bin/release/"; ProjectType projType = projData.getProjectType(); if(projType == PROJECTTYPE_APPLICATION) { path += projData.getProductName() + ".app/Info.plist"; } else { return; } String fileContents; if(FileTools_fileExists(path)) { bool success = FileTools::loadFileIntoString(path, fileContents); if(!success) { return; } CompilerTools_fillProjectVarsInString(fileContents, projData); FileTools::writeStringToFile(path, fileContents); } void* infoPlist = ProjLoad_loadAllocatedPlist(path); if(infoPlist!=NULL) { //UIDeviceFamily void* uidevicefamily = NSMutableArray_alloc_init(); ProjectDevice projDevice = projData.getProjectDevice(); if(projDevice==DEVICE_IPHONE) { void* num = NSNumber_numberWithInt(1); NSMutableArray_addObject(uidevicefamily, num); } else if(projDevice==DEVICE_IPAD) { void* num = NSNumber_numberWithInt(2); NSMutableArray_addObject(uidevicefamily, num); } else if(projDevice==DEVICE_ALL) { void* num = NSNumber_numberWithInt(1); NSMutableArray_addObject(uidevicefamily, num); num = NSNumber_numberWithInt(2); NSMutableArray_addObject(uidevicefamily, num); } if(projDevice!=DEVICE_UNKNOWN) { NSMutableDictionary_setObjectForKey(infoPlist, uidevicefamily, "UIDeviceFamily"); } id_release(uidevicefamily); ProjLoad_savePlist(infoPlist, path); id_release(infoPlist); } }