From f23b4c9267be2f1e3bb129f3f8775c7c49c2d115 Mon Sep 17 00:00:00 2001 From: Blaizer Date: Sun, 3 Oct 2010 13:20:07 +1030 Subject: [PATCH] SDL::Deprecated updated. quit is now stop. --- lib/SDLx/Controller.pm | 10 +++++----- lib/pods/SDL/Deprecated.pod | 13 +++++++++++++ lib/pods/SDLx/Controller.pod | 10 +++++----- t/sdlx_controller.t | 4 ++-- t/sdlx_controller_interface.t | 2 +- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/lib/SDLx/Controller.pm b/lib/SDLx/Controller.pm index 714d87b1..4007d3e8 100644 --- a/lib/SDLx/Controller.pm +++ b/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 ) = @_; diff --git a/lib/pods/SDL/Deprecated.pod b/lib/pods/SDL/Deprecated.pod index 5c0aae42..7a5de347 100644 --- a/lib/pods/SDL/Deprecated.pod +++ b/lib/pods/SDL/Deprecated.pod @@ -11,6 +11,19 @@ Core =head1 RELEASES +=head2 2.5xx + +Major changes to C. + +C is now C. Event handlers no longer end C on returning false. Call C explicitly instead. + +The first argument to move handlers is the step portion instead of C
. +The second argument to move handlers, the C value, is now the third argument. + +The handle holders are now hashes instead of arrays. + +C will limit apps to a framerate of 60 by default. + =head2 2.513 =over diff --git a/lib/pods/SDLx/Controller.pod b/lib/pods/SDLx/Controller.pod index c56f9816..75ffe36f 100644 --- a/lib/pods/SDLx/Controller.pod +++ b/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 is called. +activate the main loop. The main loop will run until C 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 object. -=head2 quit +=head2 stop Returns from the C 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 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 diff --git a/t/sdlx_controller.t b/t/sdlx_controller.t index 4f898340..867488c4 100644 --- a/t/sdlx_controller.t +++ b/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); diff --git a/t/sdlx_controller_interface.t b/t/sdlx_controller_interface.t index 5d818440..6a0c53ef 100644 --- a/t/sdlx_controller_interface.t +++ b/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 );