private void CallOnTextAreaDeselect(SDEComponent component) { if (OnTextAreaDeselect != null) { OnTextAreaDeselect(this); } }
public void Init(SDEComponent parent, string text, float width, float height) { base.Init(SDEComponentType.Label, parent, new Rect(0, 0, width, height), SDEStyles.labelDefault, null, null); Init(text); }
/* * Used at the start of an event processing queue to check if anything * was selected within that queue. * * For now, only handled on mouse down, as keyboard input does not influence * component selection. */ public static void StartSelectionEventProcessing(Event e) { if (e.type == EventType.MouseDown) { eventSelectionStarted = true; componentSelectedOnEvent = false; _selectedEventComponent = null; } }
public void Init(SDEComponent parent, string text, float width) { Init(SDEComponentType.TextArea, parent, new Rect(0, 0, width - 2 * TextAreaManager.X_PAD, 0), SDEStyles.textBoxDefault, SDEStyles.textBoxDefault, SDEStyles.textBoxSelected); Init(text); }
/* * Deselect() removes the given component from the current selection. * * If the component is not part of the selection, or if there is * currently nothing selected, then nothing happens. */ public static void Deselect(SDEComponent component) { if (_selectedComponent == null) { return; } if (_selectedComponent.Equals(component)) { _selectedComponent = null; } }
public void Init(SDEComponentType componentType, SDEComponent parent, Rect rect, GUIStyle style, GUIStyle defaultStyle, GUIStyle selectedStyle, SDEContainer container = null) { this.componentType = componentType; this.parent = parent; this.container = container; this.rect = rect; // default click rect to be the same as the rect, but only specific component types // will continuously update the clickRect position. this.clickRect = rect; this.style = style; this.defaultStyle = defaultStyle; this.selectedStyle = selectedStyle; }
public void Init(SDEComponent parent, ConnectionPointType connectionType) { base.Init(SDEComponentType.ConnectionPoint, parent, new Rect(0, 0, ConnectionManager.CONNECTIONPOINT_WIDTH, ConnectionManager.CONNECTIONPOINT_HEIGHT), SDEStyles.connectionPointDefault, SDEStyles.connectionPointDefault, SDEStyles.connectionPointSelected); this.connectionType = connectionType; // determine what method to be called when clicked if (this.connectionType == ConnectionPointType.In) { this.OnClickConnectionPoint = ConnectionManager.OnClickInPoint; } else { this.OnClickConnectionPoint = ConnectionManager.OnClickOutPoint; } this.connections = new List <Connection>(); }
public static void RecordCompleteComponent(SDEComponent component) { Undo.RegisterCompleteObjectUndo(component, ""); MarkModified(); }
/* * SelectComponent() gives selection awareness of the given component. */ public static void SelectComponent(SDEComponent component) { _selectedComponent = component; _selectedEventComponent = component; componentSelectedOnEvent = true; }
/* * ClearSelection() resets the selection */ public static void ClearSelection() { _selectedComponent = null; }
/* * ProcessKeyboardInput() takes a given key and triggers a process based on the hotkey. * * Returns true if a hotkey was given, false otherwise. */ private bool ProcessKeyboardInput(KeyCode key) { // check modifiers if (Event.current.shift) { // shift + 'S' save entry as if (key == KeyCode.S) { Debug.Log("saving as..."); bool saved = SDEXMLManager.SaveItems(true); if (saved) { HistoryManager.needsSave = false; } return(true); } // shift + 'N' open new if (key == KeyCode.N) { if (!EditorUtility.DisplayDialog("Start new entry", "Are you sure you want to start a new entry and close the current one?", "yes", "no")) { return(true); } DestroyScene(); HistoryManager.needsSave = false; return(true); } } else { // 'C' center on node positions if (key == KeyCode.C) { if (nodes != null && nodes.Count > 0) { Debug.Log("centering on nodes..."); // calculate current average Vector2 avgPosition = new Vector2(); for (int i = 0; i < nodes.Count; i++) { avgPosition += nodes[i].rect.center; } avgPosition /= nodes.Count; // reshift everything by this new average, including window size OnDrag(-avgPosition + (position.size / 2)); } else { Debug.Log("no nodes to center on"); } return(true); } // 'D' delete the selected node if (key == KeyCode.D) { if (nodes != null && SelectionManager.SelectedComponent() != null) { Debug.Log("deleting selected node..."); SDEComponent component = SelectionManager.SelectedComponent(); while (component != null) { if (component.componentType == SDEComponentType.Node) { // if a match is found, remove the Node if it's not an Interrupt and return if (((Node)component).nodeType != NodeType.Interrupt) { NodeManager.RemoveNode((Node)component); } return(true); } component = component.parent; } // if no match was found, that means the component had no Node parent! throw new UnityException("tried to delete SDEComponent with no parent Node!"); } else { Debug.Log("Ignoring 'D'elete, no Node selected!"); } return(true); } // 'H' show/hide the help box if (key == KeyCode.H) { if (drawHelp) { Debug.Log("Hiding Help menu"); drawHelp = false; } else { Debug.Log("Displaying Help menu"); drawHelp = true; } return(true); } // 'Q' show/hide debug information if (key == KeyCode.Q) { if (drawDebug) { Debug.Log("Hiding Debug info"); drawDebug = false; } else { Debug.Log("Displaying Debug info"); drawDebug = true; } return(true); } // 'S' saves entry if (key == KeyCode.S) { Debug.Log("saving..."); bool saved = SDEXMLManager.SaveItems(false); if (saved) { HistoryManager.needsSave = false; } return(true); } } return(false); }
/* * UpdateInterrupts() heavily modifies the editor by updating connected InterruptNodes * and associated connections depending on the interrupt flags defined in the textArea. */ private void UpdateInterrupts(SDEComponent textComponent) { HistoryManager.RecordEditor(); string text = ((TextArea)textComponent).text; // parse the text for interrupts flags List <string> flags; try { flags = GetFlags(text); } catch (UnityException e) { Debug.Log(e.Message); return; } // find an Interrupt Node that's connected to this Node interruptNode = DialogBoxManager.GetInterruptNode(outPoint); if (interruptNode == null) { interruptNode = ConnectInterruptNode(); } // update the Interrupt Node's bottom level status if (child == null) { interruptNode.SetBottomLevelInterrupt(true); } else { interruptNode.SetBottomLevelInterrupt(false); } // update the Interrupt Node DialogInterrupt interrupt = (DialogInterrupt)interruptNode.childContainer; List <DialogInterrupt> oldInterrupts = new List <DialogInterrupt>(); // remove all the old Interrupt Nodes, but queue the interrupts that need to be added. while (interrupt != null) { if (flags.Contains(interrupt.label.text)) { oldInterrupts.Add(interrupt); SDEContainerManager.RemoveContainer(interrupt, removeConnections: false, markHistory: false); } else { SDEContainerManager.RemoveContainer(interrupt, removeConnections: true, markHistory: false); } interrupt = (DialogInterrupt)interrupt.child; } // rebuild the nodes bool appendNode = true; bool foundMatch = false; DialogInterrupt newInterrupt = null; for (int i = 0; i < flags.Count; i++) { // look for pre-existing nodes that match the flag for (int j = 0; j < oldInterrupts.Count; j++) { if (flags[i] == oldInterrupts[j].label.text) { newInterrupt = oldInterrupts[j]; oldInterrupts.RemoveAt(j); foundMatch = true; break; } } if (!foundMatch) { newInterrupt = ScriptableObject.CreateInstance <DialogInterrupt>(); newInterrupt.Init(); newInterrupt.label.text = flags[i]; } // guarantee that we are dealing with a new, unlinked Container. SDEContainerManager.CleanLinks(newInterrupt); if (appendNode) { SDEContainerManager.InsertChild(interruptNode, newInterrupt); appendNode = false; } else { SDEContainerManager.InsertChild(interrupt, newInterrupt); } interrupt = newInterrupt; foundMatch = false; } }