Merge pull request #244 from FunkinCrew/chart-edit-playtest

Enabling / Disabling "playtest" mode from chart editor
This commit is contained in:
Cameron Taylor 2023-12-13 17:19:02 -05:00 committed by GitHub
commit db76a0dd1d
3 changed files with 76 additions and 26 deletions

2
assets

@ -1 +1 @@
Subproject commit 3c8ac202bbb93bf84c7dcd0697a9d7121d3c5283
Subproject commit 42b4bee68600bfb9c31831ccdd0579c00930d771

View file

@ -139,6 +139,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
public static final CHART_EDITOR_TOOLBOX_NOTEDATA_LAYOUT:String = Paths.ui('chart-editor/toolbox/notedata');
public static final CHART_EDITOR_TOOLBOX_EVENTDATA_LAYOUT:String = Paths.ui('chart-editor/toolbox/eventdata');
public static final CHART_EDITOR_TOOLBOX_PLAYTEST_PROPERTIES_LAYOUT:String = Paths.ui('chart-editor/toolbox/playtest-properties');
public static final CHART_EDITOR_TOOLBOX_METADATA_LAYOUT:String = Paths.ui('chart-editor/toolbox/metadata');
public static final CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT:String = Paths.ui('chart-editor/toolbox/difficulty');
public static final CHART_EDITOR_TOOLBOX_PLAYER_PREVIEW_LAYOUT:String = Paths.ui('chart-editor/toolbox/player-preview');
@ -516,6 +517,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
*/
var playtestStartTime:Bool = false;
/**
* If true, playtesting a chart will let you "gameover" / die when you lose ur health!
*/
var playtestPracticeMode:Bool = false;
// Visuals
/**
@ -2475,9 +2481,6 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
menubarItemDifficultyUp.onClick = _ -> incrementDifficulty(1);
menubarItemDifficultyDown.onClick = _ -> incrementDifficulty(-1);
menubarItemPlaytestStartTime.onChange = event -> playtestStartTime = event.value;
menubarItemPlaytestStartTime.selected = playtestStartTime;
menuBarItemThemeLight.onChange = function(event:UIEvent) {
if (event.target.value) currentTheme = ChartEditorTheme.Light;
};
@ -2544,6 +2547,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
menubarItemToggleToolboxMetadata.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_METADATA_LAYOUT, event.value);
menubarItemToggleToolboxNotes.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_NOTEDATA_LAYOUT, event.value);
menubarItemToggleToolboxEvents.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_EVENTDATA_LAYOUT, event.value);
menubarItemToggleToolboxPlaytestProperties.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_PLAYTEST_PROPERTIES_LAYOUT, event.value);
menubarItemToggleToolboxPlayerPreview.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_PLAYER_PREVIEW_LAYOUT, event.value);
menubarItemToggleToolboxOpponentPreview.onChange = event -> this.setToolboxState(CHART_EDITOR_TOOLBOX_OPPONENT_PREVIEW_LAYOUT, event.value);
@ -3430,7 +3434,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
{
gridPlayheadScrollAreaPressed = true;
}
else if (notePreview != null && FlxG.mouse.overlaps(notePreview))
else if (notePreview != null && !isCursorOverHaxeUI && FlxG.mouse.overlaps(notePreview))
{
// Clicked note preview
notePreviewScrollAreaStartPos = new FlxPoint(FlxG.mouse.screenX, FlxG.mouse.screenY);
@ -3882,7 +3886,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
if (FlxG.mouse.justPressed)
{
// Just clicked to place a note.
if (overlapsGrid && !overlapsSelectionBorder)
if (!isCursorOverHaxeUI && overlapsGrid && !overlapsSelectionBorder)
{
// We clicked on the grid without moving the mouse.
@ -4027,7 +4031,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
var isOrWillSelect = overlapsSelection || dragTargetNote != null || dragTargetEvent != null;
// Handle grid cursor.
if (overlapsGrid && !isOrWillSelect && !overlapsSelectionBorder && !gridPlayheadScrollAreaPressed)
if (!isCursorOverHaxeUI && overlapsGrid && !isOrWillSelect && !overlapsSelectionBorder && !gridPlayheadScrollAreaPressed)
{
// Indicate that we can place a note here.
@ -4097,6 +4101,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
}
}
else
{
if (!isCursorOverHaxeUI)
{
if (notePreview != null && FlxG.mouse.overlaps(notePreview))
{
@ -4120,6 +4126,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
}
}
}
}
// Actually set the cursor mode to the one we specified earlier.
Cursor.cursorMode = targetCursorMode ?? Default;
@ -4733,7 +4740,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
targetDifficulty: selectedDifficulty,
// TODO: Add this.
// targetCharacter: targetCharacter,
practiceMode: true,
practiceMode: playtestPracticeMode,
minimalMode: minimal,
startTimestamp: startTimestamp,
overrideMusic: true,

View file

@ -80,6 +80,8 @@ class ChartEditorToolboxHandler
onShowToolboxNoteData(state, toolbox);
case ChartEditorState.CHART_EDITOR_TOOLBOX_EVENTDATA_LAYOUT:
onShowToolboxEventData(state, toolbox);
case ChartEditorState.CHART_EDITOR_TOOLBOX_PLAYTEST_PROPERTIES_LAYOUT:
onShowToolboxPlaytestProperties(state, toolbox);
case ChartEditorState.CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT:
onShowToolboxDifficulty(state, toolbox);
case ChartEditorState.CHART_EDITOR_TOOLBOX_METADATA_LAYOUT:
@ -117,6 +119,8 @@ class ChartEditorToolboxHandler
onHideToolboxNoteData(state, toolbox);
case ChartEditorState.CHART_EDITOR_TOOLBOX_EVENTDATA_LAYOUT:
onHideToolboxEventData(state, toolbox);
case ChartEditorState.CHART_EDITOR_TOOLBOX_PLAYTEST_PROPERTIES_LAYOUT:
onHideToolboxPlaytestProperties(state, toolbox);
case ChartEditorState.CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT:
onHideToolboxDifficulty(state, toolbox);
case ChartEditorState.CHART_EDITOR_TOOLBOX_METADATA_LAYOUT:
@ -175,6 +179,8 @@ class ChartEditorToolboxHandler
toolbox = buildToolboxNoteDataLayout(state);
case ChartEditorState.CHART_EDITOR_TOOLBOX_EVENTDATA_LAYOUT:
toolbox = buildToolboxEventDataLayout(state);
case ChartEditorState.CHART_EDITOR_TOOLBOX_PLAYTEST_PROPERTIES_LAYOUT:
toolbox = buildToolboxPlaytestPropertiesLayout(state);
case ChartEditorState.CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT:
toolbox = buildToolboxDifficultyLayout(state);
case ChartEditorState.CHART_EDITOR_TOOLBOX_METADATA_LAYOUT:
@ -321,8 +327,12 @@ class ChartEditorToolboxHandler
static function onShowToolboxEventData(state:ChartEditorState, toolbox:CollapsibleDialog):Void {}
static function onShowToolboxPlaytestProperties(state:ChartEditorState, toolbox:CollapsibleDialog):Void {}
static function onHideToolboxEventData(state:ChartEditorState, toolbox:CollapsibleDialog):Void {}
static function onHideToolboxPlaytestProperties(state:ChartEditorState, toolbox:CollapsibleDialog):Void {}
static function buildEventDataFormFromSchema(state:ChartEditorState, target:Box, schema:SongEventSchema):Void
{
trace(schema);
@ -418,6 +428,39 @@ class ChartEditorToolboxHandler
}
}
static function buildToolboxPlaytestPropertiesLayout(state:ChartEditorState):Null<CollapsibleDialog>
{
// fill with playtest properties
var toolbox:CollapsibleDialog = cast RuntimeComponentBuilder.fromAsset(ChartEditorState.CHART_EDITOR_TOOLBOX_PLAYTEST_PROPERTIES_LAYOUT);
if (toolbox == null) return null;
toolbox.onDialogClosed = function(_) {
state.menubarItemToggleToolboxPlaytestProperties.selected = false;
}
var checkboxPracticeMode:Null<CheckBox> = toolbox.findComponent('practiceModeCheckbox', CheckBox);
if (checkboxPracticeMode == null) throw 'ChartEditorToolboxHandler.buildToolboxPlaytestPropertiesLayout() - Could not find practiceModeCheckbox component.';
checkboxPracticeMode.selected = state.playtestPracticeMode;
checkboxPracticeMode.onClick = _ -> {
state.playtestPracticeMode = checkboxPracticeMode.selected;
};
var checkboxStartTime:Null<CheckBox> = toolbox.findComponent('playtestStartTimeCheckbox', CheckBox);
if (checkboxStartTime == null)
throw 'ChartEditorToolboxHandler.buildToolboxPlaytestPropertiesLayout() - Could not find playtestStartTimeCheckbox component.';
checkboxStartTime.selected = state.playtestStartTime;
checkboxStartTime.onClick = _ -> {
state.playtestStartTime = checkboxStartTime.selected;
};
return toolbox;
}
static function buildToolboxDifficultyLayout(state:ChartEditorState):Null<CollapsibleDialog>
{
var toolbox:CollapsibleDialog = cast RuntimeComponentBuilder.fromAsset(ChartEditorState.CHART_EDITOR_TOOLBOX_DIFFICULTY_LAYOUT);