… | |
… | |
415 | } while $self->{texture}[$id]; |
415 | } while $self->{texture}[$id]; |
416 | |
416 | |
417 | CFPlus::DB::get tilecache => $id, sub { |
417 | CFPlus::DB::get tilecache => $id, sub { |
418 | my ($data) = @_; |
418 | my ($data) = @_; |
419 | |
419 | |
|
|
420 | return unless $self->{map}; # stop when destroyed |
|
|
421 | |
420 | $self->set_texture ($id => $data) |
422 | $self->set_texture ($id => $data) |
421 | if defined $data; |
423 | if defined $data; |
422 | |
424 | |
423 | $self->bg_fetch; |
425 | $self->bg_fetch; |
424 | }; |
426 | }; |
… | |
… | |
433 | if (defined $data) { |
435 | if (defined $data) { |
434 | $data = Compress::LZF::decompress $data; |
436 | $data = Compress::LZF::decompress $data; |
435 | #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# |
437 | #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# |
436 | |
438 | |
437 | my $inprogress = @{ $self->{bg_fetch} || [] }; |
439 | my $inprogress = @{ $self->{bg_fetch} || [] }; |
438 | push @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $data); |
440 | unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $data); |
439 | $self->bg_fetch unless $inprogress; |
441 | $self->bg_fetch unless $inprogress; |
440 | } |
442 | } |
441 | }; |
443 | }; |
442 | } |
444 | } |
443 | |
445 | |
… | |
… | |
586 | } |
588 | } |
587 | |
589 | |
588 | sub set_texture { |
590 | sub set_texture { |
589 | my ($self, $id, $data) = @_; |
591 | my ($self, $id, $data) = @_; |
590 | |
592 | |
591 | $self->{texture}[$id] ||= do { |
593 | $self->{texture}[$id] = my $tex = |
592 | my $tex = |
|
|
593 | new_from_image CFPlus::Texture |
594 | new_from_image CFPlus::Texture |
594 | $data, minify => 1, mipmap => 1; |
595 | $data, minify => 1, mipmap => 1; |
595 | |
596 | |
596 | $self->{map}->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
597 | $self->{map}->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
597 | $self->{map_widget}->update; |
598 | $self->{map_widget}->update; |
598 | |
|
|
599 | $tex |
|
|
600 | }; |
|
|
601 | } |
599 | } |
602 | |
600 | |
603 | sub sound_play { |
601 | sub sound_play { |
604 | my ($self, $x, $y, $soundnum, $type) = @_; |
602 | my ($self, $x, $y, $soundnum, $type) = @_; |
605 | |
603 | |