1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-15 11:22:55 +00:00

allow controls to get dialouge name from control + ignore brackets

This commit is contained in:
FabsTheFabs 2024-09-12 22:44:22 +01:00
parent bfb19cc67e
commit 5f60be6d75

View file

@ -395,20 +395,37 @@ class Controls extends FlxActionSet
return result; return result;
} }
public function getDialogueName(action:FlxActionDigital):String public function getDialogueName(action:FlxActionDigital, ?ignoreSurrounding:Bool = false):String
{ {
var input = action.inputs[0]; var input = action.inputs[0];
return switch (input.device) if (ignoreSurrounding == false)
{ {
case KEYBOARD: return '[${(input.inputID : FlxKey)}]'; return switch (input.device)
case GAMEPAD: return '(${(input.inputID : FlxGamepadInputID)})'; {
case device: throw 'unhandled device: $device'; case KEYBOARD: return '[${(input.inputID : FlxKey)}]';
case GAMEPAD: return '(${(input.inputID : FlxGamepadInputID)})';
case device: throw 'unhandled device: $device';
}
}
else
{
return switch (input.device)
{
case KEYBOARD: return '${(input.inputID : FlxKey)}';
case GAMEPAD: return '${(input.inputID : FlxGamepadInputID)}';
case device: throw 'unhandled device: $device';
}
} }
} }
public function getDialogueNameFromToken(token:String):String public function getDialogueNameFromToken(token:String, ?ignoreSurrounding:Bool = false):String
{ {
return getDialogueName(getActionFromControl(Control.createByName(token.toUpperCase()))); return getDialogueName(getActionFromControl(Control.createByName(token.toUpperCase())), ignoreSurrounding);
}
public function getDialogueNameFromControl(control:Control, ?ignoreSurrounding:Bool = false):String
{
return getDialogueName(getActionFromControl(control), ignoreSurrounding);
} }
function getActionFromControl(control:Control):FlxActionDigital function getActionFromControl(control:Control):FlxActionDigital