From fa53926f06211ff3ba713a4e1a2b7a27d9ff79a4 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Sat, 8 Apr 2023 23:17:48 +0200 Subject: [PATCH] strumline bullshit --- .../editors/charter/strumline-info-bg.png | Bin 0 -> 582 bytes source/funkin/editors/charter/Charter.hx | 42 +++++--- .../editors/charter/CharterStrumline.hx | 94 ++++++++++++++++++ source/funkin/editors/ui/UISliceSprite.hx | 10 +- source/funkin/editors/ui/UITopMenu.hx | 18 ++-- source/funkin/utils/FunkinParentDisabler.hx | 2 +- 6 files changed, 139 insertions(+), 27 deletions(-) create mode 100644 assets/images/editors/charter/strumline-info-bg.png create mode 100644 source/funkin/editors/charter/CharterStrumline.hx diff --git a/assets/images/editors/charter/strumline-info-bg.png b/assets/images/editors/charter/strumline-info-bg.png new file mode 100644 index 0000000000000000000000000000000000000000..5d073dbcc8644f756ea8d2ebe55f1046374c0c05 GIT binary patch literal 582 zcmV-M0=fN(P)pG_(?=TRCwAg&e={AaTLe#{9b{mSV582Qd?`+>2$U()GpA{z0kd# znR@4~FQ92OL>OFo;4#g8>DMT4O6%MR^2Yz(?>uqc@*?&&jzsFb;(Oz;-Hq z4C_gPTK2&tL6bU$<4pP&sMFb>aB4C~a1IfuVS?*y_6YR3%n#5b+3%#L`*5Gn_Q8zi z`d}3}?esUWx|u_8y8I!83;6@^`oaN(vHVwf^o1TghGGw1L#YSf#bOseW2pF`NDoRVch`Gggh|$tprFJmINIQtL^0rdjq@*`UaPk%sth9xsT3q9`vQv45B;VLX zO1QfDzxc*Wa@W{U#tkyc>jY^X39tBq+{w=gjWr}a@|rR}BX`m&;-2~{*-1~8aRmuM zTp>GBQ-ZjRIA2{xOsKX=)!XE?S{qTO@&qxavV=*tx`YX)^cWF$QRNZBbm1X_u0jhD zSH6WHHPb?X$~{29k-Lv^d-fju_RJ!Dw)7&r*3?}Hmc#;hb9@1uDK-zr6rBfcn3#iG zADM$o7rFz7HaH90XkZqW5&vzNhdsAo9O9cWYPcrG2AL*wC+M5d4p296O}_s7FLcte UHJiMeYXATM07*qoM6N<$f = []; + public var strumLines:FlxTypedGroup = new FlxTypedGroup(); public var notesGroup:CharterNoteGroup = new CharterNoteGroup(); /** @@ -327,6 +329,14 @@ class Charter extends UIState { topLimit.color = 0xFF888888; topLimit.blend = MULTIPLY; + strumlineInfoBG = new UISprite(); + strumlineInfoBG.loadGraphic(Paths.image('editors/charter/strumline-info-bg')); + strumlineInfoBG.y = 23; + strumlineInfoBG.scrollFactor.set(); + + strumlineInfoBG.cameras = [charterCamera]; + strumLines.cameras = [charterCamera]; + // adds grid and notes so that they're ALWAYS behind the UI add(gridBackdrop); @@ -336,6 +346,8 @@ class Charter extends UIState { add(topLimit); add(conductorFollowerSpr); add(selectionBox); + add(strumlineInfoBG); + add(strumLines); // add the ui group add(uiGroup); // add the top menu last OUT of the ui group so that it stays on top @@ -362,10 +374,7 @@ class Charter extends UIState { notesGroup.add(n); } - strumLines.push({ - strumLine: strL, - hitsounds: true - }); + strumLines.add(new CharterStrumline(strL)); } } @@ -509,9 +518,9 @@ class Charter extends UIState { super.update(elapsed); - if (gridBackdrop.strumlinesAmount != (gridBackdrop.strumlinesAmount = strumLines.length)) { + if (gridBackdrop.strumlinesAmount != (gridBackdrop.strumlinesAmount = strumLines.length)) updateDisplaySprites(); - } + sectionSeparator.spacing.y = (10 * Conductor.beatsPerMesure * Conductor.stepsPerBeat) - 1; beatSeparator.spacing.y = (20 * Conductor.stepsPerBeat) - 1; @@ -560,6 +569,16 @@ class Charter extends UIState { topLimit.scale.set(gridBackdrop.strumlinesAmount * 4 * 40, Math.ceil(FlxG.height / charterCamera.zoom)); topLimit.updateHitbox(); topLimit.y = -topLimit.height; + + strumlineInfoBG.scale.set(FlxG.width / charterCamera.zoom, 1); + strumlineInfoBG.updateHitbox(); + strumlineInfoBG.screenCenter(X); + + for(id=>str in strumLines.members) { + if (str == null) continue; + str.x = id * 40 * 4; + str.y = strumlineInfoBG.y; + } } var zoom:Float = 0; @@ -731,7 +750,7 @@ class Charter extends UIState { inline function _note_subtractsustain(t) changeNoteSustain(-1); - + #end function changeNoteSustain(change:Float) { @@ -779,7 +798,7 @@ class Charter extends UIState { } public inline function hitsoundsEnabled(id:Int) - return strumLines[Std.int(id / 4)] != null && strumLines[Std.int(id / 4)].hitsounds; + return strumLines.members[Std.int(id / 4)] != null && strumLines.members[Std.int(id / 4)].hitsounds; } enum CharterChange { @@ -793,11 +812,6 @@ enum CharterCopyboardObject { CNote(step:Float, id:Int, susLength:Float, type:Int); } -typedef CharterStrumline = { - var strumLine:ChartStrumLine; - var hitsounds:Bool; -} - typedef NoteSustainChange = { var note:CharterNote; var before:Float; diff --git a/source/funkin/editors/charter/CharterStrumline.hx b/source/funkin/editors/charter/CharterStrumline.hx new file mode 100644 index 00000000..2b4644cf --- /dev/null +++ b/source/funkin/editors/charter/CharterStrumline.hx @@ -0,0 +1,94 @@ +package funkin.editors.charter; + +import funkin.editors.ui.UIContextMenu.UIContextMenuOption; +import funkin.editors.ui.UITopMenu.UITopMenuButton; +import funkin.game.HealthIcon; +import funkin.chart.ChartData.ChartStrumLine; + +class CharterStrumline extends UISprite { + public var strumLine:ChartStrumLine; + public var hitsounds:Bool = true; + + var healthIcon:HealthIcon; + var button:CharterStrumlineButton; + + public var curMenu:UIContextMenu = null; + + public function new(strumLine:ChartStrumLine) { + super(); + this.strumLine = strumLine; + + scrollFactor.set(1, 0); + alpha = 0; + + healthIcon = new HealthIcon(strumLine.characters != null ? strumLine.characters[0] : null); + healthIcon.scale.set(80 / 150, 80 / 150); + healthIcon.updateHitbox(); + + members.push(healthIcon); + + button = new CharterStrumlineButton(this); + + members.push(button); + } + + public override function update(elapsed:Float) { + healthIcon.follow(this, ((40 * 4) - healthIcon.width) / 2, 0); + button.follow(this, 0, 95); + super.update(elapsed); + } + + public function updateInfo() { + // todo + } +} + +class CharterStrumlineButton extends UITopMenuButton { + var strLine:CharterStrumline; + public function new(parent:CharterStrumline) { + super(0, 95, null, "Strumline Options", []); + strLine = parent; + bWidth = 40 * 4; + this.label.fieldWidth = bWidth; + } + + public override function update(elapsed:Float) { + super.update(elapsed); + alpha = FlxMath.lerp(1/3, 1, alpha); + } + + public override function openContextMenu() { + contextMenu = [ + { + label: "Player", + onSelect: function(_) { + strLine.strumLine.type = PLAYER; + }, + icon: strLine.strumLine.type == PLAYER ? 1 : 0 + }, + { + label: "Opponent", + onSelect: function(_) { + strLine.strumLine.type = OPPONENT; + }, + icon: strLine.strumLine.type == OPPONENT ? 1 : 0 + }, + { + label: "Additional", + onSelect: function(_) { + strLine.strumLine.type = ADDITIONAL; + }, + icon: strLine.strumLine.type == ADDITIONAL ? 1 : 0 + }, + null, + { + label: "Hitsounds", + onSelect: function(_) { + strLine.hitsounds = !strLine.hitsounds; + }, + icon: strLine.hitsounds ? 1 : 0 + } + ]; + super.openContextMenu(); + } +} \ No newline at end of file diff --git a/source/funkin/editors/ui/UISliceSprite.hx b/source/funkin/editors/ui/UISliceSprite.hx index 37df6b81..5c5cac6b 100644 --- a/source/funkin/editors/ui/UISliceSprite.hx +++ b/source/funkin/editors/ui/UISliceSprite.hx @@ -11,7 +11,7 @@ class UISliceSprite extends UISprite { public function new(x:Float, y:Float, w:Int, h:Int, path:String) { super(x, y); - + frames = CoolUtil.loadFrames(Paths.image(path)); resize(w, h); } @@ -33,7 +33,7 @@ class UISliceSprite extends UISprite { public override function draw() { var x:Float = this.x; var y:Float = this.y; - + var topleft:FlxFrame = frames.frames[framesOffset]; var top:FlxFrame = frames.frames[framesOffset + 1]; var topright:FlxFrame = frames.frames[framesOffset + 2]; @@ -50,7 +50,7 @@ class UISliceSprite extends UISprite { setPosition(x, y); __setSize(topleft.frame.width, topleft.frame.height); super.drawSuper(); - + // TOP if (bWidth > topleft.frame.width + topright.frame.width) { frame = top; @@ -71,7 +71,7 @@ class UISliceSprite extends UISprite { setPosition(x, y + top.frame.height); __setSize(middleleft.frame.width, bHeight - topleft.frame.height - bottomleft.frame.height); super.drawSuper(); - + if (bWidth > middleleft.frame.width + middleright.frame.width) { // MIDDLE frame = middle; @@ -92,7 +92,7 @@ class UISliceSprite extends UISprite { setPosition(x, y + bHeight - bottom.frame.height); __setSize(bottomleft.frame.width, bottomleft.frame.height); super.drawSuper(); - + if (bWidth > bottomleft.frame.width + bottomright.frame.width) { // BOTTOM frame = bottom; diff --git a/source/funkin/editors/ui/UITopMenu.hx b/source/funkin/editors/ui/UITopMenu.hx index 296e2090..b98476d9 100644 --- a/source/funkin/editors/ui/UITopMenu.hx +++ b/source/funkin/editors/ui/UITopMenu.hx @@ -25,10 +25,9 @@ class UITopMenu extends UISliceSprite { anyMenuOpened = true; break; } - + super.update(elapsed); - bWidth = FlxG.width; } } @@ -39,7 +38,7 @@ class UITopMenuButton extends UISliceSprite { public var parent:UITopMenu; public var curMenu:UIContextMenu = null; - + public function new(x:Float, y:Float, parent:UITopMenu, label:String, contextMenu:Array) { super(x, y, 0, 23, "editors/ui/menu-item"); this.contextMenu = contextMenu; @@ -48,12 +47,12 @@ class UITopMenuButton extends UISliceSprite { this.label = new UIText(4, 0, 0, label); this.label.alignment = CENTER; - bWidth = this.label.frameWidth + 8; + bWidth = Std.int(this.label.fieldWidth = this.label.frameWidth + 8); members.push(this.label); } public override function update(elapsed:Float) { - label.follow(this, 4, Std.int((bHeight - label.height) / 2)); + label.follow(this, 0, Std.int((bHeight - label.height) / 2)); super.update(elapsed); var opened = curMenu.contextMenuOpened(); @@ -67,10 +66,15 @@ class UITopMenuButton extends UISliceSprite { if (curMenu.contextMenuOpened()) { UIState.state.curContextMenu.preventOutOfBoxClickDeletion(); } else { - if (parent.anyMenuOpened || FlxG.mouse.justReleased) { - curMenu = UIState.state.openContextMenu(contextMenu, null, x, y + bHeight); + if ((parent != null && parent.anyMenuOpened) || FlxG.mouse.justReleased) { + openContextMenu(); } } } } + + public function openContextMenu() { + var screenPos = getScreenPosition(null, __lastDrawCameras[0] == null ? FlxG.camera : __lastDrawCameras[0]); + curMenu = UIState.state.openContextMenu(contextMenu, null, screenPos.x, screenPos.y + bHeight); + } } \ No newline at end of file diff --git a/source/funkin/utils/FunkinParentDisabler.hx b/source/funkin/utils/FunkinParentDisabler.hx index 1ed58ba3..af6d0351 100644 --- a/source/funkin/utils/FunkinParentDisabler.hx +++ b/source/funkin/utils/FunkinParentDisabler.hx @@ -19,7 +19,7 @@ class FunkinParentDisabler extends FlxBasic { var __timers:Array; var __sounds:Array; var __replaceUponDestroy:Bool; - public function new(replaceUponDestroy:Bool = true) { + public function new(replaceUponDestroy:Bool = false) { super(); __replaceUponDestroy = replaceUponDestroy; @:privateAccess {