From ba178cd446f6bc690ed1229f9d967ac1bc357303 Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Mon, 4 Nov 2024 19:12:12 -0500 Subject: [PATCH 01/20] Add record icon so it begins --- assets/images/editors/ui/context-icons.png | Bin 833 -> 1568 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/assets/images/editors/ui/context-icons.png b/assets/images/editors/ui/context-icons.png index 733a852327f572e1f62df277b89a11c1f93c2e23..bb90746144e2a9704b2e8066ee8c6d2bed6f7e06 100644 GIT binary patch literal 1568 zcmV+*2H*LKP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D1+_^;K~!i%?U}!C z97PnzXMH}O!MVg|8v`atxIl6m3U^SXjOeH+K*9(*NkIWpVuNFuGXxWx^W}Kock{-xvopK1_tOO*>FMpv?7n-u?|U=*BTNOH{JkKiNf+6{x) zdQjhSwNpz$0Df{*0HTIfN4&xvtmOI-Y z>6TJIZdJ<&2624*g!-9KJt~#T!*;ukIz-ijaN}ge^6T1~-sISb4wg8#DEw83k>w!}RoYYjSc@)$4WK-1b$EkXV59xigP| z#Go7`g(Qx}&?cKAtK}v4ZReKWV(_G7g9{>7MBctJ#}`o)!;H%^WX~)RjWfI0xUoZR zyFau~0&$S9E-x=DU5_K0UDVXnl&aNg=!>m~;Qp3ZEJ9$6V_-?b6o<#MztJI3|01~w z>i@ml<4^AM<1clKkEvU6GD(_y7i&oZ&b^G_olZl_58+I$c1#-+-@Ru6ff*(=-J?Hq z?ghv(T#wb&)dyQ!TRZ?(R#w#h{=S-+m{7aBySlfy9)#qWx_)_LvH9ZgP!S_$-jYwWF`UI&H=99f~gFDnB^jwT{(sq#rldDfGz%#SB zaZb;-KL%Eh+1XijaBwhi!C*-;&+AA6<`N;6d2)DRmtK;}iUss?Oz#XrEQ6-+dd$tu zsgsl8yg!v2ECxxy>?9+^@)$X+xyUg6S>RUDi$)J+kGXg6)NFixX;QO7y#eF za#i~>*vIr$kA;N=EMMn`DVPkBWQ15AC-*NI1Ou_8r{?$Q2^#{i&BYzZF)`$cBwr{X zHM0ozy-E*ak)m&C?;_)_pwJE-!^GBOk(TMby}b*x*=o1_pY(7~hoz9+XDv;#}-!G&XY4L#fahpS2u64Z#$S)GRKql6k^}61Q z!(D^5=XmxqWQ%3?A#6d72!=A~TC5=e~n+=_VW&Oi^J{C)@*ee2xXd;NC^vw+!G0*A)PM z#}^~ikLz2y9`p0_cj&(595svTk-3KMjO|;72$L%WgO_u7Nrxo&xtBnaz#|qsHbX3O z--5*Og|w)k-SOT9Ge}IXSbl^dJPl=L5KX8b*Lc|VD5{f7>N-F$@)>~N?Al4%(0)tg zkeEz+uvoEx(|zP#CcPYuMKA$InM;Zh)gx9knd<<-$fGrXvmnDKf>b4GA3QoEA^Y*U zj97%wzN0QsUe03^3pnfbfM75PvlA6VKY}75F(lSYa)NuzSPOL47(+cupwxeJce2@A SS8BQd0000BIN literal 833 zcmeAS@N?(olHy`uVBq!ia0vp^6+kS)!3-n|dpHjQDaPU;cPEB*=VV?2Ia>mJLR^9L ze`*7uneRV!PW`|5(sh|9^KUO&ruZN(j^UUDLxMC+6cQE@6%&_`l#kV#B#5ZST8^m}Ypjb@P_}etPA@+!az6RxUc)wyXPS z(&f)DuSf*02sYNamfdhmcU#OOi5Kg_Rx`9EL_N+=xp4igao+B`d3?J2}@p9C0KaB(DUF+Fvy>!_E_V{$Cm<9F+GyWSyh?4q8n~$u~;)t za{1jO9BYx-uyDENkHVV64?g@3&p5$lkbmzd-;`3$GNW_n9antOJ67B0A^+)Vc+I^( zKg1-T1l3%h!t>m$BTn${-+$ewWgE&hXTO{4*?WA_)sj<(^4769n|ra(*&$nyWFx~e zoAFIq_Wf92m2`&d3#(-hRLhtMZtE)6z0;P%-TATj(~;87wQukFrOq>SkX#(dV{xNB zp?==p(;h}i-jfgR{8+2?KV=K=_J|qpYJ;EM>d5_SarkN5up7XaP zY(H=Jmb2X0Os*#|q&TazeB}md)q?Vj>E`Ep3(R-(=!tBb!e6Y){JrE*!JZFBZ;bAQ zmR=1xRMNcusAFE%kJFJ?eb=61+MN>nZBvQVe}?BRciuIg%u)g-BL+`bKbLh*2~7a0 CLyGbM From 14e875cc6b266ed56b6a88ef4345b0438efcd86f Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Mon, 4 Nov 2024 19:15:04 -0500 Subject: [PATCH 02/20] Add dropdown shit --- source/funkin/editors/charter/Charter.hx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 2ff39aa01..ba192f19f 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -241,6 +241,21 @@ class Charter extends UIState { onSelect: _chart_playtest_opponent_here }, null, + { + label: "Record live charting", + color: 0xFFA91734, + icon: 7, + keybind: [CONTROL, R], + onSelect: _chart_live + }, + { + label: "Record live charting here", + color: 0xFFA91734, + icon: 7, + keybind: [CONTROL, SHIFT, R], + onSelect: _chart_live_here + }, + null, { label: 'Enable scripts during playtesting', onSelect: _chart_enablescripts, @@ -1528,6 +1543,10 @@ class Charter extends UIState { playtestChart(0, true); inline function _chart_playtest_opponent_here(_) playtestChart(Conductor.songPosition, true, true); + inline function _chart_live(_) + trace("make this"); + inline function _chart_live_here(_) + trace("and this too"); function _chart_enablescripts(t) { t.icon = (Options.charterEnablePlaytestScripts = !Options.charterEnablePlaytestScripts) ? 1 : 0; } @@ -2005,4 +2024,4 @@ typedef PlaytestInfo = { var hitSounds:Array; var mutedVocals:Array; var waveforms:Array; -} \ No newline at end of file +} From d8cfe1900d27369b6cef60d5ef3c01a2aeac25aa Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Mon, 4 Nov 2024 19:19:55 -0500 Subject: [PATCH 03/20] Make the things play the song --- source/funkin/editors/charter/Charter.hx | 39 ++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index ba192f19f..36c844a5f 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -1543,9 +1543,44 @@ class Charter extends UIState { playtestChart(0, true); inline function _chart_playtest_opponent_here(_) playtestChart(Conductor.songPosition, true, true); - inline function _chart_live(_) + inline function _chart_live(_) { trace("make this"); - inline function _chart_live_here(_) + + if (Conductor.songPosition >= FlxG.sound.music.getDefault(vocals).length - Conductor.songOffset) return; + + if (FlxG.sound.music.playing) { + FlxG.sound.music.pause(); + vocals.pause(); + for (strumLine in strumLines.members) strumLine.vocals.pause(); + } else { + FlxG.sound.music.play(); + vocals.play(); + vocals.time = FlxG.sound.music.time = Conductor.songPosition + Conductor.songOffset * 2; + for (strumLine in strumLines.members) { + strumLine.vocals.play(); + strumLine.vocals.time = vocals.time; + } + } + } + inline function _chart_live_here(_) { + trace("and this too"); + + if (Conductor.songPosition >= FlxG.sound.music.getDefault(vocals).length - Conductor.songOffset) return; + + if (FlxG.sound.music.playing) { + FlxG.sound.music.pause(); + vocals.pause(); + for (strumLine in strumLines.members) strumLine.vocals.pause(); + } else { + FlxG.sound.music.play(); + vocals.play(); + vocals.time = FlxG.sound.music.time = Conductor.songPosition + Conductor.songOffset * 2; + for (strumLine in strumLines.members) { + strumLine.vocals.play(); + strumLine.vocals.time = vocals.time; + } + } + } trace("and this too"); function _chart_enablescripts(t) { t.icon = (Options.charterEnablePlaytestScripts = !Options.charterEnablePlaytestScripts) ? 1 : 0; From 134ffe600ad31d7b0789726a417ea8c7fe84b41f Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Mon, 4 Nov 2024 19:34:16 -0500 Subject: [PATCH 04/20] Add notes for coding fuck you, songposition --- source/funkin/editors/charter/Charter.hx | 58 ++++++++++++------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 36c844a5f..bae1a18cc 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -1543,42 +1543,42 @@ class Charter extends UIState { playtestChart(0, true); inline function _chart_playtest_opponent_here(_) playtestChart(Conductor.songPosition, true, true); - inline function _chart_live(_) { + inline function _chart_live(_) + { trace("make this"); - if (Conductor.songPosition >= FlxG.sound.music.getDefault(vocals).length - Conductor.songOffset) return; + Conductor.songPosition = 0; // fuck you - if (FlxG.sound.music.playing) { - FlxG.sound.music.pause(); - vocals.pause(); - for (strumLine in strumLines.members) strumLine.vocals.pause(); - } else { - FlxG.sound.music.play(); - vocals.play(); - vocals.time = FlxG.sound.music.time = Conductor.songPosition + Conductor.songOffset * 2; - for (strumLine in strumLines.members) { - strumLine.vocals.play(); - strumLine.vocals.time = vocals.time; - } + // pause until a SL was selected + // start countdown + // only after all that can it... + + FlxG.sound.music.play(); + vocals.play(); + + vocals.time = FlxG.sound.music.time = Conductor.songPosition + Conductor.songOffset * 2; + for (strumLine in strumLines.members) + { + strumLine.vocals.play(); + strumLine.vocals.time = vocals.time; } } - inline function _chart_live_here(_) { + + inline function _chart_live_here(_) + { trace("and this too"); - - if (Conductor.songPosition >= FlxG.sound.music.getDefault(vocals).length - Conductor.songOffset) return; - if (FlxG.sound.music.playing) { - FlxG.sound.music.pause(); - vocals.pause(); - for (strumLine in strumLines.members) strumLine.vocals.pause(); - } else { - FlxG.sound.music.play(); - vocals.play(); - vocals.time = FlxG.sound.music.time = Conductor.songPosition + Conductor.songOffset * 2; - for (strumLine in strumLines.members) { - strumLine.vocals.play(); - strumLine.vocals.time = vocals.time; - } + // pause until a SL was selected + // start countdown + // only after all that can it... + + FlxG.sound.music.play(); + vocals.play(); + vocals.time = FlxG.sound.music.time = Conductor.songPosition + Conductor.songOffset * 2; + for (strumLine in strumLines.members) + { + strumLine.vocals.play(); + strumLine.vocals.time = vocals.time; } } trace("and this too"); From adebf289dbd04033d6dd0a0567e924f51d30a215 Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Tue, 5 Nov 2024 22:26:31 -0500 Subject: [PATCH 05/20] Keybind charting test The notes aren't visually appearing for some reason (help) --- source/funkin/editors/charter/Charter.hx | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index bae1a18cc..050591b14 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -1166,6 +1166,43 @@ class Charter extends UIState { updateNoteLogic(elapsed); updateAutoSaving(elapsed); + // TEST CODE ----------------------------- + + if (controls.LEFT) + { + var debugcodeteehee = new CharterNote(); + debugcodeteehee.updatePos(1.0, 0, 0, 0); + // add(debugcodeteehee); + notesGroup.add(debugcodeteehee); + trace(debugcodeteehee); + } + else if (controls.DOWN) + { + var debugcodeteehee = new CharterNote(); + debugcodeteehee.updatePos(1.0, 1, 0, 0); + // add(debugcodeteehee); + notesGroup.add(debugcodeteehee); + trace(debugcodeteehee); + } + else if (controls.UP) + { + var debugcodeteehee = new CharterNote(); + debugcodeteehee.updatePos(1.0, 2, 0, 0); + // add(debugcodeteehee); + notesGroup.add(debugcodeteehee); + trace(debugcodeteehee); + } + else if (controls.RIGHT) + { + var debugcodeteehee = new CharterNote(); + debugcodeteehee.updatePos(1.0, 3, 0, 0); + // add(debugcodeteehee); + notesGroup.add(debugcodeteehee); + trace(debugcodeteehee); + } + + // TEST CODE ----------------------------- + if (FlxG.sound.music.playing || __firstFrame) { gridBackdrops.conductorSprY = curStepFloat * 40; } else { From a3f80da46af20cdfc5306fcdf32cc27494e84aff Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Wed, 6 Nov 2024 07:43:16 -0500 Subject: [PATCH 06/20] add Live Charting check --- source/funkin/editors/charter/Charter.hx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 050591b14..bee2211a7 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -87,6 +87,9 @@ class Charter extends UIState { public var uiCamera:FlxCamera; public var selectionBox:UISliceSprite; public var autoSaveNotif:CharterAutoSaveUI; + + public var isLiveCharting:Bool = false; + public static var autoSaveTimer:Float = 0; public static var selection:Selection; @@ -1584,6 +1587,7 @@ class Charter extends UIState { { trace("make this"); + isLiveCharting = true; Conductor.songPosition = 0; // fuck you // pause until a SL was selected @@ -1605,6 +1609,7 @@ class Charter extends UIState { { trace("and this too"); + isLiveCharting = true; // pause until a SL was selected // start countdown // only after all that can it... From 97b454ba2c93f27eb56c7b1fc4aa8ecb01c6b807 Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Wed, 6 Nov 2024 08:02:38 -0500 Subject: [PATCH 07/20] Add checks for keybinds that could interfere This has not been tested --- source/funkin/editors/charter/Charter.hx | 134 ++++++++++++++--------- 1 file changed, 84 insertions(+), 50 deletions(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index bee2211a7..98fe49b67 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -1170,38 +1170,41 @@ class Charter extends UIState { updateAutoSaving(elapsed); // TEST CODE ----------------------------- - - if (controls.LEFT) - { - var debugcodeteehee = new CharterNote(); - debugcodeteehee.updatePos(1.0, 0, 0, 0); - // add(debugcodeteehee); - notesGroup.add(debugcodeteehee); - trace(debugcodeteehee); - } - else if (controls.DOWN) - { - var debugcodeteehee = new CharterNote(); - debugcodeteehee.updatePos(1.0, 1, 0, 0); - // add(debugcodeteehee); - notesGroup.add(debugcodeteehee); - trace(debugcodeteehee); - } - else if (controls.UP) - { - var debugcodeteehee = new CharterNote(); - debugcodeteehee.updatePos(1.0, 2, 0, 0); - // add(debugcodeteehee); - notesGroup.add(debugcodeteehee); - trace(debugcodeteehee); - } - else if (controls.RIGHT) + + if (isChartingLive) { - var debugcodeteehee = new CharterNote(); - debugcodeteehee.updatePos(1.0, 3, 0, 0); - // add(debugcodeteehee); - notesGroup.add(debugcodeteehee); - trace(debugcodeteehee); + if (controls.LEFT) + { + var debugcodeteehee = new CharterNote(); + debugcodeteehee.updatePos(1.0, 0, 0, 0); + // add(debugcodeteehee); + notesGroup.add(debugcodeteehee); + trace(debugcodeteehee); + } + else if (controls.DOWN) + { + var debugcodeteehee = new CharterNote(); + debugcodeteehee.updatePos(1.0, 1, 0, 0); + // add(debugcodeteehee); + notesGroup.add(debugcodeteehee); + trace(debugcodeteehee); + } + else if (controls.UP) + { + var debugcodeteehee = new CharterNote(); + debugcodeteehee.updatePos(1.0, 2, 0, 0); + // add(debugcodeteehee); + notesGroup.add(debugcodeteehee); + trace(debugcodeteehee); + } + else if (controls.RIGHT) + { + var debugcodeteehee = new CharterNote(); + debugcodeteehee.updatePos(1.0, 3, 0, 0); + // add(debugcodeteehee); + notesGroup.add(debugcodeteehee); + trace(debugcodeteehee); + } } // TEST CODE ----------------------------- @@ -1476,12 +1479,18 @@ class Charter extends UIState { deleteSelection(selection, false); } - function _edit_delete(_) { - if (selection == null || selection.length == 0) return; - selection.loop((n:CharterNote) -> { - noteDeleteAnims.deleteNotes.push({note: n, time: noteDeleteAnims.deleteTime}); - }); - selection = deleteSelection(selection, true); + function _edit_delete(_) + { + if (!isChartingLive) + { + if (selection == null || selection.length == 0) + return; + selection.loop((n:CharterNote) -> + { + noteDeleteAnims.deleteNotes.push({note: n, time: noteDeleteAnims.deleteTime}); + }); + selection = deleteSelection(selection, true); + } } function _edit_undo(_) { @@ -1576,13 +1585,17 @@ class Charter extends UIState { } inline function _chart_playtest(_) - playtestChart(0, false); + if (!isChartingLive) + playtestChart(0, false); inline function _chart_playtest_here(_) - playtestChart(Conductor.songPosition, false, true); + if (!isChartingLive) + playtestChart(Conductor.songPosition, false, true); inline function _chart_playtest_opponent(_) - playtestChart(0, true); + if (!isChartingLive) + playtestChart(0, true); inline function _chart_playtest_opponent_here(_) - playtestChart(Conductor.songPosition, true, true); + if (!isChartingLive) + playtestChart(Conductor.songPosition, true, true); inline function _chart_live(_) { trace("make this"); @@ -1708,12 +1721,22 @@ class Charter extends UIState { for (shader in waveformHandler.waveShaders) shader.data.lowDetail.value = [Options.charterLowDetailWaveforms]; } - inline function _snap_increasesnap(_) changequant(1); - inline function _snap_decreasesnap(_) changequant(-1); - inline function _snap_resetsnap(_) setquant(16); - - inline function changequant(change:Int) {quant = quants[FlxMath.wrap(quants.indexOf(quant) + change, 0, quants.length-1)]; buildSnapsUI();}; - inline function setquant(newquant:Int) {quant = newquant; buildSnapsUI();} + inline function _snap_increasesnap(_) if (!isChartingLive) changequant(1); + inline function _snap_decreasesnap(_) if (!isChartingLive) changequant(-1); + inline function _snap_resetsnap(_) if (!isChartingLive) setquant(16); + + inline function changequant(change:Int) { + if (!isChartingLive) { + quant = quants[FlxMath.wrap(quants.indexOf(quant) + change, 0, quants.length-1)]; + buildSnapsUI(); + } + }; + inline function setquant(newquant:Int) { + if (!isChartingLive) { + quant = newquant; + buildSnapsUI(); + } + } function buildSnapsUI():Array { var snapsTopButton:UITopMenuButton = topMenuSpr == null ? null : cast topMenuSpr.members[snapIndex]; @@ -1747,10 +1770,12 @@ class Charter extends UIState { } inline function _note_addsustain(t) - changeNoteSustain(1); + if (!isChartingLive) + changeNoteSustain(1); inline function _note_subtractsustain(t) - changeNoteSustain(-1); + if (!isChartingLive) + changeNoteSustain(-1); function _note_selectall(_) { selection = [for (note in notesGroup.members) note]; @@ -1910,7 +1935,16 @@ class Charter extends UIState { } public inline function hitsoundsEnabled(id:Int) - return strumLines.members[id] != null && strumLines.members[id].hitsounds; + { + if (!isChartingLive) + { + return strumLines.members[id] != null && strumLines.members[id].hitsounds; + } + else + { + return false; + } + } public inline function __fixSelection(selection:Selection):Selection { var newSelection:Selection = new Selection(); From 0db2de6de9d92d8e9a1df4d3e77b4df76025df55 Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Wed, 6 Nov 2024 08:09:11 -0500 Subject: [PATCH 08/20] whoopsie daisy gee willikers by jove oh stars I have the demonetnia --- source/funkin/editors/charter/Charter.hx | 28 ++++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 98fe49b67..f5b125a22 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -1171,7 +1171,7 @@ class Charter extends UIState { // TEST CODE ----------------------------- - if (isChartingLive) + if (isLiveCharting) { if (controls.LEFT) { @@ -1481,7 +1481,7 @@ class Charter extends UIState { function _edit_delete(_) { - if (!isChartingLive) + if (!isLiveCharting) { if (selection == null || selection.length == 0) return; @@ -1585,16 +1585,16 @@ class Charter extends UIState { } inline function _chart_playtest(_) - if (!isChartingLive) + if (!isLiveCharting) playtestChart(0, false); inline function _chart_playtest_here(_) - if (!isChartingLive) + if (!isLiveCharting) playtestChart(Conductor.songPosition, false, true); inline function _chart_playtest_opponent(_) - if (!isChartingLive) + if (!isLiveCharting) playtestChart(0, true); inline function _chart_playtest_opponent_here(_) - if (!isChartingLive) + if (!isLiveCharting) playtestChart(Conductor.songPosition, true, true); inline function _chart_live(_) { @@ -1721,18 +1721,18 @@ class Charter extends UIState { for (shader in waveformHandler.waveShaders) shader.data.lowDetail.value = [Options.charterLowDetailWaveforms]; } - inline function _snap_increasesnap(_) if (!isChartingLive) changequant(1); - inline function _snap_decreasesnap(_) if (!isChartingLive) changequant(-1); - inline function _snap_resetsnap(_) if (!isChartingLive) setquant(16); + inline function _snap_increasesnap(_) if (!isLiveCharting) changequant(1); + inline function _snap_decreasesnap(_) if (!isLiveCharting) changequant(-1); + inline function _snap_resetsnap(_) if (!isLiveCharting) setquant(16); inline function changequant(change:Int) { - if (!isChartingLive) { + if (!isLiveCharting) { quant = quants[FlxMath.wrap(quants.indexOf(quant) + change, 0, quants.length-1)]; buildSnapsUI(); } }; inline function setquant(newquant:Int) { - if (!isChartingLive) { + if (!isLiveCharting) { quant = newquant; buildSnapsUI(); } @@ -1770,11 +1770,11 @@ class Charter extends UIState { } inline function _note_addsustain(t) - if (!isChartingLive) + if (!isLiveCharting) changeNoteSustain(1); inline function _note_subtractsustain(t) - if (!isChartingLive) + if (!isLiveCharting) changeNoteSustain(-1); function _note_selectall(_) { @@ -1936,7 +1936,7 @@ class Charter extends UIState { public inline function hitsoundsEnabled(id:Int) { - if (!isChartingLive) + if (!isLiveCharting) { return strumLines.members[id] != null && strumLines.members[id].hitsounds; } From e260ad03f42dda8af3f8bece48a1097a8ce462f9 Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Wed, 6 Nov 2024 08:15:40 -0500 Subject: [PATCH 09/20] Add stop to recording --- source/funkin/editors/charter/Charter.hx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index f5b125a22..0e26333cd 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -1616,6 +1616,15 @@ class Charter extends UIState { strumLine.vocals.play(); strumLine.vocals.time = vocals.time; } + + if (controls.ACCEPT) { + FlxG.sound.music.pause(); + vocals.pause(); + for (strumLine in strumLines.members) + strumLine.vocals.pause(); + + isLiveCharting = false; + } } inline function _chart_live_here(_) @@ -1635,6 +1644,15 @@ class Charter extends UIState { strumLine.vocals.play(); strumLine.vocals.time = vocals.time; } + + if (controls.ACCEPT) { + FlxG.sound.music.pause(); + vocals.pause(); + for (strumLine in strumLines.members) + strumLine.vocals.pause(); + + isLiveCharting = false; + } } trace("and this too"); function _chart_enablescripts(t) { From 6628689f679259f211269040b7adc0919870d2fb Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Wed, 6 Nov 2024 08:19:53 -0500 Subject: [PATCH 10/20] Actually just Shift + Alt + F the whole thing please --- source/funkin/editors/charter/Charter.hx | 1222 ++++++++++++++-------- 1 file changed, 808 insertions(+), 414 deletions(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 0e26333cd..05445bf2f 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -1,6 +1,6 @@ package funkin.editors.charter; -// ! FUCK YOU CHUF (your biggest fan -lunar) <3 +// ! FUCK YOU CHUF (your biggest fan -lunar) <3 import flixel.input.FlxPointer; import openfl.geom.Point; import openfl.geom.Rectangle; @@ -26,12 +26,14 @@ import flixel.util.FlxColor; import openfl.display.BitmapData; import funkin.backend.shaders.CustomShader; -class Charter extends UIState { +class Charter extends UIState +{ public static var __song:String; static var __diff:String; static var __reload:Bool; var chart(get, null):ChartData; + private function get_chart() return PlayState.SONG; @@ -44,6 +46,7 @@ class Charter extends UIState { public var uiGroup:FlxTypedGroup = new FlxTypedGroup(); public var topMenu:Array; + @:noCompletion private var playbackIndex:Int = 7; @:noCompletion private var snapIndex:Int = 6; @:noCompletion private var noteIndex:Int = 5; @@ -89,7 +92,7 @@ class Charter extends UIState { public var autoSaveNotif:CharterAutoSaveUI; public var isLiveCharting:Bool = false; - + public static var autoSaveTimer:Float = 0; public static var selection:Selection; @@ -100,21 +103,27 @@ class Charter extends UIState { public static var clipboard:Array = []; public static var waveformHandler:CharterWaveformHandler; - public function new(song:String, diff:String, reload:Bool = true) { + public function new(song:String, diff:String, reload:Bool = true) + { super(); - if (song != null) { + if (song != null) + { __song = song; __diff = diff; __reload = reload; } } - public override function create() { + public override function create() + { super.create(); WindowUtils.suffix = " (Chart Editor)"; SaveWarning.selectionClass = CharterSelection; - SaveWarning.saveFunc = () -> {_file_save(null);}; + SaveWarning.saveFunc = () -> + { + _file_save(null); + }; topMenu = [ { @@ -163,7 +172,7 @@ class Charter extends UIState { }, { label: "Save Meta As...", - keybind: [CONTROL, ALT ,SHIFT, S], + keybind: [CONTROL, ALT, SHIFT, S], onSelect: _file_meta_saveas, }, null, @@ -267,14 +276,22 @@ class Charter extends UIState { null, { label: "Edit chart data", - color: 0xFF959829, icon: 4, - onCreate: function (button:UIContextMenuOptionSpr) {button.label.offset.x = button.icon.offset.x = -2;}, + color: 0xFF959829, + icon: 4, + onCreate: function(button:UIContextMenuOptionSpr) + { + button.label.offset.x = button.icon.offset.x = -2; + }, onSelect: chart_edit_data }, { label: "Edit metadata information", - color: 0xFF959829, icon: 4, - onCreate: function (button:UIContextMenuOptionSpr) {button.label.offset.x = button.icon.offset.x = -2;}, + color: 0xFF959829, + icon: 4, + onCreate: function(button:UIContextMenuOptionSpr) + { + button.label.offset.x = button.icon.offset.x = -2; + }, onSelect: chart_edit_metadata } ] @@ -401,7 +418,8 @@ class Charter extends UIState { uiCamera.bgColor = 0; FlxG.cameras.add(uiCamera); - for (camera in FlxG.cameras.list) camera.antialiasing = false; + for (camera in FlxG.cameras.list) + camera.antialiasing = false; charterBG = new FunkinSprite(0, 0, Paths.image('menus/menuDesat')); charterBG.color = 0xFF181818; @@ -427,8 +445,7 @@ class Charter extends UIState { noteHoverer = new CharterNoteHoverer(); noteDeleteAnims = new CharterDeleteAnim(); - selectionBox.cameras = notesGroup.cameras = gridBackdrops.cameras = - noteHoverer.cameras = noteDeleteAnims.cameras = [charterCamera]; + selectionBox.cameras = notesGroup.cameras = gridBackdrops.cameras = noteHoverer.cameras = noteDeleteAnims.cameras = [charterCamera]; topMenuSpr = new UITopMenu(topMenu); topMenuSpr.cameras = uiGroup.cameras = [uiCamera]; @@ -438,7 +455,8 @@ class Charter extends UIState { scrollBar = new UIScrollBar(FlxG.width - 20, topMenuSpr.bHeight, 1000, 0, 100); scrollBar.cameras = [uiCamera]; - scrollBar.onChange = function(v) { + scrollBar.onChange = function(v) + { if (!FlxG.sound.music.playing) Conductor.songPosition = Conductor.getTimeForStep(v) + Conductor.songOffset; }; @@ -448,17 +466,24 @@ class Charter extends UIState { songPosInfo.alignment = RIGHT; uiGroup.add(songPosInfo); - playBackSlider = new UISlider(FlxG.width - 160 - 26 - 20, (23/2) - (12/2), 160, 1, [{start: 0.25, end: 1, size: 0.5}, {start: 1, end: 2, size: 0.5}], true); - playBackSlider.onChange = function (v) { + playBackSlider = new UISlider(FlxG.width - 160 - 26 - 20, (23 / 2) - (12 / 2), 160, 1, + [{start: 0.25, end: 1, size: 0.5}, {start: 1, end: 2, size: 0.5}], true); + playBackSlider.onChange = function(v) + { FlxG.sound.music.pitch = vocals.pitch = v; - for (strumLine in strumLines.members) strumLine.vocals.pitch = v; + for (strumLine in strumLines.members) + strumLine.vocals.pitch = v; }; uiGroup.add(playBackSlider); quants.reverse(); - for (quant in quants) { + for (quant in quants) + { var button:CharterQuantButton = new CharterQuantButton(0, 0, quant); - button.onClick = () -> {setquant(button.quant);}; + button.onClick = () -> + { + setquant(button.quant); + }; quantButtons.push(cast uiGroup.add(button)); } quants.reverse(); @@ -477,8 +502,10 @@ class Charter extends UIState { strumlineAddButton.textColorLerp = 0.5; strumlineLockButton = new CharterStrumlineButton("editors/charter/lock-strumline", "Lock/Unlock"); - strumlineLockButton.onClick = function () { - if (strumLines != null) { + strumlineLockButton.onClick = function() + { + if (strumLines != null) + { strumLines.draggable = !strumLines.draggable; strumlineLockButton.textTweenColor.color = strumLines.draggable ? 0xFF5C95CA : 0xFFE16565; } @@ -514,7 +541,8 @@ class Charter extends UIState { loadSong(); - if(Framerate.isLoaded) { + if (Framerate.isLoaded) + { Framerate.fpsCounter.alpha = 0.4; Framerate.memoryCounter.alpha = 0.4; Framerate.codenameBuildField.alpha = 0.4; @@ -523,19 +551,21 @@ class Charter extends UIState { // ! IF YOU EVER WANNA VIEW IN THE FUTURE, JUST USE A FLXSPRITE :D -lunar /*var dataDisplay:FlxSprite = new FlxSprite().loadGraphic(waveformHandler.waveDatas.get("Voices.ogg")); - dataDisplay.scrollFactor.set(1, 0); - dataDisplay.scale.set(2, 2); - dataDisplay.updateHitbox(); - dataDisplay.screenCenter(Y); - dataDisplay.cameras = [charterCamera]; dataDisplay.x = -dataDisplay.width; add(dataDisplay);*/ + dataDisplay.scrollFactor.set(1, 0); + dataDisplay.scale.set(2, 2); + dataDisplay.updateHitbox(); + dataDisplay.screenCenter(Y); + dataDisplay.cameras = [charterCamera]; dataDisplay.x = -dataDisplay.width; add(dataDisplay); */ DiscordUtil.call("onEditorLoaded", ["Chart Editor", __song + " (" + __diff + ")"]); } - override function destroy() { + override function destroy() + { __updatePlaytestInfo(); - if(Framerate.isLoaded) { + if (Framerate.isLoaded) + { Framerate.fpsCounter.alpha = 1; Framerate.memoryCounter.alpha = 1; Framerate.codenameBuildField.alpha = 1; @@ -543,8 +573,10 @@ class Charter extends UIState { super.destroy(); } - public function loadSong() { - if (__reload) { + public function loadSong() + { + if (__reload) + { EventsData.reloadEvents(); PlayState.loadSong(__song, __diff, false, false); __resetStatics(); @@ -561,7 +593,7 @@ class Charter extends UIState { gridBackdrops.createGrids(PlayState.SONG.strumLines.length); - for(strL in PlayState.SONG.strumLines) + for (strL in PlayState.SONG.strumLines) createStrumline(strumLines.members.length, strL, false, false); // create notes @@ -573,7 +605,8 @@ class Charter extends UIState { var notesCreated:Int = 0; for (i => strL in PlayState.SONG.strumLines) - for (note in strL.notes) { + for (note in strL.notes) + { var n = new CharterNote(); var t = Conductor.getStepForTime(note.time); n.updatePos(t, note.id, Conductor.getStepForTime(note.time + note.sLen) - t, note.type, strumLines.members[i]); @@ -586,11 +619,16 @@ class Charter extends UIState { eventsGroup.autoSort = false; var __last:CharterEvent = null; var __lastTime:Float = Math.NaN; - for(e in PlayState.SONG.events) { - if (e == null) continue; - if (__last != null && __lastTime == e.time) { + for (e in PlayState.SONG.events) + { + if (e == null) + continue; + if (__last != null && __lastTime == e.time) + { __last.events.push(e); - } else { + } + else + { __last = new CharterEvent(Conductor.getStepForTime(e.time), [e]); __lastTime = e.time; eventsGroup.add(__last); @@ -600,47 +638,60 @@ class Charter extends UIState { eventsGroup.sortEvents(); eventsGroup.autoSort = true; - for(e in eventsGroup.members) + for (e in eventsGroup.members) e.refreshEventIcons(); buildNoteTypesUI(); refreshBPMSensitive(); // Just for now until i add event stacking -lunar - try {__relinkUndos();} - catch (e) {Logs.trace('Failed to relink undos: ${Std.string(e)}', ERROR);} - + try + { + __relinkUndos(); + } + catch (e) + { + Logs.trace('Failed to relink undos: ${Std.string(e)}', ERROR); + } + __applyPlaytestInfo(); } public var __endStep:Float = 0; - public function refreshBPMSensitive() { + + public function refreshBPMSensitive() + { // refreshes everything dependant on BPM, and BPM changes var length = FlxG.sound.music.getDefault(vocals).length; scrollBar.length = __endStep = Conductor.getStepForTime(length); gridBackdrops.bottomLimitY = __endStep * 40; - eventsBackdrop.bottomSeparator.y = gridBackdrops.bottomLimitY-2; + eventsBackdrop.bottomSeparator.y = gridBackdrops.bottomLimitY - 2; updateWaveforms(); } - inline function isSoundLoaded(sound:FlxSound) { + inline function isSoundLoaded(sound:FlxSound) + { @:privateAccess return sound != null && sound._sound != null && sound._sound.length > 0; } - public function updateWaveforms() { + public function updateWaveforms() + { var wavesToGenerate:Array<{name:String, sound:FlxSound}> = []; - if(isSoundLoaded(FlxG.sound.music)) + if (isSoundLoaded(FlxG.sound.music)) wavesToGenerate.push({name: "Inst.ogg", sound: FlxG.sound.music}); if (PlayState.SONG.meta.needsVoices != false && isSoundLoaded(vocals)) wavesToGenerate.push({name: "Voices.ogg", sound: vocals}); for (strumLine in strumLines) - if (strumLine.vocals != null && strumLine.strumLine.vocalsSuffix != null && strumLine.strumLine.vocalsSuffix != "" && isSoundLoaded(strumLine.vocals)) + if (strumLine.vocals != null + && strumLine.strumLine.vocalsSuffix != null + && strumLine.strumLine.vocalsSuffix != "" + && isSoundLoaded(strumLine.vocals)) wavesToGenerate.push({ name: 'Voices${strumLine.strumLine.vocalsSuffix}.ogg', sound: strumLine.vocals @@ -649,15 +700,19 @@ class Charter extends UIState { var oldWaveformList:Array = waveformHandler.waveformList; var newWaveformList:Array = [for (data in wavesToGenerate) data.name]; - if (waveformHandler == null ? true : waveformHandler.ampsNeeded != __endStep*40) { + if (waveformHandler == null ? true : waveformHandler.ampsNeeded != __endStep * 40) + { waveformHandler.clearWaveforms(); waveformHandler.ampsNeeded = __endStep * 40; - for (data in wavesToGenerate) { + for (data in wavesToGenerate) + { waveformHandler.generateShader(data.name, data.sound); waveformHandler.waveformList.push(data.name); } - } else if (waveformHandler != null && waveformHandler.waveformList.length != newWaveformList.length) { + } + else if (waveformHandler != null && waveformHandler.waveformList.length != newWaveformList.length) + { for (name in oldWaveformList) if (!newWaveformList.contains(name)) waveformHandler.clearWaveform(name); @@ -669,17 +724,21 @@ class Charter extends UIState { waveformHandler.waveformList = newWaveformList; } - for (strumLine in strumLines) { - if (strumLine.selectedWaveform == -1) continue; + for (strumLine in strumLines) + { + if (strumLine.selectedWaveform == -1) + continue; var oldName:String = oldWaveformList[strumLine.selectedWaveform]; strumLine.selectedWaveform = waveformHandler.waveformList.indexOf(oldName); } } - public override function beatHit(curBeat:Int) { + public override function beatHit(curBeat:Int) + { super.beatHit(curBeat); - if (FlxG.sound.music.playing) { + if (FlxG.sound.music.playing) + { if (Options.charterMetronomeEnabled) metronome.replay(); } @@ -694,50 +753,68 @@ class Charter extends UIState { public var mousePos:FlxPoint = new FlxPoint(); public var selectionDragging:Bool = false; - public function updateSelectionLogic() { - function select(s:ICharterSelectable) { - if (FlxG.keys.pressed.CONTROL) selection.push(s); - else if (FlxG.keys.pressed.SHIFT) selection.remove(s); - else selection = [s]; + public function updateSelectionLogic() + { + function select(s:ICharterSelectable) + { + if (FlxG.keys.pressed.CONTROL) + selection.push(s); + else if (FlxG.keys.pressed.SHIFT) + selection.remove(s); + else + selection = [s]; } - for (group in [notesGroup, eventsGroup]) { - cast(group, FlxTypedGroup).forEach(function(s) { + for (group in [notesGroup, eventsGroup]) + { + cast(group, FlxTypedGroup).forEach(function(s) + { s.selected = false; - if (gridActionType == NONE) { - if (s is CharterNote) { + if (gridActionType == NONE) + { + if (s is CharterNote) + { var n:CharterNote = cast s; - if ((n.hovered || n.sustainDraggable) && FlxG.mouse.justReleased) select(cast s); - } else if (FlxG.mouse.justReleased && s.hovered) select(cast s); + if ((n.hovered || n.sustainDraggable) && FlxG.mouse.justReleased) + select(cast s); + } + else if (FlxG.mouse.justReleased && s.hovered) + select(cast s); } }); } selection = __fixSelection(selection); - for(s in selection) s.selected = true; + for (s in selection) + s.selected = true; } var __autoSaveLocation:String = null; - public function updateAutoSaving(elapsed:Float) { - if (!Options.charterAutoSaves) return; + + public function updateAutoSaving(elapsed:Float) + { + if (!Options.charterAutoSaves) + return; autoSaveTimer -= elapsed; - if (autoSaveTimer < Options.charterAutoSaveWarningTime && !autoSaveNotif.cancelled && !autoSaveNotif.showedAnimation) { + if (autoSaveTimer < Options.charterAutoSaveWarningTime && !autoSaveNotif.cancelled && !autoSaveNotif.showedAnimation) + { if (Options.charterAutoSavesSeperateFolder) __autoSaveLocation = __diff.toLowerCase() + DateTools.format(Date.now(), "%m-%d_%H-%M"); - autoSaveNotif.startAutoSave(autoSaveTimer, - !Options.charterAutoSavesSeperateFolder ? 'Saved chart at ${__diff.toLowerCase()}.json!' : - 'Saved chart at $__autoSaveLocation.json!' - ); + autoSaveNotif.startAutoSave(autoSaveTimer, + !Options.charterAutoSavesSeperateFolder ? 'Saved chart at ${__diff.toLowerCase()}.json!' : 'Saved chart at $__autoSaveLocation.json!'); } - if (autoSaveTimer <= 0) { + if (autoSaveTimer <= 0) + { autoSaveTimer = Options.charterAutoSaveTime; - if (!autoSaveNotif.cancelled) { - buildChart(); + if (!autoSaveNotif.cancelled) + { + buildChart(); var songPath:String = '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}'; - + if (Options.charterAutoSavesSeperateFolder) - Chart.save(songPath, PlayState.SONG, __autoSaveLocation, {saveMetaInChart: false, folder: "autosaves", prettyPrint: Options.editorPrettyPrint}); - else + Chart.save(songPath, PlayState.SONG, __autoSaveLocation, + {saveMetaInChart: false, folder: "autosaves", prettyPrint: Options.editorPrettyPrint}); + else Chart.save(songPath, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: false, prettyPrint: Options.editorPrettyPrint}); undos.save(); } @@ -746,7 +823,9 @@ class Charter extends UIState { } var deletedNotes:Selection = new Selection(); - public function updateNoteLogic(elapsed:Float) { + + public function updateNoteLogic(elapsed:Float) + { updateSelectionLogic(); /** @@ -756,30 +835,40 @@ class Charter extends UIState { if (!gridBackdropDummy.hoveredByChild && !FlxG.mouse.pressed) gridActionType = NONE; selectionBox.visible = false; - switch(gridActionType) { + switch (gridActionType) + { case BOX_SELECTION: - if (gridBackdropDummy.hoveredByChild) { + if (gridBackdropDummy.hoveredByChild) + { selectionBox.visible = true; - if (FlxG.mouse.pressed) { + if (FlxG.mouse.pressed) + { selectionBox.x = Math.min(mousePos.x, dragStartPos.x); selectionBox.y = Math.min(mousePos.y, dragStartPos.y); selectionBox.bWidth = Std.int(Math.abs(mousePos.x - dragStartPos.x)); selectionBox.bHeight = Std.int(Math.abs(mousePos.y - dragStartPos.y)); - } else { - if (FlxG.keys.pressed.SHIFT) { + } + else + { + if (FlxG.keys.pressed.SHIFT) + { for (group in [notesGroup, eventsGroup]) - for(n in cast(group, FlxTypedGroup)) + for (n in cast(group, FlxTypedGroup)) if (n.handleSelection(selectionBox) && selection.contains(n)) selection.remove(n); - } else if (FlxG.keys.pressed.CONTROL) { + } + else if (FlxG.keys.pressed.CONTROL) + { for (group in [notesGroup, eventsGroup]) - for(n in cast(group, FlxTypedGroup)) + for (n in cast(group, FlxTypedGroup)) if (n.handleSelection(selectionBox) && !selection.contains(n)) selection.push(n); - } else { + } + else + { selection = []; for (group in [notesGroup, eventsGroup]) - for(n in cast(group, FlxTypedGroup)) + for (n in cast(group, FlxTypedGroup)) if (n.handleSelection(selectionBox)) selection.push(n); } @@ -794,54 +883,70 @@ class Charter extends UIState { gridActionType = NONE; case NOTE_DRAG: selectionDragging = FlxG.mouse.pressed; - if (selectionDragging) { + if (selectionDragging) + { gridBackdrops.draggingObj = null; - selection.loop(function (n:CharterNote) { + selection.loop(function(n:CharterNote) + { n.snappedToStrumline = false; n.setPosition(n.fullID * 40 + (mousePos.x - dragStartPos.x), n.step * 40 + (mousePos.y - dragStartPos.y)); - n.y = FlxMath.bound(n.y, 0, (__endStep*40) - n.height); - n.x = FlxMath.bound(n.x, 0, ((strumLines.members.length * 4)-1) * 40); + n.y = FlxMath.bound(n.y, 0, (__endStep * 40) - n.height); + n.x = FlxMath.bound(n.x, 0, ((strumLines.members.length * 4) - 1) * 40); n.cursor = HAND; - }, function (e:CharterEvent) { - e.y = e.step * 40 + (mousePos.y - dragStartPos.y) - 17; - e.y = FlxMath.bound(e.y, -17, (__endStep*40)-17); + }, function(e:CharterEvent) + { + e.y = e.step * 40 + (mousePos.y - dragStartPos.y) - 17; + e.y = FlxMath.bound(e.y, -17, (__endStep * 40) - 17); e.cursor = HAND; }); currentCursor = HAND; - } else { + } + else + { dragStartPos.set(Std.int(dragStartPos.x / 40) * 40, dragStartPos.y); var verticalChange:Float = (mousePos.y - dragStartPos.y) / 40; var horizontalChange:Int = CoolUtil.floorInt((mousePos.x - dragStartPos.x) / 40); var undoDrags:Array = []; - for (s in selection) { - if (s.draggable) { + for (s in selection) + { + if (s.draggable) + { var changePoint:FlxPoint = FlxPoint.get(verticalChange, horizontalChange); if (!FlxG.keys.pressed.SHIFT) - changePoint.x -= ((s.step + verticalChange) - quantStepRounded(s.step+verticalChange, verticalChange > 0 ? 0.35 : 0.65)); + changePoint.x -= ((s.step + verticalChange) - quantStepRounded(s.step + verticalChange, verticalChange > 0 ? 0.35 : 0.65)); var boundedChange:FlxPoint = changePoint.clone(); // Some maths, so cool bro -lunar (i dont know why i quopte my self here) - if (s.step + changePoint.x < 0) boundedChange.x += Math.abs(s.step + changePoint.x); - if (s.step + changePoint.x > __endStep-1) boundedChange.x -= (s.step + changePoint.x) - (__endStep-1); + if (s.step + changePoint.x < 0) + boundedChange.x += Math.abs(s.step + changePoint.x); + if (s.step + changePoint.x > __endStep - 1) + boundedChange.x -= (s.step + changePoint.x) - (__endStep - 1); - if (s is CharterNote) { + if (s is CharterNote) + { var note:CharterNote = cast s; - if (note.fullID + changePoint.y < 0) boundedChange.y += Math.abs(note.fullID + changePoint.y); - if (note.fullID + changePoint.y > (strumLines.members.length*4)-1) boundedChange.y -= (note.fullID + changePoint.y) - ((strumLines.members.length*4)-1); + if (note.fullID + changePoint.y < 0) + boundedChange.y += Math.abs(note.fullID + changePoint.y); + if (note.fullID + changePoint.y > (strumLines.members.length * 4) - 1) + boundedChange.y -= (note.fullID + changePoint.y) - ((strumLines.members.length * 4) - 1); } s.handleDrag(boundedChange); - undoDrags.push({selectable:s, change: boundedChange}); + undoDrags.push({selectable: s, change: boundedChange}); changePoint.put(); } - if (s is CharterNote) cast(s, CharterNote).snappedToStrumline = true; - if (s is UISprite) cast(s, UISprite).cursor = BUTTON; + if (s is CharterNote) + cast(s, CharterNote).snappedToStrumline = true; + if (s is UISprite) + cast(s, UISprite).cursor = BUTTON; } - if (!(verticalChange == 0 && horizontalChange == 0)) { - notesGroup.sortNotes(); eventsGroup.sortEvents(); + if (!(verticalChange == 0 && horizontalChange == 0)) + { + notesGroup.sortNotes(); + eventsGroup.sortEvents(); undos.addToUndo(CSelectionDrag(undoDrags)); } @@ -851,12 +956,14 @@ class Charter extends UIState { case NONE: if (FlxG.mouse.justPressed) FlxG.mouse.getWorldPosition(charterCamera, dragStartPos); - else if (FlxG.mouse.justPressedRight) { + else if (FlxG.mouse.justPressedRight) + { closeCurrentContextMenu(); gridActionType = DELETE_SELECTION; } - if (gridBackdropDummy.hovered) { + if (gridBackdropDummy.hovered) + { // AUTO DETECT if (FlxG.mouse.pressed && (Math.abs(mousePos.x - dragStartPos.x) > 20 || Math.abs(mousePos.y - dragStartPos.y) > 20)) gridActionType = BOX_SELECTION; @@ -864,54 +971,78 @@ class Charter extends UIState { var id = Math.floor(mousePos.x / 40); var mouseOnGrid = id >= 0 && id < 4 * gridBackdrops.strumlinesAmount && mousePos.y >= 0; - if (FlxG.mouse.justReleased) { - for (n in selection) n.selected = false; - selection = []; - - if (mouseOnGrid && mousePos.y > 0 && mousePos.y < (__endStep)*40) { - var note = new CharterNote(); - note.updatePos( - FlxMath.bound(FlxG.keys.pressed.SHIFT ? ((mousePos.y-20) / 40) : quantStep(mousePos.y/40), 0, __endStep-1), - id % 4, 0, noteType, strumLines.members[Std.int(id/4)] - ); - notesGroup.add(note); - selection = [note]; - undos.addToUndo(CCreateSelection([note])); - } + if (FlxG.mouse.justReleased) + { + for (n in selection) + n.selected = false; + selection = []; + + if (mouseOnGrid && mousePos.y > 0 && mousePos.y < (__endStep) * 40) + { + var note = new CharterNote(); + note.updatePos(FlxMath.bound(FlxG.keys.pressed.SHIFT ? ((mousePos.y - 20) / 40) : quantStep(mousePos.y / 40), 0, __endStep - 1), + id % 4, 0, noteType, strumLines.members[Std.int(id / 4)]); + notesGroup.add(note); + selection = [note]; + undos.addToUndo(CCreateSelection([note])); + } } - } else if (gridBackdropDummy.hoveredByChild) { - if (FlxG.mouse.pressed) { + } + else if (gridBackdropDummy.hoveredByChild) + { + if (FlxG.mouse.pressed) + { var noteHovered:Bool = false; - for(n in selection) if (n.hovered) {noteHovered = true; break;} + for (n in selection) + if (n.hovered) + { + noteHovered = true; + break; + } var noteSusDrag:Bool = false; - for(s in selection) { - if (!(s is CharterNote)) continue; + for (s in selection) + { + if (!(s is CharterNote)) + continue; var n:CharterNote = cast s; - if (n.sustainDraggable) {noteSusDrag = true; break;} + if (n.sustainDraggable) + { + noteSusDrag = true; + break; + } } - if ((Math.abs(mousePos.x - dragStartPos.x) > (noteSusDrag ? 1 : 5) || Math.abs(mousePos.y - dragStartPos.y) > (noteSusDrag ? 1 : 5))) { - if (noteHovered) gridActionType = noteHovered ? NOTE_DRAG : INVALID_DRAG; - if (noteSusDrag) gridActionType = SUSTAIN_DRAG; + if ((Math.abs(mousePos.x - dragStartPos.x) > (noteSusDrag ? 1 : 5) + || Math.abs(mousePos.y - dragStartPos.y) > (noteSusDrag ? 1 : 5))) + { + if (noteHovered) + gridActionType = noteHovered ? NOTE_DRAG : INVALID_DRAG; + if (noteSusDrag) + gridActionType = SUSTAIN_DRAG; } } } case SUSTAIN_DRAG: selectionDragging = FlxG.mouse.pressed; - if (selectionDragging) { + if (selectionDragging) + { currentCursor = BUTTON; - selection.loop(function (n:CharterNote) { - var change:Float = Math.max((mousePos.y-(FlxG.keys.pressed.SHIFT ? dragStartPos.y : quantStep(dragStartPos.y))) / 40, -n.susLength); + selection.loop(function(n:CharterNote) + { + var change:Float = Math.max((mousePos.y - (FlxG.keys.pressed.SHIFT ? dragStartPos.y : quantStep(dragStartPos.y))) / 40, -n.susLength); n.tempSusLength = change; if (!FlxG.keys.pressed.SHIFT) n.tempSusLength -= (n.susLength + change) - quantStepRounded(n.susLength + change, change > 0 ? 0.35 : 0.65); @:privateAccess n.__susInstaLerp = FlxG.keys.pressed.SHIFT; }); - } else { + } + else + { var undoChanges:Array = []; - selection.loop(function (n:CharterNote) { + selection.loop(function(n:CharterNote) + { var oldSusLen:Float = n.susLength; n.susLength += n.tempSusLength; @@ -927,61 +1058,78 @@ class Charter extends UIState { currentCursor = ARROW; } case DELETE_SELECTION: - notesGroup.forEach(function(n) { - if (n.hovered || n.sustainDraggable) { + notesGroup.forEach(function(n) + { + if (n.hovered || n.sustainDraggable) + { deletedNotes.push(n); deleteSingleSelection(n, false); - if (selection.contains(n)) selection.remove(n); + if (selection.contains(n)) + selection.remove(n); noteDeleteAnims.deleteNotes.push({ - note: n, time: noteDeleteAnims.deleteTime + note: n, + time: noteDeleteAnims.deleteTime }); } }); - if (FlxG.mouse.justReleasedRight) { - if (deletedNotes.length > 0) undos.addToUndo(CDeleteSelection(deletedNotes.copy())); - else if (noteDeleteAnims.garbageIcon.alpha <= .5) { + if (FlxG.mouse.justReleasedRight) + { + if (deletedNotes.length > 0) + undos.addToUndo(CDeleteSelection(deletedNotes.copy())); + else if (noteDeleteAnims.garbageIcon.alpha <= .5) + { var mousePos = FlxG.mouse.getScreenPosition(uiCamera); closeCurrentContextMenu(); openContextMenu(topMenu[1].childs, null, mousePos.x, mousePos.y); mousePos.put(); } - gridActionType = NONE; deletedNotes = []; + gridActionType = NONE; + deletedNotes = []; } } addEventSpr.selectable = !selectionBox.visible; - var inBoundsY:Bool = (mousePos.y > 0 && mousePos.y < (__endStep)*40); + var inBoundsY:Bool = (mousePos.y > 0 && mousePos.y < (__endStep) * 40); // Event Spr - if (mousePos.x < 0 && mousePos.x > -addEventSpr.bWidth && gridActionType == NONE && inBoundsY) { + if (mousePos.x < 0 && mousePos.x > -addEventSpr.bWidth && gridActionType == NONE && inBoundsY) + { addEventSpr.incorporeal = false; addEventSpr.sprAlpha = lerp(addEventSpr.sprAlpha, 0.75, 0.25); var event = getHoveredEvent(mousePos.y); - if (event != null) addEventSpr.updateEdit(event); - else addEventSpr.updatePos(FlxG.keys.pressed.SHIFT ? ((mousePos.y) / 40) : quantStepRounded(mousePos.y/40)); - } else addEventSpr.sprAlpha = lerp(addEventSpr.sprAlpha, 0, 0.25); + if (event != null) + addEventSpr.updateEdit(event); + else + addEventSpr.updatePos(FlxG.keys.pressed.SHIFT ? ((mousePos.y) / 40) : quantStepRounded(mousePos.y / 40)); + } + else + addEventSpr.sprAlpha = lerp(addEventSpr.sprAlpha, 0, 0.25); noteHoverer.showHoverer = Charter.instance.gridBackdropDummy.hovered; } - public function quantStep(step:Float):Float { - var stepMulti:Float = 1/(quant/16); - return Math.floor(step/stepMulti) * stepMulti; + public function quantStep(step:Float):Float + { + var stepMulti:Float = 1 / (quant / 16); + return Math.floor(step / stepMulti) * stepMulti; } - public function quantStepRounded(step:Float, ?roundRatio:Float = 0.5):Float { - var stepMulti:Float = 1/(quant/16); - return ratioRound(step/stepMulti, roundRatio) * stepMulti; + public function quantStepRounded(step:Float, ?roundRatio:Float = 0.5):Float + { + var stepMulti:Float = 1 / (quant / 16); + return ratioRound(step / stepMulti, roundRatio) * stepMulti; } public function ratioRound(val:Float, ratio:Float):Int return Math.floor(val) + ((Math.abs(val % 1) > ratio ? 1 : 0) * (val > 0 ? 1 : -1)); - public function getHoveredEvent(y:Float) { + public function getHoveredEvent(y:Float) + { var eventHovered:CharterEvent = null; - eventsGroup.forEach(function(e) { + eventsGroup.forEach(function(e) + { if (eventHovered != null) return; @@ -991,16 +1139,21 @@ class Charter extends UIState { return eventHovered; } - public function deleteSingleSelection(selected:ICharterSelectable, addToUndo:Bool = true):Null { - if (selected == null) return selected; + public function deleteSingleSelection(selected:ICharterSelectable, addToUndo:Bool = true):Null + { + if (selected == null) + return selected; - if (selected is CharterNote) { + if (selected is CharterNote) + { var note:CharterNote = cast selected; note.strumLineID = strumLines.members.indexOf(note.strumLine); note.strumLine = null; // For static undos :D notesGroup.remove(note); note.kill(); - } else if (selected is CharterEvent) { + } + else if (selected is CharterEvent) + { var event:CharterEvent = cast selected; eventsGroup.remove(event); event.kill(); @@ -1012,15 +1165,19 @@ class Charter extends UIState { return null; } - public function createSelection(selection:Selection, addToUndo:Bool = true) { - if (selection.length <= 0) return []; + public function createSelection(selection:Selection, addToUndo:Bool = true) + { + if (selection.length <= 0) + return []; notesGroup.autoSort = false; - selection.loop(function (n:CharterNote) { + selection.loop(function(n:CharterNote) + { n.strumLine = strumLines.members[n.strumLineID]; n.revive(); notesGroup.add(n); - }, function (e:CharterEvent) { + }, function(e:CharterEvent) + { e.revive(); eventsGroup.add(e); e.refreshEventIcons(); @@ -1029,7 +1186,8 @@ class Charter extends UIState { notesGroup.autoSort = true; for (s in selection) - if (s is CharterEvent) { + if (s is CharterEvent) + { Charter.instance.updateBPMEvents(); break; } @@ -1039,25 +1197,31 @@ class Charter extends UIState { return []; } - public function deleteSelection(selection:Selection, addToUndo:Bool = true) { - if (selection.length <= 0) return []; + public function deleteSelection(selection:Selection, addToUndo:Bool = true) + { + if (selection.length <= 0) + return []; notesGroup.autoSort = false; - for (objects in [notesGroup, eventsGroup]) { + for (objects in [notesGroup, eventsGroup]) + { var group = cast(objects, FlxTypedGroup); var member = 0; - while(member < group.members.length) { + while (member < group.members.length) + { var s = group.members[member]; if (selection.contains(s)) deleteSingleSelection(s, false); - else member++; + else + member++; } } notesGroup.sortNotes(); notesGroup.autoSort = true; for (s in selection) - if (s is CharterEvent) { + if (s is CharterEvent) + { Charter.instance.updateBPMEvents(); break; } @@ -1068,14 +1232,17 @@ class Charter extends UIState { } // STRUMLINE DELETION/CREATION - public function createStrumline(strumLineID:Int, strL:ChartStrumLine, addToUndo:Bool = true, ?__createNotes:Bool = true) { + public function createStrumline(strumLineID:Int, strL:ChartStrumLine, addToUndo:Bool = true, ?__createNotes:Bool = true) + { var cStr = new CharterStrumline(strL); strumLines.insert(strumLineID, cStr); strumLines.snapStrums(); - if (__createNotes) { + if (__createNotes) + { var toBeCreated:Selection = []; - for(note in strL.notes) { + for (note in strL.notes) + { var n = new CharterNote(); var t = Conductor.getStepForTime(note.time); n.updatePos(t, note.id, Conductor.getStepForTime(note.time + note.sLen) - t, note.type, cStr); @@ -1088,14 +1255,16 @@ class Charter extends UIState { undos.addToUndo(CCreateStrumLine(strumLineID, strL)); } - public function deleteStrumline(strumLineID:Int, addToUndo:Bool = true) { + public function deleteStrumline(strumLineID:Int, addToUndo:Bool = true) + { var undoNotes:Array = []; removeStrumlineFromSelection(strumLineID); var i = 0; var toBeDeleted:Selection = []; for (note in notesGroup.members) - if (note.strumLineID == strumLineID) { + if (note.strumLineID == strumLineID) + { undoNotes.push(buildNote(note)); toBeDeleted.push(note); } @@ -1106,7 +1275,8 @@ class Charter extends UIState { strumLines.members.remove(strumLines.members[strumLineID]); strumLines.snapStrums(); - if (addToUndo) { + if (addToUndo) + { var newStrL = Reflect.copy(strL); newStrL.notes = undoNotes; @@ -1114,17 +1284,22 @@ class Charter extends UIState { } } - public function getStrumlineID(strL:ChartStrumLine):Int { - for (index=>strumLine in strumLines.members) { + public function getStrumlineID(strL:ChartStrumLine):Int + { + for (index => strumLine in strumLines.members) + { if (strumLine.strumLine == strL) return index; } return -1; } - public function createStrumWithUI() { - FlxG.state.openSubState(new CharterStrumlineScreen(strumLines.members.length, null, (_) -> { - if (_ != null) { + public function createStrumWithUI() + { + FlxG.state.openSubState(new CharterStrumlineScreen(strumLines.members.length, null, (_) -> + { + if (_ != null) + { createStrumline(strumLines.members.length, _); strumlineAddButton.textTweenColor.color = 0xFF00FF00; @@ -1136,28 +1311,35 @@ class Charter extends UIState { public inline function deleteStrumlineFromData(strL:ChartStrumLine) deleteStrumline(getStrumlineID(strL)); - public inline function editStrumline(strL:ChartStrumLine) { + public inline function editStrumline(strL:ChartStrumLine) + { var strID = getStrumlineID(strL); var oldData:ChartStrumLine = Reflect.copy(strL); - FlxG.state.openSubState(new CharterStrumlineScreen(strID, strL, (_) -> { + FlxG.state.openSubState(new CharterStrumlineScreen(strID, strL, (_) -> + { strumLines.members[strID].strumLine = _; strumLines.members[strID].updateInfo(); undos.addToUndo(CEditStrumLine(strID, oldData, _)); - if (oldData.vocalsSuffix != _.vocalsSuffix) updateWaveforms(); + if (oldData.vocalsSuffix != _.vocalsSuffix) + updateWaveforms(); })); } - public inline function removeStrumlineFromSelection(strumLineID:Int) { + public inline function removeStrumlineFromSelection(strumLineID:Int) + { var i = 0; - while(i < selection.length) { - if (selection[i] is CharterNote) { + while (i < selection.length) + { + if (selection[i] is CharterNote) + { var note:CharterNote = cast selection[i]; if (note.strumLineID == strumLineID) selection.remove(note); - else i++; + else + i++; } } } @@ -1165,12 +1347,14 @@ class Charter extends UIState { var __crochet:Float; var __firstFrame:Bool = true; - public override function update(elapsed:Float) { + + public override function update(elapsed:Float) + { updateNoteLogic(elapsed); updateAutoSaving(elapsed); // TEST CODE ----------------------------- - + if (isLiveCharting) { if (controls.LEFT) @@ -1209,47 +1393,52 @@ class Charter extends UIState { // TEST CODE ----------------------------- - if (FlxG.sound.music.playing || __firstFrame) { + if (FlxG.sound.music.playing || __firstFrame) + { gridBackdrops.conductorSprY = curStepFloat * 40; - } else { - gridBackdrops.conductorSprY = lerp(gridBackdrops.conductorSprY, curStepFloat * 40, __firstFrame ? 1 : 1/3); } - charterCamera.scroll.set( - ((((40*4) * gridBackdrops.strumlinesAmount) - FlxG.width) / 2), - gridBackdrops.conductorSprY - (FlxG.height * 0.5) - ); + else + { + gridBackdrops.conductorSprY = lerp(gridBackdrops.conductorSprY, curStepFloat * 40, __firstFrame ? 1 : 1 / 3); + } + charterCamera.scroll.set(((((40 * 4) * gridBackdrops.strumlinesAmount) - FlxG.width) / 2), gridBackdrops.conductorSprY - (FlxG.height * 0.5)); - if (topMenuSpr.members[playbackIndex] != null) { + if (topMenuSpr.members[playbackIndex] != null) + { var playBackButton:UITopMenuButton = cast topMenuSpr.members[playbackIndex]; - playBackButton.x = playBackSlider.x-playBackSlider.startText.width-10-playBackSlider.valueStepper.bWidth-playBackButton.bWidth-10; + playBackButton.x = playBackSlider.x - playBackSlider.startText.width - 10 - playBackSlider.valueStepper.bWidth - playBackButton.bWidth - 10; playBackButton.label.offset.x = -1; - if (topMenuSpr.members[snapIndex] != null) { + if (topMenuSpr.members[snapIndex] != null) + { var snapButton:UITopMenuButton = cast topMenuSpr.members[snapIndex]; - var lastButtonX = playBackButton.x-10; + var lastButtonX = playBackButton.x - 10; var buttonI:Int = 0; - for (button in quantButtons) { - button.visible = ((button.quant == quant) || - (button.quant == quants[FlxMath.wrap(quants.indexOf(quant)-1, 0, quants.length-1)]) || - (button.quant == quants[FlxMath.wrap(quants.indexOf(quant)+1, 0, quants.length-1)])); + for (button in quantButtons) + { + button.visible = ((button.quant == quant) + || (button.quant == quants[FlxMath.wrap(quants.indexOf(quant) - 1, 0, quants.length - 1)]) + || (button.quant == quants[FlxMath.wrap(quants.indexOf(quant) + 1, 0, quants.length - 1)])); button.selectable = button.visible; - if (!button.visible) continue; + if (!button.visible) + continue; button.x = lastButtonX -= button.bWidth; button.framesOffset = button.quant == quant ? 9 : 0; button.alpha = button.quant == quant ? 1 : (button.hovered ? 0.4 : 0); } - snapButton.x = (lastButtonX -= snapButton.bWidth)-10; + snapButton.x = (lastButtonX -= snapButton.bWidth) - 10; } } - if (topMenuSpr.members[noteIndex] != null) { + if (topMenuSpr.members[noteIndex] != null) + { var noteTopButton:UITopMenuButton = cast topMenuSpr.members[noteIndex]; noteTypeText.x = noteTopButton.x + noteTopButton.bWidth + 6; noteTypeText.y = Std.int((noteTopButton.bHeight - noteTypeText.height) / 2); } - noteTypeText.text = '($noteType) ${noteTypes[noteType-1] == null ? "Default Note" : noteTypes[noteType-1]}'; + noteTypeText.text = '($noteType) ${noteTypes[noteType - 1] == null ? "Default Note" : noteTypes[noteType - 1]}'; super.update(elapsed); @@ -1260,19 +1449,25 @@ class Charter extends UIState { updateDisplaySprites(); // TODO: canTypeText in case an ui input element is focused - if (true) { + if (true) + { __crochet = ((60 / Conductor.bpm) * 1000); - if(FlxG.keys.justPressed.ANY && !strumLines.isDragging && this.currentFocus == null) + if (FlxG.keys.justPressed.ANY && !strumLines.isDragging && this.currentFocus == null) UIUtil.processShortcuts(topMenu); - if (FlxG.keys.pressed.CONTROL) { - if (FlxG.mouse.wheel != 0) { + if (FlxG.keys.pressed.CONTROL) + { + if (FlxG.mouse.wheel != 0) + { zoom += 0.25 * FlxG.mouse.wheel; __camZoom = Math.pow(2, zoom); } - } else { - if (!FlxG.sound.music.playing) { + } + else + { + if (!FlxG.sound.music.playing) + { Conductor.songPosition -= (__crochet * FlxG.mouse.wheel) - Conductor.songOffset; } } @@ -1281,18 +1476,20 @@ class Charter extends UIState { var songLength = FlxG.sound.music.getDefault(vocals).length; Conductor.songPosition = FlxMath.bound(Conductor.songPosition + Conductor.songOffset, 0, songLength); - if (Conductor.songPosition >= songLength - Conductor.songOffset) { + if (Conductor.songPosition >= songLength - Conductor.songOffset) + { FlxG.sound.music.pause(); vocals.pause(); - for (strumLine in strumLines.members) strumLine.vocals.pause(); + for (strumLine in strumLines.members) + strumLine.vocals.pause(); } songPosInfo.text = '${CoolUtil.timeToStr(Conductor.songPosition)} / ${CoolUtil.timeToStr(songLength)}' - + '\nStep: ${curStep}' - + '\nBeat: ${curBeat}' - + '\nMeasure: ${curMeasure}' - + '\nBPM: ${Conductor.bpm}' - + '\nTime Signature: ${Conductor.beatsPerMeasure}/${Conductor.stepsPerBeat}'; + + '\nStep: ${curStep}' + + '\nBeat: ${curBeat}' + + '\nMeasure: ${curMeasure}' + + '\nBPM: ${Conductor.bpm}' + + '\nTime Signature: ${Conductor.beatsPerMeasure}/${Conductor.stepsPerBeat}'; if (charterCamera.zoom != (charterCamera.zoom = lerp(charterCamera.zoom, __camZoom, __firstFrame ? 1 : 0.125))) updateDisplaySprites(); @@ -1309,7 +1506,8 @@ class Charter extends UIState { public static var startTime:Float = 0; public static var startHere:Bool = false; - function updateDisplaySprites() { + function updateDisplaySprites() + { gridBackdrops.strumlinesAmount = strumLines.members.length; charterBG.scale.set(1 / charterCamera.zoom, 1 / charterCamera.zoom); @@ -1319,8 +1517,9 @@ class Charter extends UIState { strumlineInfoBG.screenCenter(X); strumlineInfoBG.y = -(((FlxG.height - (2 * topMenuSpr.bHeight)) / charterCamera.zoom) - FlxG.height) / 2; - for(id=>str in strumLines.members) - if (str != null) str.y = strumlineInfoBG.y; + for (id => str in strumLines.members) + if (str != null) + str.y = strumlineInfoBG.y; strumlineAddButton.y = strumlineInfoBG.y; strumlineLockButton.y = strumlineInfoBG.y; @@ -1328,21 +1527,34 @@ class Charter extends UIState { var zoom(default, set):Float = 0; var __camZoom(default, set):Float = 1; - function set_zoom(val:Float) { + + function set_zoom(val:Float) + { return zoom = FlxMath.bound(val, -3.5, 1.75); // makes zooming not lag behind when continuing scrolling } - function set___camZoom(val:Float) { + + function set___camZoom(val:Float) + { return __camZoom = FlxMath.bound(val, 0.1, 3); } // TOP MENU OPTIONS #if REGION - function _file_exit(_) { - if (undos.unsaved) SaveWarning.triggerWarning(); - else {undos = null; FlxG.switchState(new CharterSelection()); PlayState.resetSongInfos(); Charter.instance.__clearStatics();} + function _file_exit(_) + { + if (undos.unsaved) + SaveWarning.triggerWarning(); + else + { + undos = null; + FlxG.switchState(new CharterSelection()); + PlayState.resetSongInfos(); + Charter.instance.__clearStatics(); + } } - function _file_save(_) { + function _file_save(_) + { #if sys saveTo('${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}'); undos.save(); @@ -1351,14 +1563,16 @@ class Charter extends UIState { _file_saveas(_); } - function _file_saveas(_) { + function _file_saveas(_) + { openSubState(new SaveSubstate(Json.stringify(Chart.filterChartForSaving(PlayState.SONG, false), null, Options.editorPrettyPrint ? "\t" : null), { defaultSaveFile: '${__diff.toLowerCase()}.json' })); undos.save(); } - function _file_save_no_events(_) { + function _file_save_no_events(_) + { #if sys saveTo('${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}', true); undos.save(); @@ -1367,96 +1581,114 @@ class Charter extends UIState { _file_saveas(_); } - function _file_saveas_no_events(_) { - openSubState(new SaveSubstate(Json.stringify(Chart.filterChartForSaving(PlayState.SONG, false, false), null, Options.editorPrettyPrint ? "\t" : null), { - defaultSaveFile: '${__diff.toLowerCase()}.json' - })); + function _file_saveas_no_events(_) + { + openSubState(new SaveSubstate(Json.stringify(Chart.filterChartForSaving(PlayState.SONG, false, false), null, Options.editorPrettyPrint ? "\t" : null), + { + defaultSaveFile: '${__diff.toLowerCase()}.json' + })); undos.save(); } - function _file_meta_save(_) { + function _file_meta_save(_) + { #if sys - CoolUtil.safeSaveFile( - '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/meta.json', - Json.stringify(PlayState.SONG.meta == null ? {} : PlayState.SONG.meta, null, "\t") - ); + CoolUtil.safeSaveFile('${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/meta.json', + Json.stringify(PlayState.SONG.meta == null ? {} : PlayState.SONG.meta, null, "\t")); #else _file_meta_saveas(_); #end } - function _file_meta_saveas(_) { + function _file_meta_saveas(_) + { openSubState(new SaveSubstate(Json.stringify(PlayState.SONG.meta == null ? {} : PlayState.SONG.meta, null, "\t"), { // always pretty print meta defaultSaveFile: 'meta.json' })); } - function _file_saveas_fnflegacy(_) { + function _file_saveas_fnflegacy(_) + { openSubState(new SaveSubstate(Json.stringify(FNFLegacyParser.encode(PlayState.SONG), null, Options.editorPrettyPrint ? "\t" : null), { defaultSaveFile: '${__song.toLowerCase().replace(" ", "-")}${__diff.toLowerCase() == "normal" ? "" : '-${__diff.toLowerCase()}'}.json', })); } - - function _file_saveas_psych(_) { + + function _file_saveas_psych(_) + { openSubState(new SaveSubstate(Json.stringify(PsychParser.encode(PlayState.SONG), null, Options.editorPrettyPrint ? "\t" : null), { defaultSaveFile: '${__song.toLowerCase().replace(" ", "-")}${__diff.toLowerCase() == "normal" ? "" : '-${__diff.toLowerCase()}'}.json', })); } - function _file_events_save(_) { + function _file_events_save(_) + { #if sys - CoolUtil.safeSaveFile( - '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/events.json', - Json.stringify({events: PlayState.SONG.events == null ? [] : PlayState.SONG.events}, null, Options.editorPrettyPrint ? "\t" : null) - ); + CoolUtil.safeSaveFile('${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/events.json', + Json.stringify({events: PlayState.SONG.events == null ? [] : PlayState.SONG.events}, null, Options.editorPrettyPrint ? "\t" : null)); #else _file_events_saveas(_); #end } - function _file_events_saveas(_) { + function _file_events_saveas(_) + { #if sys - openSubState(new SaveSubstate(Json.stringify({events: PlayState.SONG.events == null ? [] : PlayState.SONG.events}, null, Options.editorPrettyPrint ? "\t" : null), { - defaultSaveFile: 'events.json' - })); + openSubState(new SaveSubstate(Json.stringify({events: PlayState.SONG.events == null ? [] : PlayState.SONG.events}, null, + Options.editorPrettyPrint ? "\t" : null), { + defaultSaveFile: 'events.json' + })); #end } #if sys - function saveTo(path:String, separateEvents:Bool = false) { + function saveTo(path:String, separateEvents:Bool = false) + { buildChart(); - Chart.save(path, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: false, saveEventsInChart: !separateEvents, prettyPrint: Options.editorPrettyPrint}); + Chart.save(path, PlayState.SONG, __diff.toLowerCase(), + {saveMetaInChart: false, saveEventsInChart: !separateEvents, prettyPrint: Options.editorPrettyPrint}); } #end - function _edit_copy(_) { - if(selection.length == 0) return; + function _edit_copy(_) + { + if (selection.length == 0) + return; var minStep:Float = selection[0].step; - for(s in selection) - if (s.step < minStep) minStep = s.step; + for (s in selection) + if (s.step < minStep) + minStep = s.step; clipboard = [ for (s in selection) - if (s is CharterNote) { - var note:CharterNote = cast s; - CNote(note.step - minStep, note.id, note.strumLineID, note.susLength, note.type); - } else if (s is CharterEvent) { - var event = cast(s,CharterEvent); - CEvent(event.step - minStep, [for (event in event.events) Reflect.copy(event)]); - } + if (s is CharterNote) + { + var note:CharterNote = cast s; + CNote(note.step - minStep, note.id, note.strumLineID, note.susLength, note.type); + } + else if (s is CharterEvent) + { + var event = cast(s, CharterEvent); + CEvent(event.step - minStep, [for (event in event.events) Reflect.copy(event)]); + } ]; } - function _edit_paste(_) { - if (clipboard.length <= 0) return; + + function _edit_paste(_) + { + if (clipboard.length <= 0) + return; var minStep = curStep; var sObjects:Array = []; - for(c in clipboard) { - switch(c) { + for (c in clipboard) + { + switch (c) + { case CNote(step, id, strumLineID, susLength, type): var note = new CharterNote(); - note.updatePos(minStep + step, id, susLength, type, strumLines.members[Std.int(FlxMath.bound(strumLineID, 0, strumLines.length-1))]); + note.updatePos(minStep + step, id, susLength, type, strumLines.members[Std.int(FlxMath.bound(strumLineID, 0, strumLines.length - 1))]); notesGroup.add(note); sObjects.push(note); case CEvent(step, events): @@ -1472,8 +1704,10 @@ class Charter extends UIState { undos.addToUndo(CCreateSelection(sObjects.copy())); } - function _edit_cut(_) { - if (selection == null || selection.length == 0) return; + function _edit_cut(_) + { + if (selection == null || selection.length == 0) + return; _edit_copy(_); deleteSelection(selection, false); @@ -1493,12 +1727,15 @@ class Charter extends UIState { } } - function _edit_undo(_) { - if (strumLines.isDragging || selectionDragging || (subState != null && !(subState is UIContextMenu))) return; + function _edit_undo(_) + { + if (strumLines.isDragging || selectionDragging || (subState != null && !(subState is UIContextMenu))) + return; selection = []; var undo = undos.undo(); - switch(undo) { + switch (undo) + { case null: // do nothing case CDeleteStrumLine(strumLineID, strumLine): createStrumline(strumLineID, strumLine, false); @@ -1517,11 +1754,12 @@ class Charter extends UIState { createSelection(selection, false); case CSelectionDrag(selectionDrags): for (s in selectionDrags) - if (s.selectable.draggable) s.selectable.handleDrag(s.change * -1); + if (s.selectable.draggable) + s.selectable.handleDrag(s.change * -1); selection = [for (s in selectionDrags) s.selectable]; case CEditSustains(changes): - for(n in changes) + for (n in changes) n.note.updatePos(n.note.step, n.note.id, n.before, n.note.type); case CEditEvent(event, oldEvents, newEvents): event.events = oldEvents.copy(); @@ -1535,16 +1773,20 @@ class Charter extends UIState { noteTypes = oldArray; changeNoteType(null, false); case CEditSpecNotesType(notes, oldTypes, newTypes): - for(i=>note in notes) note.updatePos(note.step, note.id, note.susLength, oldTypes[i]); + for (i => note in notes) + note.updatePos(note.step, note.id, note.susLength, oldTypes[i]); } } - function _edit_redo(_) { - if (strumLines.isDragging || selectionDragging || (subState != null && !(subState is UIContextMenu))) return; + function _edit_redo(_) + { + if (strumLines.isDragging || selectionDragging || (subState != null && !(subState is UIContextMenu))) + return; selection = []; var redo = undos.redo(); - switch(redo) { + switch (redo) + { case null: // do nothing case CDeleteStrumLine(strumLineID, strumLine): deleteStrumline(strumLineID, false); @@ -1563,10 +1805,11 @@ class Charter extends UIState { deleteSelection(selection, false); case CSelectionDrag(selectionDrags): for (s in selectionDrags) - if (s.selectable.draggable) s.selectable.handleDrag(s.change); - //this.selection = selection; + if (s.selectable.draggable) + s.selectable.handleDrag(s.change); + // this.selection = selection; case CEditSustains(changes): - for(n in changes) + for (n in changes) n.note.updatePos(n.note.step, n.note.id, n.after, n.note.type); case CEditEvent(event, oldEvents, newEvents): event.events = newEvents.copy(); @@ -1580,22 +1823,27 @@ class Charter extends UIState { noteTypes = newArray; changeNoteType(null, false); case CEditSpecNotesType(notes, oldTypes, newTypes): - for(i=>note in notes) note.updatePos(note.step, note.id, note.susLength, newTypes[i]); + for (i => note in notes) + note.updatePos(note.step, note.id, note.susLength, newTypes[i]); } } inline function _chart_playtest(_) if (!isLiveCharting) playtestChart(0, false); + inline function _chart_playtest_here(_) if (!isLiveCharting) playtestChart(Conductor.songPosition, false, true); + inline function _chart_playtest_opponent(_) if (!isLiveCharting) playtestChart(0, true); + inline function _chart_playtest_opponent_here(_) if (!isLiveCharting) playtestChart(Conductor.songPosition, true, true); + inline function _chart_live(_) { trace("make this"); @@ -1603,6 +1851,7 @@ class Charter extends UIState { isLiveCharting = true; Conductor.songPosition = 0; // fuck you + // make SL selection functionality // pause until a SL was selected // start countdown // only after all that can it... @@ -1617,7 +1866,8 @@ class Charter extends UIState { strumLine.vocals.time = vocals.time; } - if (controls.ACCEPT) { + if (controls.ACCEPT) + { FlxG.sound.music.pause(); vocals.pause(); for (strumLine in strumLines.members) @@ -1632,6 +1882,8 @@ class Charter extends UIState { trace("and this too"); isLiveCharting = true; + + // make SL selection functionality // pause until a SL was selected // start countdown // only after all that can it... @@ -1645,7 +1897,8 @@ class Charter extends UIState { strumLine.vocals.time = vocals.time; } - if (controls.ACCEPT) { + if (controls.ACCEPT) + { FlxG.sound.music.pause(); vocals.pause(); for (strumLine in strumLines.members) @@ -1654,109 +1907,168 @@ class Charter extends UIState { isLiveCharting = false; } } - trace("and this too"); - function _chart_enablescripts(t) { + + function _chart_enablescripts(t) + { t.icon = (Options.charterEnablePlaytestScripts = !Options.charterEnablePlaytestScripts) ? 1 : 0; } function chart_edit_data(_) FlxG.state.openSubState(new ChartDataScreen(PlayState.SONG)); + function chart_edit_metadata(_) FlxG.state.openSubState(new CharterMetaDataScreen(PlayState.SONG.meta)); - function _playback_play(_) { - if (Conductor.songPosition >= FlxG.sound.music.getDefault(vocals).length - Conductor.songOffset) return; + function _playback_play(_) + { + if (Conductor.songPosition >= FlxG.sound.music.getDefault(vocals).length - Conductor.songOffset) + return; - if (FlxG.sound.music.playing) { + if (FlxG.sound.music.playing) + { FlxG.sound.music.pause(); vocals.pause(); - for (strumLine in strumLines.members) strumLine.vocals.pause(); - } else { + for (strumLine in strumLines.members) + strumLine.vocals.pause(); + } + else + { FlxG.sound.music.play(); vocals.play(); vocals.time = FlxG.sound.music.time = Conductor.songPosition + Conductor.songOffset * 2; - for (strumLine in strumLines.members) { + for (strumLine in strumLines.members) + { strumLine.vocals.play(); strumLine.vocals.time = vocals.time; } } } - function _playback_speed_raise(_) playBackSlider.value += .25; - function _playback_speed_reset(_) playBackSlider.value = 1; - function _playback_speed_lower(_) playBackSlider.value -= .25; + function _playback_speed_raise(_) + playBackSlider.value += .25; - function _playback_metronome(t) { + function _playback_speed_reset(_) + playBackSlider.value = 1; + + function _playback_speed_lower(_) + playBackSlider.value -= .25; + + function _playback_metronome(t) + { t.icon = (Options.charterMetronomeEnabled = !Options.charterMetronomeEnabled) ? 1 : 0; } - function _song_muteinst(t) { + + function _song_muteinst(t) + { FlxG.sound.music.volume = FlxG.sound.music.volume > 0 ? 0 : 1; t.icon = 1 - Std.int(Math.ceil(FlxG.sound.music.volume)); } - function _song_mutevoices(t) { + + function _song_mutevoices(t) + { vocals.volume = vocals.volume > 0 ? 0 : 1; - for (strumLine in strumLines.members) strumLine.vocals.volume = strumLine.vocals.volume > 0 ? 0 : 1; + for (strumLine in strumLines.members) + strumLine.vocals.volume = strumLine.vocals.volume > 0 ? 0 : 1; t.icon = 1 - Std.int(Math.ceil(vocals.volume)); } - function _playback_back(_) { - if (FlxG.sound.music.playing) return; + + function _playback_back(_) + { + if (FlxG.sound.music.playing) + return; Conductor.songPosition -= (Conductor.beatsPerMeasure * __crochet); } - function _playback_forward(_) { - if (FlxG.sound.music.playing) return; + + function _playback_forward(_) + { + if (FlxG.sound.music.playing) + return; Conductor.songPosition += (Conductor.beatsPerMeasure * __crochet); } - function _song_start(_) { - if (FlxG.sound.music.playing) return; + + function _song_start(_) + { + if (FlxG.sound.music.playing) + return; Conductor.songPosition = 0; } - function _song_end(_) { - if (FlxG.sound.music.playing) return; + + function _song_end(_) + { + if (FlxG.sound.music.playing) + return; Conductor.songPosition = FlxG.sound.music.length; } - function _view_zoomin(_) { + + function _view_zoomin(_) + { zoom += 0.25; __camZoom = Math.pow(2, zoom); } - function _view_zoomout(_) { + + function _view_zoomout(_) + { zoom -= 0.25; __camZoom = Math.pow(2, zoom); } - function _view_zoomreset(_) { + + function _view_zoomreset(_) + { zoom = 0; __camZoom = Math.pow(2, zoom); } - function _view_showeventSecSeparator(t) { + + function _view_showeventSecSeparator(t) + { t.icon = (Options.charterShowSections = !Options.charterShowSections) ? 1 : 0; eventsBackdrop.eventSecSeparator.visible = gridBackdrops.sectionsVisible = Options.charterShowSections; } - function _view_showeventBeatSeparator(t) { + + function _view_showeventBeatSeparator(t) + { t.icon = (Options.charterShowBeats = !Options.charterShowBeats) ? 1 : 0; eventsBackdrop.eventBeatSeparator.visible = gridBackdrops.beatsVisible = Options.charterShowBeats; } - function _view_switchWaveformDetail(t) { + + function _view_switchWaveformDetail(t) + { t.icon = (Options.charterLowDetailWaveforms = !Options.charterLowDetailWaveforms) ? 1 : 0; - for (shader in waveformHandler.waveShaders) shader.data.lowDetail.value = [Options.charterLowDetailWaveforms]; + for (shader in waveformHandler.waveShaders) + shader.data.lowDetail.value = [Options.charterLowDetailWaveforms]; } - - inline function _snap_increasesnap(_) if (!isLiveCharting) changequant(1); - inline function _snap_decreasesnap(_) if (!isLiveCharting) changequant(-1); - inline function _snap_resetsnap(_) if (!isLiveCharting) setquant(16); - inline function changequant(change:Int) { - if (!isLiveCharting) { - quant = quants[FlxMath.wrap(quants.indexOf(quant) + change, 0, quants.length-1)]; + inline function _snap_increasesnap(_) + if (!isLiveCharting) + changequant(1); + + inline function _snap_decreasesnap(_) + if (!isLiveCharting) + changequant(-1); + + inline function _snap_resetsnap(_) + if (!isLiveCharting) + setquant(16); + + inline function changequant(change:Int) + { + if (!isLiveCharting) + { + quant = quants[FlxMath.wrap(quants.indexOf(quant) + change, 0, quants.length - 1)]; buildSnapsUI(); } }; - inline function setquant(newquant:Int) { - if (!isLiveCharting) { + + inline function setquant(newquant:Int) + { + if (!isLiveCharting) + { quant = newquant; buildSnapsUI(); } } - function buildSnapsUI():Array { + function buildSnapsUI():Array + { var snapsTopButton:UITopMenuButton = topMenuSpr == null ? null : cast topMenuSpr.members[snapIndex]; var newChilds:Array = [ { @@ -1779,11 +2091,16 @@ class Charter extends UIState { for (_quant in quants) newChilds.push({ label: '${_quant}x Grid Snap', - onSelect: (_) -> {setquant(_quant); buildSnapsUI();}, + onSelect: (_) -> + { + setquant(_quant); + buildSnapsUI(); + }, icon: _quant == quant ? 1 : 0 }); - if (snapsTopButton != null) snapsTopButton.contextMenu = newChilds; + if (snapsTopButton != null) + snapsTopButton.contextMenu = newChilds; return newChilds; } @@ -1795,23 +2112,30 @@ class Charter extends UIState { if (!isLiveCharting) changeNoteSustain(-1); - function _note_selectall(_) { + function _note_selectall(_) + { selection = [for (note in notesGroup.members) note]; } - function _note_selectmeasure(_) { - selection = [for (note in notesGroup.members) - if (note.step > Conductor.curMeasure*Conductor.getMeasureLength() && note.step < (Conductor.curMeasure+1)*Conductor.getMeasureLength()) note + function _note_selectmeasure(_) + { + selection = [ + for (note in notesGroup.members) + if (note.step > Conductor.curMeasure * Conductor.getMeasureLength() + && note.step < (Conductor.curMeasure + 1) * Conductor.getMeasureLength()) note ]; } #end - function changeNoteSustain(change:Float) { - if (selection.length <= 0 || change == 0 || gridActionType != NONE) return; + function changeNoteSustain(change:Float) + { + if (selection.length <= 0 || change == 0 || gridActionType != NONE) + return; var undoChanges:Array = []; - for(s in selection) - if (s is CharterNote) { + for (s in selection) + if (s is CharterNote) + { var n:CharterNote = cast s; var old:Float = n.susLength; n.updatePos(n.step, n.id, Math.max(n.susLength + change, 0), n.type); @@ -1821,30 +2145,42 @@ class Charter extends UIState { undos.addToUndo(CEditSustains(undoChanges)); } - inline public function changeNoteType(?newID:Int, checkSelection:Bool = true) { - if(newID != null) noteType = newID; + inline public function changeNoteType(?newID:Int, checkSelection:Bool = true) + { + if (newID != null) + noteType = newID; noteType = Std.int(FlxMath.bound(noteType, 0, noteTypes.length)); buildNoteTypesUI(); - var changedNotes:{notes:Array, oldTypes:Array, newTypes:Array} = {notes:[], oldTypes:[], newTypes:[]}; - for(note in notesGroup) if(note.type < 0 || note.type > noteTypes.length) { - changedNotes.notes.push(note); changedNotes.oldTypes.push(note.type); changedNotes.newTypes.push(0); - note.updatePos(note.step, note.id, note.susLength, 0); - } - - if(checkSelection) for(s in selection) - if (s is CharterNote) { - var n:CharterNote = cast s; - changedNotes.notes.push(n); changedNotes.oldTypes.push(n.type); changedNotes.newTypes.push(newID); - n.updatePos(n.step, n.id, n.susLength, newID); + var changedNotes:{notes:Array, oldTypes:Array, newTypes:Array} = {notes: [], oldTypes: [], newTypes: []}; + for (note in notesGroup) + if (note.type < 0 || note.type > noteTypes.length) + { + changedNotes.notes.push(note); + changedNotes.oldTypes.push(note.type); + changedNotes.newTypes.push(0); + note.updatePos(note.step, note.id, note.susLength, 0); } - if(changedNotes.notes.length > 0) undos.addToUndo(CEditSpecNotesType(changedNotes.notes, changedNotes.oldTypes, changedNotes.newTypes)); + + if (checkSelection) + for (s in selection) + if (s is CharterNote) + { + var n:CharterNote = cast s; + changedNotes.notes.push(n); + changedNotes.oldTypes.push(n.type); + changedNotes.newTypes.push(newID); + n.updatePos(n.step, n.id, n.susLength, newID); + } + if (changedNotes.notes.length > 0) + undos.addToUndo(CEditSpecNotesType(changedNotes.notes, changedNotes.oldTypes, changedNotes.newTypes)); } function editNoteTypesList(_) FlxG.state.openSubState(new CharterNoteTypesList()); - function buildNoteTypesUI():Array { + function buildNoteTypesUI():Array + { var noteTopButton:UITopMenuButton = topMenuSpr == null ? null : cast topMenuSpr.members[noteIndex]; var newChilds:Array = [ { @@ -1872,33 +2208,47 @@ class Charter extends UIState { { label: "(0) Default Note", keybind: [ZERO], - onSelect: (_) -> {changeNoteType(0);}, + onSelect: (_) -> + { + changeNoteType(0); + }, icon: this.noteType == 0 ? 1 : 0 } ]; var noteKeys:Array = [ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE]; - for (i=>type in noteTypes) { - var realNoteID:Int = i+1; // Default Note not stored + for (i => type in noteTypes) + { + var realNoteID:Int = i + 1; // Default Note not stored var newChild:UIContextMenuOption = { label: '(${realNoteID}) ${type}', - onSelect: (_) -> {changeNoteType(realNoteID);}, + onSelect: (_) -> + { + changeNoteType(realNoteID); + }, icon: this.noteType == realNoteID ? 1 : 0 }; - if (realNoteID <= 9) newChild.keybind = [noteKeys[realNoteID]]; + if (realNoteID <= 9) + newChild.keybind = [noteKeys[realNoteID]]; newChilds.push(newChild); } newChilds.push({ label: "Edit Note Types List", - color: 0xFF959829, icon: 4, - onCreate: function (button:UIContextMenuOptionSpr) {button.label.offset.x = button.icon.offset.x = -2;}, + color: 0xFF959829, + icon: 4, + onCreate: function(button:UIContextMenuOptionSpr) + { + button.label.offset.x = button.icon.offset.x = -2; + }, onSelect: editNoteTypesList }); - if (noteTopButton != null) noteTopButton.contextMenu = newChilds; + if (noteTopButton != null) + noteTopButton.contextMenu = newChilds; return newChilds; } - public function playtestChart(time:Float = 0, opponentMode = false, here = false) { + public function playtestChart(time:Float = 0, opponentMode = false, here = false) + { buildChart(); startHere = here; startTime = Conductor.songPosition; @@ -1907,7 +2257,8 @@ class Charter extends UIState { FlxG.switchState(new PlayState()); } - public inline function buildNote(note:CharterNote):ChartNote { + public inline function buildNote(note:CharterNote):ChartNote + { var time = Conductor.getTimeForStep(note.step); return { type: note.type, @@ -1917,37 +2268,45 @@ class Charter extends UIState { }; } - public function buildChart() { + public function buildChart() + { PlayState.SONG.strumLines = []; PlayState.SONG.noteTypes = this.noteTypes; - for(s in strumLines) { + for (s in strumLines) + { s.strumLine.notes = []; PlayState.SONG.strumLines.push(s.strumLine); } notesGroup.sortNotes(); - for(n in notesGroup.members) { + for (n in notesGroup.members) + { if (PlayState.SONG.strumLines[n.strumLineID] != null) PlayState.SONG.strumLines[n.strumLineID].notes.push(buildNote(n)); } buildEvents(); } - public function buildEvents() { + public function buildEvents() + { PlayState.SONG.events = []; eventsGroup.sortEvents(); - for(e in eventsGroup.members) { - for(event in e.events) { + for (e in eventsGroup.members) + { + for (event in e.events) + { event.time = Conductor.getTimeForStep(e.step); PlayState.SONG.events.push(event); } } } - public function updateBPMEvents() { + public function updateBPMEvents() + { buildEvents(); Conductor.mapBPMChanges(PlayState.SONG); - Conductor.changeBPM(PlayState.SONG.meta.bpm, cast PlayState.SONG.meta.beatsPerMeasure.getDefault(4), cast PlayState.SONG.meta.stepsPerBeat.getDefault(4)); + Conductor.changeBPM(PlayState.SONG.meta.bpm, cast PlayState.SONG.meta.beatsPerMeasure.getDefault(4), + cast PlayState.SONG.meta.stepsPerBeat.getDefault(4)); refreshBPMSensitive(); } @@ -1964,15 +2323,22 @@ class Charter extends UIState { } } - public inline function __fixSelection(selection:Selection):Selection { + public inline function __fixSelection(selection:Selection):Selection + { var newSelection:Selection = new Selection(); - for (s in selection) if (newSelection.indexOf(s) == -1) newSelection.push(s); - return newSelection.filter((s:ICharterSelectable) -> {return s != null;}); + for (s in selection) + if (newSelection.indexOf(s) == -1) + newSelection.push(s); + return newSelection.filter((s:ICharterSelectable) -> + { + return s != null; + }); } // UH OH!!! DANGER ZONE APPOARCHING !!!! LUNARS SHITTY CODE !!!! -lunar - @:noCompletion public function __relinkSingleSelection(selectable:ICharterSelectable):ICharterSelectable { + @:noCompletion public function __relinkSingleSelection(selectable:ICharterSelectable):ICharterSelectable + { if (selectable is CharterNote) return selectable.ID == -1 ? cast(selectable, CharterNote) : notesGroup.members[selectable.ID]; else if (selectable is CharterEvent) @@ -1987,17 +2353,21 @@ class Charter extends UIState { return newSelection; } - @:noCompletion public inline function __relinkUndos() { + @:noCompletion public inline function __relinkUndos() + { selection = __relinkSelection(selection); - for (list => changeList in [undos.undoList, undos.redoList]) { + for (list => changeList in [undos.undoList, undos.redoList]) + { var newChanges:Array = []; - for (i => change in changeList) { - switch (change) { + for (i => change in changeList) + { + switch (change) + { case CCreateSelection(selection): newChanges[i] = CCreateSelection(__relinkSelection(selection)); case CDeleteSelection(selection): - newChanges[i] = CDeleteSelection(__relinkSelection(selection)); + newChanges[i] = CDeleteSelection(__relinkSelection(selection)); case CSelectionDrag(selectionDrags): newChanges[i] = CSelectionDrag([ for (selectionDrag in selectionDrags) @@ -2022,29 +2392,41 @@ class Charter extends UIState { for (noteChanged in notesChanged) cast(__relinkSingleSelection(noteChanged), CharterNote) ], oldNoteTypes, newNoteTypes); - default: newChanges[i] = change; + default: + newChanges[i] = change; } } - if (list == 0) undos.undoList = newChanges; - else undos.redoList = newChanges; + if (list == 0) + undos.undoList = newChanges; + else + undos.redoList = newChanges; } } - @:noCompletion public function __resetStatics() { + @:noCompletion public function __resetStatics() + { selection = new Selection(); undos = new UndoList(); - clipboard = []; playtestInfo = null; + clipboard = []; + playtestInfo = null; waveformHandler = new CharterWaveformHandler(); autoSaveTimer = Options.charterAutoSaveTime; } - @:noCompletion public function __clearStatics() { - selection = null; undos = null; clipboard = null; playtestInfo = null; - waveformHandler.destroy(); Charter.waveformHandler = null; autoSaveTimer = 0; + @:noCompletion public function __clearStatics() + { + selection = null; + undos = null; + clipboard = null; + playtestInfo = null; + waveformHandler.destroy(); + Charter.waveformHandler = null; + autoSaveTimer = 0; } - @:noCompletion public function __updatePlaytestInfo() { + @:noCompletion public function __updatePlaytestInfo() + { playtestInfo = { songPosition: Conductor.songPosition, playbackSpeed: playBackSlider.value, @@ -2057,8 +2439,10 @@ class Charter extends UIState { } } - @:noCompletion public function __applyPlaytestInfo() { - if (playtestInfo == null) return; + @:noCompletion public function __applyPlaytestInfo() + { + if (playtestInfo == null) + return; Conductor.songPosition = playtestInfo.songPosition; playBackSlider.value = playtestInfo.playbackSpeed; @@ -2075,7 +2459,8 @@ class Charter extends UIState { } } -enum CharterChange { +enum CharterChange +{ CCreateStrumLine(strumLineID:Int, strumLine:ChartStrumLine); CEditStrumLine(strumLineID:Int, oldStrumLine:ChartStrumLine, newStrumLine:ChartStrumLine); COrderStrumLine(strumLineID:Int, oldID:Int, newID:Int); @@ -2090,38 +2475,45 @@ enum CharterChange { CEditSpecNotesType(notes:Array, oldNoteTypes:Array, newNoteTypes:Array); } -enum CharterCopyboardObject { +enum CharterCopyboardObject +{ CNote(step:Float, id:Int, strumLineID:Int, susLength:Float, type:Int); CEvent(step:Float, events:Array); } -typedef NoteSustainChange = { +typedef NoteSustainChange = +{ var note:CharterNote; var before:Float; var after:Float; } -typedef SelectionDragChange = { +typedef SelectionDragChange = +{ var selectable:ICharterSelectable; var change:FlxPoint; } -@:forward abstract Selection(Array) from Array to Array { +@:forward abstract Selection(Array) from Array to Array +{ public inline function new(?array:Array) this = array == null ? [] : array; // too lazy to put this in every for loop so i made it a abstract - public inline function loop(onNote:CharterNote->Void, ?onEvent:CharterEvent->Void, ?draggableOnly:Bool = true) { - for (s in this) { - if (s is CharterNote && onNote != null && (draggableOnly ? s.draggable: true)) + public inline function loop(onNote:CharterNote->Void, ?onEvent:CharterEvent->Void, ?draggableOnly:Bool = true) + { + for (s in this) + { + if (s is CharterNote && onNote != null && (draggableOnly ? s.draggable : true)) onNote(cast(s, CharterNote)); - else if (s is CharterEvent && onEvent != null && (draggableOnly ? s.draggable: true)) + else if (s is CharterEvent && onEvent != null && (draggableOnly ? s.draggable : true)) onEvent(cast(s, CharterEvent)); } } } -interface ICharterSelectable { +interface ICharterSelectable +{ public var x(default, set):Float; public var y(default, set):Float; public var ID:Int; @@ -2135,7 +2527,8 @@ interface ICharterSelectable { public function handleDrag(change:FlxPoint):Void; } -enum abstract CharterGridActionType(Int) { +enum abstract CharterGridActionType(Int) +{ var NONE = 0; var BOX_SELECTION = 1; var NOTE_DRAG = 2; @@ -2144,7 +2537,8 @@ enum abstract CharterGridActionType(Int) { var DELETE_SELECTION = 5; } -typedef PlaytestInfo = { +typedef PlaytestInfo = +{ var songPosition:Float; var playbackSpeed:Float; var quantSelected:Int; From c310cf7149e10265de300985649c6173436ef01a Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Wed, 6 Nov 2024 08:39:54 -0500 Subject: [PATCH 11/20] Moved the accept call whoopsie --- source/funkin/editors/charter/Charter.hx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 05445bf2f..de516afc4 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -1389,6 +1389,16 @@ class Charter extends UIState notesGroup.add(debugcodeteehee); trace(debugcodeteehee); } + else if (controls.ACCEPT) + { + trace("hey dummy I'm pressing accept"); + FlxG.sound.music.pause(); + vocals.pause(); + for (strumLine in strumLines.members) + strumLine.vocals.pause(); + + isLiveCharting = false; + } } // TEST CODE ----------------------------- @@ -1865,16 +1875,6 @@ class Charter extends UIState strumLine.vocals.play(); strumLine.vocals.time = vocals.time; } - - if (controls.ACCEPT) - { - FlxG.sound.music.pause(); - vocals.pause(); - for (strumLine in strumLines.members) - strumLine.vocals.pause(); - - isLiveCharting = false; - } } inline function _chart_live_here(_) From e95c3393d42d1b94a5d0442f5b7e21589a7a002a Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Wed, 6 Nov 2024 09:31:34 -0500 Subject: [PATCH 12/20] Bug I found --- source/funkin/editors/charter/Charter.hx | 78 +++++++++++++----------- 1 file changed, 42 insertions(+), 36 deletions(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index de516afc4..88ac588e6 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -421,7 +421,7 @@ class Charter extends UIState for (camera in FlxG.cameras.list) camera.antialiasing = false; - charterBG = new FunkinSprite(0, 0, Paths.image('menus/menuDesat')); + charterBG = new FunkinSprite(0, 0, Paths.image('menus/portermenus/menuDesat')); charterBG.color = 0xFF181818; charterBG.cameras = [charterCamera]; charterBG.screenCenter(); @@ -1856,55 +1856,61 @@ class Charter extends UIState inline function _chart_live(_) { - trace("make this"); + if (!isLiveCharting) + { + trace("make this"); - isLiveCharting = true; - Conductor.songPosition = 0; // fuck you + isLiveCharting = true; + Conductor.songPosition = 0; // fuck you - // make SL selection functionality - // pause until a SL was selected - // start countdown - // only after all that can it... + // make SL selection functionality + // pause until a SL was selected + // start countdown + // only after all that can it... - FlxG.sound.music.play(); - vocals.play(); + FlxG.sound.music.play(); + vocals.play(); - vocals.time = FlxG.sound.music.time = Conductor.songPosition + Conductor.songOffset * 2; - for (strumLine in strumLines.members) - { - strumLine.vocals.play(); - strumLine.vocals.time = vocals.time; + vocals.time = FlxG.sound.music.time = Conductor.songPosition + Conductor.songOffset * 2; + for (strumLine in strumLines.members) + { + strumLine.vocals.play(); + strumLine.vocals.time = vocals.time; + } } } inline function _chart_live_here(_) { - trace("and this too"); + if (!isLiveCharting) + { + trace("and this too"); - isLiveCharting = true; + isLiveCharting = true; - // make SL selection functionality - // pause until a SL was selected - // start countdown - // only after all that can it... + // make SL selection functionality + // pause until a SL was selected + // start countdown + // only after all that can it... - FlxG.sound.music.play(); - vocals.play(); - vocals.time = FlxG.sound.music.time = Conductor.songPosition + Conductor.songOffset * 2; - for (strumLine in strumLines.members) - { - strumLine.vocals.play(); - strumLine.vocals.time = vocals.time; - } - - if (controls.ACCEPT) - { - FlxG.sound.music.pause(); - vocals.pause(); + FlxG.sound.music.play(); + vocals.play(); + vocals.time = FlxG.sound.music.time = Conductor.songPosition + Conductor.songOffset * 2; for (strumLine in strumLines.members) - strumLine.vocals.pause(); + { + strumLine.vocals.play(); + strumLine.vocals.time = vocals.time; + } - isLiveCharting = false; + if (controls.ACCEPT) + { + FlxG.sound.music.pause(); + vocals.pause(); + for (strumLine in strumLines.members) + strumLine.vocals.pause(); + + isLiveCharting = false; + } } } From b63ae939f157201ef3c5ae0f72bdc8fc873e721a Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Wed, 6 Nov 2024 09:33:16 -0500 Subject: [PATCH 13/20] oops totally forgot about this --- source/funkin/editors/charter/Charter.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 88ac588e6..c7716acd2 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -421,7 +421,7 @@ class Charter extends UIState for (camera in FlxG.cameras.list) camera.antialiasing = false; - charterBG = new FunkinSprite(0, 0, Paths.image('menus/portermenus/menuDesat')); + charterBG = new FunkinSprite(0, 0, Paths.image('menus/menuDesat')); charterBG.color = 0xFF181818; charterBG.cameras = [charterCamera]; charterBG.screenCenter(); From 80ca88683f79ca1f8df9b7b2ac1b42b049c1721f Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Wed, 6 Nov 2024 12:28:17 -0500 Subject: [PATCH 14/20] Add recording shit skibidi --- assets/images/editors/charter/recording.png | Bin 0 -> 870 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 assets/images/editors/charter/recording.png diff --git a/assets/images/editors/charter/recording.png b/assets/images/editors/charter/recording.png new file mode 100644 index 0000000000000000000000000000000000000000..a20bf235022debece8607331ace532b470a9f9ed GIT binary patch literal 870 zcmeAS@N?(olHy`uVBq!ia0vp^bAZ^7gBeIZn$RB&q!^2X+?^QKos)S9O9c3YxB_WAe&y{F64Gq^58~qdE!&fLd4Ylt&F=97DUOmLzu^B6z;Lg5 zZzNERv%n*=n1O-s5C}7hYIrp;FfbkVba4#HaDIF3WZoSE0oTCv4Zr{Yw+OA;e#B8_ zcG#vDSx@qEf@Js{Bt9H}>?!Z-bFVMC<7B2};hVT4ht}TM)X^GyvtZ5oUxh~&bn%{! zi2C}u!%gwBQ=CDYiCOP%Ia>b=GM>1I)r z$Kq!PbS(BoX-9nNIj)|~+I?(~jKw}4xhv`Gw)US^O!wi3F;^B;Z#c0(TfTixW*NWO z&+@mACx}@1ZZlyyZD;Rpb9M`mv2S10z1NRTE_p1ACG1S|4G^1yA<)YrgU3V^L^ki3b7M6zJDhCn2 zA02zJd&kEZwU`e(dXv_ie(boOe|5f0iHh9zKnK3O?U&k^-}=JeFMcm9yC(hE<#)Kn#ea`?OuQ$mE@ytJSjH%W6~>rZxNA;) z|E-PvSNP7Q-`ZK$bLLcY^v7opH)YLQezC)xe|l&}Wx=`IywgRu$UWb4w;(Hm2reLVR}axvE$J6-N|PuDhlZSKpIo4@w8^0lk{x8_Y_f4=cp zQInR+QKoL+%Modoj-r#28jmj99JAxsffeemIT6P$t(qsYaiNy$8fWly^>bP0l+XkK;!Byp literal 0 HcmV?d00001 From 667d13c8f38478e0c315d49889fdfb2b615e6d07 Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Wed, 6 Nov 2024 12:29:29 -0500 Subject: [PATCH 15/20] Recording visuals + small bugfix noticed that it keeps playing (but not recording) after you press accept probably just a FlxG.pressed thing I'll try to fix it or I won't it's not like it's a huge bug, just a little quirk --- source/funkin/editors/charter/Charter.hx | 41 ++++++++++++++++++------ 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index c7716acd2..ddc8271d0 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -67,6 +67,7 @@ class Charter extends UIState public var noteDeleteAnims:CharterDeleteAnim; public var strumlineInfoBG:FlxSprite; + public var liveChartRecording:FlxSprite; public var strumlineAddButton:CharterStrumlineButton; public var strumlineLockButton:CharterStrumlineButton; @@ -496,6 +497,14 @@ class Charter extends UIState autoSaveNotif = new CharterAutoSaveUI(20, strumlineInfoBG.y + strumlineInfoBG.height + 20); uiGroup.add(autoSaveNotif); + liveChartRecording = new UISprite(); + liveChartRecording.loadGraphic(Paths.image('editors/charter/recording'), true, 78, 78); + liveChartRecording.animation.add("off", [0]); + liveChartRecording.animation.add("on", [1]); + liveChartRecording.x = (FlxG.width - liveChartRecording.frameWidth - scrollBar.width) - 20; + liveChartRecording.y = (strumlineInfoBG.y + strumlineInfoBG.height) + 20; + liveChartRecording.scrollFactor.set(); + strumlineAddButton = new CharterStrumlineButton("editors/new", "Create New"); strumlineAddButton.onClick = createStrumWithUI; strumlineAddButton.animationOnClick = false; @@ -513,6 +522,7 @@ class Charter extends UIState strumlineAddButton.cameras = strumlineLockButton.cameras = [charterCamera]; strumlineInfoBG.cameras = [charterCamera]; + liveChartRecording.cameras = [charterCamera]; strumLines.cameras = [charterCamera]; addEventSpr = new CharterEventAdd(); @@ -530,6 +540,7 @@ class Charter extends UIState add(notesGroup); add(selectionBox); add(strumlineInfoBG); + add(liveChartRecording); add(strumlineLockButton); add(strumlineAddButton); add(strumLines); @@ -539,6 +550,8 @@ class Charter extends UIState // add the ui group add(uiGroup); + liveChartRecording.animation.play("off"); + loadSong(); if (Framerate.isLoaded) @@ -573,6 +586,19 @@ class Charter extends UIState super.destroy(); } + public function recordingDisplay(isIt:Bool = true) + { + switch isIt { + case true: + charterBG.color = 0xFF0B0B0B; + liveChartRecording.animation.play("on"); + + case false: + charterBG.color = 0xFF181818; + liveChartRecording.animation.play("off"); + } + } + public function loadSong() { if (__reload) @@ -1398,6 +1424,7 @@ class Charter extends UIState strumLine.vocals.pause(); isLiveCharting = false; + recordingDisplay(false); } } @@ -1868,6 +1895,8 @@ class Charter extends UIState // start countdown // only after all that can it... + recordingDisplay(true); + FlxG.sound.music.play(); vocals.play(); @@ -1893,6 +1922,8 @@ class Charter extends UIState // start countdown // only after all that can it... + recordingDisplay(true); + FlxG.sound.music.play(); vocals.play(); vocals.time = FlxG.sound.music.time = Conductor.songPosition + Conductor.songOffset * 2; @@ -1901,16 +1932,6 @@ class Charter extends UIState strumLine.vocals.play(); strumLine.vocals.time = vocals.time; } - - if (controls.ACCEPT) - { - FlxG.sound.music.pause(); - vocals.pause(); - for (strumLine in strumLines.members) - strumLine.vocals.pause(); - - isLiveCharting = false; - } } } From 4ba377d7ed75d7eef0300f88606b33077720ec32 Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Fri, 8 Nov 2024 22:29:35 -0500 Subject: [PATCH 16/20] Couldn't autoupdate womp womp --- source/funkin/editors/charter/Charter.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index ddc8271d0..851a4c1f6 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -2141,7 +2141,7 @@ class Charter extends UIState function _note_selectall(_) { - selection = [for (note in notesGroup.members) note]; + selection = cast notesGroup.members.copy(); } function _note_selectmeasure(_) From b3346f413444fc39bf90f082243fa1fb2c1ad93d Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Fri, 8 Nov 2024 23:10:53 -0500 Subject: [PATCH 17/20] Removed (now unnecessary) trace functions --- source/funkin/editors/charter/Charter.hx | 38 +++++++++++------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 851a4c1f6..4f1f36d37 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -422,7 +422,7 @@ class Charter extends UIState for (camera in FlxG.cameras.list) camera.antialiasing = false; - charterBG = new FunkinSprite(0, 0, Paths.image('menus/menuDesat')); + charterBG = new FunkinSprite(0, 0, Paths.image('menus/portermenus/menuDesat')); charterBG.color = 0xFF181818; charterBG.cameras = [charterCamera]; charterBG.screenCenter(); @@ -1385,35 +1385,31 @@ class Charter extends UIState { if (controls.LEFT) { - var debugcodeteehee = new CharterNote(); - debugcodeteehee.updatePos(1.0, 0, 0, 0); - // add(debugcodeteehee); - notesGroup.add(debugcodeteehee); - trace(debugcodeteehee); + var leftrec = new CharterNote(); + leftrec.updatePos(1.0, 0, 0, 0); + add(leftrec); + notesGroup.add(leftrec); } else if (controls.DOWN) { - var debugcodeteehee = new CharterNote(); - debugcodeteehee.updatePos(1.0, 1, 0, 0); - // add(debugcodeteehee); - notesGroup.add(debugcodeteehee); - trace(debugcodeteehee); + var downrec = new CharterNote(); + downrec.updatePos(1.0, 1, 0, 0); + add(downrec); + notesGroup.add(downrec); } else if (controls.UP) { - var debugcodeteehee = new CharterNote(); - debugcodeteehee.updatePos(1.0, 2, 0, 0); - // add(debugcodeteehee); - notesGroup.add(debugcodeteehee); - trace(debugcodeteehee); + var uprec = new CharterNote(); + uprec.updatePos(1.0, 2, 0, 0); + add(uprec); + notesGroup.add(uprec); } else if (controls.RIGHT) { - var debugcodeteehee = new CharterNote(); - debugcodeteehee.updatePos(1.0, 3, 0, 0); - // add(debugcodeteehee); - notesGroup.add(debugcodeteehee); - trace(debugcodeteehee); + var rightrec = new CharterNote(); + rightrec.updatePos(1.0, 3, 0, 0); + add(rightrec); + notesGroup.add(rightrec); } else if (controls.ACCEPT) { From c84cba2671e30603980d2eb1dfc58cda41d3fcf6 Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Fri, 8 Nov 2024 23:13:30 -0500 Subject: [PATCH 18/20] I fucking hate Funkin Family Rush You'll get it when you're older (check Gamejolt) --- source/funkin/editors/charter/Charter.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 4f1f36d37..215ed9cc8 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -422,7 +422,7 @@ class Charter extends UIState for (camera in FlxG.cameras.list) camera.antialiasing = false; - charterBG = new FunkinSprite(0, 0, Paths.image('menus/portermenus/menuDesat')); + charterBG = new FunkinSprite(0, 0, Paths.image('menus/menuDesat')); charterBG.color = 0xFF181818; charterBG.cameras = [charterCamera]; charterBG.screenCenter(); From dbf318135df5976268e560e9d6c5517ab1df0fdf Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:09:04 -0500 Subject: [PATCH 19/20] Slight Revival of Branch - fixed it so it follows the current format - optimized one of the bits of code --- source/funkin/editors/charter/Charter.hx | 1304 ++++++++-------------- 1 file changed, 445 insertions(+), 859 deletions(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 484dfb326..50f0eb04a 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -1,6 +1,6 @@ package funkin.editors.charter; - // ! FUCK YOU CHUF (your biggest fan -lunar) <3 + import flixel.input.FlxPointer; import openfl.geom.Point; import openfl.geom.Rectangle; @@ -26,14 +26,12 @@ import flixel.util.FlxColor; import openfl.display.BitmapData; import funkin.backend.shaders.CustomShader; -class Charter extends UIState -{ +class Charter extends UIState { public static var __song:String; static var __diff:String; static var __reload:Bool; var chart(get, null):ChartData; - private function get_chart() return PlayState.SONG; @@ -46,7 +44,6 @@ class Charter extends UIState public var uiGroup:FlxTypedGroup = new FlxTypedGroup(); public var topMenu:Array; - @:noCompletion private var playbackIndex:Int = 7; @:noCompletion private var snapIndex:Int = 6; @:noCompletion private var noteIndex:Int = 5; @@ -67,10 +64,12 @@ class Charter extends UIState public var noteDeleteAnims:CharterDeleteAnim; public var strumlineInfoBG:FlxSprite; - public var liveChartRecording:FlxSprite; public var strumlineAddButton:CharterStrumlineButton; public var strumlineLockButton:CharterStrumlineButton; + public var liveChartRecording:FlxSprite; + public var isLiveCharting:Bool = false; + public var hitsound:FlxSound; public var metronome:FlxSound; @@ -91,9 +90,6 @@ class Charter extends UIState public var uiCamera:FlxCamera; public var selectionBox:UISliceSprite; public var autoSaveNotif:CharterAutoSaveUI; - - public var isLiveCharting:Bool = false; - public static var autoSaveTimer:Float = 0; public static var selection:Selection; @@ -104,27 +100,21 @@ class Charter extends UIState public static var clipboard:Array = []; public static var waveformHandler:CharterWaveformHandler; - public function new(song:String, diff:String, reload:Bool = true) - { + public function new(song:String, diff:String, reload:Bool = true) { super(); - if (song != null) - { + if (song != null) { __song = song; __diff = diff; __reload = reload; } } - public override function create() - { + public override function create() { super.create(); WindowUtils.suffix = " (Chart Editor)"; SaveWarning.selectionClass = CharterSelection; - SaveWarning.saveFunc = () -> - { - _file_save(null); - }; + SaveWarning.saveFunc = () -> {_file_save(null);}; topMenu = [ { @@ -173,7 +163,7 @@ class Charter extends UIState }, { label: "Save Meta As...", - keybind: [CONTROL, ALT, SHIFT, S], + keybind: [CONTROL, ALT ,SHIFT, S], onSelect: _file_meta_saveas, }, null, @@ -256,14 +246,14 @@ class Charter extends UIState null, { label: "Record live charting", - color: 0xFFA91734, + color: 0xFFD21239, icon: 7, keybind: [CONTROL, R], onSelect: _chart_live }, { label: "Record live charting here", - color: 0xFFA91734, + color: 0xFFD21239, icon: 7, keybind: [CONTROL, SHIFT, R], onSelect: _chart_live_here @@ -277,22 +267,14 @@ class Charter extends UIState null, { label: "Edit chart data", - color: 0xFF959829, - icon: 4, - onCreate: function(button:UIContextMenuOptionSpr) - { - button.label.offset.x = button.icon.offset.x = -2; - }, + color: 0xFF959829, icon: 4, + onCreate: function (button:UIContextMenuOptionSpr) {button.label.offset.x = button.icon.offset.x = -2;}, onSelect: chart_edit_data }, { label: "Edit metadata information", - color: 0xFF959829, - icon: 4, - onCreate: function(button:UIContextMenuOptionSpr) - { - button.label.offset.x = button.icon.offset.x = -2; - }, + color: 0xFF959829, icon: 4, + onCreate: function (button:UIContextMenuOptionSpr) {button.label.offset.x = button.icon.offset.x = -2;}, onSelect: chart_edit_metadata } ] @@ -437,8 +419,7 @@ class Charter extends UIState uiCamera.bgColor = 0; FlxG.cameras.add(uiCamera); - for (camera in FlxG.cameras.list) - camera.antialiasing = false; + for (camera in FlxG.cameras.list) camera.antialiasing = false; charterBG = new FunkinSprite(0, 0, Paths.image('menus/menuDesat')); charterBG.color = 0xFF181818; @@ -464,7 +445,8 @@ class Charter extends UIState noteHoverer = new CharterNoteHoverer(); noteDeleteAnims = new CharterDeleteAnim(); - selectionBox.cameras = notesGroup.cameras = gridBackdrops.cameras = noteHoverer.cameras = noteDeleteAnims.cameras = [charterCamera]; + selectionBox.cameras = notesGroup.cameras = gridBackdrops.cameras = + noteHoverer.cameras = noteDeleteAnims.cameras = [charterCamera]; topMenuSpr = new UITopMenu(topMenu); topMenuSpr.cameras = uiGroup.cameras = [uiCamera]; @@ -474,8 +456,7 @@ class Charter extends UIState scrollBar = new UIScrollBar(FlxG.width - 20, topMenuSpr.bHeight, 1000, 0, 100); scrollBar.cameras = [uiCamera]; - scrollBar.onChange = function(v) - { + scrollBar.onChange = function(v) { if (!FlxG.sound.music.playing) Conductor.songPosition = Conductor.getTimeForStep(v) + Conductor.songOffset; }; @@ -485,24 +466,17 @@ class Charter extends UIState songPosInfo.alignment = RIGHT; uiGroup.add(songPosInfo); - playBackSlider = new UISlider(FlxG.width - 160 - 26 - 20, (23 / 2) - (12 / 2), 160, 1, - [{start: 0.25, end: 1, size: 0.5}, {start: 1, end: 2, size: 0.5}], true); - playBackSlider.onChange = function(v) - { + playBackSlider = new UISlider(FlxG.width - 160 - 26 - 20, (23/2) - (12/2), 160, 1, [{start: 0.25, end: 1, size: 0.5}, {start: 1, end: 2, size: 0.5}], true); + playBackSlider.onChange = function (v) { FlxG.sound.music.pitch = vocals.pitch = v; - for (strumLine in strumLines.members) - strumLine.vocals.pitch = v; + for (strumLine in strumLines.members) strumLine.vocals.pitch = v; }; uiGroup.add(playBackSlider); quants.reverse(); - for (quant in quants) - { + for (quant in quants) { var button:CharterQuantButton = new CharterQuantButton(0, 0, quant); - button.onClick = () -> - { - setquant(button.quant); - }; + button.onClick = () -> {setquant(button.quant);}; quantButtons.push(cast uiGroup.add(button)); } quants.reverse(); @@ -529,10 +503,8 @@ class Charter extends UIState strumlineAddButton.textColorLerp = 0.5; strumlineLockButton = new CharterStrumlineButton("editors/charter/lock-strumline", "Lock/Unlock"); - strumlineLockButton.onClick = function() - { - if (strumLines != null) - { + strumlineLockButton.onClick = function () { + if (strumLines != null) { strumLines.draggable = !strumLines.draggable; strumlineLockButton.textTweenColor.color = strumLines.draggable ? 0xFF5C95CA : 0xFFE16565; } @@ -540,7 +512,6 @@ class Charter extends UIState strumlineAddButton.cameras = strumlineLockButton.cameras = [charterCamera]; strumlineInfoBG.cameras = [charterCamera]; - liveChartRecording.cameras = [charterCamera]; strumLines.cameras = [charterCamera]; addEventSpr = new CharterEventAdd(); @@ -568,12 +539,11 @@ class Charter extends UIState // add the ui group add(uiGroup); - liveChartRecording.animation.play("off"); + liveChartRecording.animation.play('off'); loadSong(); - if (Framerate.isLoaded) - { + if(Framerate.isLoaded) { Framerate.fpsCounter.alpha = 0.4; Framerate.memoryCounter.alpha = 0.4; Framerate.codenameBuildField.alpha = 0.4; @@ -582,21 +552,19 @@ class Charter extends UIState // ! IF YOU EVER WANNA VIEW IN THE FUTURE, JUST USE A FLXSPRITE :D -lunar /*var dataDisplay:FlxSprite = new FlxSprite().loadGraphic(waveformHandler.waveDatas.get("Voices.ogg")); - dataDisplay.scrollFactor.set(1, 0); - dataDisplay.scale.set(2, 2); - dataDisplay.updateHitbox(); - dataDisplay.screenCenter(Y); - dataDisplay.cameras = [charterCamera]; dataDisplay.x = -dataDisplay.width; add(dataDisplay); */ + dataDisplay.scrollFactor.set(1, 0); + dataDisplay.scale.set(2, 2); + dataDisplay.updateHitbox(); + dataDisplay.screenCenter(Y); + dataDisplay.cameras = [charterCamera]; dataDisplay.x = -dataDisplay.width; add(dataDisplay);*/ DiscordUtil.call("onEditorLoaded", ["Chart Editor", __song + " (" + __diff + ")"]); } - override function destroy() - { + override function destroy() { __updatePlaytestInfo(); - if (Framerate.isLoaded) - { + if(Framerate.isLoaded) { Framerate.fpsCounter.alpha = 1; Framerate.memoryCounter.alpha = 1; Framerate.codenameBuildField.alpha = 1; @@ -604,23 +572,20 @@ class Charter extends UIState super.destroy(); } - public function recordingDisplay(isIt:Bool = true) - { + public function recordingDisplay(isIt:Bool = true) { switch isIt { case true: charterBG.color = 0xFF0B0B0B; liveChartRecording.animation.play("on"); - + case false: charterBG.color = 0xFF181818; liveChartRecording.animation.play("off"); } } - public function loadSong() - { - if (__reload) - { + public function loadSong() { + if (__reload) { EventsData.reloadEvents(); PlayState.loadSong(__song, __diff, false, false); __resetStatics(); @@ -637,7 +602,7 @@ class Charter extends UIState gridBackdrops.createGrids(PlayState.SONG.strumLines.length); - for (strL in PlayState.SONG.strumLines) + for(strL in PlayState.SONG.strumLines) createStrumline(strumLines.members.length, strL, false, false); // create notes @@ -649,8 +614,7 @@ class Charter extends UIState var notesCreated:Int = 0; for (i => strL in PlayState.SONG.strumLines) - for (note in strL.notes) - { + for (note in strL.notes) { var n = new CharterNote(); var t = Conductor.getStepForTime(note.time); n.updatePos(t, note.id, Conductor.getStepForTime(note.time + note.sLen) - t, note.type, strumLines.members[i]); @@ -663,16 +627,11 @@ class Charter extends UIState eventsGroup.autoSort = false; var __last:CharterEvent = null; var __lastTime:Float = Math.NaN; - for (e in PlayState.SONG.events) - { - if (e == null) - continue; - if (__last != null && __lastTime == e.time) - { + for(e in PlayState.SONG.events) { + if (e == null) continue; + if (__last != null && __lastTime == e.time) { __last.events.push(e); - } - else - { + } else { __last = new CharterEvent(Conductor.getStepForTime(e.time), [e]); __lastTime = e.time; eventsGroup.add(__last); @@ -682,60 +641,47 @@ class Charter extends UIState eventsGroup.sortEvents(); eventsGroup.autoSort = true; - for (e in eventsGroup.members) + for(e in eventsGroup.members) e.refreshEventIcons(); buildNoteTypesUI(); refreshBPMSensitive(); // Just for now until i add event stacking -lunar - try - { - __relinkUndos(); - } - catch (e) - { - Logs.trace('Failed to relink undos: ${Std.string(e)}', ERROR); - } - + try {__relinkUndos();} + catch (e) {Logs.trace('Failed to relink undos: ${Std.string(e)}', ERROR);} + __applyPlaytestInfo(); } public var __endStep:Float = 0; - - public function refreshBPMSensitive() - { + public function refreshBPMSensitive() { // refreshes everything dependant on BPM, and BPM changes var length = FlxG.sound.music.getDefault(vocals).length; scrollBar.length = __endStep = Conductor.getStepForTime(length); gridBackdrops.bottomLimitY = __endStep * 40; - eventsBackdrop.bottomSeparator.y = gridBackdrops.bottomLimitY - 2; + eventsBackdrop.bottomSeparator.y = gridBackdrops.bottomLimitY-2; updateWaveforms(); } - inline function isSoundLoaded(sound:FlxSound) - { + inline function isSoundLoaded(sound:FlxSound) { @:privateAccess return sound != null && sound._sound != null && sound._sound.length > 0; } - public function updateWaveforms() - { + public function updateWaveforms() { var wavesToGenerate:Array<{name:String, sound:FlxSound}> = []; - if (isSoundLoaded(FlxG.sound.music)) + if(isSoundLoaded(FlxG.sound.music)) wavesToGenerate.push({name: "Inst.ogg", sound: FlxG.sound.music}); if (PlayState.SONG.meta.needsVoices != false && isSoundLoaded(vocals)) wavesToGenerate.push({name: "Voices.ogg", sound: vocals}); for (strumLine in strumLines) - if (strumLine.vocals != null - && strumLine.strumLine.vocalsSuffix != null - && strumLine.strumLine.vocalsSuffix != "" - && isSoundLoaded(strumLine.vocals)) + if (strumLine.vocals != null && strumLine.strumLine.vocalsSuffix != null && strumLine.strumLine.vocalsSuffix != "" && isSoundLoaded(strumLine.vocals)) wavesToGenerate.push({ name: 'Voices${strumLine.strumLine.vocalsSuffix}.ogg', sound: strumLine.vocals @@ -744,19 +690,15 @@ class Charter extends UIState var oldWaveformList:Array = waveformHandler.waveformList; var newWaveformList:Array = [for (data in wavesToGenerate) data.name]; - if (waveformHandler == null ? true : waveformHandler.ampsNeeded != __endStep * 40) - { + if (waveformHandler == null ? true : waveformHandler.ampsNeeded != __endStep*40) { waveformHandler.clearWaveforms(); waveformHandler.ampsNeeded = __endStep * 40; - for (data in wavesToGenerate) - { + for (data in wavesToGenerate) { waveformHandler.generateShader(data.name, data.sound); waveformHandler.waveformList.push(data.name); } - } - else if (waveformHandler != null && waveformHandler.waveformList.length != newWaveformList.length) - { + } else if (waveformHandler != null && waveformHandler.waveformList.length != newWaveformList.length) { for (name in oldWaveformList) if (!newWaveformList.contains(name)) waveformHandler.clearWaveform(name); @@ -768,21 +710,17 @@ class Charter extends UIState waveformHandler.waveformList = newWaveformList; } - for (strumLine in strumLines) - { - if (strumLine.selectedWaveform == -1) - continue; + for (strumLine in strumLines) { + if (strumLine.selectedWaveform == -1) continue; var oldName:String = oldWaveformList[strumLine.selectedWaveform]; strumLine.selectedWaveform = waveformHandler.waveformList.indexOf(oldName); } } - public override function beatHit(curBeat:Int) - { + public override function beatHit(curBeat:Int) { super.beatHit(curBeat); - if (FlxG.sound.music.playing) - { + if (FlxG.sound.music.playing) { if (Options.charterMetronomeEnabled) metronome.replay(); } @@ -797,68 +735,50 @@ class Charter extends UIState public var mousePos:FlxPoint = new FlxPoint(); public var selectionDragging:Bool = false; - public function updateSelectionLogic() - { - function select(s:ICharterSelectable) - { - if (FlxG.keys.pressed.CONTROL) - selection.push(s); - else if (FlxG.keys.pressed.SHIFT) - selection.remove(s); - else - selection = [s]; + public function updateSelectionLogic() { + function select(s:ICharterSelectable) { + if (FlxG.keys.pressed.CONTROL) selection.push(s); + else if (FlxG.keys.pressed.SHIFT) selection.remove(s); + else selection = [s]; } - for (group in [notesGroup, eventsGroup]) - { - cast(group, FlxTypedGroup).forEach(function(s) - { + for (group in [notesGroup, eventsGroup]) { + cast(group, FlxTypedGroup).forEach(function(s) { s.selected = false; - if (gridActionType == NONE) - { - if (s is CharterNote) - { + if (gridActionType == NONE) { + if (s is CharterNote) { var n:CharterNote = cast s; - if ((n.hovered || n.sustainDraggable) && FlxG.mouse.justReleased) - select(cast s); - } - else if (FlxG.mouse.justReleased && s.hovered) - select(cast s); + if ((n.hovered || n.sustainDraggable) && FlxG.mouse.justReleased) select(cast s); + } else if (FlxG.mouse.justReleased && s.hovered) select(cast s); } }); } selection = __fixSelection(selection); - for (s in selection) - s.selected = true; + for(s in selection) s.selected = true; } var __autoSaveLocation:String = null; - - public function updateAutoSaving(elapsed:Float) - { - if (!Options.charterAutoSaves) - return; + public function updateAutoSaving(elapsed:Float) { + if (!Options.charterAutoSaves) return; autoSaveTimer -= elapsed; - if (autoSaveTimer < Options.charterAutoSaveWarningTime && !autoSaveNotif.cancelled && !autoSaveNotif.showedAnimation) - { + if (autoSaveTimer < Options.charterAutoSaveWarningTime && !autoSaveNotif.cancelled && !autoSaveNotif.showedAnimation) { if (Options.charterAutoSavesSeperateFolder) __autoSaveLocation = __diff.toLowerCase() + DateTools.format(Date.now(), "%m-%d_%H-%M"); - autoSaveNotif.startAutoSave(autoSaveTimer, - !Options.charterAutoSavesSeperateFolder ? 'Saved chart at ${__diff.toLowerCase()}.json!' : 'Saved chart at $__autoSaveLocation.json!'); + autoSaveNotif.startAutoSave(autoSaveTimer, + !Options.charterAutoSavesSeperateFolder ? 'Saved chart at ${__diff.toLowerCase()}.json!' : + 'Saved chart at $__autoSaveLocation.json!' + ); } - if (autoSaveTimer <= 0) - { + if (autoSaveTimer <= 0) { autoSaveTimer = Options.charterAutoSaveTime; - if (!autoSaveNotif.cancelled) - { - buildChart(); + if (!autoSaveNotif.cancelled) { + buildChart(); var songPath:String = '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}'; - + if (Options.charterAutoSavesSeperateFolder) - Chart.save(songPath, PlayState.SONG, __autoSaveLocation, - {saveMetaInChart: false, folder: "autosaves", prettyPrint: Options.editorPrettyPrint}); - else + Chart.save(songPath, PlayState.SONG, __autoSaveLocation, {saveMetaInChart: false, folder: "autosaves", prettyPrint: Options.editorPrettyPrint}); + else Chart.save(songPath, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: false, prettyPrint: Options.editorPrettyPrint}); undos.save(); } @@ -867,9 +787,7 @@ class Charter extends UIState } var deletedNotes:Selection = new Selection(); - - public function updateNoteLogic(elapsed:Float) - { + public function updateNoteLogic(elapsed:Float) { updateSelectionLogic(); /** @@ -879,40 +797,30 @@ class Charter extends UIState if (!gridBackdropDummy.hoveredByChild && !FlxG.mouse.pressed) gridActionType = NONE; selectionBox.visible = false; - switch (gridActionType) - { + switch(gridActionType) { case BOX_SELECTION: - if (gridBackdropDummy.hoveredByChild) - { + if (gridBackdropDummy.hoveredByChild) { selectionBox.visible = true; - if (FlxG.mouse.pressed) - { + if (FlxG.mouse.pressed) { selectionBox.x = Math.min(mousePos.x, dragStartPos.x); selectionBox.y = Math.min(mousePos.y, dragStartPos.y); selectionBox.bWidth = Std.int(Math.abs(mousePos.x - dragStartPos.x)); selectionBox.bHeight = Std.int(Math.abs(mousePos.y - dragStartPos.y)); - } - else - { - if (FlxG.keys.pressed.SHIFT) - { + } else { + if (FlxG.keys.pressed.SHIFT) { for (group in [notesGroup, eventsGroup]) - for (n in cast(group, FlxTypedGroup)) + for(n in cast(group, FlxTypedGroup)) if (n.handleSelection(selectionBox) && selection.contains(n)) selection.remove(n); - } - else if (FlxG.keys.pressed.CONTROL) - { + } else if (FlxG.keys.pressed.CONTROL) { for (group in [notesGroup, eventsGroup]) - for (n in cast(group, FlxTypedGroup)) + for(n in cast(group, FlxTypedGroup)) if (n.handleSelection(selectionBox) && !selection.contains(n)) selection.push(n); - } - else - { + } else { selection = []; for (group in [notesGroup, eventsGroup]) - for (n in cast(group, FlxTypedGroup)) + for(n in cast(group, FlxTypedGroup)) if (n.handleSelection(selectionBox)) selection.push(n); } @@ -927,70 +835,54 @@ class Charter extends UIState gridActionType = NONE; case NOTE_DRAG: selectionDragging = FlxG.mouse.pressed; - if (selectionDragging) - { + if (selectionDragging) { gridBackdrops.draggingObj = null; - selection.loop(function(n:CharterNote) - { + selection.loop(function (n:CharterNote) { n.snappedToStrumline = false; n.setPosition(n.fullID * 40 + (mousePos.x - dragStartPos.x), n.step * 40 + (mousePos.y - dragStartPos.y)); - n.y = FlxMath.bound(n.y, 0, (__endStep * 40) - n.height); - n.x = FlxMath.bound(n.x, 0, ((strumLines.members.length * 4) - 1) * 40); + n.y = FlxMath.bound(n.y, 0, (__endStep*40) - n.height); + n.x = FlxMath.bound(n.x, 0, ((strumLines.members.length * 4)-1) * 40); n.cursor = HAND; - }, function(e:CharterEvent) - { - e.y = e.step * 40 + (mousePos.y - dragStartPos.y) - 17; - e.y = FlxMath.bound(e.y, -17, (__endStep * 40) - 17); + }, function (e:CharterEvent) { + e.y = e.step * 40 + (mousePos.y - dragStartPos.y) - 17; + e.y = FlxMath.bound(e.y, -17, (__endStep*40)-17); e.cursor = HAND; }); currentCursor = HAND; - } - else - { + } else { dragStartPos.set(Std.int(dragStartPos.x / 40) * 40, dragStartPos.y); var verticalChange:Float = (mousePos.y - dragStartPos.y) / 40; var horizontalChange:Int = CoolUtil.floorInt((mousePos.x - dragStartPos.x) / 40); var undoDrags:Array = []; - for (s in selection) - { - if (s.draggable) - { + for (s in selection) { + if (s.draggable) { var changePoint:FlxPoint = FlxPoint.get(verticalChange, horizontalChange); if (!FlxG.keys.pressed.SHIFT) - changePoint.x -= ((s.step + verticalChange) - quantStepRounded(s.step + verticalChange, verticalChange > 0 ? 0.35 : 0.65)); + changePoint.x -= ((s.step + verticalChange) - quantStepRounded(s.step+verticalChange, verticalChange > 0 ? 0.35 : 0.65)); var boundedChange:FlxPoint = changePoint.clone(); // Some maths, so cool bro -lunar (i dont know why i quopte my self here) - if (s.step + changePoint.x < 0) - boundedChange.x += Math.abs(s.step + changePoint.x); - if (s.step + changePoint.x > __endStep - 1) - boundedChange.x -= (s.step + changePoint.x) - (__endStep - 1); + if (s.step + changePoint.x < 0) boundedChange.x += Math.abs(s.step + changePoint.x); + if (s.step + changePoint.x > __endStep-1) boundedChange.x -= (s.step + changePoint.x) - (__endStep-1); - if (s is CharterNote) - { + if (s is CharterNote) { var note:CharterNote = cast s; - if (note.fullID + changePoint.y < 0) - boundedChange.y += Math.abs(note.fullID + changePoint.y); - if (note.fullID + changePoint.y > (strumLines.members.length * 4) - 1) - boundedChange.y -= (note.fullID + changePoint.y) - ((strumLines.members.length * 4) - 1); + if (note.fullID + changePoint.y < 0) boundedChange.y += Math.abs(note.fullID + changePoint.y); + if (note.fullID + changePoint.y > (strumLines.members.length*4)-1) boundedChange.y -= (note.fullID + changePoint.y) - ((strumLines.members.length*4)-1); } s.handleDrag(boundedChange); - undoDrags.push({selectable: s, change: boundedChange}); + undoDrags.push({selectable:s, change: boundedChange}); changePoint.put(); } - if (s is CharterNote) - cast(s, CharterNote).snappedToStrumline = true; - if (s is UISprite) - cast(s, UISprite).cursor = BUTTON; + if (s is CharterNote) cast(s, CharterNote).snappedToStrumline = true; + if (s is UISprite) cast(s, UISprite).cursor = BUTTON; } - if (!(verticalChange == 0 && horizontalChange == 0)) - { - notesGroup.sortNotes(); - eventsGroup.sortEvents(); + if (!(verticalChange == 0 && horizontalChange == 0)) { + notesGroup.sortNotes(); eventsGroup.sortEvents(); undos.addToUndo(CSelectionDrag(undoDrags)); } @@ -1000,14 +892,12 @@ class Charter extends UIState case NONE: if (FlxG.mouse.justPressed) FlxG.mouse.getWorldPosition(charterCamera, dragStartPos); - else if (FlxG.mouse.justPressedRight) - { + else if (FlxG.mouse.justPressedRight) { closeCurrentContextMenu(); gridActionType = DELETE_SELECTION; } - if (gridBackdropDummy.hovered) - { + if (gridBackdropDummy.hovered) { // AUTO DETECT if (FlxG.mouse.pressed && (Math.abs(mousePos.x - dragStartPos.x) > 20 || Math.abs(mousePos.y - dragStartPos.y) > 20)) gridActionType = BOX_SELECTION; @@ -1015,78 +905,54 @@ class Charter extends UIState var id = Math.floor(mousePos.x / 40); var mouseOnGrid = id >= 0 && id < 4 * gridBackdrops.strumlinesAmount && mousePos.y >= 0; - if (FlxG.mouse.justReleased) - { - for (n in selection) - n.selected = false; - selection = []; - - if (mouseOnGrid && mousePos.y > 0 && mousePos.y < (__endStep) * 40) - { - var note = new CharterNote(); - note.updatePos(FlxMath.bound(FlxG.keys.pressed.SHIFT ? ((mousePos.y - 20) / 40) : quantStep(mousePos.y / 40), 0, __endStep - 1), - id % 4, 0, noteType, strumLines.members[Std.int(id / 4)]); - notesGroup.add(note); - selection = [note]; - undos.addToUndo(CCreateSelection([note])); - } + if (FlxG.mouse.justReleased) { + for (n in selection) n.selected = false; + selection = []; + + if (mouseOnGrid && mousePos.y > 0 && mousePos.y < (__endStep)*40) { + var note = new CharterNote(); + note.updatePos( + FlxMath.bound(FlxG.keys.pressed.SHIFT ? ((mousePos.y-20) / 40) : quantStep(mousePos.y/40), 0, __endStep-1), + id % 4, 0, noteType, strumLines.members[Std.int(id/4)] + ); + notesGroup.add(note); + selection = [note]; + undos.addToUndo(CCreateSelection([note])); + } } - } - else if (gridBackdropDummy.hoveredByChild) - { - if (FlxG.mouse.pressed) - { + } else if (gridBackdropDummy.hoveredByChild) { + if (FlxG.mouse.pressed) { var noteHovered:Bool = false; - for (n in selection) - if (n.hovered) - { - noteHovered = true; - break; - } + for(n in selection) if (n.hovered) {noteHovered = true; break;} var noteSusDrag:Bool = false; - for (s in selection) - { - if (!(s is CharterNote)) - continue; + for(s in selection) { + if (!(s is CharterNote)) continue; var n:CharterNote = cast s; - if (n.sustainDraggable) - { - noteSusDrag = true; - break; - } + if (n.sustainDraggable) {noteSusDrag = true; break;} } - if ((Math.abs(mousePos.x - dragStartPos.x) > (noteSusDrag ? 1 : 5) - || Math.abs(mousePos.y - dragStartPos.y) > (noteSusDrag ? 1 : 5))) - { - if (noteHovered) - gridActionType = noteHovered ? NOTE_DRAG : INVALID_DRAG; - if (noteSusDrag) - gridActionType = SUSTAIN_DRAG; + if ((Math.abs(mousePos.x - dragStartPos.x) > (noteSusDrag ? 1 : 5) || Math.abs(mousePos.y - dragStartPos.y) > (noteSusDrag ? 1 : 5))) { + if (noteHovered) gridActionType = noteHovered ? NOTE_DRAG : INVALID_DRAG; + if (noteSusDrag) gridActionType = SUSTAIN_DRAG; } } } case SUSTAIN_DRAG: selectionDragging = FlxG.mouse.pressed; - if (selectionDragging) - { + if (selectionDragging) { currentCursor = BUTTON; - selection.loop(function(n:CharterNote) - { - var change:Float = Math.max((mousePos.y - (FlxG.keys.pressed.SHIFT ? dragStartPos.y : quantStep(dragStartPos.y))) / 40, -n.susLength); + selection.loop(function (n:CharterNote) { + var change:Float = Math.max((mousePos.y-(FlxG.keys.pressed.SHIFT ? dragStartPos.y : quantStep(dragStartPos.y))) / 40, -n.susLength); n.tempSusLength = change; if (!FlxG.keys.pressed.SHIFT) n.tempSusLength -= (n.susLength + change) - quantStepRounded(n.susLength + change, change > 0 ? 0.35 : 0.65); @:privateAccess n.__susInstaLerp = FlxG.keys.pressed.SHIFT; }); - } - else - { + } else { var undoChanges:Array = []; - selection.loop(function(n:CharterNote) - { + selection.loop(function (n:CharterNote) { var oldSusLen:Float = n.susLength; n.susLength += n.tempSusLength; @@ -1102,78 +968,61 @@ class Charter extends UIState currentCursor = ARROW; } case DELETE_SELECTION: - notesGroup.forEach(function(n) - { - if (n.hovered || n.sustainDraggable) - { + notesGroup.forEach(function(n) { + if (n.hovered || n.sustainDraggable) { deletedNotes.push(n); deleteSingleSelection(n, false); - if (selection.contains(n)) - selection.remove(n); + if (selection.contains(n)) selection.remove(n); noteDeleteAnims.deleteNotes.push({ - note: n, - time: noteDeleteAnims.deleteTime + note: n, time: noteDeleteAnims.deleteTime }); } }); - if (FlxG.mouse.justReleasedRight) - { - if (deletedNotes.length > 0) - undos.addToUndo(CDeleteSelection(deletedNotes.copy())); - else if (noteDeleteAnims.garbageIcon.alpha <= .5) - { + if (FlxG.mouse.justReleasedRight) { + if (deletedNotes.length > 0) undos.addToUndo(CDeleteSelection(deletedNotes.copy())); + else if (noteDeleteAnims.garbageIcon.alpha <= .5) { var mousePos = FlxG.mouse.getScreenPosition(uiCamera); closeCurrentContextMenu(); openContextMenu(topMenu[1].childs, null, mousePos.x, mousePos.y); mousePos.put(); } - gridActionType = NONE; - deletedNotes = []; + gridActionType = NONE; deletedNotes = []; } } addEventSpr.selectable = !selectionBox.visible; - var inBoundsY:Bool = (mousePos.y > 0 && mousePos.y < (__endStep) * 40); + var inBoundsY:Bool = (mousePos.y > 0 && mousePos.y < (__endStep)*40); // Event Spr - if (mousePos.x < 0 && mousePos.x > -addEventSpr.bWidth && gridActionType == NONE && inBoundsY) - { + if (mousePos.x < 0 && mousePos.x > -addEventSpr.bWidth && gridActionType == NONE && inBoundsY) { addEventSpr.incorporeal = false; addEventSpr.sprAlpha = lerp(addEventSpr.sprAlpha, 0.75, 0.25); var event = getHoveredEvent(mousePos.y); - if (event != null) - addEventSpr.updateEdit(event); - else - addEventSpr.updatePos(FlxG.keys.pressed.SHIFT ? ((mousePos.y) / 40) : quantStepRounded(mousePos.y / 40)); - } - else - addEventSpr.sprAlpha = lerp(addEventSpr.sprAlpha, 0, 0.25); + if (event != null) addEventSpr.updateEdit(event); + else addEventSpr.updatePos(FlxG.keys.pressed.SHIFT ? ((mousePos.y) / 40) : quantStepRounded(mousePos.y/40)); + } else addEventSpr.sprAlpha = lerp(addEventSpr.sprAlpha, 0, 0.25); noteHoverer.showHoverer = Charter.instance.gridBackdropDummy.hovered; } - public function quantStep(step:Float):Float - { - var stepMulti:Float = 1 / (quant / 16); - return Math.floor(step / stepMulti) * stepMulti; + public function quantStep(step:Float):Float { + var stepMulti:Float = 1/(quant/16); + return Math.floor(step/stepMulti) * stepMulti; } - public function quantStepRounded(step:Float, ?roundRatio:Float = 0.5):Float - { - var stepMulti:Float = 1 / (quant / 16); - return ratioRound(step / stepMulti, roundRatio) * stepMulti; + public function quantStepRounded(step:Float, ?roundRatio:Float = 0.5):Float { + var stepMulti:Float = 1/(quant/16); + return ratioRound(step/stepMulti, roundRatio) * stepMulti; } public function ratioRound(val:Float, ratio:Float):Int return Math.floor(val) + ((Math.abs(val % 1) > ratio ? 1 : 0) * (val > 0 ? 1 : -1)); - public function getHoveredEvent(y:Float) - { + public function getHoveredEvent(y:Float) { var eventHovered:CharterEvent = null; - eventsGroup.forEach(function(e) - { + eventsGroup.forEach(function(e) { if (eventHovered != null) return; @@ -1183,21 +1032,16 @@ class Charter extends UIState return eventHovered; } - public function deleteSingleSelection(selected:ICharterSelectable, addToUndo:Bool = true):Null - { - if (selected == null) - return selected; + public function deleteSingleSelection(selected:ICharterSelectable, addToUndo:Bool = true):Null { + if (selected == null) return selected; - if (selected is CharterNote) - { + if (selected is CharterNote) { var note:CharterNote = cast selected; note.strumLineID = strumLines.members.indexOf(note.strumLine); note.strumLine = null; // For static undos :D notesGroup.remove(note); note.kill(); - } - else if (selected is CharterEvent) - { + } else if (selected is CharterEvent) { var event:CharterEvent = cast selected; eventsGroup.remove(event); event.kill(); @@ -1209,19 +1053,15 @@ class Charter extends UIState return null; } - public function createSelection(selection:Selection, addToUndo:Bool = true) - { - if (selection.length <= 0) - return []; + public function createSelection(selection:Selection, addToUndo:Bool = true) { + if (selection.length <= 0) return []; notesGroup.autoSort = false; - selection.loop(function(n:CharterNote) - { + selection.loop(function (n:CharterNote) { n.strumLine = strumLines.members[n.strumLineID]; n.revive(); notesGroup.add(n); - }, function(e:CharterEvent) - { + }, function (e:CharterEvent) { e.revive(); eventsGroup.add(e); e.refreshEventIcons(); @@ -1230,8 +1070,7 @@ class Charter extends UIState notesGroup.autoSort = true; for (s in selection) - if (s is CharterEvent) - { + if (s is CharterEvent) { Charter.instance.updateBPMEvents(); break; } @@ -1241,31 +1080,25 @@ class Charter extends UIState return []; } - public function deleteSelection(selection:Selection, addToUndo:Bool = true) - { - if (selection.length <= 0) - return []; + public function deleteSelection(selection:Selection, addToUndo:Bool = true) { + if (selection.length <= 0) return []; notesGroup.autoSort = false; - for (objects in [notesGroup, eventsGroup]) - { + for (objects in [notesGroup, eventsGroup]) { var group = cast(objects, FlxTypedGroup); var member = 0; - while (member < group.members.length) - { + while(member < group.members.length) { var s = group.members[member]; if (selection.contains(s)) deleteSingleSelection(s, false); - else - member++; + else member++; } } notesGroup.sortNotes(); notesGroup.autoSort = true; for (s in selection) - if (s is CharterEvent) - { + if (s is CharterEvent) { Charter.instance.updateBPMEvents(); break; } @@ -1276,17 +1109,14 @@ class Charter extends UIState } // STRUMLINE DELETION/CREATION - public function createStrumline(strumLineID:Int, strL:ChartStrumLine, addToUndo:Bool = true, ?__createNotes:Bool = true) - { + public function createStrumline(strumLineID:Int, strL:ChartStrumLine, addToUndo:Bool = true, ?__createNotes:Bool = true) { var cStr = new CharterStrumline(strL); strumLines.insert(strumLineID, cStr); strumLines.snapStrums(); - if (__createNotes) - { + if (__createNotes) { var toBeCreated:Selection = []; - for (note in strL.notes) - { + for(note in strL.notes) { var n = new CharterNote(); var t = Conductor.getStepForTime(note.time); n.updatePos(t, note.id, Conductor.getStepForTime(note.time + note.sLen) - t, note.type, cStr); @@ -1299,16 +1129,14 @@ class Charter extends UIState undos.addToUndo(CCreateStrumLine(strumLineID, strL)); } - public function deleteStrumline(strumLineID:Int, addToUndo:Bool = true) - { + public function deleteStrumline(strumLineID:Int, addToUndo:Bool = true) { var undoNotes:Array = []; removeStrumlineFromSelection(strumLineID); var i = 0; var toBeDeleted:Selection = []; for (note in notesGroup.members) - if (note.strumLineID == strumLineID) - { + if (note.strumLineID == strumLineID) { undoNotes.push(buildNote(note)); toBeDeleted.push(note); } @@ -1319,8 +1147,7 @@ class Charter extends UIState strumLines.members.remove(strumLines.members[strumLineID]); strumLines.snapStrums(); - if (addToUndo) - { + if (addToUndo) { var newStrL = Reflect.copy(strL); newStrL.notes = undoNotes; @@ -1328,22 +1155,17 @@ class Charter extends UIState } } - public function getStrumlineID(strL:ChartStrumLine):Int - { - for (index => strumLine in strumLines.members) - { + public function getStrumlineID(strL:ChartStrumLine):Int { + for (index=>strumLine in strumLines.members) { if (strumLine.strumLine == strL) return index; } return -1; } - public function createStrumWithUI() - { - FlxG.state.openSubState(new CharterStrumlineScreen(strumLines.members.length, null, (_) -> - { - if (_ != null) - { + public function createStrumWithUI() { + FlxG.state.openSubState(new CharterStrumlineScreen(strumLines.members.length, null, (_) -> { + if (_ != null) { createStrumline(strumLines.members.length, _); strumlineAddButton.textTweenColor.color = 0xFF00FF00; @@ -1355,35 +1177,28 @@ class Charter extends UIState public inline function deleteStrumlineFromData(strL:ChartStrumLine) deleteStrumline(getStrumlineID(strL)); - public inline function editStrumline(strL:ChartStrumLine) - { + public inline function editStrumline(strL:ChartStrumLine) { var strID = getStrumlineID(strL); var oldData:ChartStrumLine = Reflect.copy(strL); - FlxG.state.openSubState(new CharterStrumlineScreen(strID, strL, (_) -> - { + FlxG.state.openSubState(new CharterStrumlineScreen(strID, strL, (_) -> { strumLines.members[strID].strumLine = _; strumLines.members[strID].updateInfo(); undos.addToUndo(CEditStrumLine(strID, oldData, _)); - if (oldData.vocalsSuffix != _.vocalsSuffix) - updateWaveforms(); + if (oldData.vocalsSuffix != _.vocalsSuffix) updateWaveforms(); })); } - public inline function removeStrumlineFromSelection(strumLineID:Int) - { + public inline function removeStrumlineFromSelection(strumLineID:Int) { var i = 0; - while (i < selection.length) - { - if (selection[i] is CharterNote) - { + while(i < selection.length) { + if (selection[i] is CharterNote) { var note:CharterNote = cast selection[i]; if (note.strumLineID == strumLineID) selection.remove(note); - else - i++; + else i++; } } } @@ -1391,105 +1206,92 @@ class Charter extends UIState var __crochet:Float; var __firstFrame:Bool = true; - - public override function update(elapsed:Float) - { + public override function update(elapsed:Float) { updateNoteLogic(elapsed); updateAutoSaving(elapsed); // TEST CODE ----------------------------- - if (isLiveCharting) - { - if (controls.LEFT) - { + if (isLiveCharting) { + if (controls.LEFT) { var leftrec = new CharterNote(); leftrec.updatePos(1.0, 0, 0, 0); add(leftrec); notesGroup.add(leftrec); } - else if (controls.DOWN) - { + else if (controls.DOWN) { var downrec = new CharterNote(); downrec.updatePos(1.0, 1, 0, 0); add(downrec); notesGroup.add(downrec); } - else if (controls.UP) - { + else if (controls.UP) { var uprec = new CharterNote(); uprec.updatePos(1.0, 2, 0, 0); add(uprec); notesGroup.add(uprec); } - else if (controls.RIGHT) - { + else if (controls.RIGHT) { var rightrec = new CharterNote(); rightrec.updatePos(1.0, 3, 0, 0); add(rightrec); notesGroup.add(rightrec); } - else if (controls.ACCEPT) - { + else if (controls.ACCEPT) { trace("hey dummy I'm pressing accept"); FlxG.sound.music.pause(); vocals.pause(); for (strumLine in strumLines.members) strumLine.vocals.pause(); - + isLiveCharting = false; recordingDisplay(false); } } - + // TEST CODE ----------------------------- - if (FlxG.sound.music.playing || __firstFrame) - { + if (FlxG.sound.music.playing || __firstFrame) { gridBackdrops.conductorSprY = curStepFloat * 40; + } else { + gridBackdrops.conductorSprY = lerp(gridBackdrops.conductorSprY, curStepFloat * 40, __firstFrame ? 1 : 1/3); } - else - { - gridBackdrops.conductorSprY = lerp(gridBackdrops.conductorSprY, curStepFloat * 40, __firstFrame ? 1 : 1 / 3); - } - charterCamera.scroll.set(((((40 * 4) * gridBackdrops.strumlinesAmount) - FlxG.width) / 2), gridBackdrops.conductorSprY - (FlxG.height * 0.5)); + charterCamera.scroll.set( + ((((40*4) * gridBackdrops.strumlinesAmount) - FlxG.width) / 2), + gridBackdrops.conductorSprY - (FlxG.height * 0.5) + ); - if (topMenuSpr.members[playbackIndex] != null) - { + if (topMenuSpr.members[playbackIndex] != null) { var playBackButton:UITopMenuButton = cast topMenuSpr.members[playbackIndex]; - playBackButton.x = playBackSlider.x - playBackSlider.startText.width - 10 - playBackSlider.valueStepper.bWidth - playBackButton.bWidth - 10; + playBackButton.x = playBackSlider.x-playBackSlider.startText.width-10-playBackSlider.valueStepper.bWidth-playBackButton.bWidth-10; playBackButton.label.offset.x = -1; - if (topMenuSpr.members[snapIndex] != null) - { + if (topMenuSpr.members[snapIndex] != null) { var snapButton:UITopMenuButton = cast topMenuSpr.members[snapIndex]; - var lastButtonX = playBackButton.x - 10; + var lastButtonX = playBackButton.x-10; var buttonI:Int = 0; - for (button in quantButtons) - { - button.visible = ((button.quant == quant) - || (button.quant == quants[FlxMath.wrap(quants.indexOf(quant) - 1, 0, quants.length - 1)]) - || (button.quant == quants[FlxMath.wrap(quants.indexOf(quant) + 1, 0, quants.length - 1)])); + for (button in quantButtons) { + button.visible = ((button.quant == quant) || + (button.quant == quants[FlxMath.wrap(quants.indexOf(quant)-1, 0, quants.length-1)]) || + (button.quant == quants[FlxMath.wrap(quants.indexOf(quant)+1, 0, quants.length-1)])); button.selectable = button.visible; - if (!button.visible) - continue; + if (!button.visible) continue; button.x = lastButtonX -= button.bWidth; button.framesOffset = button.quant == quant ? 9 : 0; button.alpha = button.quant == quant ? 1 : (button.hovered ? 0.4 : 0); } - snapButton.x = (lastButtonX -= snapButton.bWidth) - 10; + snapButton.x = (lastButtonX -= snapButton.bWidth)-10; } } - if (topMenuSpr.members[noteIndex] != null) - { + if (topMenuSpr.members[noteIndex] != null) { var noteTopButton:UITopMenuButton = cast topMenuSpr.members[noteIndex]; noteTypeText.x = noteTopButton.x + noteTopButton.bWidth + 6; noteTypeText.y = Std.int((noteTopButton.bHeight - noteTypeText.height) / 2); } - noteTypeText.text = '($noteType) ${noteTypes[noteType - 1] == null ? "Default Note" : noteTypes[noteType - 1]}'; + noteTypeText.text = '($noteType) ${noteTypes[noteType-1] == null ? "Default Note" : noteTypes[noteType-1]}'; super.update(elapsed); @@ -1500,25 +1302,19 @@ class Charter extends UIState updateDisplaySprites(); // TODO: canTypeText in case an ui input element is focused - if (true) - { + if (true) { __crochet = ((60 / Conductor.bpm) * 1000); - if (FlxG.keys.justPressed.ANY && !strumLines.isDragging && this.currentFocus == null) + if(FlxG.keys.justPressed.ANY && !strumLines.isDragging && this.currentFocus == null) UIUtil.processShortcuts(topMenu); - if (FlxG.keys.pressed.CONTROL) - { - if (FlxG.mouse.wheel != 0) - { + if (FlxG.keys.pressed.CONTROL) { + if (FlxG.mouse.wheel != 0) { zoom += 0.25 * FlxG.mouse.wheel; __camZoom = Math.pow(2, zoom); } - } - else - { - if (!FlxG.sound.music.playing) - { + } else { + if (!FlxG.sound.music.playing) { Conductor.songPosition -= (__crochet * FlxG.mouse.wheel) - Conductor.songOffset; } } @@ -1527,20 +1323,18 @@ class Charter extends UIState var songLength = FlxG.sound.music.getDefault(vocals).length; Conductor.songPosition = FlxMath.bound(Conductor.songPosition + Conductor.songOffset, 0, songLength); - if (Conductor.songPosition >= songLength - Conductor.songOffset) - { + if (Conductor.songPosition >= songLength - Conductor.songOffset) { FlxG.sound.music.pause(); vocals.pause(); - for (strumLine in strumLines.members) - strumLine.vocals.pause(); + for (strumLine in strumLines.members) strumLine.vocals.pause(); } songPosInfo.text = '${CoolUtil.timeToStr(Conductor.songPosition)} / ${CoolUtil.timeToStr(songLength)}' - + '\nStep: ${curStep}' - + '\nBeat: ${curBeat}' - + '\nMeasure: ${curMeasure}' - + '\nBPM: ${Conductor.bpm}' - + '\nTime Signature: ${Conductor.beatsPerMeasure}/${Conductor.stepsPerBeat}'; + + '\nStep: ${curStep}' + + '\nBeat: ${curBeat}' + + '\nMeasure: ${curMeasure}' + + '\nBPM: ${Conductor.bpm}' + + '\nTime Signature: ${Conductor.beatsPerMeasure}/${Conductor.stepsPerBeat}'; if (charterCamera.zoom != (charterCamera.zoom = lerp(charterCamera.zoom, __camZoom, __firstFrame ? 1 : 0.125))) updateDisplaySprites(); @@ -1557,8 +1351,7 @@ class Charter extends UIState public static var startTime:Float = 0; public static var startHere:Bool = false; - function updateDisplaySprites() - { + function updateDisplaySprites() { gridBackdrops.strumlinesAmount = strumLines.members.length; charterBG.scale.set(1 / charterCamera.zoom, 1 / charterCamera.zoom); @@ -1568,9 +1361,8 @@ class Charter extends UIState strumlineInfoBG.screenCenter(X); strumlineInfoBG.y = -(((FlxG.height - (2 * topMenuSpr.bHeight)) / charterCamera.zoom) - FlxG.height) / 2; - for (id => str in strumLines.members) - if (str != null) - str.y = strumlineInfoBG.y; + for(id=>str in strumLines.members) + if (str != null) str.y = strumlineInfoBG.y; strumlineAddButton.y = strumlineInfoBG.y; strumlineLockButton.y = strumlineInfoBG.y; @@ -1578,34 +1370,21 @@ class Charter extends UIState var zoom(default, set):Float = 0; var __camZoom(default, set):Float = 1; - - function set_zoom(val:Float) - { + function set_zoom(val:Float) { return zoom = FlxMath.bound(val, -3.5, 1.75); // makes zooming not lag behind when continuing scrolling } - - function set___camZoom(val:Float) - { + function set___camZoom(val:Float) { return __camZoom = FlxMath.bound(val, 0.1, 3); } // TOP MENU OPTIONS #if REGION - function _file_exit(_) - { - if (undos.unsaved) - SaveWarning.triggerWarning(); - else - { - undos = null; - FlxG.switchState(new CharterSelection()); - PlayState.resetSongInfos(); - Charter.instance.__clearStatics(); - } + function _file_exit(_) { + if (undos.unsaved) SaveWarning.triggerWarning(); + else {undos = null; FlxG.switchState(new CharterSelection()); PlayState.resetSongInfos(); Charter.instance.__clearStatics();} } - function _file_save(_) - { + function _file_save(_) { #if sys saveTo('${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}'); undos.save(); @@ -1614,16 +1393,14 @@ class Charter extends UIState _file_saveas(_); } - function _file_saveas(_) - { + function _file_saveas(_) { openSubState(new SaveSubstate(Json.stringify(Chart.filterChartForSaving(PlayState.SONG, false), null, Options.editorPrettyPrint ? "\t" : null), { defaultSaveFile: '${__diff.toLowerCase()}.json' })); undos.save(); } - function _file_save_no_events(_) - { + function _file_save_no_events(_) { #if sys saveTo('${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}', true); undos.save(); @@ -1632,34 +1409,31 @@ class Charter extends UIState _file_saveas(_); } - function _file_saveas_no_events(_) - { - openSubState(new SaveSubstate(Json.stringify(Chart.filterChartForSaving(PlayState.SONG, false, false), null, Options.editorPrettyPrint ? "\t" : null), - { - defaultSaveFile: '${__diff.toLowerCase()}.json' - })); + function _file_saveas_no_events(_) { + openSubState(new SaveSubstate(Json.stringify(Chart.filterChartForSaving(PlayState.SONG, false, false), null, Options.editorPrettyPrint ? "\t" : null), { + defaultSaveFile: '${__diff.toLowerCase()}.json' + })); undos.save(); } - function _file_meta_save(_) - { + function _file_meta_save(_) { #if sys - CoolUtil.safeSaveFile('${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/meta.json', - Json.stringify(PlayState.SONG.meta == null ? {} : PlayState.SONG.meta, null, "\t")); + CoolUtil.safeSaveFile( + '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/meta.json', + Json.stringify(PlayState.SONG.meta == null ? {} : PlayState.SONG.meta, null, "\t") + ); #else _file_meta_saveas(_); #end } - function _file_meta_saveas(_) - { + function _file_meta_saveas(_) { openSubState(new SaveSubstate(Json.stringify(PlayState.SONG.meta == null ? {} : PlayState.SONG.meta, null, "\t"), { // always pretty print meta defaultSaveFile: 'meta.json' })); } - function _file_saveas_fnflegacy(_) - { + function _file_saveas_fnflegacy(_) { openSubState(new SaveSubstate(Json.stringify(FNFLegacyParser.encode(PlayState.SONG), null, Options.editorPrettyPrint ? "\t" : null), { defaultSaveFile: '${__song.toLowerCase().replace(" ", "-")}${__diff.toLowerCase() == "normal" ? "" : '-${__diff.toLowerCase()}'}.json', })); @@ -1671,74 +1445,60 @@ class Charter extends UIState })); } - function _file_events_save(_) - { + function _file_events_save(_) { #if sys - CoolUtil.safeSaveFile('${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/events.json', - Json.stringify({events: PlayState.SONG.events == null ? [] : PlayState.SONG.events}, null, Options.editorPrettyPrint ? "\t" : null)); + CoolUtil.safeSaveFile( + '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/events.json', + Json.stringify({events: PlayState.SONG.events == null ? [] : PlayState.SONG.events}, null, Options.editorPrettyPrint ? "\t" : null) + ); #else _file_events_saveas(_); #end } - function _file_events_saveas(_) - { + function _file_events_saveas(_) { #if sys - openSubState(new SaveSubstate(Json.stringify({events: PlayState.SONG.events == null ? [] : PlayState.SONG.events}, null, - Options.editorPrettyPrint ? "\t" : null), { - defaultSaveFile: 'events.json' - })); + openSubState(new SaveSubstate(Json.stringify({events: PlayState.SONG.events == null ? [] : PlayState.SONG.events}, null, Options.editorPrettyPrint ? "\t" : null), { + defaultSaveFile: 'events.json' + })); #end } #if sys - function saveTo(path:String, separateEvents:Bool = false) - { + function saveTo(path:String, separateEvents:Bool = false) { buildChart(); - Chart.save(path, PlayState.SONG, __diff.toLowerCase(), - {saveMetaInChart: false, saveEventsInChart: !separateEvents, prettyPrint: Options.editorPrettyPrint}); + Chart.save(path, PlayState.SONG, __diff.toLowerCase(), {saveMetaInChart: false, saveEventsInChart: !separateEvents, prettyPrint: Options.editorPrettyPrint}); } #end - function _edit_copy(_) - { - if (selection.length == 0) - return; + function _edit_copy(_) { + if(selection.length == 0) return; var minStep:Float = selection[0].step; - for (s in selection) - if (s.step < minStep) - minStep = s.step; + for(s in selection) + if (s.step < minStep) minStep = s.step; clipboard = [ for (s in selection) - if (s is CharterNote) - { - var note:CharterNote = cast s; - CNote(note.step - minStep, note.id, note.strumLineID, note.susLength, note.type); - } - else if (s is CharterEvent) - { - var event = cast(s, CharterEvent); - CEvent(event.step - minStep, [for (event in event.events) Reflect.copy(event)]); - } + if (s is CharterNote) { + var note:CharterNote = cast s; + CNote(note.step - minStep, note.id, note.strumLineID, note.susLength, note.type); + } else if (s is CharterEvent) { + var event = cast(s,CharterEvent); + CEvent(event.step - minStep, [for (event in event.events) Reflect.copy(event)]); + } ]; } - - function _edit_paste(_) - { - if (clipboard.length <= 0) - return; + function _edit_paste(_) { + if (clipboard.length <= 0) return; var minStep = curStep; var sObjects:Array = []; - for (c in clipboard) - { - switch (c) - { + for(c in clipboard) { + switch(c) { case CNote(step, id, strumLineID, susLength, type): var note = new CharterNote(); - note.updatePos(minStep + step, id, susLength, type, strumLines.members[Std.int(FlxMath.bound(strumLineID, 0, strumLines.length - 1))]); + note.updatePos(minStep + step, id, susLength, type, strumLines.members[Std.int(FlxMath.bound(strumLineID, 0, strumLines.length-1))]); notesGroup.add(note); sObjects.push(note); case CEvent(step, events): @@ -1754,38 +1514,27 @@ class Charter extends UIState undos.addToUndo(CCreateSelection(sObjects.copy())); } - function _edit_cut(_) - { - if (selection == null || selection.length == 0) - return; + function _edit_cut(_) { + if (selection == null || selection.length == 0) return; _edit_copy(_); deleteSelection(selection, false); } - function _edit_delete(_) - { - if (!isLiveCharting) - { - if (selection == null || selection.length == 0) - return; - selection.loop((n:CharterNote) -> - { - noteDeleteAnims.deleteNotes.push({note: n, time: noteDeleteAnims.deleteTime}); - }); - selection = deleteSelection(selection, true); - } + function _edit_delete(_) { + if (selection == null || selection.length == 0) return; + selection.loop((n:CharterNote) -> { + noteDeleteAnims.deleteNotes.push({note: n, time: noteDeleteAnims.deleteTime}); + }); + selection = deleteSelection(selection, true); } - function _edit_undo(_) - { - if (strumLines.isDragging || selectionDragging || (subState != null && !(subState is UIContextMenu))) - return; + function _edit_undo(_) { + if (strumLines.isDragging || selectionDragging || (subState != null && !(subState is UIContextMenu))) return; selection = []; var undo = undos.undo(); - switch (undo) - { + switch(undo) { case null: // do nothing case CDeleteStrumLine(strumLineID, strumLine): createStrumline(strumLineID, strumLine, false); @@ -1804,12 +1553,11 @@ class Charter extends UIState createSelection(selection, false); case CSelectionDrag(selectionDrags): for (s in selectionDrags) - if (s.selectable.draggable) - s.selectable.handleDrag(s.change * -1); + if (s.selectable.draggable) s.selectable.handleDrag(s.change * -1); selection = [for (s in selectionDrags) s.selectable]; case CEditSustains(changes): - for (n in changes) + for(n in changes) n.note.updatePos(n.note.step, n.note.id, n.before, n.note.type); case CEditEvent(event, oldEvents, newEvents): event.events = oldEvents.copy(); @@ -1823,20 +1571,16 @@ class Charter extends UIState noteTypes = oldArray; changeNoteType(null, false); case CEditSpecNotesType(notes, oldTypes, newTypes): - for (i => note in notes) - note.updatePos(note.step, note.id, note.susLength, oldTypes[i]); + for(i=>note in notes) note.updatePos(note.step, note.id, note.susLength, oldTypes[i]); } } - function _edit_redo(_) - { - if (strumLines.isDragging || selectionDragging || (subState != null && !(subState is UIContextMenu))) - return; + function _edit_redo(_) { + if (strumLines.isDragging || selectionDragging || (subState != null && !(subState is UIContextMenu))) return; selection = []; var redo = undos.redo(); - switch (redo) - { + switch(redo) { case null: // do nothing case CDeleteStrumLine(strumLineID, strumLine): deleteStrumline(strumLineID, false); @@ -1855,11 +1599,10 @@ class Charter extends UIState deleteSelection(selection, false); case CSelectionDrag(selectionDrags): for (s in selectionDrags) - if (s.selectable.draggable) - s.selectable.handleDrag(s.change); - // this.selection = selection; + if (s.selectable.draggable) s.selectable.handleDrag(s.change); + //this.selection = selection; case CEditSustains(changes): - for (n in changes) + for(n in changes) n.note.updatePos(n.note.step, n.note.id, n.after, n.note.type); case CEditEvent(event, oldEvents, newEvents): event.events = newEvents.copy(); @@ -1873,156 +1616,120 @@ class Charter extends UIState noteTypes = newArray; changeNoteType(null, false); case CEditSpecNotesType(notes, oldTypes, newTypes): - for (i => note in notes) - note.updatePos(note.step, note.id, note.susLength, newTypes[i]); + for(i=>note in notes) note.updatePos(note.step, note.id, note.susLength, newTypes[i]); } } inline function _chart_playtest(_) if (!isLiveCharting) playtestChart(0, false); - inline function _chart_playtest_here(_) if (!isLiveCharting) playtestChart(Conductor.songPosition, false, true); - inline function _chart_playtest_opponent(_) if (!isLiveCharting) playtestChart(0, true); - inline function _chart_playtest_opponent_here(_) if (!isLiveCharting) playtestChart(Conductor.songPosition, true, true); - inline function _chart_live(_) - { - if (!isLiveCharting) - { + inline function _chart_live(_) { + if (!isLiveCharting) { trace("make this"); - + isLiveCharting = true; Conductor.songPosition = 0; // fuck you - + // make SL selection functionality // pause until a SL was selected // start countdown // only after all that can it... - + recordingDisplay(true); - + FlxG.sound.music.play(); vocals.play(); - + vocals.time = FlxG.sound.music.time = Conductor.songPosition + Conductor.songOffset * 2; - for (strumLine in strumLines.members) - { + for (strumLine in strumLines.members) { strumLine.vocals.play(); strumLine.vocals.time = vocals.time; } } } - - inline function _chart_live_here(_) - { - if (!isLiveCharting) - { + + inline function _chart_live_here(_) { + if (!isLiveCharting) { trace("and this too"); - + isLiveCharting = true; - + // make SL selection functionality // pause until a SL was selected // start countdown // only after all that can it... - + recordingDisplay(true); - + FlxG.sound.music.play(); vocals.play(); vocals.time = FlxG.sound.music.time = Conductor.songPosition + Conductor.songOffset * 2; - for (strumLine in strumLines.members) - { + for (strumLine in strumLines.members) { strumLine.vocals.play(); strumLine.vocals.time = vocals.time; } } } - function _chart_enablescripts(t) - { + function _chart_enablescripts(t) { t.icon = (Options.charterEnablePlaytestScripts = !Options.charterEnablePlaytestScripts) ? 1 : 0; } function chart_edit_data(_) FlxG.state.openSubState(new ChartDataScreen(PlayState.SONG)); - function chart_edit_metadata(_) FlxG.state.openSubState(new CharterMetaDataScreen(PlayState.SONG.meta)); - function _playback_play(_) - { - if (Conductor.songPosition >= FlxG.sound.music.getDefault(vocals).length - Conductor.songOffset) - return; + function _playback_play(_) { + if (Conductor.songPosition >= FlxG.sound.music.getDefault(vocals).length - Conductor.songOffset) return; - if (FlxG.sound.music.playing) - { + if (FlxG.sound.music.playing) { FlxG.sound.music.pause(); vocals.pause(); - for (strumLine in strumLines.members) - strumLine.vocals.pause(); - } - else - { + for (strumLine in strumLines.members) strumLine.vocals.pause(); + } else { FlxG.sound.music.play(); vocals.play(); vocals.time = FlxG.sound.music.time = Conductor.songPosition + Conductor.songOffset * 2; - for (strumLine in strumLines.members) - { + for (strumLine in strumLines.members) { strumLine.vocals.play(); strumLine.vocals.time = vocals.time; } } } - function _playback_speed_raise(_) - playBackSlider.value += .25; - - function _playback_speed_reset(_) - playBackSlider.value = 1; + function _playback_speed_raise(_) playBackSlider.value += .25; + function _playback_speed_reset(_) playBackSlider.value = 1; + function _playback_speed_lower(_) playBackSlider.value -= .25; - function _playback_speed_lower(_) - playBackSlider.value -= .25; - - function _playback_metronome(t) - { + function _playback_metronome(t) { t.icon = (Options.charterMetronomeEnabled = !Options.charterMetronomeEnabled) ? 1 : 0; } - - function _song_muteinst(t) - { + function _song_muteinst(t) { FlxG.sound.music.volume = FlxG.sound.music.volume > 0 ? 0 : 1; t.icon = 1 - Std.int(Math.ceil(FlxG.sound.music.volume)); } - - function _song_mutevoices(t) - { + function _song_mutevoices(t) { vocals.volume = vocals.volume > 0 ? 0 : 1; - for (strumLine in strumLines.members) - strumLine.vocals.volume = strumLine.vocals.volume > 0 ? 0 : 1; + for (strumLine in strumLines.members) strumLine.vocals.volume = strumLine.vocals.volume > 0 ? 0 : 1; t.icon = 1 - Std.int(Math.ceil(vocals.volume)); } - - function _playback_back(_) - { - if (FlxG.sound.music.playing) - return; + function _playback_back(_) { + if (FlxG.sound.music.playing) return; Conductor.songPosition -= (Conductor.beatsPerMeasure * __crochet); } - - function _playback_forward(_) - { - if (FlxG.sound.music.playing) - return; + function _playback_forward(_) { + if (FlxG.sound.music.playing) return; Conductor.songPosition += (Conductor.beatsPerMeasure * __crochet); } function _playback_section_start(_) { @@ -2041,83 +1748,53 @@ class Charter extends UIState if (FlxG.sound.music.playing) return; Conductor.songPosition = 0; } - - function _song_end(_) - { - if (FlxG.sound.music.playing) - return; + function _song_end(_) { + if (FlxG.sound.music.playing) return; Conductor.songPosition = FlxG.sound.music.length; } - - function _view_zoomin(_) - { + function _view_zoomin(_) { zoom += 0.25; __camZoom = Math.pow(2, zoom); } - - function _view_zoomout(_) - { + function _view_zoomout(_) { zoom -= 0.25; __camZoom = Math.pow(2, zoom); } - - function _view_zoomreset(_) - { + function _view_zoomreset(_) { zoom = 0; __camZoom = Math.pow(2, zoom); } - - function _view_showeventSecSeparator(t) - { + function _view_showeventSecSeparator(t) { t.icon = (Options.charterShowSections = !Options.charterShowSections) ? 1 : 0; eventsBackdrop.eventSecSeparator.visible = gridBackdrops.sectionsVisible = Options.charterShowSections; } - - function _view_showeventBeatSeparator(t) - { + function _view_showeventBeatSeparator(t) { t.icon = (Options.charterShowBeats = !Options.charterShowBeats) ? 1 : 0; eventsBackdrop.eventBeatSeparator.visible = gridBackdrops.beatsVisible = Options.charterShowBeats; } - - function _view_switchWaveformDetail(t) - { + function _view_switchWaveformDetail(t) { t.icon = (Options.charterLowDetailWaveforms = !Options.charterLowDetailWaveforms) ? 1 : 0; - for (shader in waveformHandler.waveShaders) - shader.data.lowDetail.value = [Options.charterLowDetailWaveforms]; + for (shader in waveformHandler.waveShaders) shader.data.lowDetail.value = [Options.charterLowDetailWaveforms]; } + + inline function _snap_increasesnap(_) if (!isLiveCharting) changequant(1); + inline function _snap_decreasesnap(_) if (!isLiveCharting) changequant(-1); + inline function _snap_resetsnap(_) if (!isLiveCharting) setquant(16); - inline function _snap_increasesnap(_) - if (!isLiveCharting) - changequant(1); - - inline function _snap_decreasesnap(_) - if (!isLiveCharting) - changequant(-1); - - inline function _snap_resetsnap(_) - if (!isLiveCharting) - setquant(16); - - inline function changequant(change:Int) - { - if (!isLiveCharting) - { - quant = quants[FlxMath.wrap(quants.indexOf(quant) + change, 0, quants.length - 1)]; + inline function changequant(change:Int) { + if (!isLiveCharting) { + quant = quants[FlxMath.wrap(quants.indexOf(quant) + change, 0, quants.length-1)]; buildSnapsUI(); } - }; - - inline function setquant(newquant:Int) - { - if (!isLiveCharting) - { + } + inline function setquant(newquant:Int) { + if (!isLiveCharting) { quant = newquant; buildSnapsUI(); } } - function buildSnapsUI():Array - { + function buildSnapsUI():Array { var snapsTopButton:UITopMenuButton = topMenuSpr == null ? null : cast topMenuSpr.members[snapIndex]; var newChilds:Array = [ { @@ -2140,16 +1817,11 @@ class Charter extends UIState for (_quant in quants) newChilds.push({ label: '${_quant}x Grid Snap', - onSelect: (_) -> - { - setquant(_quant); - buildSnapsUI(); - }, + onSelect: (_) -> {setquant(_quant); buildSnapsUI();}, icon: _quant == quant ? 1 : 0 }); - if (snapsTopButton != null) - snapsTopButton.contextMenu = newChilds; + if (snapsTopButton != null) snapsTopButton.contextMenu = newChilds; return newChilds; } @@ -2161,30 +1833,23 @@ class Charter extends UIState if (!isLiveCharting) changeNoteSustain(-1); - function _note_selectall(_) - { + function _note_selectall(_) { selection = cast notesGroup.members.copy(); } - function _note_selectmeasure(_) - { - selection = [ - for (note in notesGroup.members) - if (note.step > Conductor.curMeasure * Conductor.getMeasureLength() - && note.step < (Conductor.curMeasure + 1) * Conductor.getMeasureLength()) note + function _note_selectmeasure(_) { + selection = [for (note in notesGroup.members) + if (note.step > Conductor.curMeasure*Conductor.getMeasureLength() && note.step < (Conductor.curMeasure+1)*Conductor.getMeasureLength()) note ]; } #end - function changeNoteSustain(change:Float) - { - if (selection.length <= 0 || change == 0 || gridActionType != NONE) - return; + function changeNoteSustain(change:Float) { + if (selection.length <= 0 || change == 0 || gridActionType != NONE) return; var undoChanges:Array = []; - for (s in selection) - if (s is CharterNote) - { + for(s in selection) + if (s is CharterNote) { var n:CharterNote = cast s; var old:Float = n.susLength; n.updatePos(n.step, n.id, Math.max(n.susLength + change, 0), n.type); @@ -2194,42 +1859,30 @@ class Charter extends UIState undos.addToUndo(CEditSustains(undoChanges)); } - inline public function changeNoteType(?newID:Int, checkSelection:Bool = true) - { - if (newID != null) - noteType = newID; + inline public function changeNoteType(?newID:Int, checkSelection:Bool = true) { + if(newID != null) noteType = newID; noteType = Std.int(FlxMath.bound(noteType, 0, noteTypes.length)); buildNoteTypesUI(); - var changedNotes:{notes:Array, oldTypes:Array, newTypes:Array} = {notes: [], oldTypes: [], newTypes: []}; - for (note in notesGroup) - if (note.type < 0 || note.type > noteTypes.length) - { - changedNotes.notes.push(note); - changedNotes.oldTypes.push(note.type); - changedNotes.newTypes.push(0); - note.updatePos(note.step, note.id, note.susLength, 0); - } + var changedNotes:{notes:Array, oldTypes:Array, newTypes:Array} = {notes:[], oldTypes:[], newTypes:[]}; + for(note in notesGroup) if(note.type < 0 || note.type > noteTypes.length) { + changedNotes.notes.push(note); changedNotes.oldTypes.push(note.type); changedNotes.newTypes.push(0); + note.updatePos(note.step, note.id, note.susLength, 0); + } - if (checkSelection) - for (s in selection) - if (s is CharterNote) - { - var n:CharterNote = cast s; - changedNotes.notes.push(n); - changedNotes.oldTypes.push(n.type); - changedNotes.newTypes.push(newID); - n.updatePos(n.step, n.id, n.susLength, newID); - } - if (changedNotes.notes.length > 0) - undos.addToUndo(CEditSpecNotesType(changedNotes.notes, changedNotes.oldTypes, changedNotes.newTypes)); + if(checkSelection) for(s in selection) + if (s is CharterNote) { + var n:CharterNote = cast s; + changedNotes.notes.push(n); changedNotes.oldTypes.push(n.type); changedNotes.newTypes.push(newID); + n.updatePos(n.step, n.id, n.susLength, newID); + } + if(changedNotes.notes.length > 0) undos.addToUndo(CEditSpecNotesType(changedNotes.notes, changedNotes.oldTypes, changedNotes.newTypes)); } function editNoteTypesList(_) FlxG.state.openSubState(new CharterNoteTypesList()); - function buildNoteTypesUI():Array - { + function buildNoteTypesUI():Array { var noteTopButton:UITopMenuButton = topMenuSpr == null ? null : cast topMenuSpr.members[noteIndex]; var newChilds:Array = [ { @@ -2257,47 +1910,33 @@ class Charter extends UIState { label: "(0) Default Note", keybind: [ZERO], - onSelect: (_) -> - { - changeNoteType(0); - }, + onSelect: (_) -> {changeNoteType(0);}, icon: this.noteType == 0 ? 1 : 0 } ]; var noteKeys:Array = [ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE]; - for (i => type in noteTypes) - { - var realNoteID:Int = i + 1; // Default Note not stored + for (i=>type in noteTypes) { + var realNoteID:Int = i+1; // Default Note not stored var newChild:UIContextMenuOption = { label: '(${realNoteID}) ${type}', - onSelect: (_) -> - { - changeNoteType(realNoteID); - }, + onSelect: (_) -> {changeNoteType(realNoteID);}, icon: this.noteType == realNoteID ? 1 : 0 }; - if (realNoteID <= 9) - newChild.keybind = [noteKeys[realNoteID]]; + if (realNoteID <= 9) newChild.keybind = [noteKeys[realNoteID]]; newChilds.push(newChild); } newChilds.push({ label: "Edit Note Types List", - color: 0xFF959829, - icon: 4, - onCreate: function(button:UIContextMenuOptionSpr) - { - button.label.offset.x = button.icon.offset.x = -2; - }, + color: 0xFF959829, icon: 4, + onCreate: function (button:UIContextMenuOptionSpr) {button.label.offset.x = button.icon.offset.x = -2;}, onSelect: editNoteTypesList }); - if (noteTopButton != null) - noteTopButton.contextMenu = newChilds; + if (noteTopButton != null) noteTopButton.contextMenu = newChilds; return newChilds; } - public function playtestChart(time:Float = 0, opponentMode = false, here = false) - { + public function playtestChart(time:Float = 0, opponentMode = false, here = false) { buildChart(); startHere = here; startTime = Conductor.songPosition; @@ -2306,8 +1945,7 @@ class Charter extends UIState FlxG.switchState(new PlayState()); } - public inline function buildNote(note:CharterNote):ChartNote - { + public inline function buildNote(note:CharterNote):ChartNote { var time = Conductor.getTimeForStep(note.step); return { type: note.type, @@ -2317,77 +1955,53 @@ class Charter extends UIState }; } - public function buildChart() - { + public function buildChart() { PlayState.SONG.strumLines = []; PlayState.SONG.noteTypes = this.noteTypes; - for (s in strumLines) - { + for(s in strumLines) { s.strumLine.notes = []; PlayState.SONG.strumLines.push(s.strumLine); } notesGroup.sortNotes(); - for (n in notesGroup.members) - { + for(n in notesGroup.members) { if (PlayState.SONG.strumLines[n.strumLineID] != null) PlayState.SONG.strumLines[n.strumLineID].notes.push(buildNote(n)); } buildEvents(); } - public function buildEvents() - { + public function buildEvents() { PlayState.SONG.events = []; eventsGroup.sortEvents(); - for (e in eventsGroup.members) - { - for (event in e.events) - { + for(e in eventsGroup.members) { + for(event in e.events) { event.time = Conductor.getTimeForStep(e.step); PlayState.SONG.events.push(event); } } } - public function updateBPMEvents() - { + public function updateBPMEvents() { buildEvents(); Conductor.mapBPMChanges(PlayState.SONG); - Conductor.changeBPM(PlayState.SONG.meta.bpm, cast PlayState.SONG.meta.beatsPerMeasure.getDefault(4), - cast PlayState.SONG.meta.stepsPerBeat.getDefault(4)); + Conductor.changeBPM(PlayState.SONG.meta.bpm, cast PlayState.SONG.meta.beatsPerMeasure.getDefault(4), cast PlayState.SONG.meta.stepsPerBeat.getDefault(4)); refreshBPMSensitive(); } public inline function hitsoundsEnabled(id:Int) - { - if (!isLiveCharting) - { - return strumLines.members[id] != null && strumLines.members[id].hitsounds; - } - else - { - return false; - } - } + return isChartingLive ? false : (strumLines.members[id] != null && strumLines.members[id].hitsounds); - public inline function __fixSelection(selection:Selection):Selection - { + public inline function __fixSelection(selection:Selection):Selection { var newSelection:Selection = new Selection(); - for (s in selection) - if (newSelection.indexOf(s) == -1) - newSelection.push(s); - return newSelection.filter((s:ICharterSelectable) -> - { - return s != null; - }); + for (s in selection) if (newSelection.indexOf(s) == -1) newSelection.push(s); + return newSelection.filter((s:ICharterSelectable) -> {return s != null;}); } // UH OH!!! DANGER ZONE APPOARCHING !!!! LUNARS SHITTY CODE !!!! -lunar - @:noCompletion public function __relinkSingleSelection(selectable:ICharterSelectable):ICharterSelectable - { + @:noCompletion public function __relinkSingleSelection(selectable:ICharterSelectable):ICharterSelectable { if (selectable is CharterNote) return selectable.ID == -1 ? cast(selectable, CharterNote) : notesGroup.members[selectable.ID]; else if (selectable is CharterEvent) @@ -2402,21 +2016,17 @@ class Charter extends UIState return newSelection; } - @:noCompletion public inline function __relinkUndos() - { + @:noCompletion public inline function __relinkUndos() { selection = __relinkSelection(selection); - for (list => changeList in [undos.undoList, undos.redoList]) - { + for (list => changeList in [undos.undoList, undos.redoList]) { var newChanges:Array = []; - for (i => change in changeList) - { - switch (change) - { + for (i => change in changeList) { + switch (change) { case CCreateSelection(selection): newChanges[i] = CCreateSelection(__relinkSelection(selection)); case CDeleteSelection(selection): - newChanges[i] = CDeleteSelection(__relinkSelection(selection)); + newChanges[i] = CDeleteSelection(__relinkSelection(selection)); case CSelectionDrag(selectionDrags): newChanges[i] = CSelectionDrag([ for (selectionDrag in selectionDrags) @@ -2441,41 +2051,29 @@ class Charter extends UIState for (noteChanged in notesChanged) cast(__relinkSingleSelection(noteChanged), CharterNote) ], oldNoteTypes, newNoteTypes); - default: - newChanges[i] = change; + default: newChanges[i] = change; } } - if (list == 0) - undos.undoList = newChanges; - else - undos.redoList = newChanges; + if (list == 0) undos.undoList = newChanges; + else undos.redoList = newChanges; } } - @:noCompletion public function __resetStatics() - { + @:noCompletion public function __resetStatics() { selection = new Selection(); undos = new UndoList(); - clipboard = []; - playtestInfo = null; + clipboard = []; playtestInfo = null; waveformHandler = new CharterWaveformHandler(); autoSaveTimer = Options.charterAutoSaveTime; } - @:noCompletion public function __clearStatics() - { - selection = null; - undos = null; - clipboard = null; - playtestInfo = null; - waveformHandler.destroy(); - Charter.waveformHandler = null; - autoSaveTimer = 0; + @:noCompletion public function __clearStatics() { + selection = null; undos = null; clipboard = null; playtestInfo = null; + waveformHandler.destroy(); Charter.waveformHandler = null; autoSaveTimer = 0; } - @:noCompletion public function __updatePlaytestInfo() - { + @:noCompletion public function __updatePlaytestInfo() { playtestInfo = { songPosition: Conductor.songPosition, playbackSpeed: playBackSlider.value, @@ -2488,10 +2086,8 @@ class Charter extends UIState } } - @:noCompletion public function __applyPlaytestInfo() - { - if (playtestInfo == null) - return; + @:noCompletion public function __applyPlaytestInfo() { + if (playtestInfo == null) return; Conductor.songPosition = playtestInfo.songPosition; playBackSlider.value = playtestInfo.playbackSpeed; @@ -2508,8 +2104,7 @@ class Charter extends UIState } } -enum CharterChange -{ +enum CharterChange { CCreateStrumLine(strumLineID:Int, strumLine:ChartStrumLine); CEditStrumLine(strumLineID:Int, oldStrumLine:ChartStrumLine, newStrumLine:ChartStrumLine); COrderStrumLine(strumLineID:Int, oldID:Int, newID:Int); @@ -2524,45 +2119,38 @@ enum CharterChange CEditSpecNotesType(notes:Array, oldNoteTypes:Array, newNoteTypes:Array); } -enum CharterCopyboardObject -{ +enum CharterCopyboardObject { CNote(step:Float, id:Int, strumLineID:Int, susLength:Float, type:Int); CEvent(step:Float, events:Array); } -typedef NoteSustainChange = -{ +typedef NoteSustainChange = { var note:CharterNote; var before:Float; var after:Float; } -typedef SelectionDragChange = -{ +typedef SelectionDragChange = { var selectable:ICharterSelectable; var change:FlxPoint; } -@:forward abstract Selection(Array) from Array to Array -{ +@:forward abstract Selection(Array) from Array to Array { public inline function new(?array:Array) this = array == null ? [] : array; // too lazy to put this in every for loop so i made it a abstract - public inline function loop(onNote:CharterNote->Void, ?onEvent:CharterEvent->Void, ?draggableOnly:Bool = true) - { - for (s in this) - { - if (s is CharterNote && onNote != null && (draggableOnly ? s.draggable : true)) + public inline function loop(onNote:CharterNote->Void, ?onEvent:CharterEvent->Void, ?draggableOnly:Bool = true) { + for (s in this) { + if (s is CharterNote && onNote != null && (draggableOnly ? s.draggable: true)) onNote(cast(s, CharterNote)); - else if (s is CharterEvent && onEvent != null && (draggableOnly ? s.draggable : true)) + else if (s is CharterEvent && onEvent != null && (draggableOnly ? s.draggable: true)) onEvent(cast(s, CharterEvent)); } } } -interface ICharterSelectable -{ +interface ICharterSelectable { public var x(default, set):Float; public var y(default, set):Float; public var ID:Int; @@ -2576,8 +2164,7 @@ interface ICharterSelectable public function handleDrag(change:FlxPoint):Void; } -enum abstract CharterGridActionType(Int) -{ +enum abstract CharterGridActionType(Int) { var NONE = 0; var BOX_SELECTION = 1; var NOTE_DRAG = 2; @@ -2586,8 +2173,7 @@ enum abstract CharterGridActionType(Int) var DELETE_SELECTION = 5; } -typedef PlaytestInfo = -{ +typedef PlaytestInfo = { var songPosition:Float; var playbackSpeed:Float; var quantSelected:Int; From 6b399f358b3bd3fea9c3f1b27879cccc8755edfa Mon Sep 17 00:00:00 2001 From: Microkat <89645987+KadePleaseHelpMe@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:19:14 -0500 Subject: [PATCH 20/20] Typo --- source/funkin/editors/charter/Charter.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 50f0eb04a..76c2007b3 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -1991,7 +1991,7 @@ class Charter extends UIState { } public inline function hitsoundsEnabled(id:Int) - return isChartingLive ? false : (strumLines.members[id] != null && strumLines.members[id].hitsounds); + return isLiveCharting ? false : (strumLines.members[id] != null && strumLines.members[id].hitsounds); public inline function __fixSelection(selection:Selection):Selection { var newSelection:Selection = new Selection();