diff --git a/source/debug/ChartingState.hx b/source/debug/ChartingState.hx index 48a996bb..d9754889 100644 --- a/source/debug/ChartingState.hx +++ b/source/debug/ChartingState.hx @@ -2253,1706 +2253,1706 @@ class ChartingState extends MusicBeatState } } } - } - for (i in sectionRenderes) - { - var diff = i.y - strumLine.y; - if (diff < 2200 && diff >= -2200) - { - i.active = true; - i.visible = true; - } - else + for (i in sectionRenderes) { - i.active = false; - i.visible = false; + var diff = i.y - strumLine.y; + if (diff < 2200 && diff >= -2200) + { + i.active = true; + i.visible = true; + } + else + { + i.active = false; + i.visible = false; + } } - } - shownNotes = []; + shownNotes = []; - for (note in curRenderedNotes) - { - var diff = note.strumTime - Conductor.songPosition; - if (diff < 1675 && diff >= -3500) // Cutting it really close with rendered notes + for (note in curRenderedNotes) { - shownNotes.push(note); - if (note.sustainLength > 0) + var diff = note.strumTime - Conductor.songPosition; + if (diff < 1675 && diff >= -3500) // Cutting it really close with rendered notes { - note.noteCharterObject.active = true; - note.noteCharterObject.visible = true; + shownNotes.push(note); + if (note.sustainLength > 0) + { + note.noteCharterObject.active = true; + note.noteCharterObject.visible = true; + } + note.active = true; + note.visible = true; } - note.active = true; - note.visible = true; - } - else - { - note.active = false; - note.visible = false; - if (note.sustainLength > 0) + else { - if (note.noteCharterObject != null) - if (note.noteCharterObject.y != note.y) - { - note.noteCharterObject.active = false; - note.noteCharterObject.visible = false; - } + note.active = false; + note.visible = false; + if (note.sustainLength > 0) + { + if (note.noteCharterObject != null) + if (note.noteCharterObject.y != note.y) + { + note.noteCharterObject.active = false; + note.noteCharterObject.visible = false; + } + } } } - } - - /* - note culling code above - */ - - for (ii in selectedBoxes.members) - { - ii.x = ii.connectedNote.x; - ii.y = ii.connectedNote.y; - } - var doInput = true; + /* + note culling code above + */ - for (inputText in blockTypes) - { - if (inputText.hasFocus) + for (ii in selectedBoxes.members) { - doInput = false; - break; + ii.x = ii.connectedNote.x; + ii.y = ii.connectedNote.y; } - } - if (doInput) - { - for (stepper in blockSteppers) + var doInput = true; + + for (inputText in blockTypes) { - @:privateAccess - var leText:FlxUIInputText = cast(stepper.text_field, FlxUIInputText); - if (leText.hasFocus) + if (inputText.hasFocus) { doInput = false; break; } } - } - if (doInput) - { - for (dropDownMenu in blockScroll) + if (doInput) { - if (dropDownMenu.dropPanel.visible) + for (stepper in blockSteppers) { - doInput = false; - break; + @:privateAccess + var leText:FlxUIInputText = cast(stepper.text_field, FlxUIInputText); + if (leText.hasFocus) + { + doInput = false; + break; + } } } - } - if (doInput) - { - if (FlxG.mouse.wheel != 0) + if (doInput) { - if (inst.playing) + for (dropDownMenu in blockScroll) { - inst.pause(); - - if (!_song.splitVoiceTracks) - vocals.pause(); - else + if (dropDownMenu.dropPanel.visible) { - vocalsPlayer.pause(); - vocalsEnemy.pause(); + doInput = false; + break; } } + } - if (FlxG.keys.pressed.CONTROL && !waitingForRelease) + if (doInput) + { + if (FlxG.mouse.wheel != 0) { - var amount = FlxG.mouse.wheel; + if (inst.playing) + { + inst.pause(); - if (amount > 0) - amount = 0; + if (!_song.splitVoiceTracks) + vocals.pause(); + else + { + vocalsPlayer.pause(); + vocalsEnemy.pause(); + } + } - var increase:Float = 0; + if (FlxG.keys.pressed.CONTROL && !waitingForRelease) + { + var amount = FlxG.mouse.wheel; - if (amount < 0) - increase = -0.02; - else - increase = 0.02; + if (amount > 0) + amount = 0; - zoomFactor += increase; + var increase:Float = 0; - if (zoomFactor > 2) - zoomFactor = 2; + if (amount < 0) + increase = -0.02; + else + increase = 0.02; - if (zoomFactor < 0.2) - zoomFactor = 0.2; - resizeEverything(); - } - else - { - var amount = FlxG.mouse.wheel; + zoomFactor += increase; - if (amount > 0 && strumLine.y < 0) - amount = 0; + if (zoomFactor > 2) + zoomFactor = 2; - if (doSnapShit) + if (zoomFactor < 0.2) + zoomFactor = 0.2; + resizeEverything(); + } + else { - var increase:Float = 0; - var beats:Float = 0; + var amount = FlxG.mouse.wheel; - if (amount < 0) - { - increase = 1 / deezNuts.get(snap); - beats = (Math.floor((curDecimalBeat * deezNuts.get(snap)) + 0.001) / deezNuts.get(snap)) + increase; - } - else + if (amount > 0 && strumLine.y < 0) + amount = 0; + + if (doSnapShit) { - increase = -1 / deezNuts.get(snap); - beats = ((Math.ceil(curDecimalBeat * deezNuts.get(snap)) - 0.001) / deezNuts.get(snap)) + increase; - } + var increase:Float = 0; + var beats:Float = 0; + + if (amount < 0) + { + increase = 1 / deezNuts.get(snap); + beats = (Math.floor((curDecimalBeat * deezNuts.get(snap)) + 0.001) / deezNuts.get(snap)) + increase; + } + else + { + increase = -1 / deezNuts.get(snap); + beats = ((Math.ceil(curDecimalBeat * deezNuts.get(snap)) - 0.001) / deezNuts.get(snap)) + increase; + } - var data = TimingStruct.getTimingAtBeat(beats); + var data = TimingStruct.getTimingAtBeat(beats); - if (beats <= 0) - inst.time = 0; + if (beats <= 0) + inst.time = 0; - var bpm = data != null ? data.bpm : _song.bpm; + var bpm = data != null ? data.bpm : _song.bpm; - if (data != null) - { - inst.time = (data.startTime + ((beats - data.startBeat) / (bpm / 60))) * 1000; + if (data != null) + { + inst.time = (data.startTime + ((beats - data.startBeat) / (bpm / 60))) * 1000; + } } - } - else - inst.time -= (FlxG.mouse.wheel * Conductor.stepCrochet * 0.4); + else + inst.time -= (FlxG.mouse.wheel * Conductor.stepCrochet * 0.4); - if (!_song.splitVoiceTracks) - vocals.time = inst.time; - else - { - vocalsPlayer.time = inst.time; - vocalsEnemy.time = inst.time; + if (!_song.splitVoiceTracks) + vocals.time = inst.time; + else + { + vocalsPlayer.time = inst.time; + vocalsEnemy.time = inst.time; + } } } - } - if (FlxG.keys.justPressed.ESCAPE) - LoadingState.loadAndSwitchState(new FreeplayState()); + if (FlxG.keys.justPressed.ESCAPE) + LoadingState.loadAndSwitchState(new FreeplayState()); - if (FlxG.keys.pressed.SHIFT) - { - if (FlxG.keys.justPressed.RIGHT) - { - speed += 0.1; - } - else if (FlxG.keys.justPressed.LEFT) + if (FlxG.keys.pressed.SHIFT) { - speed -= 0.1; - } + if (FlxG.keys.justPressed.RIGHT) + { + speed += 0.1; + } + else if (FlxG.keys.justPressed.LEFT) + { + speed -= 0.1; + } - if (speed > 3) - speed = 3; - if (speed <= 0.01) - speed = 0.1; - } - else - { - if (FlxG.keys.justPressed.RIGHT && !FlxG.keys.pressed.CONTROL) - { - goToSection(curSection + 1); + if (speed > 3) + speed = 3; + if (speed <= 0.01) + speed = 0.1; } - else if (FlxG.keys.justPressed.LEFT && !FlxG.keys.pressed.CONTROL) + else { - goToSection(curSection - 1); + if (FlxG.keys.justPressed.RIGHT && !FlxG.keys.pressed.CONTROL) + { + goToSection(curSection + 1); + } + else if (FlxG.keys.justPressed.LEFT && !FlxG.keys.pressed.CONTROL) + { + goToSection(curSection - 1); + } } - } - if (FlxG.mouse.pressed && FlxG.keys.pressed.CONTROL) - { - if (!waitingForRelease) + if (FlxG.mouse.pressed && FlxG.keys.pressed.CONTROL) { - while (selectedBoxes.members.length != 0) + if (!waitingForRelease) { - selectedBoxes.members[0].connectedNote.charterSelected = false; - selectedBoxes.members[0].destroy(); - selectedBoxes.members.remove(selectedBoxes.members[0]); - } + while (selectedBoxes.members.length != 0) + { + selectedBoxes.members[0].connectedNote.charterSelected = false; + selectedBoxes.members[0].destroy(); + selectedBoxes.members.remove(selectedBoxes.members[0]); + } - waitingForRelease = true; - selectBox = new FlxSprite(FlxG.mouse.x, FlxG.mouse.y); - selectBox.makeGraphic(1, 1, FlxColor.fromRGB(173, 216, 230)); - selectBox.alpha = 0.4; + waitingForRelease = true; + selectBox = new FlxSprite(FlxG.mouse.x, FlxG.mouse.y); + selectBox.makeGraphic(1, 1, FlxColor.fromRGB(173, 216, 230)); + selectBox.alpha = 0.4; - selectInitialX = selectBox.x; - selectInitialY = selectBox.y; + selectInitialX = selectBox.x; + selectInitialY = selectBox.y; - add(selectBox); - } - else - { - if (waitingForRelease) + add(selectBox); + } + else { - selectBox.x = Math.min(FlxG.mouse.x, selectInitialX); - selectBox.y = Math.min(FlxG.mouse.y, selectInitialY); - selectBox.scale.x = Math.floor(Math.abs(FlxG.mouse.x - selectInitialX)); - selectBox.scale.y = Math.floor(Math.abs(FlxG.mouse.y - selectInitialY)); - selectBox.updateHitbox(); + if (waitingForRelease) + { + selectBox.x = Math.min(FlxG.mouse.x, selectInitialX); + selectBox.y = Math.min(FlxG.mouse.y, selectInitialY); + selectBox.scale.x = Math.floor(Math.abs(FlxG.mouse.x - selectInitialX)); + selectBox.scale.y = Math.floor(Math.abs(FlxG.mouse.y - selectInitialY)); + selectBox.updateHitbox(); - // selectBox.makeGraphic(Math.floor(Math.abs(FlxG.mouse.x - selectInitialX)), Math.floor(Math.abs(FlxG.mouse.y - selectInitialY)),FlxColor.fromRGB(173, 216, 230)); + // selectBox.makeGraphic(Math.floor(Math.abs(FlxG.mouse.x - selectInitialX)), Math.floor(Math.abs(FlxG.mouse.y - selectInitialY)),FlxColor.fromRGB(173, 216, 230)); + } } } - } - if (FlxG.mouse.justReleased && waitingForRelease) - { - waitingForRelease = false; - - for (i in curRenderedNotes) + if (FlxG.mouse.justReleased && waitingForRelease) { - if (i.overlaps(selectBox) && !i.charterSelected) + waitingForRelease = false; + + for (i in curRenderedNotes) { - selectNote(i); + if (i.overlaps(selectBox) && !i.charterSelected) + { + selectNote(i); + } } + selectBox.destroy(); + remove(selectBox); } - selectBox.destroy(); - remove(selectBox); - } - if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.D) - { - lastAction = "delete"; - var notesToBeDeleted = []; - deletedNotes = []; - for (i in 0...selectedBoxes.members.length) + if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.D) { - deletedNotes.push([ - selectedBoxes.members[i].connectedNote.strumTime, - selectedBoxes.members[i].connectedNote.rawNoteData, - selectedBoxes.members[i].connectedNote.sustainLength - ]); - notesToBeDeleted.push(selectedBoxes.members[i].connectedNote); - } + lastAction = "delete"; + var notesToBeDeleted = []; + deletedNotes = []; + for (i in 0...selectedBoxes.members.length) + { + deletedNotes.push([ + selectedBoxes.members[i].connectedNote.strumTime, + selectedBoxes.members[i].connectedNote.rawNoteData, + selectedBoxes.members[i].connectedNote.sustainLength + ]); + notesToBeDeleted.push(selectedBoxes.members[i].connectedNote); + } - for (i in notesToBeDeleted) - { - deleteNote(i); + for (i in notesToBeDeleted) + { + deleteNote(i); + } } - } - if (FlxG.keys.justPressed.DELETE) - { - lastAction = "delete"; - var notesToBeDeleted = []; - deletedNotes = []; - for (i in 0...selectedBoxes.members.length) + if (FlxG.keys.justPressed.DELETE) { - deletedNotes.push([ - selectedBoxes.members[i].connectedNote.strumTime, - selectedBoxes.members[i].connectedNote.rawNoteData, - selectedBoxes.members[i].connectedNote.sustainLength - ]); - notesToBeDeleted.push(selectedBoxes.members[i].connectedNote); - } + lastAction = "delete"; + var notesToBeDeleted = []; + deletedNotes = []; + for (i in 0...selectedBoxes.members.length) + { + deletedNotes.push([ + selectedBoxes.members[i].connectedNote.strumTime, + selectedBoxes.members[i].connectedNote.rawNoteData, + selectedBoxes.members[i].connectedNote.sustainLength + ]); + notesToBeDeleted.push(selectedBoxes.members[i].connectedNote); + } - for (i in notesToBeDeleted) - { - deleteNote(i); + for (i in notesToBeDeleted) + { + deleteNote(i); + } } - } - if (FlxG.keys.justPressed.UP || FlxG.keys.justPressed.DOWN) - { - var offsetSteps = FlxG.keys.pressed.CONTROL ? 16 : 1; - var offsetSeconds = Conductor.stepCrochet * offsetSteps; + if (FlxG.keys.justPressed.UP || FlxG.keys.justPressed.DOWN) + { + var offsetSteps = FlxG.keys.pressed.CONTROL ? 16 : 1; + var offsetSeconds = Conductor.stepCrochet * offsetSteps; - var offset:Float = 0; - if (FlxG.keys.justPressed.UP) - offset -= offsetSeconds; - if (FlxG.keys.justPressed.DOWN) - offset += offsetSeconds; + var offset:Float = 0; + if (FlxG.keys.justPressed.UP) + offset -= offsetSeconds; + if (FlxG.keys.justPressed.DOWN) + offset += offsetSeconds; - offsetSelectedNotes(offset); - } + offsetSelectedNotes(offset); + } - if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.C) - { - if (selectedBoxes.members.length != 0) + if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.C) { - copiedNotes = []; - for (i in selectedBoxes.members) - copiedNotes.push([ - i.connectedNote.strumTime, - i.connectedNote.rawNoteData, - i.connectedNote.sustainLength, - i.connectedNote.isAlt, - i.connectedNote.beat, - i.connectedNote.noteShit - ]); - - var firstNote = copiedNotes[0][0]; - - for (i in copiedNotes) // normalize the notes + if (selectedBoxes.members.length != 0) { - i[0] = i[0] - firstNote; + copiedNotes = []; + for (i in selectedBoxes.members) + copiedNotes.push([ + i.connectedNote.strumTime, + i.connectedNote.rawNoteData, + i.connectedNote.sustainLength, + i.connectedNote.isAlt, + i.connectedNote.beat, + i.connectedNote.noteShit + ]); + + var firstNote = copiedNotes[0][0]; + + for (i in copiedNotes) // normalize the notes + { + i[0] = i[0] - firstNote; + } } } - } - if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.V) - { - if (copiedNotes.length != 0) + if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.V) { - while (selectedBoxes.members.length != 0) + if (copiedNotes.length != 0) { - selectedBoxes.members[0].connectedNote.charterSelected = false; - selectedBoxes.members[0].destroy(); - selectedBoxes.members.remove(selectedBoxes.members[0]); - selectedBoxes.clear(); - } - pasteNotesFromArray(copiedNotes); + while (selectedBoxes.members.length != 0) + { + selectedBoxes.members[0].connectedNote.charterSelected = false; + selectedBoxes.members[0].destroy(); + selectedBoxes.members.remove(selectedBoxes.members[0]); + selectedBoxes.clear(); + } + pasteNotesFromArray(copiedNotes); - lastAction = "paste"; + lastAction = "paste"; + } } - } - if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.Z) - { - switch (lastAction) + if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.Z) { - case "paste": - if (pastedNotes.length != 0) - { - for (i in pastedNotes) + switch (lastAction) + { + case "paste": + if (pastedNotes.length != 0) { - if (curRenderedNotes.members.contains(i)) - deleteNote(i); - } + for (i in pastedNotes) + { + if (curRenderedNotes.members.contains(i)) + deleteNote(i); + } - pastedNotes = []; - } - case "delete": - if (deletedNotes.length != 0) - { - pasteNotesFromArray(deletedNotes, false); - deletedNotes = []; - } + pastedNotes = []; + } + case "delete": + if (deletedNotes.length != 0) + { + pasteNotesFromArray(deletedNotes, false); + deletedNotes = []; + } + } } } - } - if (updateFrame == 4) - { - TimingStruct.clearTimings(); - - var currentIndex = 0; - for (i in _song.eventObjects) + if (updateFrame == 4) { - if (i.type == "BPM Change") + TimingStruct.clearTimings(); + + var currentIndex = 0; + for (i in _song.eventObjects) { - var beat:Float = i.position; + if (i.type == "BPM Change") + { + var beat:Float = i.position; - var endBeat:Float = Math.POSITIVE_INFINITY; + var endBeat:Float = Math.POSITIVE_INFINITY; - TimingStruct.addTiming(beat, i.value, endBeat, 0); // offset in this case = start time since we don't have a offset + TimingStruct.addTiming(beat, i.value, endBeat, 0); // offset in this case = start time since we don't have a offset - if (currentIndex != 0) - { - var data = TimingStruct.AllTimings[currentIndex - 1]; - data.endBeat = beat; - data.length = (data.endBeat - data.startBeat) / (data.bpm / 60); - var step = ((60 / data.bpm) * 1000) / 4; - TimingStruct.AllTimings[currentIndex].startStep = Math.floor(((data.endBeat / (data.bpm / 60)) * 1000) / step); - TimingStruct.AllTimings[currentIndex].startTime = data.startTime + data.length; - } + if (currentIndex != 0) + { + var data = TimingStruct.AllTimings[currentIndex - 1]; + data.endBeat = beat; + data.length = (data.endBeat - data.startBeat) / (data.bpm / 60); + var step = ((60 / data.bpm) * 1000) / 4; + TimingStruct.AllTimings[currentIndex].startStep = Math.floor(((data.endBeat / (data.bpm / 60)) * 1000) / step); + TimingStruct.AllTimings[currentIndex].startTime = data.startTime + data.length; + } - currentIndex++; + currentIndex++; + } } - } - recalculateAllSectionTimes(); + recalculateAllSectionTimes(); - regenerateLines(); - updateFrame++; - } - else if (updateFrame != 5) - updateFrame++; + regenerateLines(); + updateFrame++; + } + else if (updateFrame != 5) + updateFrame++; - snapText.text = ""; + snapText.text = ""; - if (FlxG.keys.justPressed.RIGHT && FlxG.keys.pressed.CONTROL) - { - snapSelection++; - var index = 6; - if (snapSelection > 6) - snapSelection = 6; - if (snapSelection < 0) - snapSelection = 0; - for (v in deezNuts.keys()) + if (FlxG.keys.justPressed.RIGHT && FlxG.keys.pressed.CONTROL) { - if (index == snapSelection) + snapSelection++; + var index = 6; + if (snapSelection > 6) + snapSelection = 6; + if (snapSelection < 0) + snapSelection = 0; + for (v in deezNuts.keys()) { - snap = v; + if (index == snapSelection) + { + snap = v; + } + index--; } - index--; } - } - if (FlxG.keys.justPressed.LEFT && FlxG.keys.pressed.CONTROL) - { - snapSelection--; - if (snapSelection > 6) - snapSelection = 6; - if (snapSelection < 0) - snapSelection = 0; - var index = 6; - for (v in deezNuts.keys()) + if (FlxG.keys.justPressed.LEFT && FlxG.keys.pressed.CONTROL) { - if (index == snapSelection) + snapSelection--; + if (snapSelection > 6) + snapSelection = 6; + if (snapSelection < 0) + snapSelection = 0; + var index = 6; + for (v in deezNuts.keys()) { - snap = v; + if (index == snapSelection) + { + snap = v; + } + index--; } - index--; } - } - - if (FlxG.keys.justPressed.SHIFT) - doSnapShit = !doSnapShit; - doSnapShit = defaultSnap; - if (FlxG.keys.pressed.SHIFT) - { - doSnapShit = !defaultSnap; - } + if (FlxG.keys.justPressed.SHIFT) + doSnapShit = !doSnapShit; - check_snap.checked = doSnapShit; + doSnapShit = defaultSnap; + if (FlxG.keys.pressed.SHIFT) + { + doSnapShit = !defaultSnap; + } - Conductor.songPosition = inst.time; + check_snap.checked = doSnapShit; - _song.songId = typingShit.text; - _song.audioFile = typingShit2.text; + Conductor.songPosition = inst.time; - var timingSeg = TimingStruct.getTimingAtTimestamp(Conductor.songPosition); + _song.songId = typingShit.text; + _song.audioFile = typingShit2.text; - var start = Conductor.songPosition; + var timingSeg = TimingStruct.getTimingAtTimestamp(Conductor.songPosition); - if (timingSeg != null) - { - var timingSegBpm = timingSeg.bpm; - currentBPM = timingSegBpm; + var start = Conductor.songPosition; - if (currentBPM != Conductor.bpm) + if (timingSeg != null) { - Conductor.changeBPM(currentBPM, false); - } + var timingSegBpm = timingSeg.bpm; + currentBPM = timingSegBpm; + + if (currentBPM != Conductor.bpm) + { + Conductor.changeBPM(currentBPM, false); + } - var pog:Float = (curDecimalBeat - timingSeg.startBeat) / (Conductor.bpm / 60); + var pog:Float = (curDecimalBeat - timingSeg.startBeat) / (Conductor.bpm / 60); - start = (timingSeg.startTime + pog) * 1000; - } + start = (timingSeg.startTime + pog) * 1000; + } - var weird = getSectionByTime(start); + var weird = getSectionByTime(start); - if (weird != null) - { - if (lastUpdatedSection != getSectionByTime(start)) + if (weird != null) { - lastUpdatedSection = weird; - check_mustHitSection.checked = weird.mustHitSection; - check_CPUAltAnim.checked = weird.CPUAltAnim; - check_playerAltAnim.checked = weird.playerAltAnim; + if (lastUpdatedSection != getSectionByTime(start)) + { + lastUpdatedSection = weird; + check_mustHitSection.checked = weird.mustHitSection; + check_CPUAltAnim.checked = weird.CPUAltAnim; + check_playerAltAnim.checked = weird.playerAltAnim; + } } - } - strumLine.y = getYfromStrum(start) * zoomFactor; - camFollow.y = strumLine.y; + strumLine.y = getYfromStrum(start) * zoomFactor; + camFollow.y = strumLine.y; - var left = FlxG.keys.justPressed.ONE; - var down = FlxG.keys.justPressed.TWO; - var up = FlxG.keys.justPressed.THREE; - var right = FlxG.keys.justPressed.FOUR; - var leftO = FlxG.keys.justPressed.FIVE; - var downO = FlxG.keys.justPressed.SIX; - var upO = FlxG.keys.justPressed.SEVEN; - var rightO = FlxG.keys.justPressed.EIGHT; + var left = FlxG.keys.justPressed.ONE; + var down = FlxG.keys.justPressed.TWO; + var up = FlxG.keys.justPressed.THREE; + var right = FlxG.keys.justPressed.FOUR; + var leftO = FlxG.keys.justPressed.FIVE; + var downO = FlxG.keys.justPressed.SIX; + var upO = FlxG.keys.justPressed.SEVEN; + var rightO = FlxG.keys.justPressed.EIGHT; - if (FlxG.keys.justPressed.F1) - { - FlxG.save.data.showHelp = !FlxG.save.data.showHelp; - } + if (FlxG.keys.justPressed.F1) + { + FlxG.save.data.showHelp = !FlxG.save.data.showHelp; + } - var pressArray = [left, down, up, right, leftO, downO, upO, rightO]; - var delete = false; + var pressArray = [left, down, up, right, leftO, downO, upO, rightO]; + var delete = false; - if (FlxG.mouse.justPressed && !waitingForRelease) - { - if (FlxG.mouse.overlaps(curRenderedNotes)) + if (FlxG.mouse.justPressed && !waitingForRelease) { - curRenderedNotes.forEach(function(note:Note) + if (FlxG.mouse.overlaps(curRenderedNotes)) { - if (FlxG.mouse.overlaps(note)) + curRenderedNotes.forEach(function(note:Note) { - if (FlxG.keys.pressed.CONTROL) - { - selectNote(note); - } - else + if (FlxG.mouse.overlaps(note)) { - deleteNote(note); + if (FlxG.keys.pressed.CONTROL) + { + selectNote(note); + } + else + { + deleteNote(note); + } } - } - }); - } - else - { - if (FlxG.mouse.x > 0 && FlxG.mouse.x < 0 + gridBG.width && FlxG.mouse.y > 0 && FlxG.mouse.y < 0 + height) + }); + } + else { - addNote(); + if (FlxG.mouse.x > 0 && FlxG.mouse.x < 0 + gridBG.width && FlxG.mouse.y > 0 && FlxG.mouse.y < 0 + height) + { + addNote(); + } } } - } - - if (FlxG.mouse.x > 0 && FlxG.mouse.x < gridBG.width && FlxG.mouse.y > 0 && FlxG.mouse.y < height) - { - dummyArrow.visible = true; - - dummyArrow.x = Math.floor(FlxG.mouse.x / GRID_SIZE) * GRID_SIZE; - if (doSnapShit) + if (FlxG.mouse.x > 0 && FlxG.mouse.x < gridBG.width && FlxG.mouse.y > 0 && FlxG.mouse.y < height) { - var time = getStrumTime(FlxG.mouse.y / zoomFactor); + dummyArrow.visible = true; - var beat = TimingStruct.getBeatFromTime(time); - var snapped = Math.round(beat * deezNuts.get(snap)) / deezNuts.get(snap); + dummyArrow.x = Math.floor(FlxG.mouse.x / GRID_SIZE) * GRID_SIZE; - dummyArrow.y = getYfromStrum(TimingStruct.getTimeFromBeat(snapped)) * zoomFactor; - } - else - { - dummyArrow.y = FlxG.mouse.y; - } - } - else - dummyArrow.visible = false; + if (doSnapShit) + { + var time = getStrumTime(FlxG.mouse.y / zoomFactor); - if (doInput) - { - if (FlxG.keys.justPressed.ENTER) - { - lastSection = curSection; + var beat = TimingStruct.getBeatFromTime(time); + var snapped = Math.round(beat * deezNuts.get(snap)) / deezNuts.get(snap); - PlayState.SONG = _song; - inst.stop(); - if (!_song.splitVoiceTracks) - vocals.stop(); - else - { - vocalsPlayer.stop(); - vocalsEnemy.stop(); + dummyArrow.y = getYfromStrum(TimingStruct.getTimeFromBeat(snapped)) * zoomFactor; } - for (i in _song.notes) + else { - if (i.startTime > inst.length) - _song.notes.remove(i); + dummyArrow.y = FlxG.mouse.y; } - Main.dumpCache(); - - LoadingState.loadAndSwitchState(new PlayState()); - clean(); } + else + dummyArrow.visible = false; - if (curSelectedNote != null && curSelectedNote[2] > -1) + if (doInput) { - if (FlxG.keys.justPressed.E) + if (FlxG.keys.justPressed.ENTER) { - changeNoteSustain(Conductor.stepCrochet); + lastSection = curSection; + + PlayState.SONG = _song; + inst.stop(); + if (!_song.splitVoiceTracks) + vocals.stop(); + else + { + vocalsPlayer.stop(); + vocalsEnemy.stop(); + } + for (i in _song.notes) + { + if (i.startTime > inst.length) + _song.notes.remove(i); + } + Main.dumpCache(); + + LoadingState.loadAndSwitchState(new PlayState()); + clean(); } - if (FlxG.keys.justPressed.Q) + + if (curSelectedNote != null && curSelectedNote[2] > -1) { - changeNoteSustain(-Conductor.stepCrochet); + if (FlxG.keys.justPressed.E) + { + changeNoteSustain(Conductor.stepCrochet); + } + if (FlxG.keys.justPressed.Q) + { + changeNoteSustain(-Conductor.stepCrochet); + } } - } - if (FlxG.keys.justPressed.C && !FlxG.keys.pressed.CONTROL) - { - var sect = _song.notes[curSection]; - - sect.mustHitSection = !sect.mustHitSection; - updateHeads(); - check_mustHitSection.checked = sect.mustHitSection; - var i = sectionRenderes.members[curSection]; - var cachedY = i.icon.y; - remove(i.icon); - var sectionicon = sect.mustHitSection ? new HealthIcon(player1.healthIcon, - player1.iconAnimated).clone() : new HealthIcon(player2.healthIcon, player2.iconAnimated).clone(); - sectionicon.x = -95; - sectionicon.y = cachedY; - sectionicon.setGraphicSize(0, 45); + if (FlxG.keys.justPressed.C && !FlxG.keys.pressed.CONTROL) + { + var sect = _song.notes[curSection]; - i.icon = sectionicon; - i.lastUpdated = sect.mustHitSection; + sect.mustHitSection = !sect.mustHitSection; + updateHeads(); + check_mustHitSection.checked = sect.mustHitSection; + var i = sectionRenderes.members[curSection]; + var cachedY = i.icon.y; + remove(i.icon); + var sectionicon = sect.mustHitSection ? new HealthIcon(player1.healthIcon, + player1.iconAnimated).clone() : new HealthIcon(player2.healthIcon, player2.iconAnimated).clone(); + sectionicon.x = -95; + sectionicon.y = cachedY; + sectionicon.setGraphicSize(0, 45); - add(sectionicon); - } - if (FlxG.keys.justPressed.V && !FlxG.keys.pressed.CONTROL) - { - var secit = _song.notes[curSection]; + i.icon = sectionicon; + i.lastUpdated = sect.mustHitSection; - if (secit != null) + add(sectionicon); + } + if (FlxG.keys.justPressed.V && !FlxG.keys.pressed.CONTROL) { - swapSection(secit); + var secit = _song.notes[curSection]; + + if (secit != null) + { + swapSection(secit); + } } - } - if (FlxG.keys.justPressed.TAB) - { - if (FlxG.keys.pressed.SHIFT) + if (FlxG.keys.justPressed.TAB) { - UI_box.selected_tab -= 1; - if (UI_box.selected_tab < 0) - UI_box.selected_tab = 3; + if (FlxG.keys.pressed.SHIFT) + { + UI_box.selected_tab -= 1; + if (UI_box.selected_tab < 0) + UI_box.selected_tab = 3; + } + else + { + UI_box.selected_tab += 1; + if (UI_box.selected_tab > 3) + UI_box.selected_tab = 0; + } } - else + + if (!FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.Z) { - UI_box.selected_tab += 1; - if (UI_box.selected_tab > 3) - UI_box.selected_tab = 0; + this.noteShit--; + if (noteShit < 0) + { + noteShit = shits.length - 1; + } + updateNotetypeText(); } - } - if (!FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.Z) - { - this.noteShit--; - if (noteShit < 0) + if (!FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.X) { - noteShit = shits.length - 1; + this.noteShit++; + if (noteShit == shits.length) + noteShit = 0; + updateNotetypeText(); } - updateNotetypeText(); - } - - if (!FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.X) - { - this.noteShit++; - if (noteShit == shits.length) - noteShit = 0; - updateNotetypeText(); - } - if (!typingShit.hasFocus && !typingShit2.hasFocus) - { - var shiftThing:Int = 1; - if (FlxG.keys.pressed.SHIFT) - shiftThing = 4; - if (FlxG.keys.justPressed.SPACE) + if (!typingShit.hasFocus && !typingShit2.hasFocus) { - if (inst.playing) - { - inst.pause(); - if (!_song.splitVoiceTracks) - vocals.pause(); - else - { - vocalsPlayer.pause(); - vocalsEnemy.pause(); - } - } - else + var shiftThing:Int = 1; + if (FlxG.keys.pressed.SHIFT) + shiftThing = 4; + if (FlxG.keys.justPressed.SPACE) { - inst.time = lastConductorPos; - if (!_song.splitVoiceTracks) + if (inst.playing) { - vocals.time = inst.time; - vocals.play(); + inst.pause(); + if (!_song.splitVoiceTracks) + vocals.pause(); + else + { + vocalsPlayer.pause(); + vocalsEnemy.pause(); + } } else { - vocalsPlayer.time = inst.time; - vocalsEnemy.time = inst.time; - vocalsPlayer.play(); - vocalsEnemy.play(); + inst.time = lastConductorPos; + if (!_song.splitVoiceTracks) + { + vocals.time = inst.time; + vocals.play(); + } + else + { + vocalsPlayer.time = inst.time; + vocalsEnemy.time = inst.time; + vocalsPlayer.play(); + vocalsEnemy.play(); + } + inst.play(); } - inst.play(); } - } - if (inst.time < 0 || curDecimalBeat < 0) - inst.time = 0; + if (inst.time < 0 || curDecimalBeat < 0) + inst.time = 0; - if (!FlxG.keys.pressed.SHIFT) - { - if (FlxG.keys.pressed.W || FlxG.keys.pressed.S) + if (!FlxG.keys.pressed.SHIFT) { - inst.pause(); - if (!_song.splitVoiceTracks) - vocals.pause(); - else + if (FlxG.keys.pressed.W || FlxG.keys.pressed.S) { - vocalsPlayer.pause(); - vocalsEnemy.pause(); - } + inst.pause(); + if (!_song.splitVoiceTracks) + vocals.pause(); + else + { + vocalsPlayer.pause(); + vocalsEnemy.pause(); + } - var daTime:Float = 700 * FlxG.elapsed; + var daTime:Float = 700 * FlxG.elapsed; - if (FlxG.keys.pressed.W) - { - inst.time -= daTime; - } - else - inst.time += daTime; + if (FlxG.keys.pressed.W) + { + inst.time -= daTime; + } + else + inst.time += daTime; - if (!_song.splitVoiceTracks) - vocals.time = inst.time; - else - { - vocalsPlayer.time = inst.time; - vocalsEnemy.time = inst.time; + if (!_song.splitVoiceTracks) + vocals.time = inst.time; + else + { + vocalsPlayer.time = inst.time; + vocalsEnemy.time = inst.time; + } } } - } - else - { - if (FlxG.keys.justPressed.W || FlxG.keys.justPressed.S) + else { - inst.pause(); - if (!_song.splitVoiceTracks) - vocals.pause(); - else + if (FlxG.keys.justPressed.W || FlxG.keys.justPressed.S) { - vocalsPlayer.pause(); - vocalsEnemy.pause(); - } + inst.pause(); + if (!_song.splitVoiceTracks) + vocals.pause(); + else + { + vocalsPlayer.pause(); + vocalsEnemy.pause(); + } - var daTime:Float = Conductor.stepCrochet * 2; + var daTime:Float = Conductor.stepCrochet * 2; - if (FlxG.keys.justPressed.W) - { - inst.time -= daTime; - } - else - inst.time += daTime; + if (FlxG.keys.justPressed.W) + { + inst.time -= daTime; + } + else + inst.time += daTime; - if (!_song.splitVoiceTracks) - vocals.time = inst.time; - else - { - vocalsPlayer.time = inst.time; - vocalsEnemy.time = inst.time; + if (!_song.splitVoiceTracks) + vocals.time = inst.time; + else + { + vocalsPlayer.time = inst.time; + vocalsEnemy.time = inst.time; + } } } } } + _song.bpm = tempBpm; } - _song.bpm = tempBpm; - } - -catch (e) - { - Debug.logError("Error\n" + e); - } - var playedSound:Array = [false, false, false, false]; - var daHitSound:FlxSound; - - curRenderedNotes.forEachAlive(function(note:Note) - { - if (FlxG.save.data.playHitsounds) + catch (e) + { + Debug.logError("Error\n" + e); + } + var playedSound:Array = [false, false, false, false]; + var daHitSound:FlxSound; + curRenderedNotes.forEachAlive(function(note:Note) { - if (note.strumTime <= Conductor.songPosition) + if (FlxG.save.data.playHitsounds) { - if (note.strumTime > lastConductorPos && inst.playing && note.noteData > -1) + if (note.strumTime <= Conductor.songPosition) { - var data:Int = note.noteData % 4; - var noteDataToCheck:Int = note.noteData; - if (noteDataToCheck > -1 && note.mustPress != _song.notes[curSection].mustHitSection) - noteDataToCheck += 4; - if (!playedSound[data]) + if (note.strumTime > lastConductorPos && inst.playing && note.noteData > -1) { - if (FlxG.save.data.hitSound == 0) - { - daHitSound = new FlxSound().loadEmbedded(Paths.sound('hitsounds/snap', 'shared')); - } - else + var data:Int = note.noteData % 4; + var noteDataToCheck:Int = note.noteData; + if (noteDataToCheck > -1 && note.mustPress != _song.notes[curSection].mustHitSection) + noteDataToCheck += 4; + if (!playedSound[data]) { - daHitSound = new FlxSound().loadEmbedded(Paths.sound('hitsounds/${HitSounds.getSoundByID(FlxG.save.data.hitSound).toLowerCase()}', - 'shared')); - } - daHitSound.volume = hitsoundsVol.value; - daHitSound.play().pan = note.noteData < 4 ? -0.3 : 0.3; - playedSound[data] = true; + if (FlxG.save.data.hitSound == 0) + { + daHitSound = new FlxSound().loadEmbedded(Paths.sound('hitsounds/snap', 'shared')); + } + else + { + daHitSound = new FlxSound() + .loadEmbedded(Paths.sound('hitsounds/${HitSounds.getSoundByID(FlxG.save.data.hitSound).toLowerCase()}', 'shared')); + } + daHitSound.volume = hitsoundsVol.value; + daHitSound.play().pan = note.noteData < 4 ? -0.3 : 0.3; + playedSound[data] = true; - data = note.noteData; - if (note.mustPress != _song.notes[curSection].mustHitSection) - { - data += 4; + data = note.noteData; + if (note.mustPress != _song.notes[curSection].mustHitSection) + { + data += 4; + } } } } } - } - }); - lastConductorPos = Conductor.songPosition; - bpmTxt.text = Std.string(FlxMath.roundDecimal(Conductor.songPosition / 1000, 2)) - + " / " - + Std.string(FlxMath.roundDecimal(inst.length / 1000, 2)) - + "\nCur Section: " - + curSection - + "\nCurBeat: " - + HelperFunctions.truncateFloat(curDecimalBeat, 3) - + "\nCurStep: " - + curStep - + "\nZoom: " - + HelperFunctions.truncateFloat(zoomFactor, 2) - + "\nSpeed: " - + HelperFunctions.truncateFloat(speed, 1) - + "\n\nSnap: " - + snap - + "\n" - + (doSnapShit ? "Snap enabled" : "Snap disabled") - + - (FlxG.save.data.showHelp ? "\n\nHelp:\nCtrl-MWheel : Zoom in/out\nShift-Left/Right :\n Change playback speed\nCtrl-Drag Click : Select notes\nCtrl-C : Copy notes\nCtrl-V : Paste notes\nCtrl-Z : Undo\nDelete : Delete selection\nCTRL-Left/Right :\n Change Snap\nHold Shift : Disable Snap\nClick:\n Place notes\nUp/Down :\n Move selected notes 1 step\nShift-Up/Down :\n Move selected notes 1 beat\nSpace: Play Music\nEnter : Preview\n Z/X Change Notetype.\nPress F1 to hide/show this!" : ""); - super.update(elapsed); -} + }); -override function beatHit() -{ - super.beatHit(); + lastConductorPos = Conductor.songPosition; + + bpmTxt.text = Std.string(FlxMath.roundDecimal(Conductor.songPosition / 1000, 2)) + + " / " + + Std.string(FlxMath.roundDecimal(inst.length / 1000, 2)) + + "\nCur Section: " + + curSection + + "\nCurBeat: " + + HelperFunctions.truncateFloat(curDecimalBeat, 3) + + "\nCurStep: " + + curStep + + "\nZoom: " + + HelperFunctions.truncateFloat(zoomFactor, 2) + + "\nSpeed: " + + HelperFunctions.truncateFloat(speed, 1) + + "\n\nSnap: " + + snap + + "\n" + + (doSnapShit ? "Snap enabled" : "Snap disabled") + + + (FlxG.save.data.showHelp ? "\n\nHelp:\nCtrl-MWheel : Zoom in/out\nShift-Left/Right :\n Change playback speed\nCtrl-Drag Click : Select notes\nCtrl-C : Copy notes\nCtrl-V : Paste notes\nCtrl-Z : Undo\nDelete : Delete selection\nCTRL-Left/Right :\n Change Snap\nHold Shift : Disable Snap\nClick:\n Place notes\nUp/Down :\n Move selected notes 1 step\nShift-Up/Down :\n Move selected notes 1 beat\nSpace: Play Music\nEnter : Preview\n Z/X Change Notetype.\nPress F1 to hide/show this!" : ""); + + super.update(elapsed); + } - if (metronome.checked) - FlxG.sound.play(Paths.sound('Metronome_Tick')); -} + override function beatHit() + { + super.beatHit(); -function changeNoteSustain(value:Float):Void -{ - if (curSelectedNote != null) + if (metronome.checked) + FlxG.sound.play(Paths.sound('Metronome_Tick')); + } + + function changeNoteSustain(value:Float):Void { - if (curSelectedNote[2] != null) + if (curSelectedNote != null) { - curSelectedNote[2] += Math.ceil(value); - curSelectedNote[2] = Math.max(curSelectedNote[2], 0); + if (curSelectedNote[2] != null) + { + curSelectedNote[2] += Math.ceil(value); + curSelectedNote[2] = Math.max(curSelectedNote[2], 0); - if (curSelectedNoteObject.noteCharterObject != null) - curRenderedSustains.remove(curSelectedNoteObject.noteCharterObject); + if (curSelectedNoteObject.noteCharterObject != null) + curRenderedSustains.remove(curSelectedNoteObject.noteCharterObject); - remove(curSelectedNoteObject.noteCharterObject); + remove(curSelectedNoteObject.noteCharterObject); - var sustainVis:FlxSprite = new FlxSprite(curSelectedNoteObject.x + (GRID_SIZE * 0.5) - 2, - curSelectedNoteObject.y + GRID_SIZE).makeGraphic(8, - Math.floor((getYfromStrum(curSelectedNoteObject.strumTime + curSelectedNote[2]) * zoomFactor) - curSelectedNoteObject.y)); - curSelectedNoteObject.sustainLength = curSelectedNote[2]; - curSelectedNoteObject.noteCharterObject = sustainVis; + var sustainVis:FlxSprite = new FlxSprite(curSelectedNoteObject.x + (GRID_SIZE * 0.5) - 2, + curSelectedNoteObject.y + GRID_SIZE).makeGraphic(8, + Math.floor((getYfromStrum(curSelectedNoteObject.strumTime + curSelectedNote[2]) * zoomFactor) - curSelectedNoteObject.y)); + curSelectedNoteObject.sustainLength = curSelectedNote[2]; + curSelectedNoteObject.noteCharterObject = sustainVis; - curRenderedSustains.add(sustainVis); + curRenderedSustains.add(sustainVis); + } } - } - updateGrid(); - updateNoteUI(); -} - -function resetSection(songBeginning:Bool = false):Void -{ - inst.pause(); - if (!_song.splitVoiceTracks) - vocals.pause(); - else - { - vocalsPlayer.pause(); - vocalsEnemy.pause(); + updateGrid(); + updateNoteUI(); } - // Basically old shit from changeSection??? - inst.time = 0; - if (!_song.splitVoiceTracks) - vocals.time = inst.time; - else + function resetSection(songBeginning:Bool = false):Void { - vocalsPlayer.time = inst.time; - vocalsEnemy.time = inst.time; - } - - updateGrid(); - if (!songBeginning) - updateSectionUI(); -} + inst.pause(); + if (!_song.splitVoiceTracks) + vocals.pause(); + else + { + vocalsPlayer.pause(); + vocalsEnemy.pause(); + } -function changeSection(sec:Int = 0, ?updateMusic:Bool = true):Void -{ - if (_song.notes[sec] != null) - { - curSection = sec; + // Basically old shit from changeSection??? + inst.time = 0; + if (!_song.splitVoiceTracks) + vocals.time = inst.time; + else + { + vocalsPlayer.time = inst.time; + vocalsEnemy.time = inst.time; + } updateGrid(); + if (!songBeginning) + updateSectionUI(); + } - if (updateMusic) + function changeSection(sec:Int = 0, ?updateMusic:Bool = true):Void + { + if (_song.notes[sec] != null) { - inst.pause(); - inst.time = sectionStartTime(); - if (!_song.splitVoiceTracks) - { - if (vocals != null) - { - vocals.pause(); - vocals.time = inst.time; - } - } - else + curSection = sec; + + updateGrid(); + + if (updateMusic) { - if (vocalsPlayer != null) + inst.pause(); + inst.time = sectionStartTime(); + if (!_song.splitVoiceTracks) { - vocalsPlayer.pause(); - vocalsPlayer.time = inst.time; + if (vocals != null) + { + vocals.pause(); + vocals.time = inst.time; + } } - if (vocalsEnemy != null) + else { - vocalsEnemy.pause(); - vocalsEnemy.time = inst.time; + if (vocalsPlayer != null) + { + vocalsPlayer.pause(); + vocalsPlayer.time = inst.time; + } + if (vocalsEnemy != null) + { + vocalsEnemy.pause(); + vocalsEnemy.time = inst.time; + } } } - } - updateGrid(); - updateSectionUI(); + updateGrid(); + updateSectionUI(); + } } -} - -function copySection(sec:SwagSection) -{ -} - -function updateSectionUI():Void -{ - var sec = getSectionByTime(Conductor.songPosition); - if (sec == null) + function copySection(sec:SwagSection) { - check_mustHitSection.checked = true; - check_CPUAltAnim.checked = false; - check_playerAltAnim.checked = false; - } - else - { - check_mustHitSection.checked = sec.mustHitSection; - check_CPUAltAnim.checked = sec.CPUAltAnim; - check_playerAltAnim.checked = sec.playerAltAnim; } -} - -function updateHeads():Void -{ - var mustHit = check_mustHitSection.checked; - #if FEATURE_FILESYSTEM - var head = (mustHit ? player1.healthIcon : player2.healthIcon); - var i = sectionRenderes.members[curSection]; - function iconUpdate(failsafe:Bool = false):Void + function updateSectionUI():Void { - var sect = _song.notes[curSection]; - var cachedY = i.icon.y; - remove(i.icon); - var sectionicon = new HealthIcon(failsafe ? (mustHit ? 'bf' : 'face') : head).clone(); - sectionicon.x = -95; - sectionicon.y = cachedY; - sectionicon.setGraphicSize(0, 45); - - i.icon = sectionicon; - i.lastUpdated = sect.mustHitSection; - - add(sectionicon); - } + var sec = getSectionByTime(Conductor.songPosition); - // fail-safe - // TODO: Refactor this to use OpenFlAssets. - if (!Paths.fileExists("images/icons/icon-" + head.split("-")[0] + ".png", IMAGE) - && !Paths.fileExists("images/icons/icon-" + head + ".png", IMAGE)) - { - if (i.icon.animation.curAnim == null) - iconUpdate(true); - } - // - else if (i.icon.animation.curAnim.name != head - && i.icon.animation.curAnim.name != head.split("-")[0] - || head == 'bf-pixel' - && i.icon.animation.curAnim.name != 'bf-pixel') - { - if (i.icon.animation.getByName(head) != null) - i.icon.animation.play(head); + if (sec == null) + { + check_mustHitSection.checked = true; + check_CPUAltAnim.checked = false; + check_playerAltAnim.checked = false; + } else - iconUpdate(); + { + check_mustHitSection.checked = sec.mustHitSection; + check_CPUAltAnim.checked = sec.CPUAltAnim; + check_playerAltAnim.checked = sec.playerAltAnim; + } } - #else - leftIcon.animation.play(mustHit ? player1.healthIcon : player2.healthIcon); - rightIcon.animation.play(mustHit ? player2.healthIcon : player1.healthIcon); - #end -} -function updateNoteUI():Void -{ - if (curSelectedNote != null) + function updateHeads():Void { - stepperSusLength.value = curSelectedNote[2]; - if (curSelectedNote[3] != null) - check_naltAnim.checked = curSelectedNote[3]; - else + var mustHit = check_mustHitSection.checked; + #if FEATURE_FILESYSTEM + var head = (mustHit ? player1.healthIcon : player2.healthIcon); + var i = sectionRenderes.members[curSection]; + + function iconUpdate(failsafe:Bool = false):Void { - curSelectedNote[3] = false; - check_naltAnim.checked = false; + var sect = _song.notes[curSection]; + var cachedY = i.icon.y; + remove(i.icon); + var sectionicon = new HealthIcon(failsafe ? (mustHit ? 'bf' : 'face') : head).clone(); + sectionicon.x = -95; + sectionicon.y = cachedY; + sectionicon.setGraphicSize(0, 45); + + i.icon = sectionicon; + i.lastUpdated = sect.mustHitSection; + + add(sectionicon); } - strumTimeInputText.text = '' + curSelectedNote[0]; + // fail-safe + // TODO: Refactor this to use OpenFlAssets. + if (!Paths.fileExists("images/icons/icon-" + head.split("-")[0] + ".png", IMAGE) + && !Paths.fileExists("images/icons/icon-" + head + ".png", IMAGE)) + { + if (i.icon.animation.curAnim == null) + iconUpdate(true); + } + // + else if (i.icon.animation.curAnim.name != head + && i.icon.animation.curAnim.name != head.split("-")[0] + || head == 'bf-pixel' + && i.icon.animation.curAnim.name != 'bf-pixel') + { + if (i.icon.animation.getByName(head) != null) + i.icon.animation.play(head); + else + iconUpdate(); + } + #else + leftIcon.animation.play(mustHit ? player1.healthIcon : player2.healthIcon); + rightIcon.animation.play(mustHit ? player2.healthIcon : player1.healthIcon); + #end } -} -function updateGrid():Void -{ - // curRenderedNotes.forEachAlive(function(spr:Note) spr.destroy()); - curRenderedNotes.clear(); - // curRenderedSustains.forEachAlive(function(spr:FlxSprite) spr.destroy()); - curRenderedSustains.clear(); + function updateNoteUI():Void + { + if (curSelectedNote != null) + { + stepperSusLength.value = curSelectedNote[2]; + if (curSelectedNote[3] != null) + check_naltAnim.checked = curSelectedNote[3]; + else + { + curSelectedNote[3] = false; + check_naltAnim.checked = false; + } - var currentSection = 0; + strumTimeInputText.text = '' + curSelectedNote[0]; + } + } - for (section in _song.notes) + function updateGrid():Void { - if (section != null) - for (i in section.sectionNotes) - { - var seg = TimingStruct.getTimingAtTimestamp(i[0]); - var daNoteInfo = i[1]; - var daStrumTime = i[0]; - var daSus = i[2]; - var daShit = i[5]; - var daBeat = TimingStruct.getBeatFromTime(daStrumTime); + // curRenderedNotes.forEachAlive(function(spr:Note) spr.destroy()); + curRenderedNotes.clear(); + // curRenderedSustains.forEachAlive(function(spr:FlxSprite) spr.destroy()); + curRenderedSustains.clear(); + + var currentSection = 0; + + for (section in _song.notes) + { + if (section != null) + for (i in section.sectionNotes) + { + var seg = TimingStruct.getTimingAtTimestamp(i[0]); + var daNoteInfo = i[1]; + var daStrumTime = i[0]; + var daSus = i[2]; + var daShit = i[5]; + var daBeat = TimingStruct.getBeatFromTime(daStrumTime); - var note:Note = new Note(daStrumTime, daNoteInfo % 4, null, false, true, true, i[3], daBeat, daShit); - note.rawNoteData = daNoteInfo; - note.sustainLength = daSus; - note.strumTime = daStrumTime; - note.setGraphicSize(Math.floor(GRID_SIZE), Math.floor(GRID_SIZE)); - note.updateHitbox(); - note.x = Math.floor(daNoteInfo * GRID_SIZE); + var note:Note = new Note(daStrumTime, daNoteInfo % 4, null, false, true, true, i[3], daBeat, daShit); + note.rawNoteData = daNoteInfo; + note.sustainLength = daSus; + note.strumTime = daStrumTime; + note.setGraphicSize(Math.floor(GRID_SIZE), Math.floor(GRID_SIZE)); + note.updateHitbox(); + note.x = Math.floor(daNoteInfo * GRID_SIZE); - note.y = Math.floor(getYfromStrum(daStrumTime) * zoomFactor); + note.y = Math.floor(getYfromStrum(daStrumTime) * zoomFactor); - if (curSelectedNote != null) - if (curSelectedNote[0] == note.strumTime) - lastNote = note; + if (curSelectedNote != null) + if (curSelectedNote[0] == note.strumTime) + lastNote = note; - curRenderedNotes.add(note); + curRenderedNotes.add(note); - var stepCrochet = (((60 / seg.bpm) * 1000) / 4); + var stepCrochet = (((60 / seg.bpm) * 1000) / 4); - if (daSus > 0) - { - var sustainVis:FlxSprite = new FlxSprite(note.x + (GRID_SIZE * 0.5) - 2, - note.y + GRID_SIZE).makeGraphic(8, Math.floor((getYfromStrum(note.strumTime + note.sustainLength) * zoomFactor) - note.y)); + if (daSus > 0) + { + var sustainVis:FlxSprite = new FlxSprite(note.x + (GRID_SIZE * 0.5) - 2, + note.y + GRID_SIZE).makeGraphic(8, Math.floor((getYfromStrum(note.strumTime + note.sustainLength) * zoomFactor) - note.y)); - note.noteCharterObject = sustainVis; + note.noteCharterObject = sustainVis; - curRenderedSustains.add(sustainVis); + curRenderedSustains.add(sustainVis); + } } + currentSection++; + } + } + + private function addSection(lengthInSteps:Int = 16):Void + { + var daPos:Float = 0; + var start:Float = 0; + + var bpm = _song.bpm; + for (i in 0...curSection) + { + for (ii in TimingStruct.AllTimings) + { + var data = TimingStruct.getTimingAtTimestamp(start); + if ((data != null ? data.bpm : _song.bpm) != bpm && bpm != ii.bpm) + bpm = ii.bpm; } - currentSection++; + start += (4 * (60 / bpm)) * 1000; + } + + var sec:SwagSection = { + startTime: daPos, + endTime: Math.POSITIVE_INFINITY, + lengthInSteps: lengthInSteps, + bpm: _song.bpm, + changeBPM: false, + mustHitSection: true, + sectionNotes: [], + typeOfSection: 0, + altAnim: false, + CPUAltAnim: false, + playerAltAnim: false + }; + + _song.notes.push(sec); } -} -private function addSection(lengthInSteps:Int = 16):Void -{ - var daPos:Float = 0; - var start:Float = 0; + function selectNote(note:Note):Void + { + var swagNum:Int = 0; - var bpm = _song.bpm; - for (i in 0...curSection) + for (sec in _song.notes) + { + swagNum = 0; + if (sec != null) + for (i in sec.sectionNotes) + { + if (i[0] == note.strumTime && i[1] == note.rawNoteData) + { + curSelectedNote = sec.sectionNotes[swagNum]; + if (curSelectedNoteObject != null) + curSelectedNoteObject.charterSelected = false; + + curSelectedNoteObject = note; + if (!note.charterSelected) + { + var box = new ChartingBox(note.x, note.y, note); + box.connectedNoteData = i; + selectedBoxes.add(box); + note.charterSelected = true; + curSelectedNoteObject.charterSelected = true; + } + } + swagNum += 1; + } + } + + updateNoteUI(); + } + + function deleteNote(note:Note):Void { - for (ii in TimingStruct.AllTimings) + while (selectedBoxes.members.length != 0) { - var data = TimingStruct.getTimingAtTimestamp(start); - if ((data != null ? data.bpm : _song.bpm) != bpm && bpm != ii.bpm) - bpm = ii.bpm; + selectedBoxes.members[0].connectedNote.charterSelected = false; + selectedBoxes.members[0].destroy(); + selectedBoxes.members.remove(selectedBoxes.members[0]); + selectedBoxes.clear(); } - start += (4 * (60 / bpm)) * 1000; - } - var sec:SwagSection = { - startTime: daPos, - endTime: Math.POSITIVE_INFINITY, - lengthInSteps: lengthInSteps, - bpm: _song.bpm, - changeBPM: false, - mustHitSection: true, - sectionNotes: [], - typeOfSection: 0, - altAnim: false, - CPUAltAnim: false, - playerAltAnim: false - }; - - _song.notes.push(sec); -} + lastNote = note; -function selectNote(note:Note):Void -{ - var swagNum:Int = 0; + var section = getSectionByTime(note.strumTime); - for (sec in _song.notes) - { - swagNum = 0; - if (sec != null) - for (i in sec.sectionNotes) + var found = false; + + if (section != null) + { + for (i in section.sectionNotes) { if (i[0] == note.strumTime && i[1] == note.rawNoteData) { - curSelectedNote = sec.sectionNotes[swagNum]; - if (curSelectedNoteObject != null) - curSelectedNoteObject.charterSelected = false; - - curSelectedNoteObject = note; - if (!note.charterSelected) - { - var box = new ChartingBox(note.x, note.y, note); - box.connectedNoteData = i; - selectedBoxes.add(box); - note.charterSelected = true; - curSelectedNoteObject.charterSelected = true; - } + section.sectionNotes.remove(i); + found = true; } - swagNum += 1; } - } - - updateNoteUI(); -} - -function deleteNote(note:Note):Void -{ - while (selectedBoxes.members.length != 0) - { - selectedBoxes.members[0].connectedNote.charterSelected = false; - selectedBoxes.members[0].destroy(); - selectedBoxes.members.remove(selectedBoxes.members[0]); - selectedBoxes.clear(); - } + } - lastNote = note; + if (!found) // backup check + { + for (i in _song.notes) + { + for (n in i.sectionNotes) + if (n[0] == note.strumTime && n[1] == note.rawNoteData) + i.sectionNotes.remove(n); + } + } - var section = getSectionByTime(note.strumTime); + curRenderedNotes.remove(note); - var found = false; + if (note.sustainLength > 0) + curRenderedSustains.remove(note.noteCharterObject); - if (section != null) - { - for (i in section.sectionNotes) + for (i in 0...selectedBoxes.members.length) { - if (i[0] == note.strumTime && i[1] == note.rawNoteData) + var box = selectedBoxes.members[i]; + if (box.connectedNote == note) { - section.sectionNotes.remove(i); - found = true; + selectedBoxes.members.remove(box); + box.destroy(); + return; } } + + // updateNoteUI(); } - if (!found) // backup check + function clearSection():Void { - for (i in _song.notes) + while (selectedBoxes.members.length != 0) { - for (n in i.sectionNotes) - if (n[0] == note.strumTime && n[1] == note.rawNoteData) - i.sectionNotes.remove(n); + selectedBoxes.members[0].connectedNote.charterSelected = false; + selectedBoxes.members[0].destroy(); + selectedBoxes.members.remove(selectedBoxes.members[0]); + selectedBoxes.clear(); } - } - curRenderedNotes.remove(note); - - if (note.sustainLength > 0) - curRenderedSustains.remove(note.noteCharterObject); + _song.notes[curSection].sectionNotes = []; + updateGrid(); + updateNoteUI(); + } - for (i in 0...selectedBoxes.members.length) + function clearSong():Void { - var box = selectedBoxes.members[i]; - if (box.connectedNote == note) + for (daSection in 0..._song.notes.length) { - selectedBoxes.members.remove(box); - box.destroy(); - return; + _song.notes[daSection].sectionNotes = []; } - } - // updateNoteUI(); -} - -function clearSection():Void -{ - while (selectedBoxes.members.length != 0) - { - selectedBoxes.members[0].connectedNote.charterSelected = false; - selectedBoxes.members[0].destroy(); - selectedBoxes.members.remove(selectedBoxes.members[0]); - selectedBoxes.clear(); + updateGrid(); } - _song.notes[curSection].sectionNotes = []; - updateGrid(); - updateNoteUI(); -} - -function clearSong():Void -{ - for (daSection in 0..._song.notes.length) + private function newSection(lengthInSteps:Int = 16, mustHitSection:Bool = false, CPUAltAnim:Bool = true, playerAltAnim:Bool = true):SwagSection { - _song.notes[daSection].sectionNotes = []; - } - - updateGrid(); -} - -private function newSection(lengthInSteps:Int = 16, mustHitSection:Bool = false, CPUAltAnim:Bool = true, playerAltAnim:Bool = true):SwagSection -{ - var daPos:Float = 0; - - var currentSeg = TimingStruct.AllTimings[TimingStruct.AllTimings.length - 1]; - - var currentBeat = 4; + var daPos:Float = 0; - for (i in _song.notes) - currentBeat += 4; + var currentSeg = TimingStruct.AllTimings[TimingStruct.AllTimings.length - 1]; - if (currentSeg == null) - return null; + var currentBeat = 4; - var start:Float = (currentBeat - currentSeg.startBeat) / (currentSeg.bpm / 60); - - daPos = (currentSeg.startTime + start) * 1000; - - var sec:SwagSection = { - startTime: daPos, - endTime: Math.POSITIVE_INFINITY, - lengthInSteps: lengthInSteps, - bpm: _song.bpm, - changeBPM: false, - mustHitSection: mustHitSection, - sectionNotes: [], - typeOfSection: 0, - altAnim: false, - CPUAltAnim: CPUAltAnim, - playerAltAnim: playerAltAnim - }; - - return sec; -} + for (i in _song.notes) + currentBeat += 4; + + if (currentSeg == null) + return null; + + var start:Float = (currentBeat - currentSeg.startBeat) / (currentSeg.bpm / 60); + + daPos = (currentSeg.startTime + start) * 1000; + + var sec:SwagSection = { + startTime: daPos, + endTime: Math.POSITIVE_INFINITY, + lengthInSteps: lengthInSteps, + bpm: _song.bpm, + changeBPM: false, + mustHitSection: mustHitSection, + sectionNotes: [], + typeOfSection: 0, + altAnim: false, + CPUAltAnim: CPUAltAnim, + playerAltAnim: playerAltAnim + }; -/* - function recalculateAllSectionTimes() - { - var savedNotes:Array = []; + return sec; + } - for (i in 0..._song.notes.length) // loops through sections + /* + function recalculateAllSectionTimes() { - var section = _song.notes[i]; + var savedNotes:Array = []; - var currentBeat = 4 * i; + for (i in 0..._song.notes.length) // loops through sections + { + var section = _song.notes[i]; - var currentSeg = TimingStruct.getTimingAtBeat(currentBeat); + var currentBeat = 4 * i; - if (currentSeg == null) - return; + var currentSeg = TimingStruct.getTimingAtBeat(currentBeat); - var start:Float = (currentBeat - currentSeg.startBeat) / (currentSeg.bpm / 60); + if (currentSeg == null) + return; - section.startTime = (currentSeg.startTime + start) * 1000; + var start:Float = (currentBeat - currentSeg.startBeat) / (currentSeg.bpm / 60); - if (i != 0) - _song.notes[i - 1].endTime = section.startTime; - section.endTime = Math.POSITIVE_INFINITY; - } - } - */ -function shiftNotes(measure:Int = 0, step:Int = 0, ms:Int = 0):Void -{ - var newSong = []; + section.startTime = (currentSeg.startTime + start) * 1000; - var millisecadd = (((measure * 4) + step / 4) * (60000 / currentBPM)) + ms; - var totaladdsection = Std.int((millisecadd / (60000 / currentBPM) / 4)); - if (millisecadd > 0) + if (i != 0) + _song.notes[i - 1].endTime = section.startTime; + section.endTime = Math.POSITIVE_INFINITY; + } + } + */ + function shiftNotes(measure:Int = 0, step:Int = 0, ms:Int = 0):Void { - for (i in 0...totaladdsection) + var newSong = []; + + var millisecadd = (((measure * 4) + step / 4) * (60000 / currentBPM)) + ms; + var totaladdsection = Std.int((millisecadd / (60000 / currentBPM) / 4)); + if (millisecadd > 0) { - newSong.unshift(newSection()); + for (i in 0...totaladdsection) + { + newSong.unshift(newSection()); + } + } + for (daSection1 in 0..._song.notes.length) + { + newSong.push(newSection(16, _song.notes[daSection1].mustHitSection, _song.notes[daSection1].CPUAltAnim, _song.notes[daSection1].playerAltAnim)); } - } - for (daSection1 in 0..._song.notes.length) - { - newSong.push(newSection(16, _song.notes[daSection1].mustHitSection, _song.notes[daSection1].CPUAltAnim, _song.notes[daSection1].playerAltAnim)); - } - for (daSection in 0...(_song.notes.length)) - { - var aimtosetsection = daSection + Std.int((totaladdsection)); - if (aimtosetsection < 0) - aimtosetsection = 0; - newSong[aimtosetsection].mustHitSection = _song.notes[daSection].mustHitSection; - updateHeads(); - newSong[aimtosetsection].CPUAltAnim = _song.notes[daSection].CPUAltAnim; - newSong[aimtosetsection].playerAltAnim = _song.notes[daSection].playerAltAnim; - for (daNote in 0...(_song.notes[daSection].sectionNotes.length)) + for (daSection in 0...(_song.notes.length)) { - var newtiming = _song.notes[daSection].sectionNotes[daNote][0] + millisecadd; - if (newtiming < 0) + var aimtosetsection = daSection + Std.int((totaladdsection)); + if (aimtosetsection < 0) + aimtosetsection = 0; + newSong[aimtosetsection].mustHitSection = _song.notes[daSection].mustHitSection; + updateHeads(); + newSong[aimtosetsection].CPUAltAnim = _song.notes[daSection].CPUAltAnim; + newSong[aimtosetsection].playerAltAnim = _song.notes[daSection].playerAltAnim; + for (daNote in 0...(_song.notes[daSection].sectionNotes.length)) { - newtiming = 0; + var newtiming = _song.notes[daSection].sectionNotes[daNote][0] + millisecadd; + if (newtiming < 0) + { + newtiming = 0; + } + var futureSection = Math.floor(newtiming / 4 / (60000 / currentBPM)); + _song.notes[daSection].sectionNotes[daNote][0] = newtiming; + newSong[futureSection].sectionNotes.push(_song.notes[daSection].sectionNotes[daNote]); } - var futureSection = Math.floor(newtiming / 4 / (60000 / currentBPM)); - _song.notes[daSection].sectionNotes[daNote][0] = newtiming; - newSong[futureSection].sectionNotes.push(_song.notes[daSection].sectionNotes[daNote]); } + _song.notes = newSong; + recalculateAllSectionTimes(); + updateGrid(); + updateSectionUI(); + updateNoteUI(); } - _song.notes = newSong; - recalculateAllSectionTimes(); - updateGrid(); - updateSectionUI(); - updateNoteUI(); -} - -/* - public function getSectionByTime(ms:Float, ?changeCurSectionIndex:Bool = false):SwagSection - { - var index = 0; - for (i in _song.notes) + /* + public function getSectionByTime(ms:Float, ?changeCurSectionIndex:Bool = false):SwagSection { - if (ms >= i.startTime && ms < i.endTime) + var index = 0; + + for (i in _song.notes) { - if (changeCurSectionIndex) - curSection = index; - return i; + if (ms >= i.startTime && ms < i.endTime) + { + if (changeCurSectionIndex) + curSection = index; + return i; + } + index++; } - index++; - } - return null; - } - */ -public function getNoteByTime(ms:Float) -{ - for (i in _song.notes) + return null; + } + */ + public function getNoteByTime(ms:Float) { - for (n in i.sectionNotes) - if (n[0] == ms) - return i; + for (i in _song.notes) + { + for (n in i.sectionNotes) + if (n[0] == ms) + return i; + } + return null; } - return null; -} -public var curSelectedNoteObject:Note = null; + public var curSelectedNoteObject:Note = null; -private function addNote(?n:Note):Void -{ - var strum = getStrumTime(dummyArrow.y) / zoomFactor; - - var section = getSectionByTime(strum); - - if (section == null) - return; - var noteStrum = strum; - var noteData = Math.floor(FlxG.mouse.x / GRID_SIZE); - var noteSus = 0; - var noteShit = shits[this.noteShit]; - // you can change this to `var noteShit = noteShitDropDown.selectedLabel;` for using the dropdown but I dont like the dropdown, its faster to press Z and X. - if (FlxG.save.data.gen) - Debug.logTrace("Adding note with " + Std.int(strum) + " from dummyArrow with data " + noteData + " With A Notetype Of " + noteShit); - - if (n != null) - section.sectionNotes.push([ - n.strumTime, - n.noteData, - n.sustainLength, - false, - TimingStruct.getBeatFromTime(n.strumTime), - n.noteShit - ]); - else - section.sectionNotes.push([ - noteStrum, - noteData, - noteSus, - false, - TimingStruct.getBeatFromTime(noteStrum), - noteShit - ]); - - var thingy = section.sectionNotes[section.sectionNotes.length - 1]; - - curSelectedNote = thingy; - - var seg = TimingStruct.getTimingAtTimestamp(noteStrum); - - if (n == null) + private function addNote(?n:Note):Void { - var note:Note = new Note(noteStrum, noteData % 4, null, false, true, true, null, TimingStruct.getBeatFromTime(noteStrum), noteShit); - note.rawNoteData = noteData; - note.sustainLength = noteSus; - note.setGraphicSize(Math.floor(GRID_SIZE), Math.floor(GRID_SIZE)); - note.updateHitbox(); - note.x = Math.floor(noteData * GRID_SIZE); + var strum = getStrumTime(dummyArrow.y) / zoomFactor; - if (curSelectedNoteObject != null) - curSelectedNoteObject.charterSelected = false; - curSelectedNoteObject = note; + var section = getSectionByTime(strum); - while (selectedBoxes.members.length != 0) + if (section == null) + return; + var noteStrum = strum; + var noteData = Math.floor(FlxG.mouse.x / GRID_SIZE); + var noteSus = 0; + var noteShit = shits[this.noteShit]; + // you can change this to `var noteShit = noteShitDropDown.selectedLabel;` for using the dropdown but I dont like the dropdown, its faster to press Z and X. + if (FlxG.save.data.gen) + Debug.logTrace("Adding note with " + Std.int(strum) + " from dummyArrow with data " + noteData + " With A Notetype Of " + noteShit); + + if (n != null) + section.sectionNotes.push([ + n.strumTime, + n.noteData, + n.sustainLength, + false, + TimingStruct.getBeatFromTime(n.strumTime), + n.noteShit + ]); + else + section.sectionNotes.push([ + noteStrum, + noteData, + noteSus, + false, + TimingStruct.getBeatFromTime(noteStrum), + noteShit + ]); + + var thingy = section.sectionNotes[section.sectionNotes.length - 1]; + + curSelectedNote = thingy; + + var seg = TimingStruct.getTimingAtTimestamp(noteStrum); + + if (n == null) { - selectedBoxes.members[0].connectedNote.charterSelected = false; - selectedBoxes.members[0].destroy(); - selectedBoxes.members.remove(selectedBoxes.members[0]); - } + var note:Note = new Note(noteStrum, noteData % 4, null, false, true, true, null, TimingStruct.getBeatFromTime(noteStrum), noteShit); + note.rawNoteData = noteData; + note.sustainLength = noteSus; + note.setGraphicSize(Math.floor(GRID_SIZE), Math.floor(GRID_SIZE)); + note.updateHitbox(); + note.x = Math.floor(noteData * GRID_SIZE); - curSelectedNoteObject.charterSelected = true; + if (curSelectedNoteObject != null) + curSelectedNoteObject.charterSelected = false; + curSelectedNoteObject = note; - note.y = Math.floor(getYfromStrum(noteStrum) * zoomFactor); + while (selectedBoxes.members.length != 0) + { + selectedBoxes.members[0].connectedNote.charterSelected = false; + selectedBoxes.members[0].destroy(); + selectedBoxes.members.remove(selectedBoxes.members[0]); + } - var box = new ChartingBox(note.x, note.y, note); - box.connectedNoteData = thingy; - selectedBoxes.add(box); + curSelectedNoteObject.charterSelected = true; - curRenderedNotes.add(note); - } - else - { - var note:Note = new Note(n.strumTime, n.noteData % 4, null, false, true, true, n.isAlt, TimingStruct.getBeatFromTime(n.strumTime), noteShit); - note.beat = TimingStruct.getBeatFromTime(n.strumTime); - note.rawNoteData = n.noteData; - note.sustainLength = noteSus; - note.setGraphicSize(Math.floor(GRID_SIZE), Math.floor(GRID_SIZE)); - note.updateHitbox(); - note.x = Math.floor(n.noteData * GRID_SIZE); - - if (curSelectedNoteObject != null) - curSelectedNoteObject.charterSelected = false; - curSelectedNoteObject = note; + note.y = Math.floor(getYfromStrum(noteStrum) * zoomFactor); - while (selectedBoxes.members.length != 0) - { - selectedBoxes.members[0].connectedNote.charterSelected = false; - selectedBoxes.members[0].destroy(); - selectedBoxes.members.remove(selectedBoxes.members[0]); - } + var box = new ChartingBox(note.x, note.y, note); + box.connectedNoteData = thingy; + selectedBoxes.add(box); - var box = new ChartingBox(note.x, note.y, note); - box.connectedNoteData = thingy; - selectedBoxes.add(box); + curRenderedNotes.add(note); + } + else + { + var note:Note = new Note(n.strumTime, n.noteData % 4, null, false, true, true, n.isAlt, TimingStruct.getBeatFromTime(n.strumTime), noteShit); + note.beat = TimingStruct.getBeatFromTime(n.strumTime); + note.rawNoteData = n.noteData; + note.sustainLength = noteSus; + note.setGraphicSize(Math.floor(GRID_SIZE), Math.floor(GRID_SIZE)); + note.updateHitbox(); + note.x = Math.floor(n.noteData * GRID_SIZE); - curSelectedNoteObject.charterSelected = true; + if (curSelectedNoteObject != null) + curSelectedNoteObject.charterSelected = false; + curSelectedNoteObject = note; - note.y = Math.floor(getYfromStrum(n.strumTime) * zoomFactor); + while (selectedBoxes.members.length != 0) + { + selectedBoxes.members[0].connectedNote.charterSelected = false; + selectedBoxes.members[0].destroy(); + selectedBoxes.members.remove(selectedBoxes.members[0]); + } - curRenderedNotes.add(note); - } + var box = new ChartingBox(note.x, note.y, note); + box.connectedNoteData = thingy; + selectedBoxes.add(box); - updateNoteUI(); + curSelectedNoteObject.charterSelected = true; - autosaveSong(); -} + note.y = Math.floor(getYfromStrum(n.strumTime) * zoomFactor); -function getStrumTime(yPos:Float):Float -{ - return FlxMath.remapToRange(yPos, 0, lengthInSteps, 0, lengthInSteps); -} + curRenderedNotes.add(note); + } -function getYfromStrum(strumTime:Float):Float -{ - return FlxMath.remapToRange(strumTime, 0, lengthInSteps, 0, lengthInSteps); -} + updateNoteUI(); -private var daSpacing:Float = 0.3; + autosaveSong(); + } -function getNotes():Array -{ - var noteData:Array = []; + function getStrumTime(yPos:Float):Float + { + return FlxMath.remapToRange(yPos, 0, lengthInSteps, 0, lengthInSteps); + } - for (i in _song.notes) + function getYfromStrum(strumTime:Float):Float { - noteData.push(i.sectionNotes); + return FlxMath.remapToRange(strumTime, 0, lengthInSteps, 0, lengthInSteps); } - return noteData; -} + private var daSpacing:Float = 0.3; -function loadJson(songId:String, diff:String):Void -{ - try + function getNotes():Array { - PlayState.storyDifficulty = CoolUtil.difficultyArray.indexOf(diff); - PlayState.SONG = Song.loadFromJson(songId, CoolUtil.getSuffixFromDiff(diff)); + var noteData:Array = []; - LoadingState.loadAndSwitchState(new ChartingState()); + for (i in _song.notes) + { + noteData.push(i.sectionNotes); + } + + return noteData; } - catch (e) + + function loadJson(songId:String, diff:String):Void { - Debug.logError('Make Sure You Have A Valid JSON To Load. Error: $e'); - return; + try + { + PlayState.storyDifficulty = CoolUtil.difficultyArray.indexOf(diff); + PlayState.SONG = Song.loadFromJson(songId, CoolUtil.getSuffixFromDiff(diff)); + + LoadingState.loadAndSwitchState(new ChartingState()); + } + catch (e) + { + Debug.logError('Make Sure You Have A Valid JSON To Load. Error: $e'); + return; + } } -} -function updateNotetypeText() -{ - switch (noteShit) + function updateNotetypeText() { - case 0: - notename = "Normal"; - case 1: - notename = "Hurt"; - case 2: - notename = "Must Press"; + switch (noteShit) + { + case 0: + notename = "Normal"; + case 1: + notename = "Hurt"; + case 2: + notename = "Must Press"; + } + notetypetext.text = "Note Type: " + notename; } - notetypetext.text = "Note Type: " + notename; -} -function cleanObjects() -{ - remove(leftIcon); - remove(rightIcon); + function cleanObjects() + { + remove(leftIcon); + remove(rightIcon); - leftIcon.kill(); - leftIcon.destroy(); + leftIcon.kill(); + leftIcon.destroy(); - rightIcon.kill(); - rightIcon.destroy(); + rightIcon.kill(); + rightIcon.destroy(); - player1 = null; - player2 = null; + player1 = null; + player2 = null; - var toRemove = []; + var toRemove = []; - for (i in _song.notes) - { - if (i.startTime > inst.length) - toRemove.push(i); + for (i in _song.notes) + { + if (i.startTime > inst.length) + toRemove.push(i); + } + + for (i in toRemove) + _song.notes.remove(i); } - for (i in toRemove) - _song.notes.remove(i); -} + override function destroy() + { + curRenderedNotes.forEachAlive(function(spr:Note) spr.destroy()); + curRenderedNotes.clear(); + curRenderedSustains.forEachAlive(function(spr:FlxSprite) spr.destroy()); + curRenderedSustains.clear(); + sectionRenderes.forEachAlive(function(huh:SectionRender) huh.destroy()); + sectionRenderes.clear(); + selectedBoxes.forEachAlive(function(huh:ChartingBox) huh.destroy()); + selectedBoxes.clear(); -override function destroy() -{ - curRenderedNotes.forEachAlive(function(spr:Note) spr.destroy()); - curRenderedNotes.clear(); - curRenderedSustains.forEachAlive(function(spr:FlxSprite) spr.destroy()); - curRenderedSustains.clear(); - sectionRenderes.forEachAlive(function(huh:SectionRender) huh.destroy()); - sectionRenderes.clear(); - selectedBoxes.forEachAlive(function(huh:ChartingBox) huh.destroy()); - selectedBoxes.clear(); - - cleanObjects(); - - super.destroy(); -} + cleanObjects(); -private function saveLevel() -{ - for (i in _song.notes) - { - if (i.startTime > inst.length) - _song.notes.remove(i); + super.destroy(); } - var json = { - "song": _song - }; + private function saveLevel() + { + for (i in _song.notes) + { + if (i.startTime > inst.length) + _song.notes.remove(i); + } + + var json = { + "song": _song + }; - var data:String = Json.stringify(json, null, " "); + var data:String = Json.stringify(json, null, " "); - if ((data != null) && (data.length > 0)) - { - _file = new FileReference(); - _file.addEventListener(Event.COMPLETE, onSaveComplete); - _file.addEventListener(Event.CANCEL, onSaveCancel); - _file.addEventListener(IOErrorEvent.IO_ERROR, onSaveError); - _file.save(data.trim(), _song.songId.toLowerCase() + CoolUtil.getSuffixFromDiff(curDiff) + ".json"); + if ((data != null) && (data.length > 0)) + { + _file = new FileReference(); + _file.addEventListener(Event.COMPLETE, onSaveComplete); + _file.addEventListener(Event.CANCEL, onSaveCancel); + _file.addEventListener(IOErrorEvent.IO_ERROR, onSaveError); + _file.save(data.trim(), _song.songId.toLowerCase() + CoolUtil.getSuffixFromDiff(curDiff) + ".json"); + } } -} -function autosaveSong():Void -{ - if (FlxG.save.data.autoSaving) + function autosaveSong():Void { - FlxG.save.data.autosave = Json.stringify({ - "song": _song, - }); + if (FlxG.save.data.autoSaving) + { + FlxG.save.data.autosave = Json.stringify({ + "song": _song, + }); - trace('Chart Saved'); - FlxG.save.flush(); + trace('Chart Saved'); + FlxG.save.flush(); + } + else + { + trace('You Have Auto Saving Disabled.'); + } } - else + + function loadAutosave():Void { - trace('You Have Auto Saving Disabled.'); - } -} + var autoSaveData = Json.parse(FlxG.save.data.autosave); -function loadAutosave():Void -{ - var autoSaveData = Json.parse(FlxG.save.data.autosave); + var json = { + "song": _song + }; - var json = { - "song": _song - }; + var data:String = Json.stringify(json, null, " "); - var data:String = Json.stringify(json, null, " "); + var data:SongData = cast autoSaveData; + var meta:SongMeta = {}; + var name:String = data.songId; + if (autoSaveData.song != null) + { + meta = autoSaveData.songMeta != null ? cast autoSaveData.songMeta : {}; + } - var data:SongData = cast autoSaveData; - var meta:SongMeta = {}; - var name:String = data.songId; - if (autoSaveData.song != null) - { - meta = autoSaveData.songMeta != null ? cast autoSaveData.songMeta : {}; + PlayState.SONG = Song.parseJSONshit(data.songId, data, meta); + for (i in _song.notes) + { + if (i.startTime > inst.length) + _song.notes.remove(i); + } + LoadingState.loadAndSwitchState(new ChartingState()); + clean(); } - PlayState.SONG = Song.parseJSONshit(data.songId, data, meta); - for (i in _song.notes) + function onSaveComplete(_):Void { - if (i.startTime > inst.length) - _song.notes.remove(i); + _file.removeEventListener(Event.COMPLETE, onSaveComplete); + _file.removeEventListener(Event.CANCEL, onSaveCancel); + _file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError); + _file = null; + FlxG.log.notice("Successfully saved LEVEL DATA."); } - LoadingState.loadAndSwitchState(new ChartingState()); - clean(); -} - -function onSaveComplete(_):Void -{ - _file.removeEventListener(Event.COMPLETE, onSaveComplete); - _file.removeEventListener(Event.CANCEL, onSaveCancel); - _file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError); - _file = null; - FlxG.log.notice("Successfully saved LEVEL DATA."); -} -/** - * Called when the save file dialog is cancelled. - */ -function onSaveCancel(_):Void -{ - _file.removeEventListener(Event.COMPLETE, onSaveComplete); - _file.removeEventListener(Event.CANCEL, onSaveCancel); - _file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError); - _file = null; -} + /** + * Called when the save file dialog is cancelled. + */ + function onSaveCancel(_):Void + { + _file.removeEventListener(Event.COMPLETE, onSaveComplete); + _file.removeEventListener(Event.CANCEL, onSaveCancel); + _file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError); + _file = null; + } -/** - * Called if there is an error while saving the gameplay recording. - */ -function onSaveError(_):Void -{ - _file.removeEventListener(Event.COMPLETE, onSaveComplete); - _file.removeEventListener(Event.CANCEL, onSaveCancel); - _file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError); - _file = null; - FlxG.log.error("Problem saving Level data"); -} + /** + * Called if there is an error while saving the gameplay recording. + */ + function onSaveError(_):Void + { + _file.removeEventListener(Event.COMPLETE, onSaveComplete); + _file.removeEventListener(Event.CANCEL, onSaveCancel); + _file.removeEventListener(IOErrorEvent.IO_ERROR, onSaveError); + _file = null; + FlxG.log.error("Problem saving Level data"); + } -function getSectionSteps(?section:Null = null) -{ - if (section == null) - section = curSection; - var val:Null = null; + function getSectionSteps(?section:Null = null) + { + if (section == null) + section = curSection; + var val:Null = null; - if (_song.notes[section] != null) - val = _song.notes[section].lengthInSteps; - return val != null ? val : 16; -} + if (_song.notes[section] != null) + val = _song.notes[section].lengthInSteps; + return val != null ? val : 16; + } }