… | |
… | |
32 | @_ |
32 | @_ |
33 | ); |
33 | ); |
34 | |
34 | |
35 | $self->{completer} = new CFPlus::MapWidget::Command:: |
35 | $self->{completer} = new CFPlus::MapWidget::Command:: |
36 | command => $self->{command}, |
36 | command => $self->{command}, |
37 | tooltip => "<b>The Command Completer</b>\n\n" |
37 | tooltip => "#completer_help", |
38 | . "This is your central interface to send text commands to the server. " |
|
|
39 | . "To enter a verbatim command to send to the server, just type the command, " |
|
|
40 | . "followed by a space, and press return. " |
|
|
41 | . "Typing the initial letters of words (or just any letters) displays guesses " |
|
|
42 | . "for commands you might want to use.\n" |
|
|
43 | . "You can use the cursor-up and cursor-down keys to select between those guesses.\n" |
|
|
44 | . "<b>Right-Click</b> opens a menu where you cna select further options, sich as redefining key bindings.", |
|
|
45 | ; |
38 | ; |
46 | |
39 | |
47 | $self |
40 | $self |
48 | } |
41 | } |
49 | |
42 | |
… | |
… | |
64 | |
57 | |
65 | %{$self->{completer}{command}} = (); |
58 | %{$self->{completer}{command}} = (); |
66 | |
59 | |
67 | $self->{completer}->hide |
60 | $self->{completer}->hide |
68 | if $self->{completer}; |
61 | if $self->{completer}; |
|
|
62 | } |
|
|
63 | |
|
|
64 | sub test_server_login { |
|
|
65 | return unless |
|
|
66 | $::CONN && length $::CONN->{test_server}; |
|
|
67 | |
|
|
68 | my $server = $::CONN->{test_server}; |
|
|
69 | ::stop_game (); |
|
|
70 | local $::PROFILE->{host} = $server; |
|
|
71 | ::start_game (); |
|
|
72 | } |
|
|
73 | |
|
|
74 | sub editor_invoke { |
|
|
75 | return unless $::CONN; |
|
|
76 | |
|
|
77 | # putting the password into the env is somewhat tasteless |
|
|
78 | local $ENV{CFPLUS_LOGIN} = $::PROFILE->{user}; |
|
|
79 | local $ENV{CFPLUS_PASSWORD} = $::PROFILE->{password}; |
|
|
80 | local $ENV{CFPLUS_UPLOAD} = $::CONN->{upload}; |
|
|
81 | local $ENV{CROSSFIRE_MAPDIR} = $::CONN->{cvs_root}; |
|
|
82 | |
|
|
83 | # CFPlus::set_proxy; |
|
|
84 | |
|
|
85 | # TODO: move into editor |
|
|
86 | require LWP::Simple; |
69 | } |
87 | } |
70 | |
88 | |
71 | sub invoke_button_down { |
89 | sub invoke_button_down { |
72 | my ($self, $ev, $x, $y) = @_; |
90 | my ($self, $ev, $x, $y) = @_; |
73 | |
91 | |
… | |
… | |
115 | $::PICKUP_ENABLE->{state} |
133 | $::PICKUP_ENABLE->{state} |
116 | ? "Disable automatic pickup" |
134 | ? "Disable automatic pickup" |
117 | : "Enable automatic pickup", |
135 | : "Enable automatic pickup", |
118 | sub { $::PICKUP_ENABLE->toggle } |
136 | sub { $::PICKUP_ENABLE->toggle } |
119 | ], |
137 | ], |
|
|
138 | $::CONN && length $::CONN->{cvs_root} |
|
|
139 | ? ["Edit this map <span size='xx-small'>(" . (CFPlus::asxml $::CONN->{map_info}[0]) . ")</span>", \&editor_invoke] |
|
|
140 | : (), |
|
|
141 | $::CONN && length $::CONN->{test_server} |
|
|
142 | ? ["Login on Test Server", \&test_server_login] |
|
|
143 | : (), |
120 | ["Quit", |
144 | ["Quit", |
121 | sub { |
145 | sub { |
122 | if ($::CONN) { |
146 | if ($::CONN) { |
123 | &::open_quit_dialog; |
147 | &::open_quit_dialog; |
124 | } else { |
148 | } else { |
… | |
… | |
212 | my ($mod, $sym, $cmds) = @_; |
236 | my ($mod, $sym, $cmds) = @_; |
213 | $::BIND_EDITOR->cfg_bind ($mod, $sym, $cmds); |
237 | $::BIND_EDITOR->cfg_bind ($mod, $sym, $cmds); |
214 | }); |
238 | }); |
215 | $::BIND_EDITOR->start; |
239 | $::BIND_EDITOR->start; |
216 | $::BIND_EDITOR->show; |
240 | $::BIND_EDITOR->show; |
|
|
241 | #TODO: elmex, what was this supposed to do? it currently crashes the client. |
217 | } elsif ($sym == CFPlus::SDLK_INSERT && not ($mod & CFPlus::KMOD_CTRL)) { |
242 | # } elsif ($sym == CFPlus::SDLK_INSERT && not ($mod & CFPlus::KMOD_CTRL)) { |
218 | $::BIND_EDITOR->stop; |
243 | # $::BIND_EDITOR->stop; |
219 | $::BIND_EDITOR->ask_for_bind_and_commit; |
244 | # $::BIND_EDITOR->ask_for_bind_and_commit; |
220 | $::BIND_EDITOR->hide; |
245 | # $::BIND_EDITOR->hide; |
221 | } elsif (!$::CONN) { |
246 | } elsif (!$::CONN) { |
222 | return 0; # bindings further down need a valid connection |
247 | return 0; # bindings further down need a valid connection |
223 | |
248 | |
224 | } elsif ($sym == CFPlus::SDLK_KP5 && !$mod) { |
249 | } elsif ($sym == CFPlus::SDLK_KP5 && !$mod) { |
225 | $::CONN->user_send ("stay fire"); |
250 | $::CONN->user_send ("stay fire"); |
226 | } elsif ($uni == ord ",") { |
251 | } elsif ($uni == ord ",") { |
227 | $::CONN->user_send ("take"); |
252 | $::CONN->user_send ("take"); |
228 | } elsif ($uni == ord " ") { |
253 | } elsif ($uni == ord " ") { |
229 | $::CONN->user_send ("apply"); |
254 | $::CONN->user_send ("apply"); |
|
|
255 | } elsif ($uni == 13) { |
|
|
256 | $::CONN->user_send ("examine"); |
230 | } elsif ($uni == ord ".") { |
257 | } elsif ($uni == ord ".") { |
231 | $::CONN->user_send ($self->{completer}{last_command}) |
258 | $::CONN->user_send ($self->{completer}{last_command}) |
232 | if exists $self->{completer}{last_command}; |
259 | if exists $self->{completer}{last_command}; |
233 | } elsif (my $bind_cmd = $::CFG->{profile}{default}{bindings}{$mod}{$sym}) { |
260 | } elsif (my $bind_cmd = $::PROFILE->{bindings}{$mod}{$sym}) { |
234 | $::CONN->user_send ($_) for @$bind_cmd; |
261 | $::CONN->user_send ($_) for @$bind_cmd; |
235 | } elsif (($sym == CFPlus::SDLK_KP_PLUS && !$mod) || $uni == ord "+") { |
262 | } elsif (($sym == CFPlus::SDLK_KP_PLUS && !$mod) || $uni == ord "+") { |
236 | $::CONN->user_send ("rotateshoottype +"); |
263 | $::CONN->user_send ("rotateshoottype +"); |
237 | } elsif (($sym == CFPlus::SDLK_KP_MINUS && !$mod) || $uni == ord "-") { |
264 | } elsif (($sym == CFPlus::SDLK_KP_MINUS && !$mod) || $uni == ord "-") { |
238 | $::CONN->user_send ("rotateshoottype -"); |
265 | $::CONN->user_send ("rotateshoottype -"); |