Example #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()))
            //{
            //}
        }
Example #2
0
        public static void HiResToGameData(GameFont gameFont)
        {
            using (DisposableStack disposables = new DisposableStack(2))
            {
                GLTexture leftTexture;
                GLTexture rightTexture;
                GLTextureFactory.HorizontalSplit(gameFont.CharactersImage.Layer, out leftTexture, out rightTexture);
                disposables.Add(leftTexture);
                disposables.Add(rightTexture);

                ArchiveDirectoryEntry mainDirectory  = Archives.GetEntry <ArchiveDirectoryEntry>(GameFontReader.MainPath);
                ArchiveDirectoryEntry menuDirectory  = Archives.GetEntry <ArchiveDirectoryEntry>(GameFontReader.MenuPath);
                ArchiveDirectoryEntry hiresDirectory = menuDirectory.GetChildEntry <ArchiveDirectoryEntry>(GameFontReader.HiResDirectoryName);
                ArchiveFileEntry      tdwEntry       = mainDirectory.GetChildEntry <ArchiveFileEntry>(GameFontReader.HiResCharactersWidthsFileName);
                ArchiveFileEntry      image01        = hiresDirectory.GetChildEntry <ArchiveFileEntry>(GameFontReader.HiResFontImage1FileName);
                ArchiveFileEntry      image02        = hiresDirectory.GetChildEntry <ArchiveFileEntry>(GameFontReader.HiResFontImage2FileName);

                using (Stream output = tdwEntry.OpenWritableCapacityStream())
                    using (TdwFileWriter tdwWriter = new TdwFileWriter(output))
                    {
                        tdwWriter.WriteFontCharactersWidths(gameFont.CharactersWidths);
                        tdwEntry.UpdateMetrics((int)output.Position, tdwEntry.ContentOffset, Compression.None);
                    }

                using (Stream output = image01.OpenWritableCapacityStream())
                    using (TexFileWriter texWriter = new TexFileWriter(output))
                    {
                        texWriter.WriteImage(leftTexture, gameFont.CharactersImage.Palettes);
                        image01.UpdateMetrics((int)output.Position, image01.ContentOffset, Compression.None);
                    }

                using (Stream output = image02.OpenWritableCapacityStream())
                    using (TexFileWriter texWriter = new TexFileWriter(output))
                    {
                        texWriter.WriteImage(rightTexture, gameFont.CharactersImage.Palettes);
                        image02.UpdateMetrics((int)output.Position, image02.ContentOffset, Compression.None);
                    }

                Archives.GetInfo(ArchiveName.Main).Update();
                Archives.GetInfo(ArchiveName.Menu).Update();
            }
        }
Example #3
0
        public void WriteMonologues(LocalizableStrings monologues)
        {
            ArchiveFileEntry msdEntry = (ArchiveFileEntry)_locationDirectory.Childs.TryGetValue(_name + ".msd");

            if (msdEntry == null)
            {
                if (!monologues.IsNullOrEmpty())
                {
                    throw new NotImplementedException();
                }

                return;
            }

            using (Stream output = msdEntry.OpenWritableCapacityStream())
                using (MsdFileWriter msdWriter = new MsdFileWriter(output))
                {
                    msdWriter.WriteAllMonologues(monologues.Select(m => m.Current));
                    msdEntry.UpdateMetrics((int)output.Position, msdEntry.ContentOffset, Compression.None);
                }
        }