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.72 by root, Sat May 27 20:46:54 2006 UTC vs.
Revision 1.83 by root, Wed May 31 07:40:33 2006 UTC

68 } 68 }
69 69
70 close CFG; 70 close CFG;
71} 71}
72 72
73mkdir "$Crossfire::VARDIR/pclient", 0777; 73mkdir "$Crossfire::VARDIR/cfplus", 0777;
74 74
75our $DB_ENV;
76
77{
78 use strict;
79
80 my $recover = $BerkeleyDB::db_version >= 4.4
81 ? eval "DB_REGISTER | DB_RECOVER"
82 : 0;
83
75our $DB_ENV = new BerkeleyDB::Env 84 $DB_ENV = new BerkeleyDB::Env
76 -Home => "$Crossfire::VARDIR/pclient", 85 -Home => "$Crossfire::VARDIR/cfplus",
77 -Cachesize => 1_000_000, 86 -Cachesize => 1_000_000,
78 -ErrFile => "$Crossfire::VARDIR/pclient/errorlog.txt", 87 -ErrFile => "$Crossfire::VARDIR/cfplus/errorlog.txt",
79# -ErrPrefix => "DATABASE", 88# -ErrPrefix => "DATABASE",
80 -Verbose => 1, 89 -Verbose => 1,
81 -Flags => DB_CREATE | DB_RECOVER | DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_TXN, 90 -Flags => DB_CREATE | DB_RECOVER | DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_TXN | $recover,
91 -SetFlags => DB_AUTO_COMMIT | DB_LOG_AUTOREMOVE,
82 or die "unable to create/open database home $Crossfire::VARDIR/pclient: $BerkeleyDB::Error"; 92 or die "unable to create/open database home $Crossfire::VARDIR/cfplus: $BerkeleyDB::Error";
93}
83 94
84sub db_table($) { 95sub db_table($) {
85 my ($table) = @_; 96 my ($table) = @_;
86 97
87 $table =~ s/([^a-zA-Z0-9_\-])/sprintf "=%x=", ord $1/ge; 98 $table =~ s/([^a-zA-Z0-9_\-])/sprintf "=%x=", ord $1/ge;
88 99
89 new CFClient::Database 100 new CFClient::Database
90 -Env => $DB_ENV, 101 -Env => $DB_ENV,
91 -Filename => $table, 102 -Filename => $table,
92# -Filename => "database", 103# -Filename => "database",
93# -Subname => $table, 104# -Subname => $table,
94 -Property => DB_CHKSUM, 105 -Property => DB_CHKSUM,
95 -Flags => DB_CREATE | DB_UPGRADE, 106 -Flags => DB_CREATE | DB_UPGRADE,
96 or die "unable to create/open database table $_[0]: $BerkeleyDB::Error"; 107 or die "unable to create/open database table $_[0]: $BerkeleyDB::Error"
97} 108}
98 109
99sub pod_to_pango($) { 110sub pod_to_pango($) {
100 my ($pom) = @_; 111 my ($pom) = @_;
101 112
240 251
241 if ($self->{container} == $::CONN->{player}{tag}) { 252 if ($self->{container} == $::CONN->{player}{tag}) {
242 $targ = $::CONN->{open_container}; 253 $targ = $::CONN->{open_container};
243 } 254 }
244 255
245 $::CONN->send ("move $targ $self->{tag} 0"); 256 $::CONN->send ("move $targ $self->{tag} 0")
257 if $targ || !($self->{flags} & F_LOCKED);
246 } elsif ($ev->{button} == 1) { 258 } elsif ($ev->{button} == 1) {
247 $::CONN->send ("examine $self->{tag}"); 259 $::CONN->send ("examine $self->{tag}");
248 } elsif ($ev->{button} == 2) { 260 } elsif ($ev->{button} == 2) {
249 $::CONN->send ("apply $self->{tag}"); 261 $::CONN->send ("apply $self->{tag}");
250 } elsif ($ev->{button} == 3) { 262 } elsif ($ev->{button} == 3) {
320 . ($self->{nrof} ? "You have $self->{nrof} of it. " : "Item cannot stack with others of it's kind. ") 332 . ($self->{nrof} ? "You have $self->{nrof} of it. " : "Item cannot stack with others of it's kind. ")
321 . "\n\n$tooltip_std" 333 . "\n\n$tooltip_std"
322 ); 334 );
323} 335}
324 336
337package CFClient::Binder;
338
339my @ALLOWED_MODIFIER_KEYS = (
340 (CFClient::SDLK_LSHIFT),
341 (CFClient::SDLK_LCTRL ),
342 (CFClient::SDLK_LALT ),
343 (CFClient::SDLK_LMETA ),
344
345 (CFClient::SDLK_RSHIFT),
346 (CFClient::SDLK_RCTRL ),
347 (CFClient::SDLK_RALT ),
348 (CFClient::SDLK_RMETA ),
349);
350
351my %ALLOWED_MODIFIERS = (
352 (CFClient::KMOD_LSHIFT) => "LSHIFT",
353 (CFClient::KMOD_LCTRL ) => "LCTRL",
354 (CFClient::KMOD_LALT ) => "LALT",
355 (CFClient::KMOD_LMETA ) => "LMETA",
356
357 (CFClient::KMOD_RSHIFT) => "RSHIFT",
358 (CFClient::KMOD_RCTRL ) => "RCTRL",
359 (CFClient::KMOD_RALT ) => "RALT",
360 (CFClient::KMOD_RMETA ) => "RMETA",
361);
362
363my %DIRECT_BIND_CHARS = map { $_ => 1 } qw/0 1 2 3 4 5 6 7 8 9/;
364my @DIRECT_BIND_KEYS = (
365 CFClient::SDLK_F1,
366 CFClient::SDLK_F2,
367 CFClient::SDLK_F3,
368 CFClient::SDLK_F4,
369 CFClient::SDLK_F5,
370 CFClient::SDLK_F6,
371 CFClient::SDLK_F7,
372 CFClient::SDLK_F8,
373 CFClient::SDLK_F9,
374 CFClient::SDLK_F10,
375 CFClient::SDLK_F11,
376 CFClient::SDLK_F12,
377 CFClient::SDLK_F13,
378 CFClient::SDLK_F14,
379 CFClient::SDLK_F15,
380);
381
382# this binding dialog asks for a key-combo to be pressed
383# and if successful it calls the $cb with $mod and $sym as args.
384sub open_binding_dialog {
385 my ($cb) = @_;
386
387 my $w = new CFClient::UI::FancyFrame
388 title => "Bind Action",
389 x => "center",
390 y => "center";
391
392 $w->add (my $vb = new CFClient::UI::VBox);
393 $vb->add (new CFClient::UI::Label
394 text => "Press a modifier (CTRL, ALT and/or SHIFT) and a key."
395 ."You can only bind 0-9 and F1-F15 without modifiers."
396 );
397 $vb->add (my $entry = new CFClient::UI::Entry
398 text => "",
399 on_key_down => sub {
400 my ($entry, $ev) = @_;
401
402 my $mod = $ev->{mod};
403 my $sym = $ev->{sym};
404
405 # XXX: This seems a little bit hackisch to me, but i have to ignore them
406 if (grep { $_ == $sym } @ALLOWED_MODIFIER_KEYS) {
407 return;
408 }
409
410 if ($mod == CFClient::KMOD_NONE
411 and not $DIRECT_BIND_CHARS{chr ($ev->{unicode})}
412 and not grep { $sym == $_ } @DIRECT_BIND_KEYS)
413 {
414 $::STATUSBOX->add (
415 "Can't bind key ".CFClient::SDL_GetKeyName ($sym)
416 ." directly without modifier! It would damage the completer handling."
417 );
418 return;
419 }
420
421 $entry->focus_out;
422
423 $cb->($mod, $sym);
424
425 $w->destroy
426 });
427
428 $entry->focus_in;
429 $w->show;
430}
431
432sub keycombo_to_name {
433 my ($mod, $sym) = @_;
434
435 my $mods = join '+',
436 map { $ALLOWED_MODIFIERS{$_} }
437 grep { ($_ + 0) & ($mod + 0) }
438 keys %ALLOWED_MODIFIERS;
439 $mods .= "+" if $mods ne '';
440
441 return $mods . CFClient::SDL_GetKeyName ($sym);
442}
443
3251; 4441;
326 445
327=back 446=back
328 447
329=head1 AUTHOR 448=head1 AUTHOR

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines