Skip to content

Commit 9cc8fc2

Browse files
committed
e
1 parent be140dd commit 9cc8fc2

File tree

5 files changed

+116
-44
lines changed

5 files changed

+116
-44
lines changed

source/archipelago/CustomAPLogic.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,8 @@ class APHScriptProcessor {
11961196
return;
11971197
}
11981198

1199+
trace('Executing AP script: ${scriptPath} for mod: ${modInfo.name}');
1200+
11991201
var scriptContent = File.getContent(scriptPath);
12001202
var parser = new Parser();
12011203
var interpreter = new Interp();

source/objects/NoteSplash.hx

Lines changed: 74 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import backend.animation.PsychAnimationController;
44
import shaders.RGBPalette;
55
import flixel.system.FlxAssets.FlxShader;
66
import 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

814
typedef 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)

source/objects/playfields/NoteField.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ class NoteField extends FieldBase
278278

279279

280280
// draw notesplashes
281-
/*for (obj in field.grpNoteSplashes.members)
281+
for (obj in field.grpNoteSplashes.members)
282282
{
283283
if (!obj.exists || !obj.visible)
284284
continue;
@@ -290,7 +290,7 @@ class NoteField extends FieldBase
290290
object.zIndex += 0.5;
291291
lookupMap.set(obj, object);
292292
drawQueue.push(object);
293-
}*/
293+
}
294294

295295
// draw strumattachments
296296
for (obj in field.strumAttachments.members)

source/objects/playfields/PlayField.hx

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,14 @@ class PlayField extends FlxTypedGroup<FlxBasic>
216216
strumAttachments.visible = false;
217217
add(strumAttachments);
218218

219-
/*var splash:NoteSplash = new NoteSplash(100, 100, 0);
220-
splash.handleRendering = false;
221-
grpNoteSplashes.add(splash);
222-
grpNoteSplashes.visible = false; // so they dont get drawn
223-
splash.alpha = 0.0;*/
219+
// Pre-allocate a few note splashes for better performance
220+
for (i in 0...4) {
221+
var splash:NoteSplash = new NoteSplash();
222+
splash.handleRendering = false;
223+
splash.alpha = 0.0;
224+
splash.kill(); // Start them as killed objects in the pool
225+
grpNoteSplashes.add(splash);
226+
}
224227

225228
////
226229
noteField = new NoteField(this, modMgr);
@@ -916,33 +919,35 @@ class PlayField extends FlxTypedGroup<FlxBasic>
916919

917920
// spawns a notesplash w/ specified skin. optional note to derive the skin and colours from.
918921

919-
/*public function spawnSplash(note:Note, splashSkin:String){
920-
var skin:String;
921-
var hue:Float;
922-
var sat:Float;
923-
var brt:Float;
924-
925-
if (note != null) {
926-
skin = note.noteSplashTexture;
927-
hue = note.noteSplashHue;
928-
sat = note.noteSplashSat;
929-
brt = note.noteSplashBrt;
930-
}else{
931-
skin = splashSkin;
932-
hue = sat = brt = 0.0;
933-
934-
/*var hsb = ClientPrefs.arrowHSV[note.column % 4];
935-
hue = hsb[0] / 360;
936-
sat = hsb[1] / 100;
937-
brt = hsb[2] / 100;
938-
}
939-
922+
public function spawnSplash(note:Note, ?splashSkin:String):NoteSplash {
923+
if (note == null) return null;
924+
940925
var splash:NoteSplash = grpNoteSplashes.recycle(NoteSplash);
941-
splash.setupNoteSplash(0, 0, note.column, skin, hue, sat, brt, note);
926+
if (splash == null) {
927+
splash = new NoteSplash();
928+
grpNoteSplashes.add(splash);
929+
}
930+
931+
// Set position based on the strum/note position
932+
var strumX:Float = 0;
933+
var strumY:Float = 0;
934+
if (note.column < strumNotes.length) {
935+
var strum = strumNotes[note.column];
936+
if (strum != null) {
937+
strumX = strum.x;
938+
strumY = strum.y;
939+
}
940+
}
941+
942+
splash.spawnSplashNote(strumX, strumY, note.noteData, note);
942943
splash.handleRendering = false;
943-
grpNoteSplashes.add(splash);
944+
944945
return splash;
945-
}*/
946+
}
947+
948+
public function spawnNoteSplashOnNote(note:Note):NoteSplash {
949+
return spawnSplash(note);
950+
}
946951

947952
// spawns notes, deals w/ hold inputs, etc.
948953
override public function update(elapsed:Float){

source/states/PlayState.hx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8150,8 +8150,8 @@ class PlayState extends MusicBeatState
81508150
note.rating = daRating.name;
81518151
score = daRating.score;
81528152

8153-
//if(daRating.noteSplash && !note.noteSplashData.disabled)
8154-
//note.field.spawnNoteSplashOnNote(note);
8153+
if(daRating.noteSplash && !note.noteSplashData.disabled && !note.isSustainNote)
8154+
note.field.spawnNoteSplashOnNote(note);
81558155

81568156
if(!cpuControlled) {
81578157
comboManager.songScore += Math.ceil(score * MechanicManager.multiplier);
@@ -8330,8 +8330,8 @@ class PlayState extends MusicBeatState
83308330
note.rating = daRating.name;
83318331
score = daRating.score;
83328332

8333-
//if(daRating.noteSplash && !note.noteSplashData.disabled)
8334-
//note.field.spawnNoteSplashOnNote(note);
8333+
if(daRating.noteSplash && !note.noteSplashData.disabled && !note.isSustainNote)
8334+
note.field.spawnNoteSplashOnNote(note);
83358335

83368336
if(!cpuControlled) {
83378337
comboManager.songScore += score;

0 commit comments

Comments
 (0)