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.153 by root, Thu Apr 20 09:13:32 2006 UTC vs.
Revision 1.168 by root, Sun Apr 23 21:47:32 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;
46our $CONSOLE; 49our $CONSOLE;
47our $METASERVER; 50our $METASERVER;
48 51
49our $GAUGES; 52our $GAUGES;
53our $STATWIDS;
50 54
51our $SDL_ACTIVE; 55our $SDL_ACTIVE;
52our %SDL_CB; 56our %SDL_CB;
53 57
54our $SDL_MIXER; 58our $SDL_MIXER;
116 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; 120 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value;
117 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); 121 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]});
118 }); 122 });
119 $mode_slider->emit (changed => $mode_slider->{range}[0]); 123 $mode_slider->emit (changed => $mode_slider->{range}[0]);
120 124
125 my $row = 1;
126
121 $table->add (0, 1, 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");
122 $table->add (1, 1, 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 {
123 my ($self, $value) = @_; 132 my ($self, $value) = @_;
124 $CFG->{fullscreen} = $value; 133 $CFG->{fullscreen} = $value;
134 }
125 }); 135 );
126 136
127 $table->add (0, 2, 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");
128 $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub { 138 $table->add (1, $row++, new CFClient::UI::CheckBox
139 state => $CFG->{fast},
140 tooltip => "Lower the visual quality considerably to speed up rendering.",
141 connect_changed => sub {
129 my ($self, $value) = @_; 142 my ($self, $value) = @_;
130 $CFG->{fast} = $value; 143 $CFG->{fast} = $value;
144 }
131 }); 145 );
132 146
133 $table->add (0, 3, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War"); 147 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War");
134 $table->add (1, 3, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub { 148 $table->add (1, $row++, new CFClient::UI::CheckBox
149 state => $CFG->{fow_enable},
150 tooltip => "Fog-of-War marks areas that cannot be seen by the player",
151 connect_changed => sub {
135 my ($self, $value) = @_; 152 my ($self, $value) = @_;
136 $CFG->{fow_enable} = $value; 153 $CFG->{fow_enable} = $value;
154 }
137 }); 155 );
138 156
139 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Intensity"); 157 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Intensity");
140 $table->add (1, 4, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub { 158 $table->add (1, $row++, new CFClient::UI::Slider
159 range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001],
160 tooltip => "The higher the intensity, the lighter the Fog-of-War color",
161 connect_changed => sub {
141 my ($self, $value) = @_; 162 my ($self, $value) = @_;
142 $CFG->{fow_intensity} = $value; 163 $CFG->{fow_intensity} = $value;
164 }
143 }); 165 );
144 166
145 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Smooth"); 167 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Smooth");
146 $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { 168 $table->add (1, $row++, new CFClient::UI::CheckBox
169 state => $CFG->{fow_smooth},
170 tooltip => "Smooth the Fog-of-War a bit to make it more realistic",
171 connect_changed => sub {
147 my ($self, $value) = @_; 172 my ($self, $value) = @_;
148 $CFG->{fow_smooth} = $value; 173 $CFG->{fow_smooth} = $value;
149 status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2; 174 status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2;
175 }
150 }); 176 );
151 177
152 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize"); 178 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize");
153 $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{gui_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub { 179 $table->add (1, $row++, new CFClient::UI::Slider
180 range => [$CFG->{gui_fontsize}, 0.5, 2, 0.1],
181 tooltip => "The font size used by most GUI elements",
182 connect_changed => sub {
154 $CFG->{gui_fontsize} = 0.1 * int $_[1] * 10; 183 $CFG->{gui_fontsize} = 0.1 * int $_[1] * 10;
155# $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; 184# $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
185 }
156 }); 186 );
157 187
158 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Server Log Fontsize"); 188 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Server Log Fontsize");
159 $table->add (1, 7, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub { 189 $table->add (1, $row++, new CFClient::UI::Slider
190 range => [$CFG->{log_fontsize}, 0.5, 2, 0.1],
191 tooltip => "The font size used by the server log window only",
192 connect_changed => sub {
160 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10); 193 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10);
194 }
161 }); 195 );
162 196
163 $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { 197 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Stats Fontsize");
198
199 $table->add (1, $row++, new CFClient::UI::Slider
200 range => [$CFG->{stat_fontsize}, 0.5, 2, 0.1],
201 tooltip => "The font size used by the statistics window only",
202 connect_changed => sub {
203 $CFG->{stat_fontsize} = 0.1 * int $_[1] * 10;
204 &set_stats_window_fontsize;
205 }
206 );
207
208 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge size");
209 $table->add (1, $row++, new CFClient::UI::Slider
210 range => [$CFG->{gauge_size}, 0.2, 0.8, 0.02],
211 tooltip => "Adjust the size of the stats gauges at the bottom right",
212 connect_changed => sub {
213 $CFG->{gauge_size} = $_[1];
214 my $h = int $HEIGHT * $CFG->{gauge_size};
215 $GAUGES->{win}->set_size ($WIDTH, $h);
216 $GAUGES->{win}->move (0, $HEIGHT - $h);
217 }
218 );
219
220 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize");
221 $table->add (1, $row++, new CFClient::UI::Slider
222 range => [$CFG->{gauge_fontsize}, 0.5, 2.0, 0.1],
223 tooltip => "Adjusts the fontsize of the gauges at the bottom right",
224 connect_changed => sub {
225 $CFG->{gauge_fontsize} = 0.1 * int $_[1] * 10;
226 &set_gauge_window_fontsize;
227 #$GAUGES->{win}->check_size;
228 #$GAUGES->{win}->update;
229 }
230 );
231
232 $table->add (1, $row++, new CFClient::UI::Button
233 expand => 1, align => 0, text => "Apply",
234 tooltip => "Apply the video settings",
235 connect_activate => sub {
164 video_shutdown (); 236 video_shutdown ();
165 video_init (); 237 video_init ();
238 }
166 }); 239 );
167 240
168 $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Audio Enable"); 241 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Audio Enable");
169 $table->add (1, 9, new CFClient::UI::CheckBox state => $CFG->{audio_enable}, connect_changed => sub { 242 $table->add (1, $row++, new CFClient::UI::CheckBox
243 state => $CFG->{audio_enable},
244 tooltip => "If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.",
245 connect_changed => sub {
170 $CFG->{audio_enable} = $_[1]; 246 $CFG->{audio_enable} = $_[1];
247 }
171 }); 248 );
172# $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Effects Volume"); 249# $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Effects Volume");
173# $table->add (1, 8, new CFClient::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], connect_changed => sub { 250# $table->add (1, 8, new CFClient::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], connect_changed => sub {
174# $CFG->{effects_volume} = $_[1]; 251# $CFG->{effects_volume} = $_[1];
175# }); 252# });
176 $table->add (0, 10, new CFClient::UI::Label valign => 0, align => 1, text => "Background Music"); 253 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Background Music");
177 $table->add (1, 10, my $hbox = new CFClient::UI::HBox); 254 $table->add (1, $row++, my $hbox = new CFClient::UI::HBox);
178 $hbox->add (new CFClient::UI::CheckBox expand => 1, state => $CFG->{bgm_enable}, connect_changed => sub { 255 $hbox->add (new CFClient::UI::CheckBox
256 expand => 1, state => $CFG->{bgm_enable},
257 tooltip => "Enable background music playing",
258 connect_changed => sub {
179 $CFG->{bgm_enable} = $_[1]; 259 $CFG->{bgm_enable} = $_[1];
260 }
180 }); 261 );
181 $hbox->add (new CFClient::UI::Slider expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0.1], connect_changed => sub { 262 $hbox->add (new CFClient::UI::Slider
263 expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0.1],
264 tooltip => "The volume of the background music",
265 connect_changed => sub {
182 $CFG->{bgm_volume} = $_[1]; 266 $CFG->{bgm_volume} = $_[1];
183 CFClient::MixMusic::volume $_[1] * 128; 267 CFClient::MixMusic::volume $_[1] * 128;
268 }
184 }); 269 );
185 270
186 $table->add (1, 11, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { 271 $table->add (1, $row++, new CFClient::UI::Button
272 expand => 1, align => 0, text => "Apply",
273 tooltip => "Apply the audio settings",
274 connect_activate => sub {
187 audio_shutdown (); 275 audio_shutdown ();
188 audio_init (); 276 audio_init ();
277 }
189 }); 278 );
190 279
191 $dialog 280 $dialog
281}
282
283sub set_stats_window_fontsize {
284 for (values %{$STATWIDS}) {
285 $_->set_fontsize ($::CFG->{stat_fontsize});
286 }
287}
288
289sub set_gauge_window_fontsize {
290 for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) {
291 $_->set_fontsize ($::CFG->{gauge_fontsize});
292 }
293}
294
295sub make_gauge_window {
296 my $gh = int ($HEIGHT * $CFG->{gauge_size});
297# my $gw = int ($WIDTH * $CFG->{gauge_w_size});
298
299 my $win = new CFClient::UI::Frame (
300 y => $HEIGHT - $gh, x => 0, req_w => $WIDTH, req_h => $gh
301 );
302 $win->add (my $vb = new CFClient::UI::VBox);
303
304 $vb->add (my $hbg = new CFClient::UI::HBox expand => 1);
305
306
307 $hbg->add (new CFClient::UI::Empty expand => 1);
308 $hbg->add (my $hb = new CFClient::UI::HBox);
309 $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp', tooltip => "Health points");
310 $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana', tooltip => "Spellpoints");
311 $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace', tooltip => "Grace");
312 $hb->add (my $fg = new CFClient::UI::Gauge type => 'food', tooltip => "Food");
313
314 $vb->add (my $exp = new CFClient::UI::Label valign => 0, align => 1, text => "XP: 0 LVL: 0");
315 $vb->add (my $rng = new CFClient::UI::Label valign => 0, align => 1, text => "Rng:");
316
317 $GAUGES = {
318 exp => $exp, win => $win, range => $rng,
319 food => $fg, mana => $mg, hp => $hg, grace => $gg
320 };
321 $win
322}
323
324sub make_stats_window {
325 my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH * 2/5, y => 0, title => "Stats");
326
327 $tgw->add (my $vb = new CFClient::UI::VBox);
328 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1);
329 $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1);
330
331 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
332
333 $hb->add (my $tbl = new CFClient::UI::Table expand => 1);
334
335 $tbl->add (0, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
336 $tbl->add (0, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
337 $tbl->add (0, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
338 $tbl->add (0, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
339 $tbl->add (0, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
340 $tbl->add (0, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
341 $tbl->add (0, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => +1, template => "30");
342
343 $tbl->add (1, 0, $STATWIDS->{st_str_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Str");
344 $tbl->add (1, 1, $STATWIDS->{st_dex_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Dex");
345 $tbl->add (1, 2, $STATWIDS->{st_con_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Con");
346 $tbl->add (1, 3, $STATWIDS->{st_int_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Int");
347 $tbl->add (1, 4, $STATWIDS->{st_wis_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Wis");
348 $tbl->add (1, 5, $STATWIDS->{st_pow_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Pow");
349 $tbl->add (1, 6, $STATWIDS->{st_cha_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Cha");
350
351 $tbl->add (2, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => +1, template => "-120");
352 $tbl->add (2, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => +1, template => "-120");
353 $tbl->add (2, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => +1, template => "120");
354 $tbl->add (2, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => +1, template => "120");
355 $tbl->add (2, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => +1, template => "10.54");
356 $tbl->add (2, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => +1, template => "9");
357
358 $tbl->add (3, 0, $STATWIDS->{st_wc_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Wc");
359 $tbl->add (3, 1, $STATWIDS->{st_ac_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Ac");
360 $tbl->add (3, 2, $STATWIDS->{st_dam_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Dam");
361 $tbl->add (3, 3, $STATWIDS->{st_arm_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Arm");
362 $tbl->add (3, 4, $STATWIDS->{st_spd_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Sp");
363 $tbl->add (3, 5, $STATWIDS->{st_wspd_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "WSp");
364
365 $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1);
366
367 my $row = 0;
368 my $col = 0;
369
370 my %resist_names = (
371 slow => "Slow",
372 holyw => "Holy Word",
373 conf => "Confusion",
374 fire => "Fire",
375 depl => "Depletion",
376 magic => "Magic",
377 drain => "Draining",
378 acid => "Acid",
379 pois => "Poison",
380 para => "Paralysation",
381 deat => "Death",
382 phys => "Physical",
383 blind => "Blind",
384 fear => "Fear",
385 tund => "Turn undead",
386 elec => "Electricity",
387 cold => "Cold",
388 ghit => "Ghost hit",
389 );
390 for (qw/slow holyw conf fire depl magic
391 drain acid pois para deat phys
392 blind fear tund elec cold ghit/)
393 {
394 $tbl2->add ($col, $row,
395 $STATWIDS->{"res_$_"} =
396 new CFClient::UI::Label
397 template => "-100%",
398 align => +1,
399 valign => 0,
400 tooltip => $resist_names{$_}
401 );
402 $tbl2->add ($col + 1, $row, new CFClient::UI::Image
403 can_hover => 1,
404 can_events => 1,
405 image => "ui/resist/resist_$_.png",
406 tooltip => $resist_names{$_}
407 );
408
409 $row++;
410 if ($row % 6 == 0) {
411 $col += 2;
412 $row = 0;
413 }
414 }
415
416 &set_stats_window_fontsize;
417 update_stats_window ({});
418
419 $tgw
420}
421
422sub update_stats_window {
423 my ($stats) = @_;
424
425 # i love text protocols!!!
426 my $hp = $stats->{1} * 1;
427 my $hp_m = $stats->{2} * 1;
428 my $sp = $stats->{3} * 1;
429 my $sp_m = $stats->{4} * 1;
430 my $fo = $stats->{18} * 1;
431 my $fo_m = 999;
432 my $gr = $stats->{23} * 1;
433 my $gr_m = $stats->{24} * 1;
434
435 $GAUGES->{hp} ->set_value ($hp, $hp_m);
436 $GAUGES->{mana} ->set_value ($sp, $sp_m);
437 $GAUGES->{food} ->set_value ($fo, $fo_m);
438 $GAUGES->{grace} ->set_value ($gr, $gr_m);
439 $GAUGES->{exp} ->set_text ("XP: " . ($stats->{11} || $stats->{28}) * 1
440 ." LVL: " . $stats->{12} * 1);
441 my $rng = $stats->{20};
442 $rng =~ s/^Range: //; # thank you so much dear server
443 $GAUGES->{range} ->set_text ("Rng: " . $rng);
444 my $title = $stats->{21};
445 $title =~ s/^Player: //;
446 $STATWIDS->{title} ->set_text ("Title: " . $title);
447
448 $STATWIDS->{st_str} ->set_text (sprintf "%d", $stats->{5});
449 $STATWIDS->{st_dex} ->set_text (sprintf "%d", $stats->{8});
450 $STATWIDS->{st_con} ->set_text (sprintf "%d", $stats->{9});
451 $STATWIDS->{st_int} ->set_text (sprintf "%d", $stats->{6});
452 $STATWIDS->{st_wis} ->set_text (sprintf "%d", $stats->{7});
453 $STATWIDS->{st_pow} ->set_text (sprintf "%d", $stats->{22});
454 $STATWIDS->{st_cha} ->set_text (sprintf "%d", $stats->{10});
455 $STATWIDS->{st_wc} ->set_text (sprintf "%d", $stats->{13});
456 $STATWIDS->{st_ac} ->set_text (sprintf "%d", $stats->{14});
457 $STATWIDS->{st_dam} ->set_text (sprintf "%d", $stats->{15});
458 $STATWIDS->{st_arm} ->set_text (sprintf "%d", $stats->{16});
459 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{17});
460 $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{19});
461
462 my %tbl = (
463 phys => 100,
464 magic => 101,
465 fire => 102,
466 elec => 103,
467 cold => 104,
468 conf => 105,
469 acid => 106,
470 drain => 107,
471 ghit => 108,
472 pois => 109,
473 slow => 110,
474 para => 111,
475 tund => 112,
476 fear => 113,
477 depl => 113,
478 deat => 115,
479 holyw => 116,
480 blind => 117
481 );
482
483 for (keys %tbl) {
484 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}});
485 }
486
192} 487}
193 488
194sub metaserver_dialog { 489sub metaserver_dialog {
195 my $dialog = new CFClient::UI::FancyFrame 490 my $dialog = new CFClient::UI::FancyFrame
196 title => "Metaserver", 491 title => "Metaserver",
276 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port"); 571 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port");
277 572
278 { 573 {
279 $table->add (1, 2, my $vbox = new CFClient::UI::VBox); 574 $table->add (1, 2, my $vbox = new CFClient::UI::VBox);
280 575
281 $vbox->add (my $HOST = new CFClient::UI::Entry expand => 1, text => $CFG->{host}, connect_changed => sub { 576 $vbox->add (
577 my $HOST = new CFClient::UI::Entry
578 expand => 1,
579 text => $CFG->{host},
580 tooltip => "The hostname or ip address of the Crossfire(+) server to connect to",
581 connect_changed => sub {
582 my ($self, $value) = @_;
583 $CFG->{host} = $value;
584 }
585 );
586
587 $METASERVER = metaserver_dialog;
588
589 $vbox->add (new CFClient::UI::Flopper
590 expand => 1,
591 text => "Metaserver",
592 other => $METASERVER,
593 tooltip => "Show a list of avaible crossfire servers",
594 connect_open => sub {
595 update_metaserver $HOST;
596 }
597 );
598 }
599
600 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username");
601 $table->add (1, 4, new CFClient::UI::Entry
602 text => $CFG->{user},
603 tooltip => "The name of your character on the server",
604 connect_changed => sub {
282 my ($self, $value) = @_; 605 my ($self, $value) = @_;
283 $CFG->{host} = $value;
284 });
285
286 $METASERVER = metaserver_dialog;
287
288 $vbox->add (new CFClient::UI::Flopper expand => 1, text => "Metaserver", other => $METASERVER, connect_open => sub {
289 update_metaserver $HOST;
290 });
291 }
292
293 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username");
294 $table->add (1, 4, new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub {
295 my ($self, $value) = @_;
296 $CFG->{user} = $value; 606 $CFG->{user} = $value;
607 }
297 }); 608 );
298 609
299 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password"); 610 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password");
300 $table->add (1, 5, new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub { 611 $table->add (1, 5, new CFClient::UI::Entry
612 text => $CFG->{password},
613 hidden => 1,
614 tooltip => "The password for your character",
615 connect_changed => sub {
301 my ($self, $value) = @_; 616 my ($self, $value) = @_;
302 $CFG->{password} = $value; 617 $CFG->{password} = $value;
618 }
303 }); 619 );
304 620
305 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd"); 621 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd");
306 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub { 622 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry
623 text => $CFG->{say_command},
624 tooltip => "This is the command that will be used if you write a line in the message window entry. "
625 ."Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
626 ."But you could also set it to 'tell <playername>' to only chat with that user.",
627 connect_changed => sub {
307 my ($self, $value) = @_; 628 my ($self, $value) = @_;
308 $CFG->{say_command} = $value; 629 $CFG->{say_command} = $value;
630 }
309 }); 631 );
310 632
311 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); 633 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size");
312 $table->add (1, 7, new CFClient::UI::Slider 634 $table->add (1, 7, new CFClient::UI::Slider
313 req_w => 100, 635 req_w => 100,
314 range => [$CFG->{mapsize}, 10, 100 + 1, 1], 636 range => [$CFG->{mapsize}, 10, 100 + 1, 1],
637 tooltip => "This is the size of the portion of the map update the server sends you. "
638 ."If you set this to a high value you will be able to see further for example.",
315 connect_changed => sub { 639 connect_changed => sub {
316 my ($self, $value) = @_; 640 my ($self, $value) = @_;
317 641
318 $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 642 $CFG->{mapsize} = $self->{range}[0] = $value = int $value;
319 }, 643 },
335 user_h => int $::HEIGHT / 5, 659 user_h => int $::HEIGHT / 5,
336 child => (my $vbox = new CFClient::UI::VBox); 660 child => (my $vbox = new CFClient::UI::VBox);
337 661
338 $vbox->add ($LOGVIEW = new CFClient::UI::TextView 662 $vbox->add ($LOGVIEW = new CFClient::UI::TextView
339 expand => 1, 663 expand => 1,
664 font => $FONT_FIXED,
340 fontsize => $::CFG->{log_fontsize}, 665 fontsize => $::CFG->{log_fontsize},
341 ); 666 );
342 667
343 $vbox->add (my $input = new CFClient::UI::Entry 668 $vbox->add (my $input = new CFClient::UI::Entry
344 connect_focus_in => sub { 669 connect_focus_in => sub {
438 763
439 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); 764 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup);
440 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); 765 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup);
441 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); 766 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window);
442 767
768 $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
769 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window);
770
443 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { 771 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub {
444 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 772 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
445 status "Configuration Saved"; 773 status "Configuration Saved";
446 }); 774 });
447 775
448 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup 776 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
449
450 my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH - 300, y => 0, title => "Stats");
451 $tgw->add (my $hbox = new CFClient::UI::HBox ());
452
453 $hbox->add (my $hg = new CFClient::UI::Gauge (type => 'hp'));
454 $hbox->add (my $mg = new CFClient::UI::Gauge (type => 'mana'));
455 $hbox->add (my $gg = new CFClient::UI::Gauge (type => 'grace'));
456 $hbox->add (my $fg = new CFClient::UI::Gauge (type => 'food'));
457
458 $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg };
459 $CFClient::UI::ROOT->add ($tgw);
460} 777}
461 778
462sub video_shutdown { 779sub video_shutdown {
463 $CFClient::UI::ROOT->{children} = []; 780 $CFClient::UI::ROOT->{children} = [];
464 undef $SDL_ACTIVE; 781 undef $SDL_ACTIVE;
478} 795}
479 796
480sub audio_init { 797sub audio_init {
481 if ($CFG->{audio_enable}) { 798 if ($CFG->{audio_enable}) {
482 if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { 799 if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") {
483
484 $SDL_MIXER = !CFClient::Mix_OpenAudio; 800 $SDL_MIXER = !CFClient::Mix_OpenAudio;
485 CFClient::Mix_AllocateChannels 8; 801 CFClient::Mix_AllocateChannels 8;
486 CFClient::MixMusic::volume $CFG->{bgm_volume} * 128; 802 CFClient::MixMusic::volume $CFG->{bgm_volume} * 128;
487 803
488 audio_music_finished; 804 audio_music_finished;
571@conn::ISA = Crossfire::Protocol::; 887@conn::ISA = Crossfire::Protocol::;
572 888
573sub conn::stats_update { 889sub conn::stats_update {
574 my ($self, $stats) = @_; 890 my ($self, $stats) = @_;
575 891
576 # i love text protocols!!! 892 update_stats_window ($stats);
577 # FIXME: the stats are somehow weird
578 my $hp = $stats->{1};
579 my $hp_m = $stats->{2};
580 my $sp = $stats->{3};
581 my $sp_m = $stats->{4};
582 my $fo = $stats->{18};
583 my $fo_m = 999;
584 my $gr = $stats->{23};
585 my $gr_m = $stats->{24};
586
587 #d# warn "DATA $hp $hp_m $sp $sp_m $fo $fo_m $gr $gr_m\n";
588 $GAUGES->{hp} ->set_value ($hp, $hp_m);
589 $GAUGES->{mana} ->set_value ($sp, $sp_m);
590 $GAUGES->{food} ->set_value ($fo, $fo_m);
591 $GAUGES->{grace}->set_value ($gr, $gr_m);
592} 893}
593 894
594sub conn::user_send { 895sub conn::user_send {
595 my ($self, $command) = @_; 896 my ($self, $command) = @_;
596 897
726 1027
727 $x += $ox; 1028 $x += $ox;
728 $y += $oy; 1029 $y += $oy;
729 1030
730 $self->{map_info} = [$hash, $x, $y, $w, $h]; 1031 $self->{map_info} = [$hash, $x, $y, $w, $h];
1032
1033 my $map = $self->{map_info}[0];
1034 $map =~ s/^.*?\/([^\/]+)$/\1/;
1035 $STATWIDS->{map}->set_text ("Map: " . $map);
731 1036
732 $self->load_map ($hash, $x, $y); 1037 $self->load_map ($hash, $x, $y);
733} 1038}
734 1039
735sub conn::face_find { 1040sub conn::face_find {
899 fast => 0, 1204 fast => 0,
900 fow_enable => 1, 1205 fow_enable => 1,
901 fow_intensity => 0.45, 1206 fow_intensity => 0.45,
902 fow_smooth => 0, 1207 fow_smooth => 0,
903 gui_fontsize => 1, 1208 gui_fontsize => 1,
904 log_fontsize => 14, 1209 log_fontsize => 1,
1210 gauge_fontsize => 1,
1211 gauge_size => 0.35,
1212 stat_fontsize => 1,
905 mapsize => 100, 1213 mapsize => 100,
906 host => "crossfire.schmorp.de", 1214 host => "crossfire.schmorp.de",
907 say_command => 'say', 1215 say_command => 'say',
908 audio_enable => 1, 1216 audio_enable => 1,
909 bgm_enable => 1, 1217 bgm_enable => 1,
923@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; 1231@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
924 1232
925$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; 1233$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
926 1234
927{ 1235{
928 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); 1236 my @fonts = map CFClient::find_rcfile "fonts/$_", qw(
1237 DejaVuSans.ttf
1238 DejaVuSansMono.ttf
1239 DejaVuSans-Bold.ttf
1240 DejaVuSansMono-Bold.ttf
1241 DejaVuSans-Oblique.ttf
1242 DejaVuSansMono-Oblique.ttf
1243 DejaVuSans-BoldOblique.ttf
1244 DejaVuSansMono-BoldOblique.ttf
1245 );
929 1246
930 CFClient::add_font $_ for @fonts; 1247 CFClient::add_font $_ for @fonts;
931 CFClient::set_font $fonts[0]; 1248
1249 $FONT_PROP = new_from_file CFClient::Font $fonts[0];
1250 $FONT_FIXED = new_from_file CFClient::Font $fonts[1];
1251
1252 $FONT_PROP->make_default;
932} 1253}
933 1254
934video_init; 1255video_init;
935audio_init; 1256audio_init;
936 1257

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines