Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

SDL::Deprecated updated. quit is now stop.

  • Loading branch information...
commit f23b4c9267be2f1e3bb129f3f8775c7c49c2d115 1 parent dbf726d
@Blaizer Blaizer authored
View
10 lib/SDLx/Controller.pm
@@ -16,7 +16,7 @@ use Scalar::Util 'refaddr';
my %_dt;
my %_min_t;
my %_current_time;
-my %_quit;
+my %_stop;
my %_event;
my %_event_handlers;
my %_move_handlers;
@@ -38,7 +38,7 @@ sub new {
$_dt{ refaddr $self} = defined $args{dt} ? $args{dt} : 0.1;
$_min_t{ refaddr $self} = defined $args{min_t} ? $args{min_t} : 1 / 60;
# $_current_time{ refaddr $self} = $args{current_time} || 0; #no point
- $_quit{ refaddr $self} = $args{quit};
+ $_stop{ refaddr $self} = $args{stop};
$_event{ refaddr $self} = $args{event} || SDL::Event->new();
$_event_handlers{ refaddr $self} = $args{event_handlers};
$_move_handlers{ refaddr $self} = $args{move_handlers};
@@ -56,7 +56,7 @@ sub DESTROY {
delete $_dt{ refaddr $self};
delete $_min_t{ refaddr $self};
delete $_current_time{ refaddr $self};
- delete $_quit{ refaddr $self};
+ delete $_stop{ refaddr $self};
delete $_event{ refaddr $self};
delete $_event_handlers{ refaddr $self};
delete $_move_handlers{ refaddr $self};
@@ -72,7 +72,7 @@ sub run {
my $min_t = $_min_t{ refaddr $self};
my $t = 0.0;
$_current_time{ refaddr $self} = Time::HiRes::time;
- while ( !$_quit{ refaddr $self} ) {
+ while ( !$_stop{ refaddr $self} ) {
$self->_event;
my $new_time = Time::HiRes::time;
@@ -135,7 +135,7 @@ sub _show {
}
}
-sub quit { $_quit{ refaddr $_[0] } = 1 }
+sub stop { $_stop{ refaddr $_[0] } = 1 }
sub _add_handler {
my ( $hash_ref, $num_ref, $handler ) = @_;
View
13 lib/pods/SDL/Deprecated.pod
@@ -11,6 +11,19 @@ Core
=head1 RELEASES
+=head2 2.5xx
+
+Major changes to C<SDLx::Controller>.
+
+C<quit> is now C<stop>. Event handlers no longer end C<run> on returning false. Call C<stop> explicitly instead.
+
+The first argument to move handlers is the step portion instead of C<dt>.
+The second argument to move handlers, the C<t> value, is now the third argument.
+
+The handle holders are now hashes instead of arrays.
+
+C<min_t> will limit apps to a framerate of 60 by default.
+
=head2 2.513
=over
View
10 lib/pods/SDLx/Controller.pod
@@ -73,7 +73,7 @@ Returns the new object.
=head2 run
After creating and setting up your handlers (see below), call this method to
-activate the main loop. The main loop will run until C<quit> is called.
+activate the main loop. The main loop will run until C<stop> is called.
All hooked functions will be called during the main loop, in this order:
@@ -90,7 +90,7 @@ All hooked functions will be called during the main loop, in this order:
Please refer to each handler below for information on received arguments.
Note that the second argument every callback recieves is the C<SDLx::Controller> object.
-=head2 quit
+=head2 stop
Returns from the C<run> loop.
@@ -137,13 +137,13 @@ order. Returns the order queue number of the added callback.
The first argument passed to registered callbacks is the L<< SDL::Event >> object.
The second is the C<SDLx::Controller> object.
- sub quit {
+ sub stop {
my ($event, $app) = @_;
if($event->type == SDL_QUIT) {
- $controller->quit;
+ $controller->stop;
}
}
- $controller->add_event_handler(\&quit);
+ $controller->add_event_handler(\&stop);
=head2 add_move_handler
View
4 t/sdlx_controller.t
@@ -12,7 +12,7 @@ use lib 't/lib';
can_ok(
'SDLx::Controller',
qw(
- new quit dt min_t
+ new run stop pause dt min_t current_time
add_move_handler add_event_handler add_show_handler
remove_move_handler remove_event_handler remove_show_handler
remove_all_move_handlers remove_all_event_handlers remove_all_show_handlers
@@ -57,7 +57,7 @@ sub test_move {
sub test_show {
my $ticks = shift;
ok( $ticks >= 0.5, "show handle \$_[0] of $ticks was >= 0.5" );
- $app->quit();
+ $app->stop();
}
$app->add_move_handler(\&test_move);
View
2  t/sdlx_controller_interface.t
@@ -88,7 +88,7 @@ $controller->add_event_handler( sub { $counts->[0]++; return 0 if $interface->cu
$interface->set_acceleration(
sub {
- $controller->quit() if $counts->[1] > 100;
+ $controller->stop() if $counts->[1] > 100;
$counts->[1]++;
isa_ok( $_[1], 'SDLx::Controller::State', '[Controller] called acceleration and gave us a state' ),
return ( 10, 10, 10 );
Please sign in to comment.
Something went wrong with that request. Please try again.