… | |
… | |
47 | our $BUTTONBAR; |
47 | our $BUTTONBAR; |
48 | our $LOGVIEW; |
48 | our $LOGVIEW; |
49 | our $CONSOLE; |
49 | our $CONSOLE; |
50 | our $METASERVER; |
50 | our $METASERVER; |
51 | |
51 | |
|
|
52 | our $FLOORBOX; |
52 | our $GAUGES; |
53 | our $GAUGES; |
53 | our $STATWIDS; |
54 | our $STATWIDS; |
54 | |
55 | |
55 | our $SDL_ACTIVE; |
56 | our $SDL_ACTIVE; |
56 | our %SDL_CB; |
57 | our %SDL_CB; |
… | |
… | |
142 | my ($self, $value) = @_; |
143 | my ($self, $value) = @_; |
143 | $CFG->{fast} = $value; |
144 | $CFG->{fast} = $value; |
144 | } |
145 | } |
145 | ); |
146 | ); |
146 | |
147 | |
|
|
148 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Map Scale"); |
|
|
149 | $table->add (1, $row++, new CFClient::UI::Slider |
|
|
150 | range => [$CFG->{map_scale}, 0.25, 2, 0.05], |
|
|
151 | tooltip => "Enlarge or shrink the displayed map", |
|
|
152 | connect_changed => sub { |
|
|
153 | my ($self, $value) = @_; |
|
|
154 | $CFG->{map_scale} = 0.05 * int $value / 0.05; |
|
|
155 | } |
|
|
156 | ); |
|
|
157 | |
147 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War"); |
158 | $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War"); |
148 | $table->add (1, $row++, new CFClient::UI::CheckBox |
159 | $table->add (1, $row++, new CFClient::UI::CheckBox |
149 | state => $CFG->{fow_enable}, |
160 | state => $CFG->{fow_enable}, |
150 | tooltip => "Fog-of-War marks areas that cannot be seen by the player", |
161 | tooltip => "Fog-of-War marks areas that cannot be seen by the player", |
151 | connect_changed => sub { |
162 | connect_changed => sub { |
… | |
… | |
222 | range => [$CFG->{gauge_fontsize}, 0.5, 2.0, 0.1], |
233 | range => [$CFG->{gauge_fontsize}, 0.5, 2.0, 0.1], |
223 | tooltip => "Adjusts the fontsize of the gauges at the bottom right", |
234 | tooltip => "Adjusts the fontsize of the gauges at the bottom right", |
224 | connect_changed => sub { |
235 | connect_changed => sub { |
225 | $CFG->{gauge_fontsize} = 0.1 * int $_[1] * 10; |
236 | $CFG->{gauge_fontsize} = 0.1 * int $_[1] * 10; |
226 | &set_gauge_window_fontsize; |
237 | &set_gauge_window_fontsize; |
227 | #$GAUGES->{win}->check_size; |
|
|
228 | #$GAUGES->{win}->update; |
|
|
229 | } |
238 | } |
230 | ); |
239 | ); |
231 | |
240 | |
232 | $table->add (1, $row++, new CFClient::UI::Button |
241 | $table->add (1, $row++, new CFClient::UI::Button |
233 | expand => 1, align => 0, text => "Apply", |
242 | expand => 1, align => 0, text => "Apply", |
… | |
… | |
288 | |
297 | |
289 | sub set_gauge_window_fontsize { |
298 | sub set_gauge_window_fontsize { |
290 | for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) { |
299 | for (map { $GAUGES->{$_} } grep { $_ ne 'win' } keys %{$GAUGES}) { |
291 | $_->set_fontsize ($::CFG->{gauge_fontsize}); |
300 | $_->set_fontsize ($::CFG->{gauge_fontsize}); |
292 | } |
301 | } |
|
|
302 | |
|
|
303 | # local $GAUGES->{win}{parent};#d# |
|
|
304 | # use PApp::Util; open D, ">:utf8", "d"; print D PApp::Util::dumpval $GAUGES->{win}; close D; |
293 | } |
305 | } |
294 | |
306 | |
295 | sub make_gauge_window { |
307 | sub make_gauge_window { |
296 | my $gh = int ($HEIGHT * $CFG->{gauge_size}); |
308 | my $gh = int ($HEIGHT * $CFG->{gauge_size}); |
297 | # my $gw = int ($WIDTH * $CFG->{gauge_w_size}); |
309 | # my $gw = int ($WIDTH * $CFG->{gauge_w_size}); |
298 | |
310 | |
299 | my $win = new CFClient::UI::Frame ( |
311 | my $win = new CFClient::UI::Frame ( |
300 | y => $HEIGHT - $gh, x => 0, req_w => $WIDTH, req_h => $gh |
312 | y => $HEIGHT - $gh, x => 0, user_w => $WIDTH, user_h => $gh |
301 | ); |
313 | ); |
302 | $win->add (my $vb = new CFClient::UI::VBox); |
314 | $win->add (my $hbox = new CFClient::UI::HBox |
303 | |
315 | children => [ |
304 | $vb->add (my $hbg = new CFClient::UI::HBox expand => 1); |
316 | (new CFClient::UI::HBox expand => 1), |
|
|
317 | ($FLOORBOX = new CFClient::UI::VBox), |
|
|
318 | (my $vbox = new CFClient::UI::VBox), |
|
|
319 | ], |
|
|
320 | ); |
305 | |
321 | |
306 | |
322 | $vbox->add (new CFClient::UI::HBox |
|
|
323 | expand => 1, |
|
|
324 | children => [ |
307 | $hbg->add (new CFClient::UI::Empty expand => 1); |
325 | (new CFClient::UI::Empty expand => 1), |
308 | $hbg->add (my $hb = new CFClient::UI::HBox); |
326 | (my $hb = new CFClient::UI::HBox), |
|
|
327 | ], |
|
|
328 | ); |
|
|
329 | |
309 | $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp', tooltip => "Health points"); |
330 | $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp', |
|
|
331 | tooltip => "Health points - depletes when you get wounded, refills when you heal or idle"); |
310 | $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana', tooltip => "Spellpoints"); |
332 | $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana', |
|
|
333 | tooltip => "Spell points - deplete when you cast wizard spells, refills when you idle"); |
311 | $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace', tooltip => "Grace"); |
334 | $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace', |
|
|
335 | tooltip => "Grace points - deplete when you cast priest spells, refills when you pray"); |
312 | $hb->add (my $fg = new CFClient::UI::Gauge type => 'food', tooltip => "Food"); |
336 | $hb->add (my $fg = new CFClient::UI::Gauge type => 'food', |
|
|
337 | tooltip => "Food - depletes with time, faster when you heal or build mana, refills when you eat healthy food"); |
313 | |
338 | |
314 | $vb->add (my $exp = new CFClient::UI::Label valign => 0, align => 1, text => "XP: 0 LVL: 0"); |
339 | $vbox->add (my $exp = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, |
|
|
340 | tooltip => "Experience points and level - increases when you kill monsters or successfully use skills"); |
315 | $vb->add (my $rng = new CFClient::UI::Label valign => 0, align => 1, text => "Rng:"); |
341 | $vbox->add (my $rng = new CFClient::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, |
|
|
342 | tooltip => "Ranged attack - how you attack when you press shift-cursor (spell, skill, weapon etc.)"); |
316 | |
343 | |
317 | $GAUGES = { |
344 | $GAUGES = { |
318 | exp => $exp, win => $win, range => $rng, |
345 | exp => $exp, win => $win, range => $rng, |
319 | food => $fg, mana => $mg, hp => $hg, grace => $gg |
346 | food => $fg, mana => $mg, hp => $hg, grace => $gg |
320 | }; |
347 | }; |
|
|
348 | |
|
|
349 | &set_gauge_window_fontsize; |
|
|
350 | |
321 | $win |
351 | $win |
322 | } |
352 | } |
323 | |
353 | |
324 | sub make_stats_window { |
354 | sub make_stats_window { |
325 | my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH * 2/5, y => 0, title => "Stats"); |
355 | my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH * 2/5, y => 0, title => "Stats"); |
… | |
… | |
329 | $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1); |
359 | $vb->add ($STATWIDS->{map} = new CFClient::UI::Label valign => 0, align => -1, text => "Map:", expand => 1); |
330 | |
360 | |
331 | $vb->add (my $hb = new CFClient::UI::HBox expand => 1); |
361 | $vb->add (my $hb = new CFClient::UI::HBox expand => 1); |
332 | |
362 | |
333 | $hb->add (my $tbl = new CFClient::UI::Table expand => 1); |
363 | $hb->add (my $tbl = new CFClient::UI::Table expand => 1); |
|
|
364 | |
|
|
365 | my $black = [0, 0, 0]; |
334 | |
366 | |
335 | $tbl->add (0, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); |
367 | $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"); |
368 | $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"); |
369 | $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"); |
370 | $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"); |
371 | $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"); |
372 | $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"); |
373 | $tbl->add (0, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => +1, template => "30"); |
342 | |
374 | |
343 | $tbl->add (1, 0, $STATWIDS->{st_str_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Str"); |
375 | $tbl->add (1, 0, $STATWIDS->{st_str_lbl} = new CFClient::UI::Label fg => $black, 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"); |
376 | $tbl->add (1, 1, $STATWIDS->{st_dex_lbl} = new CFClient::UI::Label fg => $black, 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"); |
377 | $tbl->add (1, 2, $STATWIDS->{st_con_lbl} = new CFClient::UI::Label fg => $black, 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"); |
378 | $tbl->add (1, 3, $STATWIDS->{st_int_lbl} = new CFClient::UI::Label fg => $black, 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"); |
379 | $tbl->add (1, 4, $STATWIDS->{st_wis_lbl} = new CFClient::UI::Label fg => $black, 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"); |
380 | $tbl->add (1, 5, $STATWIDS->{st_pow_lbl} = new CFClient::UI::Label fg => $black, 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"); |
381 | $tbl->add (1, 6, $STATWIDS->{st_cha_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "Cha"); |
350 | |
382 | |
351 | $tbl->add (2, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => +1, template => "-120"); |
383 | $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"); |
384 | $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"); |
385 | $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"); |
386 | $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"); |
387 | $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"); |
388 | $tbl->add (2, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => +1, template => "9"); |
357 | |
389 | |
358 | $tbl->add (3, 0, $STATWIDS->{st_wc_lbl} = new CFClient::UI::Label valign => 0, align => -1, text => "Wc"); |
390 | $tbl->add (3, 0, $STATWIDS->{st_wc_lbl} = new CFClient::UI::Label fg => $black, 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"); |
391 | $tbl->add (3, 1, $STATWIDS->{st_ac_lbl} = new CFClient::UI::Label fg => $black, 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"); |
392 | $tbl->add (3, 2, $STATWIDS->{st_dam_lbl} = new CFClient::UI::Label fg => $black, 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"); |
393 | $tbl->add (3, 3, $STATWIDS->{st_arm_lbl} = new CFClient::UI::Label fg => $black, 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"); |
394 | $tbl->add (3, 4, $STATWIDS->{st_spd_lbl} = new CFClient::UI::Label fg => $black, 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"); |
395 | $tbl->add (3, 5, $STATWIDS->{st_wspd_lbl} = new CFClient::UI::Label fg => $black, valign => 0, align => -1, text => "WSp"); |
364 | |
396 | |
365 | $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); |
397 | $hb->add (my $tbl2 = new CFClient::UI::Table expand => 1); |
366 | |
398 | |
367 | my $row = 0; |
399 | my $row = 0; |
368 | my $col = 0; |
400 | my $col = 0; |
… | |
… | |
417 | update_stats_window ({}); |
449 | update_stats_window ({}); |
418 | |
450 | |
419 | $tgw |
451 | $tgw |
420 | } |
452 | } |
421 | |
453 | |
|
|
454 | sub formsep { |
|
|
455 | reverse join ",", grep length, split /(...)/, reverse $_[0] * 1 |
|
|
456 | } |
|
|
457 | |
422 | sub update_stats_window { |
458 | sub update_stats_window { |
423 | my ($stats) = @_; |
459 | my ($stats) = @_; |
424 | |
460 | |
425 | # i love text protocols!!! |
461 | # i love text protocols!!! |
426 | my $hp = $stats->{1} * 1; |
462 | my $hp = $stats->{Crossfire::Protocol::CS_STAT_HP} * 1; |
427 | my $hp_m = $stats->{2} * 1; |
463 | my $hp_m = $stats->{Crossfire::Protocol::CS_STAT_MAXHP} * 1; |
428 | my $sp = $stats->{3} * 1; |
464 | my $sp = $stats->{Crossfire::Protocol::CS_STAT_SP} * 1; |
429 | my $sp_m = $stats->{4} * 1; |
465 | my $sp_m = $stats->{Crossfire::Protocol::CS_STAT_MAXSP} * 1; |
430 | my $fo = $stats->{18} * 1; |
466 | my $fo = $stats->{Crossfire::Protocol::CS_STAT_FOOD} * 1; |
431 | my $fo_m = 999; |
467 | my $fo_m = 999; |
432 | my $gr = $stats->{23} * 1; |
468 | my $gr = $stats->{Crossfire::Protocol::CS_STAT_GRACE} * 1; |
433 | my $gr_m = $stats->{24} * 1; |
469 | my $gr_m = $stats->{Crossfire::Protocol::CS_STAT_MAXGRACE} * 1; |
434 | |
470 | |
435 | $GAUGES->{hp} ->set_value ($hp, $hp_m); |
471 | $GAUGES->{hp} ->set_value ($hp, $hp_m); |
436 | $GAUGES->{mana} ->set_value ($sp, $sp_m); |
472 | $GAUGES->{mana} ->set_value ($sp, $sp_m); |
437 | $GAUGES->{food} ->set_value ($fo, $fo_m); |
473 | $GAUGES->{food} ->set_value ($fo, $fo_m); |
438 | $GAUGES->{grace} ->set_value ($gr, $gr_m); |
474 | $GAUGES->{grace} ->set_value ($gr, $gr_m); |
439 | $GAUGES->{exp} ->set_text ("XP: " . ($stats->{11} || $stats->{28}) * 1 |
475 | $GAUGES->{exp} ->set_text ("Exp: " . (formsep $stats->{Crossfire::Protocol::CS_STAT_EXP64}) |
440 | ." LVL: " . $stats->{12} * 1); |
476 | . " (lvl " . ($stats->{Crossfire::Protocol::CS_STAT_LEVEL} * 1) . ")"); |
441 | my $rng = $stats->{20}; |
477 | my $rng = $stats->{Crossfire::Protocol::CS_STAT_RANGE}; |
442 | $rng =~ s/^Range: //; # thank you so much dear server |
478 | $rng =~ s/^Range: //; # thank you so much dear server |
443 | $GAUGES->{range} ->set_text ("Rng: " . $rng); |
479 | $GAUGES->{range} ->set_text ("Rng: " . $rng); |
444 | my $title = $stats->{21}; |
480 | my $title = $stats->{Crossfire::Protocol::CS_STAT_TITLE}; |
445 | $title =~ s/^Player: //; |
481 | $title =~ s/^Player: //; |
446 | $STATWIDS->{title} ->set_text ("Title: " . $title); |
482 | $STATWIDS->{title} ->set_text ("Title: " . $title); |
447 | |
483 | |
448 | $STATWIDS->{st_str} ->set_text (sprintf "%d", $stats->{5}); |
484 | $STATWIDS->{st_str} ->set_text (sprintf "%d", $stats->{5}); |
449 | $STATWIDS->{st_dex} ->set_text (sprintf "%d", $stats->{8}); |
485 | $STATWIDS->{st_dex} ->set_text (sprintf "%d", $stats->{8}); |
450 | $STATWIDS->{st_con} ->set_text (sprintf "%d", $stats->{9}); |
486 | $STATWIDS->{st_con} ->set_text (sprintf "%d", $stats->{9}); |
451 | $STATWIDS->{st_int} ->set_text (sprintf "%d", $stats->{6}); |
487 | $STATWIDS->{st_int} ->set_text (sprintf "%d", $stats->{6}); |
452 | $STATWIDS->{st_wis} ->set_text (sprintf "%d", $stats->{7}); |
488 | $STATWIDS->{st_wis} ->set_text (sprintf "%d", $stats->{7}); |
453 | $STATWIDS->{st_pow} ->set_text (sprintf "%d", $stats->{22}); |
489 | $STATWIDS->{st_pow} ->set_text (sprintf "%d", $stats->{22}); |
454 | $STATWIDS->{st_cha} ->set_text (sprintf "%d", $stats->{10}); |
490 | $STATWIDS->{st_cha} ->set_text (sprintf "%d", $stats->{10}); |
455 | $STATWIDS->{st_wc} ->set_text (sprintf "%d", $stats->{13}); |
491 | $STATWIDS->{st_wc} ->set_text (sprintf "%d", $stats->{13}); |
456 | $STATWIDS->{st_ac} ->set_text (sprintf "%d", $stats->{14}); |
492 | $STATWIDS->{st_ac} ->set_text (sprintf "%d", $stats->{14}); |
457 | $STATWIDS->{st_dam} ->set_text (sprintf "%d", $stats->{15}); |
493 | $STATWIDS->{st_dam} ->set_text (sprintf "%d", $stats->{15}); |
458 | $STATWIDS->{st_arm} ->set_text (sprintf "%d", $stats->{16}); |
494 | $STATWIDS->{st_arm} ->set_text (sprintf "%d", $stats->{16}); |
459 | $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{17}); |
495 | $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{Crossfire::Protocol::CS_STAT_SPEED}); |
460 | $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{19}); |
496 | $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{Crossfire::Protocol::CS_STAT_WEAP_SP}); |
461 | |
497 | |
462 | my %tbl = ( |
498 | my %tbl = ( |
463 | phys => 100, |
499 | phys => 100, |
464 | magic => 101, |
500 | magic => 101, |
465 | fire => 102, |
501 | fire => 102, |
… | |
… | |
621 | $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd"); |
657 | $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd"); |
622 | $table->add (1, 6, my $saycmd = new CFClient::UI::Entry |
658 | $table->add (1, 6, my $saycmd = new CFClient::UI::Entry |
623 | text => $CFG->{say_command}, |
659 | text => $CFG->{say_command}, |
624 | tooltip => "This is the command that will be used if you write a line in the message window entry. " |
660 | 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. " |
661 | ."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.", |
662 | ."But you could also set it to 'tell <playername>' to only chat with that user.", |
627 | connect_changed => sub { |
663 | connect_changed => sub { |
628 | my ($self, $value) = @_; |
664 | my ($self, $value) = @_; |
629 | $CFG->{say_command} = $value; |
665 | $CFG->{say_command} = $value; |
630 | } |
666 | } |
631 | ); |
667 | ); |
… | |
… | |
1066 | } |
1102 | } |
1067 | |
1103 | |
1068 | gotid: |
1104 | gotid: |
1069 | $face->{id} = $id; |
1105 | $face->{id} = $id; |
1070 | $MAP->set_face ($facenum => $id); |
1106 | $MAP->set_face ($facenum => $id); |
|
|
1107 | $self->{faceid}[$facenum] = $id;#d# |
1071 | $TILECACHE->get ($id) |
1108 | $TILECACHE->get ($id) |
1072 | } |
1109 | } |
1073 | |
1110 | |
1074 | sub conn::face_update { |
1111 | sub conn::face_update { |
1075 | my ($self, $facenum, $face) = @_; |
1112 | my ($self, $facenum, $face) = @_; |
… | |
… | |
1083 | my ($self, $id, $data) = @_; |
1120 | my ($self, $id, $data) = @_; |
1084 | |
1121 | |
1085 | $self->{texture}[$id] ||= do { |
1122 | $self->{texture}[$id] ||= do { |
1086 | my $tex = |
1123 | my $tex = |
1087 | new_from_image CFClient::Texture |
1124 | new_from_image CFClient::Texture |
1088 | $data, minify => 1; |
1125 | $data, minify => 1, mipmap => 1; |
1089 | |
1126 | |
1090 | $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
1127 | $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
1091 | $MAPWIDGET->update; |
1128 | $MAPWIDGET->update; |
1092 | |
1129 | |
1093 | $tex |
1130 | $tex |
… | |
… | |
1105 | |
1142 | |
1106 | $chunk->play; |
1143 | $chunk->play; |
1107 | # warn "sound $x,$y,$soundnum,$type\n";#d# |
1144 | # warn "sound $x,$y,$soundnum,$type\n";#d# |
1108 | } |
1145 | } |
1109 | |
1146 | |
|
|
1147 | my $LAST_QUERY; # server is stupid, stupid, stupid |
|
|
1148 | |
1110 | sub conn::query { |
1149 | sub conn::query { |
1111 | my ($self, $flags, $prompt) = @_; |
1150 | my ($self, $flags, $prompt) = @_; |
1112 | |
1151 | |
1113 | #TODO, display dialog with relevant information |
1152 | $prompt = $LAST_QUERY unless length $prompt; |
1114 | warn "<<<<QUERY:$flags:$prompt>>>\n";#d# |
1153 | $LAST_QUERY = $prompt; |
|
|
1154 | |
|
|
1155 | my $dialog = new CFClient::UI::FancyFrame |
|
|
1156 | title => "Query", |
|
|
1157 | child => my $vbox = new CFClient::UI::VBox; |
|
|
1158 | |
|
|
1159 | $vbox->add (new CFClient::UI::Label |
|
|
1160 | max_w => $::WIDTH * 0.4, |
|
|
1161 | text => $prompt); |
|
|
1162 | |
|
|
1163 | if ($flags & Crossfire::Protocol::CS_QUERY_YESNO) { |
|
|
1164 | $vbox->add (my $hbox = new CFClient::HBox); |
|
|
1165 | $hbox->add (new CFClient::Button |
|
|
1166 | text => "No", |
|
|
1167 | connect_activate => sub { |
|
|
1168 | $self->send ("reply n"); |
|
|
1169 | $dialog->destroy; |
|
|
1170 | $MAPWIDGET->focus_in; |
|
|
1171 | } |
|
|
1172 | ); |
|
|
1173 | $hbox->add (new CFClient::Button |
|
|
1174 | text => "Yes", |
|
|
1175 | connect_activate => sub { |
|
|
1176 | $self->send ("reply y"); |
|
|
1177 | $dialog->destroy; |
|
|
1178 | $MAPWIDGET->focus_in; |
|
|
1179 | }, |
|
|
1180 | ); |
|
|
1181 | |
|
|
1182 | $dialog->focus_in; |
|
|
1183 | |
|
|
1184 | } elsif ($flags & Crossfire::Protocol::CS_QUERY_SINGLECHAR) { |
|
|
1185 | $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)"; |
|
|
1186 | $vbox->add (my $entry = new CFClient::UI::Entry |
|
|
1187 | connect_changed => sub { |
|
|
1188 | $self->send ("reply $_[1]"); |
|
|
1189 | $dialog->destroy; |
|
|
1190 | $MAPWIDGET->focus_in; |
|
|
1191 | }, |
|
|
1192 | ); |
|
|
1193 | |
|
|
1194 | $entry->focus_in; |
|
|
1195 | |
|
|
1196 | } else { |
|
|
1197 | $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; |
|
|
1198 | |
|
|
1199 | $vbox->add (my $entry = new CFClient::UI::Entry |
|
|
1200 | $flags & Crossfire::Protocol::CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (), |
|
|
1201 | connect_activate => sub { |
|
|
1202 | $self->send ("reply $_[1]"); |
|
|
1203 | $dialog->destroy; |
|
|
1204 | $MAPWIDGET->focus_in; |
|
|
1205 | }, |
|
|
1206 | ); |
|
|
1207 | |
|
|
1208 | $entry->focus_in; |
|
|
1209 | } |
|
|
1210 | |
|
|
1211 | $dialog->show; |
1115 | } |
1212 | } |
1116 | |
1213 | |
1117 | sub conn::drawinfo { |
1214 | sub conn::drawinfo { |
1118 | my ($self, $color, $text) = @_; |
1215 | my ($self, $color, $text) = @_; |
1119 | |
1216 | |
… | |
… | |
1137 | } |
1234 | } |
1138 | |
1235 | |
1139 | sub conn::spell_add { |
1236 | sub conn::spell_add { |
1140 | my ($self, $spell) = @_; |
1237 | my ($self, $spell) = @_; |
1141 | |
1238 | |
|
|
1239 | # TODO |
|
|
1240 | # create a widget dynamically, using spell face (CF::Protocol downloads them) |
1142 | $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message}, sub { |
1241 | $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message}); |
1143 | }); |
|
|
1144 | $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message}, sub { |
1242 | $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message}); |
1145 | }); |
|
|
1146 | } |
1243 | } |
1147 | |
1244 | |
1148 | sub conn::spell_delete { |
1245 | sub conn::spell_delete { |
1149 | my ($self, $spell) = @_; |
1246 | my ($self, $spell) = @_; |
1150 | } |
1247 | } |
1151 | |
1248 | |
1152 | sub conn::addme_success { |
1249 | sub conn::addme_success { |
1153 | my ($self) = @_; |
1250 | my ($self) = @_; |
1154 | |
1251 | |
1155 | for my $skill (values %{$self->{skill_info}}) { |
1252 | for my $skill (values %{$self->{skill_info}}) { |
1156 | $MAPWIDGET->add_command ("ready_skill $skill", "", sub { |
1253 | $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'"); |
1157 | }); |
1254 | $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'"); |
1158 | $MAPWIDGET->add_command ("use_skill $skill", "", sub { |
|
|
1159 | }); |
|
|
1160 | } |
1255 | } |
|
|
1256 | } |
|
|
1257 | |
|
|
1258 | sub update_floorbox { |
|
|
1259 | $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { |
|
|
1260 | $FLOORBOX->clear; |
|
|
1261 | $FLOORBOX->add (new CFClient::UI::Empty expand => 1); |
|
|
1262 | |
|
|
1263 | my @items = values %{ $CONN->{container}{0} }; |
|
|
1264 | |
|
|
1265 | # we basically have to use the same sorting as everybody else |
|
|
1266 | @items = sort { $a->{type} <=> $b->{type} } @items; |
|
|
1267 | |
|
|
1268 | for my $item (reverse @items) { |
|
|
1269 | my $desc = $item->{nrof} < 2 |
|
|
1270 | ? $item->{name} |
|
|
1271 | : "$item->{nrof} $item->{name_pl}"; |
|
|
1272 | # todo: animation widget, face widget, weight(?) etc. |
|
|
1273 | $FLOORBOX->add (my $hbox = new CFClient::UI::HBox |
|
|
1274 | tooltip => (CFClient::UI::Label->escape ($desc) |
|
|
1275 | . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"), |
|
|
1276 | can_hover => 1, |
|
|
1277 | can_events => 1, |
|
|
1278 | connect_button_down => sub { |
|
|
1279 | my ($self, $ev, $x, $y) = @_; |
|
|
1280 | |
|
|
1281 | # todo: maybe put examine on 1? but should just be a tooltip :( |
|
|
1282 | if ($ev->{button} == 1) { |
|
|
1283 | $CONN->send ("move $CONN->{player}{tag} $item->{tag} 0"); |
|
|
1284 | } elsif ($ev->{button} == 2) { |
|
|
1285 | $CONN->send ("apply $item->{tag}"); |
|
|
1286 | } elsif ($ev->{button} == 3) { |
|
|
1287 | # examine, lock, mark, maybe other things |
|
|
1288 | warn "MENU not implemented yet\n"; |
|
|
1289 | } |
|
|
1290 | |
|
|
1291 | 1 |
|
|
1292 | }, |
|
|
1293 | ); |
|
|
1294 | |
|
|
1295 | $hbox->add (new CFClient::UI::Face |
|
|
1296 | face => $item->{face}, |
|
|
1297 | anim => $item->{anim}, |
|
|
1298 | animspeed => $item->{animspeed}, |
|
|
1299 | ); |
|
|
1300 | |
|
|
1301 | $hbox->add (new CFClient::UI::Label |
|
|
1302 | text => $desc, |
|
|
1303 | ); |
|
|
1304 | } |
|
|
1305 | }); |
|
|
1306 | refresh; |
|
|
1307 | } |
|
|
1308 | |
|
|
1309 | sub conn::container_add { |
|
|
1310 | my ($self, $id, $items) = @_; |
|
|
1311 | |
|
|
1312 | update_floorbox if $id == 0; |
|
|
1313 | # $self-<{player}{tag} => player inv |
|
|
1314 | #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; |
|
|
1315 | } |
|
|
1316 | |
|
|
1317 | sub conn::container_clear { |
|
|
1318 | my ($self, $id) = @_; |
|
|
1319 | |
|
|
1320 | update_floorbox if $id == 0; |
|
|
1321 | # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; |
|
|
1322 | } |
|
|
1323 | |
|
|
1324 | sub conn::item_delete { |
|
|
1325 | my ($self, @items) = @_; |
|
|
1326 | |
|
|
1327 | for (@items) { |
|
|
1328 | update_floorbox if $_->{container} == 0; |
|
|
1329 | } |
|
|
1330 | } |
|
|
1331 | |
|
|
1332 | sub conn::item_update { |
|
|
1333 | my ($self, $item) = @_; |
|
|
1334 | |
|
|
1335 | update_floorbox if $item->{container} == 0; |
1161 | } |
1336 | } |
1162 | |
1337 | |
1163 | %SDL_CB = ( |
1338 | %SDL_CB = ( |
1164 | CFClient::SDL_QUIT => sub { |
1339 | CFClient::SDL_QUIT => sub { |
1165 | Event::unloop -1; |
1340 | Event::unloop -1; |
… | |
… | |
1200 | sdl_mode => 0, |
1375 | sdl_mode => 0, |
1201 | width => 640, |
1376 | width => 640, |
1202 | height => 480, |
1377 | height => 480, |
1203 | fullscreen => 0, |
1378 | fullscreen => 0, |
1204 | fast => 0, |
1379 | fast => 0, |
|
|
1380 | map_scale => 0.5, |
1205 | fow_enable => 1, |
1381 | fow_enable => 1, |
1206 | fow_intensity => 0.45, |
1382 | fow_intensity => 0.45, |
1207 | fow_smooth => 0, |
1383 | fow_smooth => 0, |
1208 | gui_fontsize => 1, |
1384 | gui_fontsize => 1, |
1209 | log_fontsize => 1, |
1385 | log_fontsize => 1, |