… | |
… | |
423 | my ($self) = @_; |
423 | my ($self) = @_; |
424 | |
424 | |
425 | return if $FOCUS == $self; |
425 | return if $FOCUS == $self; |
426 | return unless $self->{can_focus}; |
426 | return unless $self->{can_focus}; |
427 | |
427 | |
428 | my $focus = $FOCUS; $FOCUS = $self; |
428 | $FOCUS = $self; |
429 | |
429 | |
430 | $focus->update if $focus; |
430 | $self->update; |
431 | $FOCUS->update; |
|
|
432 | |
431 | |
433 | 0 |
432 | 0 |
434 | } |
433 | } |
435 | |
434 | |
436 | sub invoke_focus_out { |
435 | sub invoke_focus_out { |
437 | my ($self) = @_; |
436 | my ($self) = @_; |
438 | |
437 | |
439 | return unless $FOCUS == $self; |
438 | return unless $FOCUS == $self; |
440 | |
439 | |
441 | my $focus = $FOCUS; undef $FOCUS; |
440 | undef $FOCUS; |
442 | |
441 | |
443 | $focus->update if $focus; #? |
442 | $self->update; |
444 | |
443 | |
445 | $::MAPWIDGET->grab_focus #d# focus mapwidget if no other widget has focus |
444 | $::MAPWIDGET->grab_focus #d# focus mapwidget if no other widget has focus |
446 | unless $FOCUS; |
445 | unless $FOCUS; |
447 | |
446 | |
448 | 0 |
447 | 0 |
449 | } |
448 | } |
450 | |
449 | |
451 | sub grab_focus { |
450 | sub grab_focus { |
452 | my ($self) = @_; |
451 | my ($self) = @_; |
453 | |
452 | |
|
|
453 | $FOCUS->emit ("focus_out") if $FOCUS; |
454 | $self->emit ("focus_in"); |
454 | $self->emit ("focus_in"); |
455 | } |
455 | } |
456 | |
456 | |
457 | sub invoke_mouse_motion { 1 } |
457 | sub invoke_mouse_motion { 1 } |
458 | sub invoke_button_up { 1 } |
458 | sub invoke_button_up { 1 } |
… | |
… | |
1096 | |
1096 | |
1097 | if ($self->{has_close_button}) { |
1097 | if ($self->{has_close_button}) { |
1098 | $self->{close_button} = |
1098 | $self->{close_button} = |
1099 | new CFClient::UI::ImageButton |
1099 | new CFClient::UI::ImageButton |
1100 | path => 'x1_close.png', |
1100 | path => 'x1_close.png', |
1101 | on_activate => sub { $self->hide }; |
1101 | on_activate => sub { $self->emit ("delete") }; |
1102 | |
1102 | |
1103 | $self->CFClient::UI::Container::add ($self->{close_button}); |
1103 | $self->CFClient::UI::Container::add ($self->{close_button}); |
1104 | } |
1104 | } |
1105 | |
1105 | |
1106 | $self |
1106 | $self |
… | |
… | |
1152 | $self->child->configure ($border, $border, $w, $h); |
1152 | $self->child->configure ($border, $border, $w, $h); |
1153 | |
1153 | |
1154 | $self->{close_button}->configure ($self->{w} - $border, 0, $border, $border) |
1154 | $self->{close_button}->configure ($self->{w} - $border, 0, $border, $border) |
1155 | if $self->{close_button}; |
1155 | if $self->{close_button}; |
1156 | |
1156 | |
|
|
1157 | 1 |
|
|
1158 | } |
|
|
1159 | |
|
|
1160 | sub invoke_delete { |
|
|
1161 | my ($self) = @_; |
|
|
1162 | |
|
|
1163 | $self->hide; |
|
|
1164 | |
1157 | 1 |
1165 | 1 |
1158 | } |
1166 | } |
1159 | |
1167 | |
1160 | sub invoke_button_down { |
1168 | sub invoke_button_down { |
1161 | my ($self, $ev, $x, $y) = @_; |
1169 | my ($self, $ev, $x, $y) = @_; |
… | |
… | |
2247 | my $ycut1 = max 0, min 1, $ycut; |
2255 | my $ycut1 = max 0, min 1, $ycut; |
2248 | my $ycut2 = max 0, min 1, $ycut - 1; |
2256 | my $ycut2 = max 0, min 1, $ycut - 1; |
2249 | |
2257 | |
2250 | my $h1 = $self->{h} * (1 - $ycut1); |
2258 | my $h1 = $self->{h} * (1 - $ycut1); |
2251 | my $h2 = $self->{h} * (1 - $ycut2); |
2259 | my $h2 = $self->{h} * (1 - $ycut2); |
|
|
2260 | my $h3 = $self->{h}; |
|
|
2261 | |
|
|
2262 | $_ = $_ * (284-4)/288 + 4/288 for ($h1, $h2, $h3); |
2252 | |
2263 | |
2253 | glEnable GL_BLEND; |
2264 | glEnable GL_BLEND; |
2254 | glBlendFuncSeparate GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, |
2265 | glBlendFuncSeparate GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, |
2255 | GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
2266 | GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
2256 | glEnable GL_TEXTURE_2D; |
2267 | glEnable GL_TEXTURE_2D; |
… | |
… | |
2275 | |
2286 | |
2276 | if ($t3) { |
2287 | if ($t3) { |
2277 | glBindTexture GL_TEXTURE_2D, $t3->{name}; |
2288 | glBindTexture GL_TEXTURE_2D, $t3->{name}; |
2278 | glBegin GL_QUADS; |
2289 | glBegin GL_QUADS; |
2279 | glTexCoord 0 , $t3->{t} * (1 - $ycut2); glVertex 0 , $h2; |
2290 | glTexCoord 0 , $t3->{t} * (1 - $ycut2); glVertex 0 , $h2; |
2280 | glTexCoord 0 , $t3->{t}; glVertex 0 , $self->{h}; |
2291 | glTexCoord 0 , $t3->{t}; glVertex 0 , $h3; |
2281 | glTexCoord $t3->{s}, $t3->{t}; glVertex $w, $self->{h}; |
2292 | glTexCoord $t3->{s}, $t3->{t}; glVertex $w, $h3; |
2282 | glTexCoord $t3->{s}, $t3->{t} * (1 - $ycut2); glVertex $w, $h2; |
2293 | glTexCoord $t3->{s}, $t3->{t} * (1 - $ycut2); glVertex $w, $h2; |
2283 | glEnd; |
2294 | glEnd; |
2284 | } |
2295 | } |
2285 | |
2296 | |
2286 | glDisable GL_BLEND; |
2297 | glDisable GL_BLEND; |
… | |
… | |
3438 | |
3449 | |
3439 | ############################################################################# |
3450 | ############################################################################# |
3440 | |
3451 | |
3441 | package CFClient::UI::Inventory; |
3452 | package CFClient::UI::Inventory; |
3442 | |
3453 | |
3443 | our @ISA = CFClient::UI::ScrolledWindow::; |
3454 | our @ISA = CFClient::UI::Table::; |
3444 | |
3455 | |
3445 | sub new { |
3456 | sub new { |
3446 | my $class = shift; |
3457 | my $class = shift; |
3447 | |
3458 | |
3448 | my $self = $class->SUPER::new ( |
3459 | my $self = $class->SUPER::new ( |
3449 | child => (new CFClient::UI::Table col_expand => [0, 1, 0]), |
3460 | col_expand => [0, 1, 0], |
3450 | @_, |
3461 | @_, |
3451 | ); |
3462 | ); |
3452 | |
3463 | |
3453 | $self |
3464 | $self |
3454 | } |
3465 | } |
3455 | |
3466 | |
3456 | sub set_items { |
3467 | sub set_items { |
3457 | my ($self, $items) = @_; |
3468 | my ($self, $items) = @_; |
3458 | |
3469 | |
3459 | $self->{child}->clear; |
3470 | $self->clear; |
3460 | return unless $items; |
3471 | return unless $items; |
3461 | |
3472 | |
3462 | my @items = sort { |
3473 | my @items = sort { |
3463 | ($a->{type} <=> $b->{type}) |
3474 | ($a->{type} <=> $b->{type}) |
3464 | or ($a->{name} cmp $b->{name}) |
3475 | or ($a->{name} cmp $b->{name}) |
… | |
… | |
3468 | |
3479 | |
3469 | my $row = 0; |
3480 | my $row = 0; |
3470 | for my $item (@items) { |
3481 | for my $item (@items) { |
3471 | CFClient::Item::update_widgets $item; |
3482 | CFClient::Item::update_widgets $item; |
3472 | |
3483 | |
3473 | $self->{child}->add (0, $row, $item->{face_widget}); |
3484 | $self->add (0, $row, $item->{face_widget}); |
3474 | $self->{child}->add (1, $row, $item->{desc_widget}); |
3485 | $self->add (1, $row, $item->{desc_widget}); |
3475 | $self->{child}->add (2, $row, $item->{weight_widget}); |
3486 | $self->add (2, $row, $item->{weight_widget}); |
3476 | |
3487 | |
3477 | $row++; |
3488 | $row++; |
3478 | } |
3489 | } |
3479 | } |
3490 | } |
3480 | |
3491 | |