public override void Update() { // Post-Init if (!init) { float buttonSize = 38f; float baseX = pos.x - WIDTH * 0.5f + 10 + buttonSize * 0.5f; float baseY = pos.y + HEIGHT * 0.5f - LINES_START - LINE_HEIGHT * (transUIElems.Length * 4) - 20 - buttonSize * 0.5f; float spacing = 5; prevPageButton = new Button("prev", new Vector2(baseX, baseY), buttonSize, false); nextPageButton = new Button("next", new Vector2(baseX + (buttonSize + spacing) * 1f, baseY), buttonSize, false); addButton = new Button("add", new Vector2(baseX + (buttonSize + spacing) * 2f, baseY), buttonSize, false); deleteButton = new Button("delete", new Vector2(baseX + (buttonSize + spacing) * 3f, baseY), buttonSize, false); copyButton = new Button("copy", new Vector2(baseX + (buttonSize + spacing) * 4f, baseY), buttonSize, false); pasteButton = new Button("paste", new Vector2(baseX + (buttonSize + spacing) * 5f, baseY), buttonSize, false); pageLabel.x = pos.x; pageLabel.y = baseY - buttonSize * 0.5f - spacing - pageLabel.textRect.height * 0.5f; titleLabel.x = pos.x; titleLabel.y = pos.y + HEIGHT * 0.5f + LINE_HEIGHT; VoezEditor.Editor.AddObject(prevPageButton); VoezEditor.Editor.AddObject(nextPageButton); VoezEditor.Editor.AddObject(addButton); VoezEditor.Editor.AddObject(deleteButton); VoezEditor.Editor.AddObject(copyButton); VoezEditor.Editor.AddObject(pasteButton); if (type == ProjectData.TrackTransformation.TransformType.MOVE) { mirrorButton = new Button("mirror", new Vector2(baseX + (buttonSize + spacing) * 6f, baseY), buttonSize, false); VoezEditor.Editor.AddObject(mirrorButton); } border = new RectangleBorder(new Rect(new Vector2(pos.x - WIDTH * 0.5f, pos.y - HEIGHT * 0.5f), new Vector2(WIDTH, HEIGHT)), 3f); VoezEditor.Editor.AddObject(border); page = TotalPages - 1; RefreshPages(); init = true; } // Edit Values if (transSelected >= 0 && transUIElems[transSelected % transUIElems.Length] != null) { int delta = 0; if (InputManager.UpTick()) { delta = 1; } if (InputManager.DownTick()) { delta = -1; } if (InputManager.RightTick()) { delta = 5; } if (InputManager.LeftTick()) { delta = -5; } if (delta != 0) { if (Util.CtrlDown() && (itemSelected == 1 || itemSelected == 2)) { // Shift all keyframes after this one float shiftAmount = delta * VoezEditor.Editor.GetBPMTimeIncrement(); float endShiftLimit = parent.data.end - transList[transList.Count - 1].end; float startShiftLimit = 0; if (itemSelected == 2) { startShiftLimit = transList[transSelected].start - transList[transSelected].end; } else { if (transSelected == 0) { startShiftLimit = parent.data.start - transList[transSelected].start; } else { startShiftLimit = transList[transSelected - 1].end - transList[transSelected].start; } } if (shiftAmount > endShiftLimit) { shiftAmount = endShiftLimit; } if (shiftAmount < startShiftLimit) { shiftAmount = startShiftLimit; } if (itemSelected == 1) { transList[transSelected].start += shiftAmount; } transList[transSelected].end += shiftAmount; for (int i = transSelected + 1; i < transList.Count; i += 1) { transList[i].start += shiftAmount; transList[i].end += shiftAmount; } if (itemSelected == 1) { VoezEditor.Editor.JumpToTime(transList[transSelected].start); } else { VoezEditor.Editor.JumpToTime(transList[transSelected].end); } for (int i = 0; i < transUIElems.Length; i += 1) { if (transUIElems[i] != null) { transUIElems[i].RefreshLabelValues(); } } } else { transUIElems[transSelected % transUIElems.Length].UpdateValue(itemSelected, delta); } } } // Mouse Slide Value Editing if (Input.GetMouseButton(1) && !VoezEditor.Editor.ui.HoveringOverSubmenuItem()) { if (transSelected >= 0 && itemSelected == 0 && type == ProjectData.TrackTransformation.TransformType.MOVE) { VoezEditor.Editor.ui.trackAdder.previewScale = 1f; VoezEditor.Editor.ui.trackAdder.previewX = -1f; // will default to following the mouse transUIElems[transSelected % transUIElems.Length].data.to = Util.InvScreenPosX(VoezEditor.Editor.ui.trackAdder.pos.x); transUIElems[transSelected % transUIElems.Length].RefreshLabelValues(); } if (transSelected >= 0 && itemSelected == 0 && type == ProjectData.TrackTransformation.TransformType.SCALE) { Track myTrack = null; for (int i = 0; i < VoezEditor.Editor.activeTracks.Count; i += 1) { if (VoezEditor.Editor.activeTracks[i].ID == parent.data.id) { myTrack = VoezEditor.Editor.activeTracks[i]; break; } } if (myTrack == null) { VoezEditor.Editor.ui.trackAdder.previewX = parent.data.x; } else { VoezEditor.Editor.ui.trackAdder.previewX = Util.InvScreenPosX(myTrack.pos.x); } VoezEditor.Editor.ui.trackAdder.previewScale = Mathf.Abs(Input.mousePosition.x - Util.ScreenPosX(VoezEditor.Editor.ui.trackAdder.previewX)) / (VoezEditor.windowRes.x * Track.TRACK_SCREEN_WIDTH); VoezEditor.Editor.ui.trackAdder.previewScale = Mathf.Clamp(VoezEditor.Editor.ui.trackAdder.previewScale * 2f, 0f, 10f); transUIElems[transSelected % transUIElems.Length].data.to = VoezEditor.Editor.ui.trackAdder.previewScale; transUIElems[transSelected % transUIElems.Length].RefreshLabelValues(); } } else if (Input.GetMouseButtonUp(1)) { VoezEditor.Editor.ui.trackAdder.previewScale = -1f; VoezEditor.Editor.ui.trackAdder.previewX = -1f; } // Page Navigation if (prevPageButton.clicked) { if (page > 0) { if (transSelected >= 0) { transSelected = Mathf.Clamp(transSelected - transUIElems.Length, 0, transList.Count - 1); } else { page -= 1; } RefreshPages(); } else if (transList.Count > 0) { transSelected = transList.Count - 1; RefreshPages(); } prevPageButton.clicked = false; } if (nextPageButton.clicked) { if (page < TotalPages - 1) { if (transSelected >= 0) { transSelected = Mathf.Clamp(transSelected + transUIElems.Length, 0, transList.Count - 1); } else { page += 1; } RefreshPages(); } else if (transList.Count > 0) { transSelected = 0; RefreshPages(); } nextPageButton.clicked = false; } // Add and Delete Transformations if (addButton.clicked) { ProjectData.TrackTransformation transformation = new ProjectData.TrackTransformation(); // Default Values if (type == ProjectData.TrackTransformation.TransformType.SCALE) { transformation.to = 1.0f; } if (type == ProjectData.TrackTransformation.TransformType.MOVE) { transformation.to = 0.5f; } if (transSelected < 0) { transSelected = transList.Count - 1; // If no item selected, default to adding at end of trans list. } if (transList.Count == 0) { transformation.start = parent.data.start; transformation.end = parent.data.end; } else if (Util.ShiftDown()) { // Add Before selection transformation.end = transList[transSelected].start; if (transSelected == 0) { transformation.start = Mathf.Max(transformation.end - VoezEditor.Editor.GetBPMTimeIncrement() * 5, parent.data.start); } else { transformation.start = Mathf.Max(transformation.end - VoezEditor.Editor.GetBPMTimeIncrement() * 5, transList[transSelected - 1].end); } } else { // Add After Selection transformation.start = transList[transSelected].end; if (transSelected == transList.Count - 1) { transformation.end = Mathf.Min(transformation.start + VoezEditor.Editor.GetBPMTimeIncrement() * 5, parent.data.end); } else { transformation.end = Mathf.Min(transformation.start + VoezEditor.Editor.GetBPMTimeIncrement() * 5, transList[transSelected + 1].start); } } if (transformation.end >= transformation.start) { transList.Add(transformation); transSelected = Mathf.Clamp(transSelected + 1, 0, transList.Count - 1); ResortDataList(); RefreshPages(); } addButton.clicked = false; } if (deleteButton.clicked) { if (transList.Count > 0 && transSelected >= 0) { transList.RemoveAt(transSelected); transSelected -= 1; RefreshPages(); } deleteButton.clicked = false; } // Copy and Paste Transformations if (copyButton.clicked) { VoezEditor.Editor.project.transformClipboard = ProjectData.DeepCopyTransformationList(transList); VoezEditor.Editor.project.clipboardContentsType = type; VoezEditor.Editor.project.transformClipboardStartTime = parent.data.start; copyButton.clicked = false; } if (pasteButton.clicked) { if (VoezEditor.Editor.project.transformClipboard != null && VoezEditor.Editor.project.clipboardContentsType == type) { ProjectData.ReplaceTransformationList(VoezEditor.Editor.project.transformClipboard, transList, VoezEditor.Editor.project.transformClipboardStartTime, parent.data.start); for (int i = 0; i < transList.Count; i += 1) { if (transList[i].end > parent.data.end) { // Pasting can change the total duration of the track if the new keyframes span beyond that duration. parent.data.end = transList[i].end; parent.endLabel.text = "Despawn Time: " + VoezEditor.Editor.BeatTimeStamp(parent.data.end); } } page = 0; transSelected = -1; RefreshPages(); } pasteButton.clicked = false; } // Mirror X if (mirrorButton != null && mirrorButton.clicked) { if (Util.ShiftDown()) { if (transSelected != -1) { transList[transSelected].to = 1f - transList[transSelected].to; } else { parent.data.x = 1f - parent.data.x; } } else { parent.data.x = 1f - parent.data.x; for (int i = 0; i < transList.Count; i += 1) { transList[i].to = 1f - transList[i].to; } } RefreshPages(); parent.RefreshValueLabel(); mirrorButton.clicked = false; } if (transSelected != -1) { parent.selectedLine = -1; } base.Update(); }