コード例 #1
0
        public override string ToString()
        {
            StringKey sk = StringKey.Find(_globalKey);

            if (sk == null)
            {
                return("???");
            }

            // Base directory in string tables do not contain English strings for whatever reason
            string text = (sk.GetValue() == null) ? sk.GetValue(Language.Japanese) : sk.GetValue();

            return((text == null) ? "???" : text);
        }
コード例 #2
0
ファイル: HKey.cs プロジェクト: PikminGuts92/BFForever
        internal HKey Extend(string extension)
        {
            if (!IsValidValue(extension))
            {
                throw new Exception(InvalidValueMessage());
            }

            ulong newKey = HKey.GetHash(extension, _key);

            if (StringKey.ContainsStringKey(_key))
            {
                // Adds new value
                string newValue = StringKey.GetValue(_key, Localization.English) + extension;
                StringKey.UpdateValue(newKey, newValue);
                return(new HKey(newKey));
            }

            return(new HKey(newKey));
        }
コード例 #3
0
ファイル: RiffFile.cs プロジェクト: PikminGuts92/BFForever
        private List <StringTable> CreateStringTables(List <ZObject> zobjects)
        {
            List <StringTable> tables = new List <StringTable>();
            var groups = zobjects.Where(x => !(x is StringTable)).GroupBy(x => x.DirectoryPath);

            foreach (var group in groups)
            {
                if (group.Key.Key != 0)
                {
                    // Creates shared string tables
                    foreach (HKey local in Global.StringTableLocalizationsOnDisc)
                    {
                        List <FString> strings = group.SelectMany(x => x.GetAllStrings()).Distinct().ToList();

                        HKey        localGroupDirectory = group.Key.Extend("." + local);
                        StringTable table = new StringTable(localGroupDirectory, group.Key.GetParentDirectory(), StringTable.GetLocalization(local));

                        // Adds strings from zobjects
                        foreach (FString str in strings)
                        {
                            table.Strings.Add(str.Key, StringKey.GetValue(str.Key, table.Localization));
                        }

                        // Adds strings from table (Directory string)
                        foreach (FString str in table.GetAllStrings().Where(x => !table.Strings.ContainsKey(x)))
                        {
                            table.Strings.Add(str, StringKey.GetValue(str.Key, table.Localization));
                        }

                        tables.Add(table);
                    }

                    continue;
                }

                // Creates string table for singular zobject (Uses file path)
                foreach (ZObject obj in group)
                {
                    List <FString> strings = obj.GetAllStrings();

                    foreach (HKey local in Global.StringTableLocalizationsOnDisc)
                    {
                        HKey        objectDirectory = obj.FilePath.Extend("." + local);
                        StringTable table           = new StringTable(objectDirectory, obj.FilePath.GetParentDirectory(), StringTable.GetLocalization(local));

                        // Adds strings from zobjects
                        foreach (FString str in strings)
                        {
                            table.Strings.Add(str.Key, StringKey.GetValue(str.Key, table.Localization));
                        }

                        // Adds strings from table (Directory string)
                        foreach (FString str in table.GetAllStrings().Where(x => !table.Strings.ContainsKey(x)))
                        {
                            table.Strings.Add(str, StringKey.GetValue(str.Key, table.Localization));
                        }

                        tables.Add(table);
                    }
                }
            }

            return(tables);
        }