refactor: Update renderer mode enum and input key handling for improved clarity
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -12,6 +12,43 @@ import 'package:wolf_3d_dart/wolf_3d_input.dart';
|
||||
|
||||
/// Translates Flutter keyboard and mouse state into engine-friendly actions.
|
||||
class Wolf3dFlutterInput extends Wolf3dInput {
|
||||
/// Keyboard shortcut used by the Flutter host to cycle renderer modes.
|
||||
LogicalKeyboardKey rendererToggleKey = LogicalKeyboardKey.keyR;
|
||||
|
||||
/// Keyboard shortcut used by the Flutter host to cycle ASCII themes.
|
||||
LogicalKeyboardKey asciiThemeCycleKey = LogicalKeyboardKey.keyT;
|
||||
|
||||
/// Keyboard shortcut used by the Flutter host to toggle the FPS counter.
|
||||
LogicalKeyboardKey fpsToggleKey = LogicalKeyboardKey.backquote;
|
||||
|
||||
/// Human-friendly label for [rendererToggleKey] shown in on-screen hints.
|
||||
String get rendererToggleKeyLabel => _formatShortcutLabel(rendererToggleKey);
|
||||
|
||||
/// Human-friendly label for [asciiThemeCycleKey] shown in on-screen hints.
|
||||
String get asciiThemeCycleKeyLabel =>
|
||||
_formatShortcutLabel(asciiThemeCycleKey);
|
||||
|
||||
/// Human-friendly label for [fpsToggleKey] shown in on-screen hints.
|
||||
String get fpsToggleKeyLabel => _formatShortcutLabel(fpsToggleKey);
|
||||
|
||||
String _formatShortcutLabel(LogicalKeyboardKey key) {
|
||||
if (key == LogicalKeyboardKey.space) {
|
||||
return 'SPACE';
|
||||
}
|
||||
if (key == LogicalKeyboardKey.tab) {
|
||||
return 'TAB';
|
||||
}
|
||||
final label = key.keyLabel;
|
||||
if (label.isNotEmpty) {
|
||||
return label.toUpperCase();
|
||||
}
|
||||
final debugName = key.debugName;
|
||||
if (debugName == null || debugName.isEmpty) {
|
||||
return 'KEY';
|
||||
}
|
||||
return debugName.replaceFirst('Logical Keyboard Key ', '').toUpperCase();
|
||||
}
|
||||
|
||||
/// Mapping from logical game actions to one or more keyboard bindings.
|
||||
///
|
||||
/// Each action can be rebound by replacing the matching set. The defaults
|
||||
|
||||
Reference in New Issue
Block a user