示例#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();
                    }
                }
            }
        }
示例#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;
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            //Hak.HakHeader read = Hak.HakHeader.Read("01_don_2da.hak");
            //List<Hak.HakKeyEntry> keys = new List<Hak.HakKeyEntry>();
            //List<Hak.HakResEntry> res = new List<Hak.HakResEntry>();
            //FileStream stream = File.OpenRead("01_don_2da.hak");
            //stream.Seek(read.OffsetToKeyList, SeekOrigin.Begin);
            //BinaryReader reader = new BinaryReader(stream);
            //for (int i = 0; i < read.EntryCount; ++i)
            //{
            //  keys.Add(Hak.HakKeyEntry.Read(reader));
            //}
            //for (int i = 0; i < read.EntryCount; ++i)
            //{
            //  res.Add(Hak.HakResEntry.Read(reader));
            //}

            CTCore.SetArgs(args);

            if (args.Length > 0)
            {
                CTCore.OpenProject(args[0]);
            }
            else
            {
                CTCore.OpenProject("");
            }
            if (CTCore.GetOpenProject() != null)
            {
                CTCore.GetOpenProject().CompileProject();
            }
            else
            {
                CTDebug.Error("Could not find manifest.ctproj.");
            }

            if (CTDebug.HasError)
            {
                Console.WriteLine("Cloaktower completed, with errors.");
                Console.WriteLine("Press any key to continue.");
                if (!Console.IsOutputRedirected)
                {
                    Console.ReadKey();
                }
            }
        }