Пример #1
0
        public void Load(bool reWrite = true)
        {
            List <LanPair> tmpPairs = new List <LanPair>();

            lanPairLoaders.ForEach((loader) => {
                List <LanPair> result = loader.Invoke();
                if (result != null && result.Count > 0)
                {
                    tmpPairs.AddRange(result);
                }
            });
            tmpPairs.ForEach((tmpPair) => {
                LanPair pair = lanPairs.Find((p) => { return(p.Lan == tmpPair.Lan && p.key == tmpPair.key); });
                if (pair != null && reWrite && pair.Value != tmpPair.Value)
                {
                    pair.Value = tmpPair.Value;
                }
                else
                {
                    lanPairs.Add(tmpPair);
                }
            });
            tmpPairs.Clear();
            Fresh();
        }
Пример #2
0
            private string GetValueInPairs()
            {
                LanPair pair = Pairs.Find(p => { return(p.Lan == CurLan); });

                if (pair == null)
                {
                    pair = Pairs.Find(p => { return(p.Lan == Fallback); });
                }
                return(pair == null ? string.Empty : pair.Value);
            }
Пример #3
0
        public void Load(Func <List <LanPair> > loader, bool reWrite = true)
        {
            List <LanPair> tmpPairs = loader.Invoke();

            tmpPairs.ForEach((tmpPair) => {
                LanPair pair = lanPairs.Find((p) => { return(p.Lan == tmpPair.Lan && p.key == tmpPair.key); });
                if (pair != null && reWrite && pair.Value != tmpPair.Value)
                {
                    pair.Value = tmpPair.Value;
                }
                else
                {
                    lanPairs.Add(tmpPair);
                }
            });
            tmpPairs.Clear();
            Fresh();
        }
Пример #4
0
 public void DeleteLanPair(LanPair pair)
 {
     lanPairs.Remove(pair);
 }
Пример #5
0
            private void AddLanPairFunc()
            {
                if (window.lanKeys.Count == 0)
                {
                    return;
                }
                Rect rect;

                this.EBeginHorizontal(out rect, Styles.Fold)
                .Foldout(ref createLanPairFlodon, "Create LanPair", true)
                .EEndHorizontal()
                .Pan(() =>
                {
                    if (!createLanPairFlodon)
                    {
                        return;
                    }
                    if (tmpLanPair == null)
                    {
                        tmpLanPair = new LanPair()
                        {
                            key = window.lanKeys[0]
                        }
                    }
                    ;
                    if (hashID == 0)
                    {
                        hashID = "CreateView".GetHashCode();
                    }
                    this.DrawVertical(() =>
                    {
                        this.BeginHorizontal()
                        .Label("Lan", GUILayout.Width(describeWidth))
                        .Pan(() => { tmpLanPair.Lan = (SystemLanguage)EditorGUILayout.EnumPopup(tmpLanPair.Lan); })
                        .EndHorizontal()
                        .BeginHorizontal()
                        .Label("Key", GUILayout.Width(describeWidth))
                        .Label(tmpLanPair.key)
                        .Label(EditorGUIUtility.IconContent("editicon.sml"), GUILayout.Width(smallBtnSize))
                        .EndHorizontal()
                        .Pan(() => {
                            Rect pos   = GUILayoutUtility.GetLastRect();
                            int ctrlId = GUIUtility.GetControlID(hashID, FocusType.Keyboard, pos);
                            {
                                if (DropdownButton(ctrlId, pos, new GUIContent(string.Format("Key: {0}", tmpLanPair.key))))
                                {
                                    int index = -1;
                                    for (int i = 0; i < window.lanKeys.Count; i++)
                                    {
                                        if (window.lanKeys[i] == tmpLanPair.key)
                                        {
                                            index = i; break;
                                        }
                                    }
                                    SearchablePopup.Show(pos, window.lanKeys.ToArray(), index, (i, str) =>
                                    {
                                        tmpLanPair.key = str;
                                        window.Repaint();
                                    });
                                }
                            }
                        })
                        .BeginHorizontal()
                        .Label("Val", GUILayout.Width(describeWidth))
                        .TextField(ref tmpLanPair.Value)
                        .EndHorizontal()
                        .BeginHorizontal()
                        .FlexibleSpace()
                        .Button(() => {
                            //createLanPairFlodon = false;
                            window.AddLanPair(tmpLanPair);
                            //tmpLanPair = null;
                        }, Contents.OK)
                        .EndHorizontal();
                    }, Styles.BG);
                });
            }