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.82 by root, Wed May 31 07:13:50 2006 UTC vs.
Revision 1.86 by elmex, Fri Jun 2 16:27:27 2006 UTC

78 use strict; 78 use strict;
79 79
80 my $recover = $BerkeleyDB::db_version >= 4.4 80 my $recover = $BerkeleyDB::db_version >= 4.4
81 ? eval "DB_REGISTER | DB_RECOVER" 81 ? eval "DB_REGISTER | DB_RECOVER"
82 : 0; 82 : 0;
83 warn $recover;
84 83
85 $DB_ENV = new BerkeleyDB::Env 84 $DB_ENV = new BerkeleyDB::Env
86 -Home => "$Crossfire::VARDIR/cfplus", 85 -Home => "$Crossfire::VARDIR/cfplus",
87 -Cachesize => 1_000_000, 86 -Cachesize => 1_000_000,
88 -ErrFile => "$Crossfire::VARDIR/cfplus/errorlog.txt", 87 -ErrFile => "$Crossfire::VARDIR/cfplus/errorlog.txt",
204 203
205package CFClient::Item; 204package CFClient::Item;
206 205
207use strict; 206use strict;
208use Crossfire::Protocol::Constants; 207use Crossfire::Protocol::Constants;
208
209my $last_enter_count = 1;
209 210
210sub desc_string { 211sub desc_string {
211 my ($self) = @_; 212 my ($self) = @_;
212 213
213 my $desc = 214 my $desc =
239 my $weight = ($self->{nrof} || 1) * $self->{weight}; 240 my $weight = ($self->{nrof} || 1) * $self->{weight};
240 241
241 $weight < 0 ? "?" : $weight * 0.001 242 $weight < 0 ? "?" : $weight * 0.001
242} 243}
243 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
244sub update_widgets { 266sub update_widgets {
245 my ($self) = @_; 267 my ($self) = @_;
246 268
247 my $button_cb = sub { 269 my $button_cb = sub {
248 my (undef, $ev, $x, $y) = @_; 270 my (undef, $ev, $x, $y) = @_;
249 271
272 my $targ = $::CONN->{player}{tag};
273
274 if ($self->{container} == $::CONN->{player}{tag}) {
275 $targ = $::CONN->{open_container};
276 }
277
250 if (($ev->{mod} & CFClient::KMOD_SHIFT) && $ev->{button} == 1) { 278 if (($ev->{mod} & CFClient::KMOD_SHIFT) && $ev->{button} == 1) {
251 my $targ = $::CONN->{player}{tag};
252
253 if ($self->{container} == $::CONN->{player}{tag}) {
254 $targ = $::CONN->{open_container};
255 }
256
257 $::CONN->send ("move $targ $self->{tag} 0") 279 $::CONN->send ("move $targ $self->{tag} 0")
258 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})
259 } elsif ($ev->{button} == 1) { 285 } elsif ($ev->{button} == 1) {
260 $::CONN->send ("examine $self->{tag}"); 286 $::CONN->send ("examine $self->{tag}");
261 } elsif ($ev->{button} == 2) { 287 } elsif ($ev->{button} == 2) {
262 $::CONN->send ("apply $self->{tag}"); 288 $::CONN->send ("apply $self->{tag}");
263 } elsif ($ev->{button} == 3) { 289 } elsif ($ev->{button} == 3) {
271 ["unlock", sub { $::CONN->send ("lock " . pack "CN", 0, $self->{tag}) }], 297 ["unlock", sub { $::CONN->send ("lock " . pack "CN", 0, $self->{tag}) }],
272 ) 298 )
273 : ( 299 : (
274 ["lock", sub { $::CONN->send ("lock " . pack "CN", 1, $self->{tag}) }], 300 ["lock", sub { $::CONN->send ("lock " . pack "CN", 1, $self->{tag}) }],
275 ["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 ]
276 ) 307 )
277 ), 308 ),
278 ); 309 );
279 310
280 CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev); 311 CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev);
285 316
286 my $tooltip_std = "<small>" 317 my $tooltip_std = "<small>"
287 . "Left click - examine item\n" 318 . "Left click - examine item\n"
288 . "Shift-Left click - " . ($self->{container} ? "move or drop" : "take") . " item\n" 319 . "Shift-Left click - " . ($self->{container} ? "move or drop" : "take") . " item\n"
289 . "Middle click - apply\n" 320 . "Middle click - apply\n"
321 . "Shift-Middle click - lock/unlock\n"
290 . "Right click - further options" 322 . "Right click - further options"
291 . "</small>\n"; 323 . "</small>\n";
292 324
293 $self->{face_widget} ||= new CFClient::UI::Face 325 $self->{face_widget} ||= new CFClient::UI::Face
294 can_events => 1, 326 can_events => 1,
336} 368}
337 369
338package CFClient::Binder; 370package CFClient::Binder;
339 371
340my @ALLOWED_MODIFIER_KEYS = ( 372my @ALLOWED_MODIFIER_KEYS = (
341 (CFClient::SDLK_LSHIFT), 373 CFClient::SDLK_LSHIFT,
342 (CFClient::SDLK_LCTRL ), 374 CFClient::SDLK_LCTRL ,
343 (CFClient::SDLK_LALT ), 375 CFClient::SDLK_LALT ,
344 (CFClient::SDLK_LMETA ), 376 CFClient::SDLK_LMETA ,
345 377
346 (CFClient::SDLK_RSHIFT), 378 CFClient::SDLK_RSHIFT,
347 (CFClient::SDLK_RCTRL ), 379 CFClient::SDLK_RCTRL ,
348 (CFClient::SDLK_RALT ), 380 CFClient::SDLK_RALT ,
349 (CFClient::SDLK_RMETA ), 381 CFClient::SDLK_RMETA ,
350); 382);
351 383
352my %ALLOWED_MODIFIERS = ( 384my %ALLOWED_MODIFIERS = (
353 (CFClient::KMOD_LSHIFT) => "LSHIFT", 385 CFClient::KMOD_LSHIFT => "LSHIFT",
354 (CFClient::KMOD_LCTRL ) => "LCTRL", 386 CFClient::KMOD_LCTRL => "LCTRL",
355 (CFClient::KMOD_LALT ) => "LALT", 387 CFClient::KMOD_LALT => "LALT",
356 (CFClient::KMOD_LMETA ) => "LMETA", 388 CFClient::KMOD_LMETA => "LMETA",
357 389
358 (CFClient::KMOD_RSHIFT) => "RSHIFT", 390 CFClient::KMOD_RSHIFT => "RSHIFT",
359 (CFClient::KMOD_RCTRL ) => "RCTRL", 391 CFClient::KMOD_RCTRL => "RCTRL",
360 (CFClient::KMOD_RALT ) => "RALT", 392 CFClient::KMOD_RALT => "RALT",
361 (CFClient::KMOD_RMETA ) => "RMETA", 393 CFClient::KMOD_RMETA => "RMETA",
362); 394);
363 395
364my %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/;
365my @DIRECT_BIND_KEYS = ( 397my @DIRECT_BIND_KEYS = (
366 CFClient::SDLK_F1, 398 CFClient::SDLK_F1,
440 $mods .= "+" if $mods ne ''; 472 $mods .= "+" if $mods ne '';
441 473
442 return $mods . CFClient::SDL_GetKeyName ($sym); 474 return $mods . CFClient::SDL_GetKeyName ($sym);
443} 475}
444 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
4451; 5181;
446 519
447=back 520=back
448 521
449=head1 AUTHOR 522=head1 AUTHOR

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines