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.164 by root, Sun Apr 23 01:05:04 2006 UTC vs.
Revision 1.171 by root, Mon Apr 24 03:33:51 2006 UTC

36our @SDL_MODES; 36our @SDL_MODES;
37our $WIDTH; 37our $WIDTH;
38our $HEIGHT; 38our $HEIGHT;
39our $FULLSCREEN; 39our $FULLSCREEN;
40our $FONTSIZE; 40our $FONTSIZE;
41
42our $FONT_PROP;
43our $FONT_FIXED;
41 44
42our $MAP; 45our $MAP;
43our $MAPWIDGET; 46our $MAPWIDGET;
44our $BUTTONBAR; 47our $BUTTONBAR;
45our $LOGVIEW; 48our $LOGVIEW;
120 $mode_slider->emit (changed => $mode_slider->{range}[0]); 123 $mode_slider->emit (changed => $mode_slider->{range}[0]);
121 124
122 my $row = 1; 125 my $row = 1;
123 126
124 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen"); 127 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen");
125 $table->add (1, $row++, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub { 128 $table->add (1, $row++, new CFClient::UI::CheckBox
129 state => $CFG->{fullscreen},
130 tooltip => "Bring the client into fullscreen mode",
131 connect_changed => sub {
126 my ($self, $value) = @_; 132 my ($self, $value) = @_;
127 $CFG->{fullscreen} = $value; 133 $CFG->{fullscreen} = $value;
134 }
128 }); 135 );
129 136
130 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); 137 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fast & Ugly");
131 $table->add (1, $row++, new CFClient::UI::CheckBox 138 $table->add (1, $row++, new CFClient::UI::CheckBox
132 state => $CFG->{fast}, 139 state => $CFG->{fast},
133 tooltip => "Lower the visual quality considerably to speed up rendering.", 140 tooltip => "Lower the visual quality considerably to speed up rendering.",
135 my ($self, $value) = @_; 142 my ($self, $value) = @_;
136 $CFG->{fast} = $value; 143 $CFG->{fast} = $value;
137 } 144 }
138 ); 145 );
139 146
147 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Map Scale");
148 $table->add (1, $row++, new CFClient::UI::Slider
149 range => [$CFG->{map_scale}, 0.25, 2, 0.05],
150 tooltip => "Enlarge or shrink the displayed map",
151 connect_changed => sub {
152 my ($self, $value) = @_;
153 $CFG->{map_scale} = 0.05 * int $value / 0.05;
154 }
155 );
156
140 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War"); 157 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War");
141 $table->add (1, $row++, new CFClient::UI::CheckBox 158 $table->add (1, $row++, new CFClient::UI::CheckBox
142 state => $CFG->{fow_enable}, 159 state => $CFG->{fow_enable},
143 tooltip => "Fog-of-War marks areas that cannot be seen by the player", 160 tooltip => "Fog-of-War marks areas that cannot be seen by the player",
144 connect_changed => sub { 161 connect_changed => sub {
211 ); 228 );
212 229
213 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); 230 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize");
214 $table->add (1, $row++, new CFClient::UI::Slider 231 $table->add (1, $row++, new CFClient::UI::Slider
215 range => [$CFG->{gauge_fontsize}, 0.5, 2.0, 0.1], 232 range => [$CFG->{gauge_fontsize}, 0.5, 2.0, 0.1],
233 tooltip => "Adjusts the fontsize of the gauges at the bottom right",
216 connect_changed => sub { 234 connect_changed => sub {
217 $CFG->{gauge_fontsize} = 0.1 * int $_[1] * 10; 235 $CFG->{gauge_fontsize} = 0.1 * int $_[1] * 10;
218 &set_gauge_window_fontsize; 236 &set_gauge_window_fontsize;
219 #$GAUGES->{win}->check_size;
220 #$GAUGES->{win}->update;
221 } 237 }
222 ); 238 );
223 239
224 $table->add (1, $row++, new CFClient::UI::Button 240 $table->add (1, $row++, new CFClient::UI::Button
225 expand => 1, align => 0, text => "Apply", 241 expand => 1, align => 0, text => "Apply",
226 tooltip => "Apply the video settings (unless they are auto-apply)", 242 tooltip => "Apply the video settings",
227 connect_activate => sub { 243 connect_activate => sub {
228 video_shutdown (); 244 video_shutdown ();
229 video_init (); 245 video_init ();
230 } 246 }
231 ); 247 );
260 } 276 }
261 ); 277 );
262 278
263 $table->add (1, $row++, new CFClient::UI::Button 279 $table->add (1, $row++, new CFClient::UI::Button
264 expand => 1, align => 0, text => "Apply", 280 expand => 1, align => 0, text => "Apply",
265 tooltip => "Apply the audio settings that are not auto-apply", 281 tooltip => "Apply the audio settings",
266 connect_activate => sub { 282 connect_activate => sub {
267 audio_shutdown (); 283 audio_shutdown ();
268 audio_init (); 284 audio_init ();
269 } 285 }
270 ); 286 );
280 296
281sub set_gauge_window_fontsize { 297sub set_gauge_window_fontsize {
282 for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) { 298 for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) {
283 $_->set_fontsize ($::CFG->{gauge_fontsize}); 299 $_->set_fontsize ($::CFG->{gauge_fontsize});
284 } 300 }
301
302# local $GAUGES->{win}{parent};#d#
303# use PApp::Util; open D, ">:utf8", "d"; print D PApp::Util::dumpval $GAUGES->{win}; close D;
285} 304}
286 305
287sub make_gauge_window { 306sub make_gauge_window {
288 my $gh = int ($HEIGHT * $CFG->{gauge_size}); 307 my $gh = int ($HEIGHT * $CFG->{gauge_size});
289# my $gw = int ($WIDTH * $CFG->{gauge_w_size}); 308# my $gw = int ($WIDTH * $CFG->{gauge_w_size});
290 309
291 my $win = new CFClient::UI::Frame ( 310 my $win = new CFClient::UI::Frame (
292 y => $HEIGHT - $gh, x => 0, req_w => $WIDTH, req_h => $gh 311 y => $HEIGHT - $gh, x => 0, user_w => $WIDTH, user_h => $gh
293 ); 312 );
294 $win->add (my $vb = new CFClient::UI::VBox); 313 $win->add (my $vb = new CFClient::UI::VBox);
295 314
296 $vb->add (my $hbg = new CFClient::UI::HBox expand => 1); 315 $vb->add (my $hbg = new CFClient::UI::HBox expand => 1);
297
298 316
299 $hbg->add (new CFClient::UI::Empty expand => 1); 317 $hbg->add (new CFClient::UI::Empty expand => 1);
300 $hbg->add (my $hb = new CFClient::UI::HBox); 318 $hbg->add (my $hb = new CFClient::UI::HBox);
301 $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp'); 319 $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp', tooltip => "Health points");
302 $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana'); 320 $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana', tooltip => "Spellpoints");
303 $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace'); 321 $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace', tooltip => "Grace");
304 $hb->add (my $fg = new CFClient::UI::Gauge type => 'food'); 322 $hb->add (my $fg = new CFClient::UI::Gauge type => 'food', tooltip => "Food");
305 323
306 $vb->add (my $exp = new CFClient::UI::Label valign => 0, align => 1, text => "XP:"); 324 $vb->add (my $exp = new CFClient::UI::Label valign => 0, align => 1, text => "XP: 0 LVL: 0");
307# $vb->add (my $lvl = new CFClient::UI::Label valign => 0, align => 1, text => "Lvl:");
308 $vb->add (my $rng = new CFClient::UI::Label valign => 0, align => 1, text => "Rng:"); 325 $vb->add (my $rng = new CFClient::UI::Label valign => 0, align => 1, text => "Rng:");
309 326
310
311 $GAUGES = { 327 $GAUGES = {
312 exp => $exp,# lvl => $lvl,
313 win => $win, range => $rng, 328 exp => $exp, win => $win, range => $rng,
314 food => $fg, mana => $mg, hp => $hg, grace => $gg 329 food => $fg, mana => $mg, hp => $hg, grace => $gg
315 }; 330 };
331
332 &set_gauge_window_fontsize;
333
316 $win 334 $win
317} 335}
318 336
319sub make_stats_window { 337sub make_stats_window {
320 my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH * 2/5, y => 0, title => "Stats"); 338 my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH * 2/5, y => 0, title => "Stats");
321 339
322 $tgw->add (my $vb = new CFClient::UI::VBox); 340 $tgw->add (my $vb = new CFClient::UI::VBox);
323 $vb->add (my $uhb = new CFClient::UI::HBox);
324 $uhb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1); 341 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1);
325 $uhb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1); 342 $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1);
326 343
327 $vb->add (my $hb = new CFClient::UI::HBox expand => 1); 344 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
328 345
329 $hb->add (my $tbl = new CFClient::UI::Table expand => 1); 346 $hb->add (my $tbl = new CFClient::UI::Table expand => 1);
330 347
348 $tbl->add (0, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
349 $tbl->add (0, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
350 $tbl->add (0, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
351 $tbl->add (0, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
352 $tbl->add (0, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
353 $tbl->add (0, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
354 $tbl->add (0, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
355
331 $tbl->add (0, 0, $STATWIDS->{st_str_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Str"); 356 $tbl->add (1, 0, $STATWIDS->{st_str_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Str");
332 $tbl->add (0, 1, $STATWIDS->{st_dex_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Dex"); 357 $tbl->add (1, 1, $STATWIDS->{st_dex_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Dex");
333 $tbl->add (0, 2, $STATWIDS->{st_con_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Con"); 358 $tbl->add (1, 2, $STATWIDS->{st_con_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Con");
334 $tbl->add (0, 3, $STATWIDS->{st_int_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Int"); 359 $tbl->add (1, 3, $STATWIDS->{st_int_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Int");
335 $tbl->add (0, 4, $STATWIDS->{st_wis_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Wis"); 360 $tbl->add (1, 4, $STATWIDS->{st_wis_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Wis");
336 $tbl->add (0, 5, $STATWIDS->{st_pow_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Pow"); 361 $tbl->add (1, 5, $STATWIDS->{st_pow_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Pow");
337 $tbl->add (0, 6, $STATWIDS->{st_cha_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Cha"); 362 $tbl->add (1, 6, $STATWIDS->{st_cha_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Cha");
338 363
339 $tbl->add (1, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => +1, text => ""); 364 $tbl->add (2, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => +1, template => "-120");
365 $tbl->add (2, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => +1, template => "-120");
340 $tbl->add (1, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => +1, text => ""); 366 $tbl->add (2, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => +1, template => "120");
341 $tbl->add (1, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => +1, text => "");
342 $tbl->add (1, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => +1, text => ""); 367 $tbl->add (2, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => +1, template => "120");
368 $tbl->add (2, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => +1, template => "10.54");
343 $tbl->add (1, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => +1, text => ""); 369 $tbl->add (2, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => +1, template => "9");
344 $tbl->add (1, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => +1, text => "");
345 $tbl->add (1, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => +1, text => "");
346 370
347 $tbl->add (2, 0, $STATWIDS->{st_wc_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Wc"); 371 $tbl->add (3, 0, $STATWIDS->{st_wc_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Wc");
348 $tbl->add (2, 1, $STATWIDS->{st_ac_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Ac"); 372 $tbl->add (3, 1, $STATWIDS->{st_ac_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Ac");
349 $tbl->add (2, 2, $STATWIDS->{st_dam_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Dam"); 373 $tbl->add (3, 2, $STATWIDS->{st_dam_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Dam");
350 $tbl->add (2, 3, $STATWIDS->{st_arm_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Arm"); 374 $tbl->add (3, 3, $STATWIDS->{st_arm_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Arm");
351 $tbl->add (2, 4, $STATWIDS->{st_spd_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Sp"); 375 $tbl->add (3, 4, $STATWIDS->{st_spd_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Sp");
352 $tbl->add (2, 5, $STATWIDS->{st_wspd_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "WSp"); 376 $tbl->add (3, 5, $STATWIDS->{st_wspd_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "WSp");
353
354 $tbl->add (3, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => +1, text => "");
355 $tbl->add (3, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => +1, text => "");
356 $tbl->add (3, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => +1, text => "");
357 $tbl->add (3, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => +1, text => "");
358 $tbl->add (3, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => +1, text => "");
359 $tbl->add (3, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => +1, text => "");
360 377
361 $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); 378 $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1);
362 379
363 my $row = 0; 380 my $row = 0;
364 my $col = 0; 381 my $col = 0;
365 382
383 my %resist_names = (
384 slow => "Slow",
385 holyw => "Holy Word",
386 conf => "Confusion",
387 fire => "Fire",
388 depl => "Depletion",
389 magic => "Magic",
390 drain => "Draining",
391 acid => "Acid",
392 pois => "Poison",
393 para => "Paralysation",
394 deat => "Death",
395 phys => "Physical",
396 blind => "Blind",
397 fear => "Fear",
398 tund => "Turn undead",
399 elec => "Electricity",
400 cold => "Cold",
401 ghit => "Ghost hit",
402 );
366 for (qw/slow holyw conf fire depl magic 403 for (qw/slow holyw conf fire depl magic
367 drain acid pois para deat phys 404 drain acid pois para deat phys
368 blind fear tund elec cold ghit/) 405 blind fear tund elec cold ghit/)
369 { 406 {
370 $tbl2->add ($col, $row, 407 $tbl2->add ($col, $row,
371 $STATWIDS->{"res_$_"} = 408 $STATWIDS->{"res_$_"} =
372 new CFClient::UI::Label text => "0", align => +1, valign => 0 409 new CFClient::UI::Label
410 template => "-100%",
411 align => +1,
412 valign => 0,
413 tooltip => $resist_names{$_}
373 ); 414 );
374 $tbl2->add ($col + 1, $row, new CFClient::UI::Image image => "ui/resist/resist_$_.png"); 415 $tbl2->add ($col + 1, $row, new CFClient::UI::Image
416 can_hover => 1,
417 can_events => 1,
418 image => "ui/resist/resist_$_.png",
419 tooltip => $resist_names{$_}
420 );
375 421
376 $row++; 422 $row++;
377 if ($row % 6 == 0) { 423 if ($row % 6 == 0) {
378 $col += 2; 424 $col += 2;
379 $row = 0; 425 $row = 0;
384 update_stats_window ({}); 430 update_stats_window ({});
385 431
386 $tgw 432 $tgw
387} 433}
388 434
435sub formsep {
436 reverse join ",", grep length, split /(...)/, reverse $_[0] * 1
437}
438
389sub update_stats_window { 439sub update_stats_window {
390 my ($stats) = @_; 440 my ($stats) = @_;
391 441
392 # i love text protocols!!! 442 # i love text protocols!!!
393 my $hp = $stats->{1} * 1; 443 my $hp = $stats->{Crossfire::Protocol::CS_STAT_HP} * 1;
394 my $hp_m = $stats->{2} * 1; 444 my $hp_m = $stats->{Crossfire::Protocol::CS_STAT_MAXHP} * 1;
395 my $sp = $stats->{3} * 1; 445 my $sp = $stats->{Crossfire::Protocol::CS_STAT_SP} * 1;
396 my $sp_m = $stats->{4} * 1; 446 my $sp_m = $stats->{Crossfire::Protocol::CS_STAT_MAXSP} * 1;
397 my $fo = $stats->{18} * 1; 447 my $fo = $stats->{Crossfire::Protocol::CS_STAT_FOOD} * 1;
398 my $fo_m = 999; 448 my $fo_m = 999;
399 my $gr = $stats->{23} * 1; 449 my $gr = $stats->{Crossfire::Protocol::CS_STAT_GRACE} * 1;
400 my $gr_m = $stats->{24} * 1; 450 my $gr_m = $stats->{Crossfire::Protocol::CS_STAT_MAXGRACE} * 1;
401 451
402 $GAUGES->{hp} ->set_value ($hp, $hp_m); 452 $GAUGES->{hp} ->set_value ($hp, $hp_m);
403 $GAUGES->{mana} ->set_value ($sp, $sp_m); 453 $GAUGES->{mana} ->set_value ($sp, $sp_m);
404 $GAUGES->{food} ->set_value ($fo, $fo_m); 454 $GAUGES->{food} ->set_value ($fo, $fo_m);
405 $GAUGES->{grace} ->set_value ($gr, $gr_m); 455 $GAUGES->{grace} ->set_value ($gr, $gr_m);
406 $GAUGES->{exp} ->set_text ("XP: " . ($stats->{11} || $stats->{28}) * 1 456 $GAUGES->{exp} ->set_text ("Exp: " . (formsep $stats->{Crossfire::Protocol::CS_STAT_EXP64})
407 ." LVL: " . $stats->{12} * 1); 457 . " (lvl " . ($stats->{Crossfire::Protocol::CS_STAT_LEVEL} * 1) . ")");
408 my $rng = $stats->{20}; 458 my $rng = $stats->{Crossfire::Protocol::CS_STAT_RANGE};
409 $rng =~ s/^Range: //; # thank you so much dear server 459 $rng =~ s/^Range: //; # thank you so much dear server
410 $GAUGES->{range} ->set_text ("Rng: " . $rng); 460 $GAUGES->{range} ->set_text ("Rng: " . $rng);
411# $GAUGES->{lvl} ->set_text ("LVL: " . $stats->{12}); 461 my $title = $stats->{Crossfire::Protocol::CS_STAT_TITLE};
462 $title =~ s/^Player: //;
412 $STATWIDS->{title} ->set_text ("Title: " . $stats->{21}); 463 $STATWIDS->{title} ->set_text ("Title: " . $title);
413 464
414 if (0) { # this code can vanish, just wanted to preserver it for a checkin
415 $STATWIDS->{st_str} ->set_text (sprintf "S%d", $stats->{5});
416 $STATWIDS->{st_dex} ->set_text (sprintf "D%d", $stats->{8});
417 $STATWIDS->{st_con} ->set_text (sprintf "Co%d", $stats->{9});
418 $STATWIDS->{st_int} ->set_text (sprintf "I%d", $stats->{6});
419 $STATWIDS->{st_wis} ->set_text (sprintf "W%d", $stats->{7});
420 $STATWIDS->{st_pow} ->set_text (sprintf "P%d", $stats->{22});
421 $STATWIDS->{st_cha} ->set_text (sprintf "Ch%d", $stats->{10});
422 $STATWIDS->{st_wc} ->set_text (sprintf "Wc%d", $stats->{13});
423 $STATWIDS->{st_ac} ->set_text (sprintf "Ac%d", $stats->{14});
424 $STATWIDS->{st_dam} ->set_text (sprintf "Dam%d", $stats->{15});
425 $STATWIDS->{st_arm} ->set_text (sprintf "Arm%d", $stats->{16});
426 $STATWIDS->{st_spd} ->set_text (sprintf "Sp%.1f", $stats->{17});
427 $STATWIDS->{st_wspd}->set_text (sprintf "WSp%.1f", $stats->{19});
428 } else {
429 $STATWIDS->{st_str} ->set_text (sprintf "%d", $stats->{5}); 465 $STATWIDS->{st_str} ->set_text (sprintf "%d", $stats->{5});
430 $STATWIDS->{st_dex} ->set_text (sprintf "%d", $stats->{8}); 466 $STATWIDS->{st_dex} ->set_text (sprintf "%d", $stats->{8});
431 $STATWIDS->{st_con} ->set_text (sprintf "%d", $stats->{9}); 467 $STATWIDS->{st_con} ->set_text (sprintf "%d", $stats->{9});
432 $STATWIDS->{st_int} ->set_text (sprintf "%d", $stats->{6}); 468 $STATWIDS->{st_int} ->set_text (sprintf "%d", $stats->{6});
433 $STATWIDS->{st_wis} ->set_text (sprintf "%d", $stats->{7}); 469 $STATWIDS->{st_wis} ->set_text (sprintf "%d", $stats->{7});
434 $STATWIDS->{st_pow} ->set_text (sprintf "%d", $stats->{22}); 470 $STATWIDS->{st_pow} ->set_text (sprintf "%d", $stats->{22});
435 $STATWIDS->{st_cha} ->set_text (sprintf "%d", $stats->{10}); 471 $STATWIDS->{st_cha} ->set_text (sprintf "%d", $stats->{10});
436 $STATWIDS->{st_wc} ->set_text (sprintf "%d", $stats->{13}); 472 $STATWIDS->{st_wc} ->set_text (sprintf "%d", $stats->{13});
437 $STATWIDS->{st_ac} ->set_text (sprintf "%d", $stats->{14}); 473 $STATWIDS->{st_ac} ->set_text (sprintf "%d", $stats->{14});
438 $STATWIDS->{st_dam} ->set_text (sprintf "%d", $stats->{15}); 474 $STATWIDS->{st_dam} ->set_text (sprintf "%d", $stats->{15});
439 $STATWIDS->{st_arm} ->set_text (sprintf "%d", $stats->{16}); 475 $STATWIDS->{st_arm} ->set_text (sprintf "%d", $stats->{16});
440 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{17}); 476 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{Crossfire::Protocol::CS_STAT_SPEED});
441 $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{19}); 477 $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{Crossfire::Protocol::CS_STAT_WEAP_SP});
442 }
443 478
444 my %tbl = ( 479 my %tbl = (
445 phys => 100, 480 phys => 100,
446 magic => 101, 481 magic => 101,
447 fire => 102, 482 fire => 102,
454 pois => 109, 489 pois => 109,
455 slow => 110, 490 slow => 110,
456 para => 111, 491 para => 111,
457 tund => 112, 492 tund => 112,
458 fear => 113, 493 fear => 113,
494 depl => 113,
459 deat => 115, 495 deat => 115,
460 holyw => 116, 496 holyw => 116,
461 blind => 117 497 blind => 117
462 ); 498 );
463 499
552 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port"); 588 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port");
553 589
554 { 590 {
555 $table->add (1, 2, my $vbox = new CFClient::UI::VBox); 591 $table->add (1, 2, my $vbox = new CFClient::UI::VBox);
556 592
557 $vbox->add (my $HOST = new CFClient::UI::Entry expand => 1, text => $CFG->{host}, connect_changed => sub { 593 $vbox->add (
594 my $HOST = new CFClient::UI::Entry
595 expand => 1,
596 text => $CFG->{host},
597 tooltip => "The hostname or ip address of the Crossfire(+) server to connect to",
598 connect_changed => sub {
599 my ($self, $value) = @_;
600 $CFG->{host} = $value;
601 }
602 );
603
604 $METASERVER = metaserver_dialog;
605
606 $vbox->add (new CFClient::UI::Flopper
607 expand => 1,
608 text => "Metaserver",
609 other => $METASERVER,
610 tooltip => "Show a list of avaible crossfire servers",
611 connect_open => sub {
612 update_metaserver $HOST;
613 }
614 );
615 }
616
617 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username");
618 $table->add (1, 4, new CFClient::UI::Entry
619 text => $CFG->{user},
620 tooltip => "The name of your character on the server",
621 connect_changed => sub {
558 my ($self, $value) = @_; 622 my ($self, $value) = @_;
559 $CFG->{host} = $value;
560 });
561
562 $METASERVER = metaserver_dialog;
563
564 $vbox->add (new CFClient::UI::Flopper expand => 1, text => "Metaserver", other => $METASERVER, connect_open => sub {
565 update_metaserver $HOST;
566 });
567 }
568
569 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username");
570 $table->add (1, 4, new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub {
571 my ($self, $value) = @_;
572 $CFG->{user} = $value; 623 $CFG->{user} = $value;
624 }
573 }); 625 );
574 626
575 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password"); 627 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password");
576 $table->add (1, 5, new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub { 628 $table->add (1, 5, new CFClient::UI::Entry
629 text => $CFG->{password},
630 hidden => 1,
631 tooltip => "The password for your character",
632 connect_changed => sub {
577 my ($self, $value) = @_; 633 my ($self, $value) = @_;
578 $CFG->{password} = $value; 634 $CFG->{password} = $value;
635 }
579 }); 636 );
580 637
581 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd"); 638 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd");
582 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub { 639 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry
640 text => $CFG->{say_command},
641 tooltip => "This is the command that will be used if you write a line in the message window entry. "
642 ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
643 ."But you could also set it to 'tell <playername>' to only chat with that user.",
644 connect_changed => sub {
583 my ($self, $value) = @_; 645 my ($self, $value) = @_;
584 $CFG->{say_command} = $value; 646 $CFG->{say_command} = $value;
647 }
585 }); 648 );
586 649
587 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); 650 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size");
588 $table->add (1, 7, new CFClient::UI::Slider 651 $table->add (1, 7, new CFClient::UI::Slider
589 req_w => 100, 652 req_w => 100,
590 range => [$CFG->{mapsize}, 10, 100 + 1, 1], 653 range => [$CFG->{mapsize}, 10, 100 + 1, 1],
654 tooltip => "This is the size of the portion of the map update the server sends you. "
655 ."If you set this to a high value you will be able to see further for example.",
591 connect_changed => sub { 656 connect_changed => sub {
592 my ($self, $value) = @_; 657 my ($self, $value) = @_;
593 658
594 $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 659 $CFG->{mapsize} = $self->{range}[0] = $value = int $value;
595 }, 660 },
611 user_h => int $::HEIGHT / 5, 676 user_h => int $::HEIGHT / 5,
612 child => (my $vbox = new CFClient::UI::VBox); 677 child => (my $vbox = new CFClient::UI::VBox);
613 678
614 $vbox->add ($LOGVIEW = new CFClient::UI::TextView 679 $vbox->add ($LOGVIEW = new CFClient::UI::TextView
615 expand => 1, 680 expand => 1,
681 font => $FONT_FIXED,
616 fontsize => $::CFG->{log_fontsize}, 682 fontsize => $::CFG->{log_fontsize},
617 ); 683 );
618 684
619 $vbox->add (my $input = new CFClient::UI::Entry 685 $vbox->add (my $input = new CFClient::UI::Entry
620 connect_focus_in => sub { 686 connect_focus_in => sub {
714 780
715 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); 781 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup);
716 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); 782 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup);
717 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); 783 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window);
718 784
785 $CFClient::UI::ROOT->add (make_gauge_window); # XXX: this has to be set before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D
786 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window);
787
719 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { 788 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub {
720 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 789 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
721 status "Configuration Saved"; 790 status "Configuration Saved";
722 }); 791 });
723 792
724 $CFClient::UI::ROOT->add (make_gauge_window); # XXX: this has to be set before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D
725 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window);
726
727 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup 793 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
728
729
730} 794}
731 795
732sub video_shutdown { 796sub video_shutdown {
733 $CFClient::UI::ROOT->{children} = []; 797 $CFClient::UI::ROOT->{children} = [];
734 undef $SDL_ACTIVE; 798 undef $SDL_ACTIVE;
1058 1122
1059 $chunk->play; 1123 $chunk->play;
1060# warn "sound $x,$y,$soundnum,$type\n";#d# 1124# warn "sound $x,$y,$soundnum,$type\n";#d#
1061} 1125}
1062 1126
1127my $LAST_QUERY; # server is stupid, stupid, stupid
1128
1063sub conn::query { 1129sub conn::query {
1064 my ($self, $flags, $prompt) = @_; 1130 my ($self, $flags, $prompt) = @_;
1065 1131
1066 #TODO, display dialog with relevant information 1132 $prompt = $LAST_QUERY unless length $prompt;
1067 warn "<<<<QUERY:$flags:$prompt>>>\n";#d# 1133 $LAST_QUERY = $prompt;
1134
1135 my $dialog = new CFClient::UI::FancyFrame
1136 title => "Query",
1137 child => my $vbox = new CFClient::UI::VBox;
1138
1139 $vbox->add (new CFClient::UI::Label
1140 max_w => $::WIDTH * 0.4,
1141 text => $prompt);
1142
1143 if ($flags & Crossfire::Protocol::CS_QUERY_YESNO) {
1144 $vbox->add (my $hbox = new CFClient::HBox);
1145 $hbox->add (new CFClient::Button
1146 text => "No",
1147 connect_activate => sub {
1148 $self->send ("reply n");
1149 $dialog->destroy;
1150 $MAPWIDGET->focus_in;
1151 }
1152 );
1153 $hbox->add (new CFClient::Button
1154 text => "Yes",
1155 connect_activate => sub {
1156 $self->send ("reply y");
1157 $dialog->destroy;
1158 $MAPWIDGET->focus_in;
1159 },
1160 );
1161
1162 $dialog->focus_in;
1163
1164 } elsif ($flags & Crossfire::Protocol::CS_QUERY_SINGLECHAR) {
1165 $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)";
1166 $vbox->add (my $entry = new CFClient::UI::Entry
1167 connect_changed => sub {
1168 $self->send ("reply $_[1]");
1169 $dialog->destroy;
1170 $MAPWIDGET->focus_in;
1171 },
1172 );
1173
1174 $entry->focus_in;
1175
1176 } else {
1177 $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)";
1178
1179 $vbox->add (my $entry = new CFClient::UI::Entry
1180 $flags & Crossfire::Protocol::CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (),
1181 connect_activate => sub {
1182 $self->send ("reply $_[1]");
1183 $dialog->destroy;
1184 $MAPWIDGET->focus_in;
1185 },
1186 );
1187
1188 $entry->focus_in;
1189 }
1190
1191 $dialog->show;
1068} 1192}
1069 1193
1070sub conn::drawinfo { 1194sub conn::drawinfo {
1071 my ($self, $color, $text) = @_; 1195 my ($self, $color, $text) = @_;
1072 1196
1090} 1214}
1091 1215
1092sub conn::spell_add { 1216sub conn::spell_add {
1093 my ($self, $spell) = @_; 1217 my ($self, $spell) = @_;
1094 1218
1219 # TODO
1220 # create a widget dynamically, using spell face (CF::Protocol downloads them)
1095 $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message}, sub { 1221 $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message});
1096 });
1097 $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message}, sub { 1222 $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message});
1098 });
1099} 1223}
1100 1224
1101sub conn::spell_delete { 1225sub conn::spell_delete {
1102 my ($self, $spell) = @_; 1226 my ($self, $spell) = @_;
1103} 1227}
1104 1228
1105sub conn::addme_success { 1229sub conn::addme_success {
1106 my ($self) = @_; 1230 my ($self) = @_;
1107 1231
1108 for my $skill (values %{$self->{skill_info}}) { 1232 for my $skill (values %{$self->{skill_info}}) {
1109 $MAPWIDGET->add_command ("ready_skill $skill", "", sub { 1233 $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'");
1110 }); 1234 $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'");
1111 $MAPWIDGET->add_command ("use_skill $skill", "", sub {
1112 });
1113 } 1235 }
1236}
1237
1238sub conn::container_add {
1239 my ($self, $id, $items) = @_;
1240
1241 # 0 floor
1242 # $self-<{player}{tag} => player inv
1243 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}};
1244}
1245
1246sub conn::container_clear {
1247 my ($self, $id) = @_;
1248# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
1114} 1249}
1115 1250
1116%SDL_CB = ( 1251%SDL_CB = (
1117 CFClient::SDL_QUIT => sub { 1252 CFClient::SDL_QUIT => sub {
1118 Event::unloop -1; 1253 Event::unloop -1;
1153 sdl_mode => 0, 1288 sdl_mode => 0,
1154 width => 640, 1289 width => 640,
1155 height => 480, 1290 height => 480,
1156 fullscreen => 0, 1291 fullscreen => 0,
1157 fast => 0, 1292 fast => 0,
1293 map_scale => 0.5,
1158 fow_enable => 1, 1294 fow_enable => 1,
1159 fow_intensity => 0.45, 1295 fow_intensity => 0.45,
1160 fow_smooth => 0, 1296 fow_smooth => 0,
1161 gui_fontsize => 1, 1297 gui_fontsize => 1,
1162 log_fontsize => 1, 1298 log_fontsize => 1,
1184@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; 1320@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
1185 1321
1186$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; 1322$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
1187 1323
1188{ 1324{
1189 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); 1325 my @fonts = map CFClient::find_rcfile "fonts/$_", qw(
1326 DejaVuSans.ttf
1327 DejaVuSansMono.ttf
1328 DejaVuSans-Bold.ttf
1329 DejaVuSansMono-Bold.ttf
1330 DejaVuSans-Oblique.ttf
1331 DejaVuSansMono-Oblique.ttf
1332 DejaVuSans-BoldOblique.ttf
1333 DejaVuSansMono-BoldOblique.ttf
1334 );
1190 1335
1191 CFClient::add_font $_ for @fonts; 1336 CFClient::add_font $_ for @fonts;
1192 CFClient::set_font $fonts[0]; 1337
1338 $FONT_PROP = new_from_file CFClient::Font $fonts[0];
1339 $FONT_FIXED = new_from_file CFClient::Font $fonts[1];
1340
1341 $FONT_PROP->make_default;
1193} 1342}
1194 1343
1195video_init; 1344video_init;
1196audio_init; 1345audio_init;
1197 1346

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines