ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/UI.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/UI.pm (file contents):
Revision 1.206 by root, Mon May 15 17:45:29 2006 UTC vs.
Revision 1.208 by root, Mon May 15 22:52:17 2006 UTC

895 my ($self, $w, $h) = @_; 895 my ($self, $w, $h) = @_;
896 896
897 $h -= List::Util::max 0, $self->border * 2; 897 $h -= List::Util::max 0, $self->border * 2;
898 $w -= List::Util::max 0, $self->border * 2; 898 $w -= List::Util::max 0, $self->border * 2;
899 899
900 $self->{title}->configure ($self->border, $self->border - $::FONTSIZE * 2, $w, $::FONTSIZE * 2) 900 $self->{title}->configure ($self->border, int $self->border - $::FONTSIZE * 2, $w, int $::FONTSIZE * 2)
901 if $self->{title}; 901 if $self->{title};
902 902
903 $self->child->configure ($self->border, $self->border, $w, $h); 903 $self->child->configure ($self->border, $self->border, $w, $h);
904} 904}
905 905
1399 $self->{layout}->set_width ($self->{w}); 1399 $self->{layout}->set_width ($self->{w});
1400 $self->{layout}->set_height (List::Util::min $self->{h}, $self->{fontsize} * $::FONTSIZE); 1400 $self->{layout}->set_height (List::Util::min $self->{h}, $self->{fontsize} * $::FONTSIZE);
1401 1401
1402 my $tex = new_from_layout CFClient::Texture $self->{layout}; 1402 my $tex = new_from_layout CFClient::Texture $self->{layout};
1403 1403
1404 $self->{ox} = int $self->{align} < 0 ? $self->{padding} 1404 $self->{ox} = int ($self->{align} < 0 ? $self->{padding}
1405 : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} 1405 : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding}
1406 : ($self->{w} - $tex->{w}) * 0.5; 1406 : ($self->{w} - $tex->{w}) * 0.5);
1407 1407
1408 $self->{oy} = int $self->{valign} < 0 ? $self->{padding} 1408 $self->{oy} = int ($self->{valign} < 0 ? $self->{padding}
1409 : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding} 1409 : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding}
1410 : ($self->{h} - $tex->{h}) * 0.5; 1410 : ($self->{h} - $tex->{h}) * 0.5);
1411 1411
1412 $tex 1412 $tex
1413 }; 1413 };
1414 1414
1415 glEnable GL_TEXTURE_2D; 1415 glEnable GL_TEXTURE_2D;
1470sub set_text { 1470sub set_text {
1471 my ($self, $text) = @_; 1471 my ($self, $text) = @_;
1472 1472
1473 $self->{cursor} = length $text; 1473 $self->{cursor} = length $text;
1474 $self->_set_text ($text); 1474 $self->_set_text ($text);
1475 $self->update;
1475 $self->check_size; 1476 $self->check_size;
1476 $self->update;
1477} 1477}
1478 1478
1479sub get_text { 1479sub get_text {
1480 $_[0]{text} 1480 $_[0]{text}
1481} 1481}
1521 substr $text, $self->{cursor}++, 0, chr $uni; 1521 substr $text, $self->{cursor}++, 0, chr $uni;
1522 } 1522 }
1523 1523
1524 $self->_set_text ($text); 1524 $self->_set_text ($text);
1525 $self->update; 1525 $self->update;
1526 $self->check_size;
1526} 1527}
1527 1528
1528sub focus_in { 1529sub focus_in {
1529 my ($self) = @_; 1530 my ($self) = @_;
1530 1531
2504 2505
2505 my $desc = $item->{nrof} < 2 2506 my $desc = $item->{nrof} < 2
2506 ? $item->{name} 2507 ? $item->{name}
2507 : "$item->{nrof} $item->{name_pl}"; 2508 : "$item->{nrof} $item->{name_pl}";
2508 2509
2510 $item->{flags} & Crossfire::Protocol::F_OPEN
2511 and $desc .= " (open)";
2512 $item->{flags} & Crossfire::Protocol::F_APPLIED
2513 and $desc .= " (applied)";
2514 $item->{flags} & Crossfire::Protocol::F_UNPAID
2515 and $desc .= " (unpaid)";
2516 $item->{flags} & Crossfire::Protocol::F_MAGIC
2517 and $desc .= " (magic)";
2518 $item->{flags} & Crossfire::Protocol::F_CURSED
2519 and $desc .= " (cursed)";
2520 $item->{flags} & Crossfire::Protocol::F_DAMNED
2521 and $desc .= " (damned)";
2522 $item->{flags} & Crossfire::Protocol::F_LOCKED
2523 and $desc .= " *";
2509 2524
2510 my $self = $class->SUPER::new ( 2525 my $self = $class->SUPER::new (
2511 can_hover => 1, 2526 can_hover => 1,
2512 can_events => 1, 2527 can_events => 1,
2513 tooltip => (CFClient::UI::Label->escape ($desc) 2528 tooltip => (CFClient::UI::Label->escape ($desc)
2519 if ($ev->{button} == 1) { 2534 if ($ev->{button} == 1) {
2520 $::CONN->send ("move $::CONN->{player}{tag} $item->{tag} 0"); 2535 $::CONN->send ("move $::CONN->{player}{tag} $item->{tag} 0");
2521 } elsif ($ev->{button} == 2) { 2536 } elsif ($ev->{button} == 2) {
2522 $::CONN->send ("apply $item->{tag}"); 2537 $::CONN->send ("apply $item->{tag}");
2523 } elsif ($ev->{button} == 3) { 2538 } elsif ($ev->{button} == 3) {
2524 CFClient::UI::Menu->new ( 2539 my @menu_items = (
2525 items => [
2526 ["examine", sub { $::CONN->send ("examine $item->{tag}") }], 2540 ["examine", sub { $::CONN->send ("examine $item->{tag}") }],
2541 ["mark", sub { $::CONN->send ("mark $item->{tag}") }],
2542 ["apply", sub { $::CONN->send ("apply $item->{tag}") }],
2543 ["drop", sub { $::CONN->send ("move $main::OPENCONT $item->{tag} 0") }],
2527 [ 2544 [
2528 $item->{flags} & Crossfire::Protocol::F_LOCKED ? "lock" : "unlock", 2545 $item->{flags} & Crossfire::Protocol::F_LOCKED ? "lock" : "unlock",
2529 sub { $::CONN->send ("lock $item->{tag}") }, 2546 sub { $::CONN->send ("lock ". () ."$item->{tag}") },
2530 ],
2531 ["mark", sub { $::CONN->send ("mark $item->{tag}") }],
2532 ["apply", sub { $::CONN->send ("apply $item->{tag}") }],
2533 ["drop", sub { $::CONN->send ("move 0 $item->{tag} 0") }],
2534 ], 2547 ],
2535 )->popup ($ev); 2548 );
2549
2550 CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev);
2536 } 2551 }
2537 2552
2538 1 2553 1
2539 }, 2554 },
2540 %args 2555 %args

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines