Exemplo n.º 1
0
 public static void AddString(StringKey sk)
 {
     if (Exists(sk.Key))
     {
         // String key exists globally
         _strings[sk.Key].MergeWith(sk); // Merges strings
     }
     else
     {
         // String key doesn't exist globally
         // - Adds to global collection
         _strings.Add(sk.Key, sk);
     }
 }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        public FString(string value)
        {
            if (!IsValidValue(value))
            {
                throw new Exception();
            }
            _key = CalculateHash(value);

            if (_key == 0)
            {
                // Adds null if not already present
                if (!StringKey.ContainsStringKey(0))
                {
                    StringKey.UpdateValue(0, "");
                }
                return;
            }

            StringKey.UpdateValue(_key, value);
        }
Exemplo n.º 5
0
        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);
        }