1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-02 19:53:15 +00:00

Merge branch 'rewrite/master' into rewrite/feature/chart-editor-erect-template

This commit is contained in:
EliteMasterEric 2023-10-15 18:42:38 -04:00
commit 022b93bc43
9 changed files with 229 additions and 67 deletions

View file

@ -156,7 +156,6 @@
<haxedef name="HXCPP_CHECK_POINTER" />
<haxedef name="HXCPP_STACK_LINE" />
<haxedef name="HXCPP_STACK_TRACE" />
<haxedef name="openfl-enable-handle-error" />
<!-- This macro allows addition of new functionality to existing Flixel. -->
<haxeflag name="--macro" value="addMetadata('@:build(funkin.util.macro.FlxMacro.buildFlxBasic())', 'flixel.FlxBasic')" />
<!--Place custom nodes like icons here (higher priority to override the HaxeFlixel icon)-->
@ -196,6 +195,22 @@
<haxedef name="REDIRECT_ASSETS_FOLDER" />
</section>
<section>
<!--
This flag enables the popup/crashlog error handler.
However, it also messes with breakpoints on some platforms.
-->
<haxedef name="openfl-enable-handle-error" />
</section>
<section>
<!-- TODO: Add a flag to Github Actions to turn this on or something. -->
<!-- Forces the version string to include the Git hash even on release builds (which are used for performance reasons). -->
<haxedef name="FORCE_DEBUG_VERSION" />
</section>
<!-- Run a script before and after building. -->
<postbuild haxe="source/Prebuild.hx"/> -->
<postbuild haxe="source/Postbuild.hx"/> -->

2
assets

@ -1 +1 @@
Subproject commit e6f43593b88123e687b505280bd112bade7552ae
Subproject commit f2e37de1ff308eeaf65babad2a4089096c40cedb

View file

@ -570,7 +570,7 @@ class FreeplayState extends MusicBeatSubState
var randomCapsule:SongMenuItem = grpCapsules.recycle(SongMenuItem);
randomCapsule.init(FlxG.width, 0, "Random");
randomCapsule.onConfirm = function() {
trace("RANDOM SELECTED");
capsuleOnConfirmRandom(randomCapsule);
};
randomCapsule.y = randomCapsule.intendedY(0) + 10;
randomCapsule.targetPos.x = randomCapsule.x;
@ -643,6 +643,8 @@ class FreeplayState extends MusicBeatSubState
var spamTimer:Float = 0;
var spamming:Bool = false;
var busy:Bool = false; // Set to true once the user has pressed enter to select a song.
override function update(elapsed:Float)
{
super.update(elapsed);
@ -690,11 +692,13 @@ class FreeplayState extends MusicBeatSubState
fp.updateScore(Std.int(lerpScore));
txtCompletion.text = Math.floor(lerpCompletion * 100) + "%";
// trace(Highscore.getCompletion(songs[curSelected].songName, curDifficulty));
// trace(intendedScore);
// trace(lerpScore);
// Highscore.getAllScores();
handleInputs(elapsed);
}
function handleInputs(elapsed:Float):Void
{
if (busy) return;
var upP = controls.UI_UP_P;
var downP = controls.UI_DOWN_P;
@ -949,6 +953,13 @@ class FreeplayState extends MusicBeatSubState
}
}
function capsuleOnConfirmRandom(cap:SongMenuItem):Void
{
trace("RANDOM SELECTED");
busy = true;
}
function capsuleOnConfirmDefault(cap:SongMenuItem):Void
{
// var poop:String = songs[curSelected].songName.toLowerCase();
@ -963,6 +974,8 @@ class FreeplayState extends MusicBeatSubState
curDifficulty = 1;
}*/
busy = true;
PlayStatePlaylist.isStoryMode = false;
var songId:String = cap.songTitle.toLowerCase();

View file

@ -150,6 +150,11 @@ class PauseSubState extends MusicBeatSubState
super.update(elapsed);
handleInputs();
}
function handleInputs():Void
{
var upP = controls.UI_UP_P;
var downP = controls.UI_DOWN_P;
var accepted = controls.ACCEPT;
@ -229,9 +234,14 @@ class PauseSubState extends MusicBeatSubState
FlxTransitionableState.skipNextTransIn = true;
FlxTransitionableState.skipNextTransOut = true;
if (PlayStatePlaylist.isStoryMode) openSubState(new funkin.ui.StickerSubState(null, STORY));
if (PlayStatePlaylist.isStoryMode)
{
openSubState(new funkin.ui.StickerSubState(null, STORY));
}
else
{
openSubState(new funkin.ui.StickerSubState(null, FREEPLAY));
}
case 'Exit to Chart Editor':
this.close();

View file

@ -17,6 +17,9 @@ import openfl.geom.Matrix;
import openfl.display.Sprite;
import openfl.display.Bitmap;
using Lambda;
using StringTools;
class StickerSubState extends MusicBeatSubState
{
public var grpStickers:FlxTypedGroup<StickerSprite>;
@ -26,10 +29,60 @@ class StickerSubState extends MusicBeatSubState
var nextState:NEXTSTATE = FREEPLAY;
// what "folders" to potentially load from (as of writing only "keys" exist)
var soundSelections:Array<String> = [];
// what "folder" was randomly selected
var soundSelection:String = "";
var sounds:Array<String> = [];
public function new(?oldStickers:Array<StickerSprite>, ?nextState:NEXTSTATE = FREEPLAY):Void
{
super();
// todo still
// make sure that ONLY plays mp3/ogg files
// if there's no mp3/ogg file, then it regenerates/reloads the random folder
var assetsInList = openfl.utils.Assets.list();
var soundFilterFunc = function(a:String) {
return a.startsWith('assets/shared/sounds/stickersounds/');
};
soundSelections = assetsInList.filter(soundFilterFunc);
soundSelections = soundSelections.map(function(a:String) {
return a.replace('assets/shared/sounds/stickersounds/', '').split('/')[0];
});
// cracked cleanup... yuchh...
for (i in soundSelections)
{
while (soundSelections.contains(i))
{
soundSelections.remove(i);
}
soundSelections.push(i);
}
trace(soundSelections);
soundSelection = FlxG.random.getObject(soundSelections);
var filterFunc = function(a:String) {
return a.startsWith('assets/shared/sounds/stickersounds/' + soundSelection + '/');
};
var assetsInList3 = openfl.utils.Assets.list();
sounds = assetsInList3.filter(filterFunc);
for (i in 0...sounds.length)
{
sounds[i] = sounds[i].replace('assets/shared/sounds/', '');
sounds[i] = sounds[i].substring(0, sounds[i].lastIndexOf('.'));
}
trace(sounds);
// trace(assetsInList);
this.nextState = nextState;
grpStickers = new FlxTypedGroup<StickerSprite>();
@ -66,6 +119,8 @@ class StickerSubState extends MusicBeatSubState
{
new FlxTimer().start(sticker.timing, _ -> {
sticker.visible = false;
var daSound:String = FlxG.random.getObject(sounds);
FlxG.sound.play(Paths.sound(daSound));
if (ind == grpStickers.members.length - 1)
{
@ -151,7 +206,11 @@ class StickerSubState extends MusicBeatSubState
sticker.timing = FlxMath.remapToRange(ind, 0, grpStickers.members.length, 0, 0.9);
new FlxTimer().start(sticker.timing, _ -> {
if (grpStickers == null) return;
sticker.visible = true;
var daSound:String = FlxG.random.getObject(sounds);
FlxG.sound.play(Paths.sound(daSound));
var frameTimer:Int = FlxG.random.int(0, 2);
@ -212,10 +271,10 @@ class StickerSubState extends MusicBeatSubState
{
super.update(elapsed);
if (FlxG.keys.justPressed.ANY)
{
regenStickers();
}
// if (FlxG.keys.justPressed.ANY)
// {
// regenStickers();
// }
}
var switchingState:Bool = false;

View file

@ -137,10 +137,10 @@ class ChartEditorImportExportHandler
/**
* @param force Whether to force the export without prompting the user for a file location.
* @param tmp If true, save to the temporary directory instead of the local `backup` directory.
*/
public static function exportAllSongData(state:ChartEditorState, force:Bool = false, tmp:Bool = false):Void
public static function exportAllSongData(state:ChartEditorState, force:Bool = false):Void
{
var tmp = false;
var zipEntries:Array<haxe.zip.Entry> = [];
for (variation in state.availableVariations)
@ -154,9 +154,9 @@ class ChartEditorImportExportHandler
if (variationId == '')
{
var variationMetadata:Null<SongMetadata> = state.songMetadata.get(variation);
if (variationMetadata != null) zipEntries.push(FileUtil.makeZIPEntry('${state.currentSongId}-metadata.json', SerializerUtil.toJSON(variationMetadata)));
if (variationMetadata != null) zipEntries.push(FileUtil.makeZIPEntry('${state.currentSongId}-metadata.json', variationMetadata.serialize()));
var variationChart:Null<SongChartData> = state.songChartData.get(variation);
if (variationChart != null) zipEntries.push(FileUtil.makeZIPEntry('${state.currentSongId}-chart.json', SerializerUtil.toJSON(variationChart)));
if (variationChart != null) zipEntries.push(FileUtil.makeZIPEntry('${state.currentSongId}-chart.json', variationChart.serialize()));
}
else
{

View file

@ -727,6 +727,16 @@ class ChartEditorState extends HaxeUIState
*/
var downKeyHandler:TurboKeyHandler = TurboKeyHandler.build(FlxKey.DOWN);
/**
* Variable used to track how long the user has been holding the W keybind.
*/
var wKeyHandler:TurboKeyHandler = TurboKeyHandler.build(FlxKey.W);
/**
* Variable used to track how long the user has been holding the S keybind.
*/
var sKeyHandler:TurboKeyHandler = TurboKeyHandler.build(FlxKey.S);
/**
* Variable used to track how long the user has been holding the page-up keybind.
*/
@ -1624,6 +1634,7 @@ class ChartEditorState extends HaxeUIState
addUIClickListener('menubarItemSaveChartAs', _ -> ChartEditorImportExportHandler.exportAllSongData(this));
addUIClickListener('menubarItemLoadInst', _ -> ChartEditorDialogHandler.openUploadInstDialog(this, true));
addUIClickListener('menubarItemImportChart', _ -> ChartEditorDialogHandler.openImportChartDialog(this, 'legacy', true));
addUIClickListener('menubarItemExit', _ -> quitChartEditor());
addUIClickListener('menubarItemUndo', _ -> undoLastCommand());
@ -1678,16 +1689,20 @@ class ChartEditorState extends HaxeUIState
addUIClickListener('menubarItemSelectNone', _ -> performCommand(new DeselectAllItemsCommand(currentNoteSelection, currentEventSelection)));
// TODO: Implement these.
// addUIClickListener('menubarItemSelectRegion', _ -> doSomething());
// addUIClickListener('menubarItemSelectBeforeCursor', _ -> doSomething());
// addUIClickListener('menubarItemSelectAfterCursor', _ -> doSomething());
addUIClickListener('menubarItemPlaytestFull', _ -> testSongInPlayState(false));
addUIClickListener('menubarItemPlaytestMinimal', _ -> testSongInPlayState(true));
addUIChangeListener('menubarItemInputStyleGroup', function(event:UIEvent) {
trace('Change input style: ${event.target}');
addUIClickListener('menuBarItemNoteSnapDecrease', _ -> noteSnapQuantIndex--);
addUIClickListener('menuBarItemNoteSnapIncrease', _ -> noteSnapQuantIndex++);
addUIChangeListener('menuBarItemInputStyleNone', function(event:UIEvent) {
currentLiveInputStyle = None;
});
addUIChangeListener('menuBarItemInputStyleNumberKeys', function(event:UIEvent) {
currentLiveInputStyle = NumberKeys;
});
addUIChangeListener('menuBarItemInputStyleWASD', function(event:UIEvent) {
currentLiveInputStyle = WASD;
});
addUIClickListener('menubarItemAbout', _ -> ChartEditorDialogHandler.openAboutDialog(this));
@ -1790,6 +1805,8 @@ class ChartEditorState extends HaxeUIState
add(redoKeyHandler);
add(upKeyHandler);
add(downKeyHandler);
add(wKeyHandler);
add(sKeyHandler);
add(pageUpKeyHandler);
add(pageDownKeyHandler);
}
@ -1816,7 +1833,7 @@ class ChartEditorState extends HaxeUIState
// Auto-save to local storage.
#else
// Auto-save to temp file.
ChartEditorImportExportHandler.exportAllSongData(this, true, true);
ChartEditorImportExportHandler.exportAllSongData(this, true);
#end
}
@ -1838,6 +1855,13 @@ class ChartEditorState extends HaxeUIState
public override function update(elapsed:Float):Void
{
// Override F4 behavior to include the autosave.
if (FlxG.keys.justPressed.F4)
{
quitChartEditor();
return;
}
// dispatchEvent gets called here.
super.update(elapsed);
@ -1917,20 +1941,33 @@ class ChartEditorState extends HaxeUIState
// Mouse Wheel = Scroll
if (FlxG.mouse.wheel != 0 && !FlxG.keys.pressed.CONTROL)
{
scrollAmount = -10 * FlxG.mouse.wheel;
scrollAmount = -50 * FlxG.mouse.wheel;
shouldPause = true;
}
// Up Arrow = Scroll Up
if (upKeyHandler.activated && currentLiveInputStyle != LiveInputStyle.WASD)
if (upKeyHandler.activated && currentLiveInputStyle == None)
{
scrollAmount = -GRID_SIZE * 0.25 * 5.0;
scrollAmount = -GRID_SIZE * 0.25 * 25.0;
shouldPause = true;
}
// Down Arrow = Scroll Down
if (downKeyHandler.activated && currentLiveInputStyle != LiveInputStyle.WASD)
if (downKeyHandler.activated && currentLiveInputStyle == None)
{
scrollAmount = GRID_SIZE * 0.25 * 5.0;
scrollAmount = GRID_SIZE * 0.25 * 25.0;
shouldPause = true;
}
// W = Scroll Up (doesn't work with Ctrl+Scroll)
if (wKeyHandler.activated && currentLiveInputStyle == None && !FlxG.keys.pressed.CONTROL)
{
scrollAmount = -GRID_SIZE * 0.25 * 25.0;
shouldPause = true;
}
// S = Scroll Down (doesn't work with Ctrl+Scroll)
if (sKeyHandler.activated && currentLiveInputStyle == None && !FlxG.keys.pressed.CONTROL)
{
scrollAmount = GRID_SIZE * 0.25 * 25.0;
shouldPause = true;
}
@ -1995,7 +2032,7 @@ class ChartEditorState extends HaxeUIState
// SHIFT + Scroll = Scroll Fast
if (FlxG.keys.pressed.SHIFT)
{
scrollAmount *= 5;
scrollAmount *= 2;
}
// CONTROL + Scroll = Scroll Precise
if (FlxG.keys.pressed.CONTROL)
@ -2066,14 +2103,17 @@ class ChartEditorState extends HaxeUIState
function handleSnap():Void
{
if (FlxG.keys.justPressed.LEFT && !FlxG.keys.pressed.CONTROL)
if (currentLiveInputStyle == None)
{
noteSnapQuantIndex--;
}
if (FlxG.keys.justPressed.LEFT && !FlxG.keys.pressed.CONTROL)
{
noteSnapQuantIndex--;
}
if (FlxG.keys.justPressed.RIGHT && !FlxG.keys.pressed.CONTROL)
{
noteSnapQuantIndex++;
if (FlxG.keys.justPressed.RIGHT && !FlxG.keys.pressed.CONTROL)
{
noteSnapQuantIndex++;
}
}
}
@ -3059,10 +3099,16 @@ class ChartEditorState extends HaxeUIState
// CTRL + Q = Quit to Menu
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.Q)
{
FlxG.switchState(new MainMenuState());
quitChartEditor();
}
}
function quitChartEditor():Void
{
autoSave();
FlxG.switchState(new MainMenuState());
}
/**
* Handle keybinds for edit menu items.
*/
@ -3151,13 +3197,17 @@ class ChartEditorState extends HaxeUIState
*/
function handleViewKeybinds():Void
{
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.LEFT)
if (currentLiveInputStyle == None)
{
incrementDifficulty(-1);
}
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.RIGHT)
{
incrementDifficulty(1);
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.LEFT)
{
incrementDifficulty(-1);
}
if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.RIGHT)
{
incrementDifficulty(1);
}
// Would bind Ctrl+A and Ctrl+D here, but they are already bound to Select All and Select None.
}
}
@ -3264,7 +3314,7 @@ class ChartEditorState extends HaxeUIState
*/
function handleTestKeybinds():Void
{
if (!isHaxeUIDialogOpen && FlxG.keys.justPressed.ENTER)
if (!isHaxeUIDialogOpen && !isCursorOverHaxeUI && FlxG.keys.justPressed.ENTER)
{
var minimal = FlxG.keys.pressed.SHIFT;
testSongInPlayState(minimal);
@ -3856,25 +3906,26 @@ class ChartEditorState extends HaxeUIState
switch (currentLiveInputStyle)
{
case LiveInputStyle.WASD:
if (FlxG.keys.justPressed.A) placeNoteAtPlayhead(0);
if (FlxG.keys.justPressed.S) placeNoteAtPlayhead(1);
if (FlxG.keys.justPressed.W) placeNoteAtPlayhead(2);
if (FlxG.keys.justPressed.D) placeNoteAtPlayhead(3);
if (FlxG.keys.justPressed.A) placeNoteAtPlayhead(4);
if (FlxG.keys.justPressed.S) placeNoteAtPlayhead(5);
if (FlxG.keys.justPressed.W) placeNoteAtPlayhead(6);
if (FlxG.keys.justPressed.D) placeNoteAtPlayhead(7);
if (FlxG.keys.justPressed.LEFT) placeNoteAtPlayhead(4);
if (FlxG.keys.justPressed.DOWN) placeNoteAtPlayhead(5);
if (FlxG.keys.justPressed.UP) placeNoteAtPlayhead(6);
if (FlxG.keys.justPressed.RIGHT) placeNoteAtPlayhead(7);
if (FlxG.keys.justPressed.LEFT) placeNoteAtPlayhead(0);
if (FlxG.keys.justPressed.DOWN) placeNoteAtPlayhead(1);
if (FlxG.keys.justPressed.UP) placeNoteAtPlayhead(2);
if (FlxG.keys.justPressed.RIGHT) placeNoteAtPlayhead(3);
case LiveInputStyle.NumberKeys:
if (FlxG.keys.justPressed.ONE) placeNoteAtPlayhead(0);
if (FlxG.keys.justPressed.TWO) placeNoteAtPlayhead(1);
if (FlxG.keys.justPressed.THREE) placeNoteAtPlayhead(2);
if (FlxG.keys.justPressed.FOUR) placeNoteAtPlayhead(3);
// Flipped because Dad is on the left but represents data 0-3.
if (FlxG.keys.justPressed.ONE) placeNoteAtPlayhead(4);
if (FlxG.keys.justPressed.TWO) placeNoteAtPlayhead(5);
if (FlxG.keys.justPressed.THREE) placeNoteAtPlayhead(6);
if (FlxG.keys.justPressed.FOUR) placeNoteAtPlayhead(7);
if (FlxG.keys.justPressed.FIVE) placeNoteAtPlayhead(4);
if (FlxG.keys.justPressed.SIX) placeNoteAtPlayhead(5);
if (FlxG.keys.justPressed.SEVEN) placeNoteAtPlayhead(6);
if (FlxG.keys.justPressed.EIGHT) placeNoteAtPlayhead(7);
if (FlxG.keys.justPressed.FIVE) placeNoteAtPlayhead(0);
if (FlxG.keys.justPressed.SIX) placeNoteAtPlayhead(1);
if (FlxG.keys.justPressed.SEVEN) placeNoteAtPlayhead(2);
if (FlxG.keys.justPressed.EIGHT) placeNoteAtPlayhead(3);
case LiveInputStyle.None:
// Do nothing.
}
@ -3883,12 +3934,24 @@ class ChartEditorState extends HaxeUIState
function placeNoteAtPlayhead(column:Int):Void
{
var playheadPos:Float = scrollPositionInPixels + playheadPositionInPixels;
var playheadPosFractionalStep:Float = playheadPos / GRID_SIZE / (16 / noteSnapQuant);
var playheadPosFractionalStep:Float = playheadPos / GRID_SIZE / noteSnapRatio;
var playheadPosStep:Int = Std.int(Math.floor(playheadPosFractionalStep));
var playheadPosMs:Float = playheadPosStep * Conductor.stepLengthMs * (16 / noteSnapQuant);
var playheadPosSnappedMs:Float = playheadPosStep * Conductor.stepLengthMs * noteSnapRatio;
var newNoteData:SongNoteData = new SongNoteData(playheadPosMs, column, 0, selectedNoteKind);
performCommand(new AddNotesCommand([newNoteData], FlxG.keys.pressed.CONTROL));
// Look for notes within 1 step of the playhead.
var notesAtPos:Array<SongNoteData> = SongDataUtils.getNotesInTimeRange(currentSongChartNoteData, playheadPosSnappedMs,
playheadPosSnappedMs + Conductor.stepLengthMs * noteSnapRatio);
notesAtPos = SongDataUtils.getNotesWithData(notesAtPos, [column]);
if (notesAtPos.length == 0)
{
var newNoteData:SongNoteData = new SongNoteData(playheadPosSnappedMs, column, 0, selectedNoteKind);
performCommand(new AddNotesCommand([newNoteData], FlxG.keys.pressed.CONTROL));
}
else
{
trace('Already a note there.');
}
}
function set_scrollPositionInPixels(value:Float):Float
@ -3947,6 +4010,8 @@ class ChartEditorState extends HaxeUIState
*/
public function testSongInPlayState(minimal:Bool = false):Void
{
autoSave();
var startTimestamp:Float = 0;
if (playtestStartTime) startTimestamp = scrollPositionInMs + playheadPositionInMs;

View file

@ -39,7 +39,7 @@ class Constants
*/
public static final VERSION_SUFFIX:String = ' PROTOTYPE';
#if debug
#if (debug || FORCE_DEBUG_VERSION)
static function get_VERSION():String
{
return 'v${Application.current.meta.get('version')} (${GIT_BRANCH} : ${GIT_HASH})' + VERSION_SUFFIX;
@ -71,7 +71,7 @@ class Constants
*/
// ==============================
#if debug
#if (debug || FORCE_DEBUG_VERSION)
/**
* The current Git branch.
*/

View file

@ -1,6 +1,6 @@
package funkin.util.macro;
#if debug
#if (debug || FORCE_DEBUG_VERSION)
class GitCommit
{
/**