/**
         * This method creates the frames of the animation from the images belonging
         * to the previous animation format.
         *
         * @param assetPath
         *            The path to the previous animation
         * @param changeFormat
         *            Change the frame creation setting the time per frame and wait user interaction.
         */
        public static void framesFromImages(Animation animation, string assetPath, bool changeFormat)
        {
            //animation.getFrames().Clear();
            //animation.getTransitions().Clear();
            //animation.getTransitions().Add(new Transition());
            //animation.getTransitions().Add(new Transition());

            //int i = 1;
            //Sprite currentSlide = null;
            //bool end = false;

            //while (!end)
            //{
            //    string file = assetPath + "_" + leadingZeros(i) + ".jpg";
            //    currentSlide = AssetsController.getImage(file);
            //    if (currentSlide == null)
            //    {
            //        file = assetPath + "_" + leadingZeros(i) + ".png";
            //        currentSlide = AssetsController.getImage(file);
            //    }
            //    if (currentSlide == null)
            //        end = true;
            //    else {
            //        if (!changeFormat)
            //            animation.addFrame(-1, new Frame(animation.getImageLoaderFactory(), file));
            //        else
            //            animation.addFrame(-1, new Frame(animation.getImageLoaderFactory(), file, 100, true));
            //    }
            //    i++;
            //}
        }
Example #2
0
        public void Init(DialogReceiverInterface e, string cutsceneFilePath)
        {
            parent = e;

            windowWidth  = 800;
            windowHeight = 1000;

            cutscenePath = cutsceneFilePath;
            clearImg     = Resources.Load <Texture2D>("EAdventureData/img/icons/deleteContent");
            addTexture   = Resources.Load <Texture2D>("EAdventureData/img/icons/addNode");
            moveLeft     = Resources.Load <Texture2D>("EAdventureData/img/icons/moveNodeLeft");
            moveRight    = Resources.Load <Texture2D>("EAdventureData/img/icons/moveNodeRight");
            duplicateImg = Resources.Load <Texture2D>("EAdventureData/img/icons/duplicateNode");

            noBackgroundSkin  = Resources.Load <GUISkin>("EAdventureData/skin/EditorNoBackgroundSkin");
            selectedFrameSkin = Resources.Load <GUISkin>("EAdventureData/skin/EditorLeftMenuItemSkinConcreteOptions");

            transitionTypeName = new string[]
            {
                TC.get("NextScene.NoTransition"),
                TC.get("NextScene.TopToBottom"),
                TC.get("NextScene.BottomToTop"),
                TC.get("NextScene.LeftToRight"),
                TC.get("NextScene.RightToLeft"),
                TC.get("NextScene.FadeIn")
            };
            transitionTypeTexture = new Texture2D[]
            {
                Resources.Load <Texture2D>("EAdventureData/img/icons/transitionNone"),
                Resources.Load <Texture2D>("EAdventureData/img/icons/transitionVertical"),
                Resources.Load <Texture2D>("EAdventureData/img/icons/transitionReverseVertical"),
                Resources.Load <Texture2D>("EAdventureData/img/icons/transitionHorizontal"),
                Resources.Load <Texture2D>("EAdventureData/img/icons/transitionReverseHorizontal"),
                Resources.Load <Texture2D>("EAdventureData/img/icons/transitionFadein"),
            };

            Debug.Log(cutsceneFilePath);

            var incidences = new List <Incidence>();

            workingAnimation = Loader.LoadAnimation(cutsceneFilePath, Controller.ResourceManager, incidences) ?? new Animation(cutsceneFilePath, 40);

            imageChooser = new FileChooser
            {
                Empty    = SpecialAssetPaths.ASSET_EMPTY_IMAGE,
                FileType = FileType.FRAME_IMAGE,
                Label    = TC.get("Animation.Image")
            };

            soundChooser = new FileChooser
            {
                FileType = FileType.FRAME_MUSIC,
                Label    = TC.get("Animation.Sound")
            };

            // Initalize
            selectedFrame = -1;

            base.Init(e);
        }
 void OnSlidesceneCreated(string val)
 {
     uAdventure.Core.Animation newAnim = new uAdventure.Core.Animation(val.Split('/').Last());
     newAnim.getFrame(0).setUri(EMPTY + "_01.png");
     AnimationWriter.WriteAnimation(val, newAnim);
     AssetDatabase.ImportAsset("Assets/uAdventure/Resources/CurrentGame/" + val);
     Path = val;
 }
        public eAnim(string path, ResourceManager.LoadingType type)
        {
            frames = new List <eFrame>();
            var incidences = new List <Incidence>();

            Animation = Loader.LoadAnimation(path, Game.Instance.ResourceManager, incidences);

            foreach (var frame in Animation.getFrames())
            {
                var eframe = new eFrame();
                eframe.Image    = Game.Instance.ResourceManager.getImage(frame.getUri());
                eframe.Duration = (int)frame.getTime();
                frames.Add(eframe);
            }
        }
Example #5
0
        public void Init(DialogReceiverInterface e, string cutsceneFilePath)
        {
            cutscenePath = cutsceneFilePath;
            clearImg     = (Texture2D)Resources.Load("EAdventureData/img/icons/deleteContent", typeof(Texture2D));
            addTexture   = (Texture2D)Resources.Load("EAdventureData/img/icons/addNode", typeof(Texture2D));
            moveLeft     = (Texture2D)Resources.Load("EAdventureData/img/icons/moveNodeLeft", typeof(Texture2D));
            moveRight    = (Texture2D)Resources.Load("EAdventureData/img/icons/moveNodeRight", typeof(Texture2D));
            duplicateImg = (Texture2D)Resources.Load("EAdventureData/img/icons/duplicateNode", typeof(Texture2D));

            animInfoRect        = new Rect(0f, 0.05f * windowHeight, windowWidth, 0.15f * windowHeight);
            timelineRect        = new Rect(0f, 0.25f * windowHeight, windowWidth, 0.3f * windowHeight);
            timelineButtonsRect = new Rect(0f, 0.50f * windowHeight, windowWidth, 0.1f * windowHeight);
            frameInfoRect       = new Rect(0f, 0.65f * windowHeight, windowWidth, 0.25f * windowHeight);
            buttonRect          = new Rect(0f, 0.9f * windowHeight, windowWidth, 0.1f * windowHeight);

            noBackgroundSkin  = (GUISkin)Resources.Load("Editor/EditorNoBackgroundSkin", typeof(GUISkin));
            selectedFrameSkin = (GUISkin)Resources.Load("Editor/EditorLeftMenuItemSkinConcreteOptions", typeof(GUISkin));

            //transitionTypes = new string []{ "None" , "Fade in", "Horizontal", "Vertical"};
            Debug.Log(cutsceneFilePath);

            workingAnimation = Loader.loadAnimation(AssetsController.InputStreamCreatorEditor.getInputStreamCreator(),
                                                    cutsceneFilePath, new EditorImageLoader());

            Debug.Log(workingAnimation.getAboslutePath() + " " + workingAnimation.getFrames().Count + " " + workingAnimation.isSlides() + " " + workingAnimation.getId());
            if (workingAnimation == null)
            {
                workingAnimation = new Animation(cutsceneFilePath, 40, new EditorImageLoader());
            }

            // Initalize
            selectedFrame            = 0;
            documentationTextContent = workingAnimation.getFrames()[selectedFrame].getDocumentation();
            imagePath = workingAnimation.getFrames()[selectedFrame].getUri();
            soundPath = workingAnimation.getFrames()[selectedFrame].getSoundUri();
            animationDurationString          =
                animationDurationStringLast  = workingAnimation.getFrames()[selectedFrame].getTime().ToString();
            transitionDurationString         =
                transitionDurationStringLast = workingAnimation.getTransitions()[selectedFrame + 1].getTime().ToString();
            useTransitonFlag    = useTransitonFlagLast = workingAnimation.isUseTransitions();
            slidesAnimationFlag = slidesAnimationFlagLast = workingAnimation.isSlides();

            base.Init(e);
        }
        public static bool writeAnimation(string filename, Animation animation)
        {
            bool            dataSaved      = false;
            XmlDocument     doc            = doc = new XmlDocument();
            XmlDeclaration  declaration    = doc.CreateXmlDeclaration("1.0", "UTF-8", "no");
            XmlDocumentType typeDescriptor = doc.CreateDocumentType("animation", "SYSTEM", "animation.dtd", null);

            doc.AppendChild(declaration);
            doc.AppendChild(typeDescriptor);
            XmlElement mainNode = doc.CreateElement("animation");

            //mainNode.AppendChild(doc.createAttribute("id").setNodeValue(animation.getId()));
            mainNode.SetAttribute("id", animation.getId());
            mainNode.SetAttribute("usetransitions", animation.isUseTransitions() ? "yes" : "no");
            mainNode.SetAttribute("slides", animation.isSlides() ? "yes" : "no");
            XmlElement documentation = doc.CreateElement("documentation");

            if (animation.getDocumentation() != null && animation.getDocumentation().Length > 0)
            {
                documentation.InnerText = animation.getDocumentation();
            }
            mainNode.AppendChild(documentation);

            foreach (ResourcesUni resources in animation.getResources())
            {
                XmlNode resourcesNode = ResourcesDOMWriter.buildDOM(resources, ResourcesDOMWriter.RESOURCES_ANIMATION);
                doc.ImportNode(resourcesNode, true);
                mainNode.AppendChild(resourcesNode);
            }

            for (int i = 0; i < animation.getFrames().Count; i++)
            {
                mainNode.AppendChild(createTransitionElement(animation.getTransitions()[i], doc));
                mainNode.AppendChild(createFrameElement(animation.getFrames()[i], doc));
            }
            mainNode.AppendChild(createTransitionElement(animation.getEndTransition(), doc));

            doc.ImportNode(mainNode, true);
            doc.AppendChild(mainNode);
            string name = "Assets/Resources/CurrentGame/" + filename;

            if (!name.EndsWith(".eaa"))
            {
                name += ".eaa";
            }
            doc.Save(name);
            System.IO.File.Copy(name, name.Substring(0, name.LastIndexOf(".")) + ".xml", true);
            //TODO: implementation?
            //transformer = tf.newTransformer();
            //transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "animation.dtd");

            //try
            //{
            //    fout = new FileOutputStream(filename);
            //}
            //catch (FileNotFoundException e)
            //{
            //    fout = new FileOutputStream(Controller.getInstance().getProjectFolder() + "/" + filename);
            //}

            //writeFile = new OutputStreamWriter(fout, "UTF-8");
            //transformer.transform(new DOMSource(doc), new StreamResult(writeFile));
            //writeFile.close();
            //fout.close();

            dataSaved = true;

            return(dataSaved);
        }
        public static bool WriteAnimation(string filename, Animation animation)
        {
            bool        dataSaved = false;
            XmlDocument doc       = new XmlDocument();

            // Declaration, encoding, version, etc
            XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", "no");

            doc.AppendChild(declaration);

            // DTD
            XmlDocumentType typeDescriptor = doc.CreateDocumentType("animation", "SYSTEM", "animation.dtd", null);

            doc.AppendChild(typeDescriptor);

            // Main animation node
            XmlElement mainNode = doc.CreateElement("animation");

            mainNode.SetAttribute("id", animation.getId());
            mainNode.SetAttribute("usetransitions", animation.isUseTransitions() ? "yes" : "no");
            mainNode.SetAttribute("slides", animation.isSlides() ? "yes" : "no");

            // Documentation node
            XmlElement documentation = doc.CreateElement("documentation");

            if (animation.getDocumentation() != null && animation.getDocumentation().Length > 0)
            {
                documentation.InnerText = animation.getDocumentation();
            }

            mainNode.AppendChild(documentation);

            // Resources in this animation
            foreach (ResourcesUni resources in animation.getResources())
            {
                // TODO update to domwriter resource
                XmlNode resourcesNode = ResourcesDOMWriter.buildDOM(resources, ResourcesDOMWriter.RESOURCES_ANIMATION);
                doc.ImportNode(resourcesNode, true);
                mainNode.AppendChild(resourcesNode);
            }

            // Frames and transitions
            // TODO update to DOMWriter
            for (int i = 0; i < animation.getFrames().Count; i++)
            {
                mainNode.AppendChild(createTransitionElement(animation.getTransitions()[i], doc));
                mainNode.AppendChild(createFrameElement(animation.getFrames()[i], doc));
            }
            mainNode.AppendChild(createTransitionElement(animation.getEndTransition(), doc));
            doc.ImportNode(mainNode, true);
            doc.AppendChild(mainNode);

            // File saving
            string name = "Assets/uAdventure/Resources/CurrentGame/" + filename;

            if (!name.EndsWith(".eaa.xml"))
            {
                name += ".eaa.xml";
            }

            try
            {
                // Save
                doc.Save(name);
                dataSaved = true;
            }
            catch (System.Exception ex)
            {
                Debug.Log("Couldn't save Animation file \"" + name + "\": " + ex.Message);
            }

            return(dataSaved);
        }
 /**
  * This method creates the frames of the animation from the images belonging
  * to the previous animation format.
  *
  * @param assetPath
  *            The path to the previous animation
  */
 public static void framesFromImages(Animation animation, string assetPath)
 {
     framesFromImages(animation, assetPath, false);
 }