public void scanGroup(SimSet group) { GuiEditorGui.GuiEditor GuiEditor = "GuiEditor"; for (uint i = 0; i < group.getCount(); i++) { SimObject obj = group.getObject(i); if (obj.isMemberOfClass("GuiControl")) { if (obj.getClassName() == "GuiCanvas") { this.scanGroup((GuiCanvas)obj); } else { string name; if (obj.getName() == "") { name = "(unnamed) - " + obj; } else { name = obj.getName() + " - " + obj; } bool skip = false; foreach (string guiEntry in sGlobal["$GuiEditor::GuiFilterList"].Split('\t')) { if (obj.getName() == guiEntry) { skip = true; break; } } if (!skip) { this.add(name, obj); } } } else if (obj.isMemberOfClass("SimGroup") && ( //(%obj.internalName !$= "EditorGuiGroup" /* Copyright (C) 2013 WinterLeaf Entertainment LLC. */&& %obj.internalName !$= "IngameGuiGroup" ) // Don't put our editor's GUIs in the list /*||*/ GuiEditor["showEditorGuis"].AsBool())) // except if explicitly requested. { // Scan nested SimGroups for GuiControls. this.scanGroup((SimGroup)obj); } } }
public void getAbsScale() { EWorldEditor EWorldEditor = "EWorldEditor"; GuiCheckBoxCtrl ETransformSelectionScaleProportional = "ETransformSelectionScaleProportional"; GuiCheckBoxCtrl DoScale = this.FOT("DoScale"); GuiCheckBoxCtrl ScaleRelative = this.FOT("ScaleRelative"); GuiTextEditCtrl ScaleX = this.FOT("ScaleX"); GuiTextEditCtrl ScaleY = this.FOT("ScaleY"); GuiTextEditCtrl ScaleZ = this.FOT("ScaleZ"); int count = EWorldEditor.getSelectionSize(); // If we have more than one SceneObject selected, // we must exit. SimObject obj = -1; for (int i = 0; i < count; i++) { SimObject test = EWorldEditor.getSelectedObject(i); if (test.isMemberOfClass("SceneObject")) { if (obj != -1) { return; } obj = test; } } if (obj == -1) { // No SceneObjects selected return; } string scale = obj["scale"]; string scalex = Util.getWord(scale, 0); ScaleX.setText(scalex); if (!ETransformSelectionScaleProportional.getValue().AsBool()) { ScaleY.setText(Util.getWord(scale, 1)); ScaleZ.setText(Util.getWord(scale, 2)); } else { ScaleY.setText(scalex); ScaleZ.setText(scalex); } // Turn off relative as we're populating absolute values ScaleRelative.setValue("0"); // Finally, set the Scale check box as active. The user // likely wants this if they're getting the position. DoScale.setValue("1"); }
public override void onObjectSelected(SimObject obj) { // Select datablock of object if this is a GameBase object. if (obj.isMemberOfClass("GameBase")) { this.selectDatablock(obj.getDataBlock()); } else if (obj.isMemberOfClass("SFXEmitter") && obj["track"].isObject()) { this.selectDatablock(obj["track"].AsString()); } else if (obj.isMemberOfClass("LightBase") && obj["animationType"].isObject()) { this.selectDatablock(obj["animationType"].AsString()); } }
public void collapseAll() { for (uint i = 0; i < ((SimSet)this.parentGroup).getCount(); i++) { SimObject ctrl = ((SimSet)this.parentGroup).getObject(i); if (ctrl.isMemberOfClass("GuiRolloutCtrl")) { ((GuiRolloutCtrl)ctrl).instantCollapse(); } } }
public void getAbsRotation() { EWorldEditor EWorldEditor = "EWorldEditor"; GuiCheckBoxCtrl DoRotation = this.FOT("DoRotation"); GuiCheckBoxCtrl RotRelative = this.FOT("RotRelative"); GuiCheckBoxCtrl RotLocal = this.FOT("RotLocal"); GuiTextEditCtrl Bank = this.FOT("Bank"); GuiTextEditCtrl Pitch = this.FOT("Pitch"); GuiTextEditCtrl Heading = this.FOT("Heading"); int count = EWorldEditor.getSelectionSize(); // If we have more than one SceneObject selected, // we must exit. SimObject obj = -1; for (int i = 0; i < count; i++) { SimObject test = EWorldEditor.getSelectedObject(i); if (test.isMemberOfClass("SceneObject")) { if (obj != -1) { return; } obj = test; } } if (obj == -1) { // No SceneObjects selected return; } string rot = obj.call("getEulerRotation"); Pitch.setText(Util.getWord(rot, 0)); Bank.setText(Util.getWord(rot, 1)); Heading.setText(Util.getWord(rot, 2)); // Turn off relative as we're populating absolute values. // Of course this means that we need to set local on. RotRelative.setValue("0"); RotLocal.setValue("1"); // Finally, set the Rotation check box as active. The user // likely wants this if they're getting the position. DoRotation.setValue("1"); }
public override void onInspectorFieldModified(string objectx, string fieldName, string arrayIndex, string oldValue, string newValue) { SimObject obj = objectx; editor Editor = "Editor"; // The instant group will try to add our // UndoAction if we don't disable it. Util.pushInstantGroup(); string nameOrClass = obj.getName(); if (nameOrClass == "") { nameOrClass = obj.getClassName(); } ObjectCreator oc = new ObjectCreator("InspectorFieldUndoAction"); oc["actionName"] = nameOrClass + "." + fieldName + " Change"; oc["objectId"] = obj.getId(); oc["fieldName"] = fieldName; oc["fieldValue"] = oldValue; oc["arrayIndex"] = arrayIndex; oc["inspectorGui"] = this; InspectorFieldUndoAction action = oc.Create(); // If it's a datablock, initiate a retransmit. Don't do so // immediately so as the actual field value will only be set // by the inspector code after this method has returned. if (obj.isMemberOfClass("SimDataBlock")) { obj.schedule("1", "reloadOnLocalClient"); } // Restore the instant group. Util.popInstantGroup(); action.addToManager(Editor.getUndoManager()); EWorldEditor EWorldEditor = "EWorldEditor"; EWorldEditor.isDirty = true; // Update the selection if (EWorldEditor.getSelectionSize() > 0 && (fieldName == "position" || fieldName == "rotation" || fieldName == "scale")) { EWorldEditor.invalidateSelectionCentroid(); } }
public void onFinishCreateObject(SimObject objId) { this.objectGroup.add(objId); if (objId.isMemberOfClass("SceneObject")) { objId["position"] = this.getCreateObjectPosition(); //flush new position objId.call("setTransform", objId.call("getTransform")); } this.onObjectCreated(objId); }
public bool isValidDragTarget(int id, SimObject obj) { EWorldEditor EWorldEditor = "EWorldEditor"; if (obj.isMemberOfClass("Path")) { return(EWorldEditor.areAllSelectedObjectsOfType("Marker")); } if (obj.name == "CameraBookmarks") { return(EWorldEditor.areAllSelectedObjectsOfType("CameraBookmark")); } else { return(obj.getClassName() == "SimGroup"); } }
public void readSettings() { Settings EditorSettings = "EditorSettings"; GuiTabBookCtrl DatablockEditorTreeTabBook = "DatablockEditorTreeTabBook"; EditorSettings.beginGroup("DatablockEditor", true); DatablockEditorTreeTabBook.selectPage(EditorSettings.value("libraryTab").AsInt()); SimObject db = EditorSettings.value("selectedDatablock"); if (db.isObject() && db.isMemberOfClass("SimDatablock")) { this.selectDatablock(db); } EditorSettings.endGroup(); }
public string getFullFilePath(GuiInspectorField field) { string fileName = field.getData(); GuiInspector inspector = field.getInspector(); SimObject objectx = inspector.getInspectObject(); if (objectx.isMemberOfClass("Material")) { // Image filenames in materials are relative to the material's file. string objectPath = Util.filePath(Util.makeFullPath(objectx.getFilename(), Util.getMainDotCsDir())); return(Util.makeFullPath(fileName, objectPath)); } else { return(Util.makeFullPath(fileName, Util.getMainDotCsDir())); } }
public string getRolloutForCategory(string category) { for (uint i = 0; i < this.getCount(); i++) { SimObject obj = this.getObject(i); if (!obj.isMemberOfClass("GuiRolloutCtrl")) { continue; } if (Util.stricmp(obj["caption"], category) == 0) { return(obj); } } return("0"); }
/// <summary> /// Return the first active SFXState in the given SimSet/SimGroup. /// </summary> /// <param name="group"></param> public static SFXState sfxGetActiveStateInGroup(SimGroup group) { for (uint i = 0; i < group.getCount(); i++) { SimObject obj = group.getObject(i); if (!obj.isMemberOfClass("SFXState")) { continue; } SFXState state = obj.As <SFXState>(); if (state.isActive()) { return(state); } } return(null); }
public virtual void scanGroup(SimGroup group, GuiPopUpMenuCtrl list, int indentLevel) { // Create a display name for the group. string text = group.getName(); if (text == "") { text = group.getClassName(); } string internalName = group.getInternalName(); if (internalName != "") { text = text + "[" + internalName + "]"; } // Indent the name according to the depth in the hierarchy. if (indentLevel > 0) { text = Util.strrepeat(" ", indentLevel, "") + text; } // Add it to the list. list.add(text, group.getId()); // Recurse into SimSets with at least one child. for (uint i = 0; i < group.getCount(); i++) { SimObject obj = group.getObject(i); if (!obj.isMemberOfClass("SimSet") || obj.call("getCount").AsInt() == 0) { continue; } scanGroup(obj.GetID(), list, indentLevel + 1); } }
public virtual void selectObjectsIn(string group, bool val, bool excludeGroup = false) { // Match to the group itself. if (!excludeGroup && objectMatchesCriteria(group)) { selectObject(group, val); } // Recursively match all children. for (uint i = 0; i < ((SimGroup)group).getCount(); i++) { SimObject obj = ((SimGroup)group).getObject(i); if (obj.isMemberOfClass("SimSet")) { selectObjectsIn(obj, val); } else if (objectMatchesCriteria(obj)) { selectObject(obj, val); } } }
public override void onActivate() { base.onActivate(); SimGroup group = ParentGroup.As <SimGroup>(); for (uint i = 0; i < group.getCount(); i++) { SimObject obj = group.getObject(i); if (obj.getId() == getId() || !obj.isMemberOfClass("SFXState")) { continue; } SFXState state = obj.As <SFXState>(); if (state.isActive()) { state.deactivate(); } } }
public override void onRightMouseUp(int itemId, string mousePos, SimObject obj) { MenuBuilder popup; GuiCanvas Canvas = "Canvas"; bool haveObjectEntries = false; bool haveLockAndHideEntries = true; // Handle multi-selection. if (this.getSelectedItemsCount() > 1) { popup = "ETMultiSelectionContextPopup"; if (!popup.isObject()) { ObjectCreator popCreator = new ObjectCreator("PopupMenu", "ETMultiSelectionContextPopup", typeof(MenuBuilder)); popCreator["isPopup"] = true.AsString(); popCreator["item[0]"] = "Delete" + '\t' + "" + '\t' + "EditorMenuEditDelete();"; popCreator["item[1]"] = "Group" + '\t' + "" + '\t' + "EWorldEditor.addSimGroup( true );"; popup = popCreator.Create(); } } // Open context menu if this is a CameraBookmark else if (obj.isMemberOfClass("CameraBookmark")) { popup = "ETCameraBookmarkContextPopup"; if (!popup.isObject()) { ObjectCreator popupCreator = new ObjectCreator("PopupMenu", "ETCameraBookmarkContextPopup", typeof(MenuBuilder)); popupCreator["isPopup"] = true.AsString(); popupCreator["item[0]"] = "Go To Bookmark" + '\t' + "" + '\t' + "EditorGui.jumpToBookmark( this.bookmark.getInternalName() );"; popupCreator["bookmark"] = "-1"; popup = popupCreator.Create(); } ((MenuBuilder)"ETCameraBookmarkContextPopup")["bookmark"] = obj; } // Open context menu if this is set CameraBookmarks group. else if (obj.name == "CameraBookmarks") { popup = "ETCameraBookmarksGroupContextPopup"; if (!popup.isObject()) { popup = new ObjectCreator("PopupMenu", "ETCameraBookmarksGroupContextPopup", typeof(MenuBuilder)).Create(); popup.isPopup = true; popup.addItem("0", "Add Camera Bookmark" + '\t' + "" + '\t' + "EditorGui.addCameraBookmarkByGui();"); } } // Open context menu if this is a SimGroup else if (obj.isMemberOfClass("SimGroup")) { popup = "ETSimGroupContextPopup"; if (!popup.isObject()) { ObjectCreator popupCreator = new ObjectCreator("PopupMenu", "ETSimGroupContextPopup", typeof(MenuBuilder)); popupCreator["isPopup"] = true.AsString(); popupCreator["item[0]"] = "Rename" + '\t' + "" + '\t' + "EditorTree.showItemRenameCtrl( EditorTree.findItemByObjectId( ETSimGroupContextPopup.object ) );"; popupCreator["item[1]"] = "Delete" + '\t' + "" + '\t' + "EWorldEditor.deleteMissionObject( ETSimGroupContextPopup.object );"; popupCreator["item[2]"] = "Inspect" + '\t' + "" + '\t' + "inspectObject( ETSimGroupContextPopup.object );"; popupCreator["item[3]"] = "-"; popupCreator["item[4]"] = "Toggle Lock Children" + '\t' + "" + '\t' + "EWorldEditor.toggleLockChildren( ETSimGroupContextPopup.object );"; popupCreator["item[5]"] = "Toggle Hide Children" + '\t' + "" + '\t' + "EWorldEditor.toggleHideChildren( ETSimGroupContextPopup.object );"; popupCreator["item[6]"] = "-"; popupCreator["item[7]"] = "Group" + '\t' + "" + '\t' + "EWorldEditor.addSimGroup( true );"; popupCreator["item[8]"] = "-"; popupCreator["item[9]"] = "Add New Objects Here" + '\t' + "" + '\t' + "EWCreatorWindow.setNewObjectGroup( ETSimGroupContextPopup.object );"; popupCreator["item[10]"] = "Add Children to Selection" + '\t' + "" + '\t' + "EWorldEditor.selectAllObjectsInSet( ETSimGroupContextPopup.object, false );"; popupCreator["item[11]"] = "Remove Children from Selection" + '\t' + "" + '\t' + "EWorldEditor.selectAllObjectsInSet( ETSimGroupContextPopup.object, true );"; popupCreator["object"] = "-1"; popup = popupCreator.Create(); } popup["object"] = obj; bool hasChildren = ((SimGroup)obj).getCount() > 0; popup.enableItem(10, hasChildren); popup.enableItem(11, hasChildren); haveObjectEntries = true; haveLockAndHideEntries = false; } // Open generic context menu. else { popup = "ETContextPopup"; if (!popup.isObject()) { ObjectCreator popCreator = new ObjectCreator("PopupMenu", "ETContextPopup", typeof(MenuBuilder)); popCreator["isPopup"] = true.AsString(); popCreator["item[0]"] = "Rename" + '\t' + "" + '\t' + "EditorTree.showItemRenameCtrl( EditorTree.findItemByObjectId( ETContextPopup.object ) );"; popCreator["item[1]"] = "Delete" + '\t' + "" + '\t' + "EWorldEditor.deleteMissionObject( ETContextPopup.object );"; popCreator["item[2]"] = "Inspect" + '\t' + "" + '\t' + "inspectObject( ETContextPopup.object );"; popCreator["item[3]"] = "-"; popCreator["item[4]"] = "Locked" + '\t' + "" + '\t' + "ETContextPopup.object.setLocked( !ETContextPopup.object.locked ); EWorldEditor.syncGui();"; popCreator["item[5]"] = "Hidden" + '\t' + "" + '\t' + "EWorldEditor.hideObject( ETContextPopup.object, !ETContextPopup.object.hidden ); EWorldEditor.syncGui();"; popCreator["item[6]"] = "-"; popCreator["item[7]"] = "Group" + '\t' + "" + '\t' + "EWorldEditor.addSimGroup( true );"; popCreator["object"] = "-1"; popup = popCreator.Create(); } // Specialized version for ConvexShapes. if (obj.isMemberOfClass("ConvexShape")) { popup = "ETConvexShapeContextPopup"; if (!popup.isObject()) { ObjectCreator popCreator = new ObjectCreator("PopupMenu", "ETConvexShapeContextPopup", typeof(MenuBuilder)); popCreator["isPopup"] = true.AsString(); popCreator["item[8]"] = "-"; popCreator["item[9]"] = "Convert to Zone" + '\t' + "" + '\t' + "EWorldEditor.convertSelectionToPolyhedralObjects( \\\"Zone\\\" );"; popCreator["item[10]"] = "Convert to Portal" + '\t' + "" + '\t' + "EWorldEditor.convertSelectionToPolyhedralObjects( \\\"Portal\\\" );"; popCreator["item[11]"] = "Convert to Occluder" + '\t' + "" + '\t' + "EWorldEditor.convertSelectionToPolyhedralObjects( \\\"OcclusionVolume\\\" );"; popCreator["item[12]"] = "Convert to Sound Space" + '\t' + "" + '\t' + "EWorldEditor.convertSelectionToPolyhedralObjects( \\\"SFXSpace\\\" );"; popup = popCreator.Create(); } } // Specialized version for polyhedral objects. else if (obj.isMemberOfClass("Zone") || obj.isMemberOfClass("Portal") || obj.isMemberOfClass("OcclusionVolume") || obj.isMemberOfClass("SFXSpace")) { popup = "ETPolyObjectContextPopup"; if (!popup.isObject()) { ObjectCreator popCreator = new ObjectCreator("PopupMenu", "ETPolyObjectContextPopup", typeof(MenuBuilder)); popCreator["isPopup"] = true.AsString(); popCreator["item[8]"] = "-"; popCreator["item[9]"] = "Convert to ConvexShape" + '\t' + "" + '\t' + "EWorldEditor.convertSelectionToConvexShape();"; popup = popCreator.Create(); } } popup["object"] = obj; haveObjectEntries = true; } if (haveObjectEntries) { popup.enableItem(0, (obj.isNameChangeAllowed() && obj.getName() != "MissionGroup")); popup.enableItem(1, (obj.getName() != "MissionGroup")); if (haveLockAndHideEntries) { popup.checkItem(4, obj["locked"].AsBool()); popup.checkItem(5, obj.hidden); } popup.enableItem(7, this.isItemSelected(itemId)); } popup.showPopup(Canvas); }
public override void onFieldRightClick(string field) { SimObject obj = this.getInspectObject(); string fieldValue = ((GuiInspectorField)field).getData(); int inspectIndex = -1; int openFileIndex = -1; int openFolderIndex = -1; int jumpToIndex = -1; // Find out if this is a TypeFilename field referring to a shape file. bool isShapeFilenameField = false; if (((GuiInspectorField)field).getInspectedFieldName() == "shapeName") { isShapeFilenameField = obj.isMemberOfClass("PhysicsShape") || obj.isMemberOfClass("TSStatic"); } else if (((GuiInspectorField)field).getInspectedFieldName() == "shapeFile") { isShapeFilenameField = obj.isMemberOfClass("ShapeBaseData") || obj.isMemberOfClass("ShapeBaseImageData") || obj.isMemberOfClass("ForestItemData") || obj.isMemberOfClass("WheeledVehicleTire") || obj.isMemberOfClass("fxShapeReplicator") || obj.isMemberOfClass("RenderShapeExample") || obj.isMemberOfClass("DebrisData"); } // Select the popup. MenuBuilder popup = ""; if (isShapeFilenameField) { popup = "EditorInspectorBaseShapeFieldPopup"; openFileIndex = 2; openFolderIndex = 3; } else if (this.isFileTypeField(field)) { popup = "EditorInspectorBaseFileFieldPopup"; openFileIndex = 0; openFolderIndex = 1; } else { switch (((GuiInspectorField)field).getClassName()) { case "GuiInspectorCustomField": if (((GuiInspectorField)field).getInspectedFieldName() != "parentGroup") { return; } break; case "GuiInspectorTypeGuiProfile": popup = "EditorInspectorBaseProfileFieldPopup"; popup.enableItem(0, fieldValue.isObject()); inspectIndex = 2; jumpToIndex = 1; break; case "GuiInspectorDatablockField": case "GuiInspectorTypeSFXDescriptionName": case "GuiInspectorTypeSFXEnvironmentName": case "GuiInspectorTypeSFXTrackName": case "GuiInspectorTypeSFXAmbienceName": case "GuiInspectorTypeSFXSourceName": popup = "EditorInspectorBaseDatablockFieldPopup"; popup.enableItem(0, fieldValue.isObject()); inspectIndex = 2; jumpToIndex = 1; break; default: popup = "EditorInspectorBaseFieldPopup"; inspectIndex = 0; jumpToIndex = 1; break; } } if (inspectIndex != -1) { bool isObject = false; if (this.isObjectTypeField(field)) { isObject = fieldValue.isObject(); } popup.enableItem(inspectIndex, isObject); popup.enableItem(jumpToIndex, isObject); } if (openFileIndex != -1 || openFolderIndex != -1) { string fullPath = this.getFullFilePath(field); popup["filePath"] = fullPath; popup["folderPath"] = Util.filePath(fullPath); if (openFileIndex != -1) { popup.enableItem(0, Util.isFile(fullPath)); } if (openFolderIndex != -1) { popup.enableItem(1, Util.IsDirectory(popup["folderPath"])); } } popup["inspectorField"] = field; GuiCanvas Canvas = "Canvas"; popup.showPopup(Canvas); }
public override void onSelectObjects(bool val, bool reuseExistingSet = false) { string sel = ""; // See if we should create an independent selection set. GuiCheckBoxCtrl createSelectionSet = this.findObjectByInternalName("createSelectionSet", true); if (createSelectionSet.isStateOn()) { string sname = ((GuiTextEditCtrl)this.findObjectByInternalName("selectionSetName", true)).getText(); // See if we should create or re-use a set. if (sname.isObject()) { SimObject name = sname; if (name.isMemberOfClass("WorldEditorSelection")) { messageBox.MessageBoxOK("Error", "An object called '" + name + "' already exists and is not a selection. Please choose a different name."); return; } else if (!reuseExistingSet) { messageBox.MessageBoxYesNo("Question", "A selection called '" + name + "' already exists. Modify the existing selection?", this + ".onSelectObjects( " + val + ", true );", ""); return; } else { sel = name; } } else { editor Editor = "Editor"; if (!Editor.validateObjectName(name, false)) { return; } // Create a new selection set. sel = console.Eval("%sel = new WorldEditorSelection( " + name + " ) { parentGroup = Selections; canSave = true; };return sel;", true); if (!sel.isObject()) { messageBox.MessageBoxOK("Error", "Could not create the selection set. Please look at the console.log for details."); return; } } this["selectionSet"] = sel; } else { this["selectionSet"] = ""; } base.onSelectObjects(val, false); // Refresh editor tree just in case. EditorTree EditorTree = "EditorTree"; EditorTree.buildVisibleTree(); }
public void init() { GuiEditorGui.GuiEditor GuiEditor = "GuiEditor"; SimSet GuiDataGroup = "GuiDataGroup"; this.clear(); int defaultGroup = this.insertItem(0, "Default", "-1", "", 1, 1); int otherGroup = this.insertItem(0, sGlobal["$GUI_EDITOR_DEFAULT_PROFILE_CATEGORY"], "-1", "", 1, 1); for (uint i = 0; i < GuiDataGroup.getCount(); i++) { SimObject obj = GuiDataGroup.getObject(i); if (!obj.isMemberOfClass("GuiControlProfile")) { continue; } // If it's an Editor profile, skip if showing them is not enabled. if (obj["category"] == "Editor" && !GuiEditor["showEditorProfiles"].AsBool()) { continue; } // Create a visible name. string name = obj.getName(); if (name == "") { name = "<Unnamed>"; } string text = name + " (" + obj.getId() + ")"; // Find which group to put the control in. bool isDefaultProfile = GuiEditor.isDefaultProfile(name); int group; if (isDefaultProfile) { group = defaultGroup; } else if (obj["category"] != "") { group = this.findChildItemByName(0, obj["category"]); if (group == 0) { group = this.insertItem(0, obj["category"], "", "", 1, 1); } } else { group = otherGroup; } // Insert the item. this.insertItem(group, text, obj.getId().AsString(), "", 1, 1); } this.sort(0, true, true, false); }
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); } } }