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.100 by elmex, Fri Apr 14 10:57:36 2006 UTC vs.
Revision 1.103 by elmex, Fri Apr 14 14:02:52 2006 UTC

48our $ALT_ENTER_MESSAGE; 48our $ALT_ENTER_MESSAGE;
49our $STATUS_LINE; 49our $STATUS_LINE;
50our $DEBUG_STATUS; 50our $DEBUG_STATUS;
51our $BUTTONBAR; 51our $BUTTONBAR;
52our $LOGVIEW; 52our $LOGVIEW;
53our $CONSOLE;
53 54
54sub status { 55sub status {
55 $STATUS_LINE->set_text ($_[0]); 56 $STATUS_LINE->set_text ($_[0]);
56 my ($w, $h) = $STATUS_LINE->size_request; 57 my ($w, $h) = $STATUS_LINE->size_request;
57 $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h); 58 $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h);
144 }); 145 });
145 146
146 $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); 147 $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup");
147 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 148 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
148 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host"); 149 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host");
149 $table->add (1, 2, my $host = new CFClient::UI::Entry text => $CFG->{host}); 150 $table->add (1, 2, my $host = new CFClient::UI::Entry text => $CFG->{host}, connect_changed => sub {
150 151 my ($self, $value) = @_;
152 $CFG->{host} = $value;
153 });
154
151 $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Port"); 155 $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Port");
152 $table->add (1, 3, my $port = new CFClient::UI::Entry text => $CFG->{port}); 156 $table->add (1, 3, my $port = new CFClient::UI::Entry text => $CFG->{port}, connect_changed => sub {
157 my ($self, $value) = @_;
158 $CFG->{port} = $value;
159 });
153 160
154 $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Username"); 161 $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Username");
155 $table->add (1, 4, my $user = new CFClient::UI::Entry text => $CFG->{user}); 162 $table->add (1, 4, my $user = new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub {
163 my ($self, $value) = @_;
164 $CFG->{user} = $value;
165 });
156 166
157 $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Password"); 167 $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Password");
158 $table->add (1, 5, my $pass = new CFClient::UI::Entry text => $CFG->{password}, hidden => 1); 168 $table->add (1, 5, my $pass = new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub {
169 my ($self, $value) = @_;
170 $CFG->{password} = $value;
171 });
159 172
173 $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Def. say cmd");
174 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub {
175 my ($self, $value) = @_;
176 $CFG->{say_command} = $value;
177 });
178
160 $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Map Size"); 179 $table->add (0, 7, new CFClient::UI::Label align => 1, text => "Map Size");
161 $table->add (1, 6, new CFClient::UI::Slider 180 $table->add (1, 7, new CFClient::UI::Slider
162 req_w => 100, 181 req_w => 100,
163 range => [$CFG->{mapsize}, 10, 100 + 1, 1], 182 range => [$CFG->{mapsize}, 10, 100 + 1, 1],
164 connect_changed => sub { 183 connect_changed => sub {
165 my ($self, $value) = @_; 184 my ($self, $value) = @_;
166 185
167 $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 186 $CFG->{mapsize} = $self->{range}[0] = $value = int $value;
168 }, 187 },
169 ); 188 );
170 189
171 $table->add (1, 7, new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub { 190 $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub {
172 start_game; 191 start_game;
173 }); 192 });
174 193
175 $vbox->add (my $hbox = new CFClient::UI::HBox); 194 $vbox->add (my $hbox = new CFClient::UI::HBox);
176 195
195 $input->set_text (''); 214 $input->set_text ('');
196 215
197 if ($text =~ /^\/(.*)/) { 216 if ($text =~ /^\/(.*)/) {
198 $::CONN->user_send ("command $1"); 217 $::CONN->user_send ("command $1");
199 } else { 218 } else {
219 my $say_cmd = $::CFG->{say_command} || 'say';
200 $::CONN->user_send ("command say $text"); 220 $::CONN->user_send ("command $say_cmd $text");
201 } 221 }
202 1 222 1
203 }); 223 });
224 $input->connect (escape => sub {
225 $MAPWIDGET->focus_in
226 });
227 $input->focus_in;
228
229 $CONSOLE = {
230 window => $window,
231 input => $input
232 };
204 233
205 $window 234 $window
206} 235}
207 236
208sub sdl_init { 237sub sdl_init {
266 text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 295 text => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
267 $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE); 296 $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE);
268 297
269 $CFClient::UI::TOPLEVEL->add ($MAPWIDGET = new CFClient::UI::MapWidget); 298 $CFClient::UI::TOPLEVEL->add ($MAPWIDGET = new CFClient::UI::MapWidget);
270 $MAPWIDGET->focus_in; 299 $MAPWIDGET->focus_in;
300 $MAPWIDGET->connect (activate_console => sub {
301 my ($mapwidget, $preset) = @_;
302
303 if ($CONSOLE) {
304 $CONSOLE->{input}->focus_in;
305
306 if ($preset && $CONSOLE->{input}->get_text eq '') {
307 $CONSOLE->{input}->set_text ($preset);
308 }
309 }
310 });
271 311
272 $CFClient::UI::TOPLEVEL->add ($BUTTONBAR = new CFClient::UI::HBox); 312 $CFClient::UI::TOPLEVEL->add ($BUTTONBAR = new CFClient::UI::HBox);
273 313
274 $BUTTONBAR->add (my $setup = new CFClient::UI::Flopper x => 0, y => 0, text => "Setup", other => config_dialog, state => 1); 314 $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); 315 $BUTTONBAR->add (my $setup = new CFClient::UI::Flopper x => 0, y => 0, text => "Console", other => console_window);
476 fullscreen => 0, 516 fullscreen => 0,
477 sdl_mode => 0, 517 sdl_mode => 0,
478 mapsize => 100, 518 mapsize => 100,
479 host => "crossfire.schmorp.de", 519 host => "crossfire.schmorp.de",
480 port => 13327, 520 port => 13327,
521 say_command => 'say',
481); 522);
482 523
483while (my ($k, $v) = each %DEF_CFG) { 524while (my ($k, $v) = each %DEF_CFG) {
484 $CFG->{$k} = $v unless exists $CFG->{$k}; 525 $CFG->{$k} = $v unless exists $CFG->{$k};
485} 526}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines