New chart event: Set the character's health icon.
This commit is contained in:
committed by
Cameron Taylor
parent
7c9f048776
commit
7231b3f645
@@ -889,6 +889,10 @@ class PlayState extends MusicBeatSubState
|
||||
Highscore.tallies.combo = 0;
|
||||
Countdown.performCountdown();
|
||||
|
||||
// Reset the health icons.
|
||||
currentStage.getBoyfriend().initHealthIcon(false);
|
||||
currentStage.getDad().initHealthIcon(true);
|
||||
|
||||
needsReset = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
package funkin.play.event;
|
||||
|
||||
// TODO: Add a song event which switches characters.
|
||||
@@ -0,0 +1,117 @@
|
||||
package funkin.play.event;
|
||||
|
||||
import funkin.data.event.SongEventSchema;
|
||||
import funkin.play.character.CharacterData.HealthIconData;
|
||||
import funkin.data.song.SongData;
|
||||
import funkin.data.song.SongData.SongEventData;
|
||||
|
||||
/**
|
||||
* This class represents a handler for scroll speed events.
|
||||
*
|
||||
* Example: Set the health icon of Boyfriend to "bf-pixel":
|
||||
* ```
|
||||
* {
|
||||
* 'e': 'SetHealthIcon',
|
||||
* "v": {
|
||||
* "char": 0,
|
||||
* "id": "bf-pixel",
|
||||
* "scale": 1.0,
|
||||
* "flipX": false,
|
||||
* "isPixel": false,
|
||||
* "offsetX": 0.0,
|
||||
* "offsetY": 0.0
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
class SetHealthIconSongEvent extends SongEvent
|
||||
{
|
||||
public function new()
|
||||
{
|
||||
super('SetHealthIcon');
|
||||
}
|
||||
|
||||
public override function handleEvent(data:SongEventData):Void
|
||||
{
|
||||
// Does nothing if there is no PlayState.
|
||||
if (PlayState.instance == null) return;
|
||||
|
||||
// Works even if we are minimal mode.
|
||||
// if (PlayState.instance.isMinimalMode) return;
|
||||
|
||||
var offsets:Array<Float> = [data.value.offsetX ?? 0.0, data.value.offsetY ?? 0.0];
|
||||
|
||||
var healthIconData:HealthIconData =
|
||||
{
|
||||
id: data.value.id ?? "bf",
|
||||
scale: data.value.scale ?? 1.0,
|
||||
flipX: data.value.flipX ?? false,
|
||||
isPixel: data.value.isPixel ?? false,
|
||||
offsets: offsets,
|
||||
};
|
||||
|
||||
switch (data?.value?.char ?? 0)
|
||||
{
|
||||
case 0:
|
||||
PlayState.instance.iconP1.configure(healthIconData);
|
||||
case 1:
|
||||
PlayState.instance.iconP2.configure(healthIconData);
|
||||
default:
|
||||
trace('[WARN] Unknown character index: ' + data.value.char);
|
||||
}
|
||||
}
|
||||
|
||||
public override function getTitle():String
|
||||
{
|
||||
return 'Set Health Icon';
|
||||
}
|
||||
|
||||
public override function getEventSchema():SongEventSchema
|
||||
{
|
||||
return new SongEventSchema([
|
||||
{
|
||||
name: 'char',
|
||||
title: 'Character',
|
||||
defaultValue: 0,
|
||||
type: SongEventFieldType.ENUM,
|
||||
keys: ['Player' => 0, 'Opponent' => 1],
|
||||
},
|
||||
{
|
||||
name: 'id',
|
||||
title: 'Health Icon ID',
|
||||
defaultValue: 'bf',
|
||||
type: SongEventFieldType.STRING,
|
||||
},
|
||||
{
|
||||
name: 'scale',
|
||||
title: 'Scale',
|
||||
defaultValue: 1.0,
|
||||
type: SongEventFieldType.FLOAT,
|
||||
},
|
||||
{
|
||||
name: 'flipX',
|
||||
title: 'Flip X?',
|
||||
defaultValue: false,
|
||||
type: SongEventFieldType.BOOL,
|
||||
},
|
||||
{
|
||||
name: 'isPixel',
|
||||
title: 'Is Pixel?',
|
||||
defaultValue: false,
|
||||
type: SongEventFieldType.BOOL,
|
||||
},
|
||||
{
|
||||
name: 'offsetX',
|
||||
title: 'X Offset',
|
||||
defaultValue: 0,
|
||||
type: SongEventFieldType.FLOAT,
|
||||
},
|
||||
{
|
||||
name: 'offsetY',
|
||||
title: 'Y Offset',
|
||||
defaultValue: 0,
|
||||
type: SongEventFieldType.FLOAT,
|
||||
}
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package funkin.play.event;
|
||||
|
||||
// TODO: Add a song event which switches stages.
|
||||
@@ -49,9 +49,14 @@ class ChartEditorEventDataToolbox extends ChartEditorBaseToolbox
|
||||
function initialize():Void
|
||||
{
|
||||
toolboxEventsEventKind.onChange = function(event:UIEvent) {
|
||||
if (event.data == null)
|
||||
{
|
||||
trace('ChartEditorEventDataToolbox: Event data is null');
|
||||
}
|
||||
|
||||
var eventType:String = event.data.id;
|
||||
|
||||
trace('ChartEditorToolboxHandler.buildToolboxEventDataLayout() - Event type changed: $eventType');
|
||||
trace('ChartEditorEventDataToolbox - Event type changed: $eventType');
|
||||
|
||||
// Edit the event data to place.
|
||||
chartEditorState.eventKindToPlace = eventType;
|
||||
@@ -60,7 +65,7 @@ class ChartEditorEventDataToolbox extends ChartEditorBaseToolbox
|
||||
|
||||
if (schema == null)
|
||||
{
|
||||
trace('ChartEditorToolboxHandler.buildToolboxEventDataLayout() - Unknown event kind: $eventType');
|
||||
trace('ChartEditorEventDataToolbox - Unknown event kind: $eventType');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -80,7 +85,7 @@ class ChartEditorEventDataToolbox extends ChartEditorBaseToolbox
|
||||
}
|
||||
}
|
||||
var startingEventValue = ChartEditorDropdowns.populateDropdownWithSongEvents(toolboxEventsEventKind, chartEditorState.eventKindToPlace);
|
||||
trace('ChartEditorToolboxHandler.buildToolboxEventDataLayout() - Starting event kind: ${startingEventValue}');
|
||||
trace('ChartEditorEventDataToolbox - Starting event kind: ${startingEventValue}');
|
||||
toolboxEventsEventKind.value = startingEventValue;
|
||||
}
|
||||
|
||||
@@ -92,7 +97,7 @@ class ChartEditorEventDataToolbox extends ChartEditorBaseToolbox
|
||||
|
||||
if (newDropdownElement == null)
|
||||
{
|
||||
throw 'ChartEditorToolboxHandler.buildToolboxEventDataLayout() - Event kind not in dropdown: ${chartEditorState.eventKindToPlace}';
|
||||
throw 'ChartEditorEventDataToolbox - Event kind not in dropdown: ${chartEditorState.eventKindToPlace}';
|
||||
}
|
||||
else if (toolboxEventsEventKind.value != newDropdownElement || lastEventKind != toolboxEventsEventKind.value.id)
|
||||
{
|
||||
@@ -101,17 +106,17 @@ class ChartEditorEventDataToolbox extends ChartEditorBaseToolbox
|
||||
var schema:SongEventSchema = SongEventRegistry.getEventSchema(chartEditorState.eventKindToPlace);
|
||||
if (schema == null)
|
||||
{
|
||||
trace('ChartEditorToolboxHandler.buildToolboxEventDataLayout() - Unknown event kind: ${chartEditorState.eventKindToPlace}');
|
||||
trace('ChartEditorEventDataToolbox - Unknown event kind: ${chartEditorState.eventKindToPlace}');
|
||||
}
|
||||
else
|
||||
{
|
||||
trace('ChartEditorToolboxHandler.buildToolboxEventDataLayout() - Event kind changed: ${toolboxEventsEventKind.value.id} != ${newDropdownElement.id} != ${lastEventKind}, rebuilding form');
|
||||
trace('ChartEditorEventDataToolbox - Event kind changed: ${toolboxEventsEventKind.value.id} != ${newDropdownElement.id} != ${lastEventKind}, rebuilding form');
|
||||
buildEventDataFormFromSchema(toolboxEventsDataGrid, schema, chartEditorState.eventKindToPlace);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
trace('ChartEditorToolboxHandler.buildToolboxEventDataLayout() - Event kind not changed: ${toolboxEventsEventKind.value} == ${newDropdownElement} == ${lastEventKind}');
|
||||
trace('ChartEditorEventDataToolbox - Event kind not changed: ${toolboxEventsEventKind.value} == ${newDropdownElement} == ${lastEventKind}');
|
||||
}
|
||||
|
||||
for (pair in chartEditorState.eventDataToPlace.keyValueIterator())
|
||||
@@ -123,7 +128,7 @@ class ChartEditorEventDataToolbox extends ChartEditorBaseToolbox
|
||||
|
||||
if (field == null)
|
||||
{
|
||||
throw 'ChartEditorToolboxHandler.refresh() - Field "${fieldId}" does not exist in the event data form for kind ${lastEventKind}.';
|
||||
throw 'ChartEditorEventDataToolbox - Field "${fieldId}" does not exist in the event data form for kind ${lastEventKind}.';
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -142,7 +147,7 @@ class ChartEditorEventDataToolbox extends ChartEditorBaseToolbox
|
||||
var textField:TextField = cast field;
|
||||
textField.text = value;
|
||||
default:
|
||||
throw 'ChartEditorToolboxHandler.refresh() - Field "${fieldId}" is of unknown type "${Type.getClassName(Type.getClass(field))}".';
|
||||
throw 'ChartEditorEventDataToolbox - Field "${fieldId}" is of unknown type "${Type.getClassName(Type.getClass(field))}".';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user