public void flagDatablockAsDirty(SimObject datablock, bool dirty) { GuiTreeViewCtrl tree = "DatablockEditorTree"; int id = tree.findItemByValue(datablock.getId().AsString()); if (id == 0) { return; } // Tag the item caption and sync the persistence manager. if (dirty) { tree.editItem(id, datablock.getName() + " *", datablock.getId().AsString()); this.PM.setDirty(datablock); } else { tree.editItem(id, datablock.getName(), datablock.getId().AsString()); this.PM.removeDirty(datablock); } // Sync the inspector dirty state. this.flagInspectorAsDirty(this.PM.hasDirty()); }
public void onInspectorPreFieldModification(string fieldName, string arrayIndex) { GuiEditorGui.GuiEditor GuiEditor = "GuiEditor"; Util.pushInstantGroup(); //UndoManager undoManager = GuiEditor.getUndoManager(); SimObject objectx = this.getInspectObject(); string nameOrClass = objectx.getName(); if (nameOrClass == "") { nameOrClass = objectx.getClassName(); } ObjectCreator oc = new ObjectCreator("InspectorFieldUndoAction"); oc["actionName"] = nameOrClass + "." + fieldName + " Change"; oc["objectId"] = objectx.getId(); oc["fieldName"] = fieldName; oc["fieldValue"] = objectx.getFieldValue(fieldName, arrayIndex == "(null)" ? -1 : arrayIndex.AsInt()); oc["arrayIndex"] = arrayIndex; oc["inspectorGui"] = this; InspectorFieldUndoAction action = oc.Create(); this.currentFieldEditAction = action; Util.popInstantGroup(); }
public static bool UnregisterObject(SimObject obj) { bool isDead = IsDead(obj.ObjectPtr); UnregisterObjectPtr(obj.ObjectPtr); if (isDead) { return(true); } if (!ObjectDictionary.ContainsKey(obj.getId())) { return(false); } ObjectDictionary.Remove(obj.getId()); return(true); }
public static object CreateInstance(Type type, SimObject objectWrapper) { if (!ObjectDictionary.ContainsKey(objectWrapper.getId()) || !(type.IsInstanceOfType(ObjectDictionary[objectWrapper.getId()]))) { SimObject obj = (SimObject)FormatterServices.GetUninitializedObject(type); obj.SetPointerFromObject(objectWrapper); RegisterObject(obj); ObjectDictionary[objectWrapper.getId()] = obj; } SimObject dicObject = ObjectDictionary[objectWrapper.getId()]; if (!string.IsNullOrEmpty(dicObject.Name)) { ObjectNameDictionary[dicObject.Name] = dicObject.getId(); } return(dicObject); }
public static string CallScriptMethod(string className, string classNamespace, SimObject objectWrapper, string methodName, object[] args, out bool found) { if (methodName.Equals("pushDialog")) { methodName = methodName; } Type type; string objectName = objectWrapper.getName(); if (objectName != null && ClassTypeDictionary.ContainsKey(objectName)) { type = ClassTypeDictionary[objectName]; } else if (classNamespace != null && ClassTypeDictionary.ContainsKey(classNamespace)) { type = ClassTypeDictionary[classNamespace]; } else if (ClassTypeDictionary.ContainsKey(className)) { type = ClassTypeDictionary[className]; } else if (SimDictionary.Find(objectWrapper.Name) != null) { type = SimDictionary.Find(objectWrapper.Name).GetType(); } else if (SimDictionary.Find(objectWrapper.getId()) != null) { type = SimDictionary.Find(objectWrapper.getId()).GetType(); } else { if (ClassTypeDictionary.ContainsKey(objectWrapper.GetType().Name)) { type = ClassTypeDictionary[objectWrapper.GetType().Name]; } else { found = false; return(null); } } return(CallNamespaceMethod(type, objectWrapper, methodName, args, out found)); }
public int addExistingItem(SimObject datablock, bool dontSort) { GuiTreeViewCtrl tree = "DatablockEditorTree"; // Look up class at root level. Create if needed. string className = datablock.getClassName(); int parentID = tree.findItemByName(className); if (parentID == 0) { parentID = tree.insertItem(0, className, "", "", 0, 0); } // If the datablock is already there, don't // do anything. if (tree.findItemByValue(datablock.getId().AsString()).AsBool()) { return(0); } // It doesn't exist so add it. string name = datablock.getName(); if (this.PM.isDirty(datablock)) { name = name + " *"; } int id = tree.insertItem(parentID, name, datablock.getId().AsString(), "", 0, 0); if (!dontSort) { tree.sort(parentID, false, false, false); } return(id); }
public override void onInspectorFieldModified(string objectx, string fieldName, string arrayIndex, string oldValue, string newValue) { SimObject obj = objectx; GuiEditorGui.GuiEditor GuiEditor = "GuiEditor"; GuiEditorProfilesTree GuiEditorProfilesTree = "GuiEditorProfilesTree"; GuiEditorProfileChangeManager GuiEditorProfileChangeManager = "GuiEditorProfileChangeManager"; ProfilePane ProfilePane = "ProfilePane"; GuiEditor.setProfileDirty(obj, true, false); // If it's the name field, make sure to sync up the treeview. if (fieldName == "name") { GuiEditorProfilesTree.onProfileRenamed(obj, newValue); } // Add change record. //GuiEditorProfileChangeManager.registerEdit(obj, fieldName, oldValue); GuiEditorProfileChangeManager.registerEdit(obj, fieldName, arrayIndex, oldValue); // Add undo. 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(); Util.popInstantGroup(); action.addToManager(ProfilePane.getUndoManager()); //GuiEditor.updateUndoMenu(); }
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 onInspectorPreFieldModification(string fieldName, string arrayIndex) { GuiEditorGui.GuiEditor GuiEditor = "GuiEditor"; Util.pushInstantGroup(); UndoManager undoManager = GuiEditor.getUndoManager(); string action = ""; int numObjects = this.getNumInspectObjects(); if (numObjects > 1) { action = undoManager.pushCompound("Multiple Field Edit"); } for (uint i = 0; i < numObjects; i++) { SimObject obj = this.getInspectObject(i); 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"] = obj.getFieldValue(fieldName, arrayIndex == "(null)" ? -1 : arrayIndex.AsInt()); oc["arrayIndex"] = arrayIndex; oc["inspectorGui"] = this; InspectorFieldUndoAction undo = oc.Create(); if (numObjects > 1) { undo.addToManager(undoManager); } else { action = undo; break; } } this.currentFieldEditAction = action; Util.popInstantGroup(); }
/// <summary> /// A helper function which will return the ghosted client object /// from a server object when connected to a local server. /// </summary> /// <param name="serverObject"></param> public static int serverToClientObject(SimObject serverObject) { Debug.Assert(Global.isObject("LocalClientConnection"), "serverToClientObject() - No local client connection found!"); Debug.Assert(Global.isObject("ServerConnection"), "serverToClientObject() - No server connection found!"); GameConnection LocalClientConnection = Sim.FindObject <GameConnection>("LocalClientConnection"); GameConnection ServerConnection = Sim.FindObject <GameConnection>("ServerConnection"); int ghostId = LocalClientConnection.getGhostID(serverObject.getId()); if (ghostId == -1) { return(0); } return(ServerConnection.resolveGhostID(ghostId)); }
public static object RegisterObject(SimObject obj) { RegisterObjectPtr(obj.ObjectPtr); int id = obj.getId(); if (!ObjectDictionary.ContainsKey(id) || ObjectDictionary[id].GetType().IsInstanceOfType(obj)) { ObjectDictionary[id] = obj; } if (!string.IsNullOrEmpty(obj.Name)) { ObjectNameDictionary[obj.Name] = id; } return(ObjectDictionary[id]); }
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 static void Inspect(SimObject obj) { GuiInspector InspectFields = "InspectFields"; GuiTextEditCtrl InspectObjectName = "InspectObjectName"; GuiTextEditCtrl InspectObjectInternalName = "InspectObjectInternalName"; GuiTextCtrl InspectObjectSimID = "InspectObjectSimID"; // Don't inspect the root group. if (obj == -1) { return; } InspectFields.inspect(obj); // Update selected object properties InspectObjectName.setValue(obj.getName()); InspectObjectInternalName.setValue(obj.getInternalName()); InspectObjectSimID.setValue(obj.getId().AsString()); // Store Object Reference InspectObjectName["refObj"] = obj; }
public override void onInspectorFieldModified(string objectx, string fieldName, string arrayIndex, string oldValue, string newValue) { SimObject obj = objectx; GuiEditorGui.GuiEditor GuiEditor = "GuiEditor"; // 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(); // Restore the instant group. Util.popInstantGroup(); action.addToManager(GuiEditor.getUndoManager()); GuiEditor.updateUndoMenu(); }
public void loadNewParticle(SimObject particle) { GuiPopUpMenuCtrl PEP_ParticleSelector = "PEP_ParticleSelector"; ParticleData PE_ParticleEditor_NotDirtyParticle = "PE_ParticleEditor_NotDirtyParticle"; if (particle.isObject()) { particle = particle.getId().AsString(); } else { particle = PEP_ParticleSelector.getSelected().AsString(); } this.currParticle = particle; particle.call("reload"); PE_ParticleEditor_NotDirtyParticle.assignFieldsFrom(particle); PE_ParticleEditor_NotDirtyParticle["originalName"] = particle.getName(); this.guiSync(); this.setParticleNotDirty(); }
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); }