diff --git a/Project.xml b/Project.xml index 22550498e..dcde8dc16 100644 --- a/Project.xml +++ b/Project.xml @@ -48,9 +48,10 @@ <!--In case you want to use the addons package--> <haxelib name="flixel-addons" /> + <haxelib name="hscript" /> <!--In case you want to use the ui package--> - <!-- <haxelib name="flixel-ui" /> --> + <haxelib name="flixel-ui" /> <!--In case you want to use nape with flixel--> <!--<haxelib name="nape-haxe4" />--> diff --git a/source/ChartingState.hx b/source/ChartingState.hx index 34d057884..8ac9a4762 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -3,7 +3,10 @@ package; import flixel.FlxG; import flixel.FlxSprite; import flixel.FlxState; +import flixel.addons.ui.FlxUI9SliceSprite; +import flixel.addons.ui.FlxUICheckBox; import flixel.group.FlxGroup.FlxTypedGroup; +import flixel.group.FlxGroup; import flixel.text.FlxText; import flixel.ui.FlxButton; import flixel.ui.FlxSpriteButton; @@ -13,6 +16,7 @@ import openfl.events.Event; import openfl.events.IOErrorEvent; import openfl.events.IOErrorEvent; import openfl.events.IOErrorEvent; +import openfl.geom.Rectangle; import openfl.net.FileReference; class ChartingState extends MusicBeatState @@ -22,6 +26,8 @@ class ChartingState extends MusicBeatState var sectionShit:FlxTypedGroup<DisplayNote>; var notes:Array<Dynamic> = []; + var UI_box:FlxUI9SliceSprite; + /** * Array of notes showing when each section STARTS in STEPS * Usually rounded up?? @@ -34,6 +40,10 @@ class ChartingState extends MusicBeatState var strumLine:FlxSprite; var curSong:String = 'Fresh'; var amountSteps:Int = 0; + private var curNoteSelected:DisplayNote; + var bullshitUI:FlxGroup; + + var highlight:FlxSprite; override function create() { @@ -66,9 +76,59 @@ class ChartingState extends MusicBeatState sectionData.set(0, 0); updateSectionColors(); + highlight = new FlxSprite().makeGraphic(10, 10, FlxColor.BLUE); + add(highlight); + + UI_box = new FlxUI9SliceSprite(FlxG.width / 2, 20, null, new Rectangle(0, 0, FlxG.width * 0.46, 400)); + add(UI_box); + + bullshitUI = new FlxGroup(); + add(bullshitUI); + super.create(); } + 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); + + var loopCheck = new FlxUICheckBox(UI_box.x + 10, UI_box.y + 50, null, null, "Loops", 100, ['loop check']); + bullshitUI.add(loopCheck); + + switch (curNoteSelected.type) + { + case DisplayNote.SECTION: + title.text = 'Section note'; + case DisplayNote.PLAY_NOTE: + title.text = 'Play note'; + } + } + + 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) + { + case 'Loops': + curNoteSelected.doesLoop = check.checked; + trace(curNoteSelected.doesLoop); + } + FlxG.log.add(label); + } + + // FlxG.log.add(id + " WEED " + sender + " WEED " + data + " WEED " + params); + } + function updateSectionColors():Void { sectionShit.forEach(function(note:DisplayNote) @@ -82,6 +142,14 @@ class ChartingState extends MusicBeatState { var sec:FlxText = new FlxText(strumLine.width, 0, 0, "Section " + i); var sectionTex:DisplayNote = createDisplayNote(5, i - 1, sec); + sectionTex.type = DisplayNote.SECTION; + + sectionTex.onDown.callback = function() + { + curNoteSelected = sectionTex; + generateUI(); + }; + sectionTex.strumTime = sectionData.get(i) * Conductor.stepCrochet; sequencer.add(sectionTex); sectionShit.add(sectionTex); @@ -107,14 +175,39 @@ class ChartingState extends MusicBeatState for (i in 0...amountSteps) { notes[r].push(false); - var seqBtn:DisplayNote = createDisplayNote(r, i, null, function() - { - if (notes[r][i] == 0) - notes[r][i] = 1; - else - notes[r][i] = 0; - }); + var seqBtn:DisplayNote = createDisplayNote(r, i, null); + /* seqBtn.onUp.callback = function() + { + if (seqBtn == curNoteSelected) + { + if (notes[r][i] == 0) + notes[r][i] = 1; + else + notes[r][i] = 0; + } + else + curNoteSelected = seqBtn; + } + */ + + seqBtn.onDown.callback = function() + { + if (FlxG.keys.pressed.SHIFT) + { + curNoteSelected = seqBtn; + generateUI(); + } + else + { + if (notes[r][i] == 0) + notes[r][i] = 1; + else + notes[r][i] = 0; + } + }; + + seqBtn.type = DisplayNote.PLAY_NOTE; seqBtn.strumTime = Conductor.stepCrochet * i; seqBtn.makeGraphic(30, 30, FlxColor.WHITE); seqBtn.ID = i + (amountSteps * r); @@ -127,6 +220,9 @@ class ChartingState extends MusicBeatState { Conductor.songPosition = FlxG.sound.music.time; + if (curNoteSelected != null) + highlight.setPosition(curNoteSelected.getGraphicMidpoint().x, curNoteSelected.getGraphicMidpoint().y); + if (FlxG.mouse.justPressedMiddle && section > 0) { var pushSection:Int = Math.round(Conductor.songPosition / Conductor.crochet) * 4; diff --git a/source/DisplayNote.hx b/source/DisplayNote.hx index 171e98c41..95e70de42 100644 --- a/source/DisplayNote.hx +++ b/source/DisplayNote.hx @@ -6,6 +6,17 @@ import flixel.ui.FlxSpriteButton; class DisplayNote extends FlxSpriteButton { public var strumTime:Float = 0; + public var type:Int = 0; + + public static inline var PLAY_NOTE:Int = 10; + public static inline var SECTION:Int = 20; + + public var selected:Bool = false; + + // SECTION SPECIFIC DATA + // If it's a simon says type section + public var doesLoop:Bool = true; + public var lengthInSteps:Int = 16; public function new(x:Float, y:Float, label:FlxSprite, onClick:Void->Void) { diff --git a/source/MusicBeatState.hx b/source/MusicBeatState.hx index 9b96609eb..ced8ab1b2 100644 --- a/source/MusicBeatState.hx +++ b/source/MusicBeatState.hx @@ -1,8 +1,9 @@ package; import flixel.addons.transition.FlxTransitionableState; +import flixel.addons.ui.FlxUIState; -class MusicBeatState extends FlxTransitionableState +class MusicBeatState extends FlxUIState { private var lastBeat:Float = 0; private var lastStep:Float = 0;