… | |
… | |
797 | $self->{vp}->set_offset (0, $_[1] * ($self->{vp}{child_h} - $self->{vp}{h})); |
797 | $self->{vp}->set_offset (0, $_[1] * ($self->{vp}{child_h} - $self->{vp}{h})); |
798 | }, |
798 | }, |
799 | ; |
799 | ; |
800 | |
800 | |
801 | $self = $class->SUPER::new ( |
801 | $self = $class->SUPER::new ( |
802 | vp => (new CFClient::UI::ViewPort), |
802 | vp => (new CFClient::UI::ViewPort expand => 1), |
803 | slider => $slider, |
803 | slider => $slider, |
804 | @_, |
804 | @_, |
805 | ); |
805 | ); |
806 | |
806 | |
807 | $self->{vp}->add ($self->{scrolled}); |
807 | $self->{vp}->add ($self->{scrolled}); |
… | |
… | |
2050 | range => [0, 0, 100, 10], |
2050 | range => [0, 0, 100, 10], |
2051 | req_w => $::WIDTH / 80, |
2051 | req_w => $::WIDTH / 80, |
2052 | req_h => $::WIDTH / 80, |
2052 | req_h => $::WIDTH / 80, |
2053 | vertical => 0, |
2053 | vertical => 0, |
2054 | can_hover => 1, |
2054 | can_hover => 1, |
2055 | inner_pad => .05, |
2055 | inner_pad => 0.02, |
2056 | @_ |
2056 | @_ |
2057 | ); |
2057 | ); |
2058 | |
2058 | |
2059 | $self->set_value ($self->{range}[0]); |
2059 | $self->set_value ($self->{range}[0]); |
2060 | $self->update; |
2060 | $self->update; |
… | |
… | |
2489 | use CFClient::OpenGL; |
2489 | use CFClient::OpenGL; |
2490 | |
2490 | |
2491 | sub new { |
2491 | sub new { |
2492 | my $class = shift; |
2492 | my $class = shift; |
2493 | |
2493 | |
2494 | $class->SUPER::new ( |
2494 | my $self = $class->SUPER::new ( |
2495 | aspect => 1, |
2495 | aspect => 1, |
2496 | @_, |
2496 | @_, |
2497 | ) |
2497 | ); |
|
|
2498 | |
|
|
2499 | if ($self->{anim} && $self->{animspeed}) { |
|
|
2500 | Scalar::Util::weaken (my $widget = $self); |
|
|
2501 | |
|
|
2502 | $self->{timer} = Event->timer ( |
|
|
2503 | at => $self->{animspeed} * int $::NOW / $self->{animspeed}, |
|
|
2504 | hard => 1, |
|
|
2505 | interval => $self->{animspeed}, |
|
|
2506 | cb => sub { |
|
|
2507 | ++$widget->{frame}; |
|
|
2508 | $widget->update; |
|
|
2509 | }, |
|
|
2510 | ); |
|
|
2511 | } |
|
|
2512 | |
|
|
2513 | $self |
2498 | } |
2514 | } |
2499 | |
2515 | |
2500 | sub size_request { |
2516 | sub size_request { |
2501 | (32, 8) |
2517 | (32, 8) |
2502 | } |
2518 | } |
2503 | |
2519 | |
2504 | sub _draw { |
2520 | sub _draw { |
2505 | my ($self) = @_; |
2521 | my ($self) = @_; |
2506 | |
2522 | |
2507 | return unless $::CONN;#d# manage and cache textures differently |
2523 | return unless $::CONN;#d# manage and cache textures differently |
|
|
2524 | |
|
|
2525 | my $face; |
|
|
2526 | |
|
|
2527 | if ($self->{frame}) { |
|
|
2528 | my $anim = $::CONN->{anim}[$self->{anim}]; |
|
|
2529 | |
|
|
2530 | $face = $anim->[ $self->{frame} % @$anim ] |
|
|
2531 | if $anim && @$anim; |
|
|
2532 | } |
|
|
2533 | |
2508 | my $tex = $::CONN->{texture}[$::CONN->{faceid}[$self->{face}]]; |
2534 | my $tex = $::CONN->{texture}[$::CONN->{faceid}[$face || $self->{face}]]; |
2509 | |
2535 | |
2510 | # TODO animation |
|
|
2511 | if ($tex) { |
2536 | if ($tex) { |
2512 | glEnable GL_TEXTURE_2D; |
2537 | glEnable GL_TEXTURE_2D; |
2513 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2538 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2514 | glColor 1, 1, 1, 1; |
2539 | glColor 1, 1, 1, 1; |
2515 | $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); |
2540 | $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); |
2516 | glDisable GL_TEXTURE_2D; |
2541 | glDisable GL_TEXTURE_2D; |
2517 | } |
2542 | } |
2518 | } |
2543 | } |
2519 | |
2544 | |
|
|
2545 | sub DESTROY { |
|
|
2546 | my ($self) = @_; |
|
|
2547 | |
|
|
2548 | $self->{timer}->cancel |
|
|
2549 | if $self->{timer}; |
|
|
2550 | |
|
|
2551 | $self->SUPER::DESTROY; |
|
|
2552 | } |
|
|
2553 | |
2520 | ############################################################################# |
2554 | ############################################################################# |
2521 | |
2555 | |
2522 | package CFClient::UI::InventoryItem; |
2556 | package CFClient::UI::InventoryItem; |
2523 | |
2557 | |
2524 | our @ISA = CFClient::UI::HBox::; |
2558 | our @ISA = CFClient::UI::HBox::; |
… | |
… | |
2527 | my ($item) = @_; |
2561 | my ($item) = @_; |
2528 | |
2562 | |
2529 | my $desc = |
2563 | my $desc = |
2530 | $item->{nrof} < 2 |
2564 | $item->{nrof} < 2 |
2531 | ? $item->{name} |
2565 | ? $item->{name} |
2532 | : "$item->{nrof} $item->{name_pl}"; |
2566 | : "$item->{nrof} × $item->{name_pl}"; |
2533 | |
2567 | |
2534 | $item->{flags} & Crossfire::Protocol::F_OPEN |
2568 | $item->{flags} & Crossfire::Protocol::F_OPEN |
2535 | and $desc .= " (open)"; |
2569 | and $desc .= " (open)"; |
2536 | $item->{flags} & Crossfire::Protocol::F_APPLIED |
2570 | $item->{flags} & Crossfire::Protocol::F_APPLIED |
2537 | and $desc .= " (applied)"; |
2571 | and $desc .= " (applied)"; |
… | |
… | |
2557 | my $item = delete $args{item}; |
2591 | my $item = delete $args{item}; |
2558 | |
2592 | |
2559 | my $desc = _item_to_desc ($item); |
2593 | my $desc = _item_to_desc ($item); |
2560 | |
2594 | |
2561 | my $self = $class->SUPER::new ( |
2595 | my $self = $class->SUPER::new ( |
2562 | can_hover => 1, |
2596 | can_hover => 1, |
2563 | can_events => 1, |
2597 | can_events => 1, |
2564 | tooltip => ((CFClient::UI::Label::escape $desc) |
2598 | tooltip => ((CFClient::UI::Label::escape $desc) |
2565 | . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"), |
2599 | . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"), |
2566 | connect_button_down => sub { |
2600 | connect_button_down => sub { |
2567 | my ($self, $ev, $x, $y) = @_; |
2601 | my ($self, $ev, $x, $y) = @_; |
2568 | |
2602 | |
2569 | # todo: maybe put examine on 1? but should just be a tooltip :( |
2603 | # todo: maybe put examine on 1? but should just be a tooltip :( |
… | |
… | |
2578 | } elsif ($ev->{button} == 2) { |
2612 | } elsif ($ev->{button} == 2) { |
2579 | $::CONN->send ("apply $item->{tag}"); |
2613 | $::CONN->send ("apply $item->{tag}"); |
2580 | } elsif ($ev->{button} == 3) { |
2614 | } elsif ($ev->{button} == 3) { |
2581 | my @menu_items = ( |
2615 | my @menu_items = ( |
2582 | ["examine", sub { $::CONN->send ("examine $item->{tag}") }], |
2616 | ["examine", sub { $::CONN->send ("examine $item->{tag}") }], |
2583 | ["mark", sub { $::CONN->send ("mark $item->{tag}") }], |
2617 | ["mark", sub { $::CONN->send ("mark ". pack "N", $item->{tag}) }], |
2584 | ["apply", sub { $::CONN->send ("apply $item->{tag}") }], |
2618 | ["apply", sub { $::CONN->send ("apply $item->{tag}") }], |
|
|
2619 | ( |
|
|
2620 | $item->{flags} & Crossfire::Protocol::F_LOCKED |
|
|
2621 | ? ( |
|
|
2622 | ["unlock", sub { $::CONN->send ("lock " . pack "CN", 0, $item->{tag}) }], |
|
|
2623 | ) |
|
|
2624 | : ( |
|
|
2625 | ["lock", sub { $::CONN->send ("lock " . pack "CN", 1, $item->{tag}) }], |
2585 | ["drop", sub { $::CONN->send ("move $main::OPENCONT $item->{tag} 0") }], |
2626 | ["drop", sub { $::CONN->send ("move $main::OPENCONT $item->{tag} 0") }], |
2586 | [ |
2627 | ) |
2587 | $item->{flags} & Crossfire::Protocol::F_LOCKED ? "lock" : "unlock", |
|
|
2588 | sub { $::CONN->send ("lock $item->{tag}") }, |
|
|
2589 | ], |
2628 | ), |
2590 | ); |
2629 | ); |
2591 | |
2630 | |
2592 | CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev); |
2631 | CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev); |
2593 | } |
2632 | } |
2594 | |
2633 | |
… | |
… | |
3015 | glClearColor +($::CFG->{fow_intensity}) x 3, 1; |
3054 | glClearColor +($::CFG->{fow_intensity}) x 3, 1; |
3016 | glClear GL_COLOR_BUFFER_BIT; |
3055 | glClear GL_COLOR_BUFFER_BIT; |
3017 | |
3056 | |
3018 | glMatrixMode GL_PROJECTION; |
3057 | glMatrixMode GL_PROJECTION; |
3019 | glLoadIdentity; |
3058 | glLoadIdentity; |
3020 | glOrtho 0, $::WIDTH, $::HEIGHT, 0, -10000 , 10000; |
3059 | glOrtho 0, $::WIDTH, $::HEIGHT, 0, -10000, 10000; |
3021 | glMatrixMode GL_MODELVIEW; |
3060 | glMatrixMode GL_MODELVIEW; |
3022 | glLoadIdentity; |
3061 | glLoadIdentity; |
3023 | |
3062 | |
3024 | $self->_draw; |
3063 | $self->_draw; |
3025 | } |
3064 | } |