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.80 by root, Sun Jul 30 13:16:44 2006 UTC vs.
Revision 1.84 by root, Sun Oct 1 18:17:38 2006 UTC

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
64sub 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
74sub 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 my $map = "map:$::CONN->{map_info}[0]";
86
87 if (fork == 0) {
88 $SIG{__DIE__} = sub {
89 warn "@_";
90 CFPlus::_exit 99;
91 };
92
93 # TODO: move into editor
94 require LWP::UserAgent;
95
96 my $ua = LWP::UserAgent->new (
97 agent => "cfplus $CFPlus::VERSION",
98 keep_alive => 1,
99 env_proxy => 1,
100 );
101
102 if ($map =~ /^map:(.*)/) {
103 my $mapname = $1;
104 # try to get the most recent head revision, what a hack
105 my $log = $ua->get ("$ENV{CROSSFIRE_MAPDIR}/$mapname?view=log&logsort=rev")->decoded_content;
106
107 if ($log =~ /\?rev=(\d+\.\d+)"/) {
108 my $rev = $1;
109 my $map = $ua->get ("$ENV{CROSSFIRE_MAPDIR}/$mapname?rev=$rev")->decoded_content;
110 warn "revision is $rev " .(length $map)."\n";#d#
111
112 # now upload it
113 my $comment = "some comment";
114
115 require HTTP::Request::Common;
116
117 my $res = $ua->post (
118 $ENV{CFPLUS_UPLOAD},
119 Content_Type => 'multipart/form-data',
120 Content => [
121 path => $mapname,
122 mapdir => $ENV{CROSSFIRE_MAPDIR},
123 map => $map,
124 revision => $rev,
125 cf_login => $ENV{CFPLUS_LOGIN},
126 cf_password => $ENV{CFPLUS_PASSWORD},
127 comment => "",
128 ]
129 );
130
131 if ($res->is_error) {
132 # fatal condition
133 warn $res->status_line;
134 } else {
135 # script replies are marked as {{..}}
136 my @msgs = $res->decoded_content =~ m/\{\{(.*?)\}\}/g;
137 warn map "$_\n", @msgs;
138 }
139 } else {
140 # error, could not detect revision
141 }
142 }
143
144 CFPlus::_exit;
145 }
69} 146}
70 147
71sub invoke_button_down { 148sub invoke_button_down {
72 my ($self, $ev, $x, $y) = @_; 149 my ($self, $ev, $x, $y) = @_;
73 150
115 $::PICKUP_ENABLE->{state} 192 $::PICKUP_ENABLE->{state}
116 ? "Disable automatic pickup" 193 ? "Disable automatic pickup"
117 : "Enable automatic pickup", 194 : "Enable automatic pickup",
118 sub { $::PICKUP_ENABLE->toggle } 195 sub { $::PICKUP_ENABLE->toggle }
119 ], 196 ],
197 $::CONN && length $::CONN->{cvs_root}
198 ? ["Edit this map <span size='xx-small'>(" . (CFPlus::asxml $::CONN->{map_info}[0]) . ")</span>",
199 \&editor_invoke]
200 : (),
201 $::CONN && length $::CONN->{test_server}
202 ? ["Login on Test Server <span size='xx-small'>(" . (CFPlus::asxml $::CONN->{test_server}) . ")</span>",
203 \&test_server_login]
204 : (),
120 ["Quit", 205 ["Quit",
121 sub { 206 sub {
122 if ($::CONN) { 207 if ($::CONN) {
123 &::open_quit_dialog; 208 &::open_quit_dialog;
124 } else { 209 } else {
212 my ($mod, $sym, $cmds) = @_; 297 my ($mod, $sym, $cmds) = @_;
213 $::BIND_EDITOR->cfg_bind ($mod, $sym, $cmds); 298 $::BIND_EDITOR->cfg_bind ($mod, $sym, $cmds);
214 }); 299 });
215 $::BIND_EDITOR->start; 300 $::BIND_EDITOR->start;
216 $::BIND_EDITOR->show; 301 $::BIND_EDITOR->show;
302#TODO: elmex, what was this supposed to do? it currently crashes the client.
217 } elsif ($sym == CFPlus::SDLK_INSERT && not ($mod & CFPlus::KMOD_CTRL)) { 303# } elsif ($sym == CFPlus::SDLK_INSERT && not ($mod & CFPlus::KMOD_CTRL)) {
218 $::BIND_EDITOR->stop; 304# $::BIND_EDITOR->stop;
219 $::BIND_EDITOR->ask_for_bind_and_commit; 305# $::BIND_EDITOR->ask_for_bind_and_commit;
220 $::BIND_EDITOR->hide; 306# $::BIND_EDITOR->hide;
221 } elsif (!$::CONN) { 307 } elsif (!$::CONN) {
222 return 0; # bindings further down need a valid connection 308 return 0; # bindings further down need a valid connection
223 309
224 } elsif ($sym == CFPlus::SDLK_KP5 && !$mod) { 310 } elsif ($sym == CFPlus::SDLK_KP5 && !$mod) {
225 $::CONN->user_send ("stay fire"); 311 $::CONN->user_send ("stay fire");
226 } elsif ($uni == ord ",") { 312 } elsif ($uni == ord ",") {
227 $::CONN->user_send ("take"); 313 $::CONN->user_send ("take");
228 } elsif ($uni == ord " ") { 314 } elsif ($uni == ord " ") {
229 $::CONN->user_send ("apply"); 315 $::CONN->user_send ("apply");
316 } elsif ($uni == 13) {
317 $::CONN->user_send ("examine");
230 } elsif ($uni == ord ".") { 318 } elsif ($uni == ord ".") {
231 $::CONN->user_send ($self->{completer}{last_command}) 319 $::CONN->user_send ($self->{completer}{last_command})
232 if exists $self->{completer}{last_command}; 320 if exists $self->{completer}{last_command};
233 } elsif (my $bind_cmd = $::CFG->{profile}{default}{bindings}{$mod}{$sym}) { 321 } elsif (my $bind_cmd = $::PROFILE->{bindings}{$mod}{$sym}) {
234 $::CONN->user_send ($_) for @$bind_cmd; 322 $::CONN->user_send ($_) for @$bind_cmd;
235 } elsif (($sym == CFPlus::SDLK_KP_PLUS && !$mod) || $uni == ord "+") { 323 } elsif (($sym == CFPlus::SDLK_KP_PLUS && !$mod) || $uni == ord "+") {
236 $::CONN->user_send ("rotateshoottype +"); 324 $::CONN->user_send ("rotateshoottype +");
237 } elsif (($sym == CFPlus::SDLK_KP_MINUS && !$mod) || $uni == ord "-") { 325 } elsif (($sym == CFPlus::SDLK_KP_MINUS && !$mod) || $uni == ord "-") {
238 $::CONN->user_send ("rotateshoottype -"); 326 $::CONN->user_send ("rotateshoottype -");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines