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.108 by root, Wed Apr 25 01:12:31 2007 UTC vs.
Revision 1.122 by root, Wed Dec 5 10:49:17 2007 UTC

20 my $class = shift; 20 my $class = shift;
21 21
22 my $self = $class->SUPER::new ( 22 my $self = $class->SUPER::new (
23 z => -1, 23 z => -1,
24 can_focus => 1, 24 can_focus => 1,
25 list => glGenList,
26 tilesize => 32, 25 tilesize => 32,
27
28 smooth_matrix => [
29 0.05, 0.13, 0.05,
30 0.13, 0.30, 0.13,
31 0.05, 0.13, 0.05,
32 ],
33
34 @_ 26 @_
35 ); 27 );
36
37 $self->{completer} = new CFPlus::MapWidget::Command::
38 command => $self->{command},
39 tooltip => "#completer_help",
40 ;
41 28
42 $self 29 $self
43} 30}
44 31
45sub set_tilesize { 32sub set_tilesize {
55 42
56 $tooltip =~ s/^\s+//; 43 $tooltip =~ s/^\s+//;
57 $tooltip = "<big>$data</big>\n\n$tooltip"; 44 $tooltip = "<big>$data</big>\n\n$tooltip";
58 $tooltip =~ s/\s+$//; 45 $tooltip =~ s/\s+$//;
59 46
60 $self->{completer}{command}{$command} = [$data, $tooltip, $widget, $cb, ++$self->{command_id}]; 47 $::COMPLETER->{command}{$command} = [$data, $tooltip, $widget, $cb, ++$self->{command_id}];
61} 48}
62 49
63sub clr_commands { 50sub clr_commands {
64 my ($self) = @_; 51 my ($self) = @_;
65 52
66 %{$self->{completer}{command}} = (); 53 %{$::COMPLETER->{command}} = ();
67 54
68 $self->{completer}->hide 55 $::COMPLETER->hide
69 if $self->{completer}; 56 if $::COMPLETER;
70} 57}
71 58
72sub server_login { 59sub server_login {
73 my ($server) = @_; 60 my ($server) = @_;
74 61
133 require File::Path; 120 require File::Path;
134 121
135 File::Path::mkpath (File::Basename::dirname ($mappath)); 122 File::Path::mkpath (File::Basename::dirname ($mappath));
136 open my $fh, ">:raw:perlio", "$mappath.meta" 123 open my $fh, ">:raw:perlio", "$mappath.meta"
137 or die "$mappath.meta: $!\n"; 124 or die "$mappath.meta: $!\n";
138 print $fh CFPlus::to_json $meta; 125 print $fh CFPlus::encode_json $meta;
139 close $fh; 126 close $fh;
140 open my $fh, ">:raw:perlio:utf8", $mappath 127 open my $fh, ">:raw:perlio:utf8", $mappath
141 or die "$mappath: $!\n"; 128 or die "$mappath: $!\n";
142 print $fh $map; 129 print $fh $map;
143 close $fh; 130 close $fh;
191 178
192 $x -= CFPlus::floor $::MAP->w * 0.5; 179 $x -= CFPlus::floor $::MAP->w * 0.5;
193 $y -= CFPlus::floor $::MAP->h * 0.5; 180 $y -= CFPlus::floor $::MAP->h * 0.5;
194 181
195 if ($::CONN) { 182 if ($::CONN) {
196 if ($::IN_BUILD_MODE) {
197 $::CONN->buildat ($::IN_BUILD_MODE, $x, $y);
198 } else {
199 $::CONN->lookat ($x, $y) 183 $::CONN->lookat ($x, $y)
200 }
201 } 184 }
202 185
203 } elsif ($ev->{button} == 2) { 186 } elsif ($ev->{button} == 2) {
204 $self->grab_focus; 187 $self->grab_focus;
205 return unless $::CONN; 188 return unless $::CONN;
308 $self->{need_update} = 1; 291 $self->{need_update} = 1;
309 $self->SUPER::update; 292 $self->SUPER::update;
310} 293}
311 294
312my %DIR = ( 295my %DIR = (
313 CFPlus::SDLK_KP5, [0, "stay fire"], 296 ( "," . CFPlus::SDLK_KP5 ), [0, "stay fire"],
314 CFPlus::SDLK_KP8, [1, "north"], 297 ( "," . CFPlus::SDLK_KP8 ), [1, "north"],
315 CFPlus::SDLK_KP9, [2, "northeast"], 298 ( "," . CFPlus::SDLK_KP9 ), [2, "northeast"],
316 CFPlus::SDLK_KP6, [3, "east"], 299 ( "," . CFPlus::SDLK_KP6 ), [3, "east"],
317 CFPlus::SDLK_KP3, [4, "southeast"], 300 ( "," . CFPlus::SDLK_KP3 ), [4, "southeast"],
318 CFPlus::SDLK_KP2, [5, "south"], 301 ( "," . CFPlus::SDLK_KP2 ), [5, "south"],
319 CFPlus::SDLK_KP1, [6, "southwest"], 302 ( "," . CFPlus::SDLK_KP1 ), [6, "southwest"],
320 CFPlus::SDLK_KP4, [7, "west"], 303 ( "," . CFPlus::SDLK_KP4 ), [7, "west"],
321 CFPlus::SDLK_KP7, [8, "northwest"], 304 ( "," . CFPlus::SDLK_KP7 ), [8, "northwest"],
322 305
323 CFPlus::SDLK_UP, [1, "north"], 306 ( "," . CFPlus::SDLK_UP ), [1, "north"],
307 ("1," . CFPlus::SDLK_UP ), [2, "northeast"],
324 CFPlus::SDLK_RIGHT, [3, "east"], 308 ( "," . CFPlus::SDLK_RIGHT), [3, "east"],
309 ("1," . CFPlus::SDLK_RIGHT), [4, "southeast"],
325 CFPlus::SDLK_DOWN, [5, "south"], 310 ( "," . CFPlus::SDLK_DOWN ), [5, "south"],
311 ("1," . CFPlus::SDLK_DOWN ), [6, "southwest"],
326 CFPlus::SDLK_LEFT, [7, "west"], 312 ( "," . CFPlus::SDLK_LEFT ), [7, "west"],
313 ("1," . CFPlus::SDLK_LEFT ), [8, "northwest"],
327); 314);
328 315
329sub invoke_key_down { 316sub invoke_key_down {
330 my ($self, $ev) = @_; 317 my ($self, $ev) = @_;
331 318
333 my $sym = $ev->{sym}; 320 my $sym = $ev->{sym};
334 my $uni = $ev->{unicode}; 321 my $uni = $ev->{unicode};
335 322
336 $mod &= CFPlus::KMOD_CTRL | CFPlus::KMOD_ALT | CFPlus::KMOD_SHIFT; 323 $mod &= CFPlus::KMOD_CTRL | CFPlus::KMOD_ALT | CFPlus::KMOD_SHIFT;
337 324
338 if ($sym == 9) { 325 if ($::CONN && (my $dir = $DIR{(!!($mod & CFPlus::KMOD_ALT)) . ",$sym"})) {
339 ($mod & CFPlus::KMOD_SHIFT ? $::CONSOLE->{window} : $::PL_WINDOW)->toggle_visibility;
340 } elsif ($sym == CFPlus::SDLK_F1 && !$mod) {
341 $::HELP_WINDOW->toggle_visibility;
342 } elsif ($sym == CFPlus::SDLK_F2 && !$mod) {
343 ::toggle_player_page ($::STATS_PAGE);
344 } elsif ($sym == CFPlus::SDLK_F3 && !$mod) {
345 ::toggle_player_page ($::SKILL_PAGE);
346 } elsif ($sym == CFPlus::SDLK_F4 && !$mod) {
347 ::toggle_player_page ($::SPELL_PAGE);
348 } elsif ($sym == CFPlus::SDLK_F5 && !$mod) {
349 ::toggle_player_page ($::INVENTORY_PAGE);
350 } elsif ($sym == CFPlus::SDLK_F9 && !$mod) {
351 $::SETUP_DIALOG->toggle_visibility;
352 } elsif (!$::CONN) {
353 return 0; # bindings further down need a valid connection
354
355 } elsif ($uni == ord ",") {
356 $::CONN->user_send ("take");
357 } elsif ($uni == ord " ") {
358 $::CONN->user_send ("apply");
359 } elsif ($uni == 13) {
360 $::CONN->user_send ("examine");
361 } elsif ($uni == ord ".") {
362 $::CONN->user_send ($self->{completer}{last_command})
363 if exists $self->{completer}{last_command};
364 } elsif (my @macros = CFPlus::Macro::match_event $ev) {
365 $::CONN->macro_send ($_) for @macros;
366 } elsif (($sym == CFPlus::SDLK_KP_PLUS && !$mod) || $uni == ord "+") {
367 $::CONN->user_send ("rotateshoottype +");
368 } elsif (($sym == CFPlus::SDLK_KP_MINUS && !$mod) || $uni == ord "-") {
369 $::CONN->user_send ("rotateshoottype -");
370 } elsif ($uni == ord '!') {
371 $self->{completer}->set_prefix ("shout ");
372 $self->{completer}->show;
373 } elsif ($uni == ord '"') {
374 $self->{completer}->set_prefix ("$::CFG->{say_command} ");
375 $self->{completer}->show;
376 } elsif ($uni == ord "'") {
377 $self->{completer}->set_prefix ("");
378 $self->{completer}->show;
379 } elsif (exists $DIR{$sym}) {
380 if ($mod & CFPlus::KMOD_SHIFT) { 326 if ($mod & CFPlus::KMOD_SHIFT) {
381 $self->{shft}++; 327 $self->{shft}++;
382 if ($DIR{$sym}[0] != $self->{fire_dir}) { 328 if ($dir->[0] != $self->{fire_dir}) {
383 $::CONN->user_send ("fire $DIR{$sym}[0]"); 329 $::CONN->user_send ("fire $dir->[0]");
384 } 330 }
385 $self->{fire_dir} = $DIR{$sym}[0]; 331 $self->{fire_dir} = $DIR{$sym}[0];
386 } elsif ($mod & CFPlus::KMOD_CTRL) { 332 } elsif ($mod & CFPlus::KMOD_CTRL) {
387 $self->{ctrl}++; 333 $self->{ctrl}++;
388 $::CONN->user_send ("run $DIR{$sym}[0]"); 334 $::CONN->user_send ("run $dir->[0]");
389 } else { 335 } else {
390 $::CONN->user_send ("$DIR{$sym}[1]"); 336 $::CONN->user_send ("$dir->[1]");
391 } 337 }
392 } elsif ((ord 'a') <= $uni && $uni <= (ord 'z')) { 338
393 $self->{completer}->inject_key_down ($ev);
394 $self->{completer}->show;
395 } else {
396 return 0; 339 return 1;
397 }
398
399 1 340 }
341
342 0
400} 343}
401 344
402sub invoke_key_up { 345sub invoke_key_up {
403 my ($self, $ev) = @_; 346 my ($self, $ev) = @_;
404 347
430 } 373 }
431 374
432 $res 375 $res
433} 376}
434 377
378sub invoke_visibility_change {
379 my ($self) = @_;
380
381 $self->refresh_hook;
382
383 0
384}
385
435sub set_magicmap { 386sub set_magicmap {
436 my ($self, $w, $h, $x, $y, $data) = @_; 387 my ($self, $w, $h, $x, $y, $data) = @_;
437 388
438 $x -= $::MAP->ox + 1 + int 0.5 * $::MAP->w; 389 $x -= $::MAP->ox + 1 + int 0.5 * $::MAP->w;
439 $y -= $::MAP->oy + 1 + int 0.5 * $::MAP->h; 390 $y -= $::MAP->oy + 1 + int 0.5 * $::MAP->h;
441 $self->{magicmap} = [$x, $y, $w, $h, $data]; 392 $self->{magicmap} = [$x, $y, $w, $h, $data];
442 393
443 $self->update; 394 $self->update;
444} 395}
445 396
397sub refresh_hook {
398 my ($self) = @_;
399
400 if ($::MAP && $::CONN) {
401 if (delete $self->{need_update}) {
402 my $tilesize = $self->{ctilesize} = (int $self->{tilesize} * $::CFG->{map_scale}) || 1;
403
404 my $sw = $self->{sw} = 1 + CFPlus::ceil $self->{w} / $tilesize;
405 my $sh = $self->{sh} = 1 + CFPlus::ceil $self->{h} / $tilesize;
406
407 my $sx = CFPlus::ceil $::CFG->{map_shift_x} / $tilesize;
408 my $sy = CFPlus::ceil $::CFG->{map_shift_y} / $tilesize;
409
410 my $sx0 = $self->{sx0} = $::CFG->{map_shift_x} - $sx * $tilesize;
411 my $sy0 = $self->{sy0} = $::CFG->{map_shift_y} - $sy * $tilesize;
412
413 my $dx = $self->{dx} = CFPlus::ceil 0.5 * ($::MAP->w - $sw) - $sx;
414 my $dy = $self->{dy} = CFPlus::ceil 0.5 * ($::MAP->h - $sh) - $sy;
415
416 if ($::CFG->{fow_enable}) {
417 my ($w, $h, $data) = $::MAP->fow_texture ($dx, $dy, $sw, $sh);
418
419 $self->{fow_texture} = new CFPlus::Texture
420 w => $w,
421 h => $h,
422 data => $data,
423 internalformat => GL_ALPHA,
424 format => GL_ALPHA;
425 } else {
426 delete $self->{fow_texture};
427 }
428
429 glNewList ($self->{list} ||= glGenList);
430
431 glPushMatrix;
432 glTranslate $sx0, $sy0;
433 glScale $::CFG->{map_scale}, $::CFG->{map_scale};
434
435 $::MAP->draw ($dx, $dy, $sw, $sh, $self->{tilesize});
436
437 glScale $self->{tilesize}, $self->{tilesize};
438
439 if (my $tex = $self->{fow_texture}) {
440 glPushMatrix;
441 glScale 1/3, 1/3;
442 glEnable GL_TEXTURE_2D;
443 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
444
445 glColor +($::CFG->{fow_intensity}) x 3, 0.9;
446 $self->{fow_texture}->draw_quad_alpha (0, 0);
447
448 glDisable GL_TEXTURE_2D;
449 glPopMatrix;
450 }
451
452 if ($self->{magicmap}) {
453 my ($x, $y, $w, $h, $data) = @{ $self->{magicmap} };
454
455 $x += $::MAP->ox + $self->{dx};
456 $y += $::MAP->oy + $self->{dy};
457
458 glTranslate - $x - 1, - $y - 1;
459 glBindTexture GL_TEXTURE_2D, $magicmap_tex->{name};
460 $::MAP->draw_magicmap ($x, $y, $w, $h, $data);
461 }
462
463 glPopMatrix;
464 glEndList;
465 }
466 } else {
467 glDeleteList delete $self->{list}
468 if $self->{list};
469 }
470}
471
446sub draw { 472sub draw {
447 my ($self) = @_; 473 my ($self) = @_;
448 474
449 return unless $::MAP; 475 $self->{root}->on_post_alloc (prepare => sub { $self->refresh_hook });
476
477 return unless $self->{list};
450 478
451 my $focused = $CFPlus::UI::FOCUS == $self 479 my $focused = $CFPlus::UI::FOCUS == $self
452 || $CFPlus::UI::FOCUS == $self->{completer}{entry}; 480 || $CFPlus::UI::FOCUS == $::COMPLETER->{entry};
453 481
454 return 482 return
455 unless $focused || !$::FAST; 483 unless $focused || !$::FAST;
456 484
457 if (delete $self->{need_update}) {
458 my $tilesize = $self->{ctilesize} = (int $self->{tilesize} * $::CFG->{map_scale}) || 1;
459
460 my $sw = $self->{sw} = 1 + CFPlus::ceil $self->{w} / $tilesize;
461 my $sh = $self->{sh} = 1 + CFPlus::ceil $self->{h} / $tilesize;
462
463 my $sx = CFPlus::ceil $::CFG->{map_shift_x} / $tilesize;
464 my $sy = CFPlus::ceil $::CFG->{map_shift_y} / $tilesize;
465
466 my $sx0 = $self->{sx0} = $::CFG->{map_shift_x} - $sx * $tilesize;
467 my $sy0 = $self->{sy0} = $::CFG->{map_shift_y} - $sy * $tilesize;
468
469 my $dx = $self->{dx} = CFPlus::ceil 0.5 * ($::MAP->w - $sw) - $sx;
470 my $dy = $self->{dy} = CFPlus::ceil 0.5 * ($::MAP->h - $sh) - $sy;
471
472 if ($::CFG->{fow_enable}) {
473 my ($w, $h, $data) = $::MAP->fow_texture ($dx, $dy, $sw, $sh);
474
475 if ($::CFG->{fow_smooth} && $CFPlus::OpenGL::GL_VERSION >= 1.2) { # smooth fog of war
476 glConvolutionParameter (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER);
477 glConvolutionFilter2D (
478 GL_CONVOLUTION_2D,
479 GL_ALPHA,
480 3, 3,
481 GL_ALPHA, GL_FLOAT,
482 (pack "f*", @{ $self->{smooth_matrix} }),
483 );
484 glEnable GL_CONVOLUTION_2D;
485 }
486
487 $self->{fow_texture} = new CFPlus::Texture
488 w => $w,
489 h => $h,
490 data => $data,
491 internalformat => GL_ALPHA,
492 format => GL_ALPHA;
493
494 glDisable GL_CONVOLUTION_2D if $::CFG->{fow_smooth};
495 } else {
496 delete $self->{fow_texture};
497 }
498
499 glNewList $self->{list};
500
501 glPushMatrix;
502 glTranslate $sx0, $sy0;
503 glScale $::CFG->{map_scale}, $::CFG->{map_scale};
504
505 $::MAP->draw ($dx, $dy, $sw, $sh, $self->{tilesize});
506
507 glScale $self->{tilesize}, $self->{tilesize};
508
509 if (my $tex = $self->{fow_texture}) {
510 glEnable GL_TEXTURE_2D;
511 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
512
513 glColor +($::CFG->{fow_intensity}) x 3, 0.9;
514 $self->{fow_texture}->draw_quad_alpha (0, 0);
515
516 glDisable GL_TEXTURE_2D;
517 }
518
519 if ($self->{magicmap}) {
520 my ($x, $y, $w, $h, $data) = @{ $self->{magicmap} };
521
522 $x += $::MAP->ox + $self->{dx};
523 $y += $::MAP->oy + $self->{dy};
524
525 glTranslate - $x - 1, - $y - 1;
526 glBindTexture GL_TEXTURE_2D, $magicmap_tex->{name};
527 $::MAP->draw_magicmap ($x, $y, $w, $h, $data);
528 }
529
530 glPopMatrix;
531 glEndList;
532 }
533
534 glCallList $self->{list}; 485 glCallList $self->{list};
535 486
536 # TNT2 emulates logops in software (or worse :) 487 # TNT2 emulates logops in software (or worse :)
537 unless ($focused) { 488 unless ($focused) {
538 glColor 0.4, 0.2, 0.2, 0.6; 489 glColor_premultiply 0, 0, 1, 0.25;
539 glEnable GL_BLEND; 490 glEnable GL_BLEND;
540 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 491 glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA;
541 glBegin GL_QUADS; 492 glBegin GL_QUADS;
542 glVertex 0, 0; 493 glVertex 0, 0;
543 glVertex 0, $::HEIGHT; 494 glVertex 0, $::HEIGHT;
544 glVertex $::WIDTH, $::HEIGHT; 495 glVertex $::WIDTH, $::HEIGHT;
545 glVertex $::WIDTH, 0; 496 glVertex $::WIDTH, 0;
565 516
566use Time::HiRes qw(time); 517use Time::HiRes qw(time);
567use CFPlus::OpenGL; 518use CFPlus::OpenGL;
568 519
569sub size_request { 520sub size_request {
570 ($::HEIGHT * 0.25, $::HEIGHT * 0.25) 521 ($::HEIGHT * 0.2, $::HEIGHT * 0.2)
571} 522}
572 523
573sub invoke_size_allocate { 524sub refresh_hook {
574 my ($self, $w, $h) = @_; 525 my ($self) = @_;
575 526
576 $self->update; 527 if ($::MAP && $self->{texture_atime} < time) {
577
578 1
579}
580
581sub update {
582 my ($self) = @_;
583
584 delete $self->{texture_atime};
585 $self->SUPER::update;
586}
587
588sub _draw {
589 my ($self) = @_;
590
591 $::MAP or return;
592
593 my ($w, $h) = @$self{qw(w h)}; 528 my ($w, $h) = @$self{qw(w h)};
594 529
595 my $sw = int $::WIDTH / ($::MAPWIDGET->{tilesize} * $::CFG->{map_scale}) + 0.99; 530 my $sw = int $::WIDTH / ($::MAPWIDGET->{tilesize} * $::CFG->{map_scale}) + 0.99;
596 my $sh = int $::HEIGHT / ($::MAPWIDGET->{tilesize} * $::CFG->{map_scale}) + 0.99; 531 my $sh = int $::HEIGHT / ($::MAPWIDGET->{tilesize} * $::CFG->{map_scale}) + 0.99;
597 532
533 my $ox = 0.5 * ($w - $sw);
534 my $oy = 0.5 * ($h - $sh);
535
598 my $sx = int $::CFG->{map_shift_x} / $::MAPWIDGET->{tilesize}; 536 my $sx = int $::CFG->{map_shift_x} / $::MAPWIDGET->{tilesize};
599 my $sy = int $::CFG->{map_shift_y} / $::MAPWIDGET->{tilesize}; 537 my $sy = int $::CFG->{map_shift_y} / $::MAPWIDGET->{tilesize};
600 538
601 my $ox = 0.5 * ($w - $sw); 539 #TODO: map scale is completely borked
602 my $oy = 0.5 * ($h - $sh);
603 540
604 glEnable GL_BLEND; 541 my $x0 = int $ox - $sx + 0.5;
605 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 542 my $y0 = int $oy - $sy + 0.5;
606 glEnable GL_TEXTURE_2D;
607 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
608 543
609 if ($self->{texture_atime} < time) { 544 $self->{sw} = $sw;
545 $self->{sh} = $sh;
546
547 $self->{x0} = $x0;
548 $self->{y0} = $y0;
549
610 $self->{texture_atime} = time + 1/3; 550 $self->{texture_atime} = time + 1/3;
611 551
612 $self->{texture} = 552 $self->{texture} =
613 new CFPlus::Texture 553 new CFPlus::Texture
614 w => $w, 554 w => $w,
615 h => $h, 555 h => $h,
616 data => $::MAP->mapmap (-$ox, -$oy, $w, $h), 556 data => $::MAP->mapmap (-$ox, -$oy, $w, $h),
617 type => $CFPlus::GL_VERSION >= 1.2 ? GL_UNSIGNED_INT_8_8_8_8_REV : GL_UNSIGNED_BYTE; 557 type => $CFPlus::GL_VERSION >= 1.2 ? GL_UNSIGNED_INT_8_8_8_8_REV : GL_UNSIGNED_BYTE;
618 } 558 }
559}
560
561sub invoke_visibility_change {
562 my ($self) = @_;
563
564 $self->refresh_hook;
565
566 0
567}
568
569sub invoke_size_allocate {
570 my ($self, $w, $h) = @_;
571
572 $self->update;
573
574 1
575}
576
577sub update {
578 my ($self) = @_;
579
580 delete $self->{texture_atime};
581 $self->SUPER::update;
582}
583
584sub _draw {
585 my ($self) = @_;
586
587 $self->{root}->on_post_alloc (texture => sub { $self->refresh_hook });
588
589 $self->{texture} or return;
590
591 glEnable GL_BLEND;
592 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
593 glEnable GL_TEXTURE_2D;
594 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
619 595
620 $self->{texture}->draw_quad (0, 0); 596 $self->{texture}->draw_quad (0, 0);
621 597
622 glDisable GL_TEXTURE_2D; 598 glDisable GL_TEXTURE_2D;
623 599
624 glTranslate 0.375, 0.375; 600 glTranslate 0.375, 0.375;
625
626 #TODO: map scale is completely borked
627
628 my $x0 = int $ox - $sx + 0.5;
629 my $y0 = int $oy - $sy + 0.5;
630 601
631 glColor 1, 1, 0, 1; 602 glColor 1, 1, 0, 1;
632 glBegin GL_LINE_LOOP; 603 glBegin GL_LINE_LOOP;
633 glVertex $x0 , $y0 ; 604 glVertex $self->{x0} , $self->{y0} ;
634 glVertex $x0 , $y0 + $sh; 605 glVertex $self->{x0} , $self->{y0} + $self->{sh};
635 glVertex $x0 + $sw, $y0 + $sh; 606 glVertex $self->{x0} + $self->{sw}, $self->{y0} + $self->{sh};
636 glVertex $x0 + $sw, $y0 ; 607 glVertex $self->{x0} + $self->{sw}, $self->{y0} ;
637 glEnd; 608 glEnd;
638 609
639 glDisable GL_BLEND; 610 glDisable GL_BLEND;
640} 611}
641 612

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines