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.62 by root, Thu Jun 15 16:44:20 2006 UTC vs.
Revision 1.66 by root, Sun Jun 18 19:13:20 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
62 my ($self) = @_; 62 my ($self) = @_;
63 63
64 %{$self->{completer}{command}} = (); 64 %{$self->{completer}{command}} = ();
65} 65}
66 66
67sub button_down { 67sub invoke_button_down {
68 my ($self, $ev, $x, $y) = @_; 68 my ($self, $ev, $x, $y) = @_;
69 69
70 return unless $::CONN; 70 return unless $::CONN;
71 71
72 $self->focus_in; 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)
98 } 98 }
99 99
100 1 100 1
101} 101}
102 102
103sub button_up { 103sub invoke_button_up {
104 my ($self, $ev, $x, $y) = @_; 104 my ($self, $ev, $x, $y) = @_;
105 105
106 delete $self->{motion}; 106 delete $self->{motion};
107 107
108 1 108 1
109} 109}
110 110
111sub mouse_motion { 111sub invoke_mouse_motion {
112 my ($self, $ev, $x, $y) = @_; 112 my ($self, $ev, $x, $y) = @_;
113 113
114 if ($self->{motion}) { 114 if ($self->{motion}) {
115 $self->{motion}->($ev, $x, $y); 115 $self->{motion}->($ev, $x, $y);
116 } else { 116 } else {
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) = @_;
148 CFClient::SDLK_RIGHT, [3, "east"], 148 CFClient::SDLK_RIGHT, [3, "east"],
149 CFClient::SDLK_DOWN, [5, "south"], 149 CFClient::SDLK_DOWN, [5, "south"],
150 CFClient::SDLK_LEFT, [7, "west"], 150 CFClient::SDLK_LEFT, [7, "west"],
151); 151);
152 152
153sub key_down { 153sub invoke_key_down {
154 my ($self, $ev) = @_; 154 my ($self, $ev) = @_;
155 155
156 return 0 unless $::CONN; 156 return 0 unless $::CONN;
157 157
158 my $mod = $ev->{mod}; 158 my $mod = $ev->{mod};
195 } 195 }
196 } elsif ($sym == CFClient::SDLK_INSERT && $mod & CFClient::KMOD_CTRL) { 196 } elsif ($sym == CFClient::SDLK_INSERT && $mod & CFClient::KMOD_CTRL) {
197 $::BIND_EDITOR->set_binding (undef, undef, [], 197 $::BIND_EDITOR->set_binding (undef, undef, [],
198 sub { 198 sub {
199 my ($mod, $sym, $cmds) = @_; 199 my ($mod, $sym, $cmds) = @_;
200 $::CFG->{bindings}->{$mod}->{$sym} = $cmds; 200 $::CFG->{profile}{default}{bindings}{$mod}{$sym} = $cmds;
201 }); 201 });
202 $::BIND_EDITOR->start; 202 $::BIND_EDITOR->start;
203 $::BIND_EDITOR->show; 203 $::BIND_EDITOR->show;
204 } elsif ($sym == CFClient::SDLK_INSERT && not ($mod & CFClient::KMOD_CTRL)) { 204 } elsif ($sym == CFClient::SDLK_INSERT && not ($mod & CFClient::KMOD_CTRL)) {
205 $::BIND_EDITOR->stop; 205 $::BIND_EDITOR->stop;
206 $::BIND_EDITOR->ask_for_bind_and_commit; 206 $::BIND_EDITOR->ask_for_bind_and_commit;
207 $::BIND_EDITOR->hide; 207 $::BIND_EDITOR->hide;
208 } elsif (my $bind_cmd = $::CFG->{bindings}->{$mod}->{$sym}) { 208 } elsif (my $bind_cmd = $::CFG->{profile}{default}{bindings}{$mod}{$sym}) {
209 $::CONN->user_send ($_) for @$bind_cmd; 209 $::CONN->user_send ($_) for @$bind_cmd;
210 } elsif ((ord 'a') <= $uni && $uni <= (ord 'z')) { 210 } elsif ((ord 'a') <= $uni && $uni <= (ord 'z')) {
211 $self->{completer}->key_down ($ev); 211 $self->{completer}->invoke_key_down ($ev);
212 $self->{completer}->show; 212 $self->{completer}->show;
213 } else { 213 } else {
214 return 0; 214 return 0;
215 } 215 }
216 216
217 1 217 1
218} 218}
219 219
220sub key_up { 220sub invoke_key_up {
221 my ($self, $ev) = @_; 221 my ($self, $ev) = @_;
222 222
223 my $res = 0; 223 my $res = 0;
224 my $mod = $ev->{mod}; 224 my $mod = $ev->{mod};
225 my $sym = $ev->{sym}; 225 my $sym = $ev->{sym};
380 380
381sub size_request { 381sub size_request {
382 ($::HEIGHT * 0.25, $::HEIGHT * 0.25) 382 ($::HEIGHT * 0.25, $::HEIGHT * 0.25)
383} 383}
384 384
385sub size_allocate { 385sub invoke_size_allocate {
386 my ($self, $w, $h) = @_; 386 my ($self, $w, $h) = @_;
387 387
388 $self->SUPER::size_allocate ($w, $h);
389 $self->update; 388 $self->update;
389
390 1
390} 391}
391 392
392sub update { 393sub update {
393 my ($self) = @_; 394 my ($self) = @_;
394 395
479 ]; 480 ];
480 481
481 $self->{entry} = new CFClient::UI::Entry 482 $self->{entry} = new CFClient::UI::Entry
482 on_changed => sub { 483 on_changed => sub {
483 $self->update_labels; 484 $self->update_labels;
485 0
484 }, 486 },
485 on_button_down => sub { 487 on_button_down => sub {
486 my ($entry, $ev, $x, $y) = @_; 488 my ($entry, $ev, $x, $y) = @_;
487 489
488 if ($ev->{button} == 3) { 490 if ($ev->{button} == 3) {
489 (new CFClient::UI::Menu 491 (new CFClient::UI::Menu
490 items => [ 492 items => [
491 ["bind to a key" => sub { $::BIND_EDITOR->do_quick_binding ([$self->{select}], sub { $entry->focus_in }) }] 493 ["bind to a key" => sub { $::BIND_EDITOR->do_quick_binding ([$self->{select}], sub { $entry->grab_focus }) }]
492 ], 494 ],
493 )->popup ($ev); 495 )->popup ($ev);
494 return 1; 496 return 1;
495 } 497 }
496 0 498 0
511 $self->hide; 513 $self->hide;
512 } 514 }
513 } elsif ($ev->{sym} == 27) { 515 } elsif ($ev->{sym} == 27) {
514 $self->{hist_ptr} = 0; 516 $self->{hist_ptr} = 0;
515 $self->hide; 517 $self->hide;
516 return;
517 } elsif ($ev->{sym} == CFClient::SDLK_DOWN) { 518 } elsif ($ev->{sym} == CFClient::SDLK_DOWN) {
518 if ($self->{hist_ptr} > 1) { 519 if ($self->{hist_ptr} > 1) {
519 $self->{hist_ptr}--; 520 $self->{hist_ptr}--;
520 $self->{entry}->set_text ($self->{history}->[$self->{hist_ptr} - 1]); 521 $self->{entry}->set_text ($self->{history}->[$self->{hist_ptr} - 1]);
521 } elsif ($self->{hist_ptr} > 0) { 522 } elsif ($self->{hist_ptr} > 0) {
561 562
562 $self->{entry}->set_text ($prefix); 563 $self->{entry}->set_text ($prefix);
563 $self->show; 564 $self->show;
564} 565}
565 566
566sub size_allocate { 567sub invoke_size_allocate {
567 my ($self, $w, $h) = @_; 568 my ($self, $w, $h) = @_;
568 569
569 $self->SUPER::size_allocate ($w, $h);
570 $self->move_abs (($::WIDTH - $w) * 0.5, ($::HEIGHT - $h) * 0.6, 10); 570 $self->move_abs (($::WIDTH - $w) * 0.5, ($::HEIGHT - $h) * 0.6, 10);
571
572 $self->SUPER::invoke_size_allocate ($w, $h)
571} 573}
572 574
573sub show { 575sub show {
574 my ($self) = @_; 576 my ($self) = @_;
575 577
576 $self->SUPER::show; 578 $self->SUPER::show;
577 $self->{entry}->focus_in; 579 $self->{entry}->grab_focus;
578} 580}
579 581
580sub hide { 582sub hide {
581 my ($self) = @_; 583 my ($self) = @_;
582 584
583 $self->SUPER::hide; 585 $self->SUPER::hide;
584 $self->{entry}->set_text (""); 586 $self->{entry}->set_text ("");
585} 587}
586 588
587sub key_down { 589sub invoke_key_down {
588 my ($self, $ev) = @_; 590 my ($self, $ev) = @_;
589 591
590 $self->{entry}->key_down ($ev) 592 $self->{entry}->emit (key_down => $ev)
591} 593}
592 594
593sub update_labels { 595sub update_labels {
594 my ($self) = @_; 596 my ($self) = @_;
595 597
682 $label->set_text (""); 684 $label->set_text ("");
683 $label->set_tooltip (""); 685 $label->set_tooltip ("");
684 } 686 }
685 687
686 $self->update; 688 $self->update;
687 ###
688} 689}
689 690
690sub _draw { 691sub _draw {
691 my ($self) = @_; 692 my ($self) = @_;
692 693

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines