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.74 by root, Tue Apr 11 20:44:49 2006 UTC vs.
Revision 1.75 by root, Tue Apr 11 21:24:10 2006 UTC

19use CFClient; 19use CFClient;
20use CFClient::UI; 20use CFClient::UI;
21 21
22our $VERSION = '0.1'; 22our $VERSION = '0.1';
23 23
24my $MAX_FPS = 30; 24my $MAX_FPS = 60;
25my $TICKS_PER_FRAME = int 1000 / $MAX_FPS - 1; # min ticks per frame 25my $TICKS_PER_FRAME = int 1000 / $MAX_FPS - 1; # min ticks per frame
26 26
27our $FACECACHE; 27our $FACECACHE;
28 28
29our $CFG; 29our $CFG;
30our $CONN; 30our $CONN;
31 31
32our @SDL_MODES;
32our $WIDTH; 33our $WIDTH;
33our $HEIGHT; 34our $HEIGHT;
34our $FULLSCREEN; 35our $FULLSCREEN;
35 36
36our $NOW; 37our $NOW;
125 my $dialog = new CFClient::UI::FancyFrame x => 300, y => 100, 126 my $dialog = new CFClient::UI::FancyFrame x => 300, y => 100,
126 child => (my $vbox = new CFClient::UI::VBox); 127 child => (my $vbox = new CFClient::UI::VBox);
127 $vbox->add (new CFClient::UI::Label align => 0, text => "Setup"); 128 $vbox->add (new CFClient::UI::Label align => 0, text => "Setup");
128 $vbox->add (my $table = new CFClient::UI::Table); 129 $vbox->add (my $table = new CFClient::UI::Table);
129 130
130 $table->add (0, 0, new CFClient::UI::Label text => "Video Mode"); 131 $table->add (0, 0, new CFClient::UI::Label align => 1, text => "Video Mode");
132 $table->add (1, 0, my $hbox = new CFClient::UI::HBox);
133
134 $hbox->add (my $mode_slider = new CFClient::UI::Slider req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]);
135 $hbox->add (my $mode_label = new CFClient::UI::Label);
136
137 $mode_slider->connect (changed => sub {
138 my (undef, $value) = @_;
139
140 $CFG->{sdl_mode} = $value = int $value + 0.5;
141 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]});
142 });
143 $mode_slider->emit (changed => $mode_slider->{range}[0]);
144
131 $table->add (0, 1, new CFClient::UI::Label text => "Host"); 145 $table->add (0, 1, new CFClient::UI::Label align => 1, text => "Host");
146 $table->add (1, 1, my $host = new CFClient::UI::Entry text => $CFG->{host});
147
132 $table->add (0, 2, new CFClient::UI::Label text => "Port"); 148 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Port");
149 $table->add (1, 2, my $port = new CFClient::UI::Entry text => $CFG->{port});
150
133 $table->add (0, 3, new CFClient::UI::Label text => "Username"); 151 $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Username");
152 $table->add (1, 3, my $user = new CFClient::UI::Entry text => $CFG->{user});
153
134 $table->add (0, 4, new CFClient::UI::Label text => "Password", hidden => 1); 154 $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Password");
155 $table->add (1, 4, my $pass = new CFClient::UI::Entry text => $CFG->{password}, hidden => 1);
156
135 $table->add (0, 5, new CFClient::UI::Label text => "Server Map Size"); 157 $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Map Size");
158 $table->add (1, 5, my $mapsize_slider = new CFClient::UI::Slider req_w => 100, range => [$CFG->{mapsize}, 10, 100 + 1, 1]);
136 159
137 $CFClient::UI::TOPLEVEL->add ($dialog); 160 $CFClient::UI::TOPLEVEL->add ($dialog);
138} 161}
139 162
140sub start_game { 163sub start_game {
184 SDL::GLSwapBuffers; 207 SDL::GLSwapBuffers;
185} 208}
186 209
187sub debug { 210sub debug {
188 $DEBUG_STATUS->set_text ($_[0]); 211 $DEBUG_STATUS->set_text ($_[0]);
189 $DEBUG_STATUS->size_allocate ($DEBUG_STATUS->size_request); 212 my ($w, $h) = $DEBUG_STATUS->size_request;
190 $DEBUG_STATUS->move ($WIDTH - $DEBUG_STATUS->{w}, 0); 213 $DEBUG_STATUS->size_allocate ($WIDTH - $w, 0, $w, $h);
191} 214}
192 215
193my $FPS; 216my $FPS;
194 217
195sub refresh { 218sub refresh {
350 [qw/Password password/], 373 [qw/Password password/],
351 ); 374 );
352 375
353 my $cfg = {}; 376 my $cfg = {};
354 377
355 my $a = SDL::ListModes (0, SDL_FULLSCREEN|SDL_HWSURFACE);
356 my @modes = map { [SDL::RectW ($_), SDL::RectH ($_)] } @$a;
357
358 $w->add (my $vb = Gtk2::VBox->new); 378 $w->add (my $vb = Gtk2::VBox->new);
359 $vb->pack_start (my $t = Gtk2::Table->new (2, scalar @cfg), 0, 0, 0); 379 $vb->pack_start (my $t = Gtk2::Table->new (2, scalar @cfg), 0, 0, 0);
360 my $selmode = $::CFG->{width} . 'x' . $::CFG->{height}; 380 my $selmode = $::CFG->{width} . 'x' . $::CFG->{height};
361 $t->attach_defaults (Gtk2::Label->new ("Modes"), 0, 1, 0, 1); 381 $t->attach_defaults (Gtk2::Label->new ("Modes"), 0, 1, 0, 1);
362 $t->attach_defaults (my $cb = Gtk2::ComboBox->new_text, 1, 2, 0, 1); 382 $t->attach_defaults (my $cb = Gtk2::ComboBox->new_text, 1, 2, 0, 1);
363 my $i = 0; 383 my $i = 0;
364 my $act = 0; 384 my $act = 0;
365 for (map { "$_->[0]x$_->[1]" } reverse @modes) { 385 for (map { "$_->[0]x$_->[1]" } @SDL_MODES) {
366 if ($_ eq $selmode) { $act = $i } 386 if ($_ eq $selmode) { $act = $i }
367 $cb->append_text ($_); 387 $cb->append_text ($_);
368 $i++; 388 $i++;
369 } 389 }
370 $cb->set_active ($act); 390 $cb->set_active ($act);
416 436
417############################################################################# 437#############################################################################
418 438
419SDL::Init SDL_INIT_EVERYTHING; 439SDL::Init SDL_INIT_EVERYTHING;
420 440
441@SDL_MODES = reverse map [SDL::RectW ($_), SDL::RectH ($_)],
442 @{ SDL::ListModes 0, SDL_FULLSCREEN|SDL_HWSURFACE };
443
421CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; 444CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
422 445
423$CFG ||= { 446$CFG ||= {
424 width => 640, 447 width => 640,
425 height => 480, 448 height => 480,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines