void GroupEditorWindow(int windowID) { var expand = GUILayout.ExpandWidth(true); var width20 = GUILayout.Width(20); var width40 = GUILayout.Width(40); var width60 = GUILayout.Width(60); var maxHeight = GUILayout.MaxHeight(Screen.height / 2); Vector2 mousePos = Input.mousePosition; mousePos.y = Screen.height - mousePos.y; editorScroll = GUILayout.BeginScrollView(editorScroll, false, false, maxHeight); //Kick off the window code GUIDragAndDrop.WindowBegin(groupEditorWinPos, editorScroll); GUILayout.BeginVertical(); if (ToolbarManager.ToolbarAvailable) { if (GUILayout.Button("Close")) { saveConfigXML(); groupEditorEnabled = false; } } GUILayout.BeginHorizontal(); //if we are showing the group handles then Pad the text so it still aligns with the text box if (GUIDragAndDrop.ShowGroupHandles) { GUIDragAndDrop.PadText(); } GUILayout.Label("Group Name", expand); GUILayout.Label("Keys", width40); if (servo_groups.Count > 1) { GUILayout.Space(60); } GUILayout.EndHorizontal(); for (int i = 0; i < servo_groups.Count; i++) { Group grp = servo_groups[i]; GUILayout.BeginHorizontal(); //Call the Add Group Handle code GUIDragAndDrop.DrawGroupHandle(grp.name, i); string tmp = GUILayout.TextField(grp.name, expand); if (grp.name != tmp) { grp.name = tmp; } tmp = GUILayout.TextField(grp.forwardKey, width20); if (grp.forwardKey != tmp) { grp.forwardKey = tmp; } tmp = GUILayout.TextField(grp.reverseKey, width20); if (grp.reverseKey != tmp) { grp.reverseKey = tmp; } if (i > 0) { //set a smaller height to align with text boxes if (GUILayout.Button("Remove", width60, GUILayout.Height(EditorButtonHeights))) { foreach (var servo in grp.servos) { move_servo(grp, servo_groups[i - 1], servo); } servo_groups.RemoveAt(i); resetWin = true; return; } } else { if (servo_groups.Count > 1) { GUILayout.Space(60); } } GUILayout.EndHorizontal(); if (useEC) { GUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.Label(string.Format("Estimated Power Draw: {0:#0.##} Ec/s", grp.groupTotalECRequirement), expand); GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); //Pad the text so it still aligns with the text box GUIDragAndDrop.PadText(); GUILayout.Label("Servo Name", expand); if (update14to15) { GUILayout.Label("Rotation", expand); } if (servo_groups.Count > 1) { GUILayout.Label("Group", width40); } GUILayout.EndHorizontal(); //foreach (var servo in grp.servos) for (int iS = 0; iS < grp.servos.Count; iS++) { var servo = grp.servos[iS]; if (!servo.freeMoving) { GUILayout.BeginHorizontal(); //Call the Add Servo Handle code GUIDragAndDrop.DrawServoHandle(servo.servoName, i, iS); //set a smaller height to align with text boxes if (GUILayout.Button("[]", GUILayout.Width(30), GUILayout.Height(EditorButtonHeights))) { tmpMin = servo.minTweak.ToString(); tmpMax = servo.maxTweak.ToString(); servoTweak = servo; guiTweakEnabled = true; } servo.servoName = GUILayout.TextField(servo.servoName, expand); //0.14 to 0.15 fix if (update14to15) { string tempRot = GUILayout.TextField(servo.rotation.ToString(), expand); servo.rotation = float.Parse(tempRot); } //0.14 to 0.15 fix servo.groupName = grp.name; servo.reverseKey = grp.reverseKey; servo.forwardKey = grp.forwardKey; if (groupEditorWinPos.Contains(mousePos)) { var last = GUILayoutUtility.GetLastRect(); var pos = Event.current.mousePosition; bool highlight = last.Contains(pos); servo.part.SetHighlight(highlight); } if (servo_groups.Count > 1) { if (i > 0) { //Changed these to actual arrows - and set a smaller height to align with text boxes if (GUILayout.Button("↑", width20, GUILayout.Height(EditorButtonHeights))) { move_servo(grp, servo_groups[i - 1], servo); } } else { GUILayout.Space(20); } if (i < (servo_groups.Count - 1)) { //Changed these to actual arrows - and set a smaller height to align with text boxes if (GUILayout.Button("↓", width20, GUILayout.Height(EditorButtonHeights))) { move_servo(grp, servo_groups[i + 1], servo); } } else { GUILayout.Space(20); } } GUILayout.EndHorizontal(); } } GUIDragAndDrop.EndDrawGroup(i); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } if (GUILayout.Button("Add new Group")) { Group temp = new Group(); temp.name = "New Group" + (servo_groups.Count + 1).ToString(); servo_groups.Add(temp); } GUILayout.EndVertical(); GUILayout.EndScrollView(); //Was gonna add a footer so you can drag resize the window and have the option to turn on dragging control //GUILayout.BeginHorizontal(); //zTriggerTweaks.DragOn = GUILayout.Toggle(zTriggerTweaks.DragOn,new GUIContent(GameDatabase.Instance.GetTexture("MagicSmokeIndustries/Textures/icon_drag",false))); //GUILayout.EndHorizontal(); //Do the End of window Code for DragAnd Drop GUIDragAndDrop.WindowEnd(); //If we are dragging an item disable the windowdrag if (!GUIDragAndDrop.draggingItem) { GUI.DragWindow(); } }