Ejemplo n.º 1
0
        public void TestSaveMethod()
        {
            MotionFile motionFile = new MotionFile();

            motionFile.Load(TEST_FILE);

            MemoryStream savedStream = new MemoryStream();

            motionFile.Save(savedStream);

            savedStream.Seek(0, SeekOrigin.Begin);

            MotionFile savedMotionFile = new MotionFile();

            savedMotionFile.Load(savedStream);

            savedStream.Close();

            Assert.AreEqual(motionFile.FramesPerSecond, savedMotionFile.FramesPerSecond, "Frames per second values do not match");
            Assert.AreEqual(motionFile.ChannelCount, savedMotionFile.ChannelCount, "Channel counts do not match");

            for (int i = 0; i < motionFile.ChannelCount; i++)
            {
                Assert.AreEqual(motionFile[i].Type, savedMotionFile[i].Type, "Channel types do not match");
                Assert.AreEqual(motionFile[i].Index, savedMotionFile[i].Index, "Channel index values do not match");
            }

            Assert.AreEqual(motionFile.FramesPerSecond, savedMotionFile.FramesPerSecond, "Frame counts do not match");
        }
Ejemplo n.º 2
0
        public bool OpenFile(bool checkSaved = true)
        {
            if (checkSaved && !ShowSaveQuestion())
            {
                return(false);
            }

            string filePath = GetOpenFilename();

            if (string.IsNullOrEmpty(filePath))
            {
                return(false);
            }

            CloseFile(false);
            EditingFile = new MotionFile(false);

            RegisterFileEvents(EditingFile);

            EditingFile.Load(filePath);

            MotionTab.UpdateItemPreviews();

            return(true);
        }
Ejemplo n.º 3
0
        private void UnregisterFileEvents(MotionFile file)
        {
            file.ItemCreated -= MotionTab.EditingFile_ItemCreated;
            file.ItemRemoved -= MotionTab.EditingFile_ItemRemoved;

            MotionTab.EditingFile_ItemRemoved(EditingFile.rootFolder, null);
        }
Ejemplo n.º 4
0
        public static MotionItem CreateDefault(MotionFile ownerFile)
        {
            MotionItem item = new MotionItem(ownerFile);

            item.AddPoint(new MotionPoint(new PVector2(0f, 0f)));
            item.AddPoint(new MotionPoint(new PVector2(1f, 1f)));
            return(item);
        }
