public Dictionary <string, FileOutput> Export() { this.replacements = new Dictionary <string, string>() { { "PROJECT_NAME", this.projectId }, { "TITLE", this.originalProjectId }, }; Dictionary <string, FileOutput> output = new Dictionary <string, FileOutput>(); SystemBitmap crayonIcon = new SystemBitmap(typeof(Util).Assembly, "icons/crayon_logo.png"); Dictionary <int, SystemBitmap> icons = new IconSetGenerator() .AddOutputSize(32) .AddOutputSize(256) .GenerateWithDefaultFallback(); output["assets/icon32.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = icons[32] }; output["assets/icon256.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = icons[256] }; System.Reflection.Assembly thisAsm = typeof(Program).Assembly; foreach (string file in new string[] { "DefaultProject/BuildFile.txt|%%%PROJECT_NAME%%%.build", "DefaultProject/main.txt|source/main.cry", "DefaultProject/dotGitIgnore.txt|output/.gitignore", }) { string[] parts = file.Split('|'); string content = Util.ReadAssemblyFileText(typeof(Program).Assembly, parts[0]); content = this.ReplaceStrings(content); string outputPath = this.ReplaceStrings(parts[1]); output[outputPath] = new FileOutput() { Type = FileOutputType.Text, TextContent = content, }; } Util.ReadAssemblyFileText(thisAsm, "DefaultProject/BuildFile.txt"); return(output); }
public Dictionary <string, FileOutput> Export() { this.replacements = new Dictionary <string, string>() { { "PROJECT_ID", this.projectId }, { "TITLE", this.originalProjectId }, { "COMPILER_LOCALE", this.projectLocale.ID.ToLowerInvariant() } }; Dictionary <string, FileOutput> output = new Dictionary <string, FileOutput>(); Dictionary <int, Bitmap> icons = new IconSetGenerator() .AddOutputSize(32) .AddOutputSize(256) .GenerateWithDefaultFallback(); output["assets/icon32.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = icons[32] }; output["assets/icon256.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = icons[256] }; foreach (string file in new string[] { "DefaultProject/BuildFile.txt|%%%PROJECT_ID%%%.build", "DefaultProject/main" + this.projectLocale.ID.ToUpperInvariant() + ".txt|source/main.cry", "DefaultProject/dotGitIgnore.txt|output/.gitignore", }) { string[] parts = file.Split('|'); string content = new ResourceStore(typeof(DefaultProjectGenerator)).ReadAssemblyFileText(parts[0]); content = this.ReplaceStrings(content); string outputPath = this.ReplaceStrings(parts[1]); output[outputPath] = new FileOutput() { Type = FileOutputType.Text, TextContent = content, }; } // TODO: why is this here? Isn't this dead code? new ResourceStore(typeof(DefaultProjectGenerator)).ReadAssemblyFileText("DefaultProject/BuildFile.txt"); return(output); }
public void OutputAndroidBoilerplate(Dictionary <string, FileOutput> output, Dictionary <string, string> replacements, Options options) { string packagedDir = replacements["JAVA_PACKAGE"].Replace('.', '/'); output[".gitignore"] = this.LoadTextFile("Resources/gitignore.txt", replacements); output["build.gradle"] = this.LoadTextFile("Resources/buildGradle.txt", replacements); output["android.iml"] = this.LoadTextFile("Resources/androidIml.txt", replacements); output["gradle.properties"] = this.LoadTextFile("Resources/gradleProperties.txt", replacements); output["gradlew"] = this.LoadTextFile("Resources/gradlew.txt", replacements); output["gradlew.bat"] = this.LoadTextFile("Resources/gradlewBat.txt", replacements); output["local.properties"] = this.LoadTextFile("Resources/localProperties.txt", replacements); output["settings.gradle"] = this.LoadTextFile("Resources/settingsGradle.txt", replacements); output["gradle/wrapper/gradle-wrapper.jar"] = this.LoadBinaryFile("Resources/gradle/wrapper/GradleWrapper.jar"); output["gradle/wrapper/gradle-wrapper.properties"] = this.LoadTextFile("Resources/gradle/wrapper/GradleWrapperProperties.txt", replacements); output[".idea/.name"] = this.LoadTextFile("Resources/idea/name.txt", replacements); output[".idea/compiler.xml"] = this.LoadTextFile("Resources/idea/compilerXml.txt", replacements); output[".idea/encodings.xml"] = this.LoadTextFile("Resources/idea/encodingsXml.txt", replacements); output[".idea/gradle.xml"] = this.LoadTextFile("Resources/idea/gradleXml.txt", replacements); output[".idea/misc.xml"] = this.LoadTextFile("Resources/idea/miscXml.txt", replacements); output[".idea/modules.xml"] = this.LoadTextFile("Resources/idea/modulesXml.txt", replacements); output[".idea/vcs.xml"] = this.LoadTextFile("Resources/idea/vcsXml.txt", replacements); output[".idea/copyright/profiles_settings.xml"] = this.LoadTextFile("Resources/idea/copyright/profileSettings.txt", replacements); output[".idea/scopes/scope_settings.xml"] = this.LoadTextFile("Resources/idea/scopes/scopeSettings.txt", replacements); if (!options.GetBool(ExportOptionKey.ANDROID_SKIP_WORKSPACE_XML)) { output[".idea/workspace.xml"] = this.LoadTextFile("Resources/idea/workspaceXml.txt", replacements); } output["app/.gitignore"] = this.LoadTextFile("Resources/app/gitignore.txt", replacements); output["app/app.iml"] = this.LoadTextFile("Resources/app/appIml.txt", replacements); output["app/build.gradle"] = this.LoadTextFile("Resources/app/buildGradle.txt", replacements); output["app/proguard-rules.txt"] = this.LoadTextFile("Resources/app/proguardRules.txt", replacements); output["app/src/main/java/" + packagedDir + "/app/MainActivity.java"] = this.LoadTextFile("Resources/app/src/main/java/org/crayonlang/sampleapp/app/MainActivityJava.txt", replacements); output["app/src/main/res/layout/activity_main.xml"] = this.LoadTextFile("Resources/app/src/main/res/layout/ActivityMainXml.txt", replacements); output["app/src/main/res/menu/main.xml"] = this.LoadTextFile("Resources/app/src/main/res/menu/MainXml.txt", replacements); output["app/src/main/res/values/dimens.xml"] = this.LoadTextFile("Resources/app/src/main/res/values/DimensXml.txt", replacements); output["app/src/main/res/values/strings.xml"] = this.LoadTextFile("Resources/app/src/main/res/values/StringsXml.txt", replacements); output["app/src/main/res/values/styles.xml"] = this.LoadTextFile("Resources/app/src/main/res/values/StylesXml.txt", replacements); output["app/src/main/res/values-w820dp/dimens.xml"] = this.LoadTextFile("Resources/app/src/main/res/valuesW820dp/DimensXml.txt", replacements); FileOutput androidManifest = this.LoadTextFile("Resources/app/src/main/AndroidManifestXml.txt", replacements); output["app/src/main/AndroidManifest.xml"] = androidManifest; androidManifest.TextContent = this.AdjustAndroidManifest(androidManifest.TextContent, options); IconSetGenerator icons = new IconSetGenerator(); if (options.GetBool(ExportOptionKey.HAS_ICON)) { string iconPath = options.GetString(ExportOptionKey.ICON_PATH); SystemBitmap icon = new SystemBitmap(iconPath); icons.AddInputImage(icon); } Dictionary <int, SystemBitmap> iconImagesBySize = icons .AddOutputSize(48) .AddOutputSize(72) .AddOutputSize(96) .AddOutputSize(144) .AddOutputSize(512) .GenerateWithDefaultFallback(); output["app/src/main/res/drawable-mdpi/ic_launcher.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[48] }; output["app/src/main/res/drawable-hdpi/ic_launcher.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[72] }; output["app/src/main/res/drawable-xhdpi/ic_launcher.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[96] }; output["app/src/main/res/drawable-xxhdpi/ic_launcher.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[144] }; output["app/src/main/ic_launcher-web.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[512] }; }
public override void ExportProject( Dictionary <string, FileOutput> output, IList <LibraryForExport> libraries, ResourceDatabase resourceDatabase, Options options) { options.SetOption(ExportOptionKey.JS_FILE_PREFIX, null); options.SetOption(ExportOptionKey.JS_FULL_PAGE, false); // iOS export has its own enforced fullscreen logic options.SetOption(ExportOptionKey.JS_HEAD_EXTRAS, ""); Dictionary <string, string> replacements = this.GenerateReplacementDictionary(options, resourceDatabase); Dictionary <string, FileOutput> files = new Dictionary <string, FileOutput>(); Dictionary <string, FileOutput> basicProject = new Dictionary <string, FileOutput>(); this.ParentPlatform.ExportProject( basicProject, libraries, resourceDatabase, options); // TODO: not good. The library inclusions should automatically be populated in LangJavaScript platforms. // This is also done identically in the ChromeApp PlatformImpl. replacements["JS_LIB_INCLUSIONS"] = JavaScriptApp.PlatformImpl.GenerateJsLibInclusionHtml(basicProject.Keys); foreach (string filePath in basicProject.Keys) { files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/" + filePath] = basicProject[filePath]; } // TODO: use this in the pbxproj file. string uuidSeed = options.GetStringOrNull(ExportOptionKey.GUID_SEED); OrientationParser orientations = new OrientationParser(options); bool useLandscapeForLaunchscreen = orientations.SupportsLandscapeLeft || orientations.SupportsLandscapeRight; FileOutput launchScreen; if (options.GetBool(ExportOptionKey.HAS_LAUNCHSCREEN)) { launchScreen = new FileOutput() { Type = FileOutputType.Image, Bitmap = new Bitmap(options.GetString(ExportOptionKey.LAUNCHSCREEN_PATH)), }; } else { string resourcePath = "SwiftResources/" + (useLandscapeForLaunchscreen ? "launchhorizontal.png" : "launchvertical.png"); byte[] bytes = new ResourceStore(typeof(JavaScriptAppIos.PlatformImpl)).ReadAssemblyFileBytes(resourcePath); launchScreen = new FileOutput() { Type = FileOutputType.Image, Bitmap = new Bitmap(bytes), }; } files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/Launchscreen.imageset/launchscreen.png"] = launchScreen; replacements["LAUNCH_SCREEN_WIDTH"] = launchScreen.Bitmap.Width.ToString(); replacements["LAUNCH_SCREEN_HEIGHT"] = launchScreen.Bitmap.Height.ToString(); IconSetGenerator icons = new IconSetGenerator(); if (options.GetBool(ExportOptionKey.HAS_ICON)) { string[] iconPaths = options.GetStringArray(ExportOptionKey.ICON_PATH); foreach (string iconPath in iconPaths) { Bitmap icon = new Bitmap(iconPath); icons.AddInputImage(icon); } } Dictionary <int, Bitmap> iconImagesBySize = icons .AddOutputSize(20 * 1) .AddOutputSize(20 * 2) .AddOutputSize(20 * 3) .AddOutputSize(29 * 1) .AddOutputSize(29 * 2) .AddOutputSize(29 * 3) .AddOutputSize(40 * 1) .AddOutputSize(40 * 2) .AddOutputSize(40 * 3) .AddOutputSize(60 * 2) .AddOutputSize(60 * 3) .AddOutputSize(76 * 1) .AddOutputSize(76 * 2) .AddOutputSize(167) // 83.5 * 2 .AddOutputSize(1024) .GenerateWithDefaultFallback(); foreach (int size in iconImagesBySize.Keys) { files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/AppIcon.appiconset/icon" + size + ".png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[size], }; } foreach (string pair in new string[] { "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%.xcodeproj/project.pbxproj|SwiftResources/PbxProj.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/AppDelegate.swift|SwiftResources/AppDelegateSwift.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/AppIcon.appiconset/Contents.json|SwiftResources/IconSetContentJson.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/Launchscreen.imageset/Contents.json|SwiftResources/ImageSetContentJson.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Base.lproj/LaunchScreen.storyboard|SwiftResources/LaunchScreenStoryboard.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Base.lproj/Main.storyboard|SwiftResources/MainStoryboard.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Info.plist|SwiftResources/InfoPlist.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/ViewController.swift|SwiftResources/ViewControllerSwift.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/ios.js|SwiftResources/iOSjs.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/index.html|SwiftResources/HostHtml.txt", }) { string[] parts = pair.Split('|'); files[parts[0]] = new FileOutput() { TrimBomIfPresent = true, Type = FileOutputType.Text, TextContent = this.LoadTextResource(parts[1], replacements), }; } foreach (string filename in files.Keys) { output[this.ApplyReplacements(filename, replacements)] = files[filename]; } }
public override void ExportProject( Dictionary <string, FileOutput> output, IList <VariableDeclaration> globals, IList <StructDefinition> structDefinitions, IList <FunctionDefinition> functionDefinitions, IList <LibraryForExport> libraries, ResourceDatabase resourceDatabase, Options options, ILibraryNativeInvocationTranslatorProvider libraryNativeInvocationTranslatorProviderForPlatform) { options.SetOption(ExportOptionKey.JS_FILE_PREFIX, null); options.SetOption(ExportOptionKey.JS_FULL_PAGE, false); // iOS export has its own enforced fullscreen logic options.SetOption(ExportOptionKey.JS_HEAD_EXTRAS, string.Join( "\n", "<script type=\"text/javascript\" src=\"ios.js\"></script>", "<style type=\"text/css\">", " body { margin:0px; background-color:#000; }", " #crayon_host {", " background-color:#000;", " text-align:left;", " width:100%;", " height:100%;", " }", "</style>" )); Dictionary <string, string> replacements = this.GenerateReplacementDictionary(options, resourceDatabase); Dictionary <string, FileOutput> files = new Dictionary <string, FileOutput>(); Dictionary <string, FileOutput> basicProject = new Dictionary <string, FileOutput>(); this.ParentPlatform.ExportProject( basicProject, globals, structDefinitions, functionDefinitions, libraries, resourceDatabase, options, libraryNativeInvocationTranslatorProviderForPlatform); // TODO: not good. The library inclusions should automatically be populated in LangJavaScript platforms. // This is also done identically in the ChromeApp PlatformImpl. replacements["JS_LIB_INCLUSIONS"] = JavaScriptApp.PlatformImpl.GenerateJsLibInclusionHtml(basicProject.Keys); foreach (string filePath in basicProject.Keys) { files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/" + filePath] = basicProject[filePath]; } // TODO: use this in the pbxproj file. string uuidSeed = options.GetStringOrNull(ExportOptionKey.GUID_SEED); OrientationParser orientations = new OrientationParser(options); bool useLandscapeForLaunchscreen = orientations.SupportsLandscapeLeft || orientations.SupportsLandscapeRight; FileOutput launchScreen; if (options.GetBool(ExportOptionKey.HAS_LAUNCHSCREEN)) { launchScreen = new FileOutput() { Type = FileOutputType.Image, Bitmap = new SystemBitmap(options.GetString(ExportOptionKey.LAUNCHSCREEN_PATH)), }; } else { launchScreen = new FileOutput() { Type = FileOutputType.Image, Bitmap = new SystemBitmap(typeof(JavaScriptAppIosTranslator).Assembly, "SwiftResources/" + (useLandscapeForLaunchscreen ? "launchhorizontal.png" : "launchvertical.png")), }; } files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/Launchscreen.imageset/launchscreen.png"] = launchScreen; replacements["LAUNCH_SCREEN_WIDTH"] = launchScreen.Bitmap.Width.ToString(); replacements["LAUNCH_SCREEN_HEIGHT"] = launchScreen.Bitmap.Height.ToString(); IconSetGenerator icons = new IconSetGenerator(); if (options.GetBool(ExportOptionKey.HAS_ICON)) { string iconPath = options.GetString(ExportOptionKey.ICON_PATH); SystemBitmap icon = new SystemBitmap(iconPath); icons.AddInputImage(icon); } Dictionary <int, SystemBitmap> iconImagesBySize = icons .AddOutputSize(20 * 1) .AddOutputSize(20 * 2) .AddOutputSize(20 * 3) .AddOutputSize(29 * 1) .AddOutputSize(29 * 2) .AddOutputSize(29 * 3) .AddOutputSize(40 * 1) .AddOutputSize(40 * 2) .AddOutputSize(40 * 3) .AddOutputSize(60 * 2) .AddOutputSize(60 * 3) .AddOutputSize(76 * 1) .AddOutputSize(76 * 2) .AddOutputSize(167) // 83.5 * 2 .GenerateWithDefaultFallback(); foreach (int size in iconImagesBySize.Keys) { files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/AppIcon.appiconset/icon" + size + ".png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[size], }; } foreach (string pair in new string[] { "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%.xcodeproj/project.pbxproj|SwiftResources/PbxProj.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/AppDelegate.swift|SwiftResources/AppDelegateSwift.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/AppIcon.appiconset/Contents.json|SwiftResources/IconSetContentJson.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/Launchscreen.imageset/Contents.json|SwiftResources/ImageSetContentJson.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Base.lproj/LaunchScreen.storyboard|SwiftResources/LaunchScreenStoryboard.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Base.lproj/Main.storyboard|SwiftResources/MainStoryboard.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Info.plist|SwiftResources/InfoPlist.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/ViewController.swift|SwiftResources/ViewControllerSwift.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/ios.js|SwiftResources/iOSjs.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/index.html|SwiftResources/HostHtml.txt", }) { string[] parts = pair.Split('|'); files[parts[0]] = new FileOutput() { TrimBomIfPresent = true, Type = FileOutputType.Text, TextContent = this.LoadTextResource(parts[1], replacements), }; } foreach (string filename in files.Keys) { output[this.ApplyReplacements(filename, replacements)] = files[filename]; } }
public override void ExportProject( Dictionary<string, FileOutput> output, BuildData buildData, ExportProperties exportProperties) { exportProperties.JsFilePrefix = null; exportProperties.JsFullPage = false; // iOS export has its own enforced fullscreen logic exportProperties.JsHeadExtras = ""; Dictionary<string, string> replacements = this.GenerateReplacementDictionary(exportProperties, buildData); Dictionary<string, FileOutput> files = new Dictionary<string, FileOutput>(); Dictionary<string, FileOutput> basicProject = new Dictionary<string, FileOutput>(); this.ParentPlatform.ExportProject( basicProject, buildData, exportProperties); foreach (string filePath in basicProject.Keys) { files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/" + filePath] = basicProject[filePath]; } // TODO: use this in the pbxproj file. string uuidSeed = exportProperties.GuidSeed; Orientations orientations = exportProperties.Orientations; bool useLandscapeForLaunchscreen = orientations.SupportsLandscapeLeft || orientations.SupportsLandscapeRight; FileOutput launchScreen; if (exportProperties.HasLaunchScreen) { launchScreen = new FileOutput() { Type = FileOutputType.Image, Bitmap = new Bitmap(exportProperties.LaunchScreenPath), }; } else { string resourcePath = "SwiftResources/" + (useLandscapeForLaunchscreen ? "launchhorizontal.png" : "launchvertical.png"); byte[] bytes = new ResourceStore(typeof(JavaScriptAppIos.PlatformImpl)).ReadAssemblyFileBytes(resourcePath); launchScreen = new FileOutput() { Type = FileOutputType.Image, Bitmap = new Bitmap(bytes), }; } files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/Launchscreen.imageset/launchscreen.png"] = launchScreen; replacements["LAUNCH_SCREEN_WIDTH"] = launchScreen.Bitmap.Width.ToString(); replacements["LAUNCH_SCREEN_HEIGHT"] = launchScreen.Bitmap.Height.ToString(); IconSetGenerator icons = new IconSetGenerator(); if (exportProperties.HasIcon) { foreach (string iconPath in exportProperties.IconPaths) { Bitmap icon = new Bitmap(iconPath); icons.AddInputImage(icon); } } Dictionary<int, Bitmap> iconImagesBySize = icons .AddOutputSize(20 * 1) .AddOutputSize(20 * 2) .AddOutputSize(20 * 3) .AddOutputSize(29 * 1) .AddOutputSize(29 * 2) .AddOutputSize(29 * 3) .AddOutputSize(40 * 1) .AddOutputSize(40 * 2) .AddOutputSize(40 * 3) .AddOutputSize(60 * 2) .AddOutputSize(60 * 3) .AddOutputSize(76 * 1) .AddOutputSize(76 * 2) .AddOutputSize(167) // 83.5 * 2 .AddOutputSize(1024) .GenerateWithDefaultFallback(); foreach (int size in iconImagesBySize.Keys) { files["%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/AppIcon.appiconset/icon" + size + ".png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[size], }; } foreach (string pair in new string[] { "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%.xcodeproj/project.pbxproj|SwiftResources/PbxProj.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/AppDelegate.swift|SwiftResources/AppDelegateSwift.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/AppIcon.appiconset/Contents.json|SwiftResources/IconSetContentJson.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Assets.xcassets/Launchscreen.imageset/Contents.json|SwiftResources/ImageSetContentJson.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Base.lproj/LaunchScreen.storyboard|SwiftResources/LaunchScreenStoryboard.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Base.lproj/Main.storyboard|SwiftResources/MainStoryboard.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/Info.plist|SwiftResources/InfoPlist.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/ViewController.swift|SwiftResources/ViewControllerSwift.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/ios.js|SwiftResources/iOSjs.txt", "%%%PROJECT_ID%%%/%%%PROJECT_ID%%%/jsres/index.html|SwiftResources/HostHtml.txt", }) { string[] parts = pair.Split('|'); files[parts[0]] = new FileOutput() { TrimBomIfPresent = true, Type = FileOutputType.Text, TextContent = this.LoadTextResource(parts[1], replacements), }; } foreach (string filename in files.Keys) { output[this.ApplyReplacements(filename, replacements)] = files[filename]; } }
public void OutputAndroidBoilerplate(Dictionary <string, FileOutput> output, Dictionary <string, string> replacements, ExportProperties exportProperties) { string androidSdkLocation = exportProperties.AndroidSdkLocation; replacements["ANDROID_SDK_LOCATION"] = this.EscapeAndroidSdkPath(androidSdkLocation); string packagedDir = replacements["JAVA_PACKAGE"].Replace('.', '/'); output[".gitignore"] = this.LoadTextFile("JsAndroidResources/gitignore.txt", replacements); output["build.gradle"] = this.LoadTextFile("JsAndroidResources/buildGradle.txt", replacements); output[replacements["PROJECT_ID_LOWERCASE"] + ".iml"] = this.LoadTextFile("JsAndroidResources/androidIml.txt", replacements); output["gradle.properties"] = this.LoadTextFile("JsAndroidResources/gradleProperties.txt", replacements); output["gradlew"] = this.LoadTextFile("JsAndroidResources/gradlew.txt", replacements); output["gradlew.bat"] = this.LoadTextFile("JsAndroidResources/gradlewBat.txt", replacements); output["local.properties"] = this.LoadTextFile("JsAndroidResources/localProperties.txt", replacements); output["settings.gradle"] = this.LoadTextFile("JsAndroidResources/settingsGradle.txt", replacements); output["gradle/wrapper/gradle-wrapper.jar"] = this.LoadBinaryFile("JsAndroidResources/gradle/wrapper/GradleWrapper.jar"); output["gradle/wrapper/gradle-wrapper.properties"] = this.LoadTextFile("JsAndroidResources/gradle/wrapper/GradleWrapperProperties.txt", replacements); output[".idea/compiler.xml"] = this.LoadTextFile("JsAndroidResources/idea/compilerXml.txt", replacements); output[".idea/encodings.xml"] = this.LoadTextFile("JsAndroidResources/idea/encodingsXml.txt", replacements); output[".idea/gradle.xml"] = this.LoadTextFile("JsAndroidResources/idea/gradleXml.txt", replacements); output[".idea/misc.xml"] = this.LoadTextFile("JsAndroidResources/idea/miscXml.txt", replacements); output[".idea/modules.xml"] = this.LoadTextFile("JsAndroidResources/idea/modulesXml.txt", replacements); output[".idea/vcs.xml"] = this.LoadTextFile("JsAndroidResources/idea/vcsXml.txt", replacements); output[".idea/copyright/profiles_settings.xml"] = this.LoadTextFile("JsAndroidResources/idea/copyright/profileSettings.txt", replacements); output[".idea/scopes/scope_settings.xml"] = this.LoadTextFile("JsAndroidResources/idea/scopes/scopeSettings.txt", replacements); if (!exportProperties.SkipAndroidWorkspaceXml) { output[".idea/workspace.xml"] = this.LoadTextFile("JsAndroidResources/idea/workspaceXml.txt", replacements); } output["app/.gitignore"] = this.LoadTextFile("JsAndroidResources/app/gitignore.txt", replacements); output["app/app.iml"] = this.LoadTextFile("JsAndroidResources/app/appIml.txt", replacements); output["app/build.gradle"] = this.LoadTextFile("JsAndroidResources/app/buildGradle.txt", replacements); output["app/proguard-rules.txt"] = this.LoadTextFile("JsAndroidResources/app/proguardRules.txt", replacements); output["app/src/main/java/" + packagedDir + "/app/MainActivity.java"] = this.LoadTextFile("JsAndroidResources/app/src/main/java/org/crayonlang/sampleapp/app/MainActivityJava.txt", replacements); output["app/src/main/java/" + packagedDir + "/app/CrayonWebView.java"] = this.LoadTextFile("JsAndroidResources/app/src/main/java/org/crayonlang/sampleapp/app/CrayonWebViewJava.txt", replacements); output["app/src/main/res/layout/activity_main.xml"] = this.LoadTextFile("JsAndroidResources/app/src/main/res/layout/ActivityMainXml.txt", replacements); output["app/src/main/res/menu/main.xml"] = this.LoadTextFile("JsAndroidResources/app/src/main/res/menu/MainXml.txt", replacements); output["app/src/main/res/values/dimens.xml"] = this.LoadTextFile("JsAndroidResources/app/src/main/res/values/DimensXml.txt", replacements); output["app/src/main/res/values/strings.xml"] = this.LoadTextFile("JsAndroidResources/app/src/main/res/values/StringsXml.txt", replacements); output["app/src/main/res/values/styles.xml"] = this.LoadTextFile("JsAndroidResources/app/src/main/res/values/StylesXml.txt", replacements); output["app/src/main/res/values-w820dp/dimens.xml"] = this.LoadTextFile("JsAndroidResources/app/src/main/res/valuesW820dp/DimensXml.txt", replacements); FileOutput androidManifest = this.LoadTextFile("JsAndroidResources/app/src/main/AndroidManifestXml.txt", replacements); output["app/src/main/AndroidManifest.xml"] = androidManifest; IconSetGenerator icons = new IconSetGenerator(); if (exportProperties.HasIcon) { string[] iconPaths = exportProperties.IconPaths; foreach (string iconPath in iconPaths) { Bitmap icon = new Bitmap(iconPath); icons.AddInputImage(icon); } } Dictionary <int, Bitmap> iconImagesBySize = icons .AddOutputSize(48) .AddOutputSize(72) .AddOutputSize(96) .AddOutputSize(144) .AddOutputSize(512) .GenerateWithDefaultFallback(); output["app/src/main/res/drawable-mdpi/ic_launcher.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[48] }; output["app/src/main/res/drawable-hdpi/ic_launcher.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[72] }; output["app/src/main/res/drawable-xhdpi/ic_launcher.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[96] }; output["app/src/main/res/drawable-xxhdpi/ic_launcher.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[144] }; output["app/src/main/ic_launcher-web.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = iconImagesBySize[512] }; output["app/src/main/assets/android.js"] = this.LoadTextFile("JsAndroidResources/app/src/main/assets/androidJs.txt", replacements); }