| 1 | package Karel::UI::Text; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | Karel::UI::Text | ||
| 6 | |||
| 7 | =head1 DESCRIPTION | ||
| 8 | |||
| 9 | Simple text UI for Karel. | ||
| 10 | |||
| 11 | =head1 SUBROUTINES | ||
| 12 | |||
| 13 | =over 4 | ||
| 14 | |||
| 15 | =cut | ||
| 16 | |||
| 17 | use warnings; | ||
| 18 | use strict; | ||
| 19 | use feature qw{ say }; | ||
| 20 | |||
| 21 | use Karel::Robot; | ||
| 22 | use Karel::UI::Text::Robot; | ||
| 23 | |||
| 24 | =item main | ||
| 25 | |||
| 26 | Runs the application. | ||
| 27 | |||
| 28 | =cut | ||
| 29 | |||
| 30 | sub main { | ||
| 31 | my $robot = 'Karel::Robot'->new; | ||
| 32 | my $grid = 'Karel::Grid'->new(x => 7, y => 7); | ||
| 33 | $robot->set_grid($grid, 4, 4, 'N'); | ||
| 34 | |||
| 35 | 'Moo::Role'->apply_roles_to_object($robot, 'Karel::UI::Text::Robot'); | ||
| 36 | |||
| 37 | while (1) { | ||
| 38 | $robot->show; | ||
| 39 | $robot->menu(undef, | ||
| 40 | [ [ Quit => sub { no warnings 'exiting'; last } ], | ||
| 41 | [ 'Run command' => 'execute' ], | ||
| 42 | [ 'Load grid' => 'load_grid_from_path' ], | ||
| 43 | [ 'Load commands' => 'load_commands_from_path' ], | ||
| 44 | ]); | ||
| 45 | } | ||
| 46 | } | ||
| 47 | |||
| 48 | =back | ||
| 49 | |||
| 50 | =cut | ||
| 51 | |||
| 52 | __PACKAGE__ |