示例#1
0
 private void hook_KeyPressed(object sender, KeyPressedEventArgs e)
 {
     if (e.Key == BasicTeraData.HotkeysData.Paste.Key && e.Modifier == BasicTeraData.HotkeysData.Paste.Value)
     {
         CopyPaste.Paste();
     }
     else if (e.Key == BasicTeraData.HotkeysData.Reset.Key && e.Modifier == BasicTeraData.HotkeysData.Reset.Value)
     {
         Reset();
     }
     foreach (var copy in BasicTeraData.HotkeysData.Copy.Where(copy => e.Key == copy.Key && e.Modifier == copy.Modifier))
     {
         CopyPaste.Copy(PlayerData(), copy.Header, copy.Content, copy.Footer);
     }
 }
    private void OnGUI()
    {
        GUILayout.Label("Language Editor", EditorStyles.boldLabel);

        if (localizationMaster)
        {
            GUILayout.Label("Localization Master Found In Resources Folder.", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            var saveContent = new GUIContent("Save active language", "Save active language");
            var LoadContent = new GUIContent("Load active language", "Load active language");

            if (GUILayout.Button(saveContent))
            {
                localizationMaster.Save();
            }

            if (GUILayout.Button(LoadContent))
            {
                localizationMaster.Load();
            }

            EditorGUILayout.EndHorizontal();
            ShowAvailableLanguages = EditorGUILayout.Toggle("Show Available Languages", ShowAvailableLanguages);

            if (ShowAvailableLanguages)
            {
                EditAvailableLanguages = EditorGUILayout.BeginToggleGroup("Show Available Languages", EditAvailableLanguages);

                for (var i = 0; i < localizationMaster.AvailableLanguages.Count; i++)
                {
                    if (localizationMaster.AvailableLanguages[i] == LocalizationMaster.englishID)
                    {
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label(i.ToString(), EditorStyles.boldLabel, GUILayout.Width(20));
                        GUILayout.Label(localizationMaster.AvailableLanguages[i]);
                        var setContent = new GUIContent("Set English to active language", "Set _en to Active Language");

                        if (localizationMaster.LangIndex != i)
                        {
                            if (GUILayout.Button(setContent))
                            {
                                localizationMaster.SetLang(i);
                            }
                        }
                        else
                        {
                            GUILayout.Label("Active", GUILayout.Width(100));
                        }
                    }
                    else
                    {
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label(i.ToString(), EditorStyles.boldLabel, GUILayout.Width(20));
                        localizationMaster.AvailableLanguages[i] = EditorGUILayout.TextArea(localizationMaster.AvailableLanguages[i]);
                        var setContent = new GUIContent("Set Active", string.Format("Set {0} to Active Language", localizationMaster.AvailableLanguages[i]));

                        if (localizationMaster.LangIndex != i)
                        {
                            if (GUILayout.Button(setContent, GUILayout.Width(100)))
                            {
                                localizationMaster.SetLang(i);
                            }
                        }
                        else
                        {
                            GUILayout.Label("Active", GUILayout.Width(100));
                        }

                        var resetContent = new GUIContent("Reset Language", "Reset Entries to Key only");

                        if (GUILayout.Button(resetContent, GUILayout.Width(100)))
                        {
                            ResetLanguage(i);
                        }

                        var deleteContent = new GUIContent("X", "Delete Entry");

                        if (GUILayout.Button(deleteContent, GUILayout.Width(25)))
                        {
                            localizationMaster.AvailableLanguages.RemoveAt(i);
                        }
                    }

                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.BeginHorizontal();
                NewLangString = EditorGUILayout.TextArea(NewLangString);

                if (GUILayout.Button("Add New Language"))
                {
                    NewLanguage();
                }

                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndToggleGroup();
            }

            ShowLanguageEntries = EditorGUILayout.Toggle("Entries in the language Database. Show?", ShowLanguageEntries);

            if (ShowLanguageEntries)
            {
                for (var i = 0; i < localizationMaster.DictionaryData.Data.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label(i.ToString(), EditorStyles.boldLabel, GUILayout.Width(20));

                    localizationMaster.DictionaryData.Data[i] = new LocalizationDictionaryEntry(EditorGUILayout.TextArea(localizationMaster.DictionaryData.Data[i].Key, GUILayout.Width(position.width * 0.2f)),
                                                                                                EditorGUILayout.TextArea(localizationMaster.DictionaryData.Data[i].Data));

                    var copyContent = new GUIContent("C", "Copy Entry");

                    if (GUILayout.Button(copyContent, GUILayout.Width(25)))
                    {
                        CopyPaste.Copy(localizationMaster.DictionaryData.Data[i]);
                    }

                    var pasteContent = new GUIContent("P", "Paste Entry");

                    if (GUILayout.Button(pasteContent, GUILayout.Width(25)))
                    {
                        localizationMaster.DictionaryData.Data[i] = CopyPaste.Paste <LocalizationDictionaryEntry>();
                    }

                    var deleteContent = new GUIContent("X", "Delete Entry");

                    if (GUILayout.Button(deleteContent, GUILayout.Width(25)))
                    {
                        localizationMaster.DictionaryData.Data.RemoveAt(i);
                    }

                    EditorGUILayout.EndHorizontal();
                }

                if (GUILayout.Button("Add New Entry"))
                {
                    localizationMaster.DictionaryData.Data.Add(new LocalizationDictionaryEntry("newKey", "newData"));
                }
            }
        }
        else
        {
            GUILayout.Label("WARNING \n Localization Master NOT Found In Resources Folder.", EditorStyles.boldLabel);
            localizationMaster = Resources.Load(LocalizationMaster.DefaultLocation) as LocalizationMaster;
        }

        //groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Settings", groupEnabled);
        //myBool = EditorGUILayout.Toggle("Toggle", myBool);
        //myFloat = EditorGUILayout.Slider("Slider", myFloat, -3, 3);
        //EditorGUILayout.EndToggleGroup();
    }