… | |
… | |
25 | |
25 | |
26 | my $cmd = $1; |
26 | my $cmd = $1; |
27 | my @args = split /\|/, $2; |
27 | my @args = split /\|/, $2; |
28 | @args = (".*") unless @args; |
28 | @args = (".*") unless @args; |
29 | |
29 | |
|
|
30 | $_ = $_ eq ".*" ? "" : " $_" |
|
|
31 | for @args; |
|
|
32 | |
30 | my $text = CFClient::pod_to_pango $head2->content; |
33 | my $text = CFClient::pod_to_pango $head2->content; |
31 | |
34 | |
32 | for my $arg (@args) { |
|
|
33 | $arg = $arg eq ".*" ? "" : " $arg"; |
|
|
34 | |
|
|
35 | $self->{map_widget}->add_command ("$cmd$arg", $text); |
35 | $self->{map_widget}->add_command ("$cmd$_", $text) |
36 | } |
36 | for sort { (length $a) <=> (length $b) } |
|
|
37 | @args; |
37 | } |
38 | } |
38 | |
39 | |
39 | $self->{noface} = new_from_file CFClient::Texture |
40 | $self->{noface} = new_from_file CFClient::Texture |
40 | CFClient::find_rcfile "noface.png", minify => 1, mipmap => 1; |
41 | CFClient::find_rcfile "noface.png", minify => 1, mipmap => 1; |
41 | |
42 | |
… | |
… | |
54 | sub stats_update { |
55 | sub stats_update { |
55 | my ($self, $stats) = @_; |
56 | my ($self, $stats) = @_; |
56 | |
57 | |
57 | if (my $exp = $stats->{+CS_STAT_EXP64}) { |
58 | if (my $exp = $stats->{+CS_STAT_EXP64}) { |
58 | my $diff = $exp - $self->{prev_exp}; |
59 | my $diff = $exp - $self->{prev_exp}; |
59 | $::STATUSBOX->add ("$diff experience gained", group => "experience $diff", fg => [0.5, 1, 0.5, 0.8], timeout => 5) |
60 | $self->{statusbox}->add ("$diff experience gained", group => "experience $diff", fg => [0.5, 1, 0.5, 0.8], timeout => 5) |
60 | if exists $self->{prev_exp} && $diff; |
61 | if exists $self->{prev_exp} && $diff; |
61 | $self->{prev_exp} = $exp; |
62 | $self->{prev_exp} = $exp; |
62 | } |
63 | } |
63 | |
64 | |
64 | ::update_stats_window ($stats); |
65 | ::update_stats_window ($stats); |
… | |
… | |
324 | $prompt = $LAST_QUERY unless length $prompt; |
325 | $prompt = $LAST_QUERY unless length $prompt; |
325 | $LAST_QUERY = $prompt; |
326 | $LAST_QUERY = $prompt; |
326 | |
327 | |
327 | my $dialog = new CFClient::UI::FancyFrame |
328 | my $dialog = new CFClient::UI::FancyFrame |
328 | title => "Query", |
329 | title => "Query", |
329 | child => my $vbox = new CFClient::UI::VBox; |
330 | child => my $vbox = new CFClient::UI::VBox, |
|
|
331 | on_visibility_change => sub { |
|
|
332 | my ($self, $visible) = @_; |
|
|
333 | $self->center if $visible; |
|
|
334 | }, |
|
|
335 | ; |
330 | |
336 | |
331 | $vbox->add (new CFClient::UI::Label |
337 | $vbox->add (new CFClient::UI::Label |
332 | max_w => $::WIDTH * 0.4, |
338 | max_w => $::WIDTH * 0.4, |
333 | ellipsise => 0, |
339 | ellipsise => 0, |
334 | text => $prompt); |
340 | text => $prompt); |
335 | |
341 | |
336 | if ($flags & CS_QUERY_YESNO) { |
342 | if ($flags & CS_QUERY_YESNO) { |
337 | $vbox->add (my $hbox = new CFClient::UI::HBox); |
343 | $vbox->add (my $hbox = new CFClient::UI::HBox); |
338 | $hbox->add (new CFClient::UI::Button |
344 | $hbox->add (new CFClient::UI::Button |
339 | text => "No", |
345 | text => "No", |
340 | connect_activate => sub { |
346 | on_activate => sub { |
341 | $self->send ("reply n"); |
347 | $self->send ("reply n"); |
342 | $dialog->destroy; |
348 | $dialog->destroy; |
343 | $self->{map_widget}->focus_in; |
349 | $self->{map_widget}->focus_in; |
344 | } |
350 | } |
345 | ); |
351 | ); |
346 | $hbox->add (new CFClient::UI::Button |
352 | $hbox->add (new CFClient::UI::Button |
347 | text => "Yes", |
353 | text => "Yes", |
348 | connect_activate => sub { |
354 | on_activate => sub { |
349 | $self->send ("reply y"); |
355 | $self->send ("reply y"); |
350 | $dialog->destroy; |
356 | $dialog->destroy; |
351 | }, |
357 | }, |
352 | ); |
358 | ); |
353 | |
359 | |
354 | $dialog->focus_in; |
360 | $dialog->focus_in; |
355 | |
361 | |
356 | } elsif ($flags & CS_QUERY_SINGLECHAR) { |
362 | } elsif ($flags & CS_QUERY_SINGLECHAR) { |
357 | $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)"; |
363 | $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)"; |
358 | $vbox->add (my $entry = new CFClient::UI::Entry |
364 | $vbox->add (my $entry = new CFClient::UI::Entry |
359 | connect_changed => sub { |
365 | on_changed => sub { |
360 | $self->send ("reply $_[1]"); |
366 | $self->send ("reply $_[1]"); |
361 | $dialog->destroy; |
367 | $dialog->destroy; |
362 | }, |
368 | }, |
363 | ); |
369 | ); |
364 | |
370 | |
… | |
… | |
367 | } else { |
373 | } else { |
368 | $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; |
374 | $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; |
369 | |
375 | |
370 | $vbox->add (my $entry = new CFClient::UI::Entry |
376 | $vbox->add (my $entry = new CFClient::UI::Entry |
371 | $flags & CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (), |
377 | $flags & CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (), |
372 | connect_activate => sub { |
378 | on_activate => sub { |
373 | $self->send ("reply $_[1]"); |
379 | $self->send ("reply $_[1]"); |
374 | $dialog->destroy; |
380 | $dialog->destroy; |
375 | }, |
381 | }, |
376 | ); |
382 | ); |
377 | |
383 | |
378 | $entry->focus_in; |
384 | $entry->focus_in; |
379 | } |
385 | } |
380 | |
386 | |
381 | $dialog->show_centered; |
387 | $dialog->show; |
382 | } |
388 | } |
383 | |
389 | |
384 | sub drawinfo { |
390 | sub drawinfo { |
385 | my ($self, $color, $text) = @_; |
391 | my ($self, $color, $text) = @_; |
386 | |
392 | |
… | |
… | |
407 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
413 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
408 | |
414 | |
409 | $self->{logview}->add_paragraph ($color[$color], |
415 | $self->{logview}->add_paragraph ($color[$color], |
410 | join "\n", map "$time $_", split /\n/, $text); |
416 | join "\n", map "$time $_", split /\n/, $text); |
411 | |
417 | |
412 | $::STATUSBOX->add ($text, |
418 | $self->{statusbox}->add ($text, |
413 | group => $text, |
419 | group => $text, |
414 | fg => $color[$color], |
420 | fg => $color[$color], |
415 | timeout => 10, |
421 | timeout => 10, |
416 | tooltip_font => $::FONT_FIXED, |
422 | tooltip_font => $::FONT_FIXED, |
417 | ); |
423 | ); |
… | |
… | |
489 | |
495 | |
490 | my ($face) = splice @{ $self->{face_prefetch} }, + rand @{ $self->{face_prefetch} }, 1, (); |
496 | my ($face) = splice @{ $self->{face_prefetch} }, + rand @{ $self->{face_prefetch} }, 1, (); |
491 | |
497 | |
492 | $self->send ("requestinfo image_sums $face $face"); |
498 | $self->send ("requestinfo image_sums $face $face"); |
493 | |
499 | |
494 | $::STATUSBOX->add (CFClient::UI::Label::escape "prefetching $todo", |
500 | $self->{statusbox}->add (CFClient::UI::Label::escape "prefetching $todo", |
495 | group => "prefetch", timeout => 2, fg => [1, 1, 0, 0.5]); |
501 | group => "prefetch", timeout => 2, fg => [1, 1, 0, 0.5]); |
496 | } elsif (!exists $self->{num_faces}) { |
502 | } elsif (!exists $self->{num_faces}) { |
497 | $self->send ("requestinfo image_info"); |
503 | $self->send ("requestinfo image_info"); |
498 | |
504 | |
499 | $self->{num_faces} = 0; |
505 | $self->{num_faces} = 0; |
500 | |
506 | |
501 | $::STATUSBOX->add (CFClient::UI::Label::escape "starting to prefetch", |
507 | $self->{statusbox}->add (CFClient::UI::Label::escape "starting to prefetch", |
502 | group => "prefetch", timeout => 2, fg => [1, 1, 0, 0.5]); |
508 | group => "prefetch", timeout => 2, fg => [1, 1, 0, 0.5]); |
503 | } |
509 | } |
504 | } |
510 | } |
505 | |
511 | |
506 | sub update_floorbox { |
512 | sub update_floorbox { |