Exemplo n.º 1
0
            public void loadNewEmitter(string emitter)
            {
                ParticleEditor      ParticleEditor      = "ParticleEditor";
                GuiPopUpMenuCtrl    PEE_EmitterSelector = "PEE_EmitterSelector";
                ParticleEmitterData PE_EmitterEditor_NotDirtyEmitter = "PE_EmitterEditor_NotDirtyEmitter";

                ParticleParticleEditor.PE_ParticleEditor PE_ParticleEditor = "PE_ParticleEditor";

                GuiCheckBoxCtrl PEE_infiniteLoop = this.FOT("PEE_infiniteLoop");

                SimObject current;

                if (emitter.isObject())
                {
                    current = emitter.getID();
                }
                else
                {
                    current = PEE_EmitterSelector.getSelected();
                }

                this.currEmitter = current;
                PE_EmitterEditor_NotDirtyEmitter.assignFieldsFrom(current);
                PE_EmitterEditor_NotDirtyEmitter["originalName"] = current["name"];

                this.guiSync();
                this.setEmitterNotDirty();

                PE_ParticleEditor.loadNewParticle(Util.getWord(current["particles"], 0));

                ParticleEditor.updateEmitterNode();

                PEE_infiniteLoop.setStateOn(current["lifetimeMS"].AsInt() == 0);
            }
Exemplo n.º 2
0
        public virtual void initClassList()
        {
            ArrayObject classArray = new ObjectCreator("ArrayObject").Create();

            this["classArray"] = classArray;

            // Add all classes to the array.

            string classes = Util._call("enumerateConsoleClasses");

            foreach (string className in classes.Split('\t'))
            {
                if (!includeClass(className))
                {
                    continue;
                }

                classArray.push_back(className, "true");
            }
            // Sort the class list.
            classArray.sortk(true);

            // Add checkboxes for all classes to the list.

            GuiStackControl classList = findObjectByInternalName("classList", true);
            int             count     = classArray.count();

            for (int i = 0; i < count; i++)
            {
                string className  = classArray.getKey(i);
                int    textLength = className.Length;
                string text       = " " + className;

                ObjectCreator oc = new ObjectCreator("GuiCheckBoxCtrl");
                oc["canSaveDynamicFields"] = "0";
                oc["isContainer"]          = "0";
                oc["Profile"]          = "ToolsGuiCheckBoxListFlipedProfile";
                oc["HorizSizing"]      = "right";
                oc["VertSizing"]       = "bottom";
                oc["Position"]         = "0 0";
                oc["Extent"]           = (textLength * 4) + " 18";
                oc["MinExtent"]        = "8 2";
                oc["canSave"]          = "0";
                oc["Visible"]          = "1";
                oc["tooltipprofile"]   = "ToolsGuiToolTipProfile";
                oc["hovertime"]        = "1000";
                oc["tooltip"]          = "Include/exclude all " + className + " objects.";
                oc["text"]             = text;
                oc["groupNum"]         = "-1";
                oc["buttonType"]       = "ToggleButton";
                oc["useMouseEvents"]   = "0";
                oc["useInactiveState"] = "0";
                oc["command"]          = classArray + ".setValue( $ThisControl.getValue(), " + i + " );";

                GuiCheckBoxCtrl checkBox = oc.Create();
                checkBox.setStateOn(true);
                classList.addGuiControl(checkBox);
            }
        }
        public void RotLocalChanged()
        {
            GuiCheckBoxCtrl RotRelative = this.FOT("RotRelative");
            GuiCheckBoxCtrl RotLocal    = this.FOT("RotLocal");

            if (RotLocal.getValue().AsInt() == 0)
            {
                // Non-local rotation can only happen relatively
                RotRelative.setStateOn(true);
            }
        }
        public void RotRelativeChanged()
        {
            GuiCheckBoxCtrl RotRelative = this.FOT("RotRelative");
            GuiCheckBoxCtrl RotLocal    = this.FOT("RotLocal");

            if (RotRelative.getValue().AsInt() == 0)
            {
                // With absolute rotation, it must happen locally
                RotLocal.setStateOn(true);
            }
        }
Exemplo n.º 5
0
        public void createDatablock()
        {
            GuiTreeViewCtrl DatablockEditorTypeTree     = "DatablockEditorTypeTree";
            GuiControl      DatablockEditorCreatePrompt = "DatablockEditorCreatePrompt";

            string className = DatablockEditorTypeTree.getItemText(DatablockEditorTypeTree.getSelectedItem());

            if (className != "")
            {
                // Need to prompt for a name.

                ((GuiTextEditCtrl)DatablockEditorCreatePrompt.findObjectByInternalName("CreateDatablockName", true))
                .setText("Name");
                ((GuiTextEditCtrl)DatablockEditorCreatePrompt.findObjectByInternalName("CreateDatablockName", true))
                .selectAllText();

                // Populate the copy source dropdown.

                GuiPopUpMenuCtrl list = DatablockEditorCreatePrompt.findObjectByInternalName("CopySourceDropdown",
                                                                                             true);
                list.clear();
                list.add("", 0);

                SimSet set   = "DataBlockSet";
                int    count = set.getCount();
                for (uint i = 0; i < count; i++)
                {
                    SimObject datablock      = set.getObject(i);
                    string    datablockClass = datablock.getClassName();

                    if (!Util.isMemberOfClass(datablockClass, className))
                    {
                        continue;
                    }

                    list.add(datablock.getName(), ((int)i + 1));
                }

                // Set up state of client-side checkbox.

                GuiCheckBoxCtrl clientSideCheckBox =
                    DatablockEditorCreatePrompt.findObjectByInternalName("ClientSideCheckBox", true);
                bool canBeClientSide = this.canBeClientSideDatablock(className);
                clientSideCheckBox.setStateOn(canBeClientSide);
                clientSideCheckBox.setActive(canBeClientSide);

                // Show the dialog.

                ((GuiCanvas)"canvas").pushDialog(DatablockEditorCreatePrompt, 0, true);
            }
        }
        public override void onWake()
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            GuiCheckBoxCtrl PosRelative    = this.FOT("PosRelative");
            GuiCheckBoxCtrl RotRelative    = this.FOT("RotRelative");
            GuiCheckBoxCtrl ScaleRelative  = this.FOT("ScaleRelative");
            GuiCheckBoxCtrl SizeRelative   = this.FOT("SizeRelative");
            GuiButtonCtrl   GetPosButton   = this.FOT("GetPosButton");
            GuiButtonCtrl   GetRotButton   = this.FOT("GetRotButton");
            GuiButtonCtrl   GetScaleButton = this.FOT("GetScaleButton");
            GuiButtonCtrl   GetSizeButton  = this.FOT("GetSizeButton");
            GuiCheckBoxCtrl SizeLocal      = this.FOT("SizeLocal");
            GuiTabBookCtrl  ScaleTabBook   = this.FOT("ScaleTabBook");
            GuiButtonCtrl   ApplyButton    = this.FOT("ApplyButton");

            // Make everything relative
            PosRelative.setStateOn(true);
            RotRelative.setStateOn(true);
            ScaleRelative.setStateOn(true);
            SizeRelative.setStateOn(false);

            GetPosButton.setActive(false);
            GetRotButton.setActive(false);
            GetScaleButton.setActive(false);
            GetSizeButton.setActive(false);

            // Size is always local
            SizeLocal.setStateOn(true);
            SizeLocal.setActive(false);

            ScaleTabBook.selectPage(0); // Scale page

            ApplyButton.setActive(false);

            EWorldEditor["ETransformSelectionDisplayed"] = false.AsString();
        }
Exemplo n.º 7
0
            public void updateLifeFields(bool isRandom, float value, bool isSlider, bool onMouseUp)
            {
                GuiCheckBoxCtrl PEE_infiniteLoop                = this.FOT("PEE_infiniteLoop");
                GuiSliderCtrl   PEE_lifetimeMS_slider           = this.FOT("PEE_lifetimeMS_slider");
                GuiSliderCtrl   PEE_lifetimeVarianceMS_slider   = this.FOT("PEE_lifetimeVarianceMS_slider");
                GuiTextEditCtrl PEE_lifetimeVarianceMS_textEdit = this.FOT("PEE_lifetimeVarianceMS_textEdit");
                GuiTextEditCtrl PEE_lifetimeMS_textEdit         = this.FOT("PEE_lifetimeMS_textEdit");
                editor          Editor         = "Editor";
                ParticleEditor  ParticleEditor = "ParticleEditor";

                this.setEmitterDirty();

                SimObject emitter = this.currEmitter;

                // Transfer values over to gui controls.

                if (isRandom)
                {
                    if (value > 0)
                    {
                        value++;
                    }

                    if (value > PEE_lifetimeMS_slider.getValue())
                    {
                        PEE_lifetimeMS_textEdit.setText(value.AsString());
                        PEE_lifetimeMS_slider.setValue(value.AsString());
                    }
                }
                else
                {
                    if (value > 0)
                    {
                        value--;
                    }

                    if (value < PEE_lifetimeVarianceMS_slider.getValue())
                    {
                        PEE_lifetimeVarianceMS_textEdit.setText(value.AsString());
                        PEE_lifetimeVarianceMS_slider.setValue(value.AsString());
                    }
                }

                // Submit undo.

                SimObject last = Editor.getUndoManager().getUndoAction((Editor.getUndoManager().getUndoCount() - 1));

                if ((isSlider) && (last["isSlider"].AsBool()) && (!last["onMouseUp"].AsBool()))
                {
                    last["isSlider"]                   = isSlider.AsString();
                    last["onMouseUp"]                  = onMouseUp.AsString();
                    last["newValueLifetimeMS"]         = PEE_lifetimeMS_textEdit.getText();
                    last["newValueLifetimeVarianceMS"] = PEE_lifetimeVarianceMS_textEdit.getText();
                }
                else
                {
                    ParticleEditorUndo.ActionUpdateActiveEmitterLifeFields action = ParticleEditor.createUndo <ParticleEditorUndo.ActionUpdateActiveEmitterLifeFields>("Update Active Emitter");
                    action["emitter"]   = emitter;
                    action["isSlider"]  = isSlider.AsString();
                    action["onMouseUp"] = onMouseUp.AsString();

                    action["newValueLifetimeMS"] = PEE_lifetimeMS_textEdit.getText();
                    action["oldValueLifetimeMS"] = emitter["lifetimeMS"];

                    action["newValueLifetimeVarianceMS"] = PEE_lifetimeVarianceMS_textEdit.getText();
                    action["oldValueLifetimeVarianceMS"] = emitter["lifetimeVarianceMS"];

                    ParticleEditor.submitUndo(action);
                }

                // Set the values on the current emitter.

                emitter["lifetimeMS"]         = PEE_lifetimeMS_textEdit.getText();
                emitter["lifetimeVarianceMS"] = PEE_lifetimeVarianceMS_textEdit.getText();
                emitter.call("reload");

                // Keep the infiniteLoop checkbox up to date.

                PEE_infiniteLoop.setStateOn(emitter["lifetimeMS"].AsInt() == 0);
            }
        public void onSelectionChanged()
        {
            EWorldEditor EWorldEditor = "EWorldEditor";

            GuiCheckBoxCtrl RotRelative    = this.FOT("RotRelative");
            GuiCheckBoxCtrl RotLocal       = this.FOT("RotLocal");
            GuiButtonCtrl   GetPosButton   = this.FOT("GetPosButton");
            GuiButtonCtrl   GetRotButton   = this.FOT("GetRotButton");
            GuiButtonCtrl   GetScaleButton = this.FOT("GetScaleButton");
            GuiButtonCtrl   GetSizeButton  = this.FOT("GetSizeButton");
            GuiButtonCtrl   ApplyButton    = this.FOT("ApplyButton");

            // Count the number of selected SceneObjects.  There are
            // other object classes that could be selected, such
            // as SimGroups.
            int count               = EWorldEditor.getSelectionSize();
            int sceneObjects        = 0;
            int globalBoundsObjects = 0;

            for (int i = 0; i < count; i++)
            {
                SimObject obj = EWorldEditor.getSelectedObject(i);
                if (obj.isMemberOfClass("SceneObject"))
                {
                    sceneObjects++;

                    if (obj.call("isGlobalBounds").AsBool())
                    {
                        globalBoundsObjects++;
                    }
                }
            }

            if (sceneObjects == 0)
            {
                // With nothing selected, disable all Get buttons
                this.disableAllButtons();
            }
            else if (sceneObjects == 1)
            {
                // With one selected, all Get buttons are active
                GetPosButton.setActive(true);
                GetRotButton.setActive(true);

                // Special case for Scale and Size for global bounds objects
                if (globalBoundsObjects == 1)
                {
                    GetSizeButton.setActive(false);
                    GetScaleButton.setActive(false);
                }
                else
                {
                    GetSizeButton.setActive(true);
                    GetScaleButton.setActive(true);
                }

                ApplyButton.setActive(true);
            }
            else
            {
                // With more than one selected, only the position button
                // is active
                GetPosButton.setActive(true);
                GetRotButton.setActive(false);
                GetScaleButton.setActive(false);
                GetSizeButton.setActive(false);

                ApplyButton.setActive(true);

                // If both RotRelative and RotLocal are unchecked, then go with RotLocal
                if (RotRelative.getValue().AsInt() == 0 && RotLocal.getValue().AsInt() == 0)
                {
                    RotLocal.setStateOn(true);
                }
            }
        }