# # change the Roboter Map # sub arbfeld_aendern { my $self = shift; $self->{robot}->einschalten; $self->{stop} = 1; $self->{map_is_renewed} = 0; my $i = 0; my $tl = $self->{mw} -> Toplevel (-title => "Roboter Map verändern"); foreach (qw/Blickrichtung: Material:/) { $tl -> Label (-text => $_, -font => "{Arial} 9 {bold}", -justify => "left", -anchor => "w")->grid (-column => 0, -row => $i++, -sticky => "ew"); } $tl -> Label (-text => "Auf der Map positionieren:", -font => "{Arial} 9 {bold}", -justify => "left", -anchor => "w")->grid (-column => 0, -columnspan => 2, -row => $i, -sticky => "ew"); $i = 0; my $update = sub { updateInfo($self); }; $tl -> Optionmenu (-options => [["rechts", 0], ["unten", 90], ["links", 180], ["oben", 270]], -variable => \$self->{robot}->{rot}, -command => sub { $self->{robot}->newlook; &$update })->grid (-column => 1, -row => $i++, -sticky => "ew"); $tl -> Scale (-from => 0, -to => 100, -orient => "horizontal", -variable => \$self->{robot}->{material}->[0], -command => $update)->grid (-column => 1, -row => $i++, -sticky => "ew"); my $mode = "wiki"; foreach ([qw/Wiki wiki/], [qw/Wände wall/], [qw/Gegenstände item/]) { $tl -> Radiobutton (-text => $_->[0], -value => $_->[1], -variable => \$mode, -anchor => "w", -command => sub { bind_map($self, $mode) })->grid (-column => 1, -row => ++$i, -sticky => "ew"); } $tl -> Button (-text => "Abbrechen", -font => "{Arial} 9 {bold}", -command => sub { bind_map($self, "no"); $tl->destroy })->grid (-column => 0, -row => $i+2, -sticky => "ew"); $tl -> Button (-text => "OK", -font => "{Arial} 9 {bold}", -command => sub {})->grid (-column => 1, -row => $i+2, -sticky => "ew"); my($cols, $rows) = $tl->gridSize(); for $i (1..$cols) { $tl->gridColumnconfigure($i-1, -weight => 1); } for $i (1..$rows) { $tl->gridRowconfigure($i-1, -weight => 1); } } # arbfeld_aendern # # bind some special events, defined by $mode, to the Roboter Map # sub bind_map { my($self, $mode) = @_; my $r = $self->{robot}; my $c = $r->{c}; if ($mode =~ "no") { $c -> Tk::bind ("", "NoOp"); $c -> Tk::bind ("", "NoOp"); } elsif ($mode =~ "wiki") { print "Jetzt werden die Bindings hinzugefuegt...\n"; $c -> Tk::bind ("", [ sub { shift; my @op = @{$r->{pos}}; my @np = @_; print " OP: @op\n NP: @np\n"; newpos($r, [$np[0]-$op[0], $np[1]-$op[1]]); @{$r->{pos}} = (getXY(@_)); }, Ev("x"), Ev("y") ]); } } # bind_map