Ejemplo n.º 1
0
        private void CopyAllocatedItemsToAtlas(List <TextureTools.AtlasItem> items, string atlasChain, int atlasId, Size size)
        {
            var atlasPath   = AssetCooker.GetAtlasPath(atlasChain, atlasId);
            var atlasPixels = new Color4[size.Width * size.Height];

            foreach (var item in items.Where(i => i.Allocated))
            {
                var atlasRect = item.AtlasRect;
                using (var bitmap = TextureTools.OpenAtlasItemBitmapAndRescaleIfNeeded(AssetCooker.Platform, item)) {
                    CopyPixels(bitmap, atlasPixels, atlasRect.A.X, atlasRect.A.Y, size.Width, size.Height);
                }
                var atlasPart = new TextureAtlasElement.Params {
                    AtlasRect = atlasRect,
                    AtlasPath = Path.ChangeExtension(atlasPath, null)
                };
                var srcPath = Path.ChangeExtension(item.Path, item.SourceExtension);
                InternalPersistence.Instance.WriteObjectToBundle(AssetCooker.OutputBundle, item.Path, atlasPart, Persistence.Format.Binary,
                                                                 item.SourceExtension, AssetCooker.InputBundle.GetFileLastWriteTime(srcPath), AssetAttributes.None, item.CookingRules.SHA1);
                // Delete non-atlased texture since now its useless
                var texturePath = Path.ChangeExtension(item.Path, AssetCooker.GetPlatformTextureExtension());
                if (AssetCooker.OutputBundle.FileExists(texturePath))
                {
                    AssetCooker.DeleteFileFromBundle(texturePath);
                }
                UserInterface.Instance.IncreaseProgressBar();
            }
            Console.WriteLine("+ " + atlasPath);
            var firstItem = items.First(i => i.Allocated);

            using (var atlas = new Bitmap(atlasPixels, size.Width, size.Height)) {
                AssetCooker.ImportTexture(atlasPath, atlas, firstItem.CookingRules, AssetCooker.InputBundle.GetFileLastWriteTime(atlasPath), CookingRulesSHA1: null);
            }
        }
Ejemplo n.º 2
0
        public static string BuildGameAction()
        {
            var target = The.UI.GetActiveTarget();

            AssetCooker.CookForTarget(target);
            return(BuildGame(target) ? null : "Can not BuildGame");
        }
Ejemplo n.º 3
0
        private Widget CreateFooterSection()
        {
            var container = new Widget {
                Layout = new HBoxLayout {
                    Spacing = 5
                },
            };

            actionPicker = new ThemedDropDownList();
            foreach (var menuItem in The.MenuController.GetVisibleAndSortedItems())
            {
                actionPicker.Items.Add(new CommonDropDownList.Item(menuItem.Label, menuItem.Action));
            }
            actionPicker.Index = 0;
            container.AddNode(actionPicker);

            goButton          = new ThemedButton("Go");
            goButton.Clicked += () => Execute((Func <string>)actionPicker.Value);
            container.AddNode(goButton);

            abortButton = new ThemedButton("Abort")
            {
                Enabled = false,
                Visible = false
            };
            abortButton.Clicked += () => AssetCooker.CancelCook();
            container.AddNode(abortButton);

            return(container);
        }
Ejemplo n.º 4
0
        public static string GenerateYuzuDeserializersForApp()
        {
            AssetCooker.CookForActivePlatform();
            if (!BuildGame())
            {
                return("Can not BuildGame");
            }

            var builder = new SolutionBuilder(
                The.Workspace.ActivePlatform, The.Workspace.CustomSolution);
            int exitCode = builder.Run("--GenerateYuzuDeserializers");

            if (exitCode != 0)
            {
                return($"Application terminated with exit code {exitCode}");
            }
            string app      = builder.GetApplicationPath();
            string assembly = Path.Combine(Path.GetDirectoryName(app), "Serializer.dll");

            if (!File.Exists(assembly))
            {
                Console.WriteLine("{0} doesn't exist", assembly);
                Console.WriteLine(@"Ensure your Application.cs contains following code:
	if (Array.IndexOf(args, ""--GenerateYuzuDeserializers"") >= 0) {
		Lime.Serialization.GenerateDeserializers(""OceanDeserializers.cs"", ""OceanDeserializers"", GetSerializationTypes());
		return;
	}"    );
                return(string.Empty);
            }
            return(null);
            // TODO: write location of generated file
        }
Ejemplo n.º 5
0
        public static void CookMainBundleAction()
        {
            var target = The.UI.GetActiveTarget();

            AssetCooker.CookForTarget(
                target,
                new [] { CookingRulesBuilder.MainBundleName }
                );
        }
Ejemplo n.º 6
0
 public static string BuildAndRunAction()
 {
     AssetCooker.CookForActivePlatform();
     if (!Actions.BuildGame())
     {
         return("Can not BuildGame");
     }
     return(null);
 }
Ejemplo n.º 7
0
 public static void CookMainBundleAction()
 {
     AssetCooker.Cook(
         The.Workspace.ActivePlatform,
         new System.Collections.Generic.List <string>()
     {
         CookingRulesBuilder.MainBundleName
     }
         );
 }
Ejemplo n.º 8
0
        public static string BuildAndRunAction()
        {
            var target = The.UI.GetActiveTarget();

            AssetCooker.CookForTarget(target);
            if (!Actions.BuildGame(target))
            {
                return("Can not BuildGame");
            }
            return(null);
        }
Ejemplo n.º 9
0
 public static string BuildAndRun(Target target, string configuration)
 {
     AssetCooker.CookForTarget(target);
     if (!BuildGame(target, configuration))
     {
         return("Can not BuildGame");
     }
     The.UI.ScrollLogToEnd();
     RunGame(target.Platform, target.ProjectPath, configuration);
     return(null);
 }
Ejemplo n.º 10
0
 public static string BuildAndRun(string configuration)
 {
     AssetCooker.CookForActivePlatform();
     if (!BuildGame(The.Workspace.ActivePlatform, The.Workspace.CustomSolution, configuration))
     {
         return("Can not BuildGame");
     }
     The.UI.ScrollLogToEnd();
     RunGame(The.Workspace.ActivePlatform, The.Workspace.CustomSolution, configuration);
     return(null);
 }
Ejemplo n.º 11
0
 public static string BuildAndRun(Target target)
 {
     AssetCooker.CookForTarget(target, The.UI.GetSelectedBundles());
     if (!BuildGame(target))
     {
         return("Can not BuildGame");
     }
     The.UI.ScrollLogToEnd();
     RunGame(target);
     return(null);
 }
Ejemplo n.º 12
0
 public static string RebuildGameAction()
 {
     if (The.UI.AskConfirmation("Are you sure you want to rebuild the game?"))
     {
         CleanupGame();
         AssetCooker.CookForActivePlatform();
         if (!BuildGame())
         {
             return("Can not BuildGame");
         }
     }
     return(null);
 }
Ejemplo n.º 13
0
        public static string BuildAndRunAction()
        {
            AssetCooker.CookForActivePlatform();

            if (!BuildGame())
            {
                return("Can not BuildGame");
            }

            The.UI.ScrollLogToEnd();
            RunGame();
            return(null);
        }
Ejemplo n.º 14
0
        public static void CookForTarget(Target target, IEnumerable <string> bundles = null)
        {
            var assetCooker = new AssetCooker(target);
            var skipCooking = The.Workspace.ProjectJson.GetValue <bool>("SkipAssetsCooking");

            if (!skipCooking)
            {
                assetCooker.Cook(bundles ?? assetCooker.GetListOfAllBundles());
            }
            else
            {
                Console.WriteLine("-------------  Skip Assets Cooking -------------");
            }
        }
Ejemplo n.º 15
0
        public static string UpdateXCodeProjectAction()
        {
            var target = The.UI.GetActiveTarget();

            if (target.Platform != TargetPlatform.iOS)
            {
                UserInterface.Instance.ExitWithErrorIfPossible();
                return("Error updating XCode project: active target must target iOS platform.");
            }
            if (The.Workspace.ProjectJson.GetValue <bool>("XCodeProject/DoSvnUpdate"))
            {
                Subversion.Update(GetXCodeProjectFolder());
            }
            AssetCooker.CookForTarget(
                target,
                new [] { CookingRulesBuilder.MainBundleName }
                );
            var solutionPath = The.Workspace.GetSolutionFilePath(TargetPlatform.iOS);
            var builder      = new SolutionBuilder(TargetPlatform.iOS, solutionPath);
            var output       = new StringBuilder();

            builder.Clean();
            if (builder.Build(output))
            {
                The.UI.ScrollLogToEnd();
                string allText = output.ToString();
                var    appPath = GetGeneratedAppPath(allText);
                foreach (var line in allText.Split('\n'))
                {
                    if (line.Contains("/bin/mtouch"))
                    {
                        var mtouch = line;
                        GenerateUnsignedBinary(target, mtouch);
                        var dstPath = GetXCodeProjectDataFolder();
                        CopyContent(appPath, dstPath);
                        CopyDSYM(appPath, Path.GetDirectoryName(dstPath));
                    }
                }
            }
            else
            {
                UserInterface.Instance.ExitWithErrorIfPossible();
                return("Build system has returned error");
            }
            if (The.Workspace.ProjectJson.GetValue <bool>("XCodeProject/DoSvnCommit"))
            {
                Subversion.Commit(GetXCodeProjectFolder(), "");
            }
            return(null);
        }
Ejemplo n.º 16
0
 public static void Unpack(Target target, List <string> bundles = null)
 {
     if (bundles == null)
     {
         bundles = new AssetCooker(target).GetListOfAllBundles();
     }
     The.UI.SetupProgressBar(GetAssetsToRevealCount(target.Platform, bundles));
     foreach (var bundleName in bundles)
     {
         string bundlePath = The.Workspace.GetBundlePath(target.Platform, bundleName);
         UnpackBundle(target.Platform, bundlePath);
     }
     The.UI.StopProgressBar();
 }
Ejemplo n.º 17
0
 public static void DeleteBundles(Target target, List <string> bundles = null)
 {
     if (bundles == null)
     {
         bundles = new AssetCooker(target).GetListOfAllBundles();
     }
     The.UI.SetupProgressBar(bundles.Count);
     foreach (var bundleName in bundles)
     {
         var bundlePath = The.Workspace.GetBundlePath(target.Platform, bundleName) + UnpackedSuffix;
         DeleteBundle(bundlePath);
         The.UI.IncreaseProgressBar();
     }
     The.UI.StopProgressBar();
 }
Ejemplo n.º 18
0
 public void Action()
 {
     foreach (var maskPath in AssetCooker.AssetBundle.EnumerateFiles().ToList())
     {
         if (maskPath.EndsWith(maskExtension, StringComparison.OrdinalIgnoreCase))
         {
             var origImageFile = Path.ChangeExtension(maskPath, AssetCooker.GetPlatformTextureExtension());
             if (!AssetCooker.AssetBundle.FileExists(origImageFile))
             {
                 AssetCooker.DeleteFileFromBundle(maskPath);
             }
             UserInterface.Instance.IncreaseProgressBar();
         }
     }
 }
Ejemplo n.º 19
0
        public static string RebuildGameAction()
        {
            var target = The.UI.GetActiveTarget();

            if (The.UI.AskConfirmation("Are you sure you want to rebuild the game?"))
            {
                CleanupGame(target);
                AssetCooker.CookForTarget(target);
                if (!BuildGame(target))
                {
                    return("Can not BuildGame");
                }
            }
            return(null);
        }
Ejemplo n.º 20
0
        private bool Converter(string srcPath, string dstPath)
        {
            var     cookingRules = AssetCooker.CookingRulesMap[srcPath];
            var     compression  = cookingRules.ModelCompression;
            Model3D model;
            var     options = new FbxImportOptions {
                Path            = srcPath,
                Target          = AssetCooker.Target,
                CookingRulesMap = AssetCooker.CookingRulesMap
            };

            using (var fbxImporter = new FbxModelImporter(options)) {
                model = fbxImporter.LoadModel();
            }
            AssetAttributes assetAttributes;

            switch (compression)
            {
            case ModelCompression.None:
                assetAttributes = AssetAttributes.None;
                break;

            case ModelCompression.Deflate:
                assetAttributes = AssetAttributes.ZippedDeflate;
                break;

            case ModelCompression.LZMA:
                assetAttributes = AssetAttributes.ZippedLZMA;
                break;

            default:
                throw new ArgumentOutOfRangeException($"Unknown compression: {compression}");
            }
            var animationPathPrefix = AssetCooker.GetModelAnimationPathPrefix(dstPath);

            AssetCooker.DeleteModelExternalAnimations(animationPathPrefix);
            AssetCooker.ExportModelAnimations(model, animationPathPrefix, assetAttributes, cookingRules.SHA1);
            model.RemoveAnimatorsForExternalAnimations();
            InternalPersistence.Instance.WriteObjectToBundle(AssetCooker.AssetBundle, dstPath, model, Persistence.Format.Binary, t3dExtension,
                                                             File.GetLastWriteTime(srcPath), assetAttributes, cookingRules.SHA1);
            return(true);
        }
Ejemplo n.º 21
0
        public int GetOperationsCount()
        {
            var result     = 0;
            var assetFiles = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var fileInfo in The.Workspace.AssetFiles.Enumerate())
            {
                assetFiles.Add(fileInfo.Path);
            }
            foreach (var path in AssetCooker.AssetBundle.EnumerateFiles())
            {
                if (!path.StartsWith("Atlases") &&
                    !toDeleteExtensions.Contains(Path.GetExtension(path), StringComparer.OrdinalIgnoreCase) &&
                    !assetFiles.Contains(Path.ChangeExtension(path, AssetCooker.GetOriginalAssetExtension(path))))
                {
                    result++;
                }
            }
            return(result);
        }
Ejemplo n.º 22
0
        public static string GenerateYuzuDeserializersForApp()
        {
            AssetCooker.CookForActivePlatform();
#if WIN
            if (!BuildGame(Orange.TargetPlatform.Win))
            {
#elif MAC
            if (!BuildGame(Orange.TargetPlatform.Mac))
            {
#endif
                return("Can not BuildGame");
            }
#if WIN
            var builder = new SolutionBuilder(TargetPlatform.Win);
#elif MAC
            var builder = new SolutionBuilder(TargetPlatform.Mac);
#endif
            int exitCode = builder.Run("--GenerateYuzuDeserializers");
            if (exitCode != 0)
            {
                return($"Application terminated with exit code {exitCode}");
            }
            string app      = builder.GetApplicationPath();
            string dir      = System.IO.Path.GetDirectoryName(app);
            string assembly = System.IO.Path.Combine(dir, "Serializer.dll");
            if (!System.IO.File.Exists(assembly))
            {
                Console.WriteLine("{0} doesn't exist", assembly);
                Console.WriteLine(@"Ensure your Application.cs contains following code:
	if (Array.IndexOf(args, ""--GenerateYuzuDeserializers"") >= 0) {
		Lime.Serialization.GenerateDeserializers(""OceanDeserializers.cs"", ""OceanDeserializers"", GetSerializationTypes());
		return;
	}"    );
                return("");
            }
            return(null);
            // TODO: write location of generated file
        }
    }
Ejemplo n.º 23
0
        private bool Converter(string srcPath, string dstPath)
        {
            var rules = AssetCooker.CookingRulesMap[Path.ChangeExtension(dstPath, originalTextureExtension)];

            if (rules.TextureAtlas != null)
            {
                // No need to cache this texture since it is a part of texture atlas.
                return(false);
            }
            using (var stream = File.OpenRead(srcPath)) {
                var bitmap = new Bitmap(stream);
                if (TextureTools.ShouldDownscale(AssetCooker.Platform, bitmap, rules))
                {
                    var scaledBitmap = TextureTools.DownscaleTexture(AssetCooker.Platform, bitmap, srcPath, rules);
                    bitmap.Dispose();
                    bitmap = scaledBitmap;
                }
                AssetCooker.ImportTexture(dstPath, bitmap, rules, File.GetLastWriteTime(srcPath), rules.SHA1);
                bitmap.Dispose();
            }
            return(true);
        }
Ejemplo n.º 24
0
        public void Action()
        {
            var assetFiles = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var fileInfo in The.Workspace.AssetFiles.Enumerate())
            {
                assetFiles.Add(fileInfo.Path);
            }
            foreach (var path in AssetCooker.AssetBundle.EnumerateFiles().ToList())
            {
                // Ignoring texture atlases
                if (path.StartsWith("Atlases"))
                {
                    continue;
                }
                // Ignore atlas parts, masks, animations
                var ext = Path.GetExtension(path);
                if (toDeleteExtensions.Contains(ext, StringComparer.OrdinalIgnoreCase))
                {
                    continue;
                }
                var assetPath = Path.ChangeExtension(path, AssetCooker.GetOriginalAssetExtension(path));
                if (!assetFiles.Contains(assetPath))
                {
                    if (path.EndsWith(modelTanExtension, StringComparison.OrdinalIgnoreCase))
                    {
                        AssetCooker.DeleteModelExternalAnimations(AssetCooker.GetModelAnimationPathPrefix(path));
                    }
                    var modelAttachmentExtIndex = path.LastIndexOf(Model3DAttachment.FileExtension);
                    if (modelAttachmentExtIndex >= 0)
                    {
                        AssetCooker.ModelsToRebuild.Add(path.Remove(modelAttachmentExtIndex) + modelTanExtension);
                    }
                    AssetCooker.DeleteFileFromBundle(path);
                    UserInterface.Instance.IncreaseProgressBar();
                }
            }
        }
Ejemplo n.º 25
0
 public SyncCompoundFonts(AssetCooker assetCooker) : base(assetCooker)
 {
 }
Ejemplo n.º 26
0
 public SyncFonts(AssetCooker assetCooker) : base(assetCooker)
 {
 }
Ejemplo n.º 27
0
 public void Action() => AssetCooker.SyncUpdated(extension, extension, Converter);
Ejemplo n.º 28
0
 public int GetOperationCount() => AssetCooker.GetUpdateOperationCount(extension);
Ejemplo n.º 29
0
 public SyncRawAssets(AssetCooker assetCooker, string extension, AssetAttributes attributes = AssetAttributes.None)
     : base(assetCooker)
 {
     this.extension  = extension;
     this.attributes = attributes;
 }
Ejemplo n.º 30
0
 public void Action() => AssetCooker.SyncUpdated(sceneExtension, sceneExtension, Converter);