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.152 by root, Thu Apr 20 08:11:57 2006 UTC vs.
Revision 1.165 by elmex, Sun Apr 23 01:46:20 2006 UTC

45our $LOGVIEW; 45our $LOGVIEW;
46our $CONSOLE; 46our $CONSOLE;
47our $METASERVER; 47our $METASERVER;
48 48
49our $GAUGES; 49our $GAUGES;
50our $STATWIDS;
50 51
51our $SDL_ACTIVE; 52our $SDL_ACTIVE;
52our %SDL_CB; 53our %SDL_CB;
53 54
54our $SDL_MIXER; 55our $SDL_MIXER;
116 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; 117 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value;
117 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); 118 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]});
118 }); 119 });
119 $mode_slider->emit (changed => $mode_slider->{range}[0]); 120 $mode_slider->emit (changed => $mode_slider->{range}[0]);
120 121
122 my $row = 1;
123
121 $table->add (0, 1, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen"); 124 $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 { 125 $table->add (1, $row++, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub {
123 my ($self, $value) = @_; 126 my ($self, $value) = @_;
124 $CFG->{fullscreen} = $value; 127 $CFG->{fullscreen} = $value;
125 }); 128 });
126 129
127 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); 130 $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 { 131 $table->add (1, $row++, new CFClient::UI::CheckBox
132 state => $CFG->{fast},
133 tooltip => "Lower the visual quality considerably to speed up rendering.",
134 connect_changed => sub {
129 my ($self, $value) = @_; 135 my ($self, $value) = @_;
130 $CFG->{fast} = $value; 136 $CFG->{fast} = $value;
137 }
131 }); 138 );
132 139
133 $table->add (0, 3, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War"); 140 $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 { 141 $table->add (1, $row++, new CFClient::UI::CheckBox
142 state => $CFG->{fow_enable},
143 tooltip => "Fog-of-War marks areas that cannot be seen by the player",
144 connect_changed => sub {
135 my ($self, $value) = @_; 145 my ($self, $value) = @_;
136 $CFG->{fow_enable} = $value; 146 $CFG->{fow_enable} = $value;
147 }
137 }); 148 );
138 149
139 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Intensity"); 150 $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 { 151 $table->add (1, $row++, new CFClient::UI::Slider
152 range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001],
153 tooltip => "The higher the intensity, the lighter the Fog-of-War color",
154 connect_changed => sub {
141 my ($self, $value) = @_; 155 my ($self, $value) = @_;
142 $CFG->{fow_intensity} = $value; 156 $CFG->{fow_intensity} = $value;
157 }
143 }); 158 );
144 159
145 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Smooth"); 160 $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 { 161 $table->add (1, $row++, new CFClient::UI::CheckBox
162 state => $CFG->{fow_smooth},
163 tooltip => "Smooth the Fog-of-War a bit to make it more realistic",
164 connect_changed => sub {
147 my ($self, $value) = @_; 165 my ($self, $value) = @_;
148 $CFG->{fow_smooth} = $value; 166 $CFG->{fow_smooth} = $value;
149 status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2; 167 status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2;
168 }
150 }); 169 );
151 170
152 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize"); 171 $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 { 172 $table->add (1, $row++, new CFClient::UI::Slider
173 range => [$CFG->{gui_fontsize}, 0.5, 2, 0.1],
174 tooltip => "The font size used by most GUI elements",
175 connect_changed => sub {
154 $CFG->{gui_fontsize} = 0.1 * int $_[1] * 10; 176 $CFG->{gui_fontsize} = 0.1 * int $_[1] * 10;
155# $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; 177# $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
178 }
156 }); 179 );
157 180
158 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Server Log Fontsize"); 181 $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 { 182 $table->add (1, $row++, new CFClient::UI::Slider
183 range => [$CFG->{log_fontsize}, 0.5, 2, 0.1],
184 tooltip => "The font size used by the server log window only",
185 connect_changed => sub {
160 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10); 186 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10);
187 }
161 }); 188 );
162 189
163 $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { 190 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Stats Fontsize");
191
192 $table->add (1, $row++, new CFClient::UI::Slider
193 range => [$CFG->{stat_fontsize}, 0.5, 2, 0.1],
194 tooltip => "The font size used by the statistics window only",
195 connect_changed => sub {
196 $CFG->{stat_fontsize} = 0.1 * int $_[1] * 10;
197 &set_stats_window_fontsize;
198 }
199 );
200
201 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge size");
202 $table->add (1, $row++, new CFClient::UI::Slider
203 range => [$CFG->{gauge_size}, 0.2, 0.8, 0.02],
204 tooltip => "Adjust the size of the stats gauges at the bottom right",
205 connect_changed => sub {
206 $CFG->{gauge_size} = $_[1];
207 my $h = int $HEIGHT * $CFG->{gauge_size};
208 $GAUGES->{win}->set_size ($WIDTH, $h);
209 $GAUGES->{win}->move (0, $HEIGHT - $h);
210 }
211 );
212
213 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize");
214 $table->add (1, $row++, new CFClient::UI::Slider
215 range => [$CFG->{gauge_fontsize}, 0.5, 2.0, 0.1],
216 connect_changed => sub {
217 $CFG->{gauge_fontsize} = 0.1 * int $_[1] * 10;
218 &set_gauge_window_fontsize;
219 #$GAUGES->{win}->check_size;
220 #$GAUGES->{win}->update;
221 }
222 );
223
224 $table->add (1, $row++, new CFClient::UI::Button
225 expand => 1, align => 0, text => "Apply",
226 tooltip => "Apply the video settings (unless they are auto-apply)",
227 connect_activate => sub {
164 video_shutdown (); 228 video_shutdown ();
165 video_init (); 229 video_init ();
230 }
166 }); 231 );
167 232
168 $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Audio Enable"); 233 $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 { 234 $table->add (1, $row++, new CFClient::UI::CheckBox
235 state => $CFG->{audio_enable},
236 tooltip => "If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.",
237 connect_changed => sub {
170 $CFG->{audio_enable} = $_[1]; 238 $CFG->{audio_enable} = $_[1];
239 }
171 }); 240 );
172# $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Effects Volume"); 241# $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 { 242# $table->add (1, 8, new CFClient::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], connect_changed => sub {
174# $CFG->{effects_volume} = $_[1]; 243# $CFG->{effects_volume} = $_[1];
175# }); 244# });
176 $table->add (0, 10, new CFClient::UI::Label valign => 0, align => 1, text => "Background Music"); 245 $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); 246 $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 { 247 $hbox->add (new CFClient::UI::CheckBox
248 expand => 1, state => $CFG->{bgm_enable},
249 tooltip => "Enable background music playing",
250 connect_changed => sub {
179 $CFG->{bgm_enable} = $_[1]; 251 $CFG->{bgm_enable} = $_[1];
252 }
180 }); 253 );
181 $hbox->add (new CFClient::UI::Slider expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0.1], connect_changed => sub { 254 $hbox->add (new CFClient::UI::Slider
255 expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0.1],
256 tooltip => "The volume of the background music",
257 connect_changed => sub {
182 $CFG->{bgm_volume} = $_[1]; 258 $CFG->{bgm_volume} = $_[1];
183 CFClient::MixMusic::volume $_[1] * 128; 259 CFClient::MixMusic::volume $_[1] * 128;
260 }
184 }); 261 );
185 262
186 $table->add (1, 11, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { 263 $table->add (1, $row++, new CFClient::UI::Button
264 expand => 1, align => 0, text => "Apply",
265 tooltip => "Apply the audio settings that are not auto-apply",
266 connect_activate => sub {
187 audio_shutdown (); 267 audio_shutdown ();
188 audio_init (); 268 audio_init ();
269 }
189 }); 270 );
190 271
191 $dialog 272 $dialog
273}
274
275sub set_stats_window_fontsize {
276 for (values %{$STATWIDS}) {
277 $_->set_fontsize ($::CFG->{stat_fontsize});
278 }
279}
280
281sub set_gauge_window_fontsize {
282 for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) {
283 $_->set_fontsize ($::CFG->{gauge_fontsize});
284 }
285}
286
287sub make_gauge_window {
288 my $gh = int ($HEIGHT * $CFG->{gauge_size});
289# my $gw = int ($WIDTH * $CFG->{gauge_w_size});
290
291 my $win = new CFClient::UI::Frame (
292 y => $HEIGHT - $gh, x => 0, req_w => $WIDTH, req_h => $gh
293 );
294 $win->add (my $vb = new CFClient::UI::VBox);
295
296 $vb->add (my $hbg = new CFClient::UI::HBox expand => 1);
297
298
299 $hbg->add (new CFClient::UI::Empty expand => 1);
300 $hbg->add (my $hb = new CFClient::UI::HBox);
301 $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp');
302 $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana');
303 $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace');
304 $hb->add (my $fg = new CFClient::UI::Gauge type => 'food');
305
306 $vb->add (my $exp = new CFClient::UI::Label valign => 0, align => 1, text => "XP:");
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:");
309
310
311 $GAUGES = {
312 exp => $exp,# lvl => $lvl,
313 win => $win, range => $rng,
314 food => $fg, mana => $mg, hp => $hg, grace => $gg
315 };
316 $win
317}
318
319sub make_stats_window {
320 my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH * 2/5, y => 0, title => "Stats");
321
322 $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);
325 $uhb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1);
326
327 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
328
329 $hb->add (my $tbl = new CFClient::UI::Table expand => 1);
330
331 $tbl->add (0, 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");
333 $tbl->add (0, 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");
335 $tbl->add (0, 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");
337 $tbl->add (0, 6, $STATWIDS->{st_cha_lbl} = new CFClient::UI::Label valign => 0, align => +1, text => "Cha");
338
339 $tbl->add (1, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => +1, text => "");
340 $tbl->add (1, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => +1, text => "");
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 => "");
343 $tbl->add (1, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => +1, text => "");
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
347 $tbl->add (2, 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");
349 $tbl->add (2, 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");
351 $tbl->add (2, 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");
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
361 $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1);
362
363 my $row = 0;
364 my $col = 0;
365
366 for (qw/slow holyw conf fire depl magic
367 drain acid pois para deat phys
368 blind fear tund elec cold ghit/)
369 {
370 $tbl2->add ($col, $row,
371 $STATWIDS->{"res_$_"} =
372 new CFClient::UI::Label text => "0", align => +1, valign => 0
373 );
374 $tbl2->add ($col + 1, $row, new CFClient::UI::Image image => "ui/resist/resist_$_.png");
375
376 $row++;
377 if ($row % 6 == 0) {
378 $col += 2;
379 $row = 0;
380 }
381 }
382
383 &set_stats_window_fontsize;
384 update_stats_window ({});
385
386 $tgw
387}
388
389sub update_stats_window {
390 my ($stats) = @_;
391
392 # i love text protocols!!!
393 my $hp = $stats->{1} * 1;
394 my $hp_m = $stats->{2} * 1;
395 my $sp = $stats->{3} * 1;
396 my $sp_m = $stats->{4} * 1;
397 my $fo = $stats->{18} * 1;
398 my $fo_m = 999;
399 my $gr = $stats->{23} * 1;
400 my $gr_m = $stats->{24} * 1;
401
402 $GAUGES->{hp} ->set_value ($hp, $hp_m);
403 $GAUGES->{mana} ->set_value ($sp, $sp_m);
404 $GAUGES->{food} ->set_value ($fo, $fo_m);
405 $GAUGES->{grace} ->set_value ($gr, $gr_m);
406 $GAUGES->{exp} ->set_text ("XP: " . ($stats->{11} || $stats->{28}) * 1
407 ." LVL: " . $stats->{12} * 1);
408 my $rng = $stats->{20};
409 $rng =~ s/^Range: //; # thank you so much dear server
410 $GAUGES->{range} ->set_text ("Rng: " . $rng);
411# $GAUGES->{lvl} ->set_text ("LVL: " . $stats->{12});
412 my $title = $stats->{21};
413 $title =~ s/^Player: //;
414 $STATWIDS->{title} ->set_text ("Title: " . $title);
415
416 if (0) { # this code can vanish, just wanted to preserver it for a checkin
417 $STATWIDS->{st_str} ->set_text (sprintf "S%d", $stats->{5});
418 $STATWIDS->{st_dex} ->set_text (sprintf "D%d", $stats->{8});
419 $STATWIDS->{st_con} ->set_text (sprintf "Co%d", $stats->{9});
420 $STATWIDS->{st_int} ->set_text (sprintf "I%d", $stats->{6});
421 $STATWIDS->{st_wis} ->set_text (sprintf "W%d", $stats->{7});
422 $STATWIDS->{st_pow} ->set_text (sprintf "P%d", $stats->{22});
423 $STATWIDS->{st_cha} ->set_text (sprintf "Ch%d", $stats->{10});
424 $STATWIDS->{st_wc} ->set_text (sprintf "Wc%d", $stats->{13});
425 $STATWIDS->{st_ac} ->set_text (sprintf "Ac%d", $stats->{14});
426 $STATWIDS->{st_dam} ->set_text (sprintf "Dam%d", $stats->{15});
427 $STATWIDS->{st_arm} ->set_text (sprintf "Arm%d", $stats->{16});
428 $STATWIDS->{st_spd} ->set_text (sprintf "Sp%.1f", $stats->{17});
429 $STATWIDS->{st_wspd}->set_text (sprintf "WSp%.1f", $stats->{19});
430 } else {
431 $STATWIDS->{st_str} ->set_text (sprintf "%d", $stats->{5});
432 $STATWIDS->{st_dex} ->set_text (sprintf "%d", $stats->{8});
433 $STATWIDS->{st_con} ->set_text (sprintf "%d", $stats->{9});
434 $STATWIDS->{st_int} ->set_text (sprintf "%d", $stats->{6});
435 $STATWIDS->{st_wis} ->set_text (sprintf "%d", $stats->{7});
436 $STATWIDS->{st_pow} ->set_text (sprintf "%d", $stats->{22});
437 $STATWIDS->{st_cha} ->set_text (sprintf "%d", $stats->{10});
438 $STATWIDS->{st_wc} ->set_text (sprintf "%d", $stats->{13});
439 $STATWIDS->{st_ac} ->set_text (sprintf "%d", $stats->{14});
440 $STATWIDS->{st_dam} ->set_text (sprintf "%d", $stats->{15});
441 $STATWIDS->{st_arm} ->set_text (sprintf "%d", $stats->{16});
442 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{17});
443 $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{19});
444 }
445
446 my %tbl = (
447 phys => 100,
448 magic => 101,
449 fire => 102,
450 elec => 103,
451 cold => 104,
452 conf => 105,
453 acid => 106,
454 drain => 107,
455 ghit => 108,
456 pois => 109,
457 slow => 110,
458 para => 111,
459 tund => 112,
460 fear => 113,
461 depl => 113,
462 deat => 115,
463 holyw => 116,
464 blind => 117
465 );
466
467 for (keys %tbl) {
468 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}});
469 }
470
192} 471}
193 472
194sub metaserver_dialog { 473sub metaserver_dialog {
195 my $dialog = new CFClient::UI::FancyFrame 474 my $dialog = new CFClient::UI::FancyFrame
196 title => "Metaserver", 475 title => "Metaserver",
443 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { 722 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub {
444 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 723 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
445 status "Configuration Saved"; 724 status "Configuration Saved";
446 }); 725 });
447 726
727 $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
728 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window);
729
448 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup 730 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
449 731
450 my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH - 300, y => 0, title => "Stats");
451 $tgw->add (my $hbox = new CFClient::UI::HBox ());
452 732
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} 733}
461 734
462sub video_shutdown { 735sub video_shutdown {
463 $CFClient::UI::ROOT->{children} = []; 736 $CFClient::UI::ROOT->{children} = [];
464 undef $SDL_ACTIVE; 737 undef $SDL_ACTIVE;
465} 738}
466 739
740my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d#
467my $bgmusic;#TODO#hack#d# 741my $bgmusic;#TODO#hack#d#
742
743sub audio_music_finished {
744 return unless $CFG->{bgm_enable};
745
746 # TODO: hack, do play loop and mood music
747 $bgmusic = new_from_file CFClient::MixMusic CFClient::find_rcfile "music/$bgmusic[0]";
748 $bgmusic->play (0);
749
750 push @bgmusic, shift @bgmusic;
751}
468 752
469sub audio_init { 753sub audio_init {
470 if ($CFG->{audio_enable}) { 754 if ($CFG->{audio_enable}) {
471 if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { 755 if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") {
472
473 $SDL_MIXER = !CFClient::Mix_OpenAudio; 756 $SDL_MIXER = !CFClient::Mix_OpenAudio;
474 CFClient::Mix_AllocateChannels 8; 757 CFClient::Mix_AllocateChannels 8;
475 CFClient::MixMusic::volume $CFG->{bgm_volume} * 128; 758 CFClient::MixMusic::volume $CFG->{bgm_volume} * 128;
476 759
477 # TODO: hack, do play loop and mood music 760 audio_music_finished;
478 if ($CFG->{bgm_enable}) {
479 $bgmusic = new_from_file CFClient::MixMusic CFClient::find_rcfile "music/game3.ogg";
480 $bgmusic->play;
481 }
482 761
483 while (<$fh>) { 762 while (<$fh>) {
484 next if /^\s*#/; 763 next if /^\s*#/;
485 next if /^\s*$/; 764 next if /^\s*$/;
486 765
564@conn::ISA = Crossfire::Protocol::; 843@conn::ISA = Crossfire::Protocol::;
565 844
566sub conn::stats_update { 845sub conn::stats_update {
567 my ($self, $stats) = @_; 846 my ($self, $stats) = @_;
568 847
569 # i love text protocols!!! 848 update_stats_window ($stats);
570 # FIXME: the stats are somehow weird
571 my $hp = $stats->{1};
572 my $hp_m = $stats->{2};
573 my $sp = $stats->{3};
574 my $sp_m = $stats->{4};
575 my $fo = $stats->{18};
576 my $fo_m = 999;
577 my $gr = $stats->{23};
578 my $gr_m = $stats->{24};
579
580 #d# warn "DATA $hp $hp_m $sp $sp_m $fo $fo_m $gr $gr_m\n";
581 $GAUGES->{hp} ->set_value ($hp, $hp_m);
582 $GAUGES->{mana} ->set_value ($sp, $sp_m);
583 $GAUGES->{food} ->set_value ($fo, $fo_m);
584 $GAUGES->{grace}->set_value ($gr, $gr_m);
585} 849}
586 850
587sub conn::user_send { 851sub conn::user_send {
588 my ($self, $command) = @_; 852 my ($self, $command) = @_;
589 853
719 983
720 $x += $ox; 984 $x += $ox;
721 $y += $oy; 985 $y += $oy;
722 986
723 $self->{map_info} = [$hash, $x, $y, $w, $h]; 987 $self->{map_info} = [$hash, $x, $y, $w, $h];
988
989 my $map = $self->{map_info}[0];
990 $map =~ s/^.*?\/([^\/]+)$/\1/;
991 $STATWIDS->{map}->set_text ("Map: " . $map);
724 992
725 $self->load_map ($hash, $x, $y); 993 $self->load_map ($hash, $x, $y);
726} 994}
727 995
728sub conn::face_find { 996sub conn::face_find {
852 CFClient::SDL_QUIT => sub { 1120 CFClient::SDL_QUIT => sub {
853 Event::unloop -1; 1121 Event::unloop -1;
854 }, 1122 },
855 CFClient::SDL_VIDEORESIZE => sub { 1123 CFClient::SDL_VIDEORESIZE => sub {
856 }, 1124 },
857 CFClient::SDL_VIDEOEXPOSE => sub { 1125 CFClient::SDL_VIDEOEXPOSE => \&refresh,
858 refresh; 1126 CFClient::SDL_ACTIVEEVENT => sub {
1127# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d#
859 }, 1128 },
860 CFClient::SDL_KEYDOWN => sub { 1129 CFClient::SDL_KEYDOWN => sub {
861 if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) { 1130 if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) {
862 # alt-enter 1131 # alt-enter
863 video_shutdown; 1132 video_shutdown;
865 video_init; 1134 video_init;
866 } else { 1135 } else {
867 CFClient::UI::feed_sdl_key_down_event ($_[0]); 1136 CFClient::UI::feed_sdl_key_down_event ($_[0]);
868 } 1137 }
869 }, 1138 },
870 CFClient::SDL_KEYUP => sub { 1139 CFClient::SDL_KEYUP => \&CFClient::UI::feed_sdl_key_up_event,
871 CFClient::UI::feed_sdl_key_up_event ($_[0]); 1140 CFClient::SDL_MOUSEMOTION => \&CFClient::UI::feed_sdl_motion_event,
872 }, 1141 CFClient::SDL_MOUSEBUTTONDOWN => \&CFClient::UI::feed_sdl_button_down_event,
873 CFClient::SDL_MOUSEMOTION => sub { 1142 CFClient::SDL_MOUSEBUTTONUP => \&CFClient::UI::feed_sdl_button_up_event,
874 CFClient::UI::feed_sdl_motion_event ($_[0]); 1143 CFClient::SDL_USEREVENT => \&audio_music_finished,
875 },
876 CFClient::SDL_MOUSEBUTTONDOWN => sub {
877 CFClient::UI::feed_sdl_button_down_event ($_[0]);
878 },
879 CFClient::SDL_MOUSEBUTTONUP => sub {
880 CFClient::UI::feed_sdl_button_up_event ($_[0]);
881 },
882 CFClient::SDL_ACTIVEEVENT => sub {
883# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d#
884 },
885); 1144);
886 1145
887############################################################################# 1146#############################################################################
888 1147
889$SIG{INT} = $SIG{TERM} = sub { exit }; 1148$SIG{INT} = $SIG{TERM} = sub { exit };
901 fast => 0, 1160 fast => 0,
902 fow_enable => 1, 1161 fow_enable => 1,
903 fow_intensity => 0.45, 1162 fow_intensity => 0.45,
904 fow_smooth => 0, 1163 fow_smooth => 0,
905 gui_fontsize => 1, 1164 gui_fontsize => 1,
906 log_fontsize => 14, 1165 log_fontsize => 1,
1166 gauge_fontsize => 1,
1167 gauge_size => 0.35,
1168 stat_fontsize => 1,
907 mapsize => 100, 1169 mapsize => 100,
908 host => "crossfire.schmorp.de", 1170 host => "crossfire.schmorp.de",
909 say_command => 'say', 1171 say_command => 'say',
910 audio_enable => 1, 1172 audio_enable => 1,
911 bgm_enable => 1, 1173 bgm_enable => 1,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines