ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/MapWidget.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/MapWidget.pm (file contents):
Revision 1.63 by root, Sun Jun 18 17:13:11 2006 UTC vs.
Revision 1.70 by elmex, Sun Jul 2 19:32:55 2006 UTC

38 . "To enter a verbatim command to send to the server, just type the command, " 38 . "To enter a verbatim command to send to the server, just type the command, "
39 . "followed by a space, and press return. " 39 . "followed by a space, and press return. "
40 . "Typing the initial letters of words (or just any letters) displays guesses " 40 . "Typing the initial letters of words (or just any letters) displays guesses "
41 . "for commands you might want to use.\n" 41 . "for commands you might want to use.\n"
42 . "You can use the cursor-up and cursor-down keys to select between those guesses.\n" 42 . "You can use the cursor-up and cursor-down keys to select between those guesses.\n"
43 . "<b>Right-Click</b> opens a menu where you cna select further options, sich as redefining keybindings.", 43 . "<b>Right-Click</b> opens a menu where you cna select further options, sich as redefining key bindings.",
44 ; 44 ;
45 45
46 $self 46 $self
47} 47}
48 48
70 return unless $::CONN; 70 return unless $::CONN;
71 71
72 $self->grab_focus; 72 $self->grab_focus;
73 73
74 if ($ev->{button} == 1) { 74 if ($ev->{button} == 1) {
75 my $x = CFClient::floor +($ev->{x} - $self->{sx0}) / $self->{tilesize} - $self->{sx}; 75 my $x = 1 + CFClient::floor +($ev->{x} - $self->{sx0}) / $self->{tilesize} - $self->{sx};
76 my $y = CFClient::floor +($ev->{y} - $self->{sy0}) / $self->{tilesize} - $self->{sy}; 76 my $y = 1 + CFClient::floor +($ev->{y} - $self->{sy0}) / $self->{tilesize} - $self->{sy};
77 77
78 $x -= int 0.5 * $self->{sw}; 78 $x -= int 0.5 * $self->{sw};
79 $y -= int 0.5 * $self->{sh}; 79 $y -= int 0.5 * $self->{sh};
80 80
81 $::CONN->lookat ($x, $y) 81 $::CONN->lookat ($x, $y)
120 1 120 1
121} 121}
122 122
123sub size_request { 123sub size_request {
124 ( 124 (
125 1 + 32 * int $::WIDTH / 32, 125 32 * CFClient::ceil $::WIDTH / 32,
126 1 + 32 * int $::HEIGHT / 32, 126 32 * CFClient::ceil $::HEIGHT / 32,
127 ) 127 )
128} 128}
129 129
130sub update { 130sub update {
131 my ($self) = @_; 131 my ($self) = @_;
167 $::CONN->user_send ("apply"); 167 $::CONN->user_send ("apply");
168 } elsif ($uni == ord ".") { 168 } elsif ($uni == ord ".") {
169 $::CONN->user_send ($self->{completer}{last_command}) 169 $::CONN->user_send ($self->{completer}{last_command})
170 if exists $self->{completer}{last_command}; 170 if exists $self->{completer}{last_command};
171 } elsif ($uni == ord "\t") { 171 } elsif ($uni == ord "\t") {
172 $::INV_WINDOW->toggle_visibility; 172 $::PL_WINDOW->toggle_visibility;
173 $::PL_NOTEBOOK->set_current_page ("Inventory");
173 } elsif ($sym == CFClient::SDLK_KP_PLUS || $uni == ord "+") { 174 } elsif ($sym == CFClient::SDLK_KP_PLUS || $uni == ord "+") {
174 $::CONN->user_send ("rotateshoottype +"); 175 $::CONN->user_send ("rotateshoottype +");
175 } elsif ($sym == CFClient::SDLK_KP_MINUS || $uni == ord "-") { 176 } elsif ($sym == CFClient::SDLK_KP_MINUS || $uni == ord "-") {
176 $::CONN->user_send ("rotateshoottype -"); 177 $::CONN->user_send ("rotateshoottype -");
177 } elsif ($uni == ord '"') { 178 } elsif ($uni == ord '"') {
195 } 196 }
196 } elsif ($sym == CFClient::SDLK_INSERT && $mod & CFClient::KMOD_CTRL) { 197 } elsif ($sym == CFClient::SDLK_INSERT && $mod & CFClient::KMOD_CTRL) {
197 $::BIND_EDITOR->set_binding (undef, undef, [], 198 $::BIND_EDITOR->set_binding (undef, undef, [],
198 sub { 199 sub {
199 my ($mod, $sym, $cmds) = @_; 200 my ($mod, $sym, $cmds) = @_;
200 $::CFG->{bindings}->{$mod}->{$sym} = $cmds; 201 $::BIND_EDITOR->cfg_bind ($mod, $sym, $cmds);
201 }); 202 });
202 $::BIND_EDITOR->start; 203 $::BIND_EDITOR->start;
203 $::BIND_EDITOR->show; 204 $::BIND_EDITOR->show;
204 } elsif ($sym == CFClient::SDLK_INSERT && not ($mod & CFClient::KMOD_CTRL)) { 205 } elsif ($sym == CFClient::SDLK_INSERT && not ($mod & CFClient::KMOD_CTRL)) {
205 $::BIND_EDITOR->stop; 206 $::BIND_EDITOR->stop;
206 $::BIND_EDITOR->ask_for_bind_and_commit; 207 $::BIND_EDITOR->ask_for_bind_and_commit;
207 $::BIND_EDITOR->hide; 208 $::BIND_EDITOR->hide;
208 } elsif (my $bind_cmd = $::CFG->{bindings}->{$mod}->{$sym}) { 209 } elsif (my $bind_cmd = $::CFG->{profile}{default}{bindings}{$mod}{$sym}) {
209 $::CONN->user_send ($_) for @$bind_cmd; 210 $::CONN->user_send ($_) for @$bind_cmd;
210 } elsif ((ord 'a') <= $uni && $uni <= (ord 'z')) { 211 } elsif ((ord 'a') <= $uni && $uni <= (ord 'z')) {
211 $self->{completer}->key_down ($ev); 212 $self->{completer}->invoke_key_down ($ev);
212 $self->{completer}->show; 213 $self->{completer}->show;
213 } else { 214 } else {
214 return 0; 215 return 0;
215 } 216 }
216 217
488 my ($entry, $ev, $x, $y) = @_; 489 my ($entry, $ev, $x, $y) = @_;
489 490
490 if ($ev->{button} == 3) { 491 if ($ev->{button} == 3) {
491 (new CFClient::UI::Menu 492 (new CFClient::UI::Menu
492 items => [ 493 items => [
494 ["bind <i>" . (CFClient::UI::Label::escape $self->{select}) . "</i> to a key"
493 ["bind to a key" => sub { $::BIND_EDITOR->do_quick_binding ([$self->{select}], sub { $entry->grab_focus }) }] 495 => sub { $::BIND_EDITOR->do_quick_binding ([$self->{select}], sub { $entry->grab_focus }) }]
494 ], 496 ],
495 )->popup ($ev); 497 )->popup ($ev);
496 return 1; 498 return 1;
497 } 499 }
498 0 500 0
505 if ($ev->{sym} == 13) { 507 if ($ev->{sym} == 13) {
506 if (exists $self->{select}) { 508 if (exists $self->{select}) {
507 $self->{last_command} = $self->{select}; 509 $self->{last_command} = $self->{select};
508 $::CONN->user_send ($self->{select}); 510 $::CONN->user_send ($self->{select});
509 511
510 unshift @{$self->{history}}, $self->{select}; 512 unshift @{$self->{history}}, $self->{entry}->get_text;
511 $self->{hist_ptr} = 0; 513 $self->{hist_ptr} = 0;
512 514
513 $self->hide; 515 $self->hide;
514 } 516 }
515 } elsif ($ev->{sym} == 27) { 517 } elsif ($ev->{sym} == 27) {
516 $self->{hist_ptr} = 0; 518 $self->{hist_ptr} = 0;
517 $self->hide; 519 $self->hide;
518 return;
519 } elsif ($ev->{sym} == CFClient::SDLK_DOWN) { 520 } elsif ($ev->{sym} == CFClient::SDLK_DOWN) {
520 if ($self->{hist_ptr} > 1) { 521 if ($self->{hist_ptr} > 1) {
521 $self->{hist_ptr}--; 522 $self->{hist_ptr}--;
522 $self->{entry}->set_text ($self->{history}->[$self->{hist_ptr} - 1]); 523 $self->{entry}->set_text ($self->{history}->[$self->{hist_ptr} - 1]);
523 } elsif ($self->{hist_ptr} > 0) { 524 } elsif ($self->{hist_ptr} > 0) {
588} 589}
589 590
590sub invoke_key_down { 591sub invoke_key_down {
591 my ($self, $ev) = @_; 592 my ($self, $ev) = @_;
592 593
593 $self->{entry}->key_down ($ev) 594 $self->{entry}->emit (key_down => $ev)
594} 595}
595 596
596sub update_labels { 597sub update_labels {
597 my ($self) = @_; 598 my ($self) = @_;
598 599
685 $label->set_text (""); 686 $label->set_text ("");
686 $label->set_tooltip (""); 687 $label->set_tooltip ("");
687 } 688 }
688 689
689 $self->update; 690 $self->update;
690 ###
691} 691}
692 692
693sub _draw { 693sub _draw {
694 my ($self) = @_; 694 my ($self) = @_;
695 695

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines