Esempio n. 1
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;
            }
        }
Esempio n. 2
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();
                }
            }
        }