コード例 #1
0
        public void SetEntry(UInt64 key, string value)
        {
            StubbleEntry stblentry;
            StringSource source = TryGetValue(key, StringSource.All, out stblentry);

            switch (source)
            {
            case StringSource.None:
                stblentry        = new StubbleEntry();
                stblentry.Source = new StubbleSource();
                break;

            case StringSource.Modified:
                stblentry.Value = value;
                return;

            default:
                StubbleEntry origentry = stblentry;
                stblentry                    = new StubbleEntry();
                stblentry.Source             = new StubbleSource();
                stblentry.Source.SourceFile  = origentry.Source.SourceFile;
                stblentry.Source.SourceTable = origentry.Source.SourceTable;
                break;
            }
            stblentry.Value = value;
            Dictionary <UInt64, StubbleEntry> langlist;

            if (!mModifiedEntries.TryGetValue(CurrentLanguage, out langlist))
            {
                langlist = new Dictionary <ulong, StubbleEntry>();
                mModifiedEntries[CurrentLanguage] = langlist;
            }
            langlist[key] = stblentry;
        }
コード例 #2
0
        public StringSource TryGetValue(UInt64 key, StringSource source, out StubbleEntry value)
        {
            if (source == StringSource.Display)
            {
                source = mCurrentSource;
            }

            if ((source & StringSource.Modified) != 0 && TryGetValue(mModifiedEntries, key, out value))
            {
                return(StringSource.Modified);
            }
            if ((source & StringSource.Loaded) != 0 && TryGetValue(mLoadedEntries, key, out value))
            {
                return(StringSource.Loaded);
            }
            if ((source & StringSource.Game) != 0 && GlobalEntries.TryGetValue(key, out value))
            {
                return(StringSource.Game);
            }
            value = null;
            return(StringSource.None);
        }
コード例 #3
0
 private bool TryGetValue(Languages targetlang, Dictionary<Languages, Dictionary<UInt64, StubbleEntry>> source, UInt64 key, out StubbleEntry value)
 {
     Dictionary<UInt64, StubbleEntry> entry;
     if (!source.TryGetValue(targetlang, out entry))
     {
         value = null;
         return false;
     }
     return entry.TryGetValue(key, out value);
 }
コード例 #4
0
 private bool TryGetValue(Dictionary<Languages, Dictionary<UInt64, StubbleEntry>> source, UInt64 key, out StubbleEntry value)
 {
     return TryGetValue(mCurrentLanguage, source, key, out value);
 }
コード例 #5
0
        public StringSource TryGetValue(UInt64 key, StringSource source, out StubbleEntry value)
        {
            if (source == StringSource.Display)
                source = mCurrentSource;

            if ((source & StringSource.Modified) != 0 && TryGetValue(mModifiedEntries, key, out value))
                return StringSource.Modified;
            if ((source & StringSource.Loaded) != 0 && TryGetValue(mLoadedEntries, key, out value))
                return StringSource.Loaded;
            if ((source & StringSource.Game) != 0 && GlobalEntries.TryGetValue(key, out value))
                return StringSource.Game;
            value = null;
            return StringSource.None;
        }
コード例 #6
0
 public StringSource TryGetValue(UInt64 key, out StubbleEntry value)
 {
     return TryGetValue(key, StringSource.Display, out value);
 }
コード例 #7
0
 public void SetEntry(UInt64 key, string value)
 {
     StubbleEntry stblentry;
     StringSource source = TryGetValue(key, StringSource.All, out stblentry);
     switch (source)
     {
         case StringSource.None:
             stblentry = new StubbleEntry();
             stblentry.Source = new StubbleSource();
             break;
         case StringSource.Modified:
             stblentry.Value = value;
             return;
         default:
             StubbleEntry origentry = stblentry;
             stblentry = new StubbleEntry();
             stblentry.Source = new StubbleSource();
             stblentry.Source.SourceFile = origentry.Source.SourceFile;
             stblentry.Source.SourceTable = origentry.Source.SourceTable;
             break;
     }
     stblentry.Value = value;
     Dictionary<UInt64, StubbleEntry> langlist;
     if (!mModifiedEntries.TryGetValue(CurrentLanguage, out langlist))
     {
         langlist = new Dictionary<ulong, StubbleEntry>();
         mModifiedEntries[CurrentLanguage] = langlist;
     }
     langlist[key] = stblentry;
 }
コード例 #8
0
        public int LoadEntries(StringSource target, StubbleSource source, Languages lang, OverwriteMode overwrite, IEnumerable<KeyValuePair<UInt64, string>> entries)
        {
            if (source.SourceTable == DBPFReference.MinValue && overwrite != OverwriteMode.All && overwrite != OverwriteMode.None)
                throw new InvalidOperationException();

            Dictionary<UInt64, StubbleEntry> targetlist;
            if (target == StringSource.Modified)
            {
                if (!mModifiedEntries.TryGetValue(lang, out targetlist))
                {
                    targetlist = new Dictionary<ulong, StubbleEntry>();
                    mModifiedEntries[lang] = targetlist;
                }
            }
            else if (target == StringSource.Loaded)
            {
                if (!mLoadedEntries.TryGetValue(lang, out targetlist))
                {
                    targetlist = new Dictionary<ulong, StubbleEntry>();
                    mLoadedEntries[lang] = targetlist;
                }
            }
            else
            {
                throw new InvalidOperationException();
            }

            int added = 0;
            foreach (KeyValuePair<UInt64, string> entry in entries)
            {
                if (overwrite != OverwriteMode.All)
                {
                    StubbleEntry oldentry;
                    if (targetlist.TryGetValue(entry.Key, out oldentry))
                    {
                        if (overwrite == OverwriteMode.None)
                            continue;

                        if (overwrite == OverwriteMode.Priority)
                        {
                            if ((UInt32)source.SourceTable.Instance >= (UInt32)oldentry.Source.SourceTable.Instance)
                                continue;
                        }
                        else
                        {
                            if (source.SourceTable != oldentry.Source.SourceTable
                                && (UInt32)source.SourceTable.Instance >= (UInt32)oldentry.Source.SourceTable.Instance)
                                continue;
                        }
                    }
                }

                StubbleEntry newentry = new StubbleEntry();
                newentry.Value = entry.Value;
                newentry.Source = source;
                targetlist[entry.Key] = newentry;
                added++;
            }
            return added;
        }
コード例 #9
0
        private bool TryGetValue(Languages targetlang, Dictionary <Languages, Dictionary <UInt64, StubbleEntry> > source, UInt64 key, out StubbleEntry value)
        {
            Dictionary <UInt64, StubbleEntry> entry;

            if (!source.TryGetValue(targetlang, out entry))
            {
                value = null;
                return(false);
            }
            return(entry.TryGetValue(key, out value));
        }
コード例 #10
0
 private bool TryGetValue(Dictionary <Languages, Dictionary <UInt64, StubbleEntry> > source, UInt64 key, out StubbleEntry value)
 {
     return(TryGetValue(mCurrentLanguage, source, key, out value));
 }
コード例 #11
0
 public StringSource TryGetValue(UInt64 key, out StubbleEntry value)
 {
     return(TryGetValue(key, StringSource.Display, out value));
 }
コード例 #12
0
        public int LoadEntries(StringSource target, StubbleSource source, Languages lang, OverwriteMode overwrite, IEnumerable <KeyValuePair <UInt64, string> > entries)
        {
            if (source.SourceTable == DBPFReference.MinValue && overwrite != OverwriteMode.All && overwrite != OverwriteMode.None)
            {
                throw new InvalidOperationException();
            }

            Dictionary <UInt64, StubbleEntry> targetlist;

            if (target == StringSource.Modified)
            {
                if (!mModifiedEntries.TryGetValue(lang, out targetlist))
                {
                    targetlist             = new Dictionary <ulong, StubbleEntry>();
                    mModifiedEntries[lang] = targetlist;
                }
            }
            else if (target == StringSource.Loaded)
            {
                if (!mLoadedEntries.TryGetValue(lang, out targetlist))
                {
                    targetlist           = new Dictionary <ulong, StubbleEntry>();
                    mLoadedEntries[lang] = targetlist;
                }
            }
            else
            {
                throw new InvalidOperationException();
            }

            int added = 0;

            foreach (KeyValuePair <UInt64, string> entry in entries)
            {
                if (overwrite != OverwriteMode.All)
                {
                    StubbleEntry oldentry;
                    if (targetlist.TryGetValue(entry.Key, out oldentry))
                    {
                        if (overwrite == OverwriteMode.None)
                        {
                            continue;
                        }

                        if (overwrite == OverwriteMode.Priority)
                        {
                            if ((UInt32)source.SourceTable.Instance >= (UInt32)oldentry.Source.SourceTable.Instance)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            if (source.SourceTable != oldentry.Source.SourceTable &&
                                (UInt32)source.SourceTable.Instance >= (UInt32)oldentry.Source.SourceTable.Instance)
                            {
                                continue;
                            }
                        }
                    }
                }

                StubbleEntry newentry = new StubbleEntry();
                newentry.Value        = entry.Value;
                newentry.Source       = source;
                targetlist[entry.Key] = newentry;
                added++;
            }
            return(added);
        }