… | |
… | |
59 | rec_inv_by_slaying ($pl, $cfg->{key_string}, sub { |
59 | rec_inv_by_slaying ($pl, $cfg->{key_string}, sub { |
60 | my ($ob) = @_; |
60 | my ($ob) = @_; |
61 | $match = $ob; |
61 | $match = $ob; |
62 | }); |
62 | }); |
63 | if ($match) { |
63 | if ($match) { |
64 | $match->decrease_ob_nr ($cfg->{decrease_by_cnt}) if $cfg->{decrease_by_cnt}; |
64 | $match->decrease ($cfg->{decrease_by_cnt}) if $cfg->{decrease_by_cnt}; |
65 | $pl->message ($cfg->{message_on_match}, cf::NDI_UNIQUE) if defined $cfg->{message_on_match}; |
65 | $pl->message ($cfg->{message_on_match}, cf::NDI_UNIQUE) if defined $cfg->{message_on_match}; |
66 | } else { |
66 | } else { |
67 | $pl->message ($cfg->{message_on_nomatch}, cf::NDI_RED | cf::NDI_UNIQUE) if defined $cfg->{message_on_nomatch}; |
67 | $pl->message ($cfg->{message_on_nomatch}, cf::NDI_RED | cf::NDI_UNIQUE) if defined $cfg->{message_on_nomatch}; |
68 | cf::override; |
68 | cf::override; |
69 | } |
69 | } |
… | |
… | |
107 | } |
107 | } |
108 | cf::override; |
108 | cf::override; |
109 | } |
109 | } |
110 | }; |
110 | }; |
111 | |
111 | |
|
|
112 | =item object attachment: 'display_info_window' |
|
|
113 | |
|
|
114 | If you attach this attachment to a sign a window containing the |
|
|
115 | message will open in the client when the player applies it. |
|
|
116 | |
|
|
117 | Use this feature with care, as popups usually are very noisy. |
|
|
118 | This is mostly thought for tutorial or other instructions. |
|
|
119 | |
|
|
120 | =cut |
|
|
121 | |
|
|
122 | cf::object::attachment display_info_window => |
|
|
123 | on_apply => sub { |
|
|
124 | my ($self, $pl) = @_; |
|
|
125 | |
|
|
126 | return unless $pl->contr->ns->{can_widget}; |
|
|
127 | |
|
|
128 | my $cfg = $self->{display_info_window}; |
|
|
129 | |
|
|
130 | if ($pl->contr->ns->{info_wins}->{$self->uuid}) { |
|
|
131 | $pl->contr->ns->{info_wins}->{$self->uuid}->destroy; |
|
|
132 | } |
|
|
133 | |
|
|
134 | my $ws = $pl->contr->ns->new_widgetset; |
|
|
135 | |
|
|
136 | my $w = $ws->{my_main} = $ws->new (Toplevel => |
|
|
137 | force_w => 600, |
|
|
138 | force_h => 400, |
|
|
139 | x => 'center', |
|
|
140 | y => 'center', |
|
|
141 | title => 'Information Sign', |
|
|
142 | has_close_button => 1, |
|
|
143 | on_delete => sub { $ws->destroy }, |
|
|
144 | ); |
|
|
145 | $w->add ($ws->{txt_area} = $ws->new ('TextScroller')); |
|
|
146 | $ws->{txt_area}->add_paragraph ($self->msg); |
|
|
147 | $w->show; |
|
|
148 | $pl->contr->ns->{info_wins}->{$self->uuid} = $ws; |
|
|
149 | |
|
|
150 | cf::override 1; |
|
|
151 | }; |
|
|
152 | |
112 | =back |
153 | =back |
113 | |
154 | |
114 | =cut |
155 | =cut |