… | |
… | |
6 | use List::Util qw(min max); |
6 | use List::Util qw(min max); |
7 | |
7 | |
8 | use CFClient::OpenGL; |
8 | use CFClient::OpenGL; |
9 | |
9 | |
10 | our @ISA = CFClient::UI::Base::; |
10 | our @ISA = CFClient::UI::Base::; |
|
|
11 | |
|
|
12 | my $magicmap_tex = |
|
|
13 | new_from_file CFClient::Texture CFClient::find_rcfile "magicmap.png", |
|
|
14 | mipmap => 1, wrap => 0, internalformat => GL_ALPHA; |
11 | |
15 | |
12 | sub new { |
16 | sub new { |
13 | my $class = shift; |
17 | my $class = shift; |
14 | |
18 | |
15 | my $self = $class->SUPER::new ( |
19 | my $self = $class->SUPER::new ( |
… | |
… | |
34 | . "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, " |
35 | . "followed by a space, and press return. " |
39 | . "followed by a space, and press return. " |
36 | . "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 " |
37 | . "for commands you might want to use.\n" |
41 | . "for commands you might want to use.\n" |
38 | . "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" |
39 | . "<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.", |
40 | ; |
44 | ; |
41 | |
45 | |
42 | $self |
46 | $self |
43 | } |
47 | } |
44 | |
48 | |
… | |
… | |
56 | |
60 | |
57 | sub clr_commands { |
61 | sub clr_commands { |
58 | my ($self) = @_; |
62 | my ($self) = @_; |
59 | |
63 | |
60 | %{$self->{completer}{command}} = (); |
64 | %{$self->{completer}{command}} = (); |
61 | } |
|
|
62 | |
65 | |
|
|
66 | $self->{completer}->hide |
|
|
67 | if $self->{completer}; |
|
|
68 | } |
|
|
69 | |
63 | sub button_down { |
70 | sub invoke_button_down { |
64 | my ($self, $ev, $x, $y) = @_; |
71 | my ($self, $ev, $x, $y) = @_; |
65 | |
72 | |
66 | return unless $::CONN; |
|
|
67 | |
|
|
68 | $self->focus_in; |
|
|
69 | |
|
|
70 | if ($ev->{button} == 1) { |
73 | if ($ev->{button} == 1) { |
|
|
74 | $self->grab_focus; |
|
|
75 | return unless $::CONN; |
|
|
76 | |
71 | my $x = CFClient::floor +($ev->{x} - $self->{sx0}) / $self->{tilesize} - $self->{sx}; |
77 | my $x = 1 + CFClient::floor +($ev->{x} - $self->{sx0}) / $self->{tilesize} - $self->{sx}; |
72 | my $y = CFClient::floor +($ev->{y} - $self->{sy0}) / $self->{tilesize} - $self->{sy}; |
78 | my $y = 1 + CFClient::floor +($ev->{y} - $self->{sy0}) / $self->{tilesize} - $self->{sy}; |
73 | |
79 | |
74 | $x -= int 0.5 * $self->{sw}; |
80 | $x -= int 0.5 * $self->{sw}; |
75 | $y -= int 0.5 * $self->{sh}; |
81 | $y -= int 0.5 * $self->{sh}; |
76 | |
82 | |
77 | $::CONN->lookat ($x, $y) |
83 | $::CONN->lookat ($x, $y) |
78 | if $::CONN; |
84 | if $::CONN; |
79 | |
85 | |
80 | } elsif ($ev->{button} == 2) { |
86 | } elsif ($ev->{button} == 2) { |
|
|
87 | $self->grab_focus; |
|
|
88 | return unless $::CONN; |
|
|
89 | |
81 | my ($ox, $oy) = ($ev->{x}, $ev->{y}); |
90 | my ($ox, $oy) = ($ev->{x}, $ev->{y}); |
82 | my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y}); |
91 | my ($bw, $bh) = ($::CFG->{map_shift_x}, $::CFG->{map_shift_y}); |
83 | |
92 | |
84 | $self->{motion} = sub { |
93 | $self->{motion} = sub { |
85 | my ($ev, $x, $y) = @_; |
94 | my ($ev, $x, $y) = @_; |
… | |
… | |
89 | $::CFG->{map_shift_x} = $bw + $x - $ox; |
98 | $::CFG->{map_shift_x} = $bw + $x - $ox; |
90 | $::CFG->{map_shift_y} = $bh + $y - $oy; |
99 | $::CFG->{map_shift_y} = $bh + $y - $oy; |
91 | |
100 | |
92 | $self->update; |
101 | $self->update; |
93 | }; |
102 | }; |
|
|
103 | } elsif ($ev->{button} == 3) { |
|
|
104 | (new CFClient::UI::Menu |
|
|
105 | items => [ |
|
|
106 | ["Help Browser…\tF1", sub { $::HELP_WINDOW->toggle_visibility }], |
|
|
107 | ["Statistics\tF2", sub { ::toggle_player_page ($::STATS_PAGE) }], |
|
|
108 | ["Skills\tF3", sub { ::toggle_player_page ($::SKILL_PAGE) }], |
|
|
109 | ["Spells…\tF4", sub { ::toggle_player_page ($::SPELL_PAGE) }], |
|
|
110 | ["Inventory…\tF5", sub { ::toggle_player_page ($::INVENTORY_PAGE) }], |
|
|
111 | ["Setup… \tF9", sub { $::SETUP_DIALOG->toggle_visibility }], |
|
|
112 | ["Server Messages…", sub { $::MESSAGE_WINDOW->toggle_visibility }], |
|
|
113 | [ |
|
|
114 | $::PICKUP_ENABLE->{state} |
|
|
115 | ? "Disable automatic pickup" |
|
|
116 | : "Enable automatic pickup", |
|
|
117 | sub { $::PICKUP_ENABLE->toggle } |
|
|
118 | ], |
|
|
119 | ], |
|
|
120 | )->popup ($ev); |
94 | } |
121 | } |
95 | |
122 | |
96 | 1 |
123 | 1 |
97 | } |
124 | } |
98 | |
125 | |
99 | sub button_up { |
126 | sub invoke_button_up { |
100 | my ($self, $ev, $x, $y) = @_; |
127 | my ($self, $ev, $x, $y) = @_; |
101 | |
128 | |
102 | delete $self->{motion}; |
129 | delete $self->{motion}; |
103 | |
130 | |
104 | 1 |
131 | 1 |
105 | } |
132 | } |
106 | |
133 | |
107 | sub mouse_motion { |
134 | sub invoke_mouse_motion { |
108 | my ($self, $ev, $x, $y) = @_; |
135 | my ($self, $ev, $x, $y) = @_; |
109 | |
136 | |
110 | if ($self->{motion}) { |
137 | if ($self->{motion}) { |
111 | $self->{motion}->($ev, $x, $y); |
138 | $self->{motion}->($ev, $x, $y); |
112 | } else { |
139 | } else { |
… | |
… | |
116 | 1 |
143 | 1 |
117 | } |
144 | } |
118 | |
145 | |
119 | sub size_request { |
146 | sub size_request { |
120 | ( |
147 | ( |
121 | 1 + 32 * int $::WIDTH / 32, |
148 | 32 * CFClient::ceil $::WIDTH / 32, |
122 | 1 + 32 * int $::HEIGHT / 32, |
149 | 32 * CFClient::ceil $::HEIGHT / 32, |
123 | ) |
150 | ) |
124 | } |
151 | } |
125 | |
152 | |
126 | sub update { |
153 | sub update { |
127 | my ($self) = @_; |
154 | my ($self) = @_; |
… | |
… | |
144 | CFClient::SDLK_RIGHT, [3, "east"], |
171 | CFClient::SDLK_RIGHT, [3, "east"], |
145 | CFClient::SDLK_DOWN, [5, "south"], |
172 | CFClient::SDLK_DOWN, [5, "south"], |
146 | CFClient::SDLK_LEFT, [7, "west"], |
173 | CFClient::SDLK_LEFT, [7, "west"], |
147 | ); |
174 | ); |
148 | |
175 | |
149 | sub key_down { |
176 | sub invoke_key_down { |
150 | my ($self, $ev) = @_; |
177 | my ($self, $ev) = @_; |
151 | |
|
|
152 | return 0 unless $::CONN; |
|
|
153 | |
178 | |
154 | my $mod = $ev->{mod}; |
179 | my $mod = $ev->{mod}; |
155 | my $sym = $ev->{sym}; |
180 | my $sym = $ev->{sym}; |
156 | my $uni = $ev->{unicode}; |
181 | my $uni = $ev->{unicode}; |
157 | |
182 | |
|
|
183 | $mod &= CFClient::KMOD_CTRL | CFClient::KMOD_ALT | CFClient::KMOD_SHIFT; |
|
|
184 | |
|
|
185 | if ($uni == ord "\t") { |
|
|
186 | $::PL_WINDOW->toggle_visibility; |
|
|
187 | } elsif ($sym == CFClient::SDLK_F1 && !$mod) { |
|
|
188 | $::HELP_WINDOW->toggle_visibility; |
|
|
189 | } elsif ($sym == CFClient::SDLK_F2 && !$mod) { |
|
|
190 | ::toggle_player_page ($::STATS_PAGE); |
|
|
191 | } elsif ($sym == CFClient::SDLK_F3 && !$mod) { |
|
|
192 | ::toggle_player_page ($::SKILL_PAGE); |
|
|
193 | } elsif ($sym == CFClient::SDLK_F4 && !$mod) { |
|
|
194 | ::toggle_player_page ($::SPELL_PAGE); |
|
|
195 | } elsif ($sym == CFClient::SDLK_F5 && !$mod) { |
|
|
196 | ::toggle_player_page ($::INVENTORY_PAGE); |
|
|
197 | } elsif ($sym == CFClient::SDLK_F9 && !$mod) { |
|
|
198 | $::SETUP_DIALOG->toggle_visibility; |
|
|
199 | } elsif ($sym == CFClient::SDLK_INSERT && $mod & CFClient::KMOD_CTRL) { |
|
|
200 | $::BIND_EDITOR->set_binding (undef, undef, [], |
|
|
201 | sub { |
|
|
202 | my ($mod, $sym, $cmds) = @_; |
|
|
203 | $::BIND_EDITOR->cfg_bind ($mod, $sym, $cmds); |
|
|
204 | }); |
|
|
205 | $::BIND_EDITOR->start; |
|
|
206 | $::BIND_EDITOR->show; |
|
|
207 | } elsif ($sym == CFClient::SDLK_INSERT && not ($mod & CFClient::KMOD_CTRL)) { |
|
|
208 | $::BIND_EDITOR->stop; |
|
|
209 | $::BIND_EDITOR->ask_for_bind_and_commit; |
|
|
210 | $::BIND_EDITOR->hide; |
|
|
211 | } elsif (!$::CONN) { |
|
|
212 | return 0; # bindings further down need a valid connection |
|
|
213 | |
158 | if ($sym == CFClient::SDLK_KP5) { |
214 | } elsif ($sym == CFClient::SDLK_KP5 && !$mod) { |
159 | $::CONN->user_send ("stay fire"); |
215 | $::CONN->user_send ("stay fire"); |
160 | } elsif ($uni == ord ",") { |
216 | } elsif ($uni == ord ",") { |
161 | $::CONN->user_send ("take"); |
217 | $::CONN->user_send ("take"); |
162 | } elsif ($uni == ord " ") { |
218 | } elsif ($uni == ord " ") { |
163 | $::CONN->user_send ("apply"); |
219 | $::CONN->user_send ("apply"); |
164 | } elsif ($uni == ord ".") { |
220 | } elsif ($uni == ord ".") { |
165 | $::CONN->user_send ($self->{completer}{last_command}) |
221 | $::CONN->user_send ($self->{completer}{last_command}) |
166 | if exists $self->{completer}{last_command}; |
222 | if exists $self->{completer}{last_command}; |
167 | } elsif ($uni == ord "\t") { |
223 | } elsif (my $bind_cmd = $::CFG->{profile}{default}{bindings}{$mod}{$sym}) { |
168 | $::INV_WINDOW->toggle_visibility; |
224 | $::CONN->user_send ($_) for @$bind_cmd; |
169 | } elsif ($sym == CFClient::SDLK_KP_PLUS || $uni == ord "+") { |
225 | } elsif (($sym == CFClient::SDLK_KP_PLUS && !$mod) || $uni == ord "+") { |
170 | $::CONN->user_send ("rotateshoottype +"); |
226 | $::CONN->user_send ("rotateshoottype +"); |
171 | } elsif ($sym == CFClient::SDLK_KP_MINUS || $uni == ord "-") { |
227 | } elsif (($sym == CFClient::SDLK_KP_MINUS && !$mod) || $uni == ord "-") { |
172 | $::CONN->user_send ("rotateshoottype -"); |
228 | $::CONN->user_send ("rotateshoottype -"); |
173 | } elsif ($uni == ord '"') { |
229 | } elsif ($uni == ord '"') { |
174 | $self->{completer}->set_prefix ("$::CFG->{say_command} "); |
230 | $self->{completer}->set_prefix ("$::CFG->{say_command} "); |
175 | $self->{completer}->show; |
231 | $self->{completer}->show; |
176 | } elsif ($uni == ord "'") { |
232 | } elsif ($uni == ord "'") { |
… | |
… | |
187 | $self->{ctrl}++; |
243 | $self->{ctrl}++; |
188 | $::CONN->user_send ("run $DIR{$sym}[0]"); |
244 | $::CONN->user_send ("run $DIR{$sym}[0]"); |
189 | } else { |
245 | } else { |
190 | $::CONN->user_send ("$DIR{$sym}[1]"); |
246 | $::CONN->user_send ("$DIR{$sym}[1]"); |
191 | } |
247 | } |
192 | } elsif ($sym == CFClient::SDLK_INSERT && $mod & CFClient::KMOD_CTRL) { |
|
|
193 | $::BIND_EDITOR->set_binding (undef, undef, [], |
|
|
194 | sub { |
|
|
195 | my ($mod, $sym, $cmds) = @_; |
|
|
196 | $::CFG->{bindings}->{$mod}->{$sym} = $cmds; |
|
|
197 | }); |
|
|
198 | $::BIND_EDITOR->start; |
|
|
199 | $::BIND_EDITOR->show; |
|
|
200 | } elsif ($sym == CFClient::SDLK_INSERT && not ($mod & CFClient::KMOD_CTRL)) { |
|
|
201 | $::BIND_EDITOR->stop; |
|
|
202 | $::BIND_EDITOR->ask_for_bind_and_commit; |
|
|
203 | $::BIND_EDITOR->hide; |
|
|
204 | } elsif (my $bind_cmd = $::CFG->{bindings}->{$mod}->{$sym}) { |
|
|
205 | $::CONN->user_send ($_) for @$bind_cmd; |
|
|
206 | } elsif ((ord 'a') <= $uni && $uni <= (ord 'z')) { |
248 | } elsif ((ord 'a') <= $uni && $uni <= (ord 'z')) { |
207 | $self->{completer}->key_down ($ev); |
249 | $self->{completer}->invoke_key_down ($ev); |
208 | $self->{completer}->show; |
250 | $self->{completer}->show; |
209 | } else { |
251 | } else { |
210 | return 0; |
252 | return 0; |
211 | } |
253 | } |
212 | |
254 | |
213 | 1 |
255 | 1 |
214 | } |
256 | } |
215 | |
257 | |
216 | sub key_up { |
258 | sub invoke_key_up { |
217 | my ($self, $ev) = @_; |
259 | my ($self, $ev) = @_; |
218 | |
260 | |
219 | my $res = 0; |
261 | my $res = 0; |
220 | my $mod = $ev->{mod}; |
262 | my $mod = $ev->{mod}; |
221 | my $sym = $ev->{sym}; |
263 | my $sym = $ev->{sym}; |
… | |
… | |
244 | } |
286 | } |
245 | |
287 | |
246 | $res |
288 | $res |
247 | } |
289 | } |
248 | |
290 | |
|
|
291 | sub set_magicmap { |
|
|
292 | my ($self, $w, $h, $x, $y, $data) = @_; |
|
|
293 | |
|
|
294 | $x -= $::MAP->ox + int 0.5 * $::MAP->w; |
|
|
295 | $y -= $::MAP->oy + int 0.5 * $::MAP->h; |
|
|
296 | |
|
|
297 | $self->{magicmap} = [$x, $y, $w, $h, $data]; |
|
|
298 | |
|
|
299 | $self->update; |
|
|
300 | } |
|
|
301 | |
249 | sub draw { |
302 | sub draw { |
250 | my ($self) = @_; |
303 | my ($self) = @_; |
251 | |
304 | |
252 | return unless $::MAP; |
305 | return unless $::MAP; |
253 | |
306 | |
… | |
… | |
264 | my $sy = $self->{sy} = CFClient::ceil $::CFG->{map_shift_y} / $tilesize; |
317 | my $sy = $self->{sy} = CFClient::ceil $::CFG->{map_shift_y} / $tilesize; |
265 | |
318 | |
266 | my $sx0 = $self->{sx0} = $::CFG->{map_shift_x} - $sx * $tilesize; |
319 | my $sx0 = $self->{sx0} = $::CFG->{map_shift_x} - $sx * $tilesize; |
267 | my $sy0 = $self->{sy0} = $::CFG->{map_shift_y} - $sy * $tilesize; |
320 | my $sy0 = $self->{sy0} = $::CFG->{map_shift_y} - $sy * $tilesize; |
268 | |
321 | |
269 | my $sw = $self->{sw} = 1 + CFClient::ceil $::WIDTH / $tilesize; |
322 | my $sw = $self->{sw} = 1 + CFClient::ceil $self->{w} / $tilesize; |
270 | my $sh = $self->{sh} = 1 + CFClient::ceil $::HEIGHT / $tilesize; |
323 | my $sh = $self->{sh} = 1 + CFClient::ceil $self->{h} / $tilesize; |
271 | |
324 | |
272 | if ($::CFG->{fow_enable}) { |
325 | if ($::CFG->{fow_enable}) { |
273 | my ($w, $h, $data) = $::MAP->fow_texture ($sx, $sy, 0, 0, $sw, $sh); |
326 | my ($w, $h, $data) = $::MAP->fow_texture ($sx, $sy, 0, 0, $sw, $sh); |
274 | |
327 | |
275 | if ($::CFG->{fow_smooth} && $CFClient::OpenGL::GL_VERSION >= 1.2) { # smooth fog of war |
328 | if ($::CFG->{fow_smooth} && $CFClient::OpenGL::GL_VERSION >= 1.2) { # smooth fog of war |
… | |
… | |
302 | glTranslate $sx0, $sy0; |
355 | glTranslate $sx0, $sy0; |
303 | glScale $::CFG->{map_scale}, $::CFG->{map_scale}; |
356 | glScale $::CFG->{map_scale}, $::CFG->{map_scale}; |
304 | |
357 | |
305 | $::MAP->draw ($sx, $sy, 0, 0, $sw, $sh); |
358 | $::MAP->draw ($sx, $sy, 0, 0, $sw, $sh); |
306 | |
359 | |
|
|
360 | glScale 32, 32; |
|
|
361 | |
307 | if (my $tex = $self->{fow_texture}) { |
362 | if (my $tex = $self->{fow_texture}) { |
308 | glEnable GL_TEXTURE_2D; |
363 | glEnable GL_TEXTURE_2D; |
309 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
364 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
310 | |
365 | |
311 | glScale 32, 32; |
|
|
312 | glColor +($::CFG->{fow_intensity}) x 3, 0.9; |
366 | glColor +($::CFG->{fow_intensity}) x 3, 0.9; |
313 | $self->{fow_texture}->draw_quad_alpha (0, 0); |
367 | $self->{fow_texture}->draw_quad_alpha (0, 0); |
314 | |
368 | |
315 | glDisable GL_TEXTURE_2D; |
369 | glDisable GL_TEXTURE_2D; |
316 | } |
370 | } |
317 | |
371 | |
|
|
372 | if ($self->{magicmap}) { |
|
|
373 | my ($x, $y, $w, $h, $data) = @{ $self->{magicmap} }; |
|
|
374 | |
|
|
375 | $x += $::MAP->ox - $sx + int 0.5 * ($::MAP->w - $sw + 1); |
|
|
376 | $y += $::MAP->oy - $sy + int 0.5 * ($::MAP->h - $sh + 1); |
|
|
377 | |
|
|
378 | glTranslate - $x - 1, - $y - 1; |
|
|
379 | glBindTexture GL_TEXTURE_2D, $magicmap_tex->{name}; |
|
|
380 | $::MAP->draw_magicmap ($x, $y, $w, $h, $data); |
|
|
381 | } |
|
|
382 | |
318 | glPopMatrix; |
383 | glPopMatrix; |
319 | |
|
|
320 | glEndList; |
384 | glEndList; |
321 | } |
385 | } |
322 | |
386 | |
323 | glPushMatrix; |
|
|
324 | glCallList $self->{list}; |
387 | glCallList $self->{list}; |
325 | glPopMatrix; |
|
|
326 | |
388 | |
327 | # TNT2 emulates logops in software (or worse :) |
389 | # TNT2 emulates logops in software (or worse :) |
328 | unless ($focused) { |
390 | unless ($focused) { |
329 | glColor 0.4, 0.2, 0.2, 0.6; |
391 | glColor 0.4, 0.2, 0.2, 0.6; |
330 | glEnable GL_BLEND; |
392 | glEnable GL_BLEND; |
… | |
… | |
356 | |
418 | |
357 | sub size_request { |
419 | sub size_request { |
358 | ($::HEIGHT * 0.25, $::HEIGHT * 0.25) |
420 | ($::HEIGHT * 0.25, $::HEIGHT * 0.25) |
359 | } |
421 | } |
360 | |
422 | |
361 | sub size_allocate { |
423 | sub invoke_size_allocate { |
362 | my ($self, $w, $h) = @_; |
424 | my ($self, $w, $h) = @_; |
363 | |
425 | |
364 | $self->SUPER::size_allocate ($w, $h); |
|
|
365 | $self->update; |
426 | $self->update; |
|
|
427 | |
|
|
428 | 1 |
366 | } |
429 | } |
367 | |
430 | |
368 | sub update { |
431 | sub update { |
369 | my ($self) = @_; |
432 | my ($self) = @_; |
370 | |
433 | |
… | |
… | |
455 | ]; |
518 | ]; |
456 | |
519 | |
457 | $self->{entry} = new CFClient::UI::Entry |
520 | $self->{entry} = new CFClient::UI::Entry |
458 | on_changed => sub { |
521 | on_changed => sub { |
459 | $self->update_labels; |
522 | $self->update_labels; |
|
|
523 | 0 |
460 | }, |
524 | }, |
461 | on_button_down => sub { |
525 | on_button_down => sub { |
462 | my ($entry, $ev, $x, $y) = @_; |
526 | my ($entry, $ev, $x, $y) = @_; |
463 | |
527 | |
464 | if ($ev->{button} == 3) { |
528 | if ($ev->{button} == 3) { |
465 | (new CFClient::UI::Menu |
529 | (new CFClient::UI::Menu |
466 | items => [ |
530 | items => [ |
|
|
531 | ["bind <i>" . (CFClient::UI::Label::escape $self->{select}) . "</i> to a key" |
467 | ["bind to a key" => sub { $::BIND_EDITOR->do_quick_binding ([$self->{select}], sub { $entry->focus_in }) }] |
532 | => sub { $::BIND_EDITOR->do_quick_binding ([$self->{select}], sub { $entry->grab_focus }) }] |
468 | ], |
533 | ], |
469 | )->popup ($ev); |
534 | )->popup ($ev); |
470 | return 1; |
535 | return 1; |
471 | } |
536 | } |
472 | 0 |
537 | 0 |
… | |
… | |
479 | if ($ev->{sym} == 13) { |
544 | if ($ev->{sym} == 13) { |
480 | if (exists $self->{select}) { |
545 | if (exists $self->{select}) { |
481 | $self->{last_command} = $self->{select}; |
546 | $self->{last_command} = $self->{select}; |
482 | $::CONN->user_send ($self->{select}); |
547 | $::CONN->user_send ($self->{select}); |
483 | |
548 | |
484 | unshift @{$self->{history}}, $self->{select}; |
549 | unshift @{$self->{history}}, $self->{entry}->get_text; |
485 | $self->{hist_ptr} = 0; |
550 | $self->{hist_ptr} = 0; |
486 | |
551 | |
487 | $self->hide; |
552 | $self->hide; |
488 | } |
553 | } |
489 | } elsif ($ev->{sym} == 27) { |
554 | } elsif ($ev->{sym} == 27) { |
490 | $self->{hist_ptr} = 0; |
555 | $self->{hist_ptr} = 0; |
491 | $self->hide; |
556 | $self->hide; |
492 | return; |
|
|
493 | } elsif ($ev->{sym} == CFClient::SDLK_DOWN) { |
557 | } elsif ($ev->{sym} == CFClient::SDLK_DOWN) { |
494 | if ($self->{hist_ptr} > 1) { |
558 | if ($self->{hist_ptr} > 1) { |
495 | $self->{hist_ptr}--; |
559 | $self->{hist_ptr}--; |
496 | $self->{entry}->set_text ($self->{history}->[$self->{hist_ptr} - 1]); |
560 | $self->{entry}->set_text ($self->{history}->[$self->{hist_ptr} - 1]); |
497 | } elsif ($self->{hist_ptr} > 0) { |
561 | } elsif ($self->{hist_ptr} > 0) { |
… | |
… | |
537 | |
601 | |
538 | $self->{entry}->set_text ($prefix); |
602 | $self->{entry}->set_text ($prefix); |
539 | $self->show; |
603 | $self->show; |
540 | } |
604 | } |
541 | |
605 | |
542 | sub size_allocate { |
606 | sub invoke_size_allocate { |
543 | my ($self, $w, $h) = @_; |
607 | my ($self, $w, $h) = @_; |
544 | |
608 | |
545 | $self->SUPER::size_allocate ($w, $h); |
|
|
546 | $self->move_abs (($::WIDTH - $w) * 0.5, ($::HEIGHT - $h) * 0.6, 10); |
609 | $self->move_abs (($::WIDTH - $w) * 0.5, ($::HEIGHT - $h) * 0.6, 10); |
|
|
610 | |
|
|
611 | $self->SUPER::invoke_size_allocate ($w, $h) |
547 | } |
612 | } |
548 | |
613 | |
549 | sub show { |
614 | sub show { |
550 | my ($self) = @_; |
615 | my ($self) = @_; |
551 | |
616 | |
552 | $self->SUPER::show; |
617 | $self->SUPER::show; |
553 | $self->{entry}->focus_in; |
618 | $self->{entry}->grab_focus; |
554 | } |
619 | } |
555 | |
620 | |
556 | sub hide { |
621 | sub hide { |
557 | my ($self) = @_; |
622 | my ($self) = @_; |
|
|
623 | |
|
|
624 | $self->{hist_ptr} = 0; |
558 | |
625 | |
559 | $self->SUPER::hide; |
626 | $self->SUPER::hide; |
560 | $self->{entry}->set_text (""); |
627 | $self->{entry}->set_text (""); |
561 | } |
628 | } |
562 | |
629 | |
563 | sub key_down { |
630 | sub invoke_key_down { |
564 | my ($self, $ev) = @_; |
631 | my ($self, $ev) = @_; |
565 | |
632 | |
566 | $self->{entry}->key_down ($ev) |
633 | $self->{entry}->emit (key_down => $ev) |
567 | } |
634 | } |
568 | |
635 | |
569 | sub update_labels { |
636 | sub update_labels { |
570 | my ($self) = @_; |
637 | my ($self) = @_; |
571 | |
638 | |
… | |
… | |
658 | $label->set_text (""); |
725 | $label->set_text (""); |
659 | $label->set_tooltip (""); |
726 | $label->set_tooltip (""); |
660 | } |
727 | } |
661 | |
728 | |
662 | $self->update; |
729 | $self->update; |
663 | ### |
|
|
664 | } |
730 | } |
665 | |
731 | |
666 | sub _draw { |
732 | sub _draw { |
667 | my ($self) = @_; |
733 | my ($self) = @_; |
668 | |
734 | |