From cf4476d2853d48b6f40d1e18cb3329ac0d34c0cd Mon Sep 17 00:00:00 2001 From: 7oltan <87986834+7oltan@users.noreply.github.com> Date: Mon, 23 Sep 2024 21:57:34 +0300 Subject: [PATCH 1/2] custom capsule colors --- assets | 2 +- .../data/freeplay/style/FreeplayStyleData.hx | 6 + source/funkin/ui/freeplay/FreeplayStyle.hx | 30 +++++ source/funkin/ui/freeplay/SongMenuItem.hx | 113 +++++++++++++++--- 4 files changed, 132 insertions(+), 19 deletions(-) diff --git a/assets b/assets index bc7009b424..7ac14b35a3 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit bc7009b4242691faa5c4552f7ca8a2f28e8cb1d2 +Subproject commit 7ac14b35a3c7e1898bbcd1107e0d7d694ed99d30 diff --git a/source/funkin/data/freeplay/style/FreeplayStyleData.hx b/source/funkin/data/freeplay/style/FreeplayStyleData.hx index 1af1982173..c4815ce4d0 100644 --- a/source/funkin/data/freeplay/style/FreeplayStyleData.hx +++ b/source/funkin/data/freeplay/style/FreeplayStyleData.hx @@ -40,6 +40,12 @@ typedef FreeplayStyleData = */ public var capsuleTextColors:Array; + /** + * Color data for the capsule colors. + * the order of this array goes as follows: [SELECTED, DESELECTED, GLOW] + */ + public var capsuleColors:Array; + /** * Delay time after confirming a song selection, before entering PlayState. * Useful for letting longer animations play out. diff --git a/source/funkin/ui/freeplay/FreeplayStyle.hx b/source/funkin/ui/freeplay/FreeplayStyle.hx index 5ced51e1cb..6d305b2108 100644 --- a/source/funkin/ui/freeplay/FreeplayStyle.hx +++ b/source/funkin/ui/freeplay/FreeplayStyle.hx @@ -88,6 +88,36 @@ class FreeplayStyle implements IRegistryEntry return FlxColor.fromString(_data.capsuleTextColors[0]); } + /** + * Return the color of the selected capsule bg + * for freeplay capsules. + * @return The color + */ + public function getCapsuleBGcolor():FlxColor + { + return FlxColor.fromString(_data.capsuleColors[0]); + } + + /** + * Return the deselected color of the capsule bg + * for freeplay capsules. + * @return The deselected color + */ + public function getCapsuleBGdeselectedColor():FlxColor + { + return FlxColor.fromString(_data.capsuleColors[1]); + } + + /** + * Return the glow color for the capsule + * for freeplay capsules. + * @return The glow color + */ + public function getCapsuleGlowColor():FlxColor + { + return FlxColor.fromString(_data.capsuleColors[2]); + } + /** * Return the song selection transition delay. * @return The start delay diff --git a/source/funkin/ui/freeplay/SongMenuItem.hx b/source/funkin/ui/freeplay/SongMenuItem.hx index 11ca44d541..cd5ddfd38a 100644 --- a/source/funkin/ui/freeplay/SongMenuItem.hx +++ b/source/funkin/ui/freeplay/SongMenuItem.hx @@ -28,7 +28,7 @@ import funkin.ui.PixelatedIcon; class SongMenuItem extends FlxSpriteGroup { - public var capsule:FlxSprite; + public var capsule:CapsuleSprite; var pixelIcon:PixelatedIcon; @@ -77,7 +77,7 @@ class SongMenuItem extends FlxSpriteGroup public var weekNumbers:Array = []; - var impactThing:FunkinSprite; + // var impactThing:FunkinSprite; public var sparkle:FlxSprite; @@ -87,11 +87,7 @@ class SongMenuItem extends FlxSpriteGroup { super(x, y); - capsule = new FlxSprite(); - capsule.frames = Paths.getSparrowAtlas('freeplay/freeplayCapsule/capsule/freeplayCapsule'); - capsule.animation.addByPrefix('selected', 'mp3 capsule w backing0', 24); - capsule.animation.addByPrefix('unselected', 'mp3 capsule w backing NOT SELECTED', 24); - // capsule.animation + capsule = new CapsuleSprite(0xFF87B5CB, 0xFF505BA9, 0xFF53B1EA); add(capsule); bpmText = new FlxSprite(144, 87).loadGraphic(Paths.image('freeplay/freeplayCapsule/bpmtext')); @@ -371,11 +367,11 @@ class SongMenuItem extends FlxSpriteGroup // diffRatingSprite.visible = false; } - var evilTrail:FlxTrail; + //var evilTrail:FlxTrail; public function fadeAnim():Void { - impactThing = new FunkinSprite(0, 0); + /*impactThing = new FunkinSprite(0, 0); impactThing.frames = capsule.frames; impactThing.frame = capsule.frame; impactThing.updateHitbox(); @@ -414,12 +410,28 @@ class SongMenuItem extends FlxSpriteGroup evilTrail.color = 0xFFFF58B4; case PERFECT_GOLD: evilTrail.color = 0xFFFFB619; - } + }*/ } public function getTrailColor():FlxColor { - return evilTrail.color; + var trailColor:FlxColor = FlxColor.WHITE; + switch (ranking.rank) + { + case SHIT: + trailColor = 0xFF6044FF; + case GOOD: + trailColor = 0xFFEF8764; + case GREAT: + trailColor = 0xFFEAF6FF; + case EXCELLENT: + trailColor = 0xFFFDCB42; + case PERFECT: + trailColor = 0xFFFF58B4; + case PERFECT_GOLD: + trailColor = 0xFFFFB619; + } + return trailColor; } function updateDifficultyRating(newRating:Int):Void @@ -467,7 +479,7 @@ class SongMenuItem extends FlxSpriteGroup function set_hsvShader(value:HSVShader):HSVShader { this.hsvShader = value; - capsule.shader = hsvShader; + capsule.capsule.shader = hsvShader; songText.shader = hsvShader; return value; @@ -511,9 +523,7 @@ class SongMenuItem extends FlxSpriteGroup // capsule.frames = Paths.getSparrowAtlas(styleData == null ? 'freeplay/freeplayCapsule/capsule/freeplayCapsule' : styleData.getCapsuleAssetKey()); thank u luv u if (styleData != null) { - capsule.frames = Paths.getSparrowAtlas(styleData.getCapsuleAssetKey()); - capsule.animation.addByPrefix('selected', 'mp3 capsule w backing0', 24); - capsule.animation.addByPrefix('unselected', 'mp3 capsule w backing NOT SELECTED', 24); + capsule.reapplyColors(styleData.getCapsuleBGcolor(), styleData.getCapsuleBGdeselectedColor(),styleData.getCapsuleGlowColor()); songText.applyStyle(styleData); } @@ -603,7 +613,7 @@ class SongMenuItem extends FlxSpriteGroup override function update(elapsed:Float):Void { - if (impactThing != null) impactThing.angle = capsule.angle; + //if (impactThing != null) impactThing.angle = capsule.angle; // if (FlxG.keys.justPressed.I) // { @@ -702,8 +712,10 @@ class SongMenuItem extends FlxSpriteGroup grayscaleShader.setAmount(this.selected ? 0 : 0.8); songText.alpha = this.selected ? 1 : 0.6; songText.blurredText.visible = this.selected ? true : false; - capsule.offset.x = this.selected ? 0 : -5; - capsule.animation.play(this.selected ? "selected" : "unselected"); + if(this.selected) + capsule.select(); + else + capsule.deselect(); ranking.alpha = this.selected ? 1 : 0.7; favIcon.alpha = this.selected ? 1 : 0.6; favIconBlurred.alpha = this.selected ? 1 : 0; @@ -715,6 +727,71 @@ class SongMenuItem extends FlxSpriteGroup } } +//TODO: return eviltrail and impactthing stuff +class CapsuleSprite extends FlxSpriteGroup{ + public var bg:FlxSprite; + public var capsule:FlxSprite; + public var glow:FlxSprite; + + var bgColor = 0xFF87B5CB; + var bgColorDeselected = 0xFF505BA9; + + var selected = false; + + public function select(){ + glow.offset.x = 0; + glow.animation.play("selected"); + capsule.animation.resume(); + bg.makeGraphic(400, 70, bgColor); + selected = true; + } + + public function deselect(){ + glow.offset.x = -5; + glow.animation.play("unselected"); + capsule.animation.pause(); + bg.makeGraphic(400, 70, bgColorDeselected); + selected = false; + } + + public function reapplyColors(bgColor, bgColorDeselected, glowColor){ + this.bgColor = bgColor; + this.bgColorDeselected = bgColorDeselected; + glow.color = glowColor; + + //reapply colors + if(selected) + select(); + else + deselect(); + + } + + + override public function new(bgColor,bgColorDeselected,glowColor){ + super(x,y); + + this.bgColor = bgColor; + this.bgColorDeselected = bgColorDeselected; + + bg = new FlxSprite(104, 23).makeGraphic(400, 70, bgColor); + add(bg); + + capsule = new FlxSprite(49,13); + capsule.frames = Paths.getSparrowAtlas('freeplay/freeplayCapsule/capsule/capsule'); + capsule.animation.addByPrefix('idle', 'capsule', 24); + capsule.animation.play('idle',true); + add(capsule); + + glow = new FlxSprite(0, 0); + glow.frames = Paths.getSparrowAtlas('freeplay/freeplayCapsule/capsule/capsuleGlow'); + glow.animation.addByPrefix('selected', 'selected', 24); + glow.animation.addByPrefix('unselected', 'not selected', 24); + glow.color = glowColor; + add(glow); + } +} + class FreeplayRank extends FlxSprite { public var rank(default, set):Null = null; From 56a6500562e852b3a19a13c717b1e6cf0d0fe883 Mon Sep 17 00:00:00 2001 From: 7oltan <87986834+7oltan@users.noreply.github.com> Date: Tue, 24 Sep 2024 21:19:29 +0300 Subject: [PATCH 2/2] removed old capsule assests --- assets | 2 +- .../data/freeplay/style/FreeplayStyleData.hx | 7 +-- source/funkin/ui/freeplay/FreeplayStyle.hx | 9 ---- source/funkin/ui/freeplay/SongMenuItem.hx | 43 +++---------------- 4 files changed, 8 insertions(+), 53 deletions(-) diff --git a/assets b/assets index 7ac14b35a3..5a184e23e7 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 7ac14b35a3c7e1898bbcd1107e0d7d694ed99d30 +Subproject commit 5a184e23e70a1f089085c04261200d0f71888ca7 diff --git a/source/funkin/data/freeplay/style/FreeplayStyleData.hx b/source/funkin/data/freeplay/style/FreeplayStyleData.hx index c4815ce4d0..73b481f47d 100644 --- a/source/funkin/data/freeplay/style/FreeplayStyleData.hx +++ b/source/funkin/data/freeplay/style/FreeplayStyleData.hx @@ -28,12 +28,7 @@ typedef FreeplayStyleData = * Asset key for the numbers shown at the top right of the screen. */ public var numbersAsset:String; - - /** - * Asset key for the freeplay capsules. - */ - public var capsuleAsset:String; - + /** * Color data for the capsule text outline. * the order of this array goes as follows: [DESELECTED, SELECTED] diff --git a/source/funkin/ui/freeplay/FreeplayStyle.hx b/source/funkin/ui/freeplay/FreeplayStyle.hx index 6d305b2108..94a4167c07 100644 --- a/source/funkin/ui/freeplay/FreeplayStyle.hx +++ b/source/funkin/ui/freeplay/FreeplayStyle.hx @@ -60,15 +60,6 @@ class FreeplayStyle implements IRegistryEntry return _data.selectorAsset; } - /** - * Get the asset key for the number assets. - * @return The asset key - */ - public function getCapsuleAssetKey():String - { - return _data.capsuleAsset; - } - /** * Get the asset key for the capsule art. * @return The asset key diff --git a/source/funkin/ui/freeplay/SongMenuItem.hx b/source/funkin/ui/freeplay/SongMenuItem.hx index cd5ddfd38a..49a71baae5 100644 --- a/source/funkin/ui/freeplay/SongMenuItem.hx +++ b/source/funkin/ui/freeplay/SongMenuItem.hx @@ -77,8 +77,6 @@ class SongMenuItem extends FlxSpriteGroup public var weekNumbers:Array = []; - // var impactThing:FunkinSprite; - public var sparkle:FlxSprite; var sparkleTimer:FlxTimer; @@ -367,24 +365,11 @@ class SongMenuItem extends FlxSpriteGroup // diffRatingSprite.visible = false; } - //var evilTrail:FlxTrail; + var evilTrail:FlxTrail; public function fadeAnim():Void { - /*impactThing = new FunkinSprite(0, 0); - impactThing.frames = capsule.frames; - impactThing.frame = capsule.frame; - impactThing.updateHitbox(); - // impactThing.x = capsule.x; - // impactThing.y = capsule.y; - // picoFade.stamp(this, 0, 0); - impactThing.alpha = 0; - impactThing.zIndex = capsule.zIndex - 3; - add(impactThing); - FlxTween.tween(impactThing.scale, {x: 2.5, y: 2.5}, 0.5); - // FlxTween.tween(impactThing, {alpha: 0}, 0.5); - - evilTrail = new FlxTrail(impactThing, null, 15, 2, 0.01, 0.069); + evilTrail = new FlxTrail(capsule.capsule, null, 15, 2, 0.01, 0.069); evilTrail.blend = BlendMode.ADD; evilTrail.zIndex = capsule.zIndex - 5; FlxTween.tween(evilTrail, {alpha: 0}, 0.6, @@ -410,28 +395,12 @@ class SongMenuItem extends FlxSpriteGroup evilTrail.color = 0xFFFF58B4; case PERFECT_GOLD: evilTrail.color = 0xFFFFB619; - }*/ + } } public function getTrailColor():FlxColor { - var trailColor:FlxColor = FlxColor.WHITE; - switch (ranking.rank) - { - case SHIT: - trailColor = 0xFF6044FF; - case GOOD: - trailColor = 0xFFEF8764; - case GREAT: - trailColor = 0xFFEAF6FF; - case EXCELLENT: - trailColor = 0xFFFDCB42; - case PERFECT: - trailColor = 0xFFFF58B4; - case PERFECT_GOLD: - trailColor = 0xFFFFB619; - } - return trailColor; + return evilTrail.color; } function updateDifficultyRating(newRating:Int):Void @@ -480,6 +449,7 @@ class SongMenuItem extends FlxSpriteGroup { this.hsvShader = value; capsule.capsule.shader = hsvShader; + capsule.glow.shader = hsvShader; songText.shader = hsvShader; return value; @@ -613,7 +583,6 @@ class SongMenuItem extends FlxSpriteGroup override function update(elapsed:Float):Void { - //if (impactThing != null) impactThing.angle = capsule.angle; // if (FlxG.keys.justPressed.I) // { @@ -727,7 +696,7 @@ class SongMenuItem extends FlxSpriteGroup } } -//TODO: return eviltrail and impactthing stuff + class CapsuleSprite extends FlxSpriteGroup{ public var bg:FlxSprite; public var capsule:FlxSprite;