… | |
… | |
2554 | connect_button_down => sub { |
2554 | connect_button_down => sub { |
2555 | my ($self, $ev, $x, $y) = @_; |
2555 | my ($self, $ev, $x, $y) = @_; |
2556 | |
2556 | |
2557 | # todo: maybe put examine on 1? but should just be a tooltip :( |
2557 | # todo: maybe put examine on 1? but should just be a tooltip :( |
2558 | if ($ev->{button} == 1) { |
2558 | if ($ev->{button} == 1) { |
|
|
2559 | my $targ = $::CONN->{player}{tag}; |
|
|
2560 | |
|
|
2561 | if ($item->{container} == $::CONN->{player}{tag}) { |
|
|
2562 | $targ = $main::OPENCONT; |
|
|
2563 | } |
|
|
2564 | |
2559 | $::CONN->send ("move $::CONN->{player}{tag} $item->{tag} 0"); |
2565 | $::CONN->send ("move $targ $item->{tag} 0"); |
2560 | } elsif ($ev->{button} == 2) { |
2566 | } elsif ($ev->{button} == 2) { |
2561 | $::CONN->send ("apply $item->{tag}"); |
2567 | $::CONN->send ("apply $item->{tag}"); |
2562 | } elsif ($ev->{button} == 3) { |
2568 | } elsif ($ev->{button} == 3) { |
2563 | my @menu_items = ( |
2569 | my @menu_items = ( |
2564 | ["examine", sub { $::CONN->send ("examine $item->{tag}") }], |
2570 | ["examine", sub { $::CONN->send ("examine $item->{tag}") }], |
2565 | ["mark", sub { $::CONN->send ("mark $item->{tag}") }], |
2571 | ["mark", sub { $::CONN->send ("mark $item->{tag}") }], |
2566 | ["apply", sub { $::CONN->send ("apply $item->{tag}") }], |
2572 | ["apply", sub { $::CONN->send ("apply $item->{tag}") }], |
2567 | ["drop", sub { $::CONN->send ("move $main::OPENCONT $item->{tag} 0") }], |
2573 | ["drop", sub { $::CONN->send ("move $main::OPENCONT $item->{tag} 0") }], |
2568 | [ |
2574 | [ |
2569 | $item->{flags} & Crossfire::Protocol::F_LOCKED ? "lock" : "unlock", |
2575 | $item->{flags} & Crossfire::Protocol::F_LOCKED ? "lock" : "unlock", |
2570 | sub { $::CONN->send ("lock ". () ."$item->{tag}") }, |
2576 | sub { $::CONN->send ("lock $item->{tag}") }, |
2571 | ], |
2577 | ], |
2572 | ); |
2578 | ); |
2573 | |
2579 | |
2574 | CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev); |
2580 | CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev); |
2575 | } |
2581 | } |
… | |
… | |
2718 | |
2724 | |
2719 | package CFClient::UI::Statusbox; |
2725 | package CFClient::UI::Statusbox; |
2720 | |
2726 | |
2721 | our @ISA = CFClient::UI::VBox::; |
2727 | our @ISA = CFClient::UI::VBox::; |
2722 | |
2728 | |
|
|
2729 | sub new { |
|
|
2730 | my $class = shift; |
|
|
2731 | |
|
|
2732 | $class->SUPER::new ( |
|
|
2733 | fontsize => 0.8, |
|
|
2734 | @_, |
|
|
2735 | ) |
|
|
2736 | } |
|
|
2737 | |
2723 | sub reorder { |
2738 | sub reorder { |
2724 | my ($self) = @_; |
2739 | my ($self) = @_; |
2725 | my $NOW = time; |
2740 | my $NOW = time; |
2726 | |
2741 | |
2727 | while (my ($k, $v) = each %{ $self->{item} }) { |
2742 | while (my ($k, $v) = each %{ $self->{item} }) { |
… | |
… | |
2743 | # TODO: doesn't handle markup well (read as: at all) |
2758 | # TODO: doesn't handle markup well (read as: at all) |
2744 | my $short = $item->{count} > 1 |
2759 | my $short = $item->{count} > 1 |
2745 | ? "<b>$item->{count} ×</b> $item->{text}" |
2760 | ? "<b>$item->{count} ×</b> $item->{text}" |
2746 | : $item->{text}; |
2761 | : $item->{text}; |
2747 | |
2762 | |
|
|
2763 | my $fontsize = $item->{fontsize} || $self->{fontsize}; |
|
|
2764 | |
2748 | for ($short) { |
2765 | for ($short) { |
2749 | s/^\s+//; |
2766 | s/^\s+//; |
2750 | s/\s+/ /g; |
2767 | s/\s+/ /g; |
2751 | my $len = int 40 / $item->{fontsize}; |
2768 | my $len = int 40 / $fontsize; |
2752 | substr $_, $len, length, "…" if $len < length; |
2769 | substr $_, $len, length, "…" if $len < length; |
2753 | } |
2770 | } |
2754 | |
2771 | |
2755 | new CFClient::UI::Label |
2772 | new CFClient::UI::Label |
2756 | markup => $short, |
2773 | markup => $short, |
2757 | tooltip => $item->{tooltip}, |
2774 | tooltip => $item->{tooltip}, |
2758 | tooltip_font => $::FONT_PROP, |
2775 | tooltip_font => $::FONT_PROP, |
2759 | tooltip_width => 0.67, |
2776 | tooltip_width => 0.67, |
2760 | fontsize => $item->{fontsize}, |
2777 | fontsize => $fontsize, |
2761 | fg => $item->{fg}, |
2778 | fg => $item->{fg}, |
2762 | can_events => 1, |
2779 | can_events => 1, |
2763 | can_hover => 1 |
2780 | can_hover => 1 |
2764 | }; |
2781 | }; |
2765 | } |
2782 | } |
… | |
… | |
2792 | $self->{item}{$group} = { |
2809 | $self->{item}{$group} = { |
2793 | id => ++$self->{id}, |
2810 | id => ++$self->{id}, |
2794 | text => $text, |
2811 | text => $text, |
2795 | timeout => $timeout, |
2812 | timeout => $timeout, |
2796 | tooltip => $text, |
2813 | tooltip => $text, |
2797 | fontsize => 0.8, |
|
|
2798 | fg => [0.8, 0.8, 0.8, 0.8], |
2814 | fg => [0.8, 0.8, 0.8, 0.8], |
2799 | pri => 0, |
2815 | pri => 0, |
2800 | count => 1, |
2816 | count => 1, |
2801 | %arg, |
2817 | %arg, |
2802 | }; |
2818 | }; |