Ejemplo n.º 5
0
        public bool CreateFile(bool checkSaved = true, bool createRootFolder = true)
        {
            if (checkSaved && !ShowSaveQuestion())
            {
                return(false);
            }

            CloseFile(false);
            EditingFile = new MotionFile(createRootFolder);

            RegisterFileEvents(EditingFile);

            MarkSaved();
            return(true);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 클라이언트에서 플레이할 수 있는 데이터 파일로 내보냅니다.
        /// </summary>
        public void Export(string fileName)
        {
            JObject jFile = new JObject();

            exportedTime = DateTime.Now;

            //File info
            jFile.Add(nameof(exportedTime), exportedTime.ToOADate());

            jFile.Add("MotionFile", MotionFile.ToJObject());
            jFile.Add("UiFile", UiFile.ToJObject());
            jFile.Add("StoryFile", StoryFile.ToJObject());

            File.WriteAllText(fileName, jFile.ToString(), Encoding.UTF8);
        }
Ejemplo n.º 7
0
        public void TestLoadMethod()
        {
            Stream stream = File.OpenRead(TEST_FILE);

            stream.Seek(0, SeekOrigin.End);
            long fileSize = stream.Position;

            stream.Seek(0, SeekOrigin.Begin);

            MotionFile motionFile = new MotionFile();

            motionFile.Load(stream);

            long streamPosition = stream.Position;

            stream.Close();

            Assert.AreEqual(fileSize, streamPosition, "Not all of the file was read");
        }
Ejemplo n.º 8
0
        public bool CloseFile(bool checkSaved = true)
        {
            if (!OnEditing)
            {
                return(true);
            }
            if (checkSaved && !ShowSaveQuestion())
            {
                return(false);
            }

            UnregisterFileEvents(EditingFile);

            MotionTab.ClearItems();
            GraphEditorTab.DetachMotion();
            EditingFile = null;

            return(true);
        }
Ejemplo n.º 9
0
        public void exportAsMotion()
        {
            if (MotionFile == null)
            {
                return;
            }

            System.Windows.Forms.SaveFileDialog sfd;
            sfd          = new System.Windows.Forms.SaveFileDialog();
            sfd.Title    = "Save motion as anb";
            sfd.FileName = "motion.motion";
            sfd.ShowDialog();
            if (sfd.FileName != "")
            {
                MemoryStream memStream = new MemoryStream();
                MotionFile.toStream().CopyTo(memStream);
                File.WriteAllBytes(sfd.FileName, memStream.ToArray());
            }
        }
Ejemplo n.º 10
0
        public static void LoadFile(string filePath, string fileId = null)
        {
            if (!CheckLoaded(fileId))
            {
                MotionFile file = new MotionFile();
                file.Load(filePath);

                if (fileId == null)
                {
                    MotionStorage.defaultFile = file;
                }
                else
                {
                    MotionStorage.fileDict.Add(fileId, file);
                }
            }
            else
            {
                throw new Exception("Already loaded same fileID.");
            }
        }
Ejemplo n.º 11
0
        public Stream toStream()
        {
            Stream stream = new MemoryStream();

            Bar.Entry MotionEntry = new Bar.Entry();
            MotionEntry.Type   = Bar.EntryType.Motion;
            MotionEntry.Index  = MotionIndex;
            MotionEntry.Name   = MotionName;
            MotionEntry.Stream = MotionFile.toStream();

            Bar.Entry TriggerEntry = new Bar.Entry();
            TriggerEntry.Type   = Bar.EntryType.MotionTriggers;
            TriggerEntry.Index  = TriggerIndex;
            TriggerEntry.Name   = TriggerName;
            TriggerEntry.Stream = (MotionTriggerFile != null) ? MotionTriggerFile.toStream() : new MemoryStream();

            Bar.Write(stream, new List <Bar.Entry> {
                MotionEntry, TriggerEntry
            });

            stream.Position = 0;
            return(stream);
        }
Ejemplo n.º 12
0
 internal MotionItem(MotionFile ownerFile) : base(ownerFile, MotionItemType.Motion)
 {
     pointList = new List <MotionPoint>();
 }
Ejemplo n.º 13
0
 public TaleData()
 {
     MotionFile = new MotionFile();
     UiFile     = new UiFile();
     StoryFile  = new StoryFile();
 }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            AsmMode mode   = AsmMode.Invalid;
            string  input  = "";
            string  output = "";
            string  labels = "";

            if (args.Length == 0)
            {
                Console.WriteLine(HelpText);
                return;
            }
            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                case "-h":
                case "help":
                    Console.WriteLine(HelpText);
                    break;

                case "-d":
                    mode = AsmMode.Disasm;
                    break;

                case "-a":
                    mode = AsmMode.Asm;
                    break;

                case "-l":
                    labels = args[++i];
                    break;

                case "-o":
                    output = args[++i];
                    break;

                default:
                    input = args[i];
                    break;
                }
            }

            if (mode == AsmMode.Invalid)
            {
                Console.WriteLine("Asm mode not set. Use -d or -a, see -h for details");
                return;
            }

            if (string.IsNullOrEmpty(input))
            {
                Console.WriteLine("No input file set. See -h for details");
                return;
            }

            if (string.IsNullOrEmpty(output))
            {
                if (mode == AsmMode.Disasm)
                {
                    output = "output.xml";
                }
                else
                {
                    output = "output_mlist.bin";
                }
            }

            //labels are only used on disassembly. During assembly they are parsed/hashed automatically
            if (string.IsNullOrEmpty(labels) || mode == AsmMode.Asm)
            {
                Labels = new Dictionary <ulong, string>();
            }
            else
            {
                Labels = GetLabels(labels);
            }

            Xml = new XmlDocument();

            if (mode == AsmMode.Disasm)
            {
                MFile = new MotionFile(input);
                Disasm();
                Xml.Save(output);
            }
            else
            {
                Xml.Load(input);
                MFile = new MotionFile();
                Asm();
                MFile.Save(output);
            }
        }
Ejemplo n.º 15
0
 public MotionItemBase(MotionFile ownerFile, MotionItemType type)
 {
     this.OwnerFile = ownerFile;
     this.Type      = type;
 }
Ejemplo n.º 16
0
 internal MotionFolderItem(MotionFile ownerFile) : base(ownerFile, MotionItemType.Folder)
 {
     childList = new List <MotionItemBase>();
 }
Ejemplo n.º 17
0
        public static PVector3 GetMotionValue(string fileId, string motionId, PVector3 linearValue, int maxSample = MotionItem.DefaultMaxSample, float tolerance = MotionItem.DefaultMaxTolerance)
        {
            MotionFile file = MotionStorage.GetFile(fileId);

            return(file.GetMotionValue(motionId, PMath.Clamp01(linearValue), maxSample, tolerance));
        }