Ejemplo n.º 1
0
        public void WriteScripts(AsmCollection asmCollection)
        {
            ArchiveFileEntry jsmEntry = (ArchiveFileEntry)_locationDirectory.Childs.TryGetValue(_name + ".jsm");

            if (jsmEntry == null)
            {
                return;
            }

            JsmHeader           header     = new JsmHeader();
            List <JsmGroup>     groups     = new List <JsmGroup>(8);
            List <JsmScript>    scripts    = new List <JsmScript>(32);
            List <JsmOperation> operations = new List <JsmOperation>(512);

            foreach (AsmModule module in asmCollection.GetOrderedModules())
            {
                JsmGroup group = new JsmGroup(module.ExecutionOrder, module.Label, (byte)module.Count, (JsmModuleType)module.Type);
                header.IncrementCount(group.Type);
                groups.Add(group);
            }

            foreach (AsmModule module in asmCollection.GetOrderedModulesByIndex())
            {
                foreach (AsmEvent evt in module.GetOrderedEvents())
                {
                    JsmScript script = new JsmScript((ushort)operations.Count, evt.Flag);
                    scripts.Add(script);

                    foreach (JsmOperation command in evt)
                    {
                        operations.Add(command);
                    }
                }
            }

            scripts.Add(new JsmScript((ushort)operations.Count, false));

            header.ScriptsOffset    = (ushort)(8 + groups.Count * 2);
            header.OperationsOffset = (ushort)(header.ScriptsOffset + scripts.Count * 2);

            using (JsmFileWriter jsmWriter = new JsmFileWriter(jsmEntry.OpenWritableCapacityStream()))
                jsmWriter.WriteScripts(header, groups, scripts, operations);

            //ArchiveFileEntry symEntry = (ArchiveFileEntry)_locationDirectory.Childs.TryGetValue(_name + ".sym");
            //if (symEntry == null)
            //    return;

            //using (SymFileWriter symWriter = new SymFileWriter(symEntry.OpenWritableCapacityStream()))
            //{
            //}
        }
Ejemplo n.º 2
0
        public void WriteScripts(AsmCollection scripts)
        {
            XmlElement node = _root.EnsureChildElement("Scripts");

            node.RemoveAll();

            bool isExists = scripts != null;

            node.SetBoolean("IsExists", isExists);

            if (!isExists)
            {
                return;
            }

            string scriptsFile = Path.ChangeExtension(_xmlPath, ".sct");

            using (Stream output = new FileStream(scriptsFile, FileMode.Create, FileAccess.Write, FileShare.None))
                using (BinaryWriter bw = new BinaryWriter(output, Encoding.UTF8))
                {
                    bw.Write("FF8S");
                    bw.Write(scripts.Count);

                    foreach (AsmModule module in scripts.GetOrderedModulesByIndex())
                    {
                        bw.Write(module.ExecutionOrder);
                        bw.Write(module.Label);
                        bw.Write(module.Title);
                        bw.Write((int)module.Type);
                        bw.Write(module.Count);

                        foreach (AsmEvent script in module.GetOrderedEvents())
                        {
                            bw.Write(script.Title);
                            bw.Write(script.Count);

                            foreach (JsmOperation operation in script)
                            {
                                bw.Write(operation.Operation);
                            }
                        }
                    }
                }
        }