Skip to content

Commit 607abc1

Browse files
StarexifyHundrec
authored andcommitted
Align x positions of Chart Editor waveforms to the center of the health icons
1 parent af35608 commit 607abc1

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

source/funkin/audio/waveform/WaveformSprite.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class WaveformSprite extends MeshRender
1313
static final DEFAULT_WIDTH:Float = 100.0;
1414
static final DEFAULT_HEIGHT:Float = 100.0;
1515

16+
public var iconId:String;
17+
1618
/**
1719
* Set this to true to tell the waveform to rebuild itself.
1820
* Do this any time the data or drawable area of the waveform changes.

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,10 +963,15 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
963963
var noteTooltipsDirty:Bool = true;
964964

965965
/**
966-
* Whether the selected charactesr have been modified and the health icons need to be updated.
966+
* Whether the selected characters have been modified and the health icons need to be updated.
967967
*/
968968
var healthIconsDirty:Bool = true;
969969

970+
/**
971+
* Whether the waveforms were modified and need to be updated.
972+
*/
973+
var waveformsDirty:Bool = false;
974+
970975
/**
971976
* Whether the note preview graphic needs to be FULLY rebuilt.
972977
*/
@@ -3570,6 +3575,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
35703575
handlePlaybar();
35713576
handleNotePreview();
35723577
handleHealthIcons();
3578+
handleWaveforms();
35733579

35743580
handleFileKeybinds();
35753581
handleViewKeybinds();
@@ -5770,6 +5776,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
57705776
{
57715777
buttonSelectOpponent.text = charDataDad?.name ?? 'Opponent';
57725778
}
5779+
waveformsDirty = true;
57735780
healthIconsDirty = false;
57745781
}
57755782

@@ -5793,6 +5800,26 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
57935800
}
57945801
}
57955802

5803+
/**
5804+
* Handle waveforms aligning based on the health icons position.
5805+
*/
5806+
function handleWaveforms()
5807+
{
5808+
if (!waveformsDirty) return;
5809+
5810+
for (waveform in audioWaveforms.members)
5811+
{
5812+
waveform.x = switch (waveform.iconId)
5813+
{
5814+
case "bf": healthIconBF != null ? healthIconBF.x : 840 + FullScreenScaleMode.gameCutoutSize.x * 0.5;
5815+
case "dad": healthIconDad != null ? healthIconDad.x : 360 + FullScreenScaleMode.gameCutoutSize.x * 0.5;
5816+
default: 0;
5817+
}
5818+
}
5819+
5820+
waveformsDirty = false;
5821+
}
5822+
57965823
/**
57975824
* Handle keybinds for File menu items.
57985825
*/

source/funkin/ui/debug/charting/handlers/ChartEditorAudioHandler.hx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import funkin.play.character.BaseCharacter.CharacterType;
88
import funkin.util.FileUtil;
99
import funkin.util.assets.SoundUtil;
1010
import funkin.audio.waveform.WaveformData;
11-
import funkin.audio.waveform.WaveformDataParser;
1211
import funkin.audio.waveform.WaveformSprite;
1312
import flixel.util.FlxColor;
1413
import haxe.io.Bytes;
@@ -201,12 +200,12 @@ class ChartEditorAudioHandler
201200
{
202201
var duration:Float = Conductor.instance.getStepTimeInMs(16) * 0.001;
203202
var waveformSprite:WaveformSprite = new WaveformSprite(waveformData, VERTICAL, FlxColor.WHITE);
204-
waveformSprite.x = 840;
205203
waveformSprite.y = Math.max(state.gridTiledSprite?.y ?? 0.0, ChartEditorState.GRID_INITIAL_Y_POS - ChartEditorState.GRID_TOP_PAD);
206204
waveformSprite.height = (ChartEditorState.GRID_SIZE) * 16;
207205
waveformSprite.width = (ChartEditorState.GRID_SIZE) * 2;
208206
waveformSprite.time = 0;
209207
waveformSprite.duration = duration;
208+
waveformSprite.iconId = "bf";
210209
state.audioWaveforms.add(waveformSprite);
211210
}
212211
else
@@ -225,12 +224,12 @@ class ChartEditorAudioHandler
225224
{
226225
var duration:Float = Conductor.instance.getStepTimeInMs(16) * 0.001;
227226
var waveformSprite:WaveformSprite = new WaveformSprite(waveformData, VERTICAL, FlxColor.WHITE);
228-
waveformSprite.x = 360;
229227
waveformSprite.y = Math.max(state.gridTiledSprite?.y ?? 0.0, ChartEditorState.GRID_INITIAL_Y_POS - ChartEditorState.GRID_TOP_PAD);
230228
waveformSprite.height = (ChartEditorState.GRID_SIZE) * 16;
231229
waveformSprite.width = (ChartEditorState.GRID_SIZE) * 2;
232230
waveformSprite.time = 0;
233231
waveformSprite.duration = duration;
232+
waveformSprite.iconId = "dad";
234233
state.audioWaveforms.add(waveformSprite);
235234
}
236235
else

0 commit comments

Comments
 (0)