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.79 by elmex, Mon Jul 24 12:25:09 2006 UTC vs.
Revision 1.83 by root, Sun Oct 1 14:48:51 2006 UTC

1package CFClient::MapWidget; 1package CFPlus::MapWidget;
2 2
3use strict; 3use strict;
4use utf8; 4use utf8;
5 5
6use List::Util qw(min max); 6use List::Util qw(min max);
7 7
8use CFClient; 8use CFPlus;
9use CFClient::OpenGL; 9use CFPlus::OpenGL;
10use CFClient::UI; 10use CFPlus::UI;
11 11
12our @ISA = CFClient::UI::Base::; 12our @ISA = CFPlus::UI::Base::;
13 13
14my $magicmap_tex = 14my $magicmap_tex =
15 new_from_file CFClient::Texture CFClient::find_rcfile "magicmap.png", 15 new_from_file CFPlus::Texture CFPlus::find_rcfile "magicmap.png",
16 mipmap => 1, wrap => 0, internalformat => GL_ALPHA; 16 mipmap => 1, wrap => 0, internalformat => GL_ALPHA;
17 17
18sub new { 18sub new {
19 my $class = shift; 19 my $class = shift;
20 20
30 ], 30 ],
31 31
32 @_ 32 @_
33 ); 33 );
34 34
35 $self->{completer} = new CFClient::MapWidget::Command:: 35 $self->{completer} = new CFPlus::MapWidget::Command::
36 command => $self->{command}, 36 command => $self->{command},
37 tooltip => "<b>The Command Completer</b>\n\n" 37 tooltip => "#completer_help",
38 . "This is your central interface to send text commands to the server. "
39 . "To enter a verbatim command to send to the server, just type the command, "
40 . "followed by a space, and press return. "
41 . "Typing the initial letters of words (or just any letters) displays guesses "
42 . "for commands you might want to use.\n"
43 . "You can use the cursor-up and cursor-down keys to select between those guesses.\n"
44 . "<b>Right-Click</b> opens a menu where you cna select further options, sich as redefining key bindings.",
45 ; 38 ;
46 39
47 $self 40 $self
48} 41}
49 42
66 59
67 $self->{completer}->hide 60 $self->{completer}->hide
68 if $self->{completer}; 61 if $self->{completer};
69} 62}
70 63
64sub test_server_login {
65 return unless
66 $::CONN && length $::CONN->{test_server};
67
68 my $server = $::CONN->{test_server};
69 ::stop_game ();
70 local $::PROFILE->{host} = $server;
71 ::start_game ();
72}
73
74sub editor_invoke {
75 return unless $::CONN;
76
77 # putting the password into the env is somewhat tasteless
78 local $ENV{CFPLUS_LOGIN} = $::PROFILE->{user};
79 local $ENV{CFPLUS_PASSWORD} = $::PROFILE->{password};
80 local $ENV{CFPLUS_UPLOAD} = $::CONN->{upload};
81 local $ENV{CROSSFIRE_MAPDIR} = $::CONN->{cvs_root};
82
83# CFPlus::set_proxy;
84
85 # TODO: move into editor
86 require LWP::Simple;
87}
88
71sub invoke_button_down { 89sub invoke_button_down {
72 my ($self, $ev, $x, $y) = @_; 90 my ($self, $ev, $x, $y) = @_;
73 91
74 if ($ev->{button} == 1) { 92 if ($ev->{button} == 1) {
75 $self->grab_focus; 93 $self->grab_focus;
76 return unless $::CONN; 94 return unless $::CONN;
77 95
78 my $x = 1 + CFClient::floor +($ev->{x} - $self->{sx0}) / $self->{tilesize} - $self->{sx}; 96 my $x = 1 + CFPlus::floor +($ev->{x} - $self->{sx0}) / $self->{tilesize} - $self->{sx};
79 my $y = 1 + CFClient::floor +($ev->{y} - $self->{sy0}) / $self->{tilesize} - $self->{sy}; 97 my $y = 1 + CFPlus::floor +($ev->{y} - $self->{sy0}) / $self->{tilesize} - $self->{sy};
80 98
81 $x -= int 0.5 * $self->{sw}; 99 $x -= int 0.5 * $self->{sw};
82 $y -= int 0.5 * $self->{sh}; 100 $y -= int 0.5 * $self->{sh};
83 101
84 $::CONN->lookat ($x, $y) 102 $::CONN->lookat ($x, $y)
100 $::CFG->{map_shift_y} = $bh + $y - $oy; 118 $::CFG->{map_shift_y} = $bh + $y - $oy;
101 119
102 $self->update; 120 $self->update;
103 }; 121 };
104 } elsif ($ev->{button} == 3) { 122 } elsif ($ev->{button} == 3) {
105 (new CFClient::UI::Menu 123 (new CFPlus::UI::Menu
106 items => [ 124 items => [
107 ["Help Browser…\tF1", sub { $::HELP_WINDOW->toggle_visibility }], 125 ["Help Browser…\tF1", sub { $::HELP_WINDOW->toggle_visibility }],
108 ["Statistics\tF2", sub { ::toggle_player_page ($::STATS_PAGE) }], 126 ["Statistics\tF2", sub { ::toggle_player_page ($::STATS_PAGE) }],
109 ["Skills\tF3", sub { ::toggle_player_page ($::SKILL_PAGE) }], 127 ["Skills\tF3", sub { ::toggle_player_page ($::SKILL_PAGE) }],
110 ["Spells…\tF4", sub { ::toggle_player_page ($::SPELL_PAGE) }], 128 ["Spells…\tF4", sub { ::toggle_player_page ($::SPELL_PAGE) }],
115 $::PICKUP_ENABLE->{state} 133 $::PICKUP_ENABLE->{state}
116 ? "Disable automatic pickup" 134 ? "Disable automatic pickup"
117 : "Enable automatic pickup", 135 : "Enable automatic pickup",
118 sub { $::PICKUP_ENABLE->toggle } 136 sub { $::PICKUP_ENABLE->toggle }
119 ], 137 ],
138 $::CONN && length $::CONN->{cvs_root}
139 ? ["Edit this map <span size='xx-small'>(" . (CFPlus::asxml $::CONN->{map_info}[0]) . ")</span>", \&editor_invoke]
140 : (),
141 $::CONN && length $::CONN->{test_server}
142 ? ["Login on Test Server", \&test_server_login]
143 : (),
120 ["Quit", 144 ["Quit",
121 sub { 145 sub {
122 if ($::CONN) { 146 if ($::CONN) {
123 &::open_quit_dialog; 147 &::open_quit_dialog;
124 } else { 148 } else {
153 1 177 1
154} 178}
155 179
156sub size_request { 180sub size_request {
157 ( 181 (
158 32 * CFClient::ceil $::WIDTH / 32, 182 32 * CFPlus::ceil $::WIDTH / 32,
159 32 * CFClient::ceil $::HEIGHT / 32, 183 32 * CFPlus::ceil $::HEIGHT / 32,
160 ) 184 )
161} 185}
162 186
163sub update { 187sub update {
164 my ($self) = @_; 188 my ($self) = @_;
166 $self->{need_update} = 1; 190 $self->{need_update} = 1;
167 $self->SUPER::update; 191 $self->SUPER::update;
168} 192}
169 193
170my %DIR = ( 194my %DIR = (
171 CFClient::SDLK_KP8, [1, "north"], 195 CFPlus::SDLK_KP8, [1, "north"],
172 CFClient::SDLK_KP9, [2, "northeast"], 196 CFPlus::SDLK_KP9, [2, "northeast"],
173 CFClient::SDLK_KP6, [3, "east"], 197 CFPlus::SDLK_KP6, [3, "east"],
174 CFClient::SDLK_KP3, [4, "southeast"], 198 CFPlus::SDLK_KP3, [4, "southeast"],
175 CFClient::SDLK_KP2, [5, "south"], 199 CFPlus::SDLK_KP2, [5, "south"],
176 CFClient::SDLK_KP1, [6, "southwest"], 200 CFPlus::SDLK_KP1, [6, "southwest"],
177 CFClient::SDLK_KP4, [7, "west"], 201 CFPlus::SDLK_KP4, [7, "west"],
178 CFClient::SDLK_KP7, [8, "northwest"], 202 CFPlus::SDLK_KP7, [8, "northwest"],
179 203
180 CFClient::SDLK_UP, [1, "north"], 204 CFPlus::SDLK_UP, [1, "north"],
181 CFClient::SDLK_RIGHT, [3, "east"], 205 CFPlus::SDLK_RIGHT, [3, "east"],
182 CFClient::SDLK_DOWN, [5, "south"], 206 CFPlus::SDLK_DOWN, [5, "south"],
183 CFClient::SDLK_LEFT, [7, "west"], 207 CFPlus::SDLK_LEFT, [7, "west"],
184); 208);
185 209
186sub invoke_key_down { 210sub invoke_key_down {
187 my ($self, $ev) = @_; 211 my ($self, $ev) = @_;
188 212
189 my $mod = $ev->{mod}; 213 my $mod = $ev->{mod};
190 my $sym = $ev->{sym}; 214 my $sym = $ev->{sym};
191 my $uni = $ev->{unicode}; 215 my $uni = $ev->{unicode};
192 216
193 $mod &= CFClient::KMOD_CTRL | CFClient::KMOD_ALT | CFClient::KMOD_SHIFT; 217 $mod &= CFPlus::KMOD_CTRL | CFPlus::KMOD_ALT | CFPlus::KMOD_SHIFT;
194 218
195 if ($uni == ord "\t") { 219 if ($uni == ord "\t") {
196 $::PL_WINDOW->toggle_visibility; 220 $::PL_WINDOW->toggle_visibility;
197 } elsif ($sym == CFClient::SDLK_F1 && !$mod) { 221 } elsif ($sym == CFPlus::SDLK_F1 && !$mod) {
198 $::HELP_WINDOW->toggle_visibility; 222 $::HELP_WINDOW->toggle_visibility;
199 } elsif ($sym == CFClient::SDLK_F2 && !$mod) { 223 } elsif ($sym == CFPlus::SDLK_F2 && !$mod) {
200 ::toggle_player_page ($::STATS_PAGE); 224 ::toggle_player_page ($::STATS_PAGE);
201 } elsif ($sym == CFClient::SDLK_F3 && !$mod) { 225 } elsif ($sym == CFPlus::SDLK_F3 && !$mod) {
202 ::toggle_player_page ($::SKILL_PAGE); 226 ::toggle_player_page ($::SKILL_PAGE);
203 } elsif ($sym == CFClient::SDLK_F4 && !$mod) { 227 } elsif ($sym == CFPlus::SDLK_F4 && !$mod) {
204 ::toggle_player_page ($::SPELL_PAGE); 228 ::toggle_player_page ($::SPELL_PAGE);
205 } elsif ($sym == CFClient::SDLK_F5 && !$mod) { 229 } elsif ($sym == CFPlus::SDLK_F5 && !$mod) {
206 ::toggle_player_page ($::INVENTORY_PAGE); 230 ::toggle_player_page ($::INVENTORY_PAGE);
207 } elsif ($sym == CFClient::SDLK_F9 && !$mod) { 231 } elsif ($sym == CFPlus::SDLK_F9 && !$mod) {
208 $::SETUP_DIALOG->toggle_visibility; 232 $::SETUP_DIALOG->toggle_visibility;
209 } elsif ($sym == CFClient::SDLK_INSERT && $mod & CFClient::KMOD_CTRL) { 233 } elsif ($sym == CFPlus::SDLK_INSERT && $mod & CFPlus::KMOD_CTRL) {
210 $::BIND_EDITOR->set_binding (undef, undef, [], 234 $::BIND_EDITOR->set_binding (undef, undef, [],
211 sub { 235 sub {
212 my ($mod, $sym, $cmds) = @_; 236 my ($mod, $sym, $cmds) = @_;
213 $::BIND_EDITOR->cfg_bind ($mod, $sym, $cmds); 237 $::BIND_EDITOR->cfg_bind ($mod, $sym, $cmds);
214 }); 238 });
215 $::BIND_EDITOR->start; 239 $::BIND_EDITOR->start;
216 $::BIND_EDITOR->show; 240 $::BIND_EDITOR->show;
241#TODO: elmex, what was this supposed to do? it currently crashes the client.
217 } elsif ($sym == CFClient::SDLK_INSERT && not ($mod & CFClient::KMOD_CTRL)) { 242# } elsif ($sym == CFPlus::SDLK_INSERT && not ($mod & CFPlus::KMOD_CTRL)) {
218 $::BIND_EDITOR->stop; 243# $::BIND_EDITOR->stop;
219 $::BIND_EDITOR->ask_for_bind_and_commit; 244# $::BIND_EDITOR->ask_for_bind_and_commit;
220 $::BIND_EDITOR->hide; 245# $::BIND_EDITOR->hide;
221 } elsif (!$::CONN) { 246 } elsif (!$::CONN) {
222 return 0; # bindings further down need a valid connection 247 return 0; # bindings further down need a valid connection
223 248
224 } elsif ($sym == CFClient::SDLK_KP5 && !$mod) { 249 } elsif ($sym == CFPlus::SDLK_KP5 && !$mod) {
225 $::CONN->user_send ("stay fire"); 250 $::CONN->user_send ("stay fire");
226 } elsif ($uni == ord ",") { 251 } elsif ($uni == ord ",") {
227 $::CONN->user_send ("take"); 252 $::CONN->user_send ("take");
228 } elsif ($uni == ord " ") { 253 } elsif ($uni == ord " ") {
229 $::CONN->user_send ("apply"); 254 $::CONN->user_send ("apply");
255 } elsif ($uni == 13) {
256 $::CONN->user_send ("examine");
230 } elsif ($uni == ord ".") { 257 } elsif ($uni == ord ".") {
231 $::CONN->user_send ($self->{completer}{last_command}) 258 $::CONN->user_send ($self->{completer}{last_command})
232 if exists $self->{completer}{last_command}; 259 if exists $self->{completer}{last_command};
233 } elsif (my $bind_cmd = $::CFG->{profile}{default}{bindings}{$mod}{$sym}) { 260 } elsif (my $bind_cmd = $::PROFILE->{bindings}{$mod}{$sym}) {
234 $::CONN->user_send ($_) for @$bind_cmd; 261 $::CONN->user_send ($_) for @$bind_cmd;
235 } elsif (($sym == CFClient::SDLK_KP_PLUS && !$mod) || $uni == ord "+") { 262 } elsif (($sym == CFPlus::SDLK_KP_PLUS && !$mod) || $uni == ord "+") {
236 $::CONN->user_send ("rotateshoottype +"); 263 $::CONN->user_send ("rotateshoottype +");
237 } elsif (($sym == CFClient::SDLK_KP_MINUS && !$mod) || $uni == ord "-") { 264 } elsif (($sym == CFPlus::SDLK_KP_MINUS && !$mod) || $uni == ord "-") {
238 $::CONN->user_send ("rotateshoottype -"); 265 $::CONN->user_send ("rotateshoottype -");
239 } elsif ($uni == ord '"') { 266 } elsif ($uni == ord '"') {
240 $self->{completer}->set_prefix ("$::CFG->{say_command} "); 267 $self->{completer}->set_prefix ("$::CFG->{say_command} ");
241 $self->{completer}->show; 268 $self->{completer}->show;
242 } elsif ($uni == ord "'") { 269 } elsif ($uni == ord "'") {
243 $self->{completer}->set_prefix (""); 270 $self->{completer}->set_prefix ("");
244 $self->{completer}->show; 271 $self->{completer}->show;
245 } elsif (exists $DIR{$sym}) { 272 } elsif (exists $DIR{$sym}) {
246 if ($mod & CFClient::KMOD_SHIFT) { 273 if ($mod & CFPlus::KMOD_SHIFT) {
247 $self->{shft}++; 274 $self->{shft}++;
248 if ($DIR{$sym}[0] != $self->{fire_dir}) { 275 if ($DIR{$sym}[0] != $self->{fire_dir}) {
249 $::CONN->user_send ("fire $DIR{$sym}[0]"); 276 $::CONN->user_send ("fire $DIR{$sym}[0]");
250 } 277 }
251 $self->{fire_dir} = $DIR{$sym}[0]; 278 $self->{fire_dir} = $DIR{$sym}[0];
252 } elsif ($mod & CFClient::KMOD_CTRL) { 279 } elsif ($mod & CFPlus::KMOD_CTRL) {
253 $self->{ctrl}++; 280 $self->{ctrl}++;
254 $::CONN->user_send ("run $DIR{$sym}[0]"); 281 $::CONN->user_send ("run $DIR{$sym}[0]");
255 } else { 282 } else {
256 $::CONN->user_send ("$DIR{$sym}[1]"); 283 $::CONN->user_send ("$DIR{$sym}[1]");
257 } 284 }
271 my $res = 0; 298 my $res = 0;
272 my $mod = $ev->{mod}; 299 my $mod = $ev->{mod};
273 my $sym = $ev->{sym}; 300 my $sym = $ev->{sym};
274 301
275 if ($::CFG->{shift_fire_stop}) { 302 if ($::CFG->{shift_fire_stop}) {
276 if (!($mod & CFClient::KMOD_SHIFT) && delete $self->{shft}) { 303 if (!($mod & CFPlus::KMOD_SHIFT) && delete $self->{shft}) {
277 $::CONN->user_send ("fire_stop"); 304 $::CONN->user_send ("fire_stop");
278 delete $self->{fire_dir}; 305 delete $self->{fire_dir};
279 $res = 1; 306 $res = 1;
280 } 307 }
281 } else { 308 } else {
282 if (exists $DIR{$sym} && delete $self->{shft}) { 309 if (exists $DIR{$sym} && delete $self->{shft}) {
283 $::CONN->user_send ("fire_stop"); 310 $::CONN->user_send ("fire_stop");
284 delete $self->{fire_dir}; 311 delete $self->{fire_dir};
285 $res = 1; 312 $res = 1;
286 } elsif (($sym == CFClient::SDLK_LSHIFT || $sym == CFClient::SDLK_RSHIFT) && delete $self->{shft}) { # XXX: is RSHIFT ok? 313 } elsif (($sym == CFPlus::SDLK_LSHIFT || $sym == CFPlus::SDLK_RSHIFT) && delete $self->{shft}) { # XXX: is RSHIFT ok?
287 $::CONN->user_send ("fire_stop"); 314 $::CONN->user_send ("fire_stop");
288 delete $self->{fire_dir}; 315 delete $self->{fire_dir};
289 $res = 1; 316 $res = 1;
290 } 317 }
291 } 318 }
292 319
293 if (!($mod & CFClient::KMOD_CTRL ) && delete $self->{ctrl}) { 320 if (!($mod & CFPlus::KMOD_CTRL ) && delete $self->{ctrl}) {
294 $::CONN->user_send ("run_stop"); 321 $::CONN->user_send ("run_stop");
295 $res = 1; 322 $res = 1;
296 } 323 }
297 324
298 $res 325 $res
312sub draw { 339sub draw {
313 my ($self) = @_; 340 my ($self) = @_;
314 341
315 return unless $::MAP; 342 return unless $::MAP;
316 343
317 my $focused = $CFClient::UI::FOCUS == $self 344 my $focused = $CFPlus::UI::FOCUS == $self
318 || $CFClient::UI::FOCUS == $self->{completer}{entry}; 345 || $CFPlus::UI::FOCUS == $self->{completer}{entry};
319 346
320 return 347 return
321 unless $focused || !$::FAST; 348 unless $focused || !$::FAST;
322 349
323 if (delete $self->{need_update}) { 350 if (delete $self->{need_update}) {
324 my $tilesize = $self->{tilesize} = int 32 * $::CFG->{map_scale}; 351 my $tilesize = $self->{tilesize} = int 32 * $::CFG->{map_scale};
325 352
326 my $sx = $self->{sx} = CFClient::ceil $::CFG->{map_shift_x} / $tilesize; 353 my $sx = $self->{sx} = CFPlus::ceil $::CFG->{map_shift_x} / $tilesize;
327 my $sy = $self->{sy} = CFClient::ceil $::CFG->{map_shift_y} / $tilesize; 354 my $sy = $self->{sy} = CFPlus::ceil $::CFG->{map_shift_y} / $tilesize;
328 355
329 my $sx0 = $self->{sx0} = $::CFG->{map_shift_x} - $sx * $tilesize; 356 my $sx0 = $self->{sx0} = $::CFG->{map_shift_x} - $sx * $tilesize;
330 my $sy0 = $self->{sy0} = $::CFG->{map_shift_y} - $sy * $tilesize; 357 my $sy0 = $self->{sy0} = $::CFG->{map_shift_y} - $sy * $tilesize;
331 358
332 my $sw = $self->{sw} = 1 + CFClient::ceil $self->{w} / $tilesize; 359 my $sw = $self->{sw} = 1 + CFPlus::ceil $self->{w} / $tilesize;
333 my $sh = $self->{sh} = 1 + CFClient::ceil $self->{h} / $tilesize; 360 my $sh = $self->{sh} = 1 + CFPlus::ceil $self->{h} / $tilesize;
334 361
335 if ($::CFG->{fow_enable}) { 362 if ($::CFG->{fow_enable}) {
336 my ($w, $h, $data) = $::MAP->fow_texture ($sx, $sy, 0, 0, $sw, $sh); 363 my ($w, $h, $data) = $::MAP->fow_texture ($sx, $sy, 0, 0, $sw, $sh);
337 364
338 if ($::CFG->{fow_smooth} && $CFClient::OpenGL::GL_VERSION >= 1.2) { # smooth fog of war 365 if ($::CFG->{fow_smooth} && $CFPlus::OpenGL::GL_VERSION >= 1.2) { # smooth fog of war
339 glConvolutionParameter (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER); 366 glConvolutionParameter (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER);
340 glConvolutionFilter2D ( 367 glConvolutionFilter2D (
341 GL_CONVOLUTION_2D, 368 GL_CONVOLUTION_2D,
342 GL_ALPHA, 369 GL_ALPHA,
343 3, 3, 370 3, 3,
345 (pack "f*", @{ $self->{smooth_matrix} }), 372 (pack "f*", @{ $self->{smooth_matrix} }),
346 ); 373 );
347 glEnable GL_CONVOLUTION_2D; 374 glEnable GL_CONVOLUTION_2D;
348 } 375 }
349 376
350 $self->{fow_texture} = new CFClient::Texture 377 $self->{fow_texture} = new CFPlus::Texture
351 w => $w, 378 w => $w,
352 h => $h, 379 h => $h,
353 data => $data, 380 data => $data,
354 internalformat => GL_ALPHA, 381 internalformat => GL_ALPHA,
355 format => GL_ALPHA; 382 format => GL_ALPHA;
417 glDeleteList $self->{list}; 444 glDeleteList $self->{list};
418 445
419 $self->SUPER::DESTROY; 446 $self->SUPER::DESTROY;
420} 447}
421 448
422package CFClient::MapWidget::MapMap; 449package CFPlus::MapWidget::MapMap;
423 450
424our @ISA = CFClient::UI::Base::; 451our @ISA = CFPlus::UI::Base::;
425 452
426use Time::HiRes qw(time); 453use Time::HiRes qw(time);
427use CFClient::OpenGL; 454use CFPlus::OpenGL;
428 455
429sub size_request { 456sub size_request {
430 ($::HEIGHT * 0.25, $::HEIGHT * 0.25) 457 ($::HEIGHT * 0.25, $::HEIGHT * 0.25)
431} 458}
432 459
468 495
469 if ($self->{texture_atime} < time) { 496 if ($self->{texture_atime} < time) {
470 $self->{texture_atime} = time + 1/3; 497 $self->{texture_atime} = time + 1/3;
471 498
472 $self->{texture} = 499 $self->{texture} =
473 new CFClient::Texture 500 new CFPlus::Texture
474 w => $w, 501 w => $w,
475 h => $h, 502 h => $h,
476 data => $::MAP->mapmap (-$ox, -$oy, $w, $h), 503 data => $::MAP->mapmap (-$ox, -$oy, $w, $h),
477 type => $CFClient::GL_VERSION >= 1.2 ? GL_UNSIGNED_INT_8_8_8_8_REV : GL_UNSIGNED_BYTE; 504 type => $CFPlus::GL_VERSION >= 1.2 ? GL_UNSIGNED_INT_8_8_8_8_REV : GL_UNSIGNED_BYTE;
478 } 505 }
479 506
480 $self->{texture}->draw_quad (0, 0); 507 $self->{texture}->draw_quad (0, 0);
481 508
482 glDisable GL_TEXTURE_2D; 509 glDisable GL_TEXTURE_2D;
497 glEnd; 524 glEnd;
498 525
499 glDisable GL_BLEND; 526 glDisable GL_BLEND;
500} 527}
501 528
502package CFClient::MapWidget::Command; 529package CFPlus::MapWidget::Command;
503 530
504use strict; 531use strict;
505 532
506use CFClient::OpenGL; 533use CFPlus::OpenGL;
507 534
508our @ISA = CFClient::UI::Frame::; 535our @ISA = CFPlus::UI::Frame::;
509 536
510sub new { 537sub new {
511 my $class = shift; 538 my $class = shift;
512 539
513 my $self = $class->SUPER::new ( 540 my $self = $class->SUPER::new (
514 bg => [0, 0, 0, 0.8], 541 bg => [0, 0, 0, 0.8],
515 @_, 542 @_,
516 ); 543 );
517 544
518 $self->add ($self->{vbox} = new CFClient::UI::VBox); 545 $self->add ($self->{vbox} = new CFPlus::UI::VBox);
519 546
520 $self->{label} = [ 547 $self->{label} = [
521 map 548 map
522 CFClient::UI::Label->new ( 549 CFPlus::UI::Label->new (
523 can_hover => 1, 550 can_hover => 1,
524 can_events => 1, 551 can_events => 1,
525 tooltip_width => 0.33, 552 tooltip_width => 0.33,
526 fontsize => $_, 553 fontsize => $_,
527 ), (0.8) x 16 554 ), (0.8) x 16
528 ]; 555 ];
529 556
530 $self->{entry} = new CFClient::UI::Entry 557 $self->{entry} = new CFPlus::UI::Entry
531 on_changed => sub { 558 on_changed => sub {
532 $self->update_labels; 559 $self->update_labels;
533 0 560 0
534 }, 561 },
535 on_button_down => sub { 562 on_button_down => sub {
536 my ($entry, $ev, $x, $y) = @_; 563 my ($entry, $ev, $x, $y) = @_;
537 564
538 if ($ev->{button} == 3) { 565 if ($ev->{button} == 3) {
539 (new CFClient::UI::Menu 566 (new CFPlus::UI::Menu
540 items => [ 567 items => [
541 ["bind <i>" . (CFClient::asxml $self->{select}) . "</i> to a key" 568 ["bind <i>" . (CFPlus::asxml $self->{select}) . "</i> to a key"
542 => sub { $::BIND_EDITOR->do_quick_binding ([$self->{select}], sub { $entry->grab_focus }) }] 569 => sub { $::BIND_EDITOR->do_quick_binding ([$self->{select}], sub { $entry->grab_focus }) }]
543 ], 570 ],
544 )->popup ($ev); 571 )->popup ($ev);
545 return 1; 572 return 1;
546 } 573 }
562 $self->hide; 589 $self->hide;
563 } 590 }
564 } elsif ($ev->{sym} == 27) { 591 } elsif ($ev->{sym} == 27) {
565 $self->{hist_ptr} = 0; 592 $self->{hist_ptr} = 0;
566 $self->hide; 593 $self->hide;
567 } elsif ($ev->{sym} == CFClient::SDLK_DOWN) { 594 } elsif ($ev->{sym} == CFPlus::SDLK_DOWN) {
568 if ($self->{hist_ptr} > 1) { 595 if ($self->{hist_ptr} > 1) {
569 $self->{hist_ptr}--; 596 $self->{hist_ptr}--;
570 $self->{entry}->set_text ($self->{history}->[$self->{hist_ptr} - 1]); 597 $self->{entry}->set_text ($self->{history}->[$self->{hist_ptr} - 1]);
571 } elsif ($self->{hist_ptr} > 0) { 598 } elsif ($self->{hist_ptr} > 0) {
572 $self->{hist_ptr}--; 599 $self->{hist_ptr}--;
574 } else { 601 } else {
575 ++$self->{select_offset} 602 ++$self->{select_offset}
576 if $self->{select_offset} < $#{ $self->{last_match} || [] }; 603 if $self->{select_offset} < $#{ $self->{last_match} || [] };
577 } 604 }
578 $self->update_labels; 605 $self->update_labels;
579 } elsif ($ev->{sym} == CFClient::SDLK_UP) { 606 } elsif ($ev->{sym} == CFPlus::SDLK_UP) {
580 if ($self->{select_offset}) { 607 if ($self->{select_offset}) {
581 --$self->{select_offset} 608 --$self->{select_offset}
582 } else { 609 } else {
583 unless ($self->{hist_ptr}) { 610 unless ($self->{hist_ptr}) {
584 $self->{hist_saveback} = $self->{entry}->get_text; 611 $self->{hist_saveback} = $self->{entry}->get_text;
742 769
743sub _draw { 770sub _draw {
744 my ($self) = @_; 771 my ($self) = @_;
745 772
746 # hack 773 # hack
747 local $CFClient::UI::FOCUS = $self->{entry}; 774 local $CFPlus::UI::FOCUS = $self->{entry};
748 775
749 $self->SUPER::_draw; 776 $self->SUPER::_draw;
750} 777}
751 778
7521 7791

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines