コード例 #1
0
        public void setViewTypeAlphabetical()
        {
            GuiEditorGui.GuiEditor GuiEditor = "GuiEditor";
            string      controls             = Util.enumerateConsoleClassesByCategory("Gui");
            ArrayObject classes = new ObjectCreator("ArrayObject").Create();

            // Collect relevant classes.

            foreach (string className in controls.Split('\t'))
            {
                if (GuiEditor.isFilteredClass(className) ||
                    !(Util.isMemberOfClass(className, "GuiControl")))
                {
                    continue;
                }

                classes.push_back(className, "");
            }

            // Sort classes alphabetically.

            classes.sortk(true);

            // Add toolbox buttons.

            int numClasses = classes.count();

            for (int i = 0; i < numClasses; i++)
            {
                string className = classes.getKey(i);

                #region GuiIconButtonCtrl ()        oc_Newobject2

                ObjectCreator oc_Newobject2 = new ObjectCreator("GuiIconButtonCtrl", "", typeof(GuiEditorToolboxButton));
                oc_Newobject2["profile"]    = "ToolsGuiIconButtonSmallProfile";
                oc_Newobject2["extent"]     = "128 18";
                oc_Newobject2["text"]       = className;
                oc_Newobject2["iconBitmap"] = console.Call_Classname("EditorIconRegistry", "findIconByClassName",
                                                                     new string[] { className });
                oc_Newobject2["buttonMargin"]   = "2 2";
                oc_Newobject2["iconLocation"]   = "left";
                oc_Newobject2["textLocation"]   = "left";
                oc_Newobject2["textMargin"]     = "24";
                oc_Newobject2["AutoSize"]       = new ObjectCreator.StringNoQuote("true");
                oc_Newobject2["command"]        = "GuiEditor.createControl( " + className + " );";
                oc_Newobject2["useMouseEvents"] = new ObjectCreator.StringNoQuote("true");
                oc_Newobject2["tooltip"]        = className + '\n' + "\n" + Util.getDescriptionOfClass(className);
                oc_Newobject2["tooltipProfile"] = "ToolsGuiToolTipProfile";

                #endregion

                GuiIconButtonCtrl ctrl = oc_Newobject2.Create();


                this.add(ctrl);
            }

            classes.delete();
            this.currentViewType = "Alphabetical";
        }
コード例 #2
0
        public bool includeClass(string className)
        {
            GuiEditorGui.GuiEditor GuiEditor = "GuiEditor";

            return(Util.isMemberOfClass(className, "GuiControl") &&
                   !GuiEditor.isFilteredClass(className));
        }
コード例 #3
0
        public void init(string guiName, string guiClass)
        {
            GuiEditorGui.GuiEditor GuiEditor = "GuiEditor";
            GuiTextEditCtrl        nameField = this.FOT("nameField");

            nameField.setValue(guiName);

            // Initialize the class dropdown if we haven't already.

            GuiPopUpMenuCtrl classDropdown = this.FOT("classDropdown");

            if (classDropdown.size() == 0)
            {
                string classes = Util.enumerateConsoleClassesByCategory("Gui");
                int    count   = Util.getFieldCount(classes);

                for (int i = 0; i < count; i++)
                {
                    string className = Util.getField(classes, i);
                    if (GuiEditor.isFilteredClass(className) ||
                        !Util.isMemberOfClass(className, "GuiControl"))
                    {
                        continue;
                    }

                    classDropdown.add(className, 0);
                }

                classDropdown.sort();
            }

            classDropdown.setText("GuiControl");
        }
コード例 #4
0
        public void setViewTypeCategorized()
        {
            GuiEditorGui.GuiEditor GuiEditor = "GuiEditor";

            // Create rollouts for each class category we have and
            // record the classes in each category in a temporary array
            // on the rollout so we can later sort the class names before
            // creating the actual controls in the toolbox.

            string controls = Util.enumerateConsoleClassesByCategory("Gui");

            foreach (string className in controls.Split('\t'))
            {
                if (GuiEditor.isFilteredClass(className) ||
                    !Util.isMemberOfClass(className, "GuiControl"))
                {
                    continue;
                }

                // Get the class's next category under Gui.

                string category = Util.getWord(Util.getCategoryOfClass(className), 1);
                if (category == "")
                {
                    continue;
                }

                // Find or create the rollout for the category.

                GuiRolloutCtrl rollout = this.getOrCreateRolloutForCategory(category);

                // Insert the item.

                if (!rollout["classes"].AsBool())
                {
                    rollout["classes"] = new ObjectCreator("ArrayObject").Create().AsString();
                }

                ((ArrayObject)rollout["classes"]).push_back(className, "");
            }

            // Go through the rollouts, sort the class names, and
            // create the toolbox controls.

            for (uint i = 0; i < this.getCount(); i++)
            {
                GuiRolloutCtrl rollout = this.getObject(i);
                if (!rollout.isMemberOfClass("GuiRolloutCtrl"))
                {
                    continue;
                }

                // Get the array with the class names and sort it.
                // Sort in descending order to counter reversal of order
                // when we later add the controls to the stack.

                ArrayObject classes = rollout["classes"];
                classes.sortk(true);

                // Add a control for each of the classes to the
                // rollout's stack control.

                GuiDynamicCtrlArrayControl stack = rollout.FOT("array");
                int numClasses = classes.count();
                for (int n = 0; n < numClasses; n++)
                {
                    string className = classes.getKey(n);

                    #region GuiIconButtonCtrl ()        oc_Newobject3

                    ObjectCreator oc_Newobject3 = new ObjectCreator("GuiIconButtonCtrl", "",
                                                                    typeof(GuiEditorToolboxButton));
                    oc_Newobject3["profile"]    = "ToolsGuiIconButtonSmallProfile";
                    oc_Newobject3["extent"]     = "128 18";
                    oc_Newobject3["text"]       = className;
                    oc_Newobject3["iconBitmap"] = console.Call_Classname("EditorIconRegistry", "findIconByClassName",
                                                                         new string[] { className });
                    oc_Newobject3["buttonMargin"]   = "2 2";
                    oc_Newobject3["iconLocation"]   = "left";
                    oc_Newobject3["textLocation"]   = "left";
                    oc_Newobject3["textMargin"]     = "24";
                    oc_Newobject3["AutoSize"]       = new ObjectCreator.StringNoQuote("true");
                    oc_Newobject3["command"]        = "GuiEditor.createControl( " + className + " );";
                    oc_Newobject3["useMouseEvents"] = new ObjectCreator.StringNoQuote("true");

                    //TODO doesn't work for every control.
                    //oc_Newobject3["tooltip"] = className + '\n' + "\n" + Util.getDescriptionOfClass( className );
                    oc_Newobject3["tooltipProfile"] = "ToolsGuiToolTipProfile";

                    #endregion

                    GuiIconButtonCtrl ctrl = oc_Newobject3.Create();


                    stack.add(ctrl);
                }

                // Delete the temporary array.

                rollout["classes"] = "";
                classes.delete();
            }

            this.currentViewType = "Categorized";
        }