public void AddTlkFile(TlkDocument doc)
 {
     if (doc != TlkDocument.DialogTlk)
     {
         m_subDocuments.Add(doc);
     }
 }
        public int GetIndex(int localRow, string subDoc)
        {
            if (subDoc == "tlk")
            {
                return(localRow);
            }
            else
            {
                int docZero = TlkDocument.UserTlkOffset;
                for (int docIndex = 0; docIndex < m_subDocuments.Count; ++docIndex)
                {
                    TlkDocument doc = m_subDocuments[docIndex];
                    if (doc.Name.ToLowerInvariant() == subDoc.ToLowerInvariant())
                    {
                        return(localRow + docZero);
                    }
                    else
                    {
                        docZero += doc.Contents.Length;
                    }
                }

                return(localRow + docZero);
            }
        }
Beispiel #3
0
        private void OpenDocument(CTDocument.DocumentType type, string name, string args = "")
        {
            if (name.ToLowerInvariant() == "all")
            {
                OpenAllDocuments(type, args);
                return;
            }

            switch (type)
            {
            case CTDocument.DocumentType.Table:
            {
                try
                {
                    CTDebug.Info("Opening Table: {0}", name);
                    _2da.TableDocument doc = new _2da.TableDocument(name);
                    if (args == "raw")
                    {
                        doc.LoadCompiled();
                    }
                    else if (args == "friendly")
                    {
                        doc.LoadFriendly();
                    }
                    else
                    {
                        doc.LoadNewest();
                    }
                    m_openDocuments.Add(name, doc);
                }
                catch (Exception e)
                {
                    CTDebug.Error("{0}: {1}", e.GetType().Name, e.Message);
                }
            }
            break;

            case CTDocument.DocumentType.TLK:
                if (name.ToLowerInvariant() != "dialog") // Don't open dialog.tlk as a document.
                {
                    CTDebug.Info("Opening TLK: {0}", name);
                    Tlk.TlkDocument doc = new Tlk.TlkDocument(name);
                    m_openDocuments.Add(name, doc);
                    m_tlkStack.AddTlkFile(doc);
                    doc.LoadCompiled();
                }
                break;
            }
        }
Beispiel #4
0
        public override void Compile()
        {
            List <TlkContents> ret      = new List <TlkContents>();
            List <TlkDocument> docStack = CTCore.GetOpenProject().GetTlkStack().GetDocuments();

            for (int i = 0; i < docStack.Count; ++i)
            {
                TlkDocument doc = docStack[i];
                CTDebug.Info("Writing from {0}.tlk ({1} lines)", doc.Name, doc.Contents.Length);
                ret.AddRange(doc.Contents);
            }

            try
            {
                TLKWriter.SaveFileContents(Path, ret.ToArray());
            }
            catch (Exception)
            {
                CTDebug.Error("Could not save {0}. Make sure the file is not in use.", Path);
            }
        }