Ejemplo n.º 1
0
        /// <summary>Draws a document dropdown (using GetDocuments).</summary>
        public static DocumentEntry DocumentDropdown(DocumentEntry selected)
        {
            if (AllDocumentNames_ == null)
            {
                // Load docs:
                GetDocuments(true);
            }

            if (AllDocuments_.Count == 0)
            {
                // Waiting for valid doc.
                PowerUIEditor.HelpBox("Waiting for documents (click this window after hitting play).");
                return(null);
            }

            // Draw a refresh button:
            if (GUILayout.Button("Refresh documents"))
            {
                // Refresh now:
                GetDocuments(true);
            }

            // Get index:
            int index = (selected == null) ? 0 : selected.Index;

            // Draw dropdown list now!
            int selectedIndex = EditorGUILayout.Popup(index, AllDocumentNames_);

            // Must always pull from all docs (as a refresh may result in the object changing).
            return(AllDocuments_[selectedIndex]);
        }
Ejemplo n.º 2
0
        void OnGUI()
        {
            PowerUIEditor.HelpBox("By default to prevent bloat, Emoji images are not included in the project. " +
                                  "Either add your own to Resources/Characters/ (e.g. 1f004.png by default), or download the Phantom Open Emoji set below.");

            DownloadPath = EditorGUILayout.TextField("Save to..", DownloadPath);

            if (IsDownloading)
            {
                GUILayout.Label("Downloading set.. (" + (Request.progress * 100f) + "%)", EditorStyles.boldLabel);
            }
            else if (Status == 1)
            {
                GUILayout.Label("Unpacking..", EditorStyles.boldLabel);
            }
            else if (Status == 2)
            {
                GUILayout.Label("Applying import settings..", EditorStyles.boldLabel);
            }
            else if (Status == 3)
            {
                GUILayout.Label("Import successful!", EditorStyles.boldLabel);
            }
            else if (GUILayout.Button("Download Icons"))
            {
                DownloadIcons();
            }
        }
Ejemplo n.º 3
0
        void OnGUI()
        {
            // Use the node from the DOM inspector:
            Node node = DomInspector.MouseOverNode;

            if (node == null)
            {
                PowerUIEditor.HelpBox("No node selected. Click on a node in the DOM inspector.");
                return;
            }

            string name = node.nodeName;

            if (name == null)
            {
                name = "(Unnamed node)";
            }

            bool refresh = GUILayout.Button("Refresh");

            GUILayout.Label(name);

            if (refresh || ComputedDataFor != node || ComputedNodeData == null)
            {
                try{
                    BuildString(node);
                }catch (Exception e) {
                    ComputedNodeData = "<b>Error whilst building node data</b>\r\n" + e.ToString();
                }
            }

            GUILayout.Label(ComputedNodeData);
        }
Ejemplo n.º 4
0
        void OnGUI()
        {
            bool previousValue = Precompiled;

            Precompiled = EditorGUILayout.Toggle("Precompile PowerUI", previousValue);
            PowerUIEditor.HelpBox("Ensure you have a backup first as this will move files. Highly recommended that you use this - PowerUI is a big library! Precompiles PowerUI such that it doesn't get built every time you change any of your scripts. Note that this precompiler can be used for your scripts too.");

            if (previousValue != Precompiled)
            {
                OnPrecompileChanged();
            }

            previousValue = EditorMode;
            EditorMode    = EditorGUILayout.Toggle("Editor Mode", previousValue);
            PowerUIEditor.HelpBox("Compile with the UNITY_EDITOR flag.");

            if (previousValue != EditorMode)
            {
                OnEditorModeChanged();
            }

            if (Precompiled && GUILayout.Button("Recompile"))
            {
                Recompile();
            }
        }
Ejemplo n.º 5
0
        void OnGUI()
        {
            // Doc dropdown:
            DocumentEntry entry = DomInspector.DocumentDropdown(Entry);

            if (entry == null)
            {
                return;
            }

            ReflowDocument reflowDoc = entry.Document as ReflowDocument;

            if (reflowDoc == null)
            {
                Entry = entry;
                PowerUIEditor.HelpBox("Not a suitable document (it can't be styled).");
                return;
            }

            if (Entry != entry)
            {
                // Changed!
                Entry            = entry;
                ComputedNodeData = null;

                // Rebuild list of stylesheets.
                RebuildSheets(reflowDoc);
            }

            // Draw a refresh button:
            if (GUILayout.Button("Refresh sheets"))
            {
                // Refresh now:
                RebuildSheets(reflowDoc);
            }

            // Draw dropdown list now!
            int selectedIndex = EditorGUILayout.Popup(SheetIndex, SheetNames);

            if (selectedIndex != SheetIndex || ComputedNodeData == null)
            {
                SheetIndex = selectedIndex;

                try{
                    BuildString(reflowDoc.styleSheets[SheetIndex]);
                }catch (Exception e) {
                    ComputedNodeData = "<b>Error whilst building node data</b>\r\n" + e.ToString();
                }
            }

            GUILayout.Label(ComputedNodeData);
        }
Ejemplo n.º 6
0
        /// <summary>Shows the UI.</summary>
        public void OnGUI()
        {
            bool previous = Active;

            Active = EditorGUILayout.Toggle(Name, previous);

            PowerUIEditor.HelpBox(Help);

            if (previous != Active)
            {
                Changed();
            }
        }
        void OnGUI()
        {
            if (Module == null)
            {
                GetModule();
            }

            // The precompile PowerUI tickbox:
            bool isPrecompiled     = Module.Precompiled;
            bool tickedPrecompiled = EditorGUILayout.Toggle("Precompile PowerUI", isPrecompiled);

            PowerUIEditor.HelpBox("Precompiles PowerUI. It will appear to freeze - backup first! You must also recompile each time you change platforms - see the Precompiler entry on the PowerUI wiki.");

            if (isPrecompiled != tickedPrecompiled)
            {
                // Compile/ revert:
                if (tickedPrecompiled)
                {
                    // Compile:
                    Module.Compile();
                }
                else
                {
                    // Revert:
                    Module.Revert();
                }
            }

            bool isEditorMode     = Module.EditorMode;
            bool tickedEditorMode = EditorGUILayout.Toggle("Editor Mode", isEditorMode);

            PowerUIEditor.HelpBox("Compile with the UNITY_EDITOR flag. Almost always leave this unchecked.");

            if (isEditorMode != tickedEditorMode)
            {
                // Update module value:
                Module.EditorMode = tickedEditorMode;

                if (Module.Precompiled)
                {
                    // Compile the module:
                    Module.Compile();
                }
            }

            if (isPrecompiled && GUILayout.Button("Recompile"))
            {
                // Compile the module now:
                Module.Compile();
            }
        }
Ejemplo n.º 8
0
        public static void Setup()
        {
            Translating = false;

            // Get the translation key, if we have one:
            // TranslationKey=GetTranslationKey();
            // Setup the foldout:
            // ShowAPIKey=(TranslationKey=="");

            // Setup the PowerUI path:
            PowerUIPath = PowerUIEditor.GetPowerUIPath();

            // Load the target languages:
            LoadAvailableLanguages();
        }
Ejemplo n.º 9
0
        void OnGUI()
        {
            if (Settings == null)
            {
                CreateSettings();
            }

            PowerUIEditor.HelpBox("If you're a new user, just hide the warning below. If you're upgrading from a previous version, you'll need to update all uses of element['attribute'] to the standard element.getAttribute and setAttribute instead. This is primarily used by custom elements. If you're not sure what you need to change, just tick the 'Show required changes' option below, and each line will error for you. If you don't want to use Javascript libraries anyway, use the legacy mode.");

            foreach (SettingTickbox setting in Settings)
            {
                // Draw it:
                setting.OnGUI();
            }
        }
Ejemplo n.º 10
0
        /// <summary>Sets up the module.</summary>
        private void GetModule()
        {
            // Create a precompileable module:
            Module = new Module("PowerUI");

            // Got source folders?
            if (Module.SourceFolders.Count == 0)
            {
                // Find PowerUI:
                string powerUIPath = PowerUIEditor.GetPowerUIPath();

                // Add the source folder(s) now:
                // (We don't precompile the managers because that would break references).
                Module.SourceFolders.Add(powerUIPath + "/Source");
            }
        }
Ejemplo n.º 11
0
        public static void WorldUI()
        {
            // Use a plane to describe the size/ shape of the WorldUI:
            GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);

            // We'll name it with something distinctive:
            plane.name = "My World UI";

            // Remove collider:
            MeshCollider mc = plane.GetComponent <MeshCollider>();

            if (mc != null)
            {
                GameObject.DestroyImmediate(mc);
            }

            // Set default rotation:
            plane.transform.rotation = Quaternion.Euler(270f, 180f, 0f);

            // Add a WorldUI Helper. It'll instance the WorldUI object when the game starts up
            // and destroy the mesh renderer/ filters.
            // (which is generally used from scripting anyway).
            plane.AddComponent <WorldUIHelper>();

            // Get the path to PowerUI:
            string powerUIPath = PowerUIEditor.GetPowerUIPath();

            if (string.IsNullOrEmpty(powerUIPath))
            {
                NoMaterial();
            }
            else
            {
                // Use the WorldUI Editor material:
                Material mat = AssetDatabase.LoadAssetAtPath(powerUIPath + "/Editor/worldUIMaterial.mat", typeof(Material)) as Material;

                if (mat == null)
                {
                    NoMaterial();
                }
                else
                {
                    // Apply it:
                    plane.GetComponent <MeshRenderer>().material = mat;
                }
            }
        }
        public static void ShowWindow()
        {
            // Show existing window instance. If one doesn't exist, make one.
            TranslateWindow = EditorWindow.GetWindow(typeof(AutoTranslate));

            // Give it a title:
            TranslateWindow.title = "Auto Translate";

            // Get the path to the Languages/UI folder:
            LanguagePath = GetLanguagePath();

            Translating = false;
            FileExists  = false;

            // Get the translation key, if we have one:
            TranslationKey = GetTranslationKey();
            // Setup the foldout:
            ShowAPIKey = (TranslationKey == "");

            // Setup the PowerUI path:
            PowerUIPath = PowerUIEditor.GetPowerUIPath();

            if (LanguagePath != "")
            {
                // Grab the language files:
                string[] files = Directory.GetFiles(LanguagePath);
                // Setup the available source array:
                AvailableSource = new string[files.Length];

                for (int i = 0; i < files.Length; i++)
                {
                    // Get the file name:
                    string[] pieces   = files[i].Replace("\\", "/").Split('/');
                    string   fileName = pieces[pieces.Length - 1];
                    // Drop the type:
                    pieces = fileName.Split('.');
                    // And put it as an available source language:
                    AvailableSource[i] = pieces[0];
                }
            }

            // Load the target languages:
            LoadAvailableLanguages();
        }
Ejemplo n.º 13
0
        void OnGUI()
        {
            PowerUIEditor.HelpBox("Named characters are things like &nbsp; or &shy;. 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;
            }
        }
        void OnGUI()
        {
            bool previousValue = IsolatePowerUI;

            IsolatePowerUI = EditorGUILayout.Toggle("Isolate UI classes", previousValue);
            PowerUIEditor.HelpBox("This isolates the 'UI' class inside the PowerUI namespace just incase you've got a class called UI of your own.");

            if (previousValue != IsolatePowerUI)
            {
                OnIsolateChanged();
            }

            previousValue = CustomInput;
            CustomInput   = EditorGUILayout.Toggle("Custom Input", previousValue);
            PowerUIEditor.HelpBox("Check if you'd like to call UI.HandleInput directly so you can use it's return value.");

            if (previousValue != CustomInput)
            {
                OnCustomInputChanged();
            }
        }
Ejemplo n.º 15
0
        void OnGUI()
        {
            bool previousValue = CompileAOT;

            CompileAOT = EditorGUILayout.Toggle("Precompile Nitro code", previousValue);
            PowerUIEditor.HelpBox("Note: Nitro on iOS and WP8 requires this. Normally, Nitro is compiled at runtime just like Javascript in a web browser. " +
                                  "It can however be compiled here in the Editor ('Ahead of time') for more performance. " +
                                  "Scripts that haven't been precompiled will still be compiled at runtime.");
            if (previousValue != CompileAOT)
            {
                OnAOTChanged();
            }

            previousValue = NoRuntime;
            NoRuntime     = EditorGUILayout.Toggle("No Runtime", previousValue);
            PowerUIEditor.HelpBox("Note: Nitro on WP8 requires this. Forces a precompile only requirement. Nitro will not be able to compile at runtime.");
            if (previousValue != NoRuntime)
            {
                OnRuntimeChanged();
            }
        }
Ejemplo n.º 16
0
        private void Precompile()
        {
            if (!Precompiled)
            {
                // Undo the "PowerUI" precompiled module.
                Precompiler.Reverse("PowerUI");

                return;
            }

            List <string> paths = new List <string>();

            // Find PowerUI:
            string powerUIPath = PowerUIEditor.GetPowerUIPath();

            paths.Add(powerUIPath + "/Source");
            paths.Add(powerUIPath + "/Wrench");

            Precompiler.Precompile(
                paths,
                "PowerUI",
                EditorMode
                );
        }
Ejemplo n.º 17
0
 void OnGUI()
 {
     PowerUIEditor.HelpBox("Coming soon! We'll list out the modules you've got here.");
 }
Ejemplo n.º 18
0
        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.");
                }
            }
        }
Ejemplo n.º 19
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);
            }
        }
        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);
                }
            }
        }
Ejemplo n.º 21
0
 void OnGUI()
 {
     PowerUIEditor.HelpBox("PowerUI is a large UI framework which renders HTML and CSS.\r\n\r\nHelp: https://powerui.kulestar.com/\r\n\r\nVersion: " + UI.Version);
 }
Ejemplo n.º 22
0
        void OnGUI()
        {
            if (Requests == null)
            {
                PowerUIEditor.HelpBox("Monitors all requests being made via PowerUI. Use either XMLHttpRequest or e.g. DataPackage to list here (and note that both work with all your supported protocols, such as 'resources://').");
                return;
            }

            ScrollPosition = EditorGUILayout.BeginScrollView(ScrollPosition);

            // For each record..
            int index = Progress - Fill;

            if (index < 0)
            {
                index += Requests.Length;
            }

            for (int i = 0; i < Fill; i++)
            {
                // Get the request:
                ContentPackage req = Requests[index];

                // Just a rough location label for now:
                GUILayout.Label(req.location.absolute);

                int readyState = req.readyState;

                string stateMessage = "";
                switch (readyState)
                {
                case 1:
                    stateMessage = "open";
                    break;

                case 2:
                    stateMessage = "waiting";
                    break;

                case 3:
                    stateMessage = "headers";
                    break;

                case 4:
                    stateMessage = "finished";
                    break;
                }

                if (readyState == 4)
                {
                    stateMessage += " (" + req.statusCode + ")";
                }

                GUILayout.Label("State: " + stateMessage);

                // Move to next index:
                index++;

                if (index == Requests.Length)
                {
                    index = 0;
                }
            }

            EditorGUILayout.EndScrollView();
        }
Ejemplo n.º 23
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);
                    }
                }
            }
        }