@@ -4,6 +4,12 @@ import backend.animation.PsychAnimationController;
44import shaders .RGBPalette ;
55import flixel .system .FlxAssets .FlxShader ;
66import objects .charting .ChartingStrumNote ;
7+ import flixel .FlxSprite ;
8+ import flixel .animation .FlxBaseAnimation ;
9+ import flixel .graphics .frames .FlxAtlasFrames ;
10+ import flixel .util .FlxColor ;
11+ import shaders .ColorSwap .ColorSwap ;
12+ import objects .NoteObject ;
713
814typedef RGB = {
915 r : Null <Int >,
@@ -28,14 +34,13 @@ typedef NoteSplashConfig = {
2834 rgb : Array <Null <RGB >>
2935}
3036
31- class NoteSplash extends FlxSprite
37+ class NoteSplash extends NoteObject
3238{
3339 public var rgbShader : PixelSplashShaderRef ;
3440 public var texture : String ;
3541 public var config (default , set ): NoteSplashConfig ;
3642 public var babyArrow : StrumNote ;
3743 public var babyArrowCharting : ChartingStrumNote ;
38- public var noteData : Int = 0 ;
3944
4045 public var copyX : Bool = true ;
4146 public var copyY : Bool = true ;
@@ -160,10 +165,37 @@ class NoteSplash extends FlxSprite
160165 }
161166 }
162167
168+ // Get current key count from PlayState or default to 4
169+ var keyCount : Int = 4 ; // Default fallback
170+ if (PlayState .instance != null && PlayState .instance .playfields != null && PlayState .instance .playfields .members .length > 0 ) {
171+ keyCount = PlayState .instance .playfields .members [0 ].keyCount ;
172+ } else if (PlayState .mania >= 0 && PlayState .mania < Note .ammo .length ) {
173+ keyCount = Note .ammo [PlayState .mania ];
174+ }
175+
176+ // Get the appropriate color array for the current key count
177+ var colArray : Array <String > = [];
178+ if (PlayState .mania >= 0 && PlayState .mania < Note .ammo .length && Note .keysShit .exists (PlayState .mania )) {
179+ var keyData = Note .keysShit .get (PlayState .mania );
180+ if (keyData .exists (" letters" ) && keyData .get (" letters" ) is Array ) {
181+ var letters : Array <String > = cast keyData .get (" letters" );
182+ colArray = letters .map (letter -> letter .toLowerCase ()); // Convert to lowercase for consistency
183+ }
184+ }
185+
186+ // Fallback to default if no proper key data found
187+ if (colArray .length == 0 ) {
188+ colArray = Note .colArray .copy ();
189+ // Extend if we need more keys
190+ while (colArray .length < keyCount ) {
191+ colArray .push (' key ${colArray .length }' );
192+ }
193+ }
194+
163195 var failedToFind : Bool = false ;
164196 while (true )
165197 {
166- for (v in Note . colArray )
198+ for (v in colArray )
167199 {
168200 if (! checkForAnim (' $anim $v ${maxAnims + 1 }' ))
169201 {
@@ -177,9 +209,9 @@ class NoteSplash extends FlxSprite
177209
178210 for (animNum in 0 ... maxAnims )
179211 {
180- for (i => col in Note . colArray )
212+ for (i => col in colArray )
181213 {
182- var data : Int = i % Note . colArray .length + (animNum * Note . colArray .length );
214+ var data : Int = i % colArray .length + (animNum * colArray .length );
183215 var name : String = animNum > 0 ? ' $col ' + (animNum + 1 ) : col ;
184216 var offset : Array <Float > = offsets [FlxMath .wrap (data , 0 , Std .int (offsets .length - 1 ))];
185217 addAnimationToConfig (tempConfig , 1 , name , ' $anim $col ${animNum + 1 }' , fps , offset , [], data );
@@ -217,16 +249,40 @@ class NoteSplash extends FlxSprite
217249 if (note != null )
218250 noteData = note .noteData ;
219251
252+ // Get current key count for proper noteData calculation
253+ var keyCount : Int = 4 ; // Default fallback
254+ var colArray : Array <String > = Note .colArray .copy ();
255+
256+ if (PlayState .instance != null && PlayState .instance .playfields != null && PlayState .instance .playfields .members .length > 0 ) {
257+ keyCount = PlayState .instance .playfields .members [0 ].keyCount ;
258+ } else if (PlayState .mania >= 0 && PlayState .mania < Note .ammo .length ) {
259+ keyCount = Note .ammo [PlayState .mania ];
260+ }
261+
262+ // Get the appropriate color array for the current key count
263+ if (PlayState .mania >= 0 && PlayState .mania < Note .ammo .length && Note .keysShit .exists (PlayState .mania )) {
264+ var keyData = Note .keysShit .get (PlayState .mania );
265+ if (keyData .exists (" letters" ) && keyData .get (" letters" ) is Array ) {
266+ var letters : Array <String > = cast keyData .get (" letters" );
267+ colArray = letters .map (letter -> letter .toLowerCase ());
268+ }
269+ }
270+
271+ // Extend color array if needed
272+ while (colArray .length < keyCount ) {
273+ colArray .push (' key ${colArray .length }' );
274+ }
275+
220276 if (randomize && maxAnims > 1 )
221- noteData = noteData % Note . colArray .length + (FlxG .random .int (0 , maxAnims - 1 ) * Note . colArray .length );
277+ noteData = noteData % colArray .length + (FlxG .random .int (0 , maxAnims - 1 ) * colArray .length );
222278
223279 this .noteData = noteData ;
224280 var anim : String = playDefaultAnim ();
225281
226282 var tempShader : RGBPalette = null ;
227283 if (config .allowRGB )
228284 {
229- Note .initializeGlobalRGBShader (noteData % Note . colArray .length );
285+ Note .initializeGlobalRGBShader (noteData % colArray .length );
230286 if (inEditor || (note == null || note .noteSplashData .useRGBShader ) && (PlayState .SONG == null || ! PlayState .SONG .disableNoteRGB ))
231287 {
232288 tempShader = new RGBPalette ();
@@ -240,8 +296,17 @@ class NoteSplash extends FlxSprite
240296 {
241297 if (i > 2 ) break ;
242298
243- var arr : Array <FlxColor > = ClientPrefs .data .arrowRGB [noteData % Note .colArray .length ];
244- if (PlayState .isPixelStage ) arr = ClientPrefs .data .arrowRGBPixel [noteData % Note .colArray .length ];
299+ var rgbIndex = noteData % colArray .length ;
300+ var arr : Array <FlxColor > = null ;
301+ // Ensure we don't go out of bounds for RGB arrays
302+ if (rgbIndex < ClientPrefs .data .arrowRGB .length ) {
303+ arr = ClientPrefs .data .arrowRGB [rgbIndex ];
304+ if (PlayState .isPixelStage && rgbIndex < ClientPrefs .data .arrowRGBPixel .length )
305+ arr = ClientPrefs .data .arrowRGBPixel [rgbIndex ];
306+ } else {
307+ // Fallback to default RGB values for extended keys
308+ arr = [FlxColor .WHITE , FlxColor .WHITE , FlxColor .WHITE ];
309+ }
245310
246311 var rgb = colors [i ];
247312 if (rgb == null )
0 commit comments