ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/pclient
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/pclient (file contents):
Revision 1.97 by root, Thu Apr 13 23:31:43 2006 UTC vs.
Revision 1.100 by elmex, Fri Apr 14 10:57:36 2006 UTC

34 34
35our @SDL_MODES; 35our @SDL_MODES;
36our $WIDTH; 36our $WIDTH;
37our $HEIGHT; 37our $HEIGHT;
38our $FULLSCREEN; 38our $FULLSCREEN;
39our $FONTSIZE;
39 40
40our $MAP; 41our $MAP;
41our $MAPWIDGET; 42our $MAPWIDGET;
42our $FONTSIZE;
43 43
44our $SDL_ACTIVE; 44our $SDL_ACTIVE;
45our $SDL_EV; 45our $SDL_EV;
46our %SDL_CB; 46our %SDL_CB;
47 47
48our $ALT_ENTER_MESSAGE; 48our $ALT_ENTER_MESSAGE;
49our $STATUS_LINE; 49our $STATUS_LINE;
50our $DEBUG_STATUS; 50our $DEBUG_STATUS;
51our $BUTTONBAR;
52our $LOGVIEW;
51 53
52sub status { 54sub status {
53 $STATUS_LINE->set_text ($_[0]); 55 $STATUS_LINE->set_text ($_[0]);
54 my ($w, $h) = $STATUS_LINE->size_request; 56 my ($w, $h) = $STATUS_LINE->size_request;
55 $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h); 57 $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h);
85sub stop_game { 87sub stop_game {
86 undef $CONN; 88 undef $CONN;
87} 89}
88 90
89sub config_dialog { 91sub config_dialog {
90 my $dialog = new CFClient::UI::FancyFrame x => 300, y => 100, 92 my $dialog = new CFClient::UI::FancyFrame
91 child => (my $vbox = new CFClient::UI::VBox); 93 child => (my $vbox = new CFClient::UI::VBox);
92 $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup"); 94 $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup");
93 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 95 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
94 96
95 $table->add (0, 0, new CFClient::UI::Label align => 1, text => "Video Mode"); 97 $table->add (0, 0, new CFClient::UI::Label align => 1, text => "Video Mode");
174 176
175 $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Save", connect_activate => sub { 177 $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Save", connect_activate => sub {
176 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 178 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
177 status "Configuration Saved"; 179 status "Configuration Saved";
178 }); 180 });
179 $CFClient::UI::TOPLEVEL->add ($dialog); 181
182 $dialog
183}
184
185sub console_window {
186 my $window = new CFClient::UI::FancyFrame
187 border_bg => [1, 1, 1, 0.5],
188 bg => [0.3, 0.3, 0.3, 0.8],
189 child => (my $vbox = new CFClient::UI::VBox);
190
191 $vbox->add ($LOGVIEW = new CFClient::UI::TextView expand => 1);
192 $vbox->add (my $input = new CFClient::UI::LineEntry);
193 $input->connect (activate => sub {
194 my ($input, $text) = @_;
195 $input->set_text ('');
196
197 if ($text =~ /^\/(.*)/) {
198 $::CONN->user_send ("command $1");
199 } else {
200 $::CONN->user_send ("command say $text");
201 }
202 1
203 });
204
205 $window
180} 206}
181 207
182sub sdl_init { 208sub sdl_init {
183 SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE 209 SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO
184 and die "SDL::Init failed!\n"; 210 and die "SDL::Init failed!\n";
185} 211}
186 212
187sub init_screen { 213sub init_screen {
188 sdl_init; 214 sdl_init;
223 249
224 $FONTSIZE = int $HEIGHT / 40; 250 $FONTSIZE = int $HEIGHT / 40;
225 251
226 ############################################################################# 252 #############################################################################
227 253
228 $DEBUG_STATUS = new CFClient::UI::Label padding => 0; 254 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100;
229 $CFClient::UI::TOPLEVEL->add ($DEBUG_STATUS); 255 $CFClient::UI::TOPLEVEL->add ($DEBUG_STATUS);
230 256
231 $STATUS_LINE = new CFClient::UI::Label 257 $STATUS_LINE = new CFClient::UI::Label
232 padding => 0, 258 padding => 0,
233 y => $HEIGHT * 49 / 50 - $FONTSIZE; 259 y => $HEIGHT * 44 / 45 - $FONTSIZE;
234 $CFClient::UI::TOPLEVEL->add ($STATUS_LINE); 260 $CFClient::UI::TOPLEVEL->add ($STATUS_LINE);
235 261
236 $ALT_ENTER_MESSAGE = new CFClient::UI::Label 262 $ALT_ENTER_MESSAGE = new CFClient::UI::Label
237 padding => 0, 263 padding => 0,
238 y => $HEIGHT * 49 / 50, 264 y => $HEIGHT * 44 / 45,
239 height => $HEIGHT / 50, 265 height => $HEIGHT / 45,
240 text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 266 text => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
241 $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE); 267 $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE);
242 268
243 $MAPWIDGET = new CFClient::UI::MapWidget;
244 $CFClient::UI::TOPLEVEL->add ($MAPWIDGET); 269 $CFClient::UI::TOPLEVEL->add ($MAPWIDGET = new CFClient::UI::MapWidget);
245 $MAPWIDGET->focus_in; 270 $MAPWIDGET->focus_in;
246 271
247 config_dialog; 272 $CFClient::UI::TOPLEVEL->add ($BUTTONBAR = new CFClient::UI::HBox);
273
274 $BUTTONBAR->add (my $setup = new CFClient::UI::Flopper x => 0, y => 0, text => "Setup", other => config_dialog, state => 1);
275 $BUTTONBAR->add (my $setup = new CFClient::UI::Flopper x => 0, y => 0, text => "Console", other => console_window);
248} 276}
249 277
250sub destroy_screen { 278sub destroy_screen {
251 $CFClient::UI::TOPLEVEL->{children} = []; 279 $CFClient::UI::TOPLEVEL->{children} = [];
252 undef $SDL_ACTIVE; 280 undef $SDL_ACTIVE;
370} 398}
371 399
372sub conn::query { 400sub conn::query {
373 my ($self, $flags, $prompt) = @_; 401 my ($self, $flags, $prompt) = @_;
374 402
403 #TODO
375 warn "<<<<QUERY:$flags:$prompt>>>\n";#d# 404 warn "<<<<QUERY:$flags:$prompt>>>\n";#d#
405}
406
407sub conn::drawinfo {
408 my ($self, $color, $text) = @_;
409
410 my @color = (
411 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00],
412 [1.00, 1.00, 1.00],
413 [0.00, 0.00, 0.55],
414 [1.00, 0.00, 0.00],
415 [1.00, 0.54, 0.00],
416 [0.11, 0.56, 1.00],
417 [0.93, 0.46, 0.00],
418 [0.18, 0.54, 0.34],
419 [0.56, 0.73, 0.56],
420 [0.80, 0.80, 0.80],
421 [0.55, 0.41, 0.13],
422 [0.99, 0.77, 0.26],
423 [0.74, 0.65, 0.41],
424 );
425
426 $LOGVIEW->add_paragraph ($color[$color], $text);
376} 427}
377 428
378%SDL_CB = ( 429%SDL_CB = (
379 SDL_QUIT() => sub { 430 SDL_QUIT() => sub {
380 Event::unloop -1; 431 Event::unloop -1;
385 refresh; 436 refresh;
386 }, 437 },
387 SDL_KEYDOWN() => sub { 438 SDL_KEYDOWN() => sub {
388 if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { 439 if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) {
389 # alt-enter 440 # alt-enter
390 $FULLSCREEN = !$FULLSCREEN;
391 destroy_screen; 441 destroy_screen;
442 $CFG->{fullscreen} = !$CFG->{fullscreen};
392 init_screen; 443 init_screen;
393 } else { 444 } else {
394 CFClient::UI::feed_sdl_key_down_event ($SDL_EV); 445 CFClient::UI::feed_sdl_key_down_event ($SDL_EV);
395 } 446 }
396 }, 447 },

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines