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.111 by root, Sat Apr 15 12:46:48 2006 UTC vs.
Revision 1.112 by root, Sat Apr 15 13:56:26 2006 UTC

21our $VERSION = '0.1'; 21our $VERSION = '0.1';
22 22
23my $MAX_FPS = 60; 23my $MAX_FPS = 60;
24my $MIN_FPS = 5; # unused as of yet 24my $MIN_FPS = 5; # unused as of yet
25 25
26our $META_SERVER = "crossfire.real-time.com:13326";
27
26our $FACECACHE; 28our $FACECACHE;
27 29
28our $LAST_REFRESH; 30our $LAST_REFRESH;
29our $NOW; 31our $NOW;
30 32
38our $FULLSCREEN; 40our $FULLSCREEN;
39our $FONTSIZE; 41our $FONTSIZE;
40 42
41our $MAP; 43our $MAP;
42our $MAPWIDGET; 44our $MAPWIDGET;
45our $BUTTONBAR;
46our $LOGVIEW;
47our $CONSOLE;
48our $METASERVER;
43 49
44our $SDL_ACTIVE; 50our $SDL_ACTIVE;
45our $SDL_EV; 51our $SDL_EV;
46our %SDL_CB; 52our %SDL_CB;
47 53
48our $ALT_ENTER_MESSAGE; 54our $ALT_ENTER_MESSAGE;
49our $STATUS_LINE; 55our $STATUS_LINE;
50our $DEBUG_STATUS; 56our $DEBUG_STATUS;
51our $BUTTONBAR;
52our $LOGVIEW;
53our $CONSOLE;
54 57
55sub status { 58sub status {
56 $STATUS_LINE->set_text ($_[0]); 59 $STATUS_LINE->set_text ($_[0]);
57 my ($w, $h) = $STATUS_LINE->size_request; 60 my ($w, $h) = $STATUS_LINE->size_request;
58 $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h); 61 $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h);
68 status "logging in..."; 71 status "logging in...";
69 72
70 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 73 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
71 74
72 $MAP = new CFClient::Map $mapsize, $mapsize; 75 $MAP = new CFClient::Map $mapsize, $mapsize;
76
77 my ($host, $port) = split /:/, $CFG->{host};
73 78
74 $CONN = new conn 79 $CONN = new conn
75 host => $CFG->{host}, 80 host => $host,
76 port => $CFG->{port}, 81 port => $port || 13327,
77 user => $CFG->{user}, 82 user => $CFG->{user},
78 pass => $CFG->{password}, 83 pass => $CFG->{password},
79 mapw => $mapsize, 84 mapw => $mapsize,
80 maph => $mapsize, 85 maph => $mapsize,
81 ; 86 ;
137 $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { 142 $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub {
138 my ($self, $value) = @_; 143 my ($self, $value) = @_;
139 $CFG->{fow_smooth} = $value; 144 $CFG->{fow_smooth} = $value;
140 }); 145 });
141 146
142 $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Log Fontsize"); 147 $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Log Fontsize");
143 $table->add (1, 5, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 8, 30, 1], connect_changed => sub { 148 $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 8, 30, 1], connect_changed => sub {
144 my ($self, $value) = @_; 149 my ($self, $value) = @_;
145 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = int $value); 150 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = int $value);
146 }); 151 });
147 152
148 $table->add (1, 6, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { 153 $table->add (1, 7, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub {
149 destroy_screen (); 154 destroy_screen ();
150 init_screen (); 155 init_screen ();
151 }); 156 });
152 157
153 $dialog 158 $dialog
159}
160
161sub metaserver_dialog {
162 my $dialog = new CFClient::UI::FancyFrame
163 child => (my $vbox = new CFClient::UI::VBox);
164
165 $vbox->add ($dialog->{table} = new CFClient::UI::Table);
166
167 $dialog
168}
169
170sub update_metaserver {
171 status "fetching metaserver list...";
172
173 my $buf;
174
175 my $fh = new IO::Socket::INET PeerHost => $META_SERVER, Blocking => 0;
176
177 Event->io (fd => $fh, poll => 'r', cb => sub {
178 my $res = sysread $fh, $buf, 8192, length $buf;
179
180 if (!defined $res) {
181 $_[0]->w->cancel;
182 status "metaserver: $!";
183 } elsif ($res == 0) {
184 $_[0]->w->cancel;
185 status "server list retrieved";
186 warn $buf;
187 }
188 });
154} 189}
155 190
156sub server_setup { 191sub server_setup {
157 my $dialog = new CFClient::UI::FancyFrame 192 my $dialog = new CFClient::UI::FancyFrame
158 child => (my $vbox = new CFClient::UI::VBox); 193 child => (my $vbox = new CFClient::UI::VBox);
159 194
160 $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); 195 $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup");
161 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 196 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
162 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host"); 197 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host:Port");
198
199 {
200 $table->add (1, 2, my $vbox = new CFClient::UI::VBox);
201
163 $table->add (1, 2, my $host = new CFClient::UI::Entry text => $CFG->{host}, connect_changed => sub { 202 $vbox->add (new CFClient::UI::Entry text => $CFG->{host}, connect_changed => sub {
164 my ($self, $value) = @_; 203 my ($self, $value) = @_;
165 $CFG->{host} = $value; 204 $CFG->{host} = $value;
166 }); 205 });
167 206
168 $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Port"); 207 $METASERVER = metaserver_dialog;
169 $table->add (1, 3, my $port = new CFClient::UI::Entry text => $CFG->{port}, connect_changed => sub { 208
170 my ($self, $value) = @_; 209 $vbox->add (new CFClient::UI::Flopper text => "Metaserver", other => $METASERVER, connect_open => sub {
171 $CFG->{port} = $value; 210 update_metaserver;
172 }); 211 });
212 }
173 213
174 $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Username"); 214 $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Username");
175 $table->add (1, 4, my $user = new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub { 215 $table->add (1, 4, my $user = new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub {
176 my ($self, $value) = @_; 216 my ($self, $value) = @_;
177 $CFG->{user} = $value; 217 $CFG->{user} = $value;
528 fow_intensity => 0.45, 568 fow_intensity => 0.45,
529 fow_smooth => 0, 569 fow_smooth => 0,
530 log_fontsize => 14, 570 log_fontsize => 14,
531 mapsize => 100, 571 mapsize => 100,
532 host => "crossfire.schmorp.de", 572 host => "crossfire.schmorp.de",
533 port => 13327,
534 say_command => 'say', 573 say_command => 'say',
535); 574);
536 575
537while (my ($k, $v) = each %DEF_CFG) { 576while (my ($k, $v) = each %DEF_CFG) {
538 $CFG->{$k} = $v unless exists $CFG->{$k}; 577 $CFG->{$k} = $v unless exists $CFG->{$k};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines