Example #1
0
        private static FileSystemOrderItem AddFileTagItem(FileListFile originalFile, uint fileId)
        {
            //find tag item
            var publishInfo = PublishInfo.GetPublishInfo(originalFile.FileInfo);
            FileSystemTagItem tagItem;

            if (TagItems.ContainsKey(publishInfo))
            {
                tagItem = TagItems[publishInfo];
            }
            else
            {
                tagItem = new FileSystemTagItem
                {
                    Tag = publishInfo.Tag
                };
                TagItems.Add(publishInfo, tagItem);
                FileSystem.TagItems.Add(tagItem);
            }

            //find name item
            string resourceName = originalFile.ResourceName;

            if (tagItem != null)
            {
                var nameItems = tagItem.NameItems;
                var nameItem  = nameItems.FirstOrDefault(resourceMapNameItem => resourceMapNameItem.Name == resourceName);

                if (nameItem == null)
                {
                    nameItem = new FileSystemNameItem {
                        Name = resourceName
                    };
                    nameItems.Add(nameItem);
                }

                //find order item
                uint order      = originalFile.Order;
                var  orderItems = nameItem.OrderItems;
                var  orderItem  = orderItems.FirstOrDefault(resourceMapOrderItem => resourceMapOrderItem.Order == order);
                if (orderItem == null)
                {
                    orderItem = new FileSystemOrderItem
                    {
                        Order  = order,
                        FileId = fileId
                    };
                    orderItems.Add(orderItem);
                    return(orderItem);
                }
                else
                {
                    var prevItem = FileListGenerator.GetFileName(orderItem.FileId);
                    Logger.LogAll("\tDuplicate tag item:{0} in {1} & {2}\r\n", resourceName, originalFile, prevItem);
                }
            }
            return(null);
        }
Example #2
0
        private void CopyAudio(FileListFile audioFile)
        {
            var packageInfo = PublishInfo.GetPublishInfo(audioFile.FileInfo.FullName);

            if (packageInfo.IsPublish(PublishTarget.Current))
            {
                string tempFilePath = PathManager.OutputPath + Path.AltDirectorySeparatorChar.ToString() + PathManager.AudioDirectoryName + Path.AltDirectorySeparatorChar.ToString() + audioFile.FileInfo.Name;
                audioFile.FileInfo.CopyTo(tempFilePath);
            }
        }
        public void Analyze()
        {
            StringTables.Clear();
            mNameGroups.Clear();

            Logger.LogAllLine("Analyze StringTable================>");
            var reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Jet\4.0\Engines\Excel", true);

            reg.SetValue("TypeGuessRows", 0);

            var validNames = Enum.GetNames(typeof(PublishLanguages));
            var tabelNames = ExcelHelper.GetExcelTableNames(PathManager.InputConfigStringTablePath.FullName);

            foreach (string tableName in tabelNames)
            {
                string pureTableName = tableName.Replace("$", String.Empty).Replace("'", String.Empty).Replace(TableName, String.Empty);
                bool   isValidTable  = validNames.Any(pureTableName.Contains);
                if (!isValidTable || !tableName.Contains(TableName))
                {
                    continue;
                }

                var    table        = ExcelHelper.LoadDataFromExcel(PathManager.InputConfigStringTablePath.FullName, tableName);
                string resourceName = tableName.Replace("$", String.Empty);
                var    packageInfo  = PublishInfo.GetPublishInfo(resourceName);


                var stringTable = GetOrCreateStringTable(packageInfo);
                foreach (DataRow row in table.Rows)
                {
                    bool isValid   = true;
                    bool isAllNull = true;
                    for (int i = 0; i < row.ItemArray.Length; i++)
                    {
                        if (row.IsNull(i))
                        {
                            isValid = false;
                        }
                        else
                        {
                            isAllNull = false;
                        }
                    }


                    if (isValid)
                    {
                        try
                        {
                            string name  = Convert.ToString(row["name"]);
                            uint   order = Convert.ToUInt32(row["order"]);
                            string str   = Convert.ToString(row["value"]);

                            string resultStr = ExcelHelper.ConvertToUTF8(str);


                            Add(stringTable, name, order, resultStr);
                        }
                        catch (Exception ex)
                        {
                            Logger.LogErrorLine(ex.Message);
                            ExcelHelper.PrintRow(row);
                        }
                    }
                    else if (!isAllNull)
                    {
                        Logger.LogErrorLine("Invalid string table line:");
                        ExcelHelper.PrintRow(row);
                    }
                }

                //print
                var stringTableResult = Parse(stringTable);

                if ((PublishTarget.Current.PublishInfo.Language & packageInfo.Language) == packageInfo.Language)
                {
                    string tempPath = PathManager.OutputConfigPath + "/" + TableName +
                                      pureTableName + ".bin";
                    using (var file = File.Open(tempPath, FileMode.Create, FileAccess.ReadWrite))
                    {
                        Serializer.Serialize(file, stringTableResult);
                        Logger.LogAllLine("Generate:{0}", tempPath);
                    }

                    var resourceFile = new FileListFile(new FileInfo(tempPath), true, true);
                    FileSystemGenerator.AddFileAndTag(resourceFile);
                }
                else
                {
                    Logger.LogAllLine("Ignore:\t{0}", pureTableName);
                }
            }
        }
        public void Analyze()
        {
            Logger.LogAllLine("Analyze FuckyString================>");
            var reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Jet\4.0\Engines\Excel", true);

            reg.SetValue("TypeGuessRows", 0);

            var validNames = Enum.GetNames(typeof(PublishLanguages));
            var tabelNames = ExcelHelper.GetExcelTableNames(PathManager.InputConfigStringTablePath.FullName);

            foreach (string tableName in tabelNames)
            {
                string pureTableName = tableName.Replace("$", String.Empty).Replace("'", String.Empty).Replace(TableName, String.Empty);
                bool   isValidTable  = validNames.Any(pureTableName.Contains);
                if (!isValidTable || !tableName.Contains(TableName))
                {
                    continue;
                }

                var    table        = ExcelHelper.LoadDataFromExcel(PathManager.InputConfigStringTablePath.FullName, tableName);
                string resourceName = tableName.Replace("$", String.Empty);
                var    packageInfo  = PublishInfo.GetPublishInfo(resourceName);

                SortedDictionary <char, MyFuckyStringNode> rootNodes = new SortedDictionary <char, MyFuckyStringNode>();

                foreach (DataRow row in table.Rows)
                {
                    bool isValid   = true;
                    bool isAllNull = true;
                    for (int i = 0; i < row.ItemArray.Length; i++)
                    {
                        if (row.IsNull(i))
                        {
                            isValid = false;
                        }
                        else
                        {
                            isAllNull = false;
                        }
                    }


                    if (isValid)
                    {
                        try
                        {
                            string str       = Convert.ToString(row["Value"]).Trim();
                            string resultStr = ExcelHelper.ConvertToUTF8(str);

                            SortedDictionary <char, MyFuckyStringNode> nodes = rootNodes;
                            var chars = resultStr.ToCharArray();
                            for (int i = 0; i < chars.Length; ++i)
                            {
                                MyFuckyStringNode node;
                                if (!nodes.TryGetValue(chars[i], out node))
                                {
                                    node = new MyFuckyStringNode {
                                        Char = chars[i], IsFucky = i == chars.Length - 1
                                    };
                                    nodes.Add(chars[i], node);
                                }
                                nodes = node.Childs;
                                if (!node.IsFucky)
                                {
                                    node.IsFucky = i == chars.Length - 1;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.LogErrorLine(ex.Message);
                            ExcelHelper.PrintRow(row);
                        }
                    }
                    else if (!isAllNull)
                    {
                        Logger.LogErrorLine("Invalid string table line:");
                        ExcelHelper.PrintRow(row);
                    }
                }

                if ((PublishTarget.Current.PublishInfo.Language & packageInfo.Language) == packageInfo.Language)
                {
                    var config = new FuckyString();
                    foreach (var fuckyStringNode in rootNodes)
                    {
                        FuckyStringNode node = new FuckyStringNode();
                        fuckyStringNode.Value.Fill(node);
                        config.rootNodes.Add(node);
                    }

                    string tempPath = PathManager.OutputConfigPath + "/" + TableName +
                                      pureTableName + ".bin";
                    using (var file = File.Open(tempPath, FileMode.Create, FileAccess.ReadWrite))
                    {
                        Serializer.Serialize(file, config);
                        Logger.LogAllLine("Generate:{0}", tempPath);
                    }

                    var resourceFile = new FileListFile(new FileInfo(tempPath), true, true);
                    FileSystemGenerator.AddFileAndTag(resourceFile);
                }
                else
                {
                    Logger.LogAllLine("Ignore:\t{0}", pureTableName);
                }
            }
        }