From 7cc46374b51b5adc94c4d3a01d4ba3ed441c8cc5 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Fri, 22 Mar 2024 17:58:36 -0700 Subject: [PATCH 01/16] indicator for delete thingy --- source/funkin/editors/charter/Charter.hx | 6 ++--- .../editors/charter/CharterDeleteAnim.hx | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 34671758..aa7dc29c 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -806,7 +806,7 @@ class Charter extends UIState { FlxG.mouse.getWorldPosition(charterCamera, dragStartPos); else if (FlxG.mouse.justPressedRight) { closeCurrentContextMenu(); - gridActionType = DELTE_SELECTION; + gridActionType = DELETE_SELECTION; } if (gridBackdropDummy.hovered) { @@ -886,7 +886,7 @@ class Charter extends UIState { gridActionType = NONE; currentCursor = ARROW; } - case DELTE_SELECTION: + case DELETE_SELECTION: notesGroup.forEach(function(n) { if (n.hovered || n.sustainDraggable) { deletedNotes.push(n); @@ -1960,7 +1960,7 @@ enum abstract CharterGridActionType(Int) { var NOTE_DRAG = 2; var INVALID_DRAG = 3; var SUSTAIN_DRAG = 4; - var DELTE_SELECTION = 5; + var DELETE_SELECTION = 5; } typedef PlaytestInfo = { diff --git a/source/funkin/editors/charter/CharterDeleteAnim.hx b/source/funkin/editors/charter/CharterDeleteAnim.hx index 51a33eca..f291ab93 100644 --- a/source/funkin/editors/charter/CharterDeleteAnim.hx +++ b/source/funkin/editors/charter/CharterDeleteAnim.hx @@ -1,6 +1,8 @@ package funkin.editors.charter; class CharterDeleteAnim extends CharterNote { + public var garbageIcon:FlxSprite; + public var deleteNotes:Array<{note:CharterNote, time:Float}> = []; public var deleteTime:Float = .4; @@ -10,13 +12,31 @@ class CharterDeleteAnim extends CharterNote { sustainSpr.color = 0xFF6D2425; color = 0xFF797171; snappedToStrumline = selectable = autoAlpha = false; @:privateAccess __animSpeed = 1.25; + + garbageIcon = new FlxSprite().loadGraphic(Paths.image("editors/autosave-delete")); + garbageIcon.color = 0xFF880000; + garbageIcon.cameras = [Charter.instance.uiCamera]; } + var __garbageAlpha:Float = 0; + var __deletionTimer:Float = .1; public override function update(elapsed:Float) { for (deleteData in deleteNotes) { deleteData.time -= elapsed; if (deleteData.time < 0) deleteNotes.remove(deleteData); } + + if (FlxG.mouse.justPressedRight) __deletionTimer = .1; + __deletionTimer -= elapsed; + + __garbageAlpha = FlxMath.lerp(__garbageAlpha, FlxG.mouse.pressedRight && __deletionTimer <= 0 ? 1 : 0, 1/10); + + if (FlxG.mouse.pressedRight && __deletionTimer <= 0) + garbageIcon.setPosition( + FlxG.mouse.screenX + garbageIcon.width/2 + (.5*FlxG.random.float(-1, 1)), + FlxG.mouse.screenY - garbageIcon.height + (.5*FlxG.random.float(-1, 1)) + ); + garbageIcon.alpha = __garbageAlpha; } public override function draw() @:privateAccess { @@ -39,5 +59,7 @@ class CharterDeleteAnim extends CharterNote { super.draw(); } + + if (garbageIcon.alpha > 0) garbageIcon.draw(); } } \ No newline at end of file From d9c21c2b110a1a6036631a21029a223ced69ebc0 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Fri, 22 Mar 2024 18:26:48 -0700 Subject: [PATCH 02/16] tweak deleter thingy --- assets/images/editors/deleter.png | Bin 0 -> 199 bytes .../funkin/editors/charter/CharterDeleteAnim.hx | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 assets/images/editors/deleter.png diff --git a/assets/images/editors/deleter.png b/assets/images/editors/deleter.png new file mode 100644 index 0000000000000000000000000000000000000000..8146955db368cf0f489e4b20ce1104da717ae78d GIT binary patch literal 199 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~e!3HF=pW8M9DaPU;cPEB*=VV?2IgOq!jv*Qo zlT#cT{_`ARb}KpdU%j!><@L14{c`K33oiS4x!(i+{>xu2@lfR17CboFyt=akR{0HQ)nFaQ7m literal 0 HcmV?d00001 diff --git a/source/funkin/editors/charter/CharterDeleteAnim.hx b/source/funkin/editors/charter/CharterDeleteAnim.hx index f291ab93..9d920e29 100644 --- a/source/funkin/editors/charter/CharterDeleteAnim.hx +++ b/source/funkin/editors/charter/CharterDeleteAnim.hx @@ -13,7 +13,7 @@ class CharterDeleteAnim extends CharterNote { snappedToStrumline = selectable = autoAlpha = false; @:privateAccess __animSpeed = 1.25; - garbageIcon = new FlxSprite().loadGraphic(Paths.image("editors/autosave-delete")); + garbageIcon = new FlxSprite().loadGraphic(Paths.image("editors/deleter")); garbageIcon.color = 0xFF880000; garbageIcon.cameras = [Charter.instance.uiCamera]; } From 92d9d650e86e0b405166c90599e54bcb297136d4 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Fri, 22 Mar 2024 18:27:57 -0700 Subject: [PATCH 03/16] clean up waveform shader --- assets/shaders/engine/editorWaveforms.frag | 91 ++++++++++------------ 1 file changed, 39 insertions(+), 52 deletions(-) diff --git a/assets/shaders/engine/editorWaveforms.frag b/assets/shaders/engine/editorWaveforms.frag index 7a424adb..789c3c20 100644 --- a/assets/shaders/engine/editorWaveforms.frag +++ b/assets/shaders/engine/editorWaveforms.frag @@ -19,13 +19,13 @@ uniform ivec2 waveformSize; uniform bool lowDetail; float getAmplitude(vec2 pixel) { - float pixelID = floor((pixel.y+pixelOffset)/3.); + float pixelID = floor((pixel.y+pixelOffset)/3.0); // TODO: INVESTIGATE THE 1.+ AND WHY IT WORKS (SRSLY I GOT NO CLUE) -lunar - vec2 wavePixel = vec2(mod(pixelID,waveformSize.x), 1.+floor(pixelID/waveformSize.x)); + vec2 wavePixel = vec2(mod(pixelID,waveformSize.x), 1.0+floor(pixelID/waveformSize.x)); vec4 waveData = texture2D(waveformTexture, wavePixel / waveformSize); - switch (int(mod(wavePixel.x, 3.))) { + switch (int(mod(wavePixel.x, 3.0))) { case 0: return waveData.r; break; case 1: return waveData.g; break; case 2: return waveData.b; break; @@ -33,70 +33,57 @@ float getAmplitude(vec2 pixel) { return 0.; } +float getAmpWidth(float amplitude) { + return (1.0-amplitude) * textureRes.x; +} + bool inWaveForm(vec2 pixel, float width) { - float widthdiv2 = width/2.; + float widthdiv2 = width/2.0; return pixel.x > widthdiv2 && pixel.x < textureRes.x-widthdiv2; } +float getHightlight(float ampwidth) { + float remapCoord = (ampwidth/textureRes.x)/2.0; + float mappedCoord = map(openfl_TextureCoordv.x, remapCoord, 1.0-remapCoord, 0.0, 1.0); + return 1.-(abs(mappedCoord-0.5)*2.0); +} + +void outlineWaveform(vec2 pixel, vec2 offset) { + float amplitude = getAmplitude(pixel - offset); + float ampwidth = (1.-amplitude) * textureRes.x; + + if (!inWaveForm(pixel, ampwidth)) + gl_FragColor -= outlinecolor*mix(0.5, .8, amplitude); +} + void highDetailWaveform(vec2 pixel, float amplitude, float ampwidth) { - if (inWaveForm(pixel, ampwidth)) { - vec3 gradientColor = mix(gradient1, gradient2, openfl_TextureCoordv.x); - gradientColor *= pixel.y+pixelOffset>playerPosition ? .7 : 1.; + vec3 gradientColor = mix(gradient1, gradient2, openfl_TextureCoordv.x); + gradientColor *= pixel.y+pixelOffset>playerPosition ? 0.7 : 1.0; + gradientColor = mix(gradientColor, gradientColor * vec3(1.8), map(getHightlight(amplitude), 0.0, 1.0, 0.5, 1.0)); - float remapCoord = (amplitude/textureRes.x)/2.; + float ampwidthHighlight = getAmpWidth(amplitude*(1.0/3.0)); + if (inWaveForm(pixel, ampwidthHighlight)) + gradientColor = mix(gradientColor, gradientColor * vec3(1.8), map(getHightlight(ampwidthHighlight), 0.0, 1.0, 0.5, 1.0)); + + gl_FragColor = vec4(vec3(gradientColor * mix(0.5, 0.8, amplitude))*openfl_Alphav, openfl_Alphav); - float mappedCoord = map(openfl_TextureCoordv.x, remapCoord, 1.-remapCoord, 0., 1.); - float hightlightAmount = 1.-(abs(mappedCoord-0.5)*2.); - - gradientColor = mix(gradientColor, gradientColor * vec3(1.8), map(hightlightAmount, 0., 1., .5, 1.)); - - float ampwidthHighlight = (1.-(amplitude*(1./3.))) * textureRes.x; - if (inWaveForm(pixel, ampwidthHighlight)) { - float remapCoord = (ampwidthHighlight/textureRes.x)/2.; - - float mappedCoord = map(openfl_TextureCoordv.x, remapCoord, 1.-remapCoord, 0., 1.); - float hightlightAmount = 1.-(abs(mappedCoord-0.5)*2.); - - gradientColor = mix(gradientColor, gradientColor * vec3(1.8), map(hightlightAmount, 0., 1., .5, 1.)); - } - - gl_FragColor = vec4(vec3(gradientColor * mix(0.5, .8, amplitude))*openfl_Alphav, openfl_Alphav); - - float lastAmplitude = getAmplitude(pixel - vec2(0., -1.)); - float lastAmpwidth = (1.-lastAmplitude) * textureRes.x; - - if (!inWaveForm(pixel, lastAmpwidth)) - gl_FragColor -= outlinecolor*mix(0.5, .8, amplitude); - - float nextAmplitude = getAmplitude(pixel - vec2(0., 1.)); - float nextAmpwidth = (1.-nextAmplitude) * textureRes.x; - - if (!inWaveForm(pixel, nextAmpwidth)) - gl_FragColor -= outlinecolor*mix(0.5, .8, amplitude); - - if (!inWaveForm(pixel, ampwidth+2.) && amplitude > 0.) - gl_FragColor -= outlinecolor; - } + outlineWaveform(pixel, vec2(0.0, -1.0)); + outlineWaveform(pixel, vec2(0.0, 1.0)); } void lowDetailWaveform(vec2 pixel, float amplitude, float ampwidth) { - if (inWaveForm(pixel, ampwidth)) { - vec3 color = lowdetailcol; - color *= pixel.y+pixelOffset>playerPosition ? .7 : 1.; - - gl_FragColor = vec4(color, 1.); - } + gl_FragColor = vec4(lowdetailcol * (pixel.y+pixelOffset>playerPosition ? 0.7 : 1.0), 1.0); } void main() { vec2 pixel = openfl_TextureCoordv * textureRes; - float amplitude = getAmplitude(pixel); - float ampwidth = (1.-amplitude) * textureRes.x; + float ampwidth = getAmpWidth(amplitude); - if (lowDetail) - lowDetailWaveform(pixel, amplitude, ampwidth); - else - highDetailWaveform(pixel, amplitude, ampwidth); + gl_FragColor = vec4(0.0); + if (!inWaveForm(pixel, ampwidth)) return; + + if (lowDetail) lowDetailWaveform(pixel, amplitude, ampwidth); + else highDetailWaveform(pixel, amplitude, ampwidth); } \ No newline at end of file From 0d30170473bcd483c41edfff4246d3951c56a661 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Sat, 23 Mar 2024 02:34:39 +0100 Subject: [PATCH 04/16] Fixed some shaders --- assets/shaders/engine/circleProfilePicture.frag | 4 ++-- assets/shaders/engine/editorBlur.frag | 13 ++++++++----- assets/shaders/engine/updaterShader.frag | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/assets/shaders/engine/circleProfilePicture.frag b/assets/shaders/engine/circleProfilePicture.frag index 6cf0b2ab..1a641250 100644 --- a/assets/shaders/engine/circleProfilePicture.frag +++ b/assets/shaders/engine/circleProfilePicture.frag @@ -6,6 +6,6 @@ void main() { float len = length(openfl_TextureCoordv - vec2(0.5, 0.5)); float r = 0.5 - (1.0 / openfl_TextureSize.x); vec4 c = flixel_texture2D(bitmap, openfl_TextureCoordv); - vec4 color = mix(vec4(0, 0, 0, 0.5), c, c.a); - gl_FragColor = color * clamp(1 - ((len - r) * openfl_TextureSize.x), 0, 1); + vec4 color = mix(vec4(0.0, 0.0, 0.0, 0.5), c, c.a); + gl_FragColor = color * clamp(1.0 - ((len - r) * openfl_TextureSize.x), 0.0, 1.0); } \ No newline at end of file diff --git a/assets/shaders/engine/editorBlur.frag b/assets/shaders/engine/editorBlur.frag index 66b3eafb..ffcbc755 100644 --- a/assets/shaders/engine/editorBlur.frag +++ b/assets/shaders/engine/editorBlur.frag @@ -7,9 +7,9 @@ int steps = 16; int stepsInside = 2; float strength = 0.0075; vec4 getColor(vec2 pos) { - if (pos.x < 0) pos.x = 0; + if (pos.x < 0.0) pos.x = 0.0; else if (pos.x > 1.0 - (1.0 / openfl_TextureSize.x)) pos.x = 1.0 - (1.0 / openfl_TextureSize.x); - if (pos.y < 0) pos.y = 0; + if (pos.y < 0.0) pos.y = 0.0; else if (pos.y > 1.0 - (1.0 / openfl_TextureSize.y)) pos.y = 1.0 - (1.0 / openfl_TextureSize.y); // return textureCam(bitmap, pos); return flixel_texture2D(bitmap, pos); @@ -17,15 +17,18 @@ vec4 getColor(vec2 pos) { void main() { // vec2 camPos = getCamPos(openfl_TextureCoordv); vec2 camPos = openfl_TextureCoordv; - if (camPos.x < 0 || camPos.x > 1 || camPos.y < 0 || camPos.y > 1) + if (camPos.x < 0.0 || camPos.x > 1.0 || camPos.y < 0.0 || camPos.y > 1.0) return; vec4 color = getColor(camPos); float fsteps = steps; - for(float inside = 1; inside < stepsInside+1; inside++) { + for(float inside = 1.0; inside < stepsInside+1.0; inside++) { for(int i = 0; i < steps; i++) { float fi = i; - color += getColor(camPos + vec2(strength * (inside / stepsInside) * cos(fi / fsteps * (PI * 2.0)), strength * (inside / stepsInside) * sin(fi / fsteps * (PI * 2.0)))); + color += getColor(camPos + vec2( + strength * (inside / stepsInside) * cos(fi / fsteps * (PI * 2.0)), + strength * (inside / stepsInside) * sin(fi / fsteps * (PI * 2.0)) + )); } } diff --git a/assets/shaders/engine/updaterShader.frag b/assets/shaders/engine/updaterShader.frag index f3a63166..ef6fec03 100644 --- a/assets/shaders/engine/updaterShader.frag +++ b/assets/shaders/engine/updaterShader.frag @@ -28,7 +28,7 @@ void main() { hsv.g = (1.0/3.0) * strength * coords.y; - hsv.r = mod(elapsed + coords.x + coords.y, 1); + hsv.r = mod(elapsed + coords.x + coords.y, 1.0); gl_FragColor = vec4(hsv2rgb(hsv), color.a); } \ No newline at end of file From 0391ba34962f19c1866d81c9c80e9297d0d72967 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Sat, 23 Mar 2024 02:40:04 +0100 Subject: [PATCH 05/16] Fix small stuffs --- assets/shaders/engine/editorWaveforms.frag | 33 +++++++++++----------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/assets/shaders/engine/editorWaveforms.frag b/assets/shaders/engine/editorWaveforms.frag index 789c3c20..c2ea827d 100644 --- a/assets/shaders/engine/editorWaveforms.frag +++ b/assets/shaders/engine/editorWaveforms.frag @@ -2,11 +2,11 @@ // Used in charter by waveforms -const vec3 gradient1 = vec3(114./255., 81./255., 135./255); -const vec3 gradient2 = vec3(144./255., 80./255., 186./255); +const vec3 gradient1 = vec3(114.0/255.0, 81.0/255.0, 135.0/255.0); +const vec3 gradient2 = vec3(144.0/255.0, 80.0/255.0, 186.0/255.0); -const vec4 outlinecolor = vec4(vec3(.1), .1); -const vec3 lowdetailcol = vec3(0., 0., 1.); +const vec4 outlinecolor = vec4(0.1); +const vec3 lowdetailcol = vec3(0.0, 0.0, 1.0); uniform vec2 textureRes; uniform float pixelOffset; @@ -20,17 +20,16 @@ uniform bool lowDetail; float getAmplitude(vec2 pixel) { float pixelID = floor((pixel.y+pixelOffset)/3.0); - + // TODO: INVESTIGATE THE 1.+ AND WHY IT WORKS (SRSLY I GOT NO CLUE) -lunar vec2 wavePixel = vec2(mod(pixelID,waveformSize.x), 1.0+floor(pixelID/waveformSize.x)); vec4 waveData = texture2D(waveformTexture, wavePixel / waveformSize); - switch (int(mod(wavePixel.x, 3.0))) { - case 0: return waveData.r; break; - case 1: return waveData.g; break; - case 2: return waveData.b; break; - } - return 0.; + int id = int(mod(wavePixel.x, 3.0)); + if(id == 0) return waveData.r; + if(id == 1) return waveData.g; + if(id == 2) return waveData.b; + return 0.0; } float getAmpWidth(float amplitude) { @@ -45,26 +44,26 @@ bool inWaveForm(vec2 pixel, float width) { float getHightlight(float ampwidth) { float remapCoord = (ampwidth/textureRes.x)/2.0; float mappedCoord = map(openfl_TextureCoordv.x, remapCoord, 1.0-remapCoord, 0.0, 1.0); - return 1.-(abs(mappedCoord-0.5)*2.0); + return 1.0-(abs(mappedCoord-0.5)*2.0); } void outlineWaveform(vec2 pixel, vec2 offset) { float amplitude = getAmplitude(pixel - offset); - float ampwidth = (1.-amplitude) * textureRes.x; + float ampwidth = (1.0-amplitude) * textureRes.x; if (!inWaveForm(pixel, ampwidth)) - gl_FragColor -= outlinecolor*mix(0.5, .8, amplitude); + gl_FragColor -= outlinecolor*mix(0.5, 0.8, amplitude); } void highDetailWaveform(vec2 pixel, float amplitude, float ampwidth) { vec3 gradientColor = mix(gradient1, gradient2, openfl_TextureCoordv.x); - gradientColor *= pixel.y+pixelOffset>playerPosition ? 0.7 : 1.0; + gradientColor *= pixel.y+pixelOffset>playerPosition ? 0.7 : 1.0; gradientColor = mix(gradientColor, gradientColor * vec3(1.8), map(getHightlight(amplitude), 0.0, 1.0, 0.5, 1.0)); - float ampwidthHighlight = getAmpWidth(amplitude*(1.0/3.0)); + float ampwidthHighlight = getAmpWidth(amplitude/3.0); if (inWaveForm(pixel, ampwidthHighlight)) gradientColor = mix(gradientColor, gradientColor * vec3(1.8), map(getHightlight(ampwidthHighlight), 0.0, 1.0, 0.5, 1.0)); - + gl_FragColor = vec4(vec3(gradientColor * mix(0.5, 0.8, amplitude))*openfl_Alphav, openfl_Alphav); outlineWaveform(pixel, vec2(0.0, -1.0)); From 891e631257d23d90d33da6265ae90ec9ff92fdbc Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Sat, 23 Mar 2024 02:51:28 +0100 Subject: [PATCH 06/16] Debug sprite --- source/funkin/editors/charter/Charter.hx | 8 ++++++++ source/funkin/editors/charter/CharterWaveformHandler.hx | 4 ---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index aa7dc29c..b563eb07 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -490,6 +490,14 @@ class Charter extends UIState { Framerate.codenameBuildField.alpha = 0.4; } updateDisplaySprites(); + + // ! IF YOU EVER WANNA VIEW IN THE FUTURE, JUST USE A FLXSPRITE :D -lunar + /*var dataDisplay:FlxSprite = new FlxSprite().loadGraphic(waveformHandler.waveDatas.get("Voices.ogg")); + dataDisplay.scrollFactor.set(1, 0); + dataDisplay.scale.set(2, 2); + dataDisplay.updateHitbox(); + dataDisplay.screenCenter(Y); + dataDisplay.cameras = [charterCamera]; dataDisplay.x = -dataDisplay.width; add(dataDisplay);*/ } override function destroy() { diff --git a/source/funkin/editors/charter/CharterWaveformHandler.hx b/source/funkin/editors/charter/CharterWaveformHandler.hx index ce4d9749..44ef5ee9 100644 --- a/source/funkin/editors/charter/CharterWaveformHandler.hx +++ b/source/funkin/editors/charter/CharterWaveformHandler.hx @@ -60,10 +60,6 @@ class CharterWaveformHandler extends FlxBasic { waveDatas.set(name, waveData); return waveData; - - // ! IF YOU EVER WANNA VIEW IN THE FUTURE, JUST USE A FLXSPRITE :D -lunar - // var dataDisplay:FlxSprite = new FlxSprite().loadGraphic(waveformHandler.waveDatas.get("Voices.ogg")); - // dataDisplay.cameras = [charterCamera]; dataDisplay.x = -dataDisplay.width; add(dataDisplay); } public function generateShader(name:String, sound:FlxSound):CustomShader { From 6875b2126f938c8dd93b506a9bd2ad753c16ab91 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Fri, 22 Mar 2024 20:52:08 -0700 Subject: [PATCH 07/16] stuff --- assets/images/editors/ui/context-icons.png | Bin 1021 -> 1334 bytes source/funkin/editors/charter/Charter.hx | 5 +++-- .../editors/charter/CharterAutoSaveUI.hx | 3 ++- .../editors/charter/CharterDeleteAnim.hx | 11 +++++++++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/assets/images/editors/ui/context-icons.png b/assets/images/editors/ui/context-icons.png index 919766562e370878e90982869bc424a1f6d80754..a9de63581403f5b134af714932b9564f2032cea9 100644 GIT binary patch literal 1334 zcmV-61Px(@JU2LRA_vI&|@pp&b)sv49K>P|A&Cuqv9kkt$KI19{Z(bfk_FTY2aQ5ESo@ zA5Z-8-n}DNnlGX$Mo)sk^!O zBJ;M zVdjKpzl%!u_EP{r{j+PLDDi=j;qLQy0DxWkR1|Ti?h*i85YREWzjnWts+_Dox_dio z^lR%1g~HhPeFqtM*qEN6)ea<@9qk;deXvqG4IqHK`|}r*-xJ6eMX@MTS-pWL$Hos` z9$`CT;W*A{I2<~{*Rm`iBM%YB<#;ZJeiQ->&2mwv?j|Kzyx?XcZCKuJ&6V)6vQNF9 zq=-kMPyj*>rBZ2V+cwJOavvFZL|IsP(m-qoz^(u&rkVZ74`sixe9)=8EVh(CDgW6d z7{+Ud8U9A~A}q@zce~}{@gpZ`{#Ct`j@h6Ml}e={0H@JtAmq_^90w~aD<~F=$il-$ zI9iG5m2$x<0E>v8rl}g(ap$QLS<~KEPr!>oqnJWMWt?uUQ z7~G%UnPnZ<2hZgrIVZrgb{ofc?gS;(s*&CI=jZtLS07pBA zINCXknHs=-3&0Qo;P`9GhlA{YFY7rkUQ9M!d9tRmWmR*+-7{#DcFsaPHa0fkdEROW z*w-#=gsB1Cw*mZ(0I&}=RNd?az~oJpT7PqD&8}A()O4@_W@pQDz!i}8XVj|?z+TEZ z0L*z*t5uwxom~Mi^nD)yn3(wr5&Z!G9~VEuhjd+g5e?jT0rUY3FbU7&R(F#DeUgPQ zE5ZJHG1v>>dZ_XZjl4cDm$m&%k~IIyo(#mpvJCg&ZX+w)T?CLs!n6zEmQ*hw%I)@Q zwc4$dlM|9X7U5B;RDSFAdY2&aAZETyMA2Q)nQF}51MnAu(JMmp7y!4rn*gGZ1$xLb zU=7@+TPI~LoLdqj`w76?EjN}eC!Avl=ytmmXn0rv{4fIs z0NfkgkFBLNa5oW*+@Wj)Jp}a)S(*sJJ850pJQ5qNhky$NBX_~;%Helk+3TdM%gm$S z?*j=u?67di%vXuX6Q(FmE+CsB_-Zlrq@?_byp((PT3Nk;gS!npeiR(%kS(jgk`k`8 zL@YB8&-2Pi;6cnRUQ0RvR)nc4X09QaZv|Wt=VPN+3DGf&=$Dv_rSPnd+<*Cd@T>=N zX`e9j=3yhgc4cO+sGpz0rO*iRfgEZ{aF-1+O}X;;2kE0_LOxrX$p8QV07*qoM6N<$f)0FmNB{r; literal 1021 zcmVPx&w@E}nR9J=Gn7?ZrM-<0D?{sGo5;+{k%C8kfML^f+4@luUU1|q%kaWUzu>XXl z4u(`QoQ+(hvXUZ=8W%}v<3;&Ul?w8cJ}St z&%HNqc0^T4lr*#%pn!_VG}Yk$LEXf07F4JBT@jII_M)o3g@HKT%ClA+8)tbdc3Mzf zgbAbp^x<`YmEyi*H$VhceWw`rvdP#u%PS6T<(VY-@TSz1o(jk!fId76t|uZ#a|1=5 z6cB3_!t?s1t;lUr&ex-VzjK{G|MCOFFaB`n7GPZz`0#odcz@fA`L+81WM6#}+MAOP z@2Xx0;F5gloE>Mm0Gtw#6?lIhe(zoCRR(sMF9_CvJ+6hfzq1!UxU{jDp}G$dzpI&^?zz7Xe*Sd>Qa_8c&%uh<#h!_U$Lbqnzq}6`hw=FDhATTHVn8k zz-kk`U-h?d8fY3oPc_8{l(onB@B0~29g%(CQ3U~nDi zh{!|R5rcPga?8KRtpQ`u?A#ajMbg-xLMnPN9LBn9_3>zwGOTvayLXVe2n^r}fT-%* z5qNW21W#4_z+`Z^aa@7-+xsamQ0mi%{+T}~^I$mS;KmKpv%a2W?x&|u`SJ1N(4Mb` zf?*ViJZGnaS2^=*_g!W6l>qM?X8l)5;ici7^q!OJmEb{HJOJ3=*<*iauL3av-g)2! z24M9w?)GHK_c_5mj~`4AVtdk=Vy0XPkv;>rtCKhX`8E}*Y3nalM!TCy@W4c%OS_wsTd>L;#0b2P zFz}ui_s=MIWc-INj>rhStvr*u&4d6*E3%Q-RBh|j0j5O-1q?)gZ5M&Jfq`e!)@@}) z?1x`CO%lvEacpcG8xBz$e%g+9H 0) garbageIcon.draw(); } + + public override function destroy() { + super.destroy(); + __mousePos.put(); + } } \ No newline at end of file From 66f946d724fb2b4b7cdc8a4c8d83f185064a18c1 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Fri, 22 Mar 2024 22:26:43 -0700 Subject: [PATCH 08/16] polish everything up --- assets/images/editors/deleter circle.png | Bin 0 -> 243 bytes .../editors/charter/CharterAutoSaveUI.hx | 8 +++---- .../editors/charter/CharterDeleteAnim.hx | 22 ++++++++++++++---- 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 assets/images/editors/deleter circle.png diff --git a/assets/images/editors/deleter circle.png b/assets/images/editors/deleter circle.png new file mode 100644 index 0000000000000000000000000000000000000000..7d63d06923ef0671332e98ff6c394c083de245ac GIT binary patch literal 243 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|)_S@)hFJ6- zoqUk@kO7aYylApQDQ{ooLhX>ZAuek!h*qUE#Vz)FBk1SW_n1wE?}y0k`{$>R-15Kq4s3m|`y#gdo7=QQY#Q84E<0IoOAoso+4%OK zW;o-vDSV7^>zH~JcO24HJtlCAVe2ZUMfanapNgeDPzz?bb6xbUv~IxtgDMk_DV}w( rVd7w6w2WQMx9#7dls_+4)om5$%(t~ {disappearAnimation(true);}); - autosavingText.text += "(Canceled!)"; cancelButton.visible = false; - for (member in [this, autosavingText]) member.color = 0xFFB62C2C; - for (member in [progressBar, progressBarBack]) member.color = 0xFFE53D3D; + autosavingText.text += " (Canceled)!"; cancelButton.visible = false; + for (member in [this, autosavingText]) member.color = 0xFFE67F7F; + for (member in [progressBar, progressBarBack]) member.color = 0xFFE67F7F; }, 24, 14); cancelButton.frames = Paths.getFrames("editors/ui/grayscale-button"); cancelButton.color = 0xFFAC3D3D; cancelButton.alpha = 0.2; members.push(cancelButton); cancelButton.visible = false; cancelIcon = new FlxSprite(x-(10+16), y+8).loadGraphic(Paths.image("editors/autosave-delete")); - cancelIcon.color = 0xFF880000; + cancelIcon.color = 0xFFD60E0E; members.push(cancelIcon); alpha = 0; diff --git a/source/funkin/editors/charter/CharterDeleteAnim.hx b/source/funkin/editors/charter/CharterDeleteAnim.hx index ff873a2b..df3f565b 100644 --- a/source/funkin/editors/charter/CharterDeleteAnim.hx +++ b/source/funkin/editors/charter/CharterDeleteAnim.hx @@ -2,6 +2,7 @@ package funkin.editors.charter; class CharterDeleteAnim extends CharterNote { public var garbageIcon:FlxSprite; + public var garbageCircle:FlxSprite; public var deleteNotes:Array<{note:CharterNote, time:Float}> = []; public var deleteTime:Float = .4; @@ -9,13 +10,17 @@ class CharterDeleteAnim extends CharterNote { public function new() { super(); - sustainSpr.color = 0xFF6D2425; color = 0xFF797171; + sustainSpr.color = 0xFF630000; color = 0xFF605A5A; snappedToStrumline = selectable = autoAlpha = false; @:privateAccess __animSpeed = 1.25; garbageIcon = new FlxSprite().loadGraphic(Paths.image("editors/deleter")); garbageIcon.color = 0xFF880000; garbageIcon.cameras = [Charter.instance.uiCamera]; + + garbageCircle = new FlxSprite().loadGraphic(Paths.image("editors/deleter circle")); + garbageCircle.color = 0xFF880000; garbageCircle.alpha = .6; + garbageCircle.cameras = [Charter.instance.uiCamera]; } var __garbageAlpha:Float = 0; @@ -33,12 +38,20 @@ class CharterDeleteAnim extends CharterNote { __garbageAlpha = FlxMath.lerp(__garbageAlpha, FlxG.mouse.pressedRight && __deletionTimer <= 0 ? 1 : 0, 1/10); FlxG.mouse.getWorldPosition(Charter.instance.uiCamera, __mousePos); - if (FlxG.mouse.pressedRight && __deletionTimer <= 0) + if (FlxG.mouse.pressedRight && __deletionTimer <= 0) { garbageIcon.setPosition( - __mousePos.x + garbageIcon.width/2 + (.5*FlxG.random.float(-1, 1)), - __mousePos.y - garbageIcon.height + (.5*FlxG.random.float(-1, 1)) + __mousePos.x + garbageIcon.width/2 + (.65*FlxG.random.float(-1, 1)) + 2, + __mousePos.y - garbageIcon.height + (.65*FlxG.random.float(-1, 1)) - 8 ); + + garbageCircle.setPosition( + __mousePos.x - garbageCircle.width/2, + (__mousePos.y - garbageCircle.height/2) + 2 + ); + } + garbageIcon.alpha = __garbageAlpha; + garbageCircle.alpha = __garbageAlpha*.6; } public override function draw() @:privateAccess { @@ -63,6 +76,7 @@ class CharterDeleteAnim extends CharterNote { } if (garbageIcon.alpha > 0) garbageIcon.draw(); + if (garbageCircle.alpha > 0) garbageCircle.draw(); } public override function destroy() { From b7b61093b6e059376576e41b302200862bba742d Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Sat, 23 Mar 2024 02:41:01 -0700 Subject: [PATCH 09/16] try catch on relink undos --- source/funkin/editors/charter/Charter.hx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index c54e200b..df5c5aa2 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -577,8 +577,10 @@ class Charter extends UIState { buildNoteTypesUI(); refreshBPMSensitive(); - // Undo Stuffs :D - __relinkUndos(); + // Just for now until i add event stacking -lunar + try {__relinkUndos();} + catch (e) {Logs.trace('Failed to relink undos: ${Std.string(e)}', ERROR);} + __applyPlaytestInfo(); } From 168dacf68e21c261770472d515b6b11e929d39e5 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Sat, 23 Mar 2024 02:49:39 -0700 Subject: [PATCH 10/16] pretty print option --- source/funkin/editors/DebugOptions.hx | 6 +++++- source/funkin/editors/charter/Charter.hx | 6 +++--- source/funkin/game/PlayState.hx | 2 +- source/funkin/options/Options.hx | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source/funkin/editors/DebugOptions.hx b/source/funkin/editors/DebugOptions.hx index 01df41d0..8dcfeda7 100644 --- a/source/funkin/editors/DebugOptions.hx +++ b/source/funkin/editors/DebugOptions.hx @@ -36,9 +36,13 @@ class DebugOptionsScreen extends OptionsScreen { })); #end add(new Checkbox( - "Enable Editor SFXs", + "Editor SFXs", "If checked, will play sound effects when working on editors (ex: will play sfxs when checking checkboxes...)", "editorSFX")); + add(new Checkbox( + "Pretty Print", + "If checked, the saved files from the editor will be formatted to be easily viewable (does not apply to xmls...)", + "editorPrettyPrint")); add(new Checkbox( "Intensive Blur", "If checked, will use more intensive blur that may be laggier but look better.", diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index df5c5aa2..9211b5fc 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -700,9 +700,9 @@ class Charter extends UIState { var songPath:String = '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}'; if (Options.charterAutoSavesSeperateFolder) - Chart.save(songPath, PlayState.SONG, __autoSaveLocation, {saveMetaInChart: false, folder: "autosaves"}); + Chart.save(songPath, PlayState.SONG, __autoSaveLocation, {saveMetaInChart: false, folder: "autosaves", prettyPrint: Options.editorPrettyPrint}); else - Chart.save(songPath, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: false}); + Chart.save(songPath, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: false, prettyPrint: Options.editorPrettyPrint}); undos.save(); } autoSaveNotif.cancelled = false; @@ -1345,7 +1345,7 @@ class Charter extends UIState { #if sys function saveTo(path:String, separateEvents:Bool = false) { buildChart(); - Chart.save(path, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: false, saveEventsInChart: !separateEvents}); + Chart.save(path, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: false, saveEventsInChart: !separateEvents, prettyPrint: Options.editorPrettyPrint}); } #end diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index c7364225..9a46aeb9 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -759,7 +759,7 @@ class PlayState extends MusicBeatState SaveWarning.warningFunc = saveWarn; SaveWarning.saveFunc = () -> { @:privateAccess Chart.save('${Paths.getAssetsRoot()}/songs/${Charter.__song.toLowerCase()}', - PlayState.SONG, Charter.__diff.toLowerCase(), {saveMetaInChart: false, saveEventsInChart: true}); + PlayState.SONG, Charter.__diff.toLowerCase(), {saveMetaInChart: false, saveEventsInChart: true, prettyPrint: Options.editorPrettyPrint}); } } } diff --git a/source/funkin/options/Options.hx b/source/funkin/options/Options.hx index debe4a13..a9bf72ac 100644 --- a/source/funkin/options/Options.hx +++ b/source/funkin/options/Options.hx @@ -43,7 +43,7 @@ class Options */ public static var intensiveBlur:Bool = true; public static var editorSFX:Bool = true; - public static var resizableEditors:Bool = true; + public static var editorPrettyPrint:Bool = false; public static var maxUndos:Int = 120; /** From 217cade22c13d0e8971c28c0c627ea93f2e89a7e Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Sat, 23 Mar 2024 05:08:53 -0700 Subject: [PATCH 11/16] Exporting to other engines wip --- source/funkin/backend/chart/Chart.hx | 3 +- .../{BaseGameParser.hx => FNFLegacyParser.hx} | 99 +++++++++++++++++-- source/funkin/editors/charter/Charter.hx | 16 +++ 3 files changed, 111 insertions(+), 7 deletions(-) rename source/funkin/backend/chart/{BaseGameParser.hx => FNFLegacyParser.hx} (52%) diff --git a/source/funkin/backend/chart/Chart.hx b/source/funkin/backend/chart/Chart.hx index 0b5dffab..a1376e82 100644 --- a/source/funkin/backend/chart/Chart.hx +++ b/source/funkin/backend/chart/Chart.hx @@ -1,5 +1,6 @@ package funkin.backend.chart; +import funkin.backend.system.Conductor; import funkin.backend.chart.ChartData; import flixel.util.FlxColor; import haxe.io.Path; @@ -143,7 +144,7 @@ class Chart { base = data; } else { // base game chart - BaseGameParser.parse(data, base); + FNFLegacyParser.parse(data, base); } #end } diff --git a/source/funkin/backend/chart/BaseGameParser.hx b/source/funkin/backend/chart/FNFLegacyParser.hx similarity index 52% rename from source/funkin/backend/chart/BaseGameParser.hx rename to source/funkin/backend/chart/FNFLegacyParser.hx index 9d017621..c962ec0a 100644 --- a/source/funkin/backend/chart/BaseGameParser.hx +++ b/source/funkin/backend/chart/FNFLegacyParser.hx @@ -1,6 +1,9 @@ package funkin.backend.chart; -class BaseGameParser { +import funkin.backend.chart.ChartData.ChartEvent; +import funkin.backend.system.Conductor; + +class FNFLegacyParser { public static function parse(data:Dynamic, result:ChartData) { // base fnf chart parsing var data:SwagSong = data; @@ -109,7 +112,90 @@ class BaseGameParser { curTime += curCrochet * beatsPerMeasure; } } + + // have conductor set up BEFORE you run this :D -lunar + public static function encode(chart:ChartData):Dynamic { + var base:SwagSong = __convertToSwagSong(chart); + base.notes = __convertToSwagSections(chart); + + for (strumLine in chart.strumLines) + for (note in strumLine.notes) { + var section:Int = Math.floor(Conductor.getStepForTime(note.time) / Conductor.getMeasureLength()); + if (section > 0 && section < base.notes.length) + base.notes[section].sectionNotes.push([ + note.time, // TIME + note.id + (strumLine.type == PLAYER ? 3 : 0), // DATA + note.sLen // SUSTAIN LENGTH + ]); + } + + return {song: base}; + } + + // To make it easier to write the psych parser... -lunar + @:noCompletion public static function __convertToSwagSong(chart:ChartData):SwagSong { + var base:SwagSong = { + song: chart.meta.name, + notes: null, + bpm: chart.meta.bpm, + needsVoices: chart.meta.needsVoices, + speed: chart.scrollSpeed, + + player1: null, + player2: null, + validScore: true + }; + + for (strumLine in chart.strumLines) + switch (strumLine.type) { + case OPPONENT: + if (base.player2 == null) base.player2 = strumLine.characters.getDefault(["dad"])[0]; + case PLAYER: + if (base.player1 == null) base.player1 = strumLine.characters.getDefault(["bf"])[0]; + case ADDITIONAL: + // if (base.gf == null || base.gfVersion == null) + // base.gf = base.gfVersion = strumLine.characters.getDefault(["gf"])[0]; + } + + return base; + } + + @:noCompletion public static function __convertToSwagSections(chart:ChartData):Array { + var events:Array = chart.events.copy(); + + var measures:Float = Conductor.getMeasuresLength(); + var sections:Int = Math.floor(measures) + (measures % 1 > 0 ? 1 : 0); + + var notes:Array = cast new haxe.ds.Vector(sections); + for (section in 0...sections) { + var baseSection:SwagSection = { + sectionNotes: [], + lengthInSteps: Std.int(Conductor.getMeasureLength()), + mustHitSection: notes[section-1] != null ? notes[section-1].mustHitSection : false, + bpm: notes[section-1] != null ? notes[section-1].bpm : chart.meta.bpm, + changeBPM: false, + altAnim: notes[section-1] != null ? notes[section-1].altAnim : false + }; + + var sectionEndTime:Float = Conductor.getTimeForStep(Conductor.getMeasureLength() * (section+1)); + while(events.length > 0 && events.last().time <= sectionEndTime) { + var event:ChartEvent = events.pop(); + switch (event.name) { + case "Camera Movement": + baseSection.mustHitSection = chart.strumLines[event.params[0]].type == PLAYER; + case "Alt Animation Toggle": + baseSection.altAnim = event.params[0] || event.params[1]; + case "BPM Change": + baseSection.changeBPM = true; + baseSection.bpm = event.params[0]; + } + } + notes[section] = baseSection; + } + return notes; + } } + typedef SwagSong = { var song:String; @@ -117,13 +203,13 @@ typedef SwagSong = var bpm:Float; var needsVoices:Bool; var speed:Float; - var stage:String; - var noteTypes:Array; + var ?stage:String; + var ?noteTypes:Array; var player1:String; var player2:String; - var gf:String; - var gfVersion:String; + var ?gf:String; + var ?gfVersion:String; var validScore:Bool; // ADDITIONAL STUFF THAT MAY NOT BE PRESENT IN CHART @@ -136,9 +222,10 @@ typedef SwagSection = { var sectionNotes:Array; var lengthInSteps:Int; + var ?typeOfSection:Int; var mustHitSection:Bool; var bpm:Float; var changeBPM:Bool; var altAnim:Null; - @:optional var camTarget:Null; + var ?camTarget:Null; } diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 9211b5fc..59be523c 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -164,6 +164,15 @@ class Charter extends UIState { onSelect: _file_meta_saveas, }, null, + { + label: "Export As FNF Legacy...", + onSelect: _file_saveas_fnflegacy, + }, + { + label: "Export As Psych Engine...", + onSelect: _file_saveas_psych, + }, + null, { label: "Exit", onSelect: _file_exit @@ -1323,6 +1332,13 @@ class Charter extends UIState { })); } + function _file_saveas_fnflegacy(_) { + openSubState(new SaveSubstate(Json.stringify(FNFLegacyParser.encode(PlayState.SONG), Options.editorPrettyPrint ? "\t" : null), { + defaultSaveFile: '${__song.toLowerCase().replace(" ", "-")}${__diff.toLowerCase() == "normal" ? "" : '-${__diff.toLowerCase()}'}.json', + })); + } + function _file_saveas_psych(_) {} + function _file_events_save(_) { #if sys CoolUtil.safeSaveFile( From bb5ad66313a915db2880786005f4a08ff0e5a267 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Sat, 23 Mar 2024 06:34:03 -0700 Subject: [PATCH 12/16] psych engine exporter Co-authored-by: Ne_Eo --- .../funkin/backend/chart/FNFLegacyParser.hx | 6 +- source/funkin/backend/chart/PsychParser.hx | 89 +++++++++++++++++++ source/funkin/editors/charter/Charter.hx | 16 ++-- 3 files changed, 102 insertions(+), 9 deletions(-) create mode 100644 source/funkin/backend/chart/PsychParser.hx diff --git a/source/funkin/backend/chart/FNFLegacyParser.hx b/source/funkin/backend/chart/FNFLegacyParser.hx index c962ec0a..279e174c 100644 --- a/source/funkin/backend/chart/FNFLegacyParser.hx +++ b/source/funkin/backend/chart/FNFLegacyParser.hx @@ -152,9 +152,7 @@ class FNFLegacyParser { if (base.player2 == null) base.player2 = strumLine.characters.getDefault(["dad"])[0]; case PLAYER: if (base.player1 == null) base.player1 = strumLine.characters.getDefault(["bf"])[0]; - case ADDITIONAL: - // if (base.gf == null || base.gfVersion == null) - // base.gf = base.gfVersion = strumLine.characters.getDefault(["gf"])[0]; + case ADDITIONAL: // do nothing } return base; @@ -205,6 +203,7 @@ typedef SwagSong = var speed:Float; var ?stage:String; var ?noteTypes:Array; + var ?events:Array; var player1:String; var player2:String; @@ -224,6 +223,7 @@ typedef SwagSection = var lengthInSteps:Int; var ?typeOfSection:Int; var mustHitSection:Bool; + var ?gfSection:Bool; var bpm:Float; var changeBPM:Bool; var altAnim:Null; diff --git a/source/funkin/backend/chart/PsychParser.hx b/source/funkin/backend/chart/PsychParser.hx new file mode 100644 index 00000000..1d718a84 --- /dev/null +++ b/source/funkin/backend/chart/PsychParser.hx @@ -0,0 +1,89 @@ +package funkin.backend.chart; + +import funkin.backend.chart.ChartData.ChartEvent; +import funkin.backend.chart.FNFLegacyParser.SwagSong; +import funkin.backend.system.Conductor; + +class PsychParser { + public static function parse(data:Dynamic, result:ChartData) + FNFLegacyParser.parse(data, result); + + public static function encode(chart:ChartData):Dynamic { + var base:SwagSong = FNFLegacyParser.__convertToSwagSong(chart); + base.notes = FNFLegacyParser.__convertToSwagSections(chart); + base.stage = chart.stage; + + for (strumLine in chart.strumLines) + if (strumLine.type == ADDITIONAL && base.gfVersion == null) + base.gfVersion = strumLine.characters.getDefault(["gf"])[0]; + + for (strumLine in chart.strumLines) + for (note in strumLine.notes) { + var section:Int = Math.floor(Conductor.getStepForTime(note.time) / Conductor.getMeasureLength()); + if (section > 0 && section < base.notes.length) + base.notes[section].sectionNotes.push([ + note.time, // TIME + note.id + (strumLine.type == PLAYER ? 3 : 0), // DATA + note.sLen, // SUSTAIN LENGTH + chart.noteTypes.getDefault([""])[note.type] // NOTE TYPE + ]); + } + + base.events = []; + + var groupedEvents:Array> = []; + var __last:Array = null; + var __lastTime:Float = Math.NaN; + for (e in chart.events) { + if (e == null) continue; + if (__last != null && __lastTime == e.time) + __last.push(e); + else { + __last = [e]; + __lastTime = e.time; + groupedEvents.push(__last); + } + } + + for (events in groupedEvents) { + var psychEvents:Array = []; + for (event in events) + switch (event.name) { + case "Add Camera Zoom": + psychEvents.push([ + event.name, + event.params[1] == "camGame" ? event.params[0] : 0, // CAMERA ZOOM + event.params[1] == "camHUD" ? event.params[0] : 0, // UI ZOOM + ]); + case "Play Animation": + psychEvents.push([ + event.name, + event.params[1], // ANIMATION TO PLAY + switch (chart.strumLines[event.params[0]].type) { // CHARACTER + case PLAYER: "bf"; + case OPPONENT: "dad"; + case ADDITIONAL: "gf"; + } + ]); + case "Scroll Speed Change": + var eventStep:Float = Conductor.getStepForTime(event.time); + psychEvents.push([ + "Change Scroll Speed", + event.params[1]/chart.scrollSpeed, // SCROLL SPEED MULTIPLER + Conductor.getTimeForStep(eventStep+event.params[2]) - Conductor.getTimeForStep(eventStep), // TIME + ]); + default: + // TODO: allow custom formats in event.json + var split:Float = event.params.length / 2; + + var val1:String = [for (arg in 0...Math.ceil(split)) event.params[arg]].join(","); + var val2:String = [for (arg in Math.ceil(split)...event.params.length) event.params[arg]].join(","); + + psychEvents.push([event.name, val1, val2]); + } + base.events.push([events[0].time, psychEvents]); + } + + return {song: base}; + } +} diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 59be523c..72bfd3e0 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -1293,7 +1293,7 @@ class Charter extends UIState { } function _file_saveas(_) { - openSubState(new SaveSubstate(Json.stringify(Chart.filterChartForSaving(PlayState.SONG, false)), { + openSubState(new SaveSubstate(Json.stringify(Chart.filterChartForSaving(PlayState.SONG, false), null, Options.editorPrettyPrint ? "\t" : null), { defaultSaveFile: '${__diff.toLowerCase()}.json' })); undos.save(); @@ -1309,7 +1309,7 @@ class Charter extends UIState { } function _file_saveas_no_events(_) { - openSubState(new SaveSubstate(Json.stringify(Chart.filterChartForSaving(PlayState.SONG, false, false)), { + openSubState(new SaveSubstate(Json.stringify(Chart.filterChartForSaving(PlayState.SONG, false, false), null, Options.editorPrettyPrint ? "\t" : null), { defaultSaveFile: '${__diff.toLowerCase()}.json' })); undos.save(); @@ -1333,17 +1333,21 @@ class Charter extends UIState { } function _file_saveas_fnflegacy(_) { - openSubState(new SaveSubstate(Json.stringify(FNFLegacyParser.encode(PlayState.SONG), Options.editorPrettyPrint ? "\t" : null), { + openSubState(new SaveSubstate(Json.stringify(FNFLegacyParser.encode(PlayState.SONG), null, Options.editorPrettyPrint ? "\t" : null), { + defaultSaveFile: '${__song.toLowerCase().replace(" ", "-")}${__diff.toLowerCase() == "normal" ? "" : '-${__diff.toLowerCase()}'}.json', + })); + } + function _file_saveas_psych(_) { + openSubState(new SaveSubstate(Json.stringify(PsychParser.encode(PlayState.SONG), null, Options.editorPrettyPrint ? "\t" : null), { defaultSaveFile: '${__song.toLowerCase().replace(" ", "-")}${__diff.toLowerCase() == "normal" ? "" : '-${__diff.toLowerCase()}'}.json', })); } - function _file_saveas_psych(_) {} function _file_events_save(_) { #if sys CoolUtil.safeSaveFile( '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/events.json', - Json.stringify({events: PlayState.SONG.events == null ? [] : PlayState.SONG.events}) + Json.stringify({events: PlayState.SONG.events == null ? [] : PlayState.SONG.events}, null, Options.editorPrettyPrint ? "\t" : null) ); #else _file_events_saveas(_); @@ -1352,7 +1356,7 @@ class Charter extends UIState { function _file_events_saveas(_) { #if sys - openSubState(new SaveSubstate(Json.stringify({events: PlayState.SONG.events == null ? [] : PlayState.SONG.events}), { + openSubState(new SaveSubstate(Json.stringify({events: PlayState.SONG.events == null ? [] : PlayState.SONG.events}, null, Options.editorPrettyPrint ? "\t" : null), { defaultSaveFile: 'events.json' })); #end From b1bbba6e95666b35253887eead75ebcb933716af Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Sat, 23 Mar 2024 06:39:15 -0700 Subject: [PATCH 13/16] sectionBeats from psych --- source/funkin/backend/chart/FNFLegacyParser.hx | 1 + source/funkin/backend/chart/PsychParser.hx | 3 +++ source/funkin/editors/charter/Charter.hx | 1 + 3 files changed, 5 insertions(+) diff --git a/source/funkin/backend/chart/FNFLegacyParser.hx b/source/funkin/backend/chart/FNFLegacyParser.hx index 279e174c..6f8faa00 100644 --- a/source/funkin/backend/chart/FNFLegacyParser.hx +++ b/source/funkin/backend/chart/FNFLegacyParser.hx @@ -221,6 +221,7 @@ typedef SwagSection = { var sectionNotes:Array; var lengthInSteps:Int; + var ?sectionBeats:Float; var ?typeOfSection:Int; var mustHitSection:Bool; var ?gfSection:Bool; diff --git a/source/funkin/backend/chart/PsychParser.hx b/source/funkin/backend/chart/PsychParser.hx index 1d718a84..91f31a51 100644 --- a/source/funkin/backend/chart/PsychParser.hx +++ b/source/funkin/backend/chart/PsychParser.hx @@ -13,6 +13,9 @@ class PsychParser { base.notes = FNFLegacyParser.__convertToSwagSections(chart); base.stage = chart.stage; + for (section in base.notes) + section.sectionBeats = Conductor.beatsPerMeasure; + for (strumLine in chart.strumLines) if (strumLine.type == ADDITIONAL && base.gfVersion == null) base.gfVersion = strumLine.characters.getDefault(["gf"])[0]; diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 72bfd3e0..e2420ce5 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -1337,6 +1337,7 @@ class Charter extends UIState { defaultSaveFile: '${__song.toLowerCase().replace(" ", "-")}${__diff.toLowerCase() == "normal" ? "" : '-${__diff.toLowerCase()}'}.json', })); } + function _file_saveas_psych(_) { openSubState(new SaveSubstate(Json.stringify(PsychParser.encode(PlayState.SONG), null, Options.editorPrettyPrint ? "\t" : null), { defaultSaveFile: '${__song.toLowerCase().replace(" ", "-")}${__diff.toLowerCase() == "normal" ? "" : '-${__diff.toLowerCase()}'}.json', From 9f798911f152da3b3ef171aa08a023724344a234 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Sat, 23 Mar 2024 06:46:22 -0700 Subject: [PATCH 14/16] awesome beans --- source/funkin/editors/charter/CharterStrumlineScreen.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/editors/charter/CharterStrumlineScreen.hx b/source/funkin/editors/charter/CharterStrumlineScreen.hx index 3b8f7920..26696251 100644 --- a/source/funkin/editors/charter/CharterStrumlineScreen.hx +++ b/source/funkin/editors/charter/CharterStrumlineScreen.hx @@ -112,7 +112,7 @@ class CharterStrumlineScreen extends UISubstateWindow { var strOffset:Float = strumLine.strumLinePos == null ? (strumLine.type == 1 ? 0.75 : 0.25) : strumLine.strumLinePos; - var startingPos:FlxPoint = strumLine.strumLinePos == null ? + var startingPos:FlxPoint = strumLine.strumPos == null ? FlxPoint.get(strOffset, 50) : FlxPoint.get(strOffset, strumLine.strumPos[1]); From cc6d4488369272cb78ff837b1753b4de3f1d86b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Sun, 24 Mar 2024 03:43:28 +0100 Subject: [PATCH 15/16] automatic installation for vs build tools thanks to @crowplexus for the curl and the vs_Community.exe cmd lines! --- README.md | 18 +++--------------- commandline/commands/Compiler.hx | 2 +- commandline/commands/Update.hx | 12 ++++++++++++ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index d09c559a..c4439c44 100644 --- a/README.md +++ b/README.md @@ -30,22 +30,10 @@ In the future (when the engine won't be a WIP anymore) we're gonna also publish ##### Tested on Windows 10 21H2 1. Install [version 4.2.5 of Haxe](https://haxe.org/download/version/4.2.5/). -2. Download [Visual Studio Build Tools](https://aka.ms/vs/17/release/vs_BuildTools.exe) -3. Wait for the Visual Studio Installer to install -4. On the Visual Studio installer screen, go to the "Individual components" tab and only select those options: - - MSVC v143 VS 2022 C++ x64/x86 build tools (Latest) - - Windows 10/11 SDK (any works) -5. This is what your Installation details panel should look like. Once correct, press "Install". - - ⚠ This will download around 1.07 GB of data from the internet, and will require around 5.5 GB of available space on your computer. - -

- -

- -6. Once you finish downloading those components, download and install [`git-scm`](https://git-scm.com/download/win). +2. Download and install [`git-scm`](https://git-scm.com/download/win). - Leave all installation options as default. -7. Run `update.bat` using cmd or double-clicking it, and wait for the libraries to install. -8. Once the libraries are installed, run `haxelib run lime test windows` to compile and launch the game (may take a long time) +3. Run `update.bat` using cmd or double-clicking it, and wait for the libraries to install. +4. Once the libraries are installed, run `haxelib run lime test windows` to compile and launch the game (may take a long time) - ℹ You can run `haxelib run lime setup` to make the lime command global, allowing you to execute `lime test windows` directly.
diff --git a/commandline/commands/Compiler.hx b/commandline/commands/Compiler.hx index 62000723..fe64c198 100644 --- a/commandline/commands/Compiler.hx +++ b/commandline/commands/Compiler.hx @@ -20,7 +20,7 @@ class Compiler { Sys.command("lime", arg); } - private static function getBuildTarget() { + public static function getBuildTarget() { return switch(Sys.systemName()) { case "Windows": "windows"; diff --git a/commandline/commands/Update.hx b/commandline/commands/Update.hx index d43c3620..a2d81153 100644 --- a/commandline/commands/Update.hx +++ b/commandline/commands/Update.hx @@ -71,6 +71,18 @@ class Update { } } } + + // vswhere.exe its used to find any visual studio related installations on the system, including full visual studio ide installations, visual studio build tools installations, and other related components - Nex + if (Compiler.getBuildTarget().toLowerCase() == "windows" && new Process('"C:/Program Files (x86)/Microsoft Visual Studio/Installer/vswhere.exe" -property catalog_productDisplayVersion').exitCode(true) == 1) { + prettyPrint("Installing Microsoft Visual Studio Community (Dependency)"); + Sys.command("curl -# -O https://download.visualstudio.microsoft.com/download/pr/3105fcfe-e771-41d6-9a1c-fc971e7d03a7/8eb13958dc429a6e6f7e0d6704d43a55f18d02a253608351b6bf6723ffdaf24e/vs_Community.exe"); + Sys.command("vs_Community.exe --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.19041 -p"); + FileSystem.deleteFile("vs_Community.exe"); + + prettyPrint('Because of this component if you want to compile you have to restart the device.'); + Sys.print("Do you wish to do it now [y/n]? "); + if(Sys.stdin().readLine().toLowerCase() == "y") Sys.command("shutdown /r /t 0 /f"); + } } public static function prettyPrint(text:String) { From 6ed2e222c1e75c78b66cb0a53fb53f73213a459f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Sun, 24 Mar 2024 04:27:44 +0100 Subject: [PATCH 16/16] adjusting some last things --- assets/data/characters/gf.xml | 2 +- assets/data/stages/philly.hx | 2 +- assets/data/stages/school.xml | 2 +- assets/data/titlescreen/titlescreen.xml | 4 ++-- commandline/commands/Update.hx | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/assets/data/characters/gf.xml b/assets/data/characters/gf.xml index 44c6f9e5..e9ac6776 100644 --- a/assets/data/characters/gf.xml +++ b/assets/data/characters/gf.xml @@ -7,7 +7,7 @@ - + diff --git a/assets/data/stages/philly.hx b/assets/data/stages/philly.hx index 2a4b9780..989b29b5 100644 --- a/assets/data/stages/philly.hx +++ b/assets/data/stages/philly.hx @@ -90,7 +90,7 @@ function updateTrainPos():Void function trainReset():Void { - gf.playAnim('hairFall'); + gf.playAnim('hairFall', true); phillyTrain.x = FlxG.width + 200; trainMoving = false; // trainSound.stop(); diff --git a/assets/data/stages/school.xml b/assets/data/stages/school.xml index e4c4d5e1..dabf463b 100644 --- a/assets/data/stages/school.xml +++ b/assets/data/stages/school.xml @@ -23,7 +23,7 @@ antialiasing="false" scale="6" scroll="0.85" updateHitbox="true" type="loop"/> - + diff --git a/assets/data/titlescreen/titlescreen.xml b/assets/data/titlescreen/titlescreen.xml index 0ff1053b..f16c8b62 100644 --- a/assets/data/titlescreen/titlescreen.xml +++ b/assets/data/titlescreen/titlescreen.xml @@ -1,8 +1,8 @@ - - + + diff --git a/commandline/commands/Update.hx b/commandline/commands/Update.hx index a2d81153..92ae18c7 100644 --- a/commandline/commands/Update.hx +++ b/commandline/commands/Update.hx @@ -79,7 +79,7 @@ class Update { Sys.command("vs_Community.exe --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.19041 -p"); FileSystem.deleteFile("vs_Community.exe"); - prettyPrint('Because of this component if you want to compile you have to restart the device.'); + prettyPrint('If it didn\'t say it before: Because of this component if you want to compile you have to restart the device.'); Sys.print("Do you wish to do it now [y/n]? "); if(Sys.stdin().readLine().toLowerCase() == "y") Sys.command("shutdown /r /t 0 /f"); }