Skip to content

Commit 1af6931

Browse files
committed
copy fields booleans for strums and notes
1 parent 650c0f4 commit 1af6931

File tree

2 files changed

+65
-34
lines changed

2 files changed

+65
-34
lines changed

source/funkin/game/Note.hx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ class Note extends FlxSprite
7575
public var scrollSpeed:Null<Float> = null;
7676
public var noteAngle:Null<Float> = null;
7777

78+
public var copyStrumAngle:Bool = true;
79+
public var updateNotesPosX:Bool = true;
80+
public var updateNotesPosY:Bool = true;
81+
public var updateFlipY:Bool = true;
82+
7883
public var noteType(get, null):String;
7984

8085
@:dox(hide) public var __strumCameras:Array<FlxCamera> = null;
@@ -215,7 +220,7 @@ class Note extends FlxSprite
215220

216221
override function drawComplex(camera:FlxCamera) {
217222
var downscrollCam = (camera is HudCamera ? cast(camera, HudCamera).downscroll : false);
218-
flipY = (isSustainNote && flipSustain) && (downscrollCam != (__strum != null && __strum.getScrollSpeed(this) < 0));
223+
if (updateFlipY) flipY = (isSustainNote && flipSustain) && (downscrollCam != (__strum != null && __strum.getScrollSpeed(this) < 0));
219224
if (downscrollCam) {
220225
frameOffset.y += __notePosFrameOffset.y * 2;
221226
super.drawComplex(camera);

source/funkin/game/Strum.hx

Lines changed: 59 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ class Strum extends FlxSprite {
1919

2020
public var lastDrawCameras(default, null):Array<FlxCamera> = [];
2121

22+
// Copy fields
23+
public var copyStrumCamera:Bool = true;
24+
public var copyStrumScrollX:Bool = true;
25+
public var copyStrumScrollY:Bool = true;
26+
public var copyStrumAngle:Bool = true;
27+
public var updateNotesPosX:Bool = true;
28+
public var updateNotesPosY:Bool = true;
29+
public var extraCopyFields(default, set):Array<String> = [];
30+
31+
private inline function set_extraCopyFields(val:Array<String>)
32+
return extraCopyFields = val == null ? [] : val;
33+
2234
public var getPressed:StrumLine->Bool = null;
2335
public var getJustPressed:StrumLine->Bool = null;
2436
public var getJustReleased:StrumLine->Bool = null;
@@ -84,47 +96,61 @@ class Strum extends FlxSprite {
8496
public function updateNotePosition(daNote:Note) {
8597
if (!daNote.exists) return;
8698

87-
daNote.__strumCameras = lastDrawCameras;
8899
daNote.__strum = this;
89-
daNote.scrollFactor.set(scrollFactor.x, scrollFactor.y);
90-
daNote.__noteAngle = getNotesAngle(daNote);
91-
daNote.angle = daNote.isSustainNote ? daNote.__noteAngle : angle;
100+
if (copyStrumCamera) daNote.__strumCameras = lastDrawCameras;
101+
if (copyStrumScrollX) daNote.scrollFactor.x = scrollFactor.x;
102+
if (copyStrumScrollY) daNote.scrollFactor.y = scrollFactor.y;
103+
if (copyStrumAngle && daNote.copyStrumAngle) {
104+
daNote.__noteAngle = getNotesAngle(daNote);
105+
daNote.angle = daNote.isSustainNote ? daNote.__noteAngle : angle;
106+
}
92107

93108
updateNotePos(daNote);
109+
for (field in extraCopyFields)
110+
Reflect.setProperty(daNote, field, Reflect.getProperty(this, field));
94111
}
95112

96113
private inline function updateNotePos(daNote:Note) {
97-
if (daNote.strumRelativePos) {
98-
daNote.setPosition((this.width - daNote.width) / 2, (daNote.strumTime - Conductor.songPosition) * (0.45 * CoolUtil.quantize(getScrollSpeed(daNote), 100)));
99-
if (daNote.isSustainNote) daNote.y += N_WIDTHDIV2;
100-
} else {
101-
var offset = FlxPoint.get(0, (Conductor.songPosition - daNote.strumTime) * (0.45 * CoolUtil.quantize(getScrollSpeed(daNote), 100)));
102-
var realOffset = FlxPoint.get(0, 0);
103-
104-
if (daNote.isSustainNote) offset.y -= N_WIDTHDIV2;
105-
106-
if (Std.int(daNote.__noteAngle % 360) != 0) {
107-
var noteAngleCos = FlxMath.fastCos(daNote.__noteAngle / PIX180);
108-
var noteAngleSin = FlxMath.fastSin(daNote.__noteAngle / PIX180);
109-
110-
var aOffset:FlxPoint = FlxPoint.get(
111-
(daNote.origin.x / daNote.scale.x) - daNote.offset.x,
112-
(daNote.origin.y / daNote.scale.y) - daNote.offset.y
113-
);
114-
realOffset.x = -aOffset.x + (noteAngleCos * (offset.x + aOffset.x)) + (noteAngleSin * (offset.y + aOffset.y));
115-
realOffset.y = -aOffset.y + (noteAngleSin * (offset.x + aOffset.x)) + (noteAngleCos * (offset.y + aOffset.y));
116-
117-
aOffset.put();
114+
var shouldX = updateNotesPosX && daNote.updateNotesPosX;
115+
var shouldY = updateNotesPosY && daNote.updateNotesPosY;
116+
117+
if (shouldX || shouldY) {
118+
if (daNote.strumRelativePos) {
119+
if (shouldX) daNote.x = (this.width - daNote.width) / 2;
120+
if (shouldY) {
121+
daNote.y = (daNote.strumTime - Conductor.songPosition) * (0.45 * CoolUtil.quantize(getScrollSpeed(daNote), 100));
122+
if (daNote.isSustainNote) daNote.y += N_WIDTHDIV2;
123+
}
118124
} else {
119-
realOffset.x = offset.x;
120-
realOffset.y = offset.y;
125+
var offset = FlxPoint.get(0, (Conductor.songPosition - daNote.strumTime) * (0.45 * CoolUtil.quantize(getScrollSpeed(daNote), 100)));
126+
var realOffset = FlxPoint.get(0, 0);
127+
128+
if (daNote.isSustainNote) offset.y -= N_WIDTHDIV2;
129+
130+
if (Std.int(daNote.__noteAngle % 360) != 0) {
131+
var noteAngleCos = FlxMath.fastCos(daNote.__noteAngle / PIX180);
132+
var noteAngleSin = FlxMath.fastSin(daNote.__noteAngle / PIX180);
133+
134+
var aOffset:FlxPoint = FlxPoint.get(
135+
(daNote.origin.x / daNote.scale.x) - daNote.offset.x,
136+
(daNote.origin.y / daNote.scale.y) - daNote.offset.y
137+
);
138+
realOffset.x = -aOffset.x + (noteAngleCos * (offset.x + aOffset.x)) + (noteAngleSin * (offset.y + aOffset.y));
139+
realOffset.y = -aOffset.y + (noteAngleSin * (offset.x + aOffset.x)) + (noteAngleCos * (offset.y + aOffset.y));
140+
141+
aOffset.put();
142+
} else {
143+
realOffset.x = offset.x;
144+
realOffset.y = offset.y;
145+
}
146+
realOffset.y *= -1;
147+
148+
if (shouldX) daNote.x = x + realOffset.x;
149+
if (shouldY) daNote.y = y + realOffset.y;
150+
151+
offset.put();
152+
realOffset.put();
121153
}
122-
realOffset.y *= -1;
123-
124-
daNote.setPosition(x + realOffset.x, y + realOffset.y);
125-
126-
offset.put();
127-
realOffset.put();
128154
}
129155
}
130156

0 commit comments

Comments
 (0)