Skip to content

Commit 2fff41e

Browse files
committed
easier to edit charter notes (may be reverted)
1 parent faf24b4 commit 2fff41e

8 files changed

Lines changed: 208 additions & 68 deletions

File tree

source/funkin/editors/charter/Charter.hx

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,7 @@ class Charter extends UIState {
11141114
if (n.hovered || n.sustainDraggable) {
11151115
deletedNotes.push(n);
11161116
deleteSingleSelection(n, false);
1117+
UIState.playEditorSound(Flags.DEFAULT_CHARTER_NOTEDELETE_SOUND);
11171118

11181119
if (selection.contains(n)) selection.remove(n);
11191120
noteDeleteAnims.deleteNotes.push({
@@ -1188,7 +1189,6 @@ class Charter extends UIState {
11881189
if (selected == null) return selected;
11891190

11901191
if (selected is CharterNote) {
1191-
UIState.playEditorSound(Flags.DEFAULT_CHARTER_NOTEDELETE_SOUND);
11921192
var note:CharterNote = cast selected;
11931193
note.strumLineID = strumLines.members.indexOf(note.strumLine);
11941194
note.strumLine = null; // For static undos :D
@@ -1243,6 +1243,7 @@ class Charter extends UIState {
12431243
else member++;
12441244
}
12451245
}
1246+
UIState.playEditorSound(Flags.DEFAULT_CHARTER_NOTEDELETE_SOUND);
12461247
notesGroup.sortNotes();
12471248
notesGroup.autoSort = true;
12481249

@@ -1340,7 +1341,7 @@ class Charter extends UIState {
13401341
FlxG.state.openSubState(new CharterStrumlineScreen(strumLines.members.length, null, (_) -> {
13411342
if (_ != null) {
13421343
createStrumline(strumLines.members.length, _);
1343-
1344+
strumlineAddButton.button.setColorTransform(1, 1, 1, strumlineAddButton.button.alpha);
13441345
strumlineAddButton.textTweenColor.color = 0xFF00FF00;
13451346
strumlineAddButton.pressAnimation(true);
13461347
}
@@ -1443,7 +1444,8 @@ class Charter extends UIState {
14431444
noteTypeText.x = noteTopButton.x + noteTopButton.bWidth + 6;
14441445
noteTypeText.y = Std.int((noteTopButton.bHeight - noteTypeText.height) / 2);
14451446
}
1446-
noteTypeText.text = '($noteType) ' + (noteTypes[noteType-1] == null ? translate("noteTypes.default") : noteTypes[noteType-1]);
1447+
var targetNoteText = '($noteType) ' + (noteTypes[noteType-1] == null ? translate("noteTypes.default") : noteTypes[noteType-1]);
1448+
if (noteTypeText.text != targetNoteText) noteTypeText.text = targetNoteText;
14471449

14481450
super.update(elapsed);
14491451

@@ -1486,22 +1488,30 @@ class Charter extends UIState {
14861488
}
14871489

14881490
var curChange = Conductor.curChange;
1489-
songPosInfo.text = [
1490-
// no need to translate the time text since it has no text only numbers
1491-
'${CoolUtil.timeToStr(Conductor.songPosition)} / ${CoolUtil.timeToStr(songLength)}',
1492-
SONGPOSINFO_STEP.format([curStep]),
1493-
SONGPOSINFO_BEAT.format([curBeat]),
1494-
SONGPOSINFO_MEASURE.format([curMeasure]),
1495-
SONGPOSINFO_BPM.format([(curChange != null && curChange.continuous && curChange.endSongTime > songPos) ? FlxMath.roundDecimal(Conductor.bpm, 3) : Conductor.bpm]),
1496-
SONGPOSINFO_TIMESIGNATURE.format([Conductor.beatsPerMeasure, Conductor.denominator])
1497-
].join("\n");
1491+
var targetText = '${CoolUtil.timeToStr(Conductor.songPosition)} / ${CoolUtil.timeToStr(songLength)}'
1492+
+'\n'+SONGPOSINFO_STEP.format([curStep])
1493+
+'\n'+SONGPOSINFO_BEAT.format([curBeat])
1494+
+'\n'+SONGPOSINFO_MEASURE.format([curMeasure])
1495+
+'\n'+SONGPOSINFO_BPM.format([(curChange != null && curChange.continuous && curChange.endSongTime > songPos) ? FlxMath.roundDecimal(Conductor.bpm, 3) : Conductor.bpm])
1496+
+'\n'+SONGPOSINFO_TIMESIGNATURE.format([Conductor.beatsPerMeasure, Conductor.denominator]);
1497+
1498+
if (songPosInfo.text != targetText) songPosInfo.text = targetText;
14981499

14991500
if (charterCamera.zoom != (charterCamera.zoom = lerp(charterCamera.zoom, __camZoom, __firstFrame ? 1 : 0.125)))
15001501
updateDisplaySprites();
15011502

15021503
if (strumLines != null)
15031504
strumlineLockButton.button.animation.play(strumLines.draggable ? "1" : "0", true);
15041505

1506+
if (strumLines.members.length <= 0) {
1507+
final glow = (Math.sin(FlxG.game.ticks * 0.004) + 1) * 0.5;
1508+
strumlineAddButton.button.setColorTransform(
1509+
1 - (glow * 0.5), 1 - (glow * 0.5), 1 - (glow * 0.5),
1510+
strumlineAddButton.button.alpha,
1511+
Std.int(glow * 255), Std.int(glow * 255), Std.int(glow * 255), 0
1512+
);
1513+
}
1514+
15051515
WindowUtils.prefix = undos.unsaved ? Flags.UNDO_PREFIX : "";
15061516
SaveWarning.showWarning = undos.unsaved;
15071517

@@ -1740,6 +1750,7 @@ class Charter extends UIState {
17401750
if (selection == null || selection.length == 0) return;
17411751
selection.loop((n:CharterNote) -> {
17421752
noteDeleteAnims.deleteNotes.push({note: n, time: noteDeleteAnims.deleteTime});
1753+
@:privateAccess CharterNote.callScriptOnNote('onCharterNoteDelete', n);
17431754
});
17441755
selection = deleteSelection(selection, true);
17451756
}
@@ -1754,6 +1765,7 @@ class Charter extends UIState {
17541765
if (oldNote != null && oldNote.step == note.step && oldNote.strumLineID == note.strumLineID && oldNote.id == note.id) {
17551766
noteDeleteAnims.deleteNotes.push({note: oldNote, time: noteDeleteAnims.deleteTime});
17561767
toDelete.push(oldNote);
1768+
@:privateAccess CharterNote.callScriptOnNote('onCharterNoteDelete', oldNote);
17571769
}
17581770
oldNote = note;
17591771
}

source/funkin/editors/charter/CharterBackdropGroup.hx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,21 +139,24 @@ class NotesDrawGroup extends FlxFastTypedGroup<CharterNote> {
139139
if (note != null && note.exists && note.visible) {
140140
if (note.snappedToGrid) note.x = (note.strumLine != null ? note.strumLine.x : 0) + (note.id % (note.strumLine != null ? note.strumLine.keyCount : 4)) * 40;
141141
note.drawMembers();
142+
/*
142143
}
143144
}
144145
145146
i = 0; note = null;
146147
while (i < length) {
147148
note = members[i++];
148-
if (note != null && note.exists && note.visible)
149+
if (note != null && note.exists && note.visible) {*/
149150
note.drawSuper();
151+
/* }
150152
}
151153
152154
i = 0; note = null;
153155
while (i < length) {
154156
note = members[i++];
155-
if (note != null && note.exists && note.visible)
157+
if (note != null && note.exists && note.visible) {*/
156158
note.drawNoteTypeText();
159+
}
157160
}
158161

159162
FlxCamera._defaultCameras = oldDefaultCameras;

source/funkin/editors/charter/CharterDeleteAnim.hx

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,50 @@ class CharterDeleteAnim extends CharterNote {
5454
garbageCircle.alpha = __garbageAlpha*.6;
5555
}
5656

57+
static var __stupidScriptParamArray:Array<CharterNote> = [];
58+
59+
static function callScriptOnNotes(event:String, note1:CharterNote, note2:CharterNote) {
60+
if (Charter.instance != null) {
61+
__stupidScriptParamArray[0] = note1;
62+
__stupidScriptParamArray[1] = note2;
63+
Charter.instance.stateScripts.call(event, __stupidScriptParamArray);
64+
}
65+
}
66+
5767
public override function draw() @:privateAccess {
68+
// kill me
69+
final __lastFrame:flixel.graphics.frames.FlxFrame = this.frame;
70+
final __lastSX:Float = this.scale.x;
71+
final __lastSY:Float = this.scale.y;
72+
final __lastW:Float = this.width;
73+
final __lastH:Float = this.height;
74+
final __lastOX:Float = this.offset.x;
75+
final __lastOY:Float = this.offset.y;
76+
final __lastRX:Float = this.origin.x;
77+
final __lastRY:Float = this.origin.y;
78+
final __lastFX:Float = this.frameOffset.x;
79+
final __lastFY:Float = this.frameOffset.y;
80+
final __lastColor:flixel.util.FlxColor = this.color;
81+
5882
for (deleteData in deleteNotes) {
5983
y = deleteData.note.y + (deleteData.time>deleteTime*.5 ? (deleteData.time/deleteTime)*FlxG.random.float(-1.1, 1.1) : 0); // lunar when no shake :((
6084
x = deleteData.note.x + (deleteData.time>deleteTime*.5 ? (deleteData.time/deleteTime)*FlxG.random.float(-1.1, 1.1) : 0); // lunar when no shake :((
61-
angle = deleteData.note.angle; alpha = 1;
62-
animation.curAnim.curFrame = 3;
85+
angle = 0;
86+
setSize(deleteData.note.width, deleteData.note.height);
87+
scale.set(deleteData.note.scale.x, deleteData.note.scale.y);
88+
offset.set(deleteData.note.offset.x, deleteData.note.offset.y);
89+
origin.set(deleteData.note.origin.x, deleteData.note.origin.y);
90+
frameOffset.set(deleteData.note.frameOffset.x, deleteData.note.frameOffset.y);
91+
92+
if (!deleteData.note.noDefaultAnims) {
93+
frame = __lastFrame;
94+
angle = deleteData.note.angle;
95+
animation.curAnim.curFrame = 3;
96+
color = __lastColor;
97+
} else {
98+
frame = deleteData.note.frame;
99+
}
100+
alpha = 1;
63101

64102
sustainSpr.scale.set(10, (40 * deleteData.note.susLength) + (height/2));
65103
sustainSpr.updateHitbox(); sustainSpr.follow(this, 15, 20);
@@ -77,9 +115,19 @@ class CharterDeleteAnim extends CharterNote {
77115
member.alpha *= mult;
78116
typeAlpha *= mult;
79117

118+
callScriptOnNotes('onCharterNoteDeleteUpdate', deleteData.note, this);
119+
80120
super.draw();
81121
}
82122

123+
this.frame = __lastFrame;
124+
this.scale.set(__lastSX, __lastSY);
125+
this.setSize(__lastW, __lastH);
126+
this.offset.set(__lastOX, __lastOY);
127+
this.origin.set(__lastRX, __lastRY);
128+
this.frameOffset.set(__lastFX, __lastFY);
129+
this.color = __lastColor;
130+
83131
if (garbageIcon.alpha > 0) garbageIcon.draw();
84132
if (garbageCircle.alpha > 0) garbageCircle.draw();
85133
}

source/funkin/editors/charter/CharterEventAdd.hx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,29 @@ class CharterEventAdd extends UISliceSprite {
6363
curCharterEvent = null;
6464
this.step = step;
6565
this.y = (step * 40) - (bHeight / 2);
66-
text.text = TU.translate("charter.addEvent");
6766
framesOffset = 0; bWidth = 37 + Math.ceil(text.width);
68-
x = (global != Options.charterSwapEventSides) ? Charter.instance.strumLines.members[Charter.instance.strumLines.members.length-1].x + (40*Charter.instance.strumLines.members[Charter.instance.strumLines.members.length-1].keyCount) : -(bWidth);
69-
sideText.text = TU.translate("charter.eventType-" + (global ? "global" : "local"));
67+
updateStuff(global, false);
7068
}
7169

7270
public function updateEdit(event:CharterEvent) {
7371
if (FlxG.state.subState != null) return;
7472
curCharterEvent = event;
7573
this.y = event.y;
76-
text.text = TU.translate("charter.editEvent");
7774
framesOffset = 9; bWidth = 27 + Math.ceil(text.width) + event.bWidth;
78-
x = (event.global != Options.charterSwapEventSides) ? Charter.instance.strumLines.members[Charter.instance.strumLines.members.length-1].x + (40*Charter.instance.strumLines.members[Charter.instance.strumLines.members.length-1].keyCount) : -(bWidth);
79-
sideText.text = TU.translate("charter.eventType-" + (event.global ? "global" : "local"));
75+
updateStuff(event.global, true);
76+
}
77+
78+
private function updateStuff(global:Bool = false, edit:Bool = false) {
79+
final lastStrumline = Charter.instance.strumLines.members[Charter.instance.strumLines.members.length-1];
80+
if (lastStrumline != null)
81+
x = (global != Options.charterSwapEventSides) ? lastStrumline.x + (40*lastStrumline.keyCount) : -(bWidth);
82+
else
83+
x = (global != Options.charterSwapEventSides) ? 0 : -(bWidth);
84+
85+
final target = TU.translate("charter.eventType-" + (global ? "global" : "local"));
86+
if (sideText.text != target) sideText.text = target;
87+
88+
final targetButtonText = TU.translate("charter." + (edit ? "edit" : "add") + "Event");
89+
if (text.text != targetButtonText) text.text = targetButtonText;
8090
}
8191
}

source/funkin/editors/charter/CharterNote.hx

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class CharterNote extends UISprite implements ICharterSelectable {
2020
0xFFF9393F
2121
];
2222

23+
public var noDefaultAnims:Bool = false;
2324
public var sustainSpr:UISprite;
2425
public var tempSusLength:Float = 0;
2526
public var sustainDraggable:Bool = false;
@@ -28,8 +29,17 @@ class CharterNote extends UISprite implements ICharterSelectable {
2829

2930
public var selected:Bool = false;
3031
public var draggable:Bool = true;
32+
public var extra:Map<String, Dynamic> = [];
3133

3234
static var noteTypeTexts:Array<UIText> = [];
35+
static var __stupidScriptParamArray:Array<CharterNote> = [];
36+
37+
static function callScriptOnNote(event:String, note:CharterNote) {
38+
if (Charter.instance != null) {
39+
__stupidScriptParamArray[0] = note;
40+
Charter.instance.stateScripts.call(event, __stupidScriptParamArray);
41+
}
42+
}
3343

3444
public function new() {
3545
super();
@@ -49,6 +59,8 @@ class CharterNote extends UISprite implements ICharterSelectable {
4959

5060
cursor = sustainSpr.cursor = CLICK;
5161
moves = false;
62+
63+
callScriptOnNote('onCharterNoteCreation', this);
5264
}
5365

5466
public override function updateButtonHandler() {
@@ -100,6 +112,11 @@ class CharterNote extends UISprite implements ICharterSelectable {
100112

101113
if (angleTween != null) angleTween.cancel();
102114

115+
if (noDefaultAnims) {
116+
// angle = 0;
117+
return callScriptOnNote('onCharterNoteUpdatePos', this);
118+
}
119+
103120
var destAngle:Float = switch(animation.curAnim.curFrame = (id % 4)) {
104121
case 0: 270;
105122
case 1: 180;
@@ -112,10 +129,10 @@ class CharterNote extends UISprite implements ICharterSelectable {
112129

113130
if (!__doAnim) {
114131
angle = destAngle;
115-
return;
132+
return callScriptOnNote('onCharterNoteUpdatePos', this);
116133
}
117134

118-
if (angle == destAngle) return;
135+
if (angle == destAngle) return callScriptOnNote('onCharterNoteUpdatePos', this);
119136

120137
if(angleTween != null)
121138
angleTween.cancel();
@@ -125,20 +142,24 @@ class CharterNote extends UISprite implements ICharterSelectable {
125142
angleTween = FlxTween.angle(this, angle, destAngle, (2/3)/__animSpeed, {ease: function(t) {
126143
return ((Math.sin(t * Math.PI) * 0.35) * 3 * t * Math.sqrt(1 - t)) + t;
127144
}});
145+
146+
callScriptOnNote('onCharterNoteUpdatePos', this);
128147
}
129148

130149
public override function kill() {
131-
if (angleTween != null) {
132-
angleTween.cancel();
133-
angleTween = null;
134-
angle = switch(animation.curAnim.curFrame = (id % 4)) {
135-
case 0: 270;
136-
case 1: 180;
137-
case 2: 0;
138-
case 3: 90;
139-
default: 0; // how is that even possible
140-
};
141-
__doAnim = false;
150+
if (!noDefaultAnims) {
151+
if (angleTween != null) {
152+
angleTween.cancel();
153+
angleTween = null;
154+
angle = switch(animation.curAnim.curFrame = (id % 4)) {
155+
case 0: 270;
156+
case 1: 180;
157+
case 2: 0;
158+
case 3: 90;
159+
default: 0; // how is that even possible
160+
};
161+
__doAnim = false;
162+
}
142163
}
143164
super.kill();
144165
}

0 commit comments

Comments
 (0)