… | |
… | |
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 | |
… | |
… | |
52 | } |
53 | } |
53 | |
54 | |
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 | $self->{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 | } |
… | |
… | |
65 | } |
66 | } |
66 | |
67 | |
67 | sub user_send { |
68 | sub user_send { |
68 | my ($self, $command) = @_; |
69 | my ($self, $command) = @_; |
69 | |
70 | |
|
|
71 | if ($self->{record}) { |
|
|
72 | push @{$self->{record}}, $command; |
|
|
73 | } |
|
|
74 | |
70 | $self->send_command ($command); |
75 | $self->send_command ($command); |
71 | ::status $command; |
76 | ::status $command; |
|
|
77 | } |
|
|
78 | |
|
|
79 | sub start_record { |
|
|
80 | my ($self) = @_; |
|
|
81 | |
|
|
82 | $self->{record} = []; |
|
|
83 | } |
|
|
84 | |
|
|
85 | sub stop_record { |
|
|
86 | my ($self) = @_; |
|
|
87 | return delete $self->{record}; |
72 | } |
88 | } |
73 | |
89 | |
74 | sub map_scroll { |
90 | sub map_scroll { |
75 | my ($self, $dx, $dy) = @_; |
91 | my ($self, $dx, $dy) = @_; |
76 | |
92 | |
… | |
… | |
324 | $prompt = $LAST_QUERY unless length $prompt; |
340 | $prompt = $LAST_QUERY unless length $prompt; |
325 | $LAST_QUERY = $prompt; |
341 | $LAST_QUERY = $prompt; |
326 | |
342 | |
327 | my $dialog = new CFClient::UI::FancyFrame |
343 | my $dialog = new CFClient::UI::FancyFrame |
328 | title => "Query", |
344 | title => "Query", |
329 | child => my $vbox = new CFClient::UI::VBox; |
345 | child => my $vbox = new CFClient::UI::VBox, |
|
|
346 | on_visibility_change => sub { |
|
|
347 | my ($self, $visible) = @_; |
|
|
348 | $self->center if $visible; |
|
|
349 | }, |
|
|
350 | ; |
330 | |
351 | |
331 | $vbox->add (new CFClient::UI::Label |
352 | $vbox->add (new CFClient::UI::Label |
332 | max_w => $::WIDTH * 0.4, |
353 | max_w => $::WIDTH * 0.4, |
333 | ellipsise => 0, |
354 | ellipsise => 0, |
334 | text => $prompt); |
355 | text => $prompt); |
335 | |
356 | |
336 | if ($flags & CS_QUERY_YESNO) { |
357 | if ($flags & CS_QUERY_YESNO) { |
337 | $vbox->add (my $hbox = new CFClient::UI::HBox); |
358 | $vbox->add (my $hbox = new CFClient::UI::HBox); |
338 | $hbox->add (new CFClient::UI::Button |
359 | $hbox->add (new CFClient::UI::Button |
339 | text => "No", |
360 | text => "No", |
340 | connect_activate => sub { |
361 | on_activate => sub { |
341 | $self->send ("reply n"); |
362 | $self->send ("reply n"); |
342 | $dialog->destroy; |
363 | $dialog->destroy; |
343 | $self->{map_widget}->focus_in; |
364 | $self->{map_widget}->focus_in; |
344 | } |
365 | } |
345 | ); |
366 | ); |
346 | $hbox->add (new CFClient::UI::Button |
367 | $hbox->add (new CFClient::UI::Button |
347 | text => "Yes", |
368 | text => "Yes", |
348 | connect_activate => sub { |
369 | on_activate => sub { |
349 | $self->send ("reply y"); |
370 | $self->send ("reply y"); |
350 | $dialog->destroy; |
371 | $dialog->destroy; |
351 | }, |
372 | }, |
352 | ); |
373 | ); |
353 | |
374 | |
354 | $dialog->focus_in; |
375 | $dialog->focus_in; |
355 | |
376 | |
356 | } elsif ($flags & CS_QUERY_SINGLECHAR) { |
377 | } elsif ($flags & CS_QUERY_SINGLECHAR) { |
357 | $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)"; |
378 | $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 |
379 | $vbox->add (my $entry = new CFClient::UI::Entry |
359 | connect_changed => sub { |
380 | on_changed => sub { |
360 | $self->send ("reply $_[1]"); |
381 | $self->send ("reply $_[1]"); |
361 | $dialog->destroy; |
382 | $dialog->destroy; |
362 | }, |
383 | }, |
363 | ); |
384 | ); |
364 | |
385 | |
… | |
… | |
367 | } else { |
388 | } else { |
368 | $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; |
389 | $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; |
369 | |
390 | |
370 | $vbox->add (my $entry = new CFClient::UI::Entry |
391 | $vbox->add (my $entry = new CFClient::UI::Entry |
371 | $flags & CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (), |
392 | $flags & CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (), |
372 | connect_activate => sub { |
393 | on_activate => sub { |
373 | $self->send ("reply $_[1]"); |
394 | $self->send ("reply $_[1]"); |
374 | $dialog->destroy; |
395 | $dialog->destroy; |
375 | }, |
396 | }, |
376 | ); |
397 | ); |
377 | |
398 | |
378 | $entry->focus_in; |
399 | $entry->focus_in; |
379 | } |
400 | } |
380 | |
401 | |
381 | $dialog->show_centered; |
402 | $dialog->show; |
382 | } |
403 | } |
383 | |
404 | |
384 | sub drawinfo { |
405 | sub drawinfo { |
385 | my ($self, $color, $text) = @_; |
406 | my ($self, $color, $text) = @_; |
386 | |
407 | |
… | |
… | |
531 | } |
552 | } |
532 | |
553 | |
533 | sub set_opencont { |
554 | sub set_opencont { |
534 | my ($conn, $tag, $name) = @_; |
555 | my ($conn, $tag, $name) = @_; |
535 | $conn->{open_container} = $tag; |
556 | $conn->{open_container} = $tag; |
536 | $::INVR_LBL->set_text ($name); |
557 | |
|
|
558 | $::INV_RIGHT_HB->clear (); |
|
|
559 | $::INV_RIGHT_HB->add (new CFClient::UI::Label align => 0, expand => 1, text => $name); |
|
|
560 | |
|
|
561 | if ($tag != 0) { # Floor isn't closable, is it? |
|
|
562 | $::INV_RIGHT_HB->add (new CFClient::UI::Button |
|
|
563 | text => "Close container", |
|
|
564 | tooltip => "Close the currently open container (if one is open)", |
|
|
565 | on_activate => sub { |
|
|
566 | $::CONN->send ("apply $tag") # $::CONN->{open_container}") |
|
|
567 | if $tag != 0; |
|
|
568 | #if $CONN->{open_container} != 0; |
|
|
569 | }, |
|
|
570 | ); |
|
|
571 | } |
|
|
572 | |
537 | $::INVR->set_items ($conn->{container}{$tag}); |
573 | $::INVR->set_items ($conn->{container}{$tag}); |
538 | } |
574 | } |
539 | |
575 | |
540 | sub update_container { |
576 | sub update_container { |
541 | my ($tag) = @_; |
577 | my ($tag) = @_; |