mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-04-15 08:54:37 +00:00
Difficulty selection now updates metadata toolbox
This commit is contained in:
parent
d03a2f0157
commit
8732adc144
|
@ -1,5 +1,9 @@
|
|||
package funkin.ui.debug.charting;
|
||||
|
||||
import haxe.ui.components.TextField;
|
||||
import haxe.ui.components.DropDown;
|
||||
import haxe.ui.components.NumberStepper;
|
||||
import haxe.ui.containers.Frame;
|
||||
import flixel.addons.display.FlxSliceSprite;
|
||||
import flixel.addons.display.FlxTiledSprite;
|
||||
import flixel.FlxCamera;
|
||||
|
@ -2834,7 +2838,8 @@ class ChartEditorState extends HaxeUIState
|
|||
|
||||
if (change < 0)
|
||||
{
|
||||
// Decrement difficulty.
|
||||
trace('Decrement difficulty.');
|
||||
|
||||
// If we reached this point, we are not at the lowest difficulty.
|
||||
if (isFirstDiffInVariation)
|
||||
{
|
||||
|
@ -2847,6 +2852,7 @@ class ChartEditorState extends HaxeUIState
|
|||
selectedDifficulty = prevDifficulty;
|
||||
|
||||
refreshDifficultyTreeSelection();
|
||||
refreshSongMetadataToolbox();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2855,11 +2861,13 @@ class ChartEditorState extends HaxeUIState
|
|||
selectedDifficulty = prevDifficulty;
|
||||
|
||||
refreshDifficultyTreeSelection();
|
||||
refreshSongMetadataToolbox();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Increment difficulty.
|
||||
trace('Increment difficulty.');
|
||||
|
||||
// If we reached this point, we are not at the highest difficulty.
|
||||
if (isLastDiffInVariation)
|
||||
{
|
||||
|
@ -2870,12 +2878,18 @@ class ChartEditorState extends HaxeUIState
|
|||
|
||||
var nextDifficulty = availableDifficulties[0];
|
||||
selectedDifficulty = nextDifficulty;
|
||||
|
||||
refreshDifficultyTreeSelection();
|
||||
refreshSongMetadataToolbox();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Go to next difficulty in this variation.
|
||||
var nextDifficulty = availableDifficulties[currentDifficultyIndex + 1];
|
||||
selectedDifficulty = nextDifficulty;
|
||||
|
||||
refreshDifficultyTreeSelection();
|
||||
refreshSongMetadataToolbox();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3125,10 +3139,11 @@ class ChartEditorState extends HaxeUIState
|
|||
|
||||
if (variation != null && difficulty != null)
|
||||
{
|
||||
trace('Changing difficulty to $variation:$difficulty');
|
||||
trace('Changing difficulty to "$variation:$difficulty"');
|
||||
selectedVariation = variation;
|
||||
selectedDifficulty = difficulty;
|
||||
// refreshDifficultyTreeSelection(treeView);
|
||||
refreshSongMetadataToolbox();
|
||||
}
|
||||
// case 'song':
|
||||
// case 'variation':
|
||||
|
@ -3136,9 +3151,44 @@ class ChartEditorState extends HaxeUIState
|
|||
// Reset the user's selection.
|
||||
trace('Selected wrong node type, resetting selection.');
|
||||
treeView.selectedNode = getCurrentTreeDifficultyNode(treeView);
|
||||
refreshSongMetadataToolbox();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When the difficulty changes, update the song metadata toolbox to reflect the new data.
|
||||
*/
|
||||
function refreshSongMetadataToolbox():Void
|
||||
{
|
||||
var toolbox:CollapsibleDialog = ChartEditorToolboxHandler.getToolbox(this, CHART_EDITOR_TOOLBOX_METADATA_LAYOUT);
|
||||
|
||||
var inputSongName:TextField = toolbox.findComponent('inputSongName', TextField);
|
||||
inputSongName.value = currentSongMetadata.songName;
|
||||
|
||||
var inputSongArtist:TextField = toolbox.findComponent('inputSongArtist', TextField);
|
||||
inputSongArtist.value = currentSongMetadata.artist;
|
||||
|
||||
var inputStage:DropDown = toolbox.findComponent('inputStage', DropDown);
|
||||
inputStage.value = currentSongMetadata.playData.stage;
|
||||
|
||||
var inputNoteSkin:DropDown = toolbox.findComponent('inputNoteSkin', DropDown);
|
||||
inputNoteSkin.value = currentSongMetadata.playData.noteSkin;
|
||||
|
||||
var inputBPM:NumberStepper = toolbox.findComponent('inputBPM', NumberStepper);
|
||||
inputBPM.value = currentSongMetadata.timeChanges[0].bpm;
|
||||
|
||||
var labelScrollSpeed:Label = toolbox.findComponent('labelScrollSpeed', Label);
|
||||
labelScrollSpeed.text = 'Scroll Speed: ${currentSongChartScrollSpeed}x';
|
||||
|
||||
var inputScrollSpeed:Slider = toolbox.findComponent('inputScrollSpeed', Slider);
|
||||
inputScrollSpeed.value = currentSongChartScrollSpeed;
|
||||
|
||||
var frameVariation:Frame = toolbox.findComponent('frameVariation', Frame);
|
||||
frameVariation.text = 'Variation: ${selectedVariation.toTitleCase()}';
|
||||
var frameDifficulty:Frame = toolbox.findComponent('frameDifficulty', Frame);
|
||||
frameDifficulty.text = 'Difficulty: ${selectedDifficulty.toTitleCase()}';
|
||||
}
|
||||
|
||||
function addDifficulty(variation:String):Void {}
|
||||
|
||||
function addVariation(variationId:String):Void
|
||||
|
|
|
@ -19,6 +19,7 @@ import haxe.ui.containers.Box;
|
|||
import haxe.ui.containers.Grid;
|
||||
import haxe.ui.containers.Group;
|
||||
import haxe.ui.containers.VBox;
|
||||
import haxe.ui.containers.Frame;
|
||||
import haxe.ui.containers.dialogs.CollapsibleDialog;
|
||||
import haxe.ui.containers.dialogs.Dialog.DialogButton;
|
||||
import haxe.ui.containers.dialogs.Dialog.DialogEvent;
|
||||
|
@ -537,7 +538,7 @@ class ChartEditorToolboxHandler
|
|||
|
||||
var inputNoteSkin:DropDown = toolbox.findComponent('inputNoteSkin', DropDown);
|
||||
inputNoteSkin.onChange = function(event:UIEvent) {
|
||||
if (event.data.id == null) return;
|
||||
if ((event?.data?.id ?? null) == null) return;
|
||||
state.currentSongMetadata.playData.noteSkin = event.data.id;
|
||||
};
|
||||
inputNoteSkin.value = state.currentSongMetadata.playData.noteSkin;
|
||||
|
@ -582,10 +583,19 @@ class ChartEditorToolboxHandler
|
|||
inputScrollSpeed.value = state.currentSongChartScrollSpeed;
|
||||
labelScrollSpeed.text = 'Scroll Speed: ${state.currentSongChartScrollSpeed}x';
|
||||
|
||||
var frameVariation:Frame = toolbox.findComponent('frameVariation', Frame);
|
||||
frameVariation.text = 'Variation: ${state.selectedVariation.toTitleCase()}';
|
||||
|
||||
var frameDifficulty:Frame = toolbox.findComponent('frameDifficulty', Frame);
|
||||
frameDifficulty.text = 'Difficulty: ${state.selectedDifficulty.toTitleCase()}';
|
||||
|
||||
return toolbox;
|
||||
}
|
||||
|
||||
static function onShowToolboxMetadata(state:ChartEditorState, toolbox:CollapsibleDialog):Void {}
|
||||
static function onShowToolboxMetadata(state:ChartEditorState, toolbox:CollapsibleDialog):Void
|
||||
{
|
||||
state.refreshSongMetadataToolbox();
|
||||
}
|
||||
|
||||
static function onHideToolboxMetadata(state:ChartEditorState, toolbox:CollapsibleDialog):Void {}
|
||||
|
||||
|
|
|
@ -6,6 +6,19 @@ import flixel.util.FlxSort;
|
|||
#end
|
||||
import funkin.play.notes.NoteSprite;
|
||||
|
||||
/**
|
||||
* A set of functions related to sorting.
|
||||
*
|
||||
* NOTE: `Array.sort()` takes a function `(x, y) -> Int`.
|
||||
* If the objects are in the correct order (x before y), return a negative value.
|
||||
* If the objects need to be swapped (y before x), return a negative value.
|
||||
* If the objects are equal, return 0.
|
||||
*
|
||||
* NOTE: `Array.sort()` does NOT guarantee that the order of equal elements. `haxe.ds.ArraySort.sort()` does guarantee this.
|
||||
* NOTE: `Array.sort()` may not be the most efficient sorting algorithm for all use cases (especially if the array is known to be mostly sorted).
|
||||
* You may consider using one of the functions in `funkin.util.tools.ArraySortTools` instead.
|
||||
* NOTE: Both sort functions modify the array in-place. You may consider using `Reflect.copy()` to make a copy of the array before sorting.
|
||||
*/
|
||||
class SortUtil
|
||||
{
|
||||
/**
|
||||
|
@ -49,11 +62,11 @@ class SortUtil
|
|||
* @param b The second string to compare.
|
||||
* @param defaultValue The value to prioritize.
|
||||
*/
|
||||
public static function defaultThenAlphabetically(a:String, b:String, defaultValue:String):Int
|
||||
public static function defaultThenAlphabetically(defaultValue:String, a:String, b:String):Int
|
||||
{
|
||||
if (a == b) return 0;
|
||||
if (a == defaultValue) return 1;
|
||||
if (b == defaultValue) return -1;
|
||||
if (a == defaultValue) return -1;
|
||||
if (b == defaultValue) return 1;
|
||||
return alphabetically(a, b);
|
||||
}
|
||||
|
||||
|
@ -64,7 +77,7 @@ class SortUtil
|
|||
* @param b The second string to compare.
|
||||
* @param defaultValues The values to prioritize.
|
||||
*/
|
||||
public static function defaultsThenAlphabetically(a:String, b:String, defaultValues:Array<String>):Int
|
||||
public static function defaultsThenAlphabetically(defaultValues:Array<String>, a:String, b:String):Int
|
||||
{
|
||||
if (a == b) return 0;
|
||||
if (defaultValues.contains(a) && defaultValues.contains(b))
|
||||
|
@ -72,8 +85,8 @@ class SortUtil
|
|||
// Sort by index in defaultValues
|
||||
return defaultValues.indexOf(a) - defaultValues.indexOf(b);
|
||||
};
|
||||
if (defaultValues.contains(a)) return 1;
|
||||
if (defaultValues.contains(b)) return -1;
|
||||
if (defaultValues.contains(a)) return -1;
|
||||
if (defaultValues.contains(b)) return 1;
|
||||
return alphabetically(a, b);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue