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

Comparing deliantra/Deliantra-Client/DC/MapWidget.pm (file contents):
Revision 1.72 by root, Wed Jul 5 01:53:24 2006 UTC vs.
Revision 1.78 by root, Sun Jul 23 16:11:12 2006 UTC

3use strict; 3use strict;
4use utf8; 4use utf8;
5 5
6use List::Util qw(min max); 6use List::Util qw(min max);
7 7
8use CFClient;
8use CFClient::OpenGL; 9use CFClient::OpenGL;
10use CFClient::UI;
9 11
10our @ISA = CFClient::UI::Base::; 12our @ISA = CFClient::UI::Base::;
11 13
12my $magicmap_tex = 14my $magicmap_tex =
13 new_from_file CFClient::Texture CFClient::find_rcfile "magicmap.png", 15 new_from_file CFClient::Texture CFClient::find_rcfile "magicmap.png",
30 @_ 32 @_
31 ); 33 );
32 34
33 $self->{completer} = new CFClient::MapWidget::Command:: 35 $self->{completer} = new CFClient::MapWidget::Command::
34 command => $self->{command}, 36 command => $self->{command},
35 can_focus => 1,
36 tooltip => "<b>The Command Completer</b>\n\n" 37 tooltip => "<b>The Command Completer</b>\n\n"
37 . "This is your central interface to send text commands to the server. " 38 . "This is your central interface to send text commands to the server. "
38 . "To enter a verbatim command to send to the server, just type the command, " 39 . "To enter a verbatim command to send to the server, just type the command, "
39 . "followed by a space, and press return. " 40 . "followed by a space, and press return. "
40 . "Typing the initial letters of words (or just any letters) displays guesses " 41 . "Typing the initial letters of words (or just any letters) displays guesses "
60 61
61sub clr_commands { 62sub clr_commands {
62 my ($self) = @_; 63 my ($self) = @_;
63 64
64 %{$self->{completer}{command}} = (); 65 %{$self->{completer}{command}} = ();
66
67 $self->{completer}->hide
68 if $self->{completer};
65} 69}
66 70
67sub invoke_button_down { 71sub invoke_button_down {
68 my ($self, $ev, $x, $y) = @_; 72 my ($self, $ev, $x, $y) = @_;
69 73
98 $self->update; 102 $self->update;
99 }; 103 };
100 } elsif ($ev->{button} == 3) { 104 } elsif ($ev->{button} == 3) {
101 (new CFClient::UI::Menu 105 (new CFClient::UI::Menu
102 items => [ 106 items => [
103 ["Help Browser…\t(F1)", sub { $::HELP_WINDOW->toggle_visibility }], 107 ["Help Browser…\tF1", sub { $::HELP_WINDOW->toggle_visibility }],
104 ["Stats &amp; Skills\t(F2)", sub { ::toggle_player_page ($::STATS_PAGE) }], 108 ["Statistics\tF2", sub { ::toggle_player_page ($::STATS_PAGE) }],
109 ["Skills\tF3", sub { ::toggle_player_page ($::SKILL_PAGE) }],
110 ["Spells…\tF4", sub { ::toggle_player_page ($::SPELL_PAGE) }],
105 ["Inventory…\t(F3)", sub { ::toggle_player_page ($::INVENTORY_PAGE) }], 111 ["Inventory…\tF5", sub { ::toggle_player_page ($::INVENTORY_PAGE) }],
106 ["Spells…\t(F4)", sub { ::toggle_player_page ($::SPELL_PAGE) }],
107 ["Setup… \t(F5)", sub { $::SETUP_DIALOG->toggle_visibility }], 112 ["Setup… \tF9", sub { $::SETUP_DIALOG->toggle_visibility }],
108 ["Server Messages…", sub { $::MESSAGE_WINDOW->toggle_visibility }], 113 ["Server Messages…", sub { $::MESSAGE_WINDOW->toggle_visibility }],
109 [ 114 [
110 $::PICKUP_ENABLE->{state} 115 $::PICKUP_ENABLE->{state}
111 ? "Disable automatic pickup" 116 ? "Disable automatic pickup"
112 : "Enable automatic pickup", 117 : "Enable automatic pickup",
113 sub { $::PICKUP_ENABLE->toggle } 118 sub { $::PICKUP_ENABLE->toggle }
183 } elsif ($sym == CFClient::SDLK_F1 && !$mod) { 188 } elsif ($sym == CFClient::SDLK_F1 && !$mod) {
184 $::HELP_WINDOW->toggle_visibility; 189 $::HELP_WINDOW->toggle_visibility;
185 } elsif ($sym == CFClient::SDLK_F2 && !$mod) { 190 } elsif ($sym == CFClient::SDLK_F2 && !$mod) {
186 ::toggle_player_page ($::STATS_PAGE); 191 ::toggle_player_page ($::STATS_PAGE);
187 } elsif ($sym == CFClient::SDLK_F3 && !$mod) { 192 } elsif ($sym == CFClient::SDLK_F3 && !$mod) {
188 ::toggle_player_page ($::INVENTORY_PAGE); 193 ::toggle_player_page ($::SKILL_PAGE);
189 } elsif ($sym == CFClient::SDLK_F4 && !$mod) { 194 } elsif ($sym == CFClient::SDLK_F4 && !$mod) {
190 ::toggle_player_page ($::SPELL_PAGE); 195 ::toggle_player_page ($::SPELL_PAGE);
191 } elsif ($sym == CFClient::SDLK_F5 && !$mod) { 196 } elsif ($sym == CFClient::SDLK_F5 && !$mod) {
197 ::toggle_player_page ($::INVENTORY_PAGE);
198 } elsif ($sym == CFClient::SDLK_F9 && !$mod) {
192 $::SETUP_DIALOG->toggle_visibility; 199 $::SETUP_DIALOG->toggle_visibility;
193 } elsif ($sym == CFClient::SDLK_INSERT && $mod & CFClient::KMOD_CTRL) { 200 } elsif ($sym == CFClient::SDLK_INSERT && $mod & CFClient::KMOD_CTRL) {
194 $::BIND_EDITOR->set_binding (undef, undef, [], 201 $::BIND_EDITOR->set_binding (undef, undef, [],
195 sub { 202 sub {
196 my ($mod, $sym, $cmds) = @_; 203 my ($mod, $sym, $cmds) = @_;
238 $::CONN->user_send ("run $DIR{$sym}[0]"); 245 $::CONN->user_send ("run $DIR{$sym}[0]");
239 } else { 246 } else {
240 $::CONN->user_send ("$DIR{$sym}[1]"); 247 $::CONN->user_send ("$DIR{$sym}[1]");
241 } 248 }
242 } elsif ((ord 'a') <= $uni && $uni <= (ord 'z')) { 249 } elsif ((ord 'a') <= $uni && $uni <= (ord 'z')) {
243 $self->{completer}->invoke_key_down ($ev); 250 $self->{completer}->inject_key_down ($ev);
244 $self->{completer}->show; 251 $self->{completer}->show;
245 } else { 252 } else {
246 return 0; 253 return 0;
247 } 254 }
248 255
520 my ($entry, $ev, $x, $y) = @_; 527 my ($entry, $ev, $x, $y) = @_;
521 528
522 if ($ev->{button} == 3) { 529 if ($ev->{button} == 3) {
523 (new CFClient::UI::Menu 530 (new CFClient::UI::Menu
524 items => [ 531 items => [
525 ["bind <i>" . (CFClient::UI::Label::escape $self->{select}) . "</i> to a key" 532 ["bind <i>" . (CFClient::asxml $self->{select}) . "</i> to a key"
526 => sub { $::BIND_EDITOR->do_quick_binding ([$self->{select}], sub { $entry->grab_focus }) }] 533 => sub { $::BIND_EDITOR->do_quick_binding ([$self->{select}], sub { $entry->grab_focus }) }]
527 ], 534 ],
528 )->popup ($ev); 535 )->popup ($ev);
529 return 1; 536 return 1;
530 } 537 }
613} 620}
614 621
615sub hide { 622sub hide {
616 my ($self) = @_; 623 my ($self) = @_;
617 624
625 $self->{hist_ptr} = 0;
626
618 $self->SUPER::hide; 627 $self->SUPER::hide;
619 $self->{entry}->set_text (""); 628 $self->{entry}->set_text ("");
620} 629}
621 630
622sub invoke_key_down { 631sub inject_key_down {
623 my ($self, $ev) = @_; 632 my ($self, $ev) = @_;
624 633
634 $self->{entry}->grab_focus;
625 $self->{entry}->emit (key_down => $ev) 635 $self->{entry}->emit (key_down => $ev);
626} 636}
627 637
628sub update_labels { 638sub update_labels {
629 my ($self) = @_; 639 my ($self) = @_;
630 640

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines