Skip to content

Commit

Permalink
made the chart better a little better feature wise
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealJake12 committed Nov 8, 2024
1 parent b2b9664 commit 90e71e1
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 43 deletions.
23 changes: 17 additions & 6 deletions assets/shared/data/editors/charter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,32 @@
<menu text="Chart" style="padding: 5px;">
<menu-item id="chartSave" text="Save Chart" />
<menu-item id="chartReload" text="Reload Chart" />
<!--
<menu-item id="chartLoadAuto" text="Load Autosave" />
<menu-item id="chartClear" text="Clear Chart" />
-->
<!-- <menu-item id="chartLoadAuto" text="Load Autosave" /> -->
</menu>
<menu text="Preferences" style="padding: 5px;">
<menu-checkbox id="editorAutoSave" text="Autosave Chart" />
<menu text="Audio" style="padding: 5px;">
<label width="100%" styleName="menuHeader" text="Inst Volume" verticalAlign="center" />
<slider id="instVol" majorTicks="10" minorTicks="5" pos="100" verticalAlign="center" />
<label width="100%" styleName="menuHeader" text="Vocals Volume" verticalAlign="center" />
<slider id="vocalVol" majorTicks="10" minorTicks="5" pos="100" verticalAlign="center" />
<menu-separator />
<label width="100%" styleName="menuHeader" text="Vocals Player Volume" verticalAlign="center" />
<slider id="vocalPVol" majorTicks="10" minorTicks="5" pos="100" verticalAlign="center" />
<label width="100%" styleName="menuHeader" text="Vocals Opponent Volume" verticalAlign="center" />
<slider id="vocalEVol" majorTicks="10" minorTicks="5" pos="100" verticalAlign="center" />
<menu-separator />
<vbox width="100%" style="padding: 5px;">
<label width="100%" styleName="menuHeader" text="Metronome Volume" verticalAlign="center" />
<slider id="editorMetroVol" majorTicks="10" minorTicks="5" pos="100" verticalAlign="center" />
<label width="100%" styleName="menuHeader" text="Hitsound Volume" verticalAlign="center" />
<slider id="editorHitVol" majorTicks="10" minorTicks="5" pos="100" verticalAlign="center" />
</vbox>
<menu-checkbox id="editorHitsoundP" text="Player Hitsounds" />
<menu-checkbox id="editorHitsoundsP" text="Player Hitsounds" />
<menu-checkbox id="editorHitsoundsE" text="Enemy Hitsounds" />
</menu>
<menu text="Preferences" style="padding: 5px;">
<menu-checkbox id="editorAutoSave" text="Autosave Chart" />
</menu>
<menu text="Game" style="padding: 5px;">
<menu-item id="editorPlaytest" text="Playtest Chart Ingame" />
<menu-checkbox id="editorOpponentMode" text="Opponent Mode" />
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion source/kec/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2872,7 +2872,7 @@ class PlayState extends MusicBeatState
numGroup.sort(Sort.sortUI, -1);
ratingGroup.sort(Sort.sortUI, -1);
rating.fadeOut();
createTween(currentTimingShown, {alpha: 0}, 0.1, {
createTween(currentTimingShown, {alpha: 0}, 0.25, {
startDelay: (Conductor.crochet * 0.0005)
});
}
Expand Down
111 changes: 75 additions & 36 deletions source/kec/states/editors/ChartingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class ChartingState extends UIState
public var waitingForRelease:Bool = false;

private var maxBeat = 0;
private var maxSectionIndex:Int = 0;

public var end:Float = 1.0;

Expand Down Expand Up @@ -102,6 +103,7 @@ class ChartingState extends UIState
private var vocalsP:FlxSound;
private var vocalsE:FlxSound;
private var hitsound:FlxSound;
private var metronome:FlxSound;

private var noteCam:FlxCamera;
private var uiCam:FlxCamera;
Expand Down Expand Up @@ -147,6 +149,15 @@ class ChartingState extends UIState
uiCam.bgColor.alpha = 0;
FlxG.cameras.add(uiCam, false);

if (FlxG.save.data.hitSound == 0)
hitsound = FlxG.sound.load(Paths.sound('hitsounds/snap'));
else
hitsound = FlxG.sound.load(Paths.sound('hitsounds/${HitSounds.getSoundByID(FlxG.save.data.hitSound).toLowerCase()}'));

hitsound.autoDestroy = false;
metronome = FlxG.sound.load(Paths.sound('metronome'));
metronome.autoDestroy = false;

super.create();

PlayState.inDaPlay = false;
Expand All @@ -159,6 +170,8 @@ class ChartingState extends UIState
TimingStruct.setSongTimings(SONG);
Song.checkforSections(SONG, inst.length);
Song.recalculateAllSectionTimes(SONG);
calculateMaxBeat();
checkforSections();
setInitVars();

activeSong = SONG;
Expand Down Expand Up @@ -258,13 +271,6 @@ class ChartingState extends UIState
selectBox.alpha = 0.4;
add(selectBox);

if (FlxG.save.data.hitSound == 0)
hitsound = new FlxSound().loadEmbedded(Paths.sound('hitsounds/snap'));
else
hitsound = new FlxSound().loadEmbedded(Paths.sound('hitsounds/${HitSounds.getSoundByID(FlxG.save.data.hitSound).toLowerCase()}'));

hitsound.autoDestroy = false;

id = Lib.setInterval(backupChart, 5 * 60 * 1000);

#if FEATURE_DISCORD
Expand Down Expand Up @@ -562,7 +568,6 @@ class ChartingState extends UIState
{
hitsound.stop();
hitsound.time = 0;
hitsound.volume = .5;
hitsound.play().pan = noteDataToCheck < 4 ? -0.3 : 0.3;
playedSound[data] = true;
}
Expand Down Expand Up @@ -602,8 +607,7 @@ class ChartingState extends UIState

function regenerateLines()
{
lines.forEachAlive(function(l:BeatLine) l.kill());
texts.forEachAlive(function(t:TextLine) t.kill());
clearLines();

for (i in 0...lengthInBeats)
{
Expand Down Expand Up @@ -811,10 +815,6 @@ class ChartingState extends UIState

toDelete = null;
toBeAdded = null;

// ok so basically theres a bug with color quant that it doesn't update the color until the grid updates.
// when the grid updates, it causes a massive performance drop everytime we offset the notes. :/
// actually its broken either way because theres a ghost note after offsetting sometimes. updateGrid anyway.
}

function containsName(name:String, events:Array<Event>):Event
Expand All @@ -827,12 +827,8 @@ class ChartingState extends UIState
return null;
}

inline function clearSection():Void
{
destroyBoxes();

SONG.notes[curSection].sectionNotes = [];
}
private inline function clearSection(index:Int)
SONG.notes[index].sectionNotes = [];

function swapSection(secit:Section)
{
Expand Down Expand Up @@ -1032,18 +1028,14 @@ class ChartingState extends UIState
if (curSection < 0)
return;

noteGroup.forEachAlive(function(n:EditorNote) n.kill());
sustainGroup.forEachAlive(function(n:EditorSustain) n.kill());
clearRenderedNotes();
sectionMustHit.selected = currentSection.mustHitSection;
noteCounter = 0;
}

override function beatHit(curBeat:Int)
{
super.beatHit(curBeat);

if (FlxG.save.data.chart_metronome)
FlxG.sound.play(Paths.sound('Metronome_Tick'));
playMetronome();
}

override function stepHit(curStep:Int)
Expand Down Expand Up @@ -1127,6 +1119,8 @@ class ChartingState extends UIState
function checkforSections()
{
final totalBeats = maxBeat;
maxSectionIndex = SONG.notes[SONG.notes.length - 1].index;
Debug.logTrace(maxSectionIndex);

var lastSecBeat = TimingStruct.getBeatFromTime(SONG.notes[SONG.notes.length - 1].endTime);

Expand Down Expand Up @@ -1249,6 +1243,26 @@ class ChartingState extends UIState
}
}

private inline function clearLines()
{
lines.forEachAlive(function(l:BeatLine) l.kill());
texts.forEachAlive(function(t:TextLine) t.kill());
}

private inline function clearRenderedNotes()
{
noteGroup.forEachAlive(function(n:EditorNote) n.kill());
sustainGroup.forEachAlive(function(n:EditorSustain) n.kill());
noteCounter = 0;
}

private function playMetronome()
{
metronome.stop();
metronome.time = 0;
metronome.play();
}

private function newSection(lengthInSteps:Int = 16, index:Int, mustHitSection:Bool = false):Section
{
var sec:Section = {
Expand Down Expand Up @@ -1298,16 +1312,6 @@ class ChartingState extends UIState
diffSelect.dataSource = diffs;

setHUIData();
editorAutoSave.selected = FlxG.save.data.autoSaving;
editorAutoSave.onClick = _ -> FlxG.save.data.autoSaving = !FlxG.save.data.autoSaving;

chartSave.onClick = _ -> saveChart();
chartReload.onClick = _ -> loadAudio(dataID.text, true);
diffSelect.registerEvent(haxe.ui.events.UIEvent.CLOSE, function(e)
{
PlayState.storyDifficulty = CoolUtil.difficulties.indexOf(diffSelect.text);
Debug.logTrace(CoolUtil.difficulties[PlayState.storyDifficulty]);
});
}

private function setHUIData()
Expand All @@ -1324,5 +1328,40 @@ class ChartingState extends UIState
dataBPM.pos = SONG.eventObjects[0].args[0];
dataSpeed.pos = SONG.speed;
sectionMustHit.onClick = _ -> currentSection.mustHitSection = !currentSection.mustHitSection;
editorMetroVol.onChange = _ -> metronome.volume = (editorMetroVol.value / 100);

editorHitsoundsP.selected = FlxG.save.data.playHitsounds;
editorHitsoundsE.selected = FlxG.save.data.playHitsoundsE;
editorHitsoundsP.onClick = _ -> FlxG.save.data.playHitsounds = !FlxG.save.data.playHitsounds;
editorHitsoundsE.onClick = _ -> FlxG.save.data.playHitsoundsE = !FlxG.save.data.playHitsoundsE;

editorAutoSave.selected = FlxG.save.data.autoSaving;
editorAutoSave.onClick = _ -> FlxG.save.data.autoSaving = !FlxG.save.data.autoSaving;

editorHitVol.onChange = _ -> hitsound.volume = (editorHitVol.value / 100);

chartSave.onClick = _ -> saveChart();
chartReload.onClick = _ -> loadAudio(dataID.text, true);
diffSelect.registerEvent(haxe.ui.events.UIEvent.CLOSE, function(e)
{
PlayState.storyDifficulty = CoolUtil.difficulties.indexOf(diffSelect.text);
Debug.logTrace(CoolUtil.difficulties[PlayState.storyDifficulty]);
});
chartClear.onClick = function(e)
{
for (i in 0...maxSectionIndex)
{
clearSection(i);
}
clearRenderedNotes();
}

instVol.onChange = _ -> inst.volume = (instVol.value / 100);
vocalVol.disabled = (SONG.needsVoices && SONG.splitVoiceTracks);
vocalPVol.disabled = (SONG.needsVoices && !SONG.splitVoiceTracks);
vocalEVol.disabled = (SONG.needsVoices && !SONG.splitVoiceTracks);
vocalVol.onChange = _ -> if (vocals != null && !vocalVol.disabled) vocals.volume = (vocalVol.value / 100);
vocalPVol.onChange = _ -> if (vocalsP != null && !vocalPVol.disabled) vocalsP.volume = (vocalPVol.value / 100);
vocalEVol.onChange = _ -> if (vocalsE != null && !vocalEVol.disabled) vocalsE.volume = (vocalEVol.value / 100);
}
}

0 comments on commit 90e71e1

Please sign in to comment.