2023-10-26 05:46:22 -04:00
|
|
|
package funkin.ui.debug.charting.util;
|
2023-09-25 23:24:07 -04:00
|
|
|
|
|
|
|
import funkin.data.notestyle.NoteStyleRegistry;
|
|
|
|
import funkin.play.notes.notestyle.NoteStyle;
|
2024-01-16 16:49:15 -05:00
|
|
|
import funkin.data.stage.StageData;
|
|
|
|
import funkin.data.stage.StageRegistry;
|
2023-09-25 23:24:07 -04:00
|
|
|
import funkin.play.character.CharacterData;
|
|
|
|
import haxe.ui.components.DropDown;
|
2024-01-16 16:49:15 -05:00
|
|
|
import funkin.play.stage.Stage;
|
2023-09-25 23:24:07 -04:00
|
|
|
import funkin.play.character.BaseCharacter.CharacterType;
|
|
|
|
import funkin.play.character.CharacterData.CharacterDataParser;
|
|
|
|
|
|
|
|
/**
|
2023-10-26 05:46:22 -04:00
|
|
|
* Functions for populating dropdowns based on game data.
|
2023-09-25 23:24:07 -04:00
|
|
|
* These get used by both dialogs and toolboxes so they're in their own class to prevent "reaching over."
|
|
|
|
*/
|
|
|
|
@:nullSafety
|
2023-10-26 05:46:22 -04:00
|
|
|
@:access(funkin.ui.debug.charting.ChartEditorState)
|
2023-09-25 23:24:07 -04:00
|
|
|
class ChartEditorDropdowns
|
|
|
|
{
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Populate a dropdown with a list of characters.
|
|
|
|
*/
|
2023-09-25 23:24:07 -04:00
|
|
|
public static function populateDropdownWithCharacters(dropDown:DropDown, charType:CharacterType, startingCharId:String):DropDownEntry
|
|
|
|
{
|
|
|
|
dropDown.dataSource.clear();
|
|
|
|
|
|
|
|
// TODO: Filter based on charType.
|
|
|
|
var charIds:Array<String> = CharacterDataParser.listCharacterIds();
|
|
|
|
|
|
|
|
var returnValue:DropDownEntry = switch (charType)
|
|
|
|
{
|
|
|
|
case BF: {id: "bf", text: "Boyfriend"};
|
|
|
|
case DAD: {id: "dad", text: "Daddy Dearest"};
|
|
|
|
default: {
|
|
|
|
dropDown.dataSource.add({id: "none", text: ""});
|
|
|
|
{id: "none", text: "None"};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (charId in charIds)
|
|
|
|
{
|
|
|
|
var character:Null<CharacterData> = CharacterDataParser.fetchCharacterData(charId);
|
|
|
|
if (character == null) continue;
|
|
|
|
|
|
|
|
var value = {id: charId, text: character.name};
|
|
|
|
if (startingCharId == charId) returnValue = value;
|
|
|
|
|
|
|
|
dropDown.dataSource.add(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
dropDown.dataSource.sort('text', ASCENDING);
|
|
|
|
|
|
|
|
return returnValue;
|
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Populate a dropdown with a list of stages.
|
|
|
|
*/
|
2023-09-25 23:24:07 -04:00
|
|
|
public static function populateDropdownWithStages(dropDown:DropDown, startingStageId:String):DropDownEntry
|
|
|
|
{
|
|
|
|
dropDown.dataSource.clear();
|
|
|
|
|
2024-01-16 16:49:15 -05:00
|
|
|
var stageIds:Array<String> = StageRegistry.instance.listEntryIds();
|
2023-09-25 23:24:07 -04:00
|
|
|
|
|
|
|
var returnValue:DropDownEntry = {id: "mainStage", text: "Main Stage"};
|
|
|
|
|
|
|
|
for (stageId in stageIds)
|
|
|
|
{
|
2024-01-16 16:49:15 -05:00
|
|
|
var stage:Null<Stage> = StageRegistry.instance.fetchEntry(stageId);
|
2023-09-25 23:24:07 -04:00
|
|
|
if (stage == null) continue;
|
|
|
|
|
2024-01-16 16:49:15 -05:00
|
|
|
var value = {id: stage.id, text: stage.stageName};
|
2023-09-25 23:24:07 -04:00
|
|
|
if (startingStageId == stageId) returnValue = value;
|
|
|
|
|
|
|
|
dropDown.dataSource.add(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
dropDown.dataSource.sort('text', ASCENDING);
|
|
|
|
|
|
|
|
return returnValue;
|
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Populate a dropdown with a list of note styles.
|
|
|
|
*/
|
2023-09-25 23:24:07 -04:00
|
|
|
public static function populateDropdownWithNoteStyles(dropDown:DropDown, startingStyleId:String):DropDownEntry
|
|
|
|
{
|
|
|
|
dropDown.dataSource.clear();
|
|
|
|
|
|
|
|
var noteStyleIds:Array<String> = NoteStyleRegistry.instance.listEntryIds();
|
|
|
|
|
|
|
|
var returnValue:DropDownEntry = {id: "funkin", text: "Funkin'"};
|
|
|
|
|
|
|
|
for (noteStyleId in noteStyleIds)
|
|
|
|
{
|
|
|
|
var noteStyle:Null<NoteStyle> = NoteStyleRegistry.instance.fetchEntry(noteStyleId);
|
|
|
|
if (noteStyle == null) continue;
|
|
|
|
|
|
|
|
var value = {id: noteStyleId, text: noteStyle.getName()};
|
|
|
|
if (startingStyleId == noteStyleId) returnValue = value;
|
|
|
|
|
|
|
|
dropDown.dataSource.add(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
dropDown.dataSource.sort('text', ASCENDING);
|
|
|
|
|
|
|
|
return returnValue;
|
|
|
|
}
|
|
|
|
|
2024-02-16 22:01:47 -05:00
|
|
|
static final NOTE_KINDS:Map<String, String> = [
|
|
|
|
// Base
|
|
|
|
"" => "Default",
|
|
|
|
"~CUSTOM~" => "Custom",
|
|
|
|
// Weeks 1-7
|
|
|
|
"mom" => "Mom Sings (Week 5)",
|
|
|
|
"ugh" => "Ugh (Week 7)",
|
|
|
|
"hehPrettyGood" => "Heh, Pretty Good (Week 7)",
|
|
|
|
// Weekend 1
|
2024-03-02 22:46:13 -05:00
|
|
|
"weekend-1-punchhigh" => "Punch High (Blazin')",
|
|
|
|
"weekend-1-punchhighdodged" => "Punch High (Dodge) (Blazin')",
|
|
|
|
"weekend-1-punchhighblocked" => "Punch High (Block) (Blazin')",
|
|
|
|
"weekend-1-punchhighspin" => "Punch High (Spin) (Blazin')",
|
|
|
|
"weekend-1-punchlow" => "Punch Low (Blazin')",
|
|
|
|
"weekend-1-punchlowdodged" => "Punch Low (Dodge) (Blazin')",
|
|
|
|
"weekend-1-punchlowblocked" => "Punch Low (Block) (Blazin')",
|
|
|
|
"weekend-1-punchlowspin" => "Punch High (Spin) (Blazin')",
|
|
|
|
"weekend-1-picouppercutprep" => "Pico Uppercut (Prep) (Blazin')",
|
|
|
|
"weekend-1-picouppercut" => "Pico Uppercut (Blazin')",
|
|
|
|
"weekend-1-blockhigh" => "Block High (Blazin')",
|
|
|
|
"weekend-1-blocklow" => "Dodge High (Blazin')",
|
|
|
|
"weekend-1-blockspin" => "Block High (Spin) (Blazin')",
|
|
|
|
"weekend-1-dodgehigh" => "Block Low (Blazin')",
|
|
|
|
"weekend-1-dodgelow" => "Dodge Low (Blazin')",
|
|
|
|
"weekend-1-dodgespin" => "Dodge High (Spin) (Blazin')",
|
|
|
|
"weekend-1-hithigh" => "Hit High (Blazin')",
|
|
|
|
"weekend-1-hitlow" => "Hit Low (Blazin')",
|
|
|
|
"weekend-1-hitspin" => "Hit High (Spin) (Blazin')",
|
|
|
|
"weekend-1-darnelluppercutprep" => "Darnell Uppercut (Prep) (Blazin')",
|
|
|
|
"weekend-1-darnelluppercut" => "Darnell Uppercut (Blazin')",
|
|
|
|
"weekend-1-idle" => "Idle (Blazin')",
|
|
|
|
"weekend-1-fakeout" => "Fakeout (Blazin')",
|
2024-03-02 23:23:52 -05:00
|
|
|
"weekend-1-taunt" => "Taunt (If Fakeout) (Blazin')",
|
|
|
|
"weekend-1-tauntforce" => "Taunt (Forced) (Blazin')",
|
|
|
|
"weekend-1-reversefakeout" => "Fakeout (Reverse) (Blazin')",
|
2024-02-16 22:01:47 -05:00
|
|
|
];
|
|
|
|
|
|
|
|
public static function populateDropdownWithNoteKinds(dropDown:DropDown, startingKindId:String):DropDownEntry
|
|
|
|
{
|
|
|
|
dropDown.dataSource.clear();
|
|
|
|
|
|
|
|
var returnValue:DropDownEntry = lookupNoteKind('~CUSTOM');
|
|
|
|
|
|
|
|
for (noteKindId in NOTE_KINDS.keys())
|
|
|
|
{
|
|
|
|
var noteKind:String = NOTE_KINDS.get(noteKindId) ?? 'Default';
|
|
|
|
|
|
|
|
var value:DropDownEntry = {id: noteKindId, text: noteKind};
|
|
|
|
if (startingKindId == noteKindId) returnValue = value;
|
|
|
|
|
|
|
|
dropDown.dataSource.add(value);
|
|
|
|
}
|
|
|
|
|
2024-02-23 03:23:00 -05:00
|
|
|
dropDown.dataSource.sort('id', ASCENDING);
|
|
|
|
|
2024-02-16 22:01:47 -05:00
|
|
|
return returnValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function lookupNoteKind(noteKindId:Null<String>):DropDownEntry
|
|
|
|
{
|
|
|
|
if (noteKindId == null) return lookupNoteKind('');
|
|
|
|
if (!NOTE_KINDS.exists(noteKindId)) return {id: '~CUSTOM~', text: 'Custom'};
|
|
|
|
return {id: noteKindId ?? '', text: NOTE_KINDS.get(noteKindId) ?? 'Default'};
|
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* Populate a dropdown with a list of song variations.
|
|
|
|
*/
|
2023-09-25 23:24:07 -04:00
|
|
|
public static function populateDropdownWithVariations(dropDown:DropDown, state:ChartEditorState, includeNone:Bool = true):DropDownEntry
|
|
|
|
{
|
|
|
|
dropDown.dataSource.clear();
|
|
|
|
|
|
|
|
var variationIds:Array<String> = state.availableVariations;
|
|
|
|
|
|
|
|
if (includeNone)
|
|
|
|
{
|
|
|
|
dropDown.dataSource.add({id: "none", text: ""});
|
|
|
|
}
|
|
|
|
|
|
|
|
var returnValue:DropDownEntry = includeNone ? ({id: "none", text: ""}) : ({id: "default", text: "Default"});
|
|
|
|
|
|
|
|
for (variationId in variationIds)
|
|
|
|
{
|
|
|
|
dropDown.dataSource.add({id: variationId, text: variationId.toTitleCase()});
|
|
|
|
}
|
|
|
|
|
|
|
|
dropDown.dataSource.sort('text', ASCENDING);
|
|
|
|
|
|
|
|
return returnValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
/**
|
|
|
|
* An entry in a dropdown.
|
|
|
|
*/
|
2023-09-25 23:24:07 -04:00
|
|
|
typedef DropDownEntry =
|
|
|
|
{
|
|
|
|
id:String,
|
|
|
|
text:String
|
|
|
|
};
|