… | |
… | |
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 | |
67 | sub button_down { |
67 | sub 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 = 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 = CFClient::floor +($ev->{y} - $self->{sy0}) / $self->{tilesize} - $self->{sy}; |
77 | |
77 | |
… | |
… | |
98 | } |
98 | } |
99 | |
99 | |
100 | 1 |
100 | 1 |
101 | } |
101 | } |
102 | |
102 | |
103 | sub button_up { |
103 | sub 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 | |
111 | sub mouse_motion { |
111 | sub 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 { |
… | |
… | |
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 | |
153 | sub key_down { |
153 | sub 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}->key_down ($ev); |
212 | $self->{completer}->show; |
212 | $self->{completer}->show; |
213 | } else { |
213 | } else { |
… | |
… | |
215 | } |
215 | } |
216 | |
216 | |
217 | 1 |
217 | 1 |
218 | } |
218 | } |
219 | |
219 | |
220 | sub key_up { |
220 | sub 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}; |
… | |
… | |
251 | } |
251 | } |
252 | |
252 | |
253 | sub set_magicmap { |
253 | sub set_magicmap { |
254 | my ($self, $w, $h, $x, $y, $data) = @_; |
254 | my ($self, $w, $h, $x, $y, $data) = @_; |
255 | |
255 | |
256 | $x += - $::MAP->x - int 0.5 * $::MAP->w; |
256 | $x -= $::MAP->ox + int 0.5 * $::MAP->w; |
257 | $y += - $::MAP->y - int 0.5 * $::MAP->h; |
257 | $y -= $::MAP->oy + int 0.5 * $::MAP->h; |
258 | |
258 | |
259 | $self->{magicmap} = [$x, $y, $w, $h, $data]; |
259 | $self->{magicmap} = [$x, $y, $w, $h, $data]; |
260 | |
260 | |
261 | $self->update; |
261 | $self->update; |
262 | } |
262 | } |
… | |
… | |
332 | } |
332 | } |
333 | |
333 | |
334 | if ($self->{magicmap}) { |
334 | if ($self->{magicmap}) { |
335 | my ($x, $y, $w, $h, $data) = @{ $self->{magicmap} }; |
335 | my ($x, $y, $w, $h, $data) = @{ $self->{magicmap} }; |
336 | |
336 | |
337 | $x += $::MAP->x - $sx + int 0.5 * ($::MAP->w - $sw + 1); |
337 | $x += $::MAP->ox - $sx + int 0.5 * ($::MAP->w - $sw + 1); |
338 | $y += $::MAP->y - $sy + int 0.5 * ($::MAP->h - $sh + 1); |
338 | $y += $::MAP->oy - $sy + int 0.5 * ($::MAP->h - $sh + 1); |
339 | |
339 | |
340 | glTranslate - $x - 1, - $y - 1; |
340 | glTranslate - $x - 1, - $y - 1; |
341 | glBindTexture GL_TEXTURE_2D, $magicmap_tex->{name}; |
341 | glBindTexture GL_TEXTURE_2D, $magicmap_tex->{name}; |
342 | $::MAP->draw_magicmap ($x, $y, $w, $h, $data); |
342 | $::MAP->draw_magicmap ($x, $y, $w, $h, $data); |
343 | } |
343 | } |
… | |
… | |
380 | |
380 | |
381 | sub size_request { |
381 | sub size_request { |
382 | ($::HEIGHT * 0.25, $::HEIGHT * 0.25) |
382 | ($::HEIGHT * 0.25, $::HEIGHT * 0.25) |
383 | } |
383 | } |
384 | |
384 | |
385 | sub size_allocate { |
385 | sub 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 | |
392 | sub update { |
393 | sub 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 |
… | |
… | |
561 | |
563 | |
562 | $self->{entry}->set_text ($prefix); |
564 | $self->{entry}->set_text ($prefix); |
563 | $self->show; |
565 | $self->show; |
564 | } |
566 | } |
565 | |
567 | |
566 | sub size_allocate { |
568 | sub invoke_size_allocate { |
567 | my ($self, $w, $h) = @_; |
569 | my ($self, $w, $h) = @_; |
568 | |
570 | |
569 | $self->SUPER::size_allocate ($w, $h); |
|
|
570 | $self->move_abs (($::WIDTH - $w) * 0.5, ($::HEIGHT - $h) * 0.6, 10); |
571 | $self->move_abs (($::WIDTH - $w) * 0.5, ($::HEIGHT - $h) * 0.6, 10); |
|
|
572 | |
|
|
573 | $self->SUPER::invoke_size_allocate ($w, $h) |
571 | } |
574 | } |
572 | |
575 | |
573 | sub show { |
576 | sub show { |
574 | my ($self) = @_; |
577 | my ($self) = @_; |
575 | |
578 | |
576 | $self->SUPER::show; |
579 | $self->SUPER::show; |
577 | $self->{entry}->focus_in; |
580 | $self->{entry}->grab_focus; |
578 | } |
581 | } |
579 | |
582 | |
580 | sub hide { |
583 | sub hide { |
581 | my ($self) = @_; |
584 | my ($self) = @_; |
582 | |
585 | |
583 | $self->SUPER::hide; |
586 | $self->SUPER::hide; |
584 | $self->{entry}->set_text (""); |
587 | $self->{entry}->set_text (""); |
585 | } |
588 | } |
586 | |
589 | |
587 | sub key_down { |
590 | sub invoke_key_down { |
588 | my ($self, $ev) = @_; |
591 | my ($self, $ev) = @_; |
589 | |
592 | |
590 | $self->{entry}->key_down ($ev) |
593 | $self->{entry}->key_down ($ev) |
591 | } |
594 | } |
592 | |
595 | |