From bbecab14c032869bebca8296041b65b225738469 Mon Sep 17 00:00:00 2001 From: lunarcleint Date: Mon, 14 Oct 2024 18:15:56 -0700 Subject: [PATCH] GUYS THIS IS DEV BRANCH --- source/funkin/editors/charter/Charter.hx | 116 +++++++++++------- .../editors/charter/CharterBackdropGroup.hx | 13 +- source/funkin/editors/charter/CharterEvent.hx | 4 +- .../funkin/editors/charter/CharterEventAdd.hx | 18 +-- .../editors/charter/CharterEventGroup.hx | 1 + .../editors/charter/CharterEventScreen.hx | 8 +- .../editors/charter/CharterStrumLineGroup.hx | 25 ++-- .../editors/charter/CharterStrumlineScreen.hx | 6 +- 8 files changed, 118 insertions(+), 73 deletions(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 0f6ab63b..93ec7d28 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -48,8 +48,10 @@ class Charter extends UIState { public var topMenuSpr:UITopMenu; public var gridBackdrops:CharterBackdropGroup; - public var eventsBackdrop:EventBackdrop; - public var addEventSpr:CharterEventAdd; + public var localEventsBackdrop:EventBackdrop; + public var localAddEventSpr:CharterEventAdd; + public var globalEventsBackdrop:EventBackdrop; + public var globalAddEventSpr:CharterEventAdd; public var gridBackdropDummy:CameraHoverDummy; public var noteHoverer:CharterNoteHoverer; @@ -73,7 +75,9 @@ class Charter extends UIState { public var strumLines:CharterStrumLineGroup = new CharterStrumLineGroup(); public var notesGroup:CharterNoteGroup = new CharterNoteGroup(); - public var eventsGroup:CharterEventGroup = new CharterEventGroup(); + + public var localEventsGroup:CharterEventGroup = new CharterEventGroup(); + public var globalEventsGroup:CharterEventGroup = new CharterEventGroup(); public var charterCamera:FlxCamera; public var uiCamera:FlxCamera; @@ -405,10 +409,15 @@ class Charter extends UIState { gridBackdrops = new CharterBackdropGroup(strumLines); gridBackdrops.notesGroup = this.notesGroup; - eventsBackdrop = new EventBackdrop(); - eventsBackdrop.x = -eventsBackdrop.width; - eventsBackdrop.cameras = [charterCamera]; - eventsGroup.eventsBackdrop = eventsBackdrop; + localEventsBackdrop = new EventBackdrop(false); + localEventsBackdrop.x = -localEventsBackdrop.width; + localEventsBackdrop.cameras = [charterCamera]; + localEventsGroup.eventsBackdrop = localEventsBackdrop; + + globalEventsBackdrop = new EventBackdrop(true); + globalEventsBackdrop.x = 0; + globalEventsBackdrop.cameras = [charterCamera]; + globalEventsGroup.eventsBackdrop = globalEventsBackdrop; add(gridBackdropDummy = new CameraHoverDummy(gridBackdrops, FlxPoint.weak(1, 0))); selectionBox = new UISliceSprite(0, 0, 2, 2, 'editors/ui/selection'); @@ -480,17 +489,25 @@ class Charter extends UIState { strumlineInfoBG.cameras = [charterCamera]; strumLines.cameras = [charterCamera]; - addEventSpr = new CharterEventAdd(); - addEventSpr.x -= addEventSpr.bWidth; - addEventSpr.cameras = [charterCamera]; - addEventSpr.alpha = 0; + localAddEventSpr = new CharterEventAdd(false); + localAddEventSpr.x -= localAddEventSpr.bWidth; + localAddEventSpr.cameras = [charterCamera]; + localAddEventSpr.alpha = 0; + + globalAddEventSpr = new CharterEventAdd(true); + globalAddEventSpr.x = 0; + globalAddEventSpr.cameras = [charterCamera]; + globalAddEventSpr.alpha = 0; // adds grid and notes so that they're ALWAYS behind the UI add(gridBackdrops); //add(textLayer = new FlxLayer()); - add(eventsBackdrop); - add(addEventSpr); - add(eventsGroup); + add(localEventsBackdrop); + add(localAddEventSpr); + add(localEventsGroup); + add(globalEventsBackdrop); + add(globalAddEventSpr); + add(globalEventsGroup); add(noteHoverer); add(noteDeleteAnims); add(notesGroup); @@ -576,7 +593,7 @@ class Charter extends UIState { notesGroup.autoSort = true; // create events - eventsGroup.autoSort = false; + localEventsGroup.autoSort = false; var __last:CharterEvent = null; var __lastTime:Float = Math.NaN; for(e in PlayState.SONG.events) { @@ -586,14 +603,14 @@ class Charter extends UIState { } else { __last = new CharterEvent(Conductor.getStepForTime(e.time), [e]); __lastTime = e.time; - eventsGroup.add(__last); + localEventsGroup.add(__last); } } - eventsGroup.sortEvents(); - eventsGroup.autoSort = true; + localEventsGroup.sortEvents(); + localEventsGroup.autoSort = true; - for(e in eventsGroup.members) + for(e in localEventsGroup.members) e.refreshEventIcons(); buildNoteTypesUI(); @@ -613,7 +630,7 @@ class Charter extends UIState { scrollBar.length = __endStep = Conductor.getStepForTime(length); gridBackdrops.bottomLimitY = __endStep * 40; - eventsBackdrop.bottomSeparator.y = gridBackdrops.bottomLimitY-2; + localEventsBackdrop.bottomSeparator.y = globalEventsBackdrop.bottomSeparator.y = gridBackdrops.bottomLimitY-2; updateWaveforms(); } @@ -694,7 +711,7 @@ class Charter extends UIState { else selection = [s]; } - for (group in [notesGroup, eventsGroup]) { + for (group in [notesGroup, localEventsGroup, globalEventsGroup]) { cast(group, FlxTypedGroup).forEach(function(s) { s.selected = false; if (gridActionType == NONE) { @@ -760,18 +777,18 @@ class Charter extends UIState { selectionBox.bHeight = Std.int(Math.abs(mousePos.y - dragStartPos.y)); } else { if (FlxG.keys.pressed.SHIFT) { - for (group in [notesGroup, eventsGroup]) + for (group in [notesGroup, localEventsGroup, globalEventsGroup]) for(n in cast(group, FlxTypedGroup)) if (n.handleSelection(selectionBox) && selection.contains(n)) selection.remove(n); } else if (FlxG.keys.pressed.CONTROL) { - for (group in [notesGroup, eventsGroup]) + for (group in [notesGroup, localEventsGroup, globalEventsGroup]) for(n in cast(group, FlxTypedGroup)) if (n.handleSelection(selectionBox) && !selection.contains(n)) selection.push(n); } else { selection = []; - for (group in [notesGroup, eventsGroup]) + for (group in [notesGroup, localEventsGroup, globalEventsGroup]) for(n in cast(group, FlxTypedGroup)) if (n.handleSelection(selectionBox)) selection.push(n); @@ -834,7 +851,7 @@ class Charter extends UIState { if (s is UISprite) cast(s, UISprite).cursor = CLICK; } if (!(verticalChange == 0 && horizontalChange == 0)) { - notesGroup.sortNotes(); eventsGroup.sortEvents(); + notesGroup.sortNotes(); localEventsGroup.sortEvents(); globalEventsGroup.sortEvents(); undos.addToUndo(CSelectionDrag(undoDrags)); } @@ -943,18 +960,24 @@ class Charter extends UIState { gridActionType = NONE; deletedNotes = []; } } - addEventSpr.selectable = !selectionBox.visible; + localAddEventSpr.selectable = !selectionBox.visible; + globalAddEventSpr.selectable = !selectionBox.visible; var inBoundsY:Bool = (mousePos.y > 0 && mousePos.y < (__endStep)*40); // Event Spr - if (mousePos.x < 0 && mousePos.x > -addEventSpr.bWidth && gridActionType == NONE && inBoundsY) { - addEventSpr.incorporeal = false; - addEventSpr.sprAlpha = lerp(addEventSpr.sprAlpha, 0.75, 0.25); - var event = getHoveredEvent(mousePos.y); - if (event != null) addEventSpr.updateEdit(event); - else addEventSpr.updatePos(FlxG.keys.pressed.SHIFT ? ((mousePos.y) / 40) : quantStepRounded(mousePos.y/40)); - } else addEventSpr.sprAlpha = lerp(addEventSpr.sprAlpha, 0, 0.25); + for (addEventSpr in [localAddEventSpr, globalAddEventSpr]) { + if ((!addEventSpr.global ? (mousePos.x < 0 && mousePos.x > -addEventSpr.bWidth) : + (mousePos.x > strumLines.totalKeyCount * 40 && mousePos.x < strumLines.totalKeyCount * 40 + addEventSpr.bWidth)) + && gridActionType == NONE && inBoundsY) { + + addEventSpr.incorporeal = false; + addEventSpr.sprAlpha = lerp(addEventSpr.sprAlpha, 0.75, 0.25); + var event = getHoveredEvent(mousePos.y, !addEventSpr.global ? localEventsGroup : globalEventsGroup); + if (event != null) addEventSpr.updateEdit(event); + else addEventSpr.updatePos(FlxG.keys.pressed.SHIFT ? ((mousePos.y) / 40) : quantStepRounded(mousePos.y/40)); + } else addEventSpr.sprAlpha = lerp(addEventSpr.sprAlpha, 0, 0.25); + } noteHoverer.showHoverer = Charter.instance.gridBackdropDummy.hovered; } @@ -972,9 +995,9 @@ class Charter extends UIState { public function ratioRound(val:Float, ratio:Float):Int return Math.floor(val) + ((Math.abs(val % 1) > ratio ? 1 : 0) * (val > 0 ? 1 : -1)); - public function getHoveredEvent(y:Float) { + public function getHoveredEvent(y:Float, group:CharterEventGroup) { var eventHovered:CharterEvent = null; - eventsGroup.forEach(function(e) { + group.forEach(function(e) { if (eventHovered != null) return; @@ -995,7 +1018,7 @@ class Charter extends UIState { note.kill(); } else if (selected is CharterEvent) { var event:CharterEvent = cast selected; - eventsGroup.remove(event); + (event.global ? globalEventsGroup : localEventsGroup).remove(event); event.kill(); } @@ -1015,7 +1038,7 @@ class Charter extends UIState { notesGroup.add(n); }, function (e:CharterEvent) { e.revive(); - eventsGroup.add(e); + (e.global ? globalEventsGroup : localEventsGroup).add(e); e.refreshEventIcons(); }, false); notesGroup.sortNotes(); @@ -1036,7 +1059,7 @@ class Charter extends UIState { if (selection.length <= 0) return []; notesGroup.autoSort = false; - for (objects in [notesGroup, eventsGroup]) { + for (objects in [notesGroup, localEventsGroup, globalEventsGroup]) { var group = cast(objects, FlxTypedGroup); var member = 0; while(member < group.members.length) { @@ -1428,7 +1451,7 @@ class Charter extends UIState { case CEvent(step, events): var event = new CharterEvent(minStep + step, events); event.refreshEventIcons(); - eventsGroup.add(event); + (event.global ? globalEventsGroup : localEventsGroup).add(event); sObjects.push(event); } } @@ -1627,11 +1650,11 @@ class Charter extends UIState { } function _view_showeventSecSeparator(t) { t.icon = (Options.charterShowSections = !Options.charterShowSections) ? 1 : 0; - eventsBackdrop.eventSecSeparator.visible = gridBackdrops.sectionsVisible = Options.charterShowSections; + localEventsBackdrop.eventSecSeparator.visible = globalEventsBackdrop.eventSecSeparator.visible = gridBackdrops.sectionsVisible = Options.charterShowSections; } function _view_showeventBeatSeparator(t) { t.icon = (Options.charterShowBeats = !Options.charterShowBeats) ? 1 : 0; - eventsBackdrop.eventBeatSeparator.visible = gridBackdrops.beatsVisible = Options.charterShowBeats; + localEventsBackdrop.eventBeatSeparator.visible = globalEventsBackdrop.eventBeatSeparator.visible = gridBackdrops.beatsVisible = Options.charterShowBeats; } function _view_switchWaveformDetail(t) { t.icon = (Options.charterLowDetailWaveforms = !Options.charterLowDetailWaveforms) ? 1 : 0; @@ -1832,8 +1855,9 @@ class Charter extends UIState { public function buildEvents() { PlayState.SONG.events = []; - eventsGroup.sortEvents(); - for(e in eventsGroup.members) { + // TODO!!!! + localEventsGroup.sortEvents(); + for(e in localEventsGroup.members) { for(event in e.events) { event.time = Conductor.getTimeForStep(e.step); PlayState.SONG.events.push(event); @@ -1864,8 +1888,10 @@ class Charter extends UIState { @:noCompletion public function __relinkSingleSelection(selectable:ICharterSelectable):ICharterSelectable { if (selectable is CharterNote) return selectable.ID == -1 ? cast(selectable, CharterNote) : notesGroup.members[selectable.ID]; - else if (selectable is CharterEvent) - return selectable.ID == -1 ? cast(selectable, CharterEvent) : eventsGroup.members[selectable.ID]; + else if (selectable is CharterEvent) { + var event:CharterEvent = cast(selectable, CharterEvent); + return selectable.ID == -1 ? event : (event.global ? globalEventsGroup : localEventsGroup).members[selectable.ID]; + } return null; } diff --git a/source/funkin/editors/charter/CharterBackdropGroup.hx b/source/funkin/editors/charter/CharterBackdropGroup.hx index 94d3dc09..a6ba36d6 100644 --- a/source/funkin/editors/charter/CharterBackdropGroup.hx +++ b/source/funkin/editors/charter/CharterBackdropGroup.hx @@ -283,8 +283,11 @@ class EventBackdrop extends FlxBackdrop { public var topSeparator:FlxSprite; public var bottomSeparator:FlxSprite; - public function new() { + public var global:Bool = false; + + public function new(global:Bool) { super(Paths.image('editors/charter/events-grid'), Y, 0, 0); + this.global = flipX = flipY = global; alpha = 0.9; // Separators @@ -331,18 +334,18 @@ class EventBackdrop extends FlxBackdrop { eventBeatSeparator.spacing.y = (20 * Conductor.stepsPerBeat) - 1; eventSecSeparator.cameras = cameras; - eventSecSeparator.x = (x+width) - 20; + eventSecSeparator.x = this.global ? x : ((x+width) - 20); if (eventSecSeparator.visible) eventSecSeparator.draw(); eventBeatSeparator.cameras = cameras; - eventBeatSeparator.x = (x+width) - 10; + eventBeatSeparator.x = this.global ? x : ((x+width) - 10); if (eventBeatSeparator.visible) eventBeatSeparator.draw(); - topSeparator.x = (x+width) - 20; + topSeparator.x = this.global ? x : ((x+width) - 20); topSeparator.cameras = this.cameras; if (!eventSecSeparator.visible) topSeparator.draw(); - bottomSeparator.x = (x+width) - 20; + bottomSeparator.x = this.global ? x : ((x+width) - 20); bottomSeparator.cameras = this.cameras; bottomSeparator.draw(); } diff --git a/source/funkin/editors/charter/CharterEvent.hx b/source/funkin/editors/charter/CharterEvent.hx index 3831d99a..bf9f8e2a 100644 --- a/source/funkin/editors/charter/CharterEvent.hx +++ b/source/funkin/editors/charter/CharterEvent.hx @@ -17,11 +17,13 @@ class CharterEvent extends UISliceSprite implements ICharterSelectable { public var eventsBackdrop:EventBackdrop; public var snappedToGrid:Bool = true; + public var global:Bool = false; - public function new(step:Float, ?events:Array) { + public function new(step:Float, ?events:Array, ?global:Bool = false) { super(-100, (step * 40) - 17, 100, 34, 'editors/charter/event-spr'); this.step = step; this.events = events.getDefault([]); + this.global = global; cursor = CLICK; } diff --git a/source/funkin/editors/charter/CharterEventAdd.hx b/source/funkin/editors/charter/CharterEventAdd.hx index 89fbf3cf..a6c345ff 100644 --- a/source/funkin/editors/charter/CharterEventAdd.hx +++ b/source/funkin/editors/charter/CharterEventAdd.hx @@ -7,9 +7,13 @@ class CharterEventAdd extends UISliceSprite { public var curCharterEvent:CharterEvent = null; - public function new() { + public var global:Bool = false; + + public function new(global:Bool) { super(0, 0, 100, 34, 'editors/charter/event-spr-add'); + this.global /*= flipX*/ = global; + text = new UIText(0, 0, 0, ""); members.push(text); @@ -20,9 +24,9 @@ class CharterEventAdd extends UISliceSprite { super.onHovered(); if (FlxG.mouse.justReleased) { if (curCharterEvent != null) - Charter.instance.openSubState(new CharterEventScreen(step, curCharterEvent)); + Charter.instance.openSubState(new CharterEventScreen(step, global, curCharterEvent)); else - Charter.instance.openSubState(new CharterEventScreen(step)); + Charter.instance.openSubState(new CharterEventScreen(step, global)); } } @@ -39,15 +43,15 @@ class CharterEventAdd extends UISliceSprite { this.step = step; this.y = (step * 40) - (bHeight / 2); text.text = "Add event"; - framesOffset = 0; - x = -(bWidth = 37 + Math.ceil(text.width)); + framesOffset = 0; bWidth = 37 + Math.ceil(text.width); + x = global ? Charter.instance.strumLines.members[Charter.instance.strumLines.members.length-1].x + (40*Charter.instance.strumLines.members[Charter.instance.strumLines.members.length-1].keyCount) : -(bWidth); } public function updateEdit(event:CharterEvent) { curCharterEvent = event; this.y = event.y; text.text = "Edit"; - framesOffset = 9; - x = -(bWidth = 27 + Math.ceil(text.width) + event.bWidth); + framesOffset = 9; bWidth = 27 + Math.ceil(text.width) + event.bWidth; + x = global ? Charter.instance.strumLines.members[Charter.instance.strumLines.members.length-1].x + (40*Charter.instance.strumLines.members[Charter.instance.strumLines.members.length-1].keyCount) : -(bWidth); } } \ No newline at end of file diff --git a/source/funkin/editors/charter/CharterEventGroup.hx b/source/funkin/editors/charter/CharterEventGroup.hx index b81ee554..5b71c47c 100644 --- a/source/funkin/editors/charter/CharterEventGroup.hx +++ b/source/funkin/editors/charter/CharterEventGroup.hx @@ -26,6 +26,7 @@ class CharterEventGroup extends FlxTypedGroup { for (event in members) { event.eventsBackdrop = eventsBackdrop; event.snappedToGrid = true; + event.cameras = cameras; } super.draw(); } diff --git a/source/funkin/editors/charter/CharterEventScreen.hx b/source/funkin/editors/charter/CharterEventScreen.hx index 77cb4ba2..60df5d9a 100644 --- a/source/funkin/editors/charter/CharterEventScreen.hx +++ b/source/funkin/editors/charter/CharterEventScreen.hx @@ -26,15 +26,17 @@ class CharterEventScreen extends UISubstateWindow { public var saveButton:UIButton; public var closeButton:UIButton; - public function new(step:Float, ?chartEvent:Null) { + public var global:Bool = false; + + public function new(step:Float, global:Bool, ?chartEvent:Null) { if (chartEvent != null) this.chartEvent = chartEvent; - this.step = step; + this.step = step; this.global = global; super(); } public override function create() { var creatingEvent:Bool = chartEvent == null; - if (creatingEvent) chartEvent = new CharterEvent(step, []); + if (creatingEvent) chartEvent = new CharterEvent(step, [], global); winTitle = creatingEvent ? "Create Event Group" : "Edit Event Group"; winWidth = 960; diff --git a/source/funkin/editors/charter/CharterStrumLineGroup.hx b/source/funkin/editors/charter/CharterStrumLineGroup.hx index 67e27b8a..3b6153c1 100644 --- a/source/funkin/editors/charter/CharterStrumLineGroup.hx +++ b/source/funkin/editors/charter/CharterStrumLineGroup.hx @@ -49,8 +49,15 @@ class CharterStrumLineGroup extends FlxTypedGroup { for (i=>strum in members) if (strum != null && !strum.dragging) strum.x = CoolUtil.fpsLerp(strum.x, 40*strum.startingID, 0.225); - if (Charter.instance.eventsBackdrop != null && members[0] != null) - Charter.instance.eventsBackdrop.x = members[0].button.x - Charter.instance.eventsBackdrop.width; + if (Charter.instance.localEventsBackdrop != null && members[0] != null) { + Charter.instance.localEventsBackdrop.x = members[0].button.x - Charter.instance.localEventsBackdrop.width; + Charter.instance.localEventsBackdrop.alpha = members[0].strumLine.visible ? 0.9 : 0.4; + } + + if (Charter.instance.globalEventsBackdrop != null && members[CoolUtil.maxInt(0, members.length-1)] != null) { + Charter.instance.globalEventsBackdrop.x = members[members.length-1].x + (40*members[members.length-1].keyCount); + Charter.instance.globalEventsBackdrop.alpha = members[CoolUtil.maxInt(0, members.length-1)].strumLine.visible ? 0.9 : 0.4; + } if (Charter.instance.strumlineLockButton != null && members[0] != null) Charter.instance.strumlineLockButton.x = members[0].x - (160); if (Charter.instance.strumlineAddButton != null && members[CoolUtil.maxInt(0, members.length-1)] != null) @@ -94,12 +101,14 @@ class CharterStrumLineGroup extends FlxTypedGroup { } public inline function fixEvents() { - for (i in Charter.instance.eventsGroup.members) { - for (j in i.events) { - var paramTypes:Array = EventsData.getEventParams(j.name); - for (i => param in paramTypes) { - if (param.type != TStrumLine) continue; - j.params[i] = members.indexOf(__pastStrumlines[j.params[i]]); + for (eventsGroup in [Charter.instance.localEventsGroup, Charter.instance.globalEventsGroup]) { + for (i in eventsGroup) { + for (j in i.events) { + var paramTypes:Array = EventsData.getEventParams(j.name); + for (i => param in paramTypes) { + if (param.type != TStrumLine) continue; + j.params[i] = members.indexOf(__pastStrumlines[j.params[i]]); + } } } } diff --git a/source/funkin/editors/charter/CharterStrumlineScreen.hx b/source/funkin/editors/charter/CharterStrumlineScreen.hx index 8576c74d..702afd9b 100644 --- a/source/funkin/editors/charter/CharterStrumlineScreen.hx +++ b/source/funkin/editors/charter/CharterStrumlineScreen.hx @@ -172,12 +172,10 @@ class CharterStrumlineScreen extends UISubstateWindow { addLabelOn(vocalsSuffixDropDown, "Vocal Suffix"); keyCountStepper = new UINumericStepper(stagePositionDropdown.x, vocalsSuffixDropDown.y, strumLine.keyCount != null ? strumLine.keyCount : 4, 1, 0, 1, 1000, 84); - if (Flags.CHARTER_ADVANCED_SETTINGS) { + // if (Flags.CHARTER_ADVANCED_SETTINGS) { add(keyCountStepper); addLabelOn(keyCountStepper, "Key Count"); - } - - + // } strumLineCam = new HudCamera(); strumLineCam.downscroll = Options.downscroll;