From 256c7ae40a6da556d9b90b6d486b882807d84ef4 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Sat, 10 Jun 2023 11:58:12 +0200 Subject: [PATCH] Icons for events in selector Fixed crash when copying nothing Fixed bug when constantly pressing right click --- TODO.md | 1 + source/funkin/editors/EditorPicker.hx | 6 +++--- source/funkin/editors/charter/Charter.hx | 7 ++++++- source/funkin/editors/charter/CharterBackdrop.hx | 4 ++++ source/funkin/editors/charter/CharterEvent.hx | 2 +- source/funkin/editors/charter/CharterEventAdd.hx | 1 - .../editors/charter/CharterEventTypeSelection.hx | 16 ++++++++++++++-- .../funkin/editors/charter/CharterSelection.hx | 2 +- source/funkin/editors/charter/EventsData.hx | 4 ++-- source/funkin/editors/ui/UIState.hx | 7 ++++++- source/funkin/editors/ui/UIText.hx | 2 ++ 11 files changed, 40 insertions(+), 12 deletions(-) diff --git a/TODO.md b/TODO.md index 97c8fab6..95daf308 100644 --- a/TODO.md +++ b/TODO.md @@ -29,6 +29,7 @@ - [ ] Character Editor - [ ] Add credits - [ ] Verbose mode (`--verbose`) +- [ ] Tooltips - [ ] Fix bugs ## `v1.1.0` diff --git a/source/funkin/editors/EditorPicker.hx b/source/funkin/editors/EditorPicker.hx index 7bd7235c..d6402c87 100644 --- a/source/funkin/editors/EditorPicker.hx +++ b/source/funkin/editors/EditorPicker.hx @@ -86,7 +86,7 @@ class EditorPicker extends MusicBeatSubstate { return; } changeSelection(-FlxG.mouse.wheel + (controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0)); - + FlxG.mouse.getScreenPosition(camera, curMousePos); if (curMousePos.x != oldMousePos.x || curMousePos.y != oldMousePos.y) { oldMousePos.set(curMousePos.x, curMousePos.y); @@ -98,7 +98,7 @@ class EditorPicker extends MusicBeatSubstate { if (options[curSelected].state != null) { selected = true; CoolUtil.playMenuSFX(CONFIRM); - + MusicBeatState.skipTransIn = true; MusicBeatState.skipTransOut = true; @@ -187,7 +187,7 @@ class EditorPickerOption extends FlxTypedSpriteGroup { selectionBG.alpha = (iconSpr.alpha = FlxEase.cubeOut(selectionLerp)) * 0.5; selectionBG.x = FlxMath.lerp(-FlxG.width, 0, selectionLerp); - + label.x = FlxMath.lerp(10, 25 + iconSpr.width + 25, selectionLerp); iconSpr.x = label.x - 25 - iconSpr.width; iconSpr.angle = Math.sin(iconRotationCycle * 0.5) * 5; diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 5007775a..b3727c0b 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -491,6 +491,7 @@ class Charter extends UIState { if (FlxG.mouse.justReleasedRight) { if (!selection.contains(n)) selection = [n]; + closeCurrentContextMenu(); openContextMenu(topMenu[1].childs); } } @@ -618,8 +619,10 @@ class Charter extends UIState { } } - if (FlxG.mouse.justReleasedRight) + if (FlxG.mouse.justReleasedRight) { + closeCurrentContextMenu(); openContextMenu(topMenu[1].childs); + } } if (gridActionType == NONE && mousePos.x < 0) { @@ -807,6 +810,8 @@ class Charter extends UIState { #end function _edit_copy(_) { + if(selection.length == 0) return; + var minStep:Float = selection[0].step; for(s in selection) if (s.step < minStep) diff --git a/source/funkin/editors/charter/CharterBackdrop.hx b/source/funkin/editors/charter/CharterBackdrop.hx index 3e6c7c67..840e7ca5 100644 --- a/source/funkin/editors/charter/CharterBackdrop.hx +++ b/source/funkin/editors/charter/CharterBackdrop.hx @@ -11,9 +11,13 @@ class CharterBackdrop extends FlxBackdrop { makeGraphic(160, 160, 0xFF272727, true); pixels.lock(); + + // Checkerboard for(y in 0...4) for(x in 0...2) pixels.fillRect(new Rectangle(40*((x*2)+(y%2)), 40*y, 40, 40), 0xFF545454); + + // Edges pixels.fillRect(new Rectangle(0, 0, 1, 160), 0xFFDDDDDD); pixels.fillRect(new Rectangle(159, 0, 1, 160), 0xFFDDDDDD); pixels.unlock(); diff --git a/source/funkin/editors/charter/CharterEvent.hx b/source/funkin/editors/charter/CharterEvent.hx index 6c49081a..e3e887a2 100644 --- a/source/funkin/editors/charter/CharterEvent.hx +++ b/source/funkin/editors/charter/CharterEvent.hx @@ -41,7 +41,7 @@ class CharterEvent extends UISliceSprite { case "Camera Movement": // custom icon for camera movement var state = cast(FlxG.state, Charter); - if (event.params[0] != null && event.params[0] >= 0 && event.params[0] < state.strumLines.length) { + if (event.params != null && event.params[0] != null && event.params[0] >= 0 && event.params[0] < state.strumLines.length) { // camera movement, use health icon var healthIcon = new HealthIcon('${state.strumLines.members[event.params[0]].strumLine.characters[0]}'); healthIcon.setUnstretchedGraphicSize(32, 32, false); diff --git a/source/funkin/editors/charter/CharterEventAdd.hx b/source/funkin/editors/charter/CharterEventAdd.hx index 545e749a..a46306a4 100644 --- a/source/funkin/editors/charter/CharterEventAdd.hx +++ b/source/funkin/editors/charter/CharterEventAdd.hx @@ -14,7 +14,6 @@ class CharterEventAdd extends UISliceSprite { members.push(text); cursor = BUTTON; - } public override function onHovered() { diff --git a/source/funkin/editors/charter/CharterEventTypeSelection.hx b/source/funkin/editors/charter/CharterEventTypeSelection.hx index 201d9600..b07c8927 100644 --- a/source/funkin/editors/charter/CharterEventTypeSelection.hx +++ b/source/funkin/editors/charter/CharterEventTypeSelection.hx @@ -17,10 +17,22 @@ class CharterEventTypeSelection extends UISubstateWindow { var lastIndex:Int = 0; for(k=>eventName in EventsData.eventsList) { - add(new UIButton(10, 41 + (32 * k), eventName, function() { + var button = new UIButton(10, 41 + (32 * k), eventName, function() { close(); callback(eventName); - }, w)); + }, w); + add(button); + + var icon = CharterEvent.generateEventIcon({ + name: eventName, + time: 0, + params: [] + }); + icon.setGraphicSize(20, 20); // Std.int(button.bHeight - 12) + icon.updateHitbox(); + icon.x = button.x + 8; + icon.y = button.y + Math.abs(button.bHeight - icon.height) / 2; + add(icon); lastIndex = k; } diff --git a/source/funkin/editors/charter/CharterSelection.hx b/source/funkin/editors/charter/CharterSelection.hx index e5cb026b..842f7510 100644 --- a/source/funkin/editors/charter/CharterSelection.hx +++ b/source/funkin/editors/charter/CharterSelection.hx @@ -45,7 +45,7 @@ class CharterSelection extends EditorTreeMenu { if (optionsTree.members.length > 1) { // selected a song // small flashbang var color:FlxColor = freeplayList.songs[main.curSelected].parsedColor.getDefault(0xFFFFFFFF); - + bg.colorTransform.redOffset = 0.25 * color.red; bg.colorTransform.greenOffset = 0.25 * color.green; bg.colorTransform.blueOffset = 0.25 * color.blue; diff --git a/source/funkin/editors/charter/EventsData.hx b/source/funkin/editors/charter/EventsData.hx index 4be01029..04345100 100644 --- a/source/funkin/editors/charter/EventsData.hx +++ b/source/funkin/editors/charter/EventsData.hx @@ -49,12 +49,12 @@ class EventsData { eventsParams.set(eventName, []); var fileTxt:String = Assets.getText(file); - if (fileTxt.trim() == "") {continue;} + if (fileTxt.trim() == "") continue; try { var data:Dynamic = Json.parse(fileTxt); if (data == null || data.params == null) continue; - + var finalParams:Array = []; for (paramData in cast(data.params, Array)) { try { diff --git a/source/funkin/editors/ui/UIState.hx b/source/funkin/editors/ui/UIState.hx index 36118f43..d287e630 100644 --- a/source/funkin/editors/ui/UIState.hx +++ b/source/funkin/editors/ui/UIState.hx @@ -117,9 +117,14 @@ class UIState extends MusicBeatState { FlxG.stage.window.onTextInput.remove(onTextInput); } + public function closeCurrentContextMenu() { + if(curContextMenu != null) + curContextMenu.close(); + } + public function openContextMenu(options:Array, ?callback:UIContextMenuCallback, ?x:Float, ?y:Float) { var state = FlxG.state; - while(state.subState != null) + while(state.subState != null && !(state._requestSubStateReset && state._requestedSubState == null)) state = state.subState; state.persistentDraw = true; diff --git a/source/funkin/editors/ui/UIText.hx b/source/funkin/editors/ui/UIText.hx index 2b376a42..413630b2 100644 --- a/source/funkin/editors/ui/UIText.hx +++ b/source/funkin/editors/ui/UIText.hx @@ -8,5 +8,7 @@ class UIText extends FunkinText { public function new(x, y, w, text, size:Int = 15, color:FlxColor = 0xFFFFFFFF) { super(x, y, w, text, size, false); this.color = color; + + this.active = false; } } \ No newline at end of file