public static void DeleteKeyFromNameDict(string key, bool useSort, bool usePrimary)
        {
            NameDict.Remove(key);
            NameOneMeaningDict.Remove(key);
            VietPhraseAndNameDict.Remove(key);
            VietPhraseOneMeaningDict.Remove(key);

            var selectedNameDict = usePrimary ? PrimaryNameDict : SecondaryNameDict;

            if (!selectedNameDict.Remove(key))
            {
                return;
            }

            var selectedNameDictPath = usePrimary
                ? DictionaryConfiguration.GetPrimaryNameDictPath()
                : DictionaryConfiguration.GetSecondaryNameDictPath();

            if (useSort)
            {
                SaveDictionaryToFileSorted(selectedNameDict, selectedNameDictPath);
            }
            else
            {
                SaveDictionaryToFile(selectedNameDict, selectedNameDictPath);
            }

            WriteNamesLog(key, "Deleted", usePrimary);
        }
Example #2
0
        public static bool ContainsName(string text, int startIndex, int length)
        {
            if (length < 2)
            {
                return(false);
            }
            if (NameDict.ContainsKey(text.Substring(startIndex, length)))
            {
                return(false);
            }
            int num  = startIndex + length - 1;
            int num2 = 2;

            for (int i = startIndex + 1; i <= num; i++)
            {
                for (int j = 20; j >= num2; j--)
                {
                    if (text.Length >= i + j && NameDict.ContainsKey(text.Substring(i, j)))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Example #3
0
    public Transform GetTransByName(string name)
    {
        Transform trans;

        if (!NameDict.TryGetValue(name, out trans))
        {
            return(null);
        }
        return(trans);
    }
Example #4
0
 private void Awake()
 {
     Instance = this;
 }
 public static string GetName(string key)
 {
     NameDict.TryGetValue(key, out var value);
     return(value);
 }
        public static void UpdateNameDict(string key, string value, bool useSort, bool usePrimary)
        {
            VietPhraseAndNameDict[key]    = value;
            VietPhraseOneMeaningDict[key] = value.Split('/', '|')[0];

            var selectedNameDict = usePrimary ? PrimaryNameDict : SecondaryNameDict;

            string action;

            if (selectedNameDict.ContainsKey(key))
            {
                selectedNameDict[key] = value;
                action = "Updated";
            }
            else
            {
                if (useSort)
                {
                    selectedNameDict[key] = value;
                }
                else if (usePrimary)
                {
                    selectedNameDict = PrimaryNameDict = AddEntryToDictionaryNoSort(selectedNameDict, key, value);
                }
                else
                {
                    selectedNameDict = SecondaryNameDict = AddEntryToDictionaryNoSort(selectedNameDict, key, value);
                }
                action = "Added";
            }
            WriteNamesLog(key, action, usePrimary);

            if (NameDict.ContainsKey(key))
            {
                NameDict[key]           = value;
                NameOneMeaningDict[key] = value.Split('/', '|')[0];
            }
            else if (useSort)
            {
                NameDict[key]           = value;
                NameOneMeaningDict[key] = value.Split('/', '|')[0];
            }
            else
            {
                NameDict           = AddEntryToDictionaryNoSort(NameDict, key, value);
                NameOneMeaningDict = AddEntryToDictionaryNoSort(NameOneMeaningDict, key, value.Split('/', '|')[0]);
            }

            var dictPath = usePrimary
                ? DictionaryConfiguration.GetPrimaryNameDictPath()
                : DictionaryConfiguration.GetSecondaryNameDictPath();

            if (useSort)
            {
                SaveDictionaryToFileSorted(selectedNameDict, dictPath);
            }
            else
            {
                SaveDictionaryToFile(selectedNameDict, dictPath);
            }
        }