… | |
… | |
203 | |
203 | |
204 | package CFClient::Item; |
204 | package CFClient::Item; |
205 | |
205 | |
206 | use strict; |
206 | use strict; |
207 | use Crossfire::Protocol::Constants; |
207 | use Crossfire::Protocol::Constants; |
|
|
208 | |
|
|
209 | my $last_enter_count = 1; |
208 | |
210 | |
209 | sub desc_string { |
211 | sub desc_string { |
210 | my ($self) = @_; |
212 | my ($self) = @_; |
211 | |
213 | |
212 | my $desc = |
214 | my $desc = |
… | |
… | |
238 | my $weight = ($self->{nrof} || 1) * $self->{weight}; |
240 | my $weight = ($self->{nrof} || 1) * $self->{weight}; |
239 | |
241 | |
240 | $weight < 0 ? "?" : $weight * 0.001 |
242 | $weight < 0 ? "?" : $weight * 0.001 |
241 | } |
243 | } |
242 | |
244 | |
|
|
245 | sub do_n_dialog { |
|
|
246 | my ($cb) = @_; |
|
|
247 | |
|
|
248 | my $w = new CFClient::UI::FancyFrame; |
|
|
249 | $w->add (my $vb = new CFClient::UI::VBox x => "center", y => "center"); |
|
|
250 | $vb->add (new CFClient::UI::Label text => "Enter item count:"); |
|
|
251 | $vb->add (my $entry = new CFClient::UI::Entry |
|
|
252 | text => $last_enter_count, |
|
|
253 | on_activate => sub { |
|
|
254 | my ($entry) = @_; |
|
|
255 | $last_enter_count = $entry->get_text; |
|
|
256 | $cb->($last_enter_count); |
|
|
257 | $w->hide; |
|
|
258 | $w = undef; |
|
|
259 | } |
|
|
260 | ); |
|
|
261 | $entry->focus_in; |
|
|
262 | $w->show; |
|
|
263 | |
|
|
264 | } |
|
|
265 | |
243 | sub update_widgets { |
266 | sub update_widgets { |
244 | my ($self) = @_; |
267 | my ($self) = @_; |
245 | |
268 | |
246 | my $button_cb = sub { |
269 | my $button_cb = sub { |
247 | my (undef, $ev, $x, $y) = @_; |
270 | my (undef, $ev, $x, $y) = @_; |
248 | |
271 | |
|
|
272 | my $targ = $::CONN->{player}{tag}; |
|
|
273 | |
|
|
274 | if ($self->{container} == $::CONN->{player}{tag}) { |
|
|
275 | $targ = $::CONN->{open_container}; |
|
|
276 | } |
|
|
277 | |
249 | if (($ev->{mod} & CFClient::KMOD_SHIFT) && $ev->{button} == 1) { |
278 | if (($ev->{mod} & CFClient::KMOD_SHIFT) && $ev->{button} == 1) { |
250 | my $targ = $::CONN->{player}{tag}; |
|
|
251 | |
|
|
252 | if ($self->{container} == $::CONN->{player}{tag}) { |
|
|
253 | $targ = $::CONN->{open_container}; |
|
|
254 | } |
|
|
255 | |
|
|
256 | $::CONN->send ("move $targ $self->{tag} 0") |
279 | $::CONN->send ("move $targ $self->{tag} 0") |
257 | if $targ || !($self->{flags} & F_LOCKED); |
280 | if $targ || !($self->{flags} & F_LOCKED); |
258 | } elsif ($ev->{button} == 1) { |
281 | } elsif ($ev->{button} == 1) { |
259 | $::CONN->send ("examine $self->{tag}"); |
282 | $::CONN->send ("examine $self->{tag}"); |
260 | } elsif ($ev->{button} == 2) { |
283 | } elsif ($ev->{button} == 2) { |
… | |
… | |
270 | ["unlock", sub { $::CONN->send ("lock " . pack "CN", 0, $self->{tag}) }], |
293 | ["unlock", sub { $::CONN->send ("lock " . pack "CN", 0, $self->{tag}) }], |
271 | ) |
294 | ) |
272 | : ( |
295 | : ( |
273 | ["lock", sub { $::CONN->send ("lock " . pack "CN", 1, $self->{tag}) }], |
296 | ["lock", sub { $::CONN->send ("lock " . pack "CN", 1, $self->{tag}) }], |
274 | ["drop", sub { $::CONN->send ("move $::CONN->{open_container} $self->{tag} 0") }], |
297 | ["drop", sub { $::CONN->send ("move $::CONN->{open_container} $self->{tag} 0") }], |
|
|
298 | ["move n", |
|
|
299 | sub { |
|
|
300 | do_n_dialog (sub { $::CONN->send ("move $targ $self->{tag} $_[0]") }) |
|
|
301 | } |
|
|
302 | ] |
275 | ) |
303 | ) |
276 | ), |
304 | ), |
277 | ); |
305 | ); |
278 | |
306 | |
279 | CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev); |
307 | CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev); |