ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC.pm (file contents):
Revision 1.83 by root, Wed May 31 07:40:33 2006 UTC vs.
Revision 1.86 by elmex, Fri Jun 2 16:27:27 2006 UTC

203 203
204package CFClient::Item; 204package CFClient::Item;
205 205
206use strict; 206use strict;
207use Crossfire::Protocol::Constants; 207use Crossfire::Protocol::Constants;
208
209my $last_enter_count = 1;
208 210
209sub desc_string { 211sub 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
245sub 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
243sub update_widgets { 266sub 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);
281 } elsif (($ev->{mod} & CFClient::KMOD_SHIFT) && $ev->{button} == 2) {
282 $self->{flags} & F_LOCKED
283 ? $::CONN->send ("lock " . pack "CN", 0, $self->{tag})
284 : $::CONN->send ("lock " . pack "CN", 1, $self->{tag})
258 } elsif ($ev->{button} == 1) { 285 } elsif ($ev->{button} == 1) {
259 $::CONN->send ("examine $self->{tag}"); 286 $::CONN->send ("examine $self->{tag}");
260 } elsif ($ev->{button} == 2) { 287 } elsif ($ev->{button} == 2) {
261 $::CONN->send ("apply $self->{tag}"); 288 $::CONN->send ("apply $self->{tag}");
262 } elsif ($ev->{button} == 3) { 289 } elsif ($ev->{button} == 3) {
270 ["unlock", sub { $::CONN->send ("lock " . pack "CN", 0, $self->{tag}) }], 297 ["unlock", sub { $::CONN->send ("lock " . pack "CN", 0, $self->{tag}) }],
271 ) 298 )
272 : ( 299 : (
273 ["lock", sub { $::CONN->send ("lock " . pack "CN", 1, $self->{tag}) }], 300 ["lock", sub { $::CONN->send ("lock " . pack "CN", 1, $self->{tag}) }],
274 ["drop", sub { $::CONN->send ("move $::CONN->{open_container} $self->{tag} 0") }], 301 ["drop", sub { $::CONN->send ("move $::CONN->{open_container} $self->{tag} 0") }],
302 ["move n",
303 sub {
304 do_n_dialog (sub { $::CONN->send ("move $targ $self->{tag} $_[0]") })
305 }
306 ]
275 ) 307 )
276 ), 308 ),
277 ); 309 );
278 310
279 CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev); 311 CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev);
284 316
285 my $tooltip_std = "<small>" 317 my $tooltip_std = "<small>"
286 . "Left click - examine item\n" 318 . "Left click - examine item\n"
287 . "Shift-Left click - " . ($self->{container} ? "move or drop" : "take") . " item\n" 319 . "Shift-Left click - " . ($self->{container} ? "move or drop" : "take") . " item\n"
288 . "Middle click - apply\n" 320 . "Middle click - apply\n"
321 . "Shift-Middle click - lock/unlock\n"
289 . "Right click - further options" 322 . "Right click - further options"
290 . "</small>\n"; 323 . "</small>\n";
291 324
292 $self->{face_widget} ||= new CFClient::UI::Face 325 $self->{face_widget} ||= new CFClient::UI::Face
293 can_events => 1, 326 can_events => 1,
335} 368}
336 369
337package CFClient::Binder; 370package CFClient::Binder;
338 371
339my @ALLOWED_MODIFIER_KEYS = ( 372my @ALLOWED_MODIFIER_KEYS = (
340 (CFClient::SDLK_LSHIFT), 373 CFClient::SDLK_LSHIFT,
341 (CFClient::SDLK_LCTRL ), 374 CFClient::SDLK_LCTRL ,
342 (CFClient::SDLK_LALT ), 375 CFClient::SDLK_LALT ,
343 (CFClient::SDLK_LMETA ), 376 CFClient::SDLK_LMETA ,
344 377
345 (CFClient::SDLK_RSHIFT), 378 CFClient::SDLK_RSHIFT,
346 (CFClient::SDLK_RCTRL ), 379 CFClient::SDLK_RCTRL ,
347 (CFClient::SDLK_RALT ), 380 CFClient::SDLK_RALT ,
348 (CFClient::SDLK_RMETA ), 381 CFClient::SDLK_RMETA ,
349); 382);
350 383
351my %ALLOWED_MODIFIERS = ( 384my %ALLOWED_MODIFIERS = (
352 (CFClient::KMOD_LSHIFT) => "LSHIFT", 385 CFClient::KMOD_LSHIFT => "LSHIFT",
353 (CFClient::KMOD_LCTRL ) => "LCTRL", 386 CFClient::KMOD_LCTRL => "LCTRL",
354 (CFClient::KMOD_LALT ) => "LALT", 387 CFClient::KMOD_LALT => "LALT",
355 (CFClient::KMOD_LMETA ) => "LMETA", 388 CFClient::KMOD_LMETA => "LMETA",
356 389
357 (CFClient::KMOD_RSHIFT) => "RSHIFT", 390 CFClient::KMOD_RSHIFT => "RSHIFT",
358 (CFClient::KMOD_RCTRL ) => "RCTRL", 391 CFClient::KMOD_RCTRL => "RCTRL",
359 (CFClient::KMOD_RALT ) => "RALT", 392 CFClient::KMOD_RALT => "RALT",
360 (CFClient::KMOD_RMETA ) => "RMETA", 393 CFClient::KMOD_RMETA => "RMETA",
361); 394);
362 395
363my %DIRECT_BIND_CHARS = map { $_ => 1 } qw/0 1 2 3 4 5 6 7 8 9/; 396my %DIRECT_BIND_CHARS = map { $_ => 1 } qw/0 1 2 3 4 5 6 7 8 9/;
364my @DIRECT_BIND_KEYS = ( 397my @DIRECT_BIND_KEYS = (
365 CFClient::SDLK_F1, 398 CFClient::SDLK_F1,
439 $mods .= "+" if $mods ne ''; 472 $mods .= "+" if $mods ne '';
440 473
441 return $mods . CFClient::SDL_GetKeyName ($sym); 474 return $mods . CFClient::SDL_GetKeyName ($sym);
442} 475}
443 476
477package CFClient::Pickup;
478# some pickup constants
479sub PU_NOTHING { 0x00000000 }
480
481sub PU_DEBUG { 0x10000000 }
482sub PU_INHIBIT { 0x20000000 }
483sub PU_STOP { 0x40000000 }
484sub PU_NEWMODE { 0x80000000 }
485
486sub PU_RATIO { 0x0000000F }
487
488sub PU_FOOD { 0x00000010 }
489sub PU_DRINK { 0x00000020 }
490sub PU_VALUABLES { 0x00000040 }
491sub PU_BOW { 0x00000080 }
492
493sub PU_ARROW { 0x00000100 }
494sub PU_HELMET { 0x00000200 }
495sub PU_SHIELD { 0x00000400 }
496sub PU_ARMOUR { 0x00000800 }
497
498sub PU_BOOTS { 0x00001000 }
499sub PU_GLOVES { 0x00002000 }
500sub PU_CLOAK { 0x00004000 }
501sub PU_KEY { 0x00008000 }
502
503sub PU_MISSILEWEAPON { 0x00010000 }
504sub PU_ALLWEAPON { 0x00020000 }
505sub PU_MAGICAL { 0x00040000 }
506sub PU_POTION { 0x00080000 }
507
508sub PU_SPELLBOOK { 0x00100000 }
509sub PU_SKILLSCROLL { 0x00200000 }
510sub PU_READABLES { 0x00400000 }
511sub PU_MAGIC_DEVICE { 0x00800000 }
512
513sub PU_NOT_CURSED { 0x01000000 }
514
515sub PU_JEWELS { 0x02000000 }
516
517
4441; 5181;
445 519
446=back 520=back
447 521
448=head1 AUTHOR 522=head1 AUTHOR

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines