Beispiel #1
0
        public void ReadManifest(string[] manifest)
        {
            ManifestPhase phase = ManifestPhase.Header;

            for (int i = 0; i < manifest.Length; ++i)
            {
                string        line = manifest[i].TrimStart();
                ManifestPhase parsePhase;
                if (Enum.TryParse <ManifestPhase>(line, out parsePhase))
                {
                    CTDebug.Info(parsePhase);
                    phase = parsePhase;
                    continue;
                }
                else if (line.Length > 0)
                {
                    string[] tok = line.Split(':');
                    switch (phase)
                    {
                    case ManifestPhase.Header:
                        break;

                    case ManifestPhase.Resource:
                        CTDebug.Info("Opening {0}", tok[1]);
                        AddResource((CTResourceType)Enum.Parse(typeof(CTResourceType), tok[0]), tok[1]);
                        break;

                    case ManifestPhase.Document:
                        if (tok.Length == 2)
                        {
                            OpenDocument((CTDocument.DocumentType)Enum.Parse(typeof(CTDocument.DocumentType), tok[0]), tok[1]);
                        }
                        else if (tok.Length == 3)
                        {
                            OpenDocument((CTDocument.DocumentType)Enum.Parse(typeof(CTDocument.DocumentType), tok[0]), tok[1], tok[2]);
                        }
                        break;

                    case ManifestPhase.Artifact:
                        this.AddArtifact(tok[0]);
                        break;
                    }
                }
            }

            foreach (CTDocument doc in m_openDocuments.Values)
            {
                if (doc is _2da.TableDocument)
                {
                    ((_2da.TableDocument)doc).ResolveReferences();
                    if (((_2da.TableDocument)doc).CanSave)
                    {
                        ((_2da.TableDocument)doc).SaveAll();
                    }
                }
            }
        }
Beispiel #2
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;
            }
        }