Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzanardo committed Oct 24, 2024
1 parent 2f9fe8d commit d40e6e3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
12 changes: 8 additions & 4 deletions doc/bridge_packages/flame_console/flame_console.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ Widget build(BuildContext context) {

```dart
class MyCustomCommand extends ConsoleCommand<MyGame> {
MyCustomCommand() : super('my_command', 'Description of my command');
MyCustomCommand();
@override
String get name => 'my_command';
@override
String get description => 'Description of my command';
// The execute method is supposed to return a tuple where the first
// element is an error message in case of failure, and the second
Expand All @@ -82,9 +88,7 @@ ConsoleView(
onClose: () {
_game.overlays.remove('console');
},
customCommands: {
'custom_cmd': MyCustomCommand(),
},
customCommands: [MyCustomCommand()],
),
```

Expand Down
5 changes: 4 additions & 1 deletion packages/flame_console/lib/src/commands/pause_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ class PauseConsoleCommand<G extends FlameGame> extends ConsoleCommand<G> {
@override
(String?, String) execute(G game, ArgResults results) {
if (game.paused) {
return ('Game is already paused', '');
return (
'Game is already paused, use the resume command start it again',
'',
);
} else {
game.pauseEngine();
return (null, '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ResumeConsoleCommand<G extends FlameGame> extends ConsoleCommand<G> {
@override
(String?, String) execute(G game, ArgResults results) {
if (!game.paused) {
return ('Game is not paused', '');
return ('Game is not paused, use the pause command to pause it', '');
} else {
game.resumeEngine();
return (null, '');
Expand Down
5 changes: 4 additions & 1 deletion packages/flame_console/test/src/pause_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ void main() {
final result = command.execute(game, command.parser.parse([]));
expect(game.paused, isTrue);

expect(result.$1, 'Game is already paused');
expect(
result.$1,
'Game is already paused, use the resume command start it again',
);
},
);
});
Expand Down
5 changes: 4 additions & 1 deletion packages/flame_console/test/src/resume_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ void main() {
final result = command.execute(game, command.parser.parse([]));
expect(game.paused, isFalse);

expect(result.$1, 'Game is not paused');
expect(
result.$1,
'Game is not paused, use the pause command to pause it',
);
},
);
});
Expand Down

0 comments on commit d40e6e3

Please sign in to comment.