Editor constructor

Editor({
  1. required Game game,
  2. required void onDone(
    1. String value
    ),
  3. String text = '',
  4. void onCancel()?,
  5. String controllerAlphabet = 'abcdefghijklmnopqrstuvwxyz,.' '1234567890' r'!"£$%^&*(){}~\/' "-=_+@'",
  6. GameControllerButton leftButton = GameControllerButton.dpadLeft,
  7. GameControllerButton rightButton = GameControllerButton.dpadRight,
  8. GameControllerButton upButton = GameControllerButton.dpadUp,
  9. GameControllerButton downButton = GameControllerButton.dpadDown,
  10. GameControllerButton typeButton = GameControllerButton.rightshoulder,
  11. GameControllerButton shiftButton = GameControllerButton.a,
  12. ScanCode doneScanCode = ScanCode.return_,
  13. GameControllerButton doneButton = GameControllerButton.y,
  14. ScanCode cancelScanCode = ScanCode.escape,
  15. GameControllerButton cancelButton = GameControllerButton.leftshoulder,
  16. GameControllerButton spaceButton = GameControllerButton.b,
  17. ScanCode backspaceScanCode = ScanCode.backspace,
  18. GameControllerButton backspaceButton = GameControllerButton.x,
  19. GameControllerAxis upDownAxis = GameControllerAxis.lefty,
  20. GameControllerAxis leftRightAxis = GameControllerAxis.rightx,
  21. GameControllerAxis typeAxis = GameControllerAxis.triggerright,
  22. GameControllerAxis backspaceAxis = GameControllerAxis.triggerleft,
  23. int controllerMovementSpeed = 400,
  24. double controllerAxisSensitivity = 0.5,
  25. AssetReference? music,
  26. List<Ambiance>? ambiances,
  27. List<RandomSound>? randomSounds,
  28. Map<String, Command>? commands,
})

Create an instance.

The upDownAxis value decides which axis will call the moveUp and moveDown methods.

The leftRightAxis value decides which axis will call the moveLeft and moveRight methods.

The typeAxis value decides which axis will call the type method.

The backspaceAxis value decides which axis will call the backspace method.

The controllerAxisSensitivity value decides how sensitive the axis controls are.

The controllerMovementSpeed value decides how regularly axis controllers can be used.

The ambiances and randomSounds lists are passed directly to the Level constructor.

Implementation

Editor({
  required super.game,
  required this.onDone,
  this.text = '',
  this.onCancel,
  this.controllerAlphabet = 'abcdefghijklmnopqrstuvwxyz,.'
      '1234567890'
      r'!"£$%^&*(){}~\/'
      "-=_+@'",
  this.leftButton = GameControllerButton.dpadLeft,
  this.rightButton = GameControllerButton.dpadRight,
  this.upButton = GameControllerButton.dpadUp,
  this.downButton = GameControllerButton.dpadDown,
  this.typeButton = GameControllerButton.rightshoulder,
  this.shiftButton = GameControllerButton.a,
  this.doneScanCode = ScanCode.return_,
  this.doneButton = GameControllerButton.y,
  this.cancelScanCode = ScanCode.escape,
  this.cancelButton = GameControllerButton.leftshoulder,
  this.spaceButton = GameControllerButton.b,
  this.backspaceScanCode = ScanCode.backspace,
  this.backspaceButton = GameControllerButton.x,
  final GameControllerAxis upDownAxis = GameControllerAxis.lefty,
  final GameControllerAxis leftRightAxis = GameControllerAxis.rightx,
  final GameControllerAxis typeAxis = GameControllerAxis.triggerright,
  final GameControllerAxis backspaceAxis = GameControllerAxis.triggerleft,
  final int controllerMovementSpeed = 400,
  final double controllerAxisSensitivity = 0.5,
  super.music,
  super.ambiances,
  super.randomSounds,
  super.commands,
})  : _shiftPressed = false,
      _currentPosition = 0 {
  controllerAxisDispatcher = ControllerAxisDispatcher(
    {
      upDownAxis: (final value) {
        if (value > 0) {
          moveDown();
        } else {
          moveUp();
        }
      },
      leftRightAxis: (final value) {
        if (value > 0) {
          moveRight();
        } else {
          moveLeft();
        }
      },
      typeAxis: (final value) => type(),
      backspaceAxis: (final value) => backspace()
    },
    axisSensitivity: controllerAxisSensitivity,
    functionInterval: controllerMovementSpeed,
  );
}