Skip to content

Commit 32c775e

Browse files
KoloInDaCribMAJigsaw77
authored andcommitted
tooltips....BUT FOR NOTES!
1 parent 1605514 commit 32c775e

3 files changed

Lines changed: 71 additions & 3 deletions

File tree

source/funkin/data/song/SongData.hx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,30 @@ class SongNoteDataRaw implements ICloneable<SongNoteDataRaw>
11171117
return 'SongNoteData(${this.time}ms, ' + (this.length > 0 ? '[${this.length}ms hold]' : '') + ' ${this.data}'
11181118
+ (this.kind != '' ? ' [kind: ${this.kind}])' : ')');
11191119
}
1120+
1121+
public function buildTooltip():String
1122+
{
1123+
var result:String = "Kind: ";
1124+
1125+
if ((this.kind?.length ?? 0) == 0)
1126+
{
1127+
result += "Default";
1128+
return result;
1129+
}
1130+
1131+
result += this.kind;
1132+
1133+
if (this.params.length == 0) return result;
1134+
1135+
result += "\nParams:";
1136+
1137+
for (param in params)
1138+
{
1139+
result += '\n- ${param.name}: ${param.value}';
1140+
}
1141+
1142+
return result;
1143+
}
11201144
}
11211145

11221146
/**

source/funkin/ui/debug/charting/ChartEditorState.hx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2522,7 +2522,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
25222522
add(gridTiledSprite);
25232523
gridTiledSprite.zIndex = 10;
25242524

2525-
gridGhostNote = new ChartEditorNoteSprite(this);
2525+
gridGhostNote = new ChartEditorNoteSprite(this, true);
25262526
gridGhostNote.alpha = 0.6;
25272527
gridGhostNote.noteData = new SongNoteData(0, 0, 0, "", []);
25282528
gridGhostNote.visible = false;
@@ -3924,6 +3924,9 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
39243924
selectionSquare.width = selectionSquare.height = GRID_SIZE;
39253925
selectionSquare.color = FlxColor.RED;
39263926
}
3927+
3928+
// Additional cleanup on notes.
3929+
if (noteTooltipsDirty) noteSprite.updateTooltipText();
39273930
}
39283931

39293932
for (eventSprite in renderedEvents.members)

source/funkin/ui/debug/charting/components/ChartEditorNoteSprite.hx

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import funkin.data.song.SongData.SongNoteData;
1010
import funkin.data.notestyle.NoteStyleRegistry;
1111
import funkin.play.notes.notestyle.NoteStyle;
1212
import funkin.play.notes.NoteDirection;
13+
import haxe.ui.tooltips.ToolTipRegionOptions;
14+
import funkin.util.HaxeUIUtil;
15+
import haxe.ui.tooltips.ToolTipManager;
1316

1417
/**
1518
* A sprite that can be used to display a note in a chart.
@@ -63,11 +66,16 @@ class ChartEditorNoteSprite extends FlxSprite
6366
return overrideData;
6467
}
6568

66-
public function new(parent:ChartEditorState)
69+
public var isGhost:Bool = false;
70+
public var tooltip:ToolTipRegionOptions;
71+
72+
public function new(parent:ChartEditorState, isGhost:Bool = false)
6773
{
6874
super();
6975

7076
this.parentState = parent;
77+
this.isGhost = isGhost;
78+
this.tooltip = HaxeUIUtil.buildTooltip('N/A');
7179

7280
var entries:Array<String> = NoteStyleRegistry.instance.listEntryIds();
7381

@@ -156,6 +164,7 @@ class ChartEditorNoteSprite extends FlxSprite
156164
if (this.noteData == null)
157165
{
158166
this.kill();
167+
updateTooltipPosition();
159168
return this.noteData;
160169
}
161170

@@ -167,7 +176,7 @@ class ChartEditorNoteSprite extends FlxSprite
167176

168177
// Update the position to match the note data.
169178
updateNotePosition();
170-
179+
updateTooltipText();
171180
return this.noteData;
172181
}
173182

@@ -194,6 +203,38 @@ class ChartEditorNoteSprite extends FlxSprite
194203
this.x += origin.x;
195204
this.y += origin.y;
196205
}
206+
207+
this.updateTooltipPosition();
208+
}
209+
210+
public function updateTooltipText():Void
211+
{
212+
if (this.noteData == null) return;
213+
if (this.isGhost) return;
214+
this.tooltip.tipData = {text: this.noteData.buildTooltip()};
215+
}
216+
217+
public function updateTooltipPosition():Void
218+
{
219+
// No tooltip for ghost sprites.
220+
if (this.isGhost) return;
221+
222+
if (this.noteData == null)
223+
{
224+
// Disable the tooltip.
225+
ToolTipManager.instance.unregisterTooltipRegion(this.tooltip);
226+
}
227+
else
228+
{
229+
// Update the position.
230+
this.tooltip.left = this.x;
231+
this.tooltip.top = this.y;
232+
this.tooltip.width = this.width;
233+
this.tooltip.height = this.height;
234+
235+
// Enable the tooltip.
236+
ToolTipManager.instance.registerTooltipRegion(this.tooltip);
237+
}
197238
}
198239

199240
function get_noteStyle():Null<String>

0 commit comments

Comments
 (0)