--- deliantra/Deliantra-Client/DC.pm 2006/06/07 23:30:25 1.92 +++ deliantra/Deliantra-Client/DC.pm 2006/07/22 12:18:01 1.101 @@ -237,6 +237,12 @@ ] } +package CFClient::Layout; + +$CFClient::OpenGL::SHUTDOWN_HOOK{"CFClient::Layout"} = sub { + reset_glyph_cache; +}; + package CFClient::Item; use strict; @@ -281,7 +287,11 @@ sub do_n_dialog { my ($cb) = @_; - my $w = new CFClient::UI::FancyFrame; + my $w = new CFClient::UI::FancyFrame + on_delete => sub { $_[0]->destroy; 1 }, + has_close_button => 1, + ; + $w->add (my $vb = new CFClient::UI::VBox x => "center", y => "center"); $vb->add (new CFClient::UI::Label text => "Enter item count:"); $vb->add (my $entry = new CFClient::UI::Entry @@ -291,12 +301,14 @@ $last_enter_count = $entry->get_text; $cb->($last_enter_count); $w->hide; - $w = undef; - } + $w->destroy; + + 0 + }, + on_escape => sub { $w->destroy; 1 }, ); - $entry->focus_in; + $entry->grab_focus; $w->show; - } sub update_widgets { @@ -326,9 +338,20 @@ } elsif ($ev->{button} == 2) { $::CONN->send ("apply $self->{tag}"); } elsif ($ev->{button} == 3) { + my $move_prefix = $::CONN->{open_container} ? 'put' : 'drop'; + if ($self->{container} == $::CONN->{open_container}) { + $move_prefix = "take"; + } + my @menu_items = ( ["examine", sub { $::CONN->send ("examine $self->{tag}") }], ["mark", sub { $::CONN->send ("mark ". pack "N", $self->{tag}) }], + ["ignite/thaw", # first try of an easier use of flint&steel + sub { + $::CONN->send ("mark ". pack "N", $self->{tag}); + $::CONN->send ("command apply flint and steel"); + } + ], ["apply", sub { $::CONN->send ("apply $self->{tag}") }], ( $self->{flags} & F_LOCKED @@ -337,8 +360,8 @@ ) : ( ["lock", sub { $::CONN->send ("lock " . pack "CN", 1, $self->{tag}) }], - ["drop", sub { $::CONN->send ("move $::CONN->{open_container} $self->{tag} 0") }], - ["move n", + ["$move_prefix all", sub { $::CONN->send ("move $targ $self->{tag} 0") }], + ["$move_prefix n", sub { do_n_dialog (sub { $::CONN->send ("move $targ $self->{tag} $_[0]") }) } @@ -406,113 +429,6 @@ ); } -package CFClient::Binder; - -my @ALLOWED_MODIFIER_KEYS = ( - CFClient::SDLK_LSHIFT, - CFClient::SDLK_LCTRL , - CFClient::SDLK_LALT , - CFClient::SDLK_LMETA , - - CFClient::SDLK_RSHIFT, - CFClient::SDLK_RCTRL , - CFClient::SDLK_RALT , - CFClient::SDLK_RMETA , -); - -my %ALLOWED_MODIFIERS = ( - CFClient::KMOD_LSHIFT => "LSHIFT", - CFClient::KMOD_LCTRL => "LCTRL", - CFClient::KMOD_LALT => "LALT", - CFClient::KMOD_LMETA => "LMETA", - - CFClient::KMOD_RSHIFT => "RSHIFT", - CFClient::KMOD_RCTRL => "RCTRL", - CFClient::KMOD_RALT => "RALT", - CFClient::KMOD_RMETA => "RMETA", -); - -my %DIRECT_BIND_CHARS = map { $_ => 1 } qw/0 1 2 3 4 5 6 7 8 9/; -my @DIRECT_BIND_KEYS = ( - CFClient::SDLK_F1, - CFClient::SDLK_F2, - CFClient::SDLK_F3, - CFClient::SDLK_F4, - CFClient::SDLK_F5, - CFClient::SDLK_F6, - CFClient::SDLK_F7, - CFClient::SDLK_F8, - CFClient::SDLK_F9, - CFClient::SDLK_F10, - CFClient::SDLK_F11, - CFClient::SDLK_F12, - CFClient::SDLK_F13, - CFClient::SDLK_F14, - CFClient::SDLK_F15, -); - -# this binding dialog asks for a key-combo to be pressed -# and if successful it calls the $cb with $mod and $sym as args. -sub open_binding_dialog { - my ($cb) = @_; - - my $w = new CFClient::UI::FancyFrame - title => "Bind Action", - x => "center", - y => "center"; - - $w->add (my $vb = new CFClient::UI::VBox); - $vb->add (new CFClient::UI::Label - text => "Press a modifier (CTRL, ALT and/or SHIFT) and a key." - ."You can only bind 0-9 and F1-F15 without modifiers." - ); - $vb->add (my $entry = new CFClient::UI::Entry - text => "", - on_key_down => sub { - my ($entry, $ev) = @_; - - my $mod = $ev->{mod}; - my $sym = $ev->{sym}; - - # XXX: This seems a little bit hackisch to me, but i have to ignore them - if (grep { $_ == $sym } @ALLOWED_MODIFIER_KEYS) { - return; - } - - if ($mod == CFClient::KMOD_NONE - and not $DIRECT_BIND_CHARS{chr ($ev->{unicode})} - and not grep { $sym == $_ } @DIRECT_BIND_KEYS) - { - $::STATUSBOX->add ( - "Can't bind key ".CFClient::SDL_GetKeyName ($sym) - ." directly without modifier! It would damage the completer handling." - ); - return; - } - - $entry->focus_out; - - $cb->($mod, $sym); - - $w->destroy - }); - - $entry->focus_in; - $w->show; -} - -sub keycombo_to_name { - my ($mod, $sym) = @_; - - my $mods = join '+', - map { $ALLOWED_MODIFIERS{$_} } - grep { ($_ + 0) & ($mod + 0) } - keys %ALLOWED_MODIFIERS; - $mods .= "+" if $mods ne ''; - - return $mods . CFClient::SDL_GetKeyName ($sym); -} - 1; =back