Esempio n. 1
0
        void OnGUI()
        {
            PowerUIEditor.HelpBox("Named characters are things like   or ­. HTML5 introduced lots more of them so PowerUI includes both the HTML5 and HTML4 sets. By default, the HTML4 set is used (because it's smaller and has great coverage anyway; 2.6kb vs 29kb).");

            if (!BothSetsOk)
            {
                PowerUIEditor.WarnBox("Unable to find the named character sets. There should be files called Html4-Set.txt and Html5-Set.txt.");
                return;
            }

            bool useHtml5 = EditorGUILayout.Toggle("Use HTML5 Set", Html5SetInUse);

            if (useHtml5 != Html5SetInUse)
            {
                // Change set:
                ChangeSet(useHtml5);

                // Update value:
                Html5SetInUse = useHtml5;
            }
        }
Esempio n. 2
0
        void OnGUI()
        {
            if (AvailableTargets == null)
            {
                Setup();
            }

            PowerUIEditor.HelpBox("This simplifies translating your project by sending off any language file for auto translation. Please note that you will need to quality check the results.");

            /*
             * ShowAPIKey = EditorGUILayout.Foldout(ShowAPIKey,"API Key");
             *
             * if(ShowAPIKey){
             *      if(GUILayout.Button("Get Free API Key")){
             *              Application.OpenURL("http://help.kulestar.com/translate-powerui/#getAKey");
             *      }
             *
             *      // The translation key (Bing API Key):
             *      string result=EditorGUILayout.TextField("API Key",TranslationKey);
             *
             *      if(result!=TranslationKey){
             *              TranslationKey=result;
             *              SaveTranslationKey();
             *      }
             * }
             */

            // Translate from:
            GUILayout.Label("Variables File", EditorStyles.boldLabel);

            UnityEngine.Object o = SelectedFile;

            SelectedFile = EditorGUILayout.ObjectField(o, typeof(TextAsset), false);

            if (SelectedFile != o)
            {
                // They changed the file. Discover which language it is now.
                FindInformation();
            }

            // Translate to language:
            GUILayout.Label("Translate To", EditorStyles.boldLabel);
            SelectedTarget = EditorGUILayout.Popup(SelectedTarget, AvailableTargets);

            if (Translating)
            {
                GUILayout.Label("Translating..", EditorStyles.boldLabel);
            }
            else if (SelectedFile == null)
            {
                PowerUIEditor.WarnBox("Please select the file you'd like to translate.");
            }
            else if (TargetBasepath == null)
            {
                PowerUIEditor.WarnBox("The file you've selected isn't a suitable language file. It must be named with a 2 character language code, such as 'en.xml'.");
            }
            else
            {
                if (GUILayout.Button("Translate Now"))
                {
                    Perform();
                }

                string path = TargetPath;

                PowerUIEditor.HelpBox("From " + SourceLanguage + " into file " + path);

                if (File.Exists(path))
                {
                    PowerUIEditor.WarnBox("The target file exists and will be overwritten.");
                }
            }

            if (LatestError != null)
            {
                PowerUIEditor.ErrorBox(LatestError);
            }
            else if (LatestMessage != null)
            {
                PowerUIEditor.HelpBox(LatestMessage);
            }
        }
Esempio n. 3
0
        void OnGUI()
        {
            PowerUIEditor.HelpBox("Here's the CSS properties that PowerUI is currently recognising.");

            if (Properties == null)
            {
                Load();
            }

            // Dropdown list:
            int selected = EditorGUILayout.Popup(SelectedPropertyIndex, Properties);

            if (selected != SelectedPropertyIndex || SelectedProperty == null)
            {
                SelectedPropertyIndex = selected;
                LoadSelected();
            }

            // Detailed information about the selected property:
            if (SelectedProperty != null)
            {
                // Show the name:
                EditorGUILayout.LabelField(SelectedProperty.Name, EditorStyles.boldLabel);

                string hostName;

                // Get as a composite property:
                CssCompositeProperty composite = SelectedProperty as CssCompositeProperty;

                if (composite != null)
                {
                    // It's a composite property (e.g. font, animation etc).
                    // They set multiple properties at once.

                    EditorGUILayout.LabelField("Composite property");

                    hostName = SelectedProperty.Name;
                }
                else if (SelectedProperty.IsAlias)
                {
                    // Get as an alias:
                    CssPropertyAlias alias = SelectedProperty as CssPropertyAlias;

                    // e.g. color-r is an alias of color.

                    if (alias.Target == null)
                    {
                        // Hmm!
                        hostName = SelectedProperty.Name;

                        // It's not an alias property
                        EditorGUILayout.LabelField("Not an alias");
                    }
                    else
                    {
                        // Get the target of the alias:
                        string aliasedTo = alias.Target.Name;

                        // It's an alias property
                        EditorGUILayout.LabelField("Alias of " + aliasedTo);

                        hostName = aliasedTo;
                    }
                }
                else
                {
                    hostName = SelectedProperty.Name;

                    // It's not an alias property
                    EditorGUILayout.LabelField("Not an alias/ composite");
                }

                if (!string.IsNullOrEmpty(PropertyFile))
                {
                    PowerUIEditor.HelpBox("To find the source file, search for its name in camel case, like this:");

                    EditorGUILayout.SelectableLabel(PropertyFile);
                }

                if (SelectedProperty.NonStandard)
                {
                    PowerUIEditor.WarnBox("This property is non-standard or not on a standards track.");
                }
                else if (SelectedProperty.NamespaceName == "svg")
                {
                    if (GUILayout.Button("View Mozilla Docs (SVG)"))
                    {
                        Application.OpenURL("https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/" + hostName);
                    }
                }
                else
                {
                    if (GUILayout.Button("View Mozilla Docs"))
                    {
                        Application.OpenURL("https://developer.mozilla.org/en-US/docs/Web/CSS/" + hostName);
                    }
                }
            }
        }
        void OnGUI()
        {
            PowerUIEditor.HelpBox("This simplifies translating your game by sending off any language file for auto translation. Please note that you will need to quality check the results.");

            if (AvailableSource == null)
            {
                PowerUIEditor.WarnBox("No language folder found; Create a Resources/Languages/UI folder for use with localisation first.");
            }
            else if (AvailableSource.Length == 0)
            {
                PowerUIEditor.WarnBox("No source languages found. To translate, you must have at least one language in your Resources/Languages/UI folder.");
            }
            else
            {
                ShowAPIKey = EditorGUILayout.Foldout(ShowAPIKey, "API Key");

                if (ShowAPIKey)
                {
                    if (GUILayout.Button("Get Free API Key"))
                    {
                        Application.OpenURL("http://help.kulestar.com/translate-powerui/#getAKey");
                    }

                    // The translation key (Bing API Key):
                    string result = EditorGUILayout.TextField("API Key", TranslationKey);

                    if (result != TranslationKey)
                    {
                        TranslationKey = result;
                        SaveTranslationKey();
                    }
                }

                // Translate from language:
                GUILayout.Label("Translate From", EditorStyles.boldLabel);
                SelectedSource = EditorGUILayout.Popup(SelectedSource, AvailableSource);
                // Translate to language:
                GUILayout.Label("Translate To", EditorStyles.boldLabel);
                SelectedTarget = EditorGUILayout.Popup(SelectedTarget, AvailableTargets);

                if (Translating)
                {
                    GUILayout.Label("Translating..", EditorStyles.boldLabel);
                }
                else if (FileExists)
                {
                    GUILayout.Label("Target file exists - would you like to overwrite it?");

                    if (GUILayout.Button("Yes"))
                    {
                        FileExists = false;
                        Perform(true);
                    }

                    if (GUILayout.Button("Cancel"))
                    {
                        FileExists = false;
                    }
                }
                else if (GUILayout.Button("Translate Now"))
                {
                    Perform(false);
                }
            }
        }
        void OnGUI()
        {
            PowerUIEditor.HelpBox("Here's the XML tags (HTML, SVG etc) that PowerUI is currently recognising.");

            if (Tags == null)
            {
                Load();
            }

            // Dropdown list:
            int selected = EditorGUILayout.Popup(SelectedTagIndex, Tags);

            if (selected != SelectedTagIndex || SelectedTag == null)
            {
                SelectedTagIndex = selected;
                LoadSelected();
            }

            // Detailed information about the selected tag:
            if (SelectedTag != null)
            {
                // Show the name:
                EditorGUILayout.LabelField(TagName, EditorStyles.boldLabel);

                if (TagNamespace != "")
                {
                    EditorGUILayout.LabelField("In namespace " + TagNamespace);
                }

                if (!string.IsNullOrEmpty(TagName))
                {
                    PowerUIEditor.HelpBox("To find the source file, just search for its name in your project:");

                    EditorGUILayout.SelectableLabel(TagName);
                }

                if (NonStandard)
                {
                    PowerUIEditor.WarnBox("This tag is non-standard or not on a standards track.");
                }
                else if (TagNamespace == "xhtml")
                {
                    if (GUILayout.Button("View Mozilla Docs"))
                    {
                        Application.OpenURL("https://developer.mozilla.org/en-US/docs/Web/HTML/Element/" + TagName);
                    }
                }
                else if (TagNamespace == "svg")
                {
                    if (GUILayout.Button("View Mozilla Docs (SVG)"))
                    {
                        Application.OpenURL("https://developer.mozilla.org/en-US/docs/Web/SVG/Element/" + TagName);
                    }
                }
                else if (TagNamespace == "lang")
                {
                    PowerUIEditor.HelpBox("Used by localisation files.");
                }
                else
                {
                    PowerUIEditor.HelpBox("Custom XML namespace.");
                }
            }
        }