Exemplo n.º 1
0
 public void ResolveReferences()
 {
     if (HasUnresolvedReferences)
     {
         CTDebug.Info("Resolving references in {0}", Name);
         foreach (ColumnInfo col in m_columns)
         {
             if (col.Type == ColumnType.TableRef)
             {
                 TableDocument table = CTCore.GetOpenProject().GetDocument <TableDocument>(col.ReferenceTo);
                 table.PrintDuplicationWarnings();
             }
         }
         foreach (DataRow row in m_docRows)
         {
             row.ResolveReferences();
         }
         HasUnresolvedReferences = false;
     }
 }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
        public static void Run(string[] args)
        {
            string inDir, outDir;
            int    increment;

            inDir = "in";
            Console.WriteLine("Please enter how many lines to increment");
            increment = Int32.Parse(Console.ReadLine());
            //Console.WriteLine("Please enter the output directory");
            outDir = "out";

            foreach (string path in Directory.EnumerateFiles(inDir))
            {
                string fileName = path.Split('\\').Last();
                if (path.ToLowerInvariant().EndsWith(".mdb"))
                {
                    string[] nameParts = fileName.Split('.')[0].Split('_');
                    string   newName;
                    string   newNumberPart;
                    if (nameParts.Length != 4)
                    {
                        Cloaktower.CTDebug.Warn("Encountered bad filename: {0}", fileName);
                        File.Copy(path, Path.Combine(outDir, fileName), true);
                        continue;
                    }
                    else
                    {
                        string numberPart  = nameParts[3];
                        int    numberIndex = numberPart.IndexOfAny(new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }, 0);
                        int    number      = int.Parse(numberPart.Substring(numberIndex, numberPart.Length - numberIndex)) + increment;
                        newNumberPart = numberPart.Substring(0, numberIndex) + (number < 10?"0":"") + (number.ToString());

                        nameParts[3] = newNumberPart;
                        newName      = string.Join("_", nameParts);
                    }
                    MdbDocument doc = new Cloaktower.MDB.MdbDocument(path);
                    doc.Read(path);

                    string filePrefix = fileName.Split('.')[0];
                    foreach (MdbPacket packet in doc.GetPackets())
                    {
                        if (packet is NamedMdbPacket)
                        {
                            NamedMdbPacket named = (NamedMdbPacket)packet;
                            if (named.Name.Contents.ToLowerInvariant() == (filePrefix.ToLowerInvariant()))
                            {
                                string[] subNameParts = named.Name.Contents.Split('_');
                                subNameParts[3] = newNumberPart;
                                CTDebug.Info("Renaming {0} to {1}", named.Name.Contents, string.Join("_", subNameParts));
                                named.Name.Contents = string.Join("_", subNameParts);
                            }
                        }
                    }
                    doc.Write(Path.Combine(outDir, newName + ".MDB"));
                }
                else
                {
                    File.Copy(path, Path.Combine(outDir, fileName), true);
                }
            }
        }
Exemplo n.º 4
0
        public static void Run(string[] args)
        {
            string inDir = "in", outDir = "out";

            //Console.WriteLine("Please enter the input directory");
            //inDir = Console.ReadLine();
            //Console.WriteLine("Please enter the output directory");
            //outDir = Console.ReadLine();

            foreach (string path in Directory.EnumerateFiles(inDir))
            {
                string fileName = path.Split('\\').Last();
                if (path.ToLowerInvariant().EndsWith(".mdb"))
                {
                    string[] nameParts = fileName.Split('.')[0].Split('_');
                    string   newName;
                    int      number;
                    if (nameParts.Length != 3)
                    {
                        Cloaktower.CTDebug.Warn("Encountered bad filename: {0}", fileName);
                        File.Copy(path, Path.Combine(outDir, fileName), true);
                        continue;
                    }
                    else
                    {
                        number       = int.Parse(nameParts[2].Substring(4, 2)) + 30;
                        nameParts[2] = nameParts[2].Substring(0, 4) + (number).ToString();
                        newName      = string.Join("_", nameParts);
                    }
                    MdbDocument doc = new Cloaktower.MDB.MdbDocument(path);
                    doc.Read(path);

                    string filePrefix = fileName.Split('.')[0];
                    foreach (MdbPacket packet in doc.GetPackets())
                    {
                        if (packet is NamedMdbPacket)
                        {
                            NamedMdbPacket named = (NamedMdbPacket)packet;
                            if (named.Signature == "SKIN")
                            {
                                string[] split = named.Name.Contents.Split('_');
                                split[2] = split[2].Substring(0, split[2].Length - 2) + (number).ToString();
                                string newInternalName = named.Name.Contents.Substring(0, named.Name.Contents.Length - 2) + (number).ToString();
                                CTDebug.Info("Renaming {0} to {1}", named.Name.Contents, newInternalName);
                                named.Name.Contents = newInternalName;
                                if (split[2].Substring(0, 4) == "Head" && split.Length == 3)
                                {
                                    newName = newInternalName;
                                }
                            }
                            else if (named.Signature == "RIGD")
                            {
                                CTDebug.Warn("Found a RIGD in {0}", fileName);
                            }
                        }
                    }
                    doc.Write(Path.Combine(outDir, newName + ".mdb"));
                }
                else
                {
                    File.Copy(path, Path.Combine(outDir, fileName), true);
                }
            }
        }