mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-09-01 19:32:22 +00:00
Compare commits
1 commit
5c077af5b2
...
34643e08ea
Author | SHA1 | Date | |
---|---|---|---|
|
34643e08ea |
|
@ -17,23 +17,23 @@ class CapsuleOptionsMenu extends FlxSpriteGroup
|
||||||
|
|
||||||
var queueDestroy:Bool = false;
|
var queueDestroy:Bool = false;
|
||||||
|
|
||||||
var instrumentalIds:Array<String> = [''];
|
var options:Array<String> = [''];
|
||||||
var currentInstrumentalIndex:Int = 0;
|
var currentOptionIndex:Int = 0;
|
||||||
|
|
||||||
var currentInstrumental:FlxText;
|
var currentOption:FlxText;
|
||||||
|
|
||||||
var busy:Bool = false;
|
var busy:Bool = false;
|
||||||
|
|
||||||
var leftArrow:InstrumentalSelector;
|
var leftArrow:OptionSelector;
|
||||||
|
|
||||||
var rightArrow:InstrumentalSelector;
|
var rightArrow:OptionSelector;
|
||||||
|
|
||||||
public function new(parent:FreeplayState, x:Float = 0, y:Float = 0, instIds:Array<String>):Void
|
public function new(parent:FreeplayState, x:Float = 0, y:Float = 0, options:Array<String>, labelText:String):Void
|
||||||
{
|
{
|
||||||
super(x, y);
|
super(x, y);
|
||||||
|
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.instrumentalIds = instIds;
|
this.options = options;
|
||||||
|
|
||||||
capsuleMenuBG = FunkinSprite.createSparrow(0, 0, 'freeplay/instBox/instBox');
|
capsuleMenuBG = FunkinSprite.createSparrow(0, 0, 'freeplay/instBox/instBox');
|
||||||
|
|
||||||
|
@ -41,21 +41,21 @@ class CapsuleOptionsMenu extends FlxSpriteGroup
|
||||||
capsuleMenuBG.animation.addByPrefix('idle', 'idle0', 24, true);
|
capsuleMenuBG.animation.addByPrefix('idle', 'idle0', 24, true);
|
||||||
capsuleMenuBG.animation.addByPrefix('open', 'open0', 24, false);
|
capsuleMenuBG.animation.addByPrefix('open', 'open0', 24, false);
|
||||||
|
|
||||||
currentInstrumental = new FlxText(0, 36, capsuleMenuBG.width, '');
|
currentOption = new FlxText(0, 36, capsuleMenuBG.width, '');
|
||||||
currentInstrumental.setFormat('VCR OSD Mono', 40, FlxTextAlign.CENTER, true);
|
currentOption.setFormat('VCR OSD Mono', 40, FlxTextAlign.CENTER, true);
|
||||||
|
|
||||||
final PAD = 4;
|
final PAD = 4;
|
||||||
leftArrow = new InstrumentalSelector(parent, PAD, 30, false, parent.getControls());
|
leftArrow = new OptionSelector(parent, PAD, 30, false, parent.getControls());
|
||||||
rightArrow = new InstrumentalSelector(parent, capsuleMenuBG.width - leftArrow.width - PAD, 30, true, parent.getControls());
|
rightArrow = new OptionSelector(parent, capsuleMenuBG.width - leftArrow.width - PAD, 30, true, parent.getControls());
|
||||||
|
|
||||||
var label:FlxText = new FlxText(0, 5, capsuleMenuBG.width, 'INSTRUMENTAL');
|
var label:FlxText = new FlxText(0, 5, capsuleMenuBG.width, labelText);
|
||||||
label.setFormat('VCR OSD Mono', 24, FlxTextAlign.CENTER, true);
|
label.setFormat('VCR OSD Mono', 24, FlxTextAlign.CENTER, true);
|
||||||
|
|
||||||
add(capsuleMenuBG);
|
add(capsuleMenuBG);
|
||||||
add(leftArrow);
|
add(leftArrow);
|
||||||
add(rightArrow);
|
add(rightArrow);
|
||||||
add(label);
|
add(label);
|
||||||
add(currentInstrumental);
|
add(currentOption);
|
||||||
|
|
||||||
capsuleMenuBG.animation.finishCallback = function(_) {
|
capsuleMenuBG.animation.finishCallback = function(_) {
|
||||||
capsuleMenuBG.animation.play('idle', true);
|
capsuleMenuBG.animation.play('idle', true);
|
||||||
|
@ -72,7 +72,7 @@ class CapsuleOptionsMenu extends FlxSpriteGroup
|
||||||
destroy();
|
destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var changedInst = false;
|
var changedOption = false;
|
||||||
|
|
||||||
if (!busy)
|
if (!busy)
|
||||||
{
|
{
|
||||||
|
@ -85,27 +85,27 @@ class CapsuleOptionsMenu extends FlxSpriteGroup
|
||||||
|
|
||||||
if (parent.getControls().UI_LEFT_P)
|
if (parent.getControls().UI_LEFT_P)
|
||||||
{
|
{
|
||||||
currentInstrumentalIndex = (currentInstrumentalIndex + 1) % instrumentalIds.length;
|
currentOptionIndex = (currentOptionIndex + 1) % options.length;
|
||||||
changedInst = true;
|
changedOption = true;
|
||||||
}
|
}
|
||||||
if (parent.getControls().UI_RIGHT_P)
|
if (parent.getControls().UI_RIGHT_P)
|
||||||
{
|
{
|
||||||
currentInstrumentalIndex = (currentInstrumentalIndex - 1 + instrumentalIds.length) % instrumentalIds.length;
|
currentOptionIndex = (currentOptionIndex - 1 + options.length) % options.length;
|
||||||
changedInst = true;
|
changedOption = true;
|
||||||
}
|
}
|
||||||
if (parent.getControls().ACCEPT)
|
if (parent.getControls().ACCEPT)
|
||||||
{
|
{
|
||||||
busy = true;
|
busy = true;
|
||||||
onConfirm(instrumentalIds[currentInstrumentalIndex] ?? '');
|
onConfirm(options[currentOptionIndex] ?? '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!changedInst && currentInstrumental.text == '') changedInst = true;
|
if (!changedOption && currentOption.text == '') changedOption = true;
|
||||||
|
|
||||||
if (changedInst)
|
if (changedOption)
|
||||||
{
|
{
|
||||||
currentInstrumental.text = instrumentalIds[currentInstrumentalIndex].toTitleCase() ?? '';
|
currentOption.text = options[currentOptionIndex].toTitleCase() ?? '';
|
||||||
if (currentInstrumental.text == '') currentInstrumental.text = 'Default';
|
if (currentOption.text == '') currentOption.text = 'Default';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ class CapsuleOptionsMenu extends FlxSpriteGroup
|
||||||
/**
|
/**
|
||||||
* Override this with `capsuleOptionsMenu.onConfirm = myFunction;`
|
* Override this with `capsuleOptionsMenu.onConfirm = myFunction;`
|
||||||
*/
|
*/
|
||||||
public dynamic function onConfirm(targetInstId:String):Void
|
public dynamic function onConfirm(targetOption:String):Void
|
||||||
{
|
{
|
||||||
throw 'onConfirm not implemented!';
|
throw 'onConfirm not implemented!';
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ class CapsuleOptionsMenu extends FlxSpriteGroup
|
||||||
/**
|
/**
|
||||||
* The difficulty selector arrows to the left and right of the difficulty.
|
* The difficulty selector arrows to the left and right of the difficulty.
|
||||||
*/
|
*/
|
||||||
class InstrumentalSelector extends FunkinSprite
|
class OptionSelector extends FunkinSprite
|
||||||
{
|
{
|
||||||
var controls:Controls;
|
var controls:Controls;
|
||||||
var whiteShader:PureColor;
|
var whiteShader:PureColor;
|
||||||
|
|
|
@ -1429,11 +1429,12 @@ class FreeplayState extends MusicBeatSubState
|
||||||
handleInputs(elapsed);
|
handleInputs(elapsed);
|
||||||
|
|
||||||
if (dj != null) FlxG.watch.addQuick('dj-anim', dj.getCurrentAnimation());
|
if (dj != null) FlxG.watch.addQuick('dj-anim', dj.getCurrentAnimation());
|
||||||
|
if (justClosedCapsuleOptions) justClosedCapsuleOptions = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleInputs(elapsed:Float):Void
|
function handleInputs(elapsed:Float):Void
|
||||||
{
|
{
|
||||||
if (busy) return;
|
if (busy || justClosedCapsuleOptions) return;
|
||||||
|
|
||||||
var upP:Bool = controls.UI_UP_P;
|
var upP:Bool = controls.UI_UP_P;
|
||||||
var downP:Bool = controls.UI_DOWN_P;
|
var downP:Bool = controls.UI_DOWN_P;
|
||||||
|
@ -1904,6 +1905,13 @@ class FreeplayState extends MusicBeatSubState
|
||||||
trace('target difficulty: ${targetDifficultyId}');
|
trace('target difficulty: ${targetDifficultyId}');
|
||||||
trace('target variation: ${targetDifficulty?.variation ?? Constants.DEFAULT_VARIATION}');
|
trace('target variation: ${targetDifficulty?.variation ?? Constants.DEFAULT_VARIATION}');
|
||||||
|
|
||||||
|
// Open a CapsuleOptionsMenu instead where you decide whether to actually delete the data of the song or not.
|
||||||
|
if (FlxG.keys.pressed.DELETE)
|
||||||
|
{
|
||||||
|
openDeleteSongDataOption(cap, targetSongId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var baseInstrumentalId:String = targetSong.getBaseInstrumentalId(targetDifficultyId, targetDifficulty?.variation ?? Constants.DEFAULT_VARIATION) ?? '';
|
var baseInstrumentalId:String = targetSong.getBaseInstrumentalId(targetDifficultyId, targetDifficulty?.variation ?? Constants.DEFAULT_VARIATION) ?? '';
|
||||||
var altInstrumentalIds:Array<String> = targetSong.listAltInstrumentalIds(targetDifficultyId,
|
var altInstrumentalIds:Array<String> = targetSong.listAltInstrumentalIds(targetDifficultyId,
|
||||||
targetDifficulty?.variation ?? Constants.DEFAULT_VARIATION) ?? [];
|
targetDifficulty?.variation ?? Constants.DEFAULT_VARIATION) ?? [];
|
||||||
|
@ -1925,9 +1933,40 @@ class FreeplayState extends MusicBeatSubState
|
||||||
return controls;
|
return controls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openDeleteSongDataOption(cap:SongMenuItem, targetSongId:String):Void
|
||||||
|
{
|
||||||
|
capsuleOptionsMenu = new CapsuleOptionsMenu(this, cap.targetPos.x + 175, cap.targetPos.y + 115, ["Funk NO!", "True.."], 'DELETE SONG DATA?');
|
||||||
|
capsuleOptionsMenu.cameras = [funnyCam];
|
||||||
|
capsuleOptionsMenu.zIndex = 10000;
|
||||||
|
add(capsuleOptionsMenu);
|
||||||
|
|
||||||
|
capsuleOptionsMenu.onConfirm = function(targetOption:String) {
|
||||||
|
if (targetOption == "True..") Save.instance.setSongScore(targetSongId, currentDifficulty,
|
||||||
|
{
|
||||||
|
// Zer0.
|
||||||
|
score: 0,
|
||||||
|
tallies:
|
||||||
|
{
|
||||||
|
sick: 0,
|
||||||
|
good: 0,
|
||||||
|
bad: 0,
|
||||||
|
shit: 0,
|
||||||
|
missed: 0,
|
||||||
|
combo: 0,
|
||||||
|
maxCombo: 0,
|
||||||
|
totalNotesHit: 0,
|
||||||
|
totalNotes: 0,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
cleanupCapsuleOptionsMenu();
|
||||||
|
// Refresh the song to update the score.
|
||||||
|
changeSelection();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function openInstrumentalList(cap:SongMenuItem, instrumentalIds:Array<String>):Void
|
function openInstrumentalList(cap:SongMenuItem, instrumentalIds:Array<String>):Void
|
||||||
{
|
{
|
||||||
capsuleOptionsMenu = new CapsuleOptionsMenu(this, cap.targetPos.x + 175, cap.targetPos.y + 115, instrumentalIds);
|
capsuleOptionsMenu = new CapsuleOptionsMenu(this, cap.targetPos.x + 175, cap.targetPos.y + 115, instrumentalIds, 'INSTRUMENTAL');
|
||||||
capsuleOptionsMenu.cameras = [funnyCam];
|
capsuleOptionsMenu.cameras = [funnyCam];
|
||||||
capsuleOptionsMenu.zIndex = 10000;
|
capsuleOptionsMenu.zIndex = 10000;
|
||||||
add(capsuleOptionsMenu);
|
add(capsuleOptionsMenu);
|
||||||
|
@ -1938,11 +1977,13 @@ class FreeplayState extends MusicBeatSubState
|
||||||
}
|
}
|
||||||
|
|
||||||
var capsuleOptionsMenu:Null<CapsuleOptionsMenu> = null;
|
var capsuleOptionsMenu:Null<CapsuleOptionsMenu> = null;
|
||||||
|
var justClosedCapsuleOptions:Bool = false;
|
||||||
|
|
||||||
public function cleanupCapsuleOptionsMenu():Void
|
public function cleanupCapsuleOptionsMenu():Void
|
||||||
{
|
{
|
||||||
this.busy = false;
|
this.busy = false;
|
||||||
letterSort.inputEnabled = true;
|
letterSort.inputEnabled = true;
|
||||||
|
justClosedCapsuleOptions = true;
|
||||||
|
|
||||||
if (capsuleOptionsMenu != null)
|
if (capsuleOptionsMenu != null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue