2023-10-31 19:30:47 +00:00
|
|
|
package funkin.ui.options;
|
2021-02-24 00:59:36 +00:00
|
|
|
|
2023-11-07 09:04:22 +00:00
|
|
|
import funkin.util.InputUtil;
|
2021-02-24 00:59:36 +00:00
|
|
|
import flixel.FlxCamera;
|
|
|
|
import flixel.FlxObject;
|
|
|
|
import flixel.FlxSprite;
|
2024-02-13 06:38:11 +00:00
|
|
|
import funkin.graphics.FunkinCamera;
|
2021-02-24 00:59:36 +00:00
|
|
|
import flixel.group.FlxGroup;
|
2021-04-04 17:17:46 +00:00
|
|
|
import flixel.input.actions.FlxActionInput;
|
|
|
|
import flixel.input.gamepad.FlxGamepadInputID;
|
2021-02-24 00:59:36 +00:00
|
|
|
import flixel.input.keyboard.FlxKey;
|
2024-01-16 21:49:15 +00:00
|
|
|
import funkin.graphics.FunkinSprite;
|
2023-10-31 19:30:47 +00:00
|
|
|
import funkin.input.Controls;
|
2022-03-08 08:13:53 +00:00
|
|
|
import funkin.ui.AtlasText;
|
|
|
|
import funkin.ui.MenuList;
|
|
|
|
import funkin.ui.TextMenuList;
|
2021-02-24 00:59:36 +00:00
|
|
|
|
2023-10-31 19:30:47 +00:00
|
|
|
class ControlsMenu extends funkin.ui.options.OptionsState.Page
|
2021-02-24 00:59:36 +00:00
|
|
|
{
|
2023-06-15 04:28:40 +00:00
|
|
|
public static inline final COLUMNS = 2;
|
2023-01-23 03:25:45 +00:00
|
|
|
static var controlList = Control.createAll();
|
|
|
|
/*
|
|
|
|
* Defines groups of controls that cannot share inputs, like left and right. Say, if ACCEPT is Z, Back is X,
|
|
|
|
* if the player sets Back to Z it also set ACCEPT to X. This prevents the player from setting the controls in
|
|
|
|
* a way the prevents them from changing more controls or exiting the menu.
|
|
|
|
*/
|
|
|
|
static var controlGroups:Array<Array<Control>> = [
|
|
|
|
[NOTE_UP, NOTE_DOWN, NOTE_LEFT, NOTE_RIGHT],
|
2023-06-15 04:28:40 +00:00
|
|
|
[UI_UP, UI_DOWN, UI_LEFT, UI_RIGHT, ACCEPT, BACK],
|
2024-02-28 05:19:08 +00:00
|
|
|
[CUTSCENE_ADVANCE],
|
2023-11-16 05:02:42 +00:00
|
|
|
[VOLUME_UP, VOLUME_DOWN, VOLUME_MUTE],
|
|
|
|
[DEBUG_MENU, DEBUG_CHART]
|
2023-01-23 03:25:45 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
var itemGroups:Array<Array<InputItem>> = [for (i in 0...controlGroups.length) []];
|
|
|
|
|
|
|
|
var controlGrid:MenuTypedList<InputItem>;
|
|
|
|
var deviceList:TextMenuList;
|
|
|
|
var menuCamera:FlxCamera;
|
|
|
|
var prompt:Prompt;
|
|
|
|
var camFollow:FlxObject;
|
|
|
|
var labels:FlxTypedGroup<AtlasText>;
|
|
|
|
|
|
|
|
var currentDevice:Device = Keys;
|
2023-06-15 04:28:40 +00:00
|
|
|
var deviceListSelected:Bool = false;
|
2023-01-23 03:25:45 +00:00
|
|
|
|
|
|
|
public function new()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
|
2024-02-13 06:38:11 +00:00
|
|
|
menuCamera = new FunkinCamera();
|
2023-01-23 03:25:45 +00:00
|
|
|
FlxG.cameras.add(menuCamera, false);
|
|
|
|
menuCamera.bgColor = 0x0;
|
|
|
|
camera = menuCamera;
|
|
|
|
|
|
|
|
labels = new FlxTypedGroup<AtlasText>();
|
2023-06-15 04:28:40 +00:00
|
|
|
var headers:FlxTypedGroup<AtlasText> = new FlxTypedGroup<AtlasText>();
|
2023-01-23 03:25:45 +00:00
|
|
|
controlGrid = new MenuTypedList(Columns(COLUMNS), Vertical);
|
|
|
|
|
|
|
|
add(labels);
|
|
|
|
add(headers);
|
|
|
|
add(controlGrid);
|
|
|
|
|
|
|
|
if (FlxG.gamepads.numActiveGamepads > 0)
|
|
|
|
{
|
2024-01-16 21:49:15 +00:00
|
|
|
var devicesBg:FunkinSprite = new FunkinSprite();
|
|
|
|
devicesBg.makeSolidColor(FlxG.width, 100, 0xFFFAFD6D);
|
2023-01-23 03:25:45 +00:00
|
|
|
add(devicesBg);
|
|
|
|
deviceList = new TextMenuList(Horizontal, None);
|
|
|
|
add(deviceList);
|
|
|
|
deviceListSelected = true;
|
|
|
|
|
2023-06-15 04:28:40 +00:00
|
|
|
var item:TextMenuItem;
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2023-06-15 04:28:40 +00:00
|
|
|
item = deviceList.createItem('Keyboard', AtlasFont.BOLD, selectDevice.bind(Keys));
|
2023-01-23 03:25:45 +00:00
|
|
|
item.x = FlxG.width / 2 - item.width - 30;
|
|
|
|
item.y = (devicesBg.height - item.height) / 2;
|
|
|
|
|
2023-06-15 04:28:40 +00:00
|
|
|
item = deviceList.createItem('Gamepad', AtlasFont.BOLD, selectDevice.bind(Gamepad(FlxG.gamepads.firstActive.id)));
|
2023-01-23 03:25:45 +00:00
|
|
|
item.x = FlxG.width / 2 + 30;
|
|
|
|
item.y = (devicesBg.height - item.height) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FlxG.debugger.drawDebug = true;
|
|
|
|
var y = deviceList == null ? 30 : 120;
|
|
|
|
var spacer = 70;
|
|
|
|
var currentHeader:String = null;
|
|
|
|
// list order is determined by enum order
|
|
|
|
for (i in 0...controlList.length)
|
|
|
|
{
|
|
|
|
var control = controlList[i];
|
|
|
|
var name = control.getName();
|
|
|
|
if (currentHeader != "UI_" && name.indexOf("UI_") == 0)
|
|
|
|
{
|
|
|
|
currentHeader = "UI_";
|
|
|
|
headers.add(new AtlasText(0, y, "UI", AtlasFont.BOLD)).screenCenter(X);
|
|
|
|
y += spacer;
|
|
|
|
}
|
|
|
|
else if (currentHeader != "NOTE_" && name.indexOf("NOTE_") == 0)
|
|
|
|
{
|
|
|
|
currentHeader = "NOTE_";
|
|
|
|
headers.add(new AtlasText(0, y, "NOTES", AtlasFont.BOLD)).screenCenter(X);
|
|
|
|
y += spacer;
|
|
|
|
}
|
2023-06-15 04:28:40 +00:00
|
|
|
else if (currentHeader != "CUTSCENE_" && name.indexOf("CUTSCENE_") == 0)
|
|
|
|
{
|
|
|
|
currentHeader = "CUTSCENE_";
|
|
|
|
headers.add(new AtlasText(0, y, "CUTSCENE", AtlasFont.BOLD)).screenCenter(X);
|
|
|
|
y += spacer;
|
|
|
|
}
|
|
|
|
else if (currentHeader != "VOLUME_" && name.indexOf("VOLUME_") == 0)
|
|
|
|
{
|
|
|
|
currentHeader = "VOLUME_";
|
|
|
|
headers.add(new AtlasText(0, y, "VOLUME", AtlasFont.BOLD)).screenCenter(X);
|
|
|
|
y += spacer;
|
|
|
|
}
|
2023-11-16 05:02:42 +00:00
|
|
|
else if (currentHeader != "DEBUG_" && name.indexOf("DEBUG_") == 0)
|
|
|
|
{
|
|
|
|
currentHeader = "DEBUG_";
|
|
|
|
headers.add(new AtlasText(0, y, "DEBUG", AtlasFont.BOLD)).screenCenter(X);
|
|
|
|
y += spacer;
|
|
|
|
}
|
2023-01-23 03:25:45 +00:00
|
|
|
|
|
|
|
if (currentHeader != null && name.indexOf(currentHeader) == 0) name = name.substr(currentHeader.length);
|
|
|
|
|
|
|
|
var label = labels.add(new AtlasText(150, y, name, AtlasFont.BOLD));
|
|
|
|
label.alpha = 0.6;
|
|
|
|
for (i in 0...COLUMNS)
|
|
|
|
createItem(label.x + 400 + i * 300, y, control, i);
|
|
|
|
|
|
|
|
y += spacer;
|
|
|
|
}
|
|
|
|
|
|
|
|
camFollow = new FlxObject(FlxG.width / 2, 0, 70, 70);
|
|
|
|
if (deviceList != null)
|
|
|
|
{
|
|
|
|
camFollow.y = deviceList.selectedItem.y;
|
|
|
|
controlGrid.selectedItem.idle();
|
|
|
|
controlGrid.enabled = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
camFollow.y = controlGrid.selectedItem.y;
|
|
|
|
|
|
|
|
menuCamera.follow(camFollow, null, 0.06);
|
|
|
|
var margin = 100;
|
|
|
|
menuCamera.deadzone.set(0, margin, menuCamera.width, menuCamera.height - margin * 2);
|
|
|
|
menuCamera.minScrollY = 0;
|
2023-06-08 20:30:45 +00:00
|
|
|
controlGrid.onChange.add(function(selected) {
|
2023-01-23 03:25:45 +00:00
|
|
|
camFollow.y = selected.y;
|
|
|
|
|
|
|
|
labels.forEach((label) -> label.alpha = 0.6);
|
|
|
|
labels.members[Std.int(controlGrid.selectedIndex / COLUMNS)].alpha = 1.0;
|
|
|
|
});
|
|
|
|
|
2023-06-15 04:28:40 +00:00
|
|
|
prompt = new Prompt("\nPress any key to rebind\n\n\nBackspace to unbind\n Escape to cancel", None);
|
2023-01-23 03:25:45 +00:00
|
|
|
prompt.create();
|
|
|
|
prompt.createBgFromMargin(100, 0xFFfafd6d);
|
|
|
|
prompt.back.scrollFactor.set(0, 0);
|
|
|
|
prompt.exists = false;
|
|
|
|
add(prompt);
|
|
|
|
}
|
|
|
|
|
|
|
|
function createItem(x = 0.0, y = 0.0, control:Control, index:Int)
|
|
|
|
{
|
|
|
|
var item = new InputItem(x, y, currentDevice, control, index, onSelect);
|
|
|
|
for (i in 0...controlGroups.length)
|
|
|
|
{
|
|
|
|
if (controlGroups[i].contains(control)) itemGroups[i].push(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return controlGrid.addItem(item.name, item);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onSelect():Void
|
|
|
|
{
|
2023-10-17 04:38:28 +00:00
|
|
|
switch (currentDevice)
|
|
|
|
{
|
|
|
|
case Keys:
|
|
|
|
{
|
|
|
|
keyUsedToEnterPrompt = FlxG.keys.firstJustPressed();
|
|
|
|
}
|
|
|
|
case Gamepad(id):
|
|
|
|
{
|
|
|
|
buttonUsedToEnterPrompt = FlxG.gamepads.getByID(id).firstJustPressedID();
|
|
|
|
}
|
|
|
|
}
|
2023-06-15 04:28:40 +00:00
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
controlGrid.enabled = false;
|
|
|
|
canExit = false;
|
|
|
|
prompt.exists = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function goToDeviceList()
|
|
|
|
{
|
|
|
|
controlGrid.selectedItem.idle();
|
|
|
|
labels.members[Std.int(controlGrid.selectedIndex / COLUMNS)].alpha = 0.6;
|
|
|
|
controlGrid.enabled = false;
|
|
|
|
deviceList.enabled = true;
|
|
|
|
canExit = true;
|
|
|
|
camFollow.y = deviceList.selectedItem.y;
|
|
|
|
deviceListSelected = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function selectDevice(device:Device)
|
|
|
|
{
|
|
|
|
currentDevice = device;
|
|
|
|
|
|
|
|
for (item in controlGrid.members)
|
|
|
|
item.updateDevice(currentDevice);
|
|
|
|
|
|
|
|
var inputName = device == Keys ? "key" : "button";
|
|
|
|
var cancel = device == Keys ? "Escape" : "Back";
|
|
|
|
// todo: alignment
|
|
|
|
if (device == Keys) prompt.setText('\nPress any key to rebind\n\n\n\n $cancel to cancel');
|
|
|
|
else
|
|
|
|
prompt.setText('\nPress any button\n to rebind\n\n\n $cancel to cancel');
|
|
|
|
|
|
|
|
controlGrid.selectedItem.select();
|
|
|
|
labels.members[Std.int(controlGrid.selectedIndex / COLUMNS)].alpha = 1.0;
|
|
|
|
controlGrid.enabled = true;
|
|
|
|
deviceList.enabled = false;
|
|
|
|
deviceListSelected = false;
|
|
|
|
canExit = false;
|
|
|
|
}
|
|
|
|
|
2023-06-15 04:28:40 +00:00
|
|
|
var keyUsedToEnterPrompt:Null<Int> = null;
|
2023-10-17 04:38:28 +00:00
|
|
|
var buttonUsedToEnterPrompt:Null<Int> = null;
|
2023-06-15 04:28:40 +00:00
|
|
|
|
|
|
|
override function update(elapsed:Float):Void
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
|
|
|
super.update(elapsed);
|
|
|
|
|
|
|
|
var controls = PlayerSettings.player1.controls;
|
|
|
|
if (controlGrid.enabled && deviceList != null && deviceListSelected == false && controls.BACK) goToDeviceList();
|
|
|
|
|
|
|
|
if (prompt.exists)
|
|
|
|
{
|
|
|
|
switch (currentDevice)
|
|
|
|
{
|
|
|
|
case Keys:
|
|
|
|
{
|
2023-06-15 04:28:40 +00:00
|
|
|
// Um?
|
|
|
|
// Checking pressed causes problems when you change the BACK key,
|
|
|
|
// but checking released causes problems when the prompt is instant.
|
|
|
|
|
|
|
|
// keyUsedToEnterPrompt is my weird workaround.
|
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
var key = FlxG.keys.firstJustReleased();
|
2023-06-15 04:28:40 +00:00
|
|
|
if (key != NONE && key != keyUsedToEnterPrompt)
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
2023-06-15 04:28:40 +00:00
|
|
|
if (key == ESCAPE)
|
|
|
|
{
|
|
|
|
closePrompt();
|
|
|
|
}
|
|
|
|
else if (key == BACKSPACE)
|
|
|
|
{
|
|
|
|
onInputSelect(NONE);
|
|
|
|
closePrompt();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
onInputSelect(key);
|
|
|
|
closePrompt();
|
|
|
|
}
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case Gamepad(id):
|
|
|
|
{
|
|
|
|
var button = FlxG.gamepads.getByID(id).firstJustReleasedID();
|
2023-10-17 04:38:28 +00:00
|
|
|
if (button != NONE && button != buttonUsedToEnterPrompt)
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
|
|
|
if (button != BACK) onInputSelect(button);
|
|
|
|
closePrompt();
|
|
|
|
}
|
2023-10-17 04:38:28 +00:00
|
|
|
|
|
|
|
var key = FlxG.keys.firstJustReleased();
|
|
|
|
if (key != NONE && key != keyUsedToEnterPrompt)
|
|
|
|
{
|
|
|
|
if (key == ESCAPE)
|
|
|
|
{
|
|
|
|
closePrompt();
|
|
|
|
}
|
|
|
|
else if (key == BACKSPACE)
|
|
|
|
{
|
|
|
|
onInputSelect(NONE);
|
|
|
|
closePrompt();
|
|
|
|
}
|
|
|
|
}
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-06-15 04:28:40 +00:00
|
|
|
|
2023-10-17 04:38:28 +00:00
|
|
|
switch (currentDevice)
|
2023-06-15 04:28:40 +00:00
|
|
|
{
|
2023-10-17 04:38:28 +00:00
|
|
|
case Keys:
|
|
|
|
{
|
|
|
|
var keyJustReleased:Int = FlxG.keys.firstJustReleased();
|
|
|
|
if (keyJustReleased != NONE && keyJustReleased == keyUsedToEnterPrompt)
|
|
|
|
{
|
|
|
|
keyUsedToEnterPrompt = null;
|
|
|
|
}
|
|
|
|
buttonUsedToEnterPrompt = null;
|
|
|
|
}
|
|
|
|
case Gamepad(id):
|
|
|
|
{
|
|
|
|
var buttonJustReleased:Int = FlxG.gamepads.getByID(id).firstJustReleasedID();
|
|
|
|
if (buttonJustReleased != NONE && buttonJustReleased == buttonUsedToEnterPrompt)
|
|
|
|
{
|
|
|
|
buttonUsedToEnterPrompt = null;
|
|
|
|
}
|
|
|
|
keyUsedToEnterPrompt = null;
|
|
|
|
}
|
2023-06-15 04:28:40 +00:00
|
|
|
}
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
|
2023-06-15 04:28:40 +00:00
|
|
|
function onInputSelect(input:Int):Void
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
|
|
|
var item = controlGrid.selectedItem;
|
|
|
|
|
|
|
|
// check if that key is already set for this
|
2023-06-15 04:28:40 +00:00
|
|
|
if (input != FlxKey.NONE)
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
2023-06-15 04:28:40 +00:00
|
|
|
var column0 = Math.floor(controlGrid.selectedIndex / 2) * 2;
|
|
|
|
for (i in 0...COLUMNS)
|
|
|
|
{
|
|
|
|
if (controlGrid.members[column0 + i].input == input) return;
|
|
|
|
}
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check if items in the same group already have the new input
|
|
|
|
for (group in itemGroups)
|
|
|
|
{
|
2023-06-15 04:28:40 +00:00
|
|
|
if (input != FlxKey.NONE && group.contains(item))
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
|
|
|
for (otherItem in group)
|
|
|
|
{
|
|
|
|
if (otherItem != item && otherItem.input == input)
|
|
|
|
{
|
|
|
|
// replace that input with this items old input.
|
|
|
|
PlayerSettings.player1.controls.replaceBinding(otherItem.control, currentDevice, item.input, otherItem.input);
|
|
|
|
// Don't use resetItem() since items share names/labels
|
|
|
|
otherItem.input = item.input;
|
|
|
|
otherItem.label.text = item.label.text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayerSettings.player1.controls.replaceBinding(item.control, currentDevice, input, item.input);
|
2023-06-15 04:28:40 +00:00
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
// Don't use resetItem() since items share names/labels
|
|
|
|
item.input = input;
|
|
|
|
item.label.text = item.getLabel(input);
|
|
|
|
|
2023-06-15 04:28:40 +00:00
|
|
|
// Shift left on the grid if the item on the right is bound and the item on the left is unbound.
|
|
|
|
if (controlGrid.selectedIndex % 2 == 1)
|
|
|
|
{
|
|
|
|
trace('Modified item on right side of grid');
|
|
|
|
var leftItem = controlGrid.members[controlGrid.selectedIndex - 1];
|
|
|
|
if (leftItem != null && input != FlxKey.NONE && leftItem.input == FlxKey.NONE)
|
|
|
|
{
|
|
|
|
trace('Left item is unbound and right item is not!');
|
|
|
|
// Swap them.
|
|
|
|
var temp = leftItem.input;
|
|
|
|
leftItem.input = item.input;
|
|
|
|
item.input = temp;
|
|
|
|
|
|
|
|
leftItem.label.text = leftItem.getLabel(leftItem.input);
|
|
|
|
item.label.text = item.getLabel(item.input);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
trace('Modified item on left side of grid');
|
|
|
|
var rightItem = controlGrid.members[controlGrid.selectedIndex + 1];
|
|
|
|
if (rightItem != null && input == FlxKey.NONE && rightItem.input != FlxKey.NONE)
|
|
|
|
{
|
|
|
|
trace('Left item is unbound and right item is not!');
|
|
|
|
// Swap them.
|
|
|
|
var temp = item.input;
|
|
|
|
item.input = rightItem.input;
|
|
|
|
rightItem.input = temp;
|
|
|
|
|
|
|
|
item.label.text = item.getLabel(item.input);
|
|
|
|
rightItem.label.text = rightItem.getLabel(rightItem.input);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
PlayerSettings.player1.saveControls();
|
|
|
|
}
|
|
|
|
|
|
|
|
function closePrompt()
|
|
|
|
{
|
|
|
|
prompt.exists = false;
|
|
|
|
controlGrid.enabled = true;
|
|
|
|
if (deviceList == null) canExit = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
override function destroy()
|
|
|
|
{
|
|
|
|
super.destroy();
|
|
|
|
|
|
|
|
itemGroups = null;
|
|
|
|
|
|
|
|
if (FlxG.cameras.list.contains(menuCamera)) FlxG.cameras.remove(menuCamera);
|
|
|
|
}
|
|
|
|
|
|
|
|
override function set_enabled(value:Bool)
|
|
|
|
{
|
|
|
|
if (value == false)
|
|
|
|
{
|
|
|
|
controlGrid.enabled = false;
|
|
|
|
if (deviceList != null) deviceList.enabled = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
controlGrid.enabled = !deviceListSelected;
|
|
|
|
if (deviceList != null) deviceList.enabled = deviceListSelected;
|
|
|
|
}
|
|
|
|
return super.set_enabled(value);
|
|
|
|
}
|
2021-03-16 14:56:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class InputItem extends TextMenuItem
|
|
|
|
{
|
2023-01-23 03:25:45 +00:00
|
|
|
public var device(default, null):Device = Keys;
|
|
|
|
public var control:Control;
|
|
|
|
public var input:Int = -1;
|
|
|
|
public var index:Int = -1;
|
|
|
|
|
|
|
|
public function new(x = 0.0, y = 0.0, device, control, index, ?callback)
|
|
|
|
{
|
|
|
|
this.device = device;
|
|
|
|
this.control = control;
|
|
|
|
this.index = index;
|
|
|
|
this.input = getInput();
|
|
|
|
|
|
|
|
super(x, y, getLabel(input), DEFAULT, callback);
|
2023-06-15 04:28:40 +00:00
|
|
|
|
|
|
|
this.fireInstantly = true;
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function updateDevice(device:Device)
|
|
|
|
{
|
|
|
|
if (this.device != device)
|
|
|
|
{
|
|
|
|
this.device = device;
|
|
|
|
input = getInput();
|
|
|
|
label.text = getLabel(input);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getInput()
|
|
|
|
{
|
|
|
|
var list = PlayerSettings.player1.controls.getInputsFor(control, device);
|
|
|
|
if (list.length > index)
|
|
|
|
{
|
|
|
|
if (list[index] != FlxKey.ESCAPE || list[index] != FlxGamepadInputID.BACK) return list[index];
|
|
|
|
|
|
|
|
if (list.length > ControlsMenu.COLUMNS) // Escape isn't mappable, show a third option, instead.
|
|
|
|
return list[ControlsMenu.COLUMNS];
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLabel(input:Int)
|
|
|
|
{
|
2023-11-07 09:04:22 +00:00
|
|
|
return input == FlxKey.NONE ? "---" : InputUtil.format(input, device);
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
2021-04-04 17:17:46 +00:00
|
|
|
}
|