2020-10-10 02:39:52 +00:00
|
|
|
package;
|
|
|
|
|
2021-03-02 04:00:02 +00:00
|
|
|
import Conductor.BPMChangeEvent;
|
2020-10-30 03:06:52 +00:00
|
|
|
import Section.SwagSection;
|
2020-10-24 09:19:13 +00:00
|
|
|
import Song.SwagSong;
|
2020-10-10 03:22:07 +00:00
|
|
|
import flixel.FlxG;
|
2020-10-10 09:28:44 +00:00
|
|
|
import flixel.FlxSprite;
|
2020-10-13 05:18:50 +00:00
|
|
|
import flixel.addons.display.FlxGridOverlay;
|
2020-10-14 08:18:19 +00:00
|
|
|
import flixel.addons.ui.FlxInputText;
|
2020-10-12 03:52:21 +00:00
|
|
|
import flixel.addons.ui.FlxUI9SliceSprite;
|
2020-10-14 08:18:19 +00:00
|
|
|
import flixel.addons.ui.FlxUI;
|
2020-10-12 03:52:21 +00:00
|
|
|
import flixel.addons.ui.FlxUICheckBox;
|
2020-10-19 00:59:53 +00:00
|
|
|
import flixel.addons.ui.FlxUIDropDownMenu;
|
2020-10-14 08:18:19 +00:00
|
|
|
import flixel.addons.ui.FlxUIInputText;
|
2020-10-16 04:22:13 +00:00
|
|
|
import flixel.addons.ui.FlxUINumericStepper;
|
2020-10-14 08:18:19 +00:00
|
|
|
import flixel.addons.ui.FlxUITabMenu;
|
2020-10-13 03:08:08 +00:00
|
|
|
import flixel.addons.ui.FlxUITooltip.FlxUITooltipStyle;
|
2020-10-10 04:22:26 +00:00
|
|
|
import flixel.group.FlxGroup.FlxTypedGroup;
|
2020-10-12 03:52:21 +00:00
|
|
|
import flixel.group.FlxGroup;
|
2020-10-13 05:18:50 +00:00
|
|
|
import flixel.math.FlxMath;
|
2020-10-13 03:08:08 +00:00
|
|
|
import flixel.math.FlxPoint;
|
2020-10-31 04:25:23 +00:00
|
|
|
import flixel.system.FlxSound;
|
2020-10-10 09:28:44 +00:00
|
|
|
import flixel.text.FlxText;
|
2020-10-10 03:22:07 +00:00
|
|
|
import flixel.ui.FlxButton;
|
2020-10-10 04:22:26 +00:00
|
|
|
import flixel.ui.FlxSpriteButton;
|
|
|
|
import flixel.util.FlxColor;
|
2020-10-10 03:22:07 +00:00
|
|
|
import haxe.Json;
|
2021-01-04 23:56:30 +00:00
|
|
|
import lime.utils.Assets;
|
2020-10-10 03:22:07 +00:00
|
|
|
import openfl.events.Event;
|
|
|
|
import openfl.events.IOErrorEvent;
|
|
|
|
import openfl.events.IOErrorEvent;
|
|
|
|
import openfl.events.IOErrorEvent;
|
2020-11-06 09:57:00 +00:00
|
|
|
import openfl.media.Sound;
|
2020-10-10 03:22:07 +00:00
|
|
|
import openfl.net.FileReference;
|
2020-11-06 09:57:00 +00:00
|
|
|
import openfl.utils.ByteArray;
|
2020-10-10 02:39:52 +00:00
|
|
|
|
2020-10-13 08:07:04 +00:00
|
|
|
using StringTools;
|
|
|
|
|
2020-10-10 03:22:07 +00:00
|
|
|
class ChartingState extends MusicBeatState
|
2020-10-10 02:39:52 +00:00
|
|
|
{
|
2020-10-10 03:22:07 +00:00
|
|
|
var _file:FileReference;
|
2020-10-12 00:24:34 +00:00
|
|
|
|
2020-10-14 08:18:19 +00:00
|
|
|
var UI_box:FlxUITabMenu;
|
2020-10-12 03:52:21 +00:00
|
|
|
|
2020-10-12 00:24:34 +00:00
|
|
|
/**
|
2020-10-12 02:05:26 +00:00
|
|
|
* Array of notes showing when each section STARTS in STEPS
|
|
|
|
* Usually rounded up??
|
2020-10-12 00:24:34 +00:00
|
|
|
*/
|
2020-10-13 08:07:04 +00:00
|
|
|
var curSection:Int = 0;
|
|
|
|
|
2021-01-14 03:38:31 +00:00
|
|
|
public static var lastSection:Int = 0;
|
|
|
|
|
2020-10-10 09:28:44 +00:00
|
|
|
var bpmTxt:FlxText;
|
|
|
|
|
|
|
|
var strumLine:FlxSprite;
|
2020-10-18 07:27:39 +00:00
|
|
|
var curSong:String = 'Dadbattle';
|
2020-10-12 00:24:34 +00:00
|
|
|
var amountSteps:Int = 0;
|
2020-10-12 03:52:21 +00:00
|
|
|
var bullshitUI:FlxGroup;
|
|
|
|
|
|
|
|
var highlight:FlxSprite;
|
2020-10-13 05:18:50 +00:00
|
|
|
|
2020-10-13 08:07:04 +00:00
|
|
|
var GRID_SIZE:Int = 40;
|
2020-10-13 05:18:50 +00:00
|
|
|
|
|
|
|
var dummyArrow:FlxSprite;
|
|
|
|
|
2020-10-13 08:07:04 +00:00
|
|
|
var curRenderedNotes:FlxTypedGroup<Note>;
|
2020-10-19 02:34:21 +00:00
|
|
|
var curRenderedSustains:FlxTypedGroup<FlxSprite>;
|
2020-10-13 08:07:04 +00:00
|
|
|
|
2020-10-13 05:18:50 +00:00
|
|
|
var gridBG:FlxSprite;
|
2020-10-10 03:22:07 +00:00
|
|
|
|
2020-10-24 09:19:13 +00:00
|
|
|
var _song:SwagSong;
|
2020-10-14 01:44:07 +00:00
|
|
|
|
2020-10-14 08:18:19 +00:00
|
|
|
var typingShit:FlxInputText;
|
2020-10-19 02:51:01 +00:00
|
|
|
/*
|
|
|
|
* WILL BE THE CURRENT / LAST PLACED NOTE
|
|
|
|
**/
|
|
|
|
var curSelectedNote:Array<Dynamic>;
|
2020-10-16 11:03:10 +00:00
|
|
|
|
2021-03-20 16:33:29 +00:00
|
|
|
var tempBpm:Float = 0;
|
2020-10-30 03:06:52 +00:00
|
|
|
|
2020-10-31 04:25:23 +00:00
|
|
|
var vocals:FlxSound;
|
|
|
|
|
2021-01-17 04:15:29 +00:00
|
|
|
var leftIcon:HealthIcon;
|
|
|
|
var rightIcon:HealthIcon;
|
|
|
|
|
2020-10-10 02:39:52 +00:00
|
|
|
override function create()
|
|
|
|
{
|
2021-01-14 03:38:31 +00:00
|
|
|
curSection = lastSection;
|
|
|
|
|
2020-10-13 05:18:50 +00:00
|
|
|
gridBG = FlxGridOverlay.create(GRID_SIZE, GRID_SIZE, GRID_SIZE * 8, GRID_SIZE * 16);
|
|
|
|
add(gridBG);
|
|
|
|
|
2021-01-17 04:15:29 +00:00
|
|
|
leftIcon = new HealthIcon('bf');
|
|
|
|
rightIcon = new HealthIcon('dad');
|
|
|
|
leftIcon.scrollFactor.set(1, 1);
|
|
|
|
rightIcon.scrollFactor.set(1, 1);
|
|
|
|
|
|
|
|
leftIcon.setGraphicSize(0, 45);
|
|
|
|
rightIcon.setGraphicSize(0, 45);
|
|
|
|
|
|
|
|
add(leftIcon);
|
|
|
|
add(rightIcon);
|
|
|
|
|
|
|
|
leftIcon.setPosition(0, -100);
|
|
|
|
rightIcon.setPosition(gridBG.width / 2, -100);
|
|
|
|
|
2021-01-07 03:38:17 +00:00
|
|
|
var gridBlackLine:FlxSprite = new FlxSprite(gridBG.x + gridBG.width / 2).makeGraphic(2, Std.int(gridBG.height), FlxColor.BLACK);
|
|
|
|
add(gridBlackLine);
|
|
|
|
|
2020-10-13 08:07:04 +00:00
|
|
|
curRenderedNotes = new FlxTypedGroup<Note>();
|
2020-10-19 02:34:21 +00:00
|
|
|
curRenderedSustains = new FlxTypedGroup<FlxSprite>();
|
2020-10-13 08:07:04 +00:00
|
|
|
|
2020-10-14 01:44:07 +00:00
|
|
|
if (PlayState.SONG != null)
|
2020-10-14 08:30:54 +00:00
|
|
|
_song = PlayState.SONG;
|
2020-10-14 01:44:07 +00:00
|
|
|
else
|
|
|
|
{
|
2020-10-25 20:51:06 +00:00
|
|
|
_song = {
|
2021-01-20 02:09:47 +00:00
|
|
|
song: 'Test',
|
2020-10-25 20:51:06 +00:00
|
|
|
notes: [],
|
2021-01-20 02:09:47 +00:00
|
|
|
bpm: 150,
|
|
|
|
needsVoices: true,
|
2020-10-25 20:51:06 +00:00
|
|
|
player1: 'bf',
|
|
|
|
player2: 'dad',
|
2020-12-04 17:32:35 +00:00
|
|
|
speed: 1,
|
2020-12-04 17:38:12 +00:00
|
|
|
validScore: false
|
2020-10-25 20:51:06 +00:00
|
|
|
};
|
2020-10-14 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
2020-12-25 09:09:14 +00:00
|
|
|
FlxG.mouse.visible = true;
|
|
|
|
FlxG.save.bind('funkin', 'ninjamuffin99');
|
|
|
|
|
2020-10-30 03:06:52 +00:00
|
|
|
tempBpm = _song.bpm;
|
|
|
|
|
2020-10-14 08:18:19 +00:00
|
|
|
addSection();
|
|
|
|
|
2020-10-14 08:30:54 +00:00
|
|
|
// sections = _song.notes;
|
2020-10-14 01:44:07 +00:00
|
|
|
|
|
|
|
updateGrid();
|
|
|
|
|
2020-10-14 08:30:54 +00:00
|
|
|
loadSong(_song.song);
|
|
|
|
Conductor.changeBPM(_song.bpm);
|
2021-02-11 22:13:50 +00:00
|
|
|
Conductor.mapBPMChanges(_song);
|
2020-10-10 09:28:44 +00:00
|
|
|
|
2020-10-16 11:03:10 +00:00
|
|
|
bpmTxt = new FlxText(1000, 50, 0, "", 16);
|
|
|
|
bpmTxt.scrollFactor.set();
|
2020-10-10 09:28:44 +00:00
|
|
|
add(bpmTxt);
|
|
|
|
|
|
|
|
strumLine = new FlxSprite(0, 50).makeGraphic(Std.int(FlxG.width / 2), 4);
|
|
|
|
add(strumLine);
|
|
|
|
|
2020-10-13 05:18:50 +00:00
|
|
|
dummyArrow = new FlxSprite().makeGraphic(GRID_SIZE, GRID_SIZE);
|
|
|
|
add(dummyArrow);
|
|
|
|
|
2020-10-14 08:18:19 +00:00
|
|
|
var tabs = [
|
|
|
|
{name: "Song", label: 'Song'},
|
|
|
|
{name: "Section", label: 'Section'},
|
|
|
|
{name: "Note", label: 'Note'}
|
|
|
|
];
|
|
|
|
|
|
|
|
UI_box = new FlxUITabMenu(null, tabs, true);
|
|
|
|
|
|
|
|
UI_box.resize(300, 400);
|
|
|
|
UI_box.x = FlxG.width / 2;
|
|
|
|
UI_box.y = 20;
|
|
|
|
add(UI_box);
|
|
|
|
|
2020-10-16 04:22:13 +00:00
|
|
|
addSongUI();
|
|
|
|
addSectionUI();
|
2020-10-19 04:01:09 +00:00
|
|
|
addNoteUI();
|
2020-10-16 04:22:13 +00:00
|
|
|
|
|
|
|
add(curRenderedNotes);
|
2020-10-19 02:34:21 +00:00
|
|
|
add(curRenderedSustains);
|
2020-10-16 04:22:13 +00:00
|
|
|
|
2021-03-20 16:33:29 +00:00
|
|
|
changeSection();
|
2020-10-16 04:22:13 +00:00
|
|
|
super.create();
|
|
|
|
}
|
|
|
|
|
|
|
|
function addSongUI():Void
|
|
|
|
{
|
2020-10-14 08:30:54 +00:00
|
|
|
var UI_songTitle = new FlxUIInputText(10, 10, 70, _song.song, 8);
|
2020-10-14 08:18:19 +00:00
|
|
|
typingShit = UI_songTitle;
|
|
|
|
|
|
|
|
var check_voices = new FlxUICheckBox(10, 25, null, null, "Has voice track", 100);
|
2021-01-20 02:09:47 +00:00
|
|
|
check_voices.checked = _song.needsVoices;
|
|
|
|
// _song.needsVoices = check_voices.checked;
|
2020-10-14 08:18:19 +00:00
|
|
|
check_voices.callback = function()
|
|
|
|
{
|
2020-10-14 08:30:54 +00:00
|
|
|
_song.needsVoices = check_voices.checked;
|
2020-10-14 08:18:19 +00:00
|
|
|
trace('CHECKED!');
|
|
|
|
};
|
|
|
|
|
2021-01-14 03:38:31 +00:00
|
|
|
var check_mute_inst = new FlxUICheckBox(10, 200, null, null, "Mute Instrumental (in editor)", 100);
|
|
|
|
check_mute_inst.checked = false;
|
|
|
|
check_mute_inst.callback = function()
|
|
|
|
{
|
|
|
|
var vol:Float = 1;
|
|
|
|
|
|
|
|
if (check_mute_inst.checked)
|
|
|
|
vol = 0;
|
|
|
|
|
|
|
|
FlxG.sound.music.volume = vol;
|
|
|
|
};
|
|
|
|
|
2020-10-14 08:18:19 +00:00
|
|
|
var saveButton:FlxButton = new FlxButton(110, 8, "Save", function()
|
|
|
|
{
|
|
|
|
saveLevel();
|
|
|
|
});
|
|
|
|
|
|
|
|
var reloadSong:FlxButton = new FlxButton(saveButton.x + saveButton.width + 10, saveButton.y, "Reload Audio", function()
|
|
|
|
{
|
2020-10-14 08:30:54 +00:00
|
|
|
loadSong(_song.song);
|
2020-10-14 08:18:19 +00:00
|
|
|
});
|
|
|
|
|
2020-10-18 01:47:59 +00:00
|
|
|
var reloadSongJson:FlxButton = new FlxButton(reloadSong.x, saveButton.y + 30, "Reload JSON", function()
|
|
|
|
{
|
|
|
|
loadJson(_song.song.toLowerCase());
|
|
|
|
});
|
|
|
|
|
2020-12-25 23:24:20 +00:00
|
|
|
var loadAutosaveBtn:FlxButton = new FlxButton(reloadSongJson.x, reloadSongJson.y + 30, 'load autosave', loadAutosave);
|
2020-12-25 09:09:14 +00:00
|
|
|
|
2021-03-20 16:33:29 +00:00
|
|
|
var stepperSpeed:FlxUINumericStepper = new FlxUINumericStepper(10, 80, 0.1, 1, 0.1, 10, 2);
|
2020-10-18 01:47:59 +00:00
|
|
|
stepperSpeed.value = _song.speed;
|
|
|
|
stepperSpeed.name = 'song_speed';
|
|
|
|
|
2021-03-20 16:33:29 +00:00
|
|
|
var stepperBPM:FlxUINumericStepper = new FlxUINumericStepper(10, 65, 1, 100, 1, 999, 3);
|
2020-10-18 01:47:59 +00:00
|
|
|
stepperBPM.value = Conductor.bpm;
|
|
|
|
stepperBPM.name = 'song_bpm';
|
|
|
|
|
2021-02-10 20:18:14 +00:00
|
|
|
var characters:Array<String> = CoolUtil.coolTextFile(Paths.txt('characterList'));
|
2020-10-19 00:59:53 +00:00
|
|
|
|
|
|
|
var player1DropDown = new FlxUIDropDownMenu(10, 100, FlxUIDropDownMenu.makeStrIdLabelArray(characters, true), function(character:String)
|
|
|
|
{
|
|
|
|
_song.player1 = characters[Std.parseInt(character)];
|
2021-03-20 16:33:29 +00:00
|
|
|
updateHeads();
|
2020-10-19 00:59:53 +00:00
|
|
|
});
|
|
|
|
player1DropDown.selectedLabel = _song.player1;
|
|
|
|
|
|
|
|
var player2DropDown = new FlxUIDropDownMenu(140, 100, FlxUIDropDownMenu.makeStrIdLabelArray(characters, true), function(character:String)
|
|
|
|
{
|
|
|
|
_song.player2 = characters[Std.parseInt(character)];
|
2021-03-20 16:33:29 +00:00
|
|
|
updateHeads();
|
2020-10-19 00:59:53 +00:00
|
|
|
});
|
|
|
|
player2DropDown.selectedLabel = _song.player2;
|
|
|
|
|
2020-10-14 08:18:19 +00:00
|
|
|
var tab_group_song = new FlxUI(null, UI_box);
|
|
|
|
tab_group_song.name = "Song";
|
|
|
|
tab_group_song.add(UI_songTitle);
|
|
|
|
|
|
|
|
tab_group_song.add(check_voices);
|
2021-01-14 03:38:31 +00:00
|
|
|
tab_group_song.add(check_mute_inst);
|
2020-10-14 08:18:19 +00:00
|
|
|
tab_group_song.add(saveButton);
|
|
|
|
tab_group_song.add(reloadSong);
|
2020-10-18 01:47:59 +00:00
|
|
|
tab_group_song.add(reloadSongJson);
|
2020-12-25 09:09:14 +00:00
|
|
|
tab_group_song.add(loadAutosaveBtn);
|
2020-10-18 01:47:59 +00:00
|
|
|
tab_group_song.add(stepperBPM);
|
|
|
|
tab_group_song.add(stepperSpeed);
|
2020-10-19 00:59:53 +00:00
|
|
|
tab_group_song.add(player1DropDown);
|
|
|
|
tab_group_song.add(player2DropDown);
|
2020-10-14 08:18:19 +00:00
|
|
|
|
|
|
|
UI_box.addGroup(tab_group_song);
|
2020-10-16 11:03:10 +00:00
|
|
|
UI_box.scrollFactor.set();
|
|
|
|
|
|
|
|
FlxG.camera.follow(strumLine);
|
2020-10-16 04:22:13 +00:00
|
|
|
}
|
2020-10-14 08:18:19 +00:00
|
|
|
|
2020-10-16 04:22:13 +00:00
|
|
|
var stepperLength:FlxUINumericStepper;
|
|
|
|
var check_mustHitSection:FlxUICheckBox;
|
2020-10-30 03:06:52 +00:00
|
|
|
var check_changeBPM:FlxUICheckBox;
|
|
|
|
var stepperSectionBPM:FlxUINumericStepper;
|
2021-01-16 20:14:56 +00:00
|
|
|
var check_altAnim:FlxUICheckBox;
|
2020-10-13 08:07:04 +00:00
|
|
|
|
2020-10-16 04:22:13 +00:00
|
|
|
function addSectionUI():Void
|
|
|
|
{
|
|
|
|
var tab_group_section = new FlxUI(null, UI_box);
|
|
|
|
tab_group_section.name = 'Section';
|
|
|
|
|
|
|
|
stepperLength = new FlxUINumericStepper(10, 10, 4, 0, 0, 999, 0);
|
|
|
|
stepperLength.value = _song.notes[curSection].lengthInSteps;
|
|
|
|
stepperLength.name = "section_length";
|
|
|
|
|
2021-03-20 16:33:29 +00:00
|
|
|
stepperSectionBPM = new FlxUINumericStepper(10, 80, 1, Conductor.bpm, 1, 999, 3);
|
2020-10-30 03:06:52 +00:00
|
|
|
stepperSectionBPM.value = Conductor.bpm;
|
|
|
|
stepperSectionBPM.name = 'section_bpm';
|
|
|
|
|
2020-12-27 02:46:22 +00:00
|
|
|
var stepperCopy:FlxUINumericStepper = new FlxUINumericStepper(110, 130, 1, 1, -999, 999, 0);
|
2020-10-18 01:47:59 +00:00
|
|
|
|
2020-12-27 02:46:22 +00:00
|
|
|
var copyButton:FlxButton = new FlxButton(10, 130, "Copy last section", function()
|
2020-10-17 21:33:35 +00:00
|
|
|
{
|
2020-10-18 01:47:59 +00:00
|
|
|
copySection(Std.int(stepperCopy.value));
|
2020-10-17 21:33:35 +00:00
|
|
|
});
|
|
|
|
|
2020-12-25 08:40:01 +00:00
|
|
|
var clearSectionButton:FlxButton = new FlxButton(10, 150, "Clear", clearSection);
|
|
|
|
|
|
|
|
var swapSection:FlxButton = new FlxButton(10, 170, "Swap section", function()
|
|
|
|
{
|
|
|
|
for (i in 0..._song.notes[curSection].sectionNotes.length)
|
|
|
|
{
|
|
|
|
var note = _song.notes[curSection].sectionNotes[i];
|
|
|
|
note[1] = (note[1] + 4) % 8;
|
|
|
|
_song.notes[curSection].sectionNotes[i] = note;
|
|
|
|
updateGrid();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-10-16 04:22:13 +00:00
|
|
|
check_mustHitSection = new FlxUICheckBox(10, 30, null, null, "Must hit section", 100);
|
|
|
|
check_mustHitSection.name = 'check_mustHit';
|
|
|
|
check_mustHitSection.checked = true;
|
|
|
|
// _song.needsVoices = check_mustHit.checked;
|
2020-10-30 03:06:52 +00:00
|
|
|
|
2021-01-16 20:14:56 +00:00
|
|
|
check_altAnim = new FlxUICheckBox(10, 400, null, null, "Alt Animation", 100);
|
|
|
|
check_altAnim.name = 'check_altAnim';
|
|
|
|
|
2020-10-30 03:06:52 +00:00
|
|
|
check_changeBPM = new FlxUICheckBox(10, 60, null, null, 'Change BPM', 100);
|
|
|
|
check_changeBPM.name = 'check_changeBPM';
|
2020-10-16 04:22:13 +00:00
|
|
|
|
|
|
|
tab_group_section.add(stepperLength);
|
2020-10-30 03:06:52 +00:00
|
|
|
tab_group_section.add(stepperSectionBPM);
|
2020-10-18 01:47:59 +00:00
|
|
|
tab_group_section.add(stepperCopy);
|
2020-10-16 04:22:13 +00:00
|
|
|
tab_group_section.add(check_mustHitSection);
|
2021-01-16 20:14:56 +00:00
|
|
|
tab_group_section.add(check_altAnim);
|
2020-10-30 03:06:52 +00:00
|
|
|
tab_group_section.add(check_changeBPM);
|
2020-10-17 21:33:35 +00:00
|
|
|
tab_group_section.add(copyButton);
|
2020-12-25 08:40:01 +00:00
|
|
|
tab_group_section.add(clearSectionButton);
|
|
|
|
tab_group_section.add(swapSection);
|
2020-10-16 04:22:13 +00:00
|
|
|
|
|
|
|
UI_box.addGroup(tab_group_section);
|
2020-10-10 04:22:26 +00:00
|
|
|
}
|
2020-10-10 03:22:07 +00:00
|
|
|
|
2020-10-19 04:01:09 +00:00
|
|
|
var stepperSusLength:FlxUINumericStepper;
|
|
|
|
|
|
|
|
function addNoteUI():Void
|
|
|
|
{
|
|
|
|
var tab_group_note = new FlxUI(null, UI_box);
|
|
|
|
tab_group_note.name = 'Note';
|
|
|
|
|
|
|
|
stepperSusLength = new FlxUINumericStepper(10, 10, Conductor.stepCrochet / 2, 0, 0, Conductor.stepCrochet * 16);
|
|
|
|
stepperSusLength.value = 0;
|
|
|
|
stepperSusLength.name = 'note_susLength';
|
|
|
|
|
|
|
|
var applyLength:FlxButton = new FlxButton(100, 10, 'Apply');
|
|
|
|
|
|
|
|
tab_group_note.add(stepperSusLength);
|
|
|
|
tab_group_note.add(applyLength);
|
|
|
|
|
|
|
|
UI_box.addGroup(tab_group_note);
|
|
|
|
}
|
|
|
|
|
2020-10-14 08:18:19 +00:00
|
|
|
function loadSong(daSong:String):Void
|
|
|
|
{
|
|
|
|
if (FlxG.sound.music != null)
|
2020-10-31 04:25:23 +00:00
|
|
|
{
|
2020-10-14 08:18:19 +00:00
|
|
|
FlxG.sound.music.stop();
|
2020-10-31 04:25:23 +00:00
|
|
|
// vocals.stop();
|
|
|
|
}
|
|
|
|
|
2021-02-10 20:18:14 +00:00
|
|
|
FlxG.sound.playMusic(Paths.inst(daSong), 0.6);
|
2020-10-31 04:25:23 +00:00
|
|
|
|
2021-01-20 02:09:47 +00:00
|
|
|
// WONT WORK FOR TUTORIAL OR TEST SONG!!! REDO LATER
|
2021-02-15 21:49:13 +00:00
|
|
|
vocals = new FlxSound().loadEmbedded(Paths.voices(daSong));
|
2020-10-31 04:25:23 +00:00
|
|
|
FlxG.sound.list.add(vocals);
|
2020-10-14 08:18:19 +00:00
|
|
|
|
|
|
|
FlxG.sound.music.pause();
|
2020-10-31 04:25:23 +00:00
|
|
|
vocals.pause();
|
|
|
|
|
2020-10-14 08:18:19 +00:00
|
|
|
FlxG.sound.music.onComplete = function()
|
|
|
|
{
|
2020-10-31 04:25:23 +00:00
|
|
|
vocals.pause();
|
|
|
|
vocals.time = 0;
|
2020-10-14 08:18:19 +00:00
|
|
|
FlxG.sound.music.pause();
|
|
|
|
FlxG.sound.music.time = 0;
|
2021-02-11 22:13:50 +00:00
|
|
|
changeSection();
|
2020-10-14 08:18:19 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-10-12 03:52:21 +00:00
|
|
|
function generateUI():Void
|
|
|
|
{
|
|
|
|
while (bullshitUI.members.length > 0)
|
|
|
|
{
|
|
|
|
bullshitUI.remove(bullshitUI.members[0], true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// general shit
|
|
|
|
var title:FlxText = new FlxText(UI_box.x + 20, UI_box.y + 20, 0);
|
|
|
|
bullshitUI.add(title);
|
2020-10-13 05:18:50 +00:00
|
|
|
/*
|
|
|
|
var loopCheck = new FlxUICheckBox(UI_box.x + 10, UI_box.y + 50, null, null, "Loops", 100, ['loop check']);
|
|
|
|
loopCheck.checked = curNoteSelected.doesLoop;
|
|
|
|
tooltips.add(loopCheck, {title: 'Section looping', body: "Whether or not it's a simon says style section", style: tooltipType});
|
|
|
|
bullshitUI.add(loopCheck);
|
2020-10-12 03:52:21 +00:00
|
|
|
|
2020-10-13 05:18:50 +00:00
|
|
|
*/
|
2020-10-12 03:52:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
override function getEvent(id:String, sender:Dynamic, data:Dynamic, ?params:Array<Dynamic>)
|
|
|
|
{
|
|
|
|
if (id == FlxUICheckBox.CLICK_EVENT)
|
|
|
|
{
|
|
|
|
var check:FlxUICheckBox = cast sender;
|
|
|
|
var label = check.getLabel().text;
|
|
|
|
switch (label)
|
|
|
|
{
|
2020-10-16 04:22:13 +00:00
|
|
|
case 'Must hit section':
|
|
|
|
_song.notes[curSection].mustHitSection = check.checked;
|
2021-01-17 04:15:29 +00:00
|
|
|
|
|
|
|
updateHeads();
|
|
|
|
|
2020-10-30 03:06:52 +00:00
|
|
|
case 'Change BPM':
|
|
|
|
_song.notes[curSection].changeBPM = check.checked;
|
2020-10-30 06:52:26 +00:00
|
|
|
FlxG.log.add('changed bpm shit');
|
2021-01-16 20:14:56 +00:00
|
|
|
case "Alt Animation":
|
|
|
|
_song.notes[curSection].altAnim = check.checked;
|
2020-10-16 04:22:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (id == FlxUINumericStepper.CHANGE_EVENT && (sender is FlxUINumericStepper))
|
|
|
|
{
|
|
|
|
var nums:FlxUINumericStepper = cast sender;
|
|
|
|
var wname = nums.name;
|
|
|
|
FlxG.log.add(wname);
|
|
|
|
if (wname == 'section_length')
|
|
|
|
{
|
|
|
|
_song.notes[curSection].lengthInSteps = Std.int(nums.value);
|
2020-10-16 11:03:10 +00:00
|
|
|
updateGrid();
|
2020-10-12 03:52:21 +00:00
|
|
|
}
|
2020-10-18 01:47:59 +00:00
|
|
|
else if (wname == 'song_speed')
|
|
|
|
{
|
|
|
|
_song.speed = nums.value;
|
|
|
|
}
|
|
|
|
else if (wname == 'song_bpm')
|
|
|
|
{
|
2021-03-20 16:33:29 +00:00
|
|
|
tempBpm = nums.value;
|
2021-02-11 22:13:50 +00:00
|
|
|
Conductor.mapBPMChanges(_song);
|
2021-03-20 16:33:29 +00:00
|
|
|
Conductor.changeBPM(nums.value);
|
2020-10-18 01:47:59 +00:00
|
|
|
}
|
2020-10-19 04:01:09 +00:00
|
|
|
else if (wname == 'note_susLength')
|
|
|
|
{
|
|
|
|
curSelectedNote[2] = nums.value;
|
|
|
|
updateGrid();
|
|
|
|
}
|
2020-10-30 03:06:52 +00:00
|
|
|
else if (wname == 'section_bpm')
|
|
|
|
{
|
2021-03-20 16:33:29 +00:00
|
|
|
_song.notes[curSection].bpm = nums.value;
|
2020-10-30 03:06:52 +00:00
|
|
|
updateGrid();
|
|
|
|
}
|
2020-10-12 03:52:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// FlxG.log.add(id + " WEED " + sender + " WEED " + data + " WEED " + params);
|
|
|
|
}
|
|
|
|
|
2020-10-16 11:03:10 +00:00
|
|
|
var updatedSection:Bool = false;
|
|
|
|
|
2021-02-11 22:13:50 +00:00
|
|
|
/* this function got owned LOL
|
2021-03-02 04:00:02 +00:00
|
|
|
function lengthBpmBullshit():Float
|
|
|
|
{
|
|
|
|
if (_song.notes[curSection].changeBPM)
|
|
|
|
return _song.notes[curSection].lengthInSteps * (_song.notes[curSection].bpm / _song.bpm);
|
|
|
|
else
|
|
|
|
return _song.notes[curSection].lengthInSteps;
|
2021-02-11 22:13:50 +00:00
|
|
|
}*/
|
|
|
|
function sectionStartTime():Float
|
|
|
|
{
|
2021-03-20 16:33:29 +00:00
|
|
|
var daBPM:Float = _song.bpm;
|
2021-02-11 22:13:50 +00:00
|
|
|
var daPos:Float = 0;
|
|
|
|
for (i in 0...curSection)
|
|
|
|
{
|
2021-03-02 04:00:02 +00:00
|
|
|
if (_song.notes[i].changeBPM)
|
|
|
|
{
|
2021-02-11 22:13:50 +00:00
|
|
|
daBPM = _song.notes[i].bpm;
|
|
|
|
}
|
|
|
|
daPos += 4 * (1000 * 60 / daBPM);
|
|
|
|
}
|
|
|
|
return daPos;
|
2020-11-14 02:49:20 +00:00
|
|
|
}
|
|
|
|
|
2020-10-10 04:22:26 +00:00
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
2020-11-21 10:43:04 +00:00
|
|
|
curStep = recalculateSteps();
|
|
|
|
|
2020-10-10 09:28:44 +00:00
|
|
|
Conductor.songPosition = FlxG.sound.music.time;
|
2020-10-14 08:30:54 +00:00
|
|
|
_song.song = typingShit.text;
|
2020-10-10 09:28:44 +00:00
|
|
|
|
2021-02-11 22:13:50 +00:00
|
|
|
strumLine.y = getYfromStrum((Conductor.songPosition - sectionStartTime()) % (Conductor.stepCrochet * _song.notes[curSection].lengthInSteps));
|
2020-10-13 08:07:04 +00:00
|
|
|
|
2021-02-11 22:13:50 +00:00
|
|
|
if (curBeat % 4 == 0 && curStep >= 16 * (curSection + 1))
|
2020-10-13 08:07:04 +00:00
|
|
|
{
|
2021-02-11 22:13:50 +00:00
|
|
|
trace(curStep);
|
|
|
|
trace((_song.notes[curSection].lengthInSteps) * (curSection + 1));
|
|
|
|
trace('DUMBSHIT');
|
2020-10-13 05:18:50 +00:00
|
|
|
|
2021-02-11 22:13:50 +00:00
|
|
|
if (_song.notes[curSection + 1] == null)
|
|
|
|
{
|
|
|
|
addSection();
|
2020-10-13 08:07:04 +00:00
|
|
|
}
|
2021-02-11 22:13:50 +00:00
|
|
|
|
|
|
|
changeSection(curSection + 1, false);
|
2020-10-13 08:07:04 +00:00
|
|
|
}
|
|
|
|
|
2020-11-18 00:22:29 +00:00
|
|
|
FlxG.watch.addQuick('daBeat', curBeat);
|
|
|
|
FlxG.watch.addQuick('daStep', curStep);
|
|
|
|
|
2020-10-19 02:34:21 +00:00
|
|
|
if (FlxG.mouse.justPressed)
|
|
|
|
{
|
|
|
|
if (FlxG.mouse.overlaps(curRenderedNotes))
|
|
|
|
{
|
|
|
|
curRenderedNotes.forEach(function(note:Note)
|
|
|
|
{
|
|
|
|
if (FlxG.mouse.overlaps(note))
|
|
|
|
{
|
2020-10-19 04:01:09 +00:00
|
|
|
if (FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
|
|
|
selectNote(note);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
trace('tryin to delete note...');
|
|
|
|
deleteNote(note);
|
|
|
|
}
|
2020-10-19 02:34:21 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-10-20 01:59:00 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (FlxG.mouse.x > gridBG.x
|
|
|
|
&& FlxG.mouse.x < gridBG.x + gridBG.width
|
|
|
|
&& FlxG.mouse.y > gridBG.y
|
|
|
|
&& FlxG.mouse.y < gridBG.y + (GRID_SIZE * _song.notes[curSection].lengthInSteps))
|
|
|
|
{
|
|
|
|
FlxG.log.add('added note');
|
|
|
|
addNote();
|
|
|
|
}
|
|
|
|
}
|
2020-10-19 02:34:21 +00:00
|
|
|
}
|
|
|
|
|
2020-10-16 11:03:10 +00:00
|
|
|
if (FlxG.mouse.x > gridBG.x
|
|
|
|
&& FlxG.mouse.x < gridBG.x + gridBG.width
|
|
|
|
&& FlxG.mouse.y > gridBG.y
|
|
|
|
&& FlxG.mouse.y < gridBG.y + (GRID_SIZE * _song.notes[curSection].lengthInSteps))
|
2020-10-13 05:18:50 +00:00
|
|
|
{
|
2020-10-13 08:07:04 +00:00
|
|
|
dummyArrow.x = Math.floor(FlxG.mouse.x / GRID_SIZE) * GRID_SIZE;
|
|
|
|
if (FlxG.keys.pressed.SHIFT)
|
|
|
|
dummyArrow.y = FlxG.mouse.y;
|
|
|
|
else
|
|
|
|
dummyArrow.y = Math.floor(FlxG.mouse.y / GRID_SIZE) * GRID_SIZE;
|
2020-10-13 05:18:50 +00:00
|
|
|
}
|
|
|
|
|
2020-10-13 08:37:19 +00:00
|
|
|
if (FlxG.keys.justPressed.ENTER)
|
|
|
|
{
|
2021-01-14 03:38:31 +00:00
|
|
|
lastSection = curSection;
|
|
|
|
|
2020-10-14 08:30:54 +00:00
|
|
|
PlayState.SONG = _song;
|
2020-10-14 01:23:22 +00:00
|
|
|
FlxG.sound.music.stop();
|
2020-10-31 04:25:23 +00:00
|
|
|
vocals.stop();
|
2020-10-13 08:37:19 +00:00
|
|
|
FlxG.switchState(new PlayState());
|
|
|
|
}
|
|
|
|
|
2021-01-14 03:38:31 +00:00
|
|
|
if (FlxG.keys.justPressed.E)
|
|
|
|
{
|
|
|
|
changeNoteSustain(Conductor.stepCrochet);
|
|
|
|
}
|
|
|
|
if (FlxG.keys.justPressed.Q)
|
|
|
|
{
|
|
|
|
changeNoteSustain(-Conductor.stepCrochet);
|
|
|
|
}
|
|
|
|
|
2021-01-08 01:38:32 +00:00
|
|
|
if (FlxG.keys.justPressed.TAB)
|
|
|
|
{
|
|
|
|
if (FlxG.keys.pressed.SHIFT)
|
|
|
|
{
|
|
|
|
UI_box.selected_tab -= 1;
|
|
|
|
if (UI_box.selected_tab < 0)
|
|
|
|
UI_box.selected_tab = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UI_box.selected_tab += 1;
|
|
|
|
if (UI_box.selected_tab >= 3)
|
|
|
|
UI_box.selected_tab = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-14 08:18:19 +00:00
|
|
|
if (!typingShit.hasFocus)
|
2020-10-10 04:22:26 +00:00
|
|
|
{
|
2020-10-14 08:18:19 +00:00
|
|
|
if (FlxG.keys.justPressed.SPACE)
|
2020-10-10 09:28:44 +00:00
|
|
|
{
|
2020-10-14 08:18:19 +00:00
|
|
|
if (FlxG.sound.music.playing)
|
|
|
|
{
|
|
|
|
FlxG.sound.music.pause();
|
2020-10-31 04:25:23 +00:00
|
|
|
vocals.pause();
|
2020-10-14 08:18:19 +00:00
|
|
|
}
|
|
|
|
else
|
2020-10-31 04:25:23 +00:00
|
|
|
{
|
|
|
|
vocals.play();
|
2020-10-14 08:18:19 +00:00
|
|
|
FlxG.sound.music.play();
|
2020-10-31 04:25:23 +00:00
|
|
|
}
|
2020-10-10 09:28:44 +00:00
|
|
|
}
|
|
|
|
|
2020-10-14 08:18:19 +00:00
|
|
|
if (FlxG.keys.justPressed.R)
|
|
|
|
{
|
|
|
|
if (FlxG.keys.pressed.SHIFT)
|
2021-01-07 04:02:23 +00:00
|
|
|
resetSection(true);
|
2021-01-08 01:38:32 +00:00
|
|
|
else
|
|
|
|
resetSection();
|
2021-01-07 04:02:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (FlxG.mouse.wheel != 0)
|
|
|
|
{
|
|
|
|
FlxG.sound.music.pause();
|
|
|
|
vocals.pause();
|
|
|
|
|
2021-01-08 01:38:32 +00:00
|
|
|
FlxG.sound.music.time -= (FlxG.mouse.wheel * Conductor.stepCrochet * 0.4);
|
2021-01-07 04:02:23 +00:00
|
|
|
vocals.time = FlxG.sound.music.time;
|
2020-10-14 08:18:19 +00:00
|
|
|
}
|
2020-10-14 04:05:55 +00:00
|
|
|
|
2020-12-25 23:24:20 +00:00
|
|
|
if (!FlxG.keys.pressed.SHIFT)
|
2020-10-14 08:18:19 +00:00
|
|
|
{
|
2020-12-25 23:24:20 +00:00
|
|
|
if (FlxG.keys.pressed.W || FlxG.keys.pressed.S)
|
|
|
|
{
|
|
|
|
FlxG.sound.music.pause();
|
|
|
|
vocals.pause();
|
2020-10-14 04:05:55 +00:00
|
|
|
|
2020-12-25 23:24:20 +00:00
|
|
|
var daTime:Float = 700 * FlxG.elapsed;
|
2020-10-14 04:05:55 +00:00
|
|
|
|
2020-12-25 23:24:20 +00:00
|
|
|
if (FlxG.keys.pressed.W)
|
|
|
|
{
|
|
|
|
FlxG.sound.music.time -= daTime;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
FlxG.sound.music.time += daTime;
|
|
|
|
|
|
|
|
vocals.time = FlxG.sound.music.time;
|
2020-10-14 08:18:19 +00:00
|
|
|
}
|
2020-12-25 23:24:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (FlxG.keys.justPressed.W || FlxG.keys.justPressed.S)
|
|
|
|
{
|
|
|
|
FlxG.sound.music.pause();
|
|
|
|
vocals.pause();
|
|
|
|
|
|
|
|
var daTime:Float = Conductor.stepCrochet * 2;
|
2020-10-31 04:25:23 +00:00
|
|
|
|
2020-12-25 23:24:20 +00:00
|
|
|
if (FlxG.keys.justPressed.W)
|
|
|
|
{
|
|
|
|
FlxG.sound.music.time -= daTime;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
FlxG.sound.music.time += daTime;
|
|
|
|
|
|
|
|
vocals.time = FlxG.sound.music.time;
|
|
|
|
}
|
2020-10-14 04:05:55 +00:00
|
|
|
}
|
2020-10-13 08:07:04 +00:00
|
|
|
}
|
|
|
|
|
2020-10-30 03:06:52 +00:00
|
|
|
_song.bpm = tempBpm;
|
2020-10-14 08:30:54 +00:00
|
|
|
|
2020-10-30 03:06:52 +00:00
|
|
|
/* if (FlxG.keys.justPressed.UP)
|
|
|
|
Conductor.changeBPM(Conductor.bpm + 1);
|
|
|
|
if (FlxG.keys.justPressed.DOWN)
|
|
|
|
Conductor.changeBPM(Conductor.bpm - 1); */
|
2020-10-10 09:28:44 +00:00
|
|
|
|
2020-12-09 18:53:46 +00:00
|
|
|
var shiftThing:Int = 1;
|
|
|
|
if (FlxG.keys.pressed.SHIFT)
|
|
|
|
shiftThing = 4;
|
2021-01-07 04:02:23 +00:00
|
|
|
if (FlxG.keys.justPressed.RIGHT || FlxG.keys.justPressed.D)
|
2020-12-09 18:53:46 +00:00
|
|
|
changeSection(curSection + shiftThing);
|
2021-01-07 04:02:23 +00:00
|
|
|
if (FlxG.keys.justPressed.LEFT || FlxG.keys.justPressed.A)
|
2020-12-09 18:53:46 +00:00
|
|
|
changeSection(curSection - shiftThing);
|
2020-10-13 08:07:04 +00:00
|
|
|
|
2020-12-09 18:53:46 +00:00
|
|
|
bpmTxt.text = bpmTxt.text = Std.string(FlxMath.roundDecimal(Conductor.songPosition / 1000, 2))
|
|
|
|
+ " / "
|
|
|
|
+ Std.string(FlxMath.roundDecimal(FlxG.sound.music.length / 1000, 2))
|
|
|
|
+ "\nSection: "
|
|
|
|
+ curSection;
|
2020-10-10 04:22:26 +00:00
|
|
|
super.update(elapsed);
|
|
|
|
}
|
|
|
|
|
2021-01-14 03:38:31 +00:00
|
|
|
function changeNoteSustain(value:Float):Void
|
|
|
|
{
|
2021-01-20 12:19:48 +00:00
|
|
|
if (curSelectedNote != null)
|
2021-01-14 03:38:31 +00:00
|
|
|
{
|
2021-01-20 12:19:48 +00:00
|
|
|
if (curSelectedNote[2] != null)
|
|
|
|
{
|
|
|
|
curSelectedNote[2] += value;
|
|
|
|
curSelectedNote[2] = Math.max(curSelectedNote[2], 0);
|
|
|
|
}
|
2021-01-14 03:38:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
updateNoteUI();
|
|
|
|
updateGrid();
|
|
|
|
}
|
|
|
|
|
2020-11-21 10:43:04 +00:00
|
|
|
function recalculateSteps():Int
|
|
|
|
{
|
2021-02-11 22:13:50 +00:00
|
|
|
var lastChange:BPMChangeEvent = {
|
|
|
|
stepTime: 0,
|
|
|
|
songTime: 0,
|
|
|
|
bpm: 0
|
|
|
|
}
|
|
|
|
for (i in 0...Conductor.bpmChangeMap.length)
|
2020-11-21 10:43:04 +00:00
|
|
|
{
|
2021-02-11 22:13:50 +00:00
|
|
|
if (FlxG.sound.music.time > Conductor.bpmChangeMap[i].songTime)
|
|
|
|
lastChange = Conductor.bpmChangeMap[i];
|
2020-11-21 10:43:04 +00:00
|
|
|
}
|
|
|
|
|
2021-02-11 22:13:50 +00:00
|
|
|
curStep = lastChange.stepTime + Math.floor((FlxG.sound.music.time - lastChange.songTime) / Conductor.stepCrochet);
|
2020-11-21 10:43:04 +00:00
|
|
|
updateBeat();
|
|
|
|
|
|
|
|
return curStep;
|
|
|
|
}
|
|
|
|
|
2021-01-07 04:02:23 +00:00
|
|
|
function resetSection(songBeginning:Bool = false):Void
|
|
|
|
{
|
|
|
|
updateGrid();
|
|
|
|
|
|
|
|
FlxG.sound.music.pause();
|
|
|
|
vocals.pause();
|
|
|
|
|
|
|
|
// Basically old shit from changeSection???
|
2021-02-11 22:13:50 +00:00
|
|
|
FlxG.sound.music.time = sectionStartTime();
|
2021-01-07 04:02:23 +00:00
|
|
|
|
|
|
|
if (songBeginning)
|
2021-01-08 01:38:32 +00:00
|
|
|
{
|
2021-01-07 04:02:23 +00:00
|
|
|
FlxG.sound.music.time = 0;
|
2021-01-08 01:38:32 +00:00
|
|
|
curSection = 0;
|
|
|
|
}
|
2021-01-07 04:02:23 +00:00
|
|
|
|
|
|
|
vocals.time = FlxG.sound.music.time;
|
|
|
|
updateCurStep();
|
|
|
|
|
|
|
|
updateGrid();
|
|
|
|
updateSectionUI();
|
|
|
|
}
|
|
|
|
|
2020-10-13 08:07:04 +00:00
|
|
|
function changeSection(sec:Int = 0, ?updateMusic:Bool = true):Void
|
|
|
|
{
|
2020-10-16 11:03:10 +00:00
|
|
|
trace('changing section' + sec);
|
|
|
|
|
2020-10-14 08:30:54 +00:00
|
|
|
if (_song.notes[sec] != null)
|
2020-10-13 08:07:04 +00:00
|
|
|
{
|
|
|
|
curSection = sec;
|
|
|
|
|
2020-10-30 06:52:26 +00:00
|
|
|
updateGrid();
|
|
|
|
|
2020-10-13 08:07:04 +00:00
|
|
|
if (updateMusic)
|
|
|
|
{
|
|
|
|
FlxG.sound.music.pause();
|
2020-10-31 04:25:23 +00:00
|
|
|
vocals.pause();
|
2020-10-13 08:07:04 +00:00
|
|
|
|
2021-02-11 22:13:50 +00:00
|
|
|
/*var daNum:Int = 0;
|
2021-03-02 04:00:02 +00:00
|
|
|
var daLength:Float = 0;
|
|
|
|
while (daNum <= sec)
|
|
|
|
{
|
|
|
|
daLength += lengthBpmBullshit();
|
|
|
|
daNum++;
|
2021-02-11 22:13:50 +00:00
|
|
|
}*/
|
2020-10-13 08:07:04 +00:00
|
|
|
|
2021-02-11 22:13:50 +00:00
|
|
|
FlxG.sound.music.time = sectionStartTime();
|
2020-10-31 04:25:23 +00:00
|
|
|
vocals.time = FlxG.sound.music.time;
|
2020-10-16 11:03:10 +00:00
|
|
|
updateCurStep();
|
2020-10-13 08:07:04 +00:00
|
|
|
}
|
2020-10-16 04:22:13 +00:00
|
|
|
|
2020-10-30 03:06:52 +00:00
|
|
|
updateGrid();
|
2020-10-16 04:22:13 +00:00
|
|
|
updateSectionUI();
|
2020-10-13 08:07:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-18 01:47:59 +00:00
|
|
|
function copySection(?sectionNum:Int = 1)
|
2020-10-17 21:33:35 +00:00
|
|
|
{
|
2020-10-18 01:47:59 +00:00
|
|
|
var daSec = FlxMath.maxInt(curSection, sectionNum);
|
2020-10-17 21:33:35 +00:00
|
|
|
|
2020-10-19 00:59:53 +00:00
|
|
|
for (note in _song.notes[daSec - sectionNum].sectionNotes)
|
2020-10-17 21:33:35 +00:00
|
|
|
{
|
2020-10-21 06:23:39 +00:00
|
|
|
var strum = note[0] + Conductor.stepCrochet * (_song.notes[daSec].lengthInSteps * sectionNum);
|
2020-10-19 02:18:06 +00:00
|
|
|
|
2020-10-21 06:23:39 +00:00
|
|
|
var copiedNote:Array<Dynamic> = [strum, note[1], note[2]];
|
2020-10-19 02:18:06 +00:00
|
|
|
_song.notes[daSec].sectionNotes.push(copiedNote);
|
2020-10-17 21:33:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
updateGrid();
|
|
|
|
}
|
|
|
|
|
2020-10-16 04:22:13 +00:00
|
|
|
function updateSectionUI():Void
|
|
|
|
{
|
|
|
|
var sec = _song.notes[curSection];
|
|
|
|
|
|
|
|
stepperLength.value = sec.lengthInSteps;
|
|
|
|
check_mustHitSection.checked = sec.mustHitSection;
|
2021-01-16 20:14:56 +00:00
|
|
|
check_altAnim.checked = sec.altAnim;
|
2020-10-30 03:06:52 +00:00
|
|
|
check_changeBPM.checked = sec.changeBPM;
|
|
|
|
stepperSectionBPM.value = sec.bpm;
|
2021-01-17 04:15:29 +00:00
|
|
|
|
|
|
|
updateHeads();
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateHeads():Void
|
|
|
|
{
|
|
|
|
if (check_mustHitSection.checked)
|
|
|
|
{
|
2021-03-20 16:33:29 +00:00
|
|
|
leftIcon.changeIcon(_song.player1);
|
|
|
|
rightIcon.changeIcon(_song.player2);
|
2021-01-17 04:15:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-03-20 16:33:29 +00:00
|
|
|
leftIcon.changeIcon(_song.player2);
|
|
|
|
rightIcon.changeIcon(_song.player1);
|
2021-01-17 04:15:29 +00:00
|
|
|
}
|
2020-10-16 04:22:13 +00:00
|
|
|
}
|
|
|
|
|
2020-10-19 04:01:09 +00:00
|
|
|
function updateNoteUI():Void
|
|
|
|
{
|
2021-01-20 12:19:48 +00:00
|
|
|
if (curSelectedNote != null)
|
|
|
|
stepperSusLength.value = curSelectedNote[2];
|
2020-10-19 04:01:09 +00:00
|
|
|
}
|
|
|
|
|
2020-10-13 08:07:04 +00:00
|
|
|
function updateGrid():Void
|
|
|
|
{
|
|
|
|
while (curRenderedNotes.members.length > 0)
|
|
|
|
{
|
|
|
|
curRenderedNotes.remove(curRenderedNotes.members[0], true);
|
|
|
|
}
|
|
|
|
|
2020-10-19 02:34:21 +00:00
|
|
|
while (curRenderedSustains.members.length > 0)
|
|
|
|
{
|
|
|
|
curRenderedSustains.remove(curRenderedSustains.members[0], true);
|
|
|
|
}
|
|
|
|
|
2020-10-19 00:59:53 +00:00
|
|
|
var sectionInfo:Array<Dynamic> = _song.notes[curSection].sectionNotes;
|
2020-10-13 08:07:04 +00:00
|
|
|
|
2020-10-30 03:06:52 +00:00
|
|
|
if (_song.notes[curSection].changeBPM && _song.notes[curSection].bpm > 0)
|
|
|
|
{
|
|
|
|
Conductor.changeBPM(_song.notes[curSection].bpm);
|
2021-02-11 22:13:50 +00:00
|
|
|
FlxG.log.add('CHANGED BPM!');
|
2020-10-30 03:06:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-03-02 04:00:02 +00:00
|
|
|
// get last bpm
|
2021-03-20 16:33:29 +00:00
|
|
|
var daBPM:Float = _song.bpm;
|
2021-02-11 22:13:50 +00:00
|
|
|
for (i in 0...curSection)
|
|
|
|
if (_song.notes[i].changeBPM)
|
|
|
|
daBPM = _song.notes[i].bpm;
|
|
|
|
Conductor.changeBPM(daBPM);
|
2020-10-30 03:06:52 +00:00
|
|
|
}
|
|
|
|
|
2020-10-19 02:34:21 +00:00
|
|
|
/* // PORT BULLSHIT, INCASE THERE'S NO SUSTAIN DATA FOR A NOTE
|
|
|
|
for (sec in 0..._song.notes.length)
|
|
|
|
{
|
|
|
|
for (notesse in 0..._song.notes[sec].sectionNotes.length)
|
|
|
|
{
|
|
|
|
if (_song.notes[sec].sectionNotes[notesse][2] == null)
|
|
|
|
{
|
|
|
|
trace('SUS NULL');
|
|
|
|
_song.notes[sec].sectionNotes[notesse][2] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2020-10-13 08:07:04 +00:00
|
|
|
for (i in sectionInfo)
|
|
|
|
{
|
|
|
|
var daNoteInfo = i[1];
|
2020-10-19 02:18:06 +00:00
|
|
|
var daStrumTime = i[0];
|
|
|
|
var daSus = i[2];
|
2020-10-13 08:07:04 +00:00
|
|
|
|
2020-10-19 02:18:06 +00:00
|
|
|
var note:Note = new Note(daStrumTime, daNoteInfo % 4);
|
|
|
|
note.sustainLength = daSus;
|
2020-10-13 08:07:04 +00:00
|
|
|
note.setGraphicSize(GRID_SIZE, GRID_SIZE);
|
|
|
|
note.updateHitbox();
|
2020-10-19 02:18:06 +00:00
|
|
|
note.x = Math.floor(daNoteInfo * GRID_SIZE);
|
2021-02-11 22:13:50 +00:00
|
|
|
note.y = Math.floor(getYfromStrum((daStrumTime - sectionStartTime()) % (Conductor.stepCrochet * _song.notes[curSection].lengthInSteps)));
|
2020-10-13 08:07:04 +00:00
|
|
|
|
|
|
|
curRenderedNotes.add(note);
|
2020-10-19 02:51:01 +00:00
|
|
|
|
|
|
|
if (daSus > 0)
|
|
|
|
{
|
2020-10-21 20:12:32 +00:00
|
|
|
var sustainVis:FlxSprite = new FlxSprite(note.x + (GRID_SIZE / 2),
|
2020-10-30 03:06:52 +00:00
|
|
|
note.y + GRID_SIZE).makeGraphic(8, Math.floor(FlxMath.remapToRange(daSus, 0, Conductor.stepCrochet * 16, 0, gridBG.height)));
|
2020-10-19 02:51:01 +00:00
|
|
|
curRenderedSustains.add(sustainVis);
|
|
|
|
}
|
2020-10-13 08:07:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function addSection(lengthInSteps:Int = 16):Void
|
|
|
|
{
|
2020-10-30 03:06:52 +00:00
|
|
|
var sec:SwagSection = {
|
|
|
|
lengthInSteps: lengthInSteps,
|
|
|
|
bpm: _song.bpm,
|
|
|
|
changeBPM: false,
|
|
|
|
mustHitSection: true,
|
|
|
|
sectionNotes: [],
|
2021-01-16 20:14:56 +00:00
|
|
|
typeOfSection: 0,
|
|
|
|
altAnim: false
|
2020-10-30 03:06:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_song.notes.push(sec);
|
2020-10-13 08:07:04 +00:00
|
|
|
}
|
|
|
|
|
2020-10-19 04:01:09 +00:00
|
|
|
function selectNote(note:Note):Void
|
|
|
|
{
|
|
|
|
var swagNum:Int = 0;
|
|
|
|
|
|
|
|
for (i in _song.notes[curSection].sectionNotes)
|
|
|
|
{
|
|
|
|
if (i.strumTime == note.strumTime && i.noteData % 4 == note.noteData)
|
|
|
|
{
|
|
|
|
curSelectedNote = _song.notes[curSection].sectionNotes[swagNum];
|
|
|
|
}
|
|
|
|
|
|
|
|
swagNum += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
updateGrid();
|
|
|
|
updateNoteUI();
|
|
|
|
}
|
|
|
|
|
2020-10-14 01:23:22 +00:00
|
|
|
function deleteNote(note:Note):Void
|
|
|
|
{
|
2020-10-19 00:59:53 +00:00
|
|
|
for (i in _song.notes[curSection].sectionNotes)
|
2020-10-14 01:23:22 +00:00
|
|
|
{
|
2020-10-20 01:59:00 +00:00
|
|
|
if (i[0] == note.strumTime && i[1] % 4 == note.noteData)
|
2020-10-14 01:23:22 +00:00
|
|
|
{
|
|
|
|
FlxG.log.add('FOUND EVIL NUMBER');
|
2020-10-19 00:59:53 +00:00
|
|
|
_song.notes[curSection].sectionNotes.remove(i);
|
2020-10-14 01:23:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-29 02:47:10 +00:00
|
|
|
updateGrid();
|
|
|
|
}
|
|
|
|
|
2020-12-25 08:40:01 +00:00
|
|
|
function clearSection():Void
|
|
|
|
{
|
|
|
|
_song.notes[curSection].sectionNotes = [];
|
|
|
|
|
|
|
|
updateGrid();
|
|
|
|
}
|
|
|
|
|
2020-10-29 02:47:10 +00:00
|
|
|
function clearSong():Void
|
|
|
|
{
|
|
|
|
for (daSection in 0..._song.notes.length)
|
|
|
|
{
|
|
|
|
_song.notes[daSection].sectionNotes = [];
|
|
|
|
}
|
|
|
|
|
2020-10-14 01:23:22 +00:00
|
|
|
updateGrid();
|
|
|
|
}
|
|
|
|
|
2020-10-13 05:18:50 +00:00
|
|
|
private function addNote():Void
|
|
|
|
{
|
2021-02-11 22:13:50 +00:00
|
|
|
var noteStrum = getStrumTime(dummyArrow.y) + sectionStartTime();
|
2020-10-19 02:51:01 +00:00
|
|
|
var noteData = Math.floor(FlxG.mouse.x / GRID_SIZE);
|
|
|
|
var noteSus = 0;
|
|
|
|
|
|
|
|
_song.notes[curSection].sectionNotes.push([noteStrum, noteData, noteSus]);
|
2020-10-19 00:59:53 +00:00
|
|
|
|
2020-10-19 02:51:01 +00:00
|
|
|
curSelectedNote = _song.notes[curSection].sectionNotes[_song.notes[curSection].sectionNotes.length - 1];
|
2020-10-13 09:55:00 +00:00
|
|
|
|
2021-01-07 03:38:17 +00:00
|
|
|
if (FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
|
|
|
_song.notes[curSection].sectionNotes.push([noteStrum, (noteData + 4) % 8, noteSus]);
|
|
|
|
}
|
|
|
|
|
2021-02-11 22:13:50 +00:00
|
|
|
trace(noteStrum);
|
2020-10-13 09:55:00 +00:00
|
|
|
trace(curSection);
|
|
|
|
|
2020-10-13 08:07:04 +00:00
|
|
|
updateGrid();
|
2020-10-19 04:01:09 +00:00
|
|
|
updateNoteUI();
|
2020-12-25 09:09:14 +00:00
|
|
|
|
|
|
|
autosaveSong();
|
2020-10-13 05:18:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getStrumTime(yPos:Float):Float
|
|
|
|
{
|
2020-10-13 09:36:45 +00:00
|
|
|
return FlxMath.remapToRange(yPos, gridBG.y, gridBG.y + gridBG.height, 0, 16 * Conductor.stepCrochet);
|
2020-10-13 08:07:04 +00:00
|
|
|
}
|
|
|
|
|
2020-10-13 09:55:00 +00:00
|
|
|
function getYfromStrum(strumTime:Float):Float
|
2020-10-13 08:07:04 +00:00
|
|
|
{
|
2020-10-13 09:55:00 +00:00
|
|
|
return FlxMath.remapToRange(strumTime, 0, 16 * Conductor.stepCrochet, gridBG.y, gridBG.y + gridBG.height);
|
2020-10-13 05:18:50 +00:00
|
|
|
}
|
|
|
|
|
2021-02-11 22:13:50 +00:00
|
|
|
/*
|
2021-03-02 04:00:02 +00:00
|
|
|
function calculateSectionLengths(?sec:SwagSection):Int
|
2020-10-16 11:03:10 +00:00
|
|
|
{
|
2021-03-02 04:00:02 +00:00
|
|
|
var daLength:Int = 0;
|
2020-10-16 11:03:10 +00:00
|
|
|
|
2021-03-02 04:00:02 +00:00
|
|
|
for (i in _song.notes)
|
|
|
|
{
|
|
|
|
var swagLength = i.lengthInSteps;
|
2020-10-16 11:03:10 +00:00
|
|
|
|
2021-03-02 04:00:02 +00:00
|
|
|
if (i.typeOfSection == Section.COPYCAT)
|
|
|
|
swagLength * 2;
|
2020-10-16 11:03:10 +00:00
|
|
|
|
2021-03-02 04:00:02 +00:00
|
|
|
daLength += swagLength;
|
|
|
|
|
|
|
|
if (sec != null && sec == i)
|
|
|
|
{
|
|
|
|
trace('swag loop??');
|
|
|
|
break;
|
|
|
|
}
|
2020-10-16 11:03:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-02 04:00:02 +00:00
|
|
|
return daLength;
|
2021-02-11 22:13:50 +00:00
|
|
|
}*/
|
2020-10-10 09:28:44 +00:00
|
|
|
private var daSpacing:Float = 0.3;
|
|
|
|
|
2020-10-14 01:44:07 +00:00
|
|
|
function loadLevel():Void
|
|
|
|
{
|
2020-10-14 08:30:54 +00:00
|
|
|
trace(_song.notes);
|
2020-10-14 01:44:07 +00:00
|
|
|
}
|
|
|
|
|
2020-10-13 08:37:19 +00:00
|
|
|
function getNotes():Array<Dynamic>
|
2020-10-10 04:22:26 +00:00
|
|
|
{
|
2020-10-13 08:07:04 +00:00
|
|
|
var noteData:Array<Dynamic> = [];
|
|
|
|
|
2020-10-14 08:30:54 +00:00
|
|
|
for (i in _song.notes)
|
2020-10-13 08:07:04 +00:00
|
|
|
{
|
2020-10-19 00:59:53 +00:00
|
|
|
noteData.push(i.sectionNotes);
|
2020-10-13 08:07:04 +00:00
|
|
|
}
|
|
|
|
|
2020-10-13 08:37:19 +00:00
|
|
|
return noteData;
|
|
|
|
}
|
|
|
|
|
2020-10-18 01:47:59 +00:00
|
|
|
function loadJson(song:String):Void
|
|
|
|
{
|
2020-11-02 22:40:12 +00:00
|
|
|
PlayState.SONG = Song.loadFromJson(song.toLowerCase(), song.toLowerCase());
|
2020-10-18 01:47:59 +00:00
|
|
|
FlxG.resetState();
|
|
|
|
}
|
|
|
|
|
2020-12-25 09:09:14 +00:00
|
|
|
function loadAutosave():Void
|
|
|
|
{
|
|
|
|
PlayState.SONG = Song.parseJSONshit(FlxG.save.data.autosave);
|
|
|
|
FlxG.resetState();
|
|
|
|
}
|
2020-11-06 09:57:00 +00:00
|
|
|
|
2020-12-25 09:09:14 +00:00
|
|
|
function autosaveSong():Void
|
2020-11-06 09:57:00 +00:00
|
|
|
{
|
2020-12-25 09:09:14 +00:00
|
|
|
FlxG.save.data.autosave = Json.stringify({
|
2021-02-11 22:13:50 +00:00
|
|
|
"song": _song
|
2020-12-25 09:09:14 +00:00
|
|
|
});
|
|
|
|
FlxG.save.flush();
|
2020-11-06 09:57:00 +00:00
|
|
|
}
|
|
|
|
|
2020-10-13 08:37:19 +00:00
|
|
|
private function saveLevel()
|
|
|
|
{
|
2020-10-10 04:22:26 +00:00
|
|
|
var json = {
|
2021-02-11 22:13:50 +00:00
|
|
|
"song": _song
|
2020-10-10 04:22:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var data:String = Json.stringify(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);
|
2020-10-19 02:18:06 +00:00
|
|
|
_file.save(data.trim(), _song.song.toLowerCase() + ".json");
|
2020-10-10 04:22:26 +00:00
|
|
|
}
|
2020-10-10 02:39:52 +00:00
|
|
|
}
|
2020-10-10 03:22:07 +00:00
|
|
|
|
|
|
|
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 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");
|
|
|
|
}
|
2020-10-10 02:39:52 +00:00
|
|
|
}
|