public override Dictionary <string, FileOutput> ExportProject( IList <VariableDeclaration> globals, IList <StructDefinition> structDefinitions, IList <FunctionDefinition> functionDefinitions, IList <LibraryForExport> libraries, ResourceDatabase resourceDatabase, Options options, ILibraryNativeInvocationTranslatorProvider libraryNativeInvocationTranslatorProviderForPlatform) { if (!options.GetBool(ExportOptionKey.HAS_ICON)) { throw new InvalidOperationException("Cannot generate a Chrome Web App without an icon resource."); } string iconFilePath = options.GetString(ExportOptionKey.ICON_PATH); if (!FileUtil.FileExists(iconFilePath)) { throw new InvalidOperationException("Icon resource path points to non-existent file."); } SystemBitmap iconFile = new SystemBitmap(iconFilePath); SystemBitmap smallIcon = iconFile.CloneToNewSize(16, 16); SystemBitmap largeIcon = iconFile.CloneToNewSize(128, 128); JavaScriptApp.PlatformImpl jsBasicPlatform = (JavaScriptApp.PlatformImpl) this.PlatformProvider.GetPlatform("javascript-app"); Dictionary <string, FileOutput> files = jsBasicPlatform.ExportProjectImpl(globals, structDefinitions, functionDefinitions, libraries, resourceDatabase, options, libraryNativeInvocationTranslatorProviderForPlatform, this.Translator); Dictionary <string, string> replacements = this.GenerateReplacementDictionary(options, resourceDatabase); replacements["JS_LIB_INCLUSIONS"] = jsBasicPlatform.GenerateJsLibInclusionHtml(files.Keys); this.CopyResourceAsText(files, "background.js", "Resources/BackgroundJs.txt", replacements); this.CopyResourceAsText(files, "index.html", "Resources/IndexHtml.txt", replacements); // overwrites GameHostHtml.txt from javascript-app this.CopyResourceAsText(files, "chrome_web_app.js", "Resources/ChromeWebAppJs.txt", replacements); this.CopyResourceAsText(files, "manifest.json", "Resources/ManifestJson.txt", Util.MakeReplacementStringsJsonSafe(replacements)); files["icon-16.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = smallIcon, }; files["icon-128.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = largeIcon, }; return(new Dictionary <string, FileOutput>() { { replacements["PROJECT_ID"] + ".zip", ZipCreator.Create(files, false) } }); }
public override void ExportProject( Dictionary <string, FileOutput> output, TemplateStorage templates, IList <LibraryForExport> libraries, ResourceDatabase resourceDatabase, Options options) { if (!options.GetBool(ExportOptionKey.HAS_ICON)) { throw new InvalidOperationException("Cannot generate a Chrome Web App without an icon resource."); } string iconFilePath = options.GetString(ExportOptionKey.ICON_PATH); if (!FileUtil.FileExists(iconFilePath)) { throw new InvalidOperationException("Icon resource path points to non-existent file."); } SystemBitmap iconFile = new SystemBitmap(iconFilePath); SystemBitmap smallIcon = iconFile.CloneToNewSize(16, 16); SystemBitmap largeIcon = iconFile.CloneToNewSize(128, 128); JavaScriptApp.PlatformImpl jsBasicPlatform = (JavaScriptApp.PlatformImpl) this.PlatformProvider.GetPlatform("javascript-app"); Dictionary <string, FileOutput> proxyOutput = new Dictionary <string, FileOutput>(); jsBasicPlatform.ExportProjectImpl(proxyOutput, templates, libraries, resourceDatabase, options); Dictionary <string, string> replacements = this.GenerateReplacementDictionary(options, resourceDatabase); replacements["JS_LIB_INCLUSIONS"] = JavaScriptApp.PlatformImpl.GenerateJsLibInclusionHtml(proxyOutput.Keys); this.CopyResourceAsText(proxyOutput, "background.js", "Resources/BackgroundJs.txt", replacements); this.CopyResourceAsText(proxyOutput, "index.html", "Resources/IndexHtml.txt", replacements); // overwrites GameHostHtml.txt from javascript-app this.CopyResourceAsText(proxyOutput, "chrome_web_app.js", "Resources/ChromeWebAppJs.txt", replacements); this.CopyResourceAsText(proxyOutput, "manifest.json", "Resources/ManifestJson.txt", Util.MakeReplacementStringsJsonSafe(replacements)); proxyOutput["icon-16.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = smallIcon, }; proxyOutput["icon-128.png"] = new FileOutput() { Type = FileOutputType.Image, Bitmap = largeIcon, }; output[replacements["PROJECT_ID"] + ".zip"] = ZipCreator.Create(proxyOutput, false); }