… | |
… | |
75 | |
75 | |
76 | unshift @INC, $root; |
76 | unshift @INC, $root; |
77 | } |
77 | } |
78 | } |
78 | } |
79 | |
79 | |
|
|
80 | # prepend private library directory |
|
|
81 | BEGIN { |
|
|
82 | for (grep !ref, @INC) { |
|
|
83 | my $path = "$_/Deliantra/Client/private"; |
|
|
84 | if (-d $path) { |
|
|
85 | unshift @INC, $path; |
|
|
86 | last; |
|
|
87 | } |
|
|
88 | } |
|
|
89 | } |
|
|
90 | |
80 | # need to do it again because that pile of garbage called PAR nukes it before main |
91 | # need to do it again because that pile of garbage called PAR nukes it before main |
81 | unshift @INC, $ENV{PAR_TEMP} |
92 | unshift @INC, $ENV{PAR_TEMP} |
82 | if %PAR::LibCache; |
93 | if %PAR::LibCache; |
83 | |
94 | |
84 | use Time::HiRes 'time'; |
95 | use Time::HiRes 'time'; |
… | |
… | |
86 | use List::Util qw(max min); |
97 | use List::Util qw(max min); |
87 | |
98 | |
88 | use Deliantra; |
99 | use Deliantra; |
89 | use Deliantra::Protocol::Constants; |
100 | use Deliantra::Protocol::Constants; |
90 | |
101 | |
|
|
102 | use AnyEvent::DNS; |
|
|
103 | |
91 | use Compress::LZF; |
104 | use Compress::LZF; |
92 | |
105 | |
93 | use CFPlus; |
106 | use DC; |
|
|
107 | BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$@" unless $^S } } |
94 | use CFPlus::OpenGL (); |
108 | use DC::OpenGL (); |
95 | use CFPlus::Protocol; |
109 | use DC::Protocol; |
96 | use CFPlus::DB; |
110 | use DC::DB; |
97 | use CFPlus::UI; |
111 | use DC::UI; |
98 | use CFPlus::UI::Canvas; |
112 | use DC::UI::Canvas; |
99 | use CFPlus::UI::Inventory; |
113 | use DC::UI::Inventory; |
100 | use CFPlus::UI::SpellList; |
114 | use DC::UI::SpellList; |
101 | use CFPlus::UI::Dockable; |
115 | use DC::UI::Dockable; |
|
|
116 | use DC::UI::Dockbar; |
102 | use CFPlus::UI::MessageWindow; |
117 | use DC::UI::MessageWindow; |
103 | use CFPlus::UI::ChatView; |
118 | use DC::UI::ChatView; |
|
|
119 | use DC::MessageDistributor; |
104 | use CFPlus::Pod; |
120 | use DC::Pod; |
105 | use CFPlus::MapWidget; |
121 | use DC::MapWidget; |
106 | use CFPlus::Macro; |
122 | use DC::Macro; |
107 | |
123 | |
108 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
124 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
109 | $SIG{PIPE} = 'IGNORE'; |
125 | $SIG{PIPE} = 'IGNORE'; |
110 | |
126 | |
111 | $EV::DIED = sub { |
127 | $EV::DIED = sub { |
112 | CFPlus::fatal Carp::longmess $@; |
128 | DC::fatal Carp::longmess $@; |
113 | }; |
129 | }; |
114 | |
130 | |
115 | my $MAX_FPS = 60; |
131 | my $MAX_FPS = 60; |
116 | my $MIN_FPS = 5; # unused as of yet |
|
|
117 | |
132 | |
118 | our $META_SERVER = "http://metaserver.schmorp.de/current.json"; |
133 | our $META_SERVER = "http://metaserver.schmorp.de/current.json"; |
119 | |
134 | |
120 | our $LAST_REFRESH; |
135 | our $LAST_REFRESH; |
121 | our $NOW; |
136 | our $NOW; |
… | |
… | |
168 | our $SPELL_PAGE; |
183 | our $SPELL_PAGE; |
169 | our $SPELL_LIST; |
184 | our $SPELL_LIST; |
170 | |
185 | |
171 | our $HELP_WINDOW; |
186 | our $HELP_WINDOW; |
172 | our $MESSAGE_WINDOW; |
187 | our $MESSAGE_WINDOW; |
|
|
188 | our $MESSAGE_DIST; |
173 | our $FLOORBOX; |
189 | our $FLOORBOX; |
174 | our $GAUGES; |
190 | our $GAUGES; |
175 | our $STATWIDS; |
191 | our $STATWIDS; |
176 | |
192 | |
177 | our $SDL_ACTIVE; |
193 | our $SDL_ACTIVE; |
178 | our %SDL_CB; |
194 | our %SDL_CB; |
179 | |
195 | |
180 | our $ALT_ENTER_MESSAGE; |
196 | our $ALT_ENTER_MESSAGE; |
181 | our $STATUSBOX; |
197 | our $STATUSBOX; |
|
|
198 | our $MODBOX; |
182 | our $DEBUG_STATUS; |
199 | our $DEBUG_STATUS; |
183 | |
200 | |
184 | our $INV; |
201 | our $INV; |
185 | our $INVR; |
202 | our $INVR; |
186 | our $INVR_HB; |
203 | our $INVR_HB; |
187 | |
204 | |
188 | ############################################################################# |
205 | ############################################################################# |
189 | |
206 | |
190 | sub status { |
207 | sub status { |
191 | $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
208 | $STATUSBOX->add (DC::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
192 | } |
209 | } |
193 | |
210 | |
194 | sub debug { |
211 | sub debug { |
195 | $DEBUG_STATUS->set_text ($_[0]); |
212 | $DEBUG_STATUS->set_text ($_[0]); |
196 | } |
213 | } |
197 | |
214 | |
198 | sub message { |
215 | sub message { |
199 | $MESSAGE_WINDOW->message (@_); |
216 | $MESSAGE_DIST->message (@_); |
|
|
217 | } |
|
|
218 | |
|
|
219 | sub update_modbox { |
|
|
220 | my $mod = DC::SDL_GetModState; |
|
|
221 | |
|
|
222 | my $markup; |
|
|
223 | |
|
|
224 | $markup .= $mod & DC::KMOD_CTRL |
|
|
225 | ? ($MAPWIDGET->{ctrl} ? "[REPEAT]" : "[<span foreground='#888'>REPEAT</span>]") |
|
|
226 | : "[<span foreground='#888'> once </span>]"; |
|
|
227 | |
|
|
228 | $markup .= $mod & DC::KMOD_SHIFT |
|
|
229 | ? ($MAPWIDGET->{shft} ? "[FIRE]" : "[<span foreground='#888'>FIRE</span>]") |
|
|
230 | : "[<span foreground='#888'>move</span>]"; |
|
|
231 | |
|
|
232 | $markup .= $mod & (DC::KMOD_ALT | DC::KMOD_META) |
|
|
233 | ? "[ALT]" |
|
|
234 | : "[<span foreground='#888'>alt</span>]"; |
|
|
235 | |
|
|
236 | $markup .= $mod & DC::KMOD_NUM |
|
|
237 | ? "[NUM]" |
|
|
238 | : "[<span foreground='#888'>num</span>]"; |
|
|
239 | |
|
|
240 | # <tt> around next statement works around some bug that keeps the |
|
|
241 | # "font =>" from being used on windows |
|
|
242 | $MODBOX->set_markup ("<tt>$markup</tt>"); |
200 | } |
243 | } |
201 | |
244 | |
202 | ############################################################################# |
245 | ############################################################################# |
203 | #TODO: maybe move into own audio module... |
246 | #TODO: maybe move into own audio module... |
204 | |
247 | |
… | |
… | |
234 | |
277 | |
235 | if (my $chunk = $AUDIO_CHUNK{$face}) { |
278 | if (my $chunk = $AUDIO_CHUNK{$face}) { |
236 | for (grep $_->[0] >= EV::now, @{(delete $AUDIO_PLAY{$face}) || []}) { |
279 | for (grep $_->[0] >= EV::now, @{(delete $AUDIO_PLAY{$face}) || []}) { |
237 | my (undef, $dx, $dy, $vol) = @$_; |
280 | my (undef, $dx, $dy, $vol) = @$_; |
238 | |
281 | |
239 | my $channel = CFPlus::Channel::find; |
282 | my $channel = DC::Channel::find; |
240 | $channel->volume ($vol * $CFG->{effects_volume} * 128 / 255); |
283 | $channel->volume ($vol * $CFG->{effects_volume} * 128 / 255); |
241 | $channel->set_position_r ($dx, $dy, 20); |
284 | $channel->set_position_r ($dx, $dy, 20); |
242 | $chunk->play ($channel); |
285 | $chunk->play ($channel); |
243 | } |
286 | } |
244 | } else { |
287 | } else { |
… | |
… | |
255 | push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue |
298 | push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue |
256 | &audio_music_push ($face); |
299 | &audio_music_push ($face); |
257 | } |
300 | } |
258 | } else { |
301 | } else { |
259 | # fetch from database |
302 | # fetch from database |
260 | CFPlus::DB::get res_data => $meta->{name}, sub { |
303 | DC::DB::get res_data => $meta->{name}, sub { |
261 | my $rwops = new CFPlus::RW $_[0]; |
304 | my $rwops = new DC::RW $_[0]; |
262 | my $chunk = new CFPlus::MixChunk $rwops |
305 | my $chunk = new DC::MixChunk $rwops |
263 | or Carp::confess "sound face " . (JSON::XS::encode_json $meta) . " unloadable: " . CFPlus::Mix_GetError; |
306 | or Carp::confess "sound face " . (JSON::XS::encode_json $meta) . " unloadable: " . DC::Mix_GetError; |
264 | $chunk->volume (($meta->{data}{volume} || 1) * 128); |
307 | $chunk->volume (($meta->{data}{volume} || 1) * 128); |
265 | $AUDIO_CHUNK{$face} = $chunk; |
308 | $AUDIO_CHUNK{$face} = $chunk; |
266 | |
309 | |
267 | audio_sound_push ($face); |
310 | audio_sound_push ($face); |
268 | }; |
311 | }; |
… | |
… | |
287 | sub audio_music_set_meta { |
330 | sub audio_music_set_meta { |
288 | my ($meta) = @_; |
331 | my ($meta) = @_; |
289 | |
332 | |
290 | $MUSIC_PLAYING_META = $meta; |
333 | $MUSIC_PLAYING_META = $meta; |
291 | $MUSIC_PLAYING_WIDGET->set_markup ( |
334 | $MUSIC_PLAYING_WIDGET->set_markup ( |
292 | "<b>Name</b>: " . (CFPlus::asxml $meta->{data}{name}) . "\n" |
335 | "<b>Name</b>: " . (DC::asxml $meta->{data}{name}) . "\n" |
293 | . "<b>Author</b>: " . (CFPlus::asxml $meta->{data}{author}) . "\n" |
336 | . "<b>Author</b>: " . (DC::asxml $meta->{data}{author}) . "\n" |
294 | . "<b>Source</b>: " . (CFPlus::asxml $meta->{data}{source}) . "\n" |
337 | . "<b>Source</b>: " . (DC::asxml $meta->{data}{source}) . "\n" |
295 | . "<b>License</b>: " . (CFPlus::asxml $meta->{data}{license}) |
338 | . "<b>License</b>: " . (DC::asxml $meta->{data}{license}) |
296 | ); |
339 | ); |
297 | } |
340 | } |
298 | |
341 | |
299 | sub audio_music_update_volume { |
342 | sub audio_music_update_volume { |
300 | return unless $MUSIC_PLAYING_META; |
343 | return unless $MUSIC_PLAYING_META; |
301 | my $volume = $MUSIC_PLAYING_META->{data}{volume} || 1; |
344 | my $volume = $MUSIC_PLAYING_META->{data}{volume} || 1; |
302 | my $base = $MUSIC_PLAYING_META->{data}{jingle} ? 1 : $CFG->{bgm_volume}; |
345 | my $base = $MUSIC_PLAYING_META->{data}{jingle} ? 1 : $CFG->{bgm_volume}; |
303 | CFPlus::MixMusic::volume $base * $volume * 128; |
346 | DC::MixMusic::volume $base * $volume * 128; |
304 | } |
347 | } |
305 | |
348 | |
306 | sub audio_music_start { |
349 | sub audio_music_start { |
307 | my $meta = $MUSIC_PLAYING_META; |
350 | my $meta = $MUSIC_PLAYING_META; |
308 | |
351 | |
309 | CFPlus::DB::get res_data => $meta->{name}, sub { |
352 | DC::DB::get res_data => $meta->{name}, sub { |
310 | return unless $SDL_MIXER; |
353 | return unless $SDL_MIXER; |
311 | |
354 | |
312 | # music might have changed... |
355 | # music might have changed... |
313 | $meta eq $MUSIC_PLAYING_META |
356 | $meta eq $MUSIC_PLAYING_META |
314 | or return &audio_music_start (); |
357 | or return &audio_music_start (); |
… | |
… | |
316 | audio_music_update_volume; |
359 | audio_music_update_volume; |
317 | |
360 | |
318 | $MUSIC_PLAYING_DATA = \$_[0]; |
361 | $MUSIC_PLAYING_DATA = \$_[0]; |
319 | |
362 | |
320 | my $rwops = $meta->{path} |
363 | my $rwops = $meta->{path} |
321 | ? new_from_file CFPlus::RW $meta->{path} |
364 | ? new_from_file DC::RW $meta->{path} |
322 | : new CFPlus::RW $$MUSIC_PLAYING_DATA; |
365 | : new DC::RW $$MUSIC_PLAYING_DATA; |
323 | |
366 | |
324 | $MUSIC_PLAYER = new CFPlus::MixMusic $rwops |
367 | $MUSIC_PLAYER = new DC::MixMusic $rwops |
325 | or Carp::confess "music face $meta->{face} unloadable: " . CFPlus::Mix_GetError; |
368 | or Carp::confess "music face $meta->{face} unloadable: " . DC::Mix_GetError; |
326 | |
369 | |
327 | my $NOW = time; |
370 | my $NOW = time; |
328 | |
371 | |
329 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
372 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
330 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |
373 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |
… | |
… | |
361 | |
404 | |
362 | # randomize music a bit so that the order is not always the same |
405 | # randomize music a bit so that the order is not always the same |
363 | $_->{stop_time} ||= rand for @MUSIC_HAVE; |
406 | $_->{stop_time} ||= rand for @MUSIC_HAVE; |
364 | |
407 | |
365 | # default MUSIC_HAVE == MUSIC_DEFAULT |
408 | # default MUSIC_HAVE == MUSIC_DEFAULT |
366 | @MUSIC_HAVE = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } |
409 | @MUSIC_HAVE = { path => DC::find_rcfile "music/$MUSIC_DEFAULT" } |
367 | unless @MUSIC_HAVE; |
410 | unless @MUSIC_HAVE; |
368 | } |
411 | } |
369 | |
412 | |
370 | # if the currently playing song is acceptable, let it continue |
413 | # if the currently playing song is acceptable, let it continue |
371 | return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE; |
414 | return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE; |
… | |
… | |
373 | my $NOW = time; |
416 | my $NOW = time; |
374 | |
417 | |
375 | if ($MUSIC_PLAYING_META) { |
418 | if ($MUSIC_PLAYING_META) { |
376 | $MUSIC_PLAYING_META->{stop_time} = $NOW; |
419 | $MUSIC_PLAYING_META->{stop_time} = $NOW; |
377 | $MUSIC_PLAYING_META->{stop_pos} = $NOW - $MUSIC_START; |
420 | $MUSIC_PLAYING_META->{stop_pos} = $NOW - $MUSIC_START; |
378 | CFPlus::MixMusic::fade_out $fade_out; |
421 | DC::MixMusic::fade_out $fade_out; |
379 | } else { |
422 | } else { |
380 | # sort by stop time, oldest first |
423 | # sort by stop time, oldest first |
381 | @MUSIC_HAVE = sort { $a->{stop_time} <=> $b->{stop_time} } @MUSIC_HAVE; |
424 | @MUSIC_HAVE = sort { $a->{stop_time} <=> $b->{stop_time} } @MUSIC_HAVE; |
382 | |
425 | |
383 | # if the most recently-played piece played very recently, |
426 | # if the most recently-played piece played very recently, |
… | |
… | |
417 | } |
460 | } |
418 | |
461 | |
419 | sub audio_init { |
462 | sub audio_init { |
420 | if ($CFG->{audio_enable}) { |
463 | if ($CFG->{audio_enable}) { |
421 | $ENV{MIX_EFFECTSMAXSPEED} = 1; |
464 | $ENV{MIX_EFFECTSMAXSPEED} = 1; |
422 | $SDL_MIXER = !CFPlus::Mix_OpenAudio |
465 | $SDL_MIXER = !DC::Mix_OpenAudio |
423 | $CFG->{audio_hw_frequency}, |
466 | $CFG->{audio_hw_frequency}, |
424 | CFPlus::MIX_DEFAULT_FORMAT, |
467 | DC::MIX_DEFAULT_FORMAT, |
425 | $CFG->{audio_hw_channels}, |
468 | $CFG->{audio_hw_channels}, |
426 | $CFG->{audio_hw_chunksize}; |
469 | $CFG->{audio_hw_chunksize}; |
427 | |
470 | |
428 | if ($SDL_MIXER) { |
471 | if ($SDL_MIXER) { |
429 | CFPlus::Mix_AllocateChannels $CFG->{audio_mix_channels}; |
472 | DC::Mix_AllocateChannels $CFG->{audio_mix_channels}; |
430 | |
473 | |
431 | audio_music_finished; |
474 | audio_music_finished; |
432 | } else { |
475 | } else { |
433 | status "Unable to open sound device: there will be no sound"; |
476 | status "Unable to open sound device: there will be no sound"; |
434 | } |
477 | } |
… | |
… | |
448 | $MUSIC_WANT = []; |
491 | $MUSIC_WANT = []; |
449 | @MUSIC_JINGLE = (); |
492 | @MUSIC_JINGLE = (); |
450 | %AUDIO_PLAY = (); |
493 | %AUDIO_PLAY = (); |
451 | %AUDIO_CHUNK = (); |
494 | %AUDIO_CHUNK = (); |
452 | |
495 | |
453 | CFPlus::Mix_CloseAudio if $SDL_MIXER; |
496 | DC::Mix_CloseAudio if $SDL_MIXER; |
454 | undef $SDL_MIXER; |
497 | undef $SDL_MIXER; |
455 | } |
498 | } |
456 | |
499 | |
457 | ############################################################################# |
500 | ############################################################################# |
458 | |
501 | |
… | |
… | |
478 | |
521 | |
479 | return; |
522 | return; |
480 | } |
523 | } |
481 | } |
524 | } |
482 | |
525 | |
483 | $conn->{query_dialog} = my $dialog = new CFPlus::UI::Toplevel |
526 | $conn->{query_dialog} = my $dialog = new DC::UI::Toplevel |
484 | x => "center", |
527 | x => "center", |
485 | y => "center", |
528 | y => "center", |
486 | title => "Server Query", |
529 | title => "Server Query", |
487 | child => my $vbox = new CFPlus::UI::VBox, |
530 | child => my $vbox = new DC::UI::VBox, |
488 | ; |
531 | ; |
489 | |
532 | |
490 | my @dialog = my $label = new CFPlus::UI::Label |
533 | my @dialog = my $label = new DC::UI::Label |
491 | max_w => $::WIDTH * 0.8, |
534 | max_w => $::WIDTH * 0.8, |
492 | ellipsise => 0, |
535 | ellipsise => 0, |
493 | text => $prompt; |
536 | text => $prompt; |
494 | |
537 | |
495 | if ($flags & CS_QUERY_YESNO) { |
538 | if ($flags & CS_QUERY_YESNO) { |
496 | push @dialog, my $hbox = new CFPlus::UI::HBox; |
539 | push @dialog, my $hbox = new DC::UI::HBox; |
497 | |
540 | |
498 | $hbox->add (new CFPlus::UI::Button |
541 | $hbox->add (new DC::UI::Button |
499 | text => "No", |
542 | text => "No", |
500 | on_activate => sub { |
543 | on_activate => sub { |
501 | $conn->send ("reply n"); |
544 | $conn->send ("reply n"); |
502 | $dialog->destroy; |
545 | $dialog->destroy; |
503 | 0 |
546 | 0 |
504 | } |
547 | } |
505 | ); |
548 | ); |
506 | $hbox->add (new CFPlus::UI::Button |
549 | $hbox->add (new DC::UI::Button |
507 | text => "Yes", |
550 | text => "Yes", |
508 | on_activate => sub { |
551 | on_activate => sub { |
509 | $conn->send ("reply y"); |
552 | $conn->send ("reply y"); |
510 | destroy_query_dialog $conn; |
553 | destroy_query_dialog $conn; |
511 | 0 |
554 | 0 |
… | |
… | |
516 | |
559 | |
517 | } elsif ($flags & CS_QUERY_SINGLECHAR) { |
560 | } elsif ($flags & CS_QUERY_SINGLECHAR) { |
518 | if ($prompt =~ /Now choose a character|Press any key for the next race/i) { |
561 | if ($prompt =~ /Now choose a character|Press any key for the next race/i) { |
519 | $dialog->{tooltip} = "#charcreation_focus"; |
562 | $dialog->{tooltip} = "#charcreation_focus"; |
520 | |
563 | |
521 | unshift @dialog, new CFPlus::UI::Label |
564 | unshift @dialog, new DC::UI::Label |
522 | max_w => $::WIDTH * 0.8, |
565 | max_w => $::WIDTH * 0.8, |
523 | ellipsise => 0, |
566 | ellipsise => 0, |
524 | markup => "\nOr use your keyboard and the text entry below:\n"; |
567 | markup => "\nOr use your keyboard and the text entry below:\n"; |
525 | |
568 | |
526 | unshift @dialog, my $table = new CFPlus::UI::Table; |
569 | unshift @dialog, my $table = new DC::UI::Table; |
527 | |
570 | |
528 | $table->add_at (0, 0, new CFPlus::UI::Button |
571 | $table->add_at (0, 0, new DC::UI::Button |
529 | text => "Next Race", |
572 | text => "Next Race", |
530 | on_activate => sub { |
573 | on_activate => sub { |
531 | $conn->send ("reply n"); |
574 | $conn->send ("reply n"); |
532 | destroy_query_dialog $conn; |
575 | destroy_query_dialog $conn; |
533 | 0 |
576 | 0 |
534 | }, |
577 | }, |
535 | ); |
578 | ); |
536 | $table->add_at (2, 0, new CFPlus::UI::Button |
579 | $table->add_at (2, 0, new DC::UI::Button |
537 | text => "Accept", |
580 | text => "Accept", |
538 | on_activate => sub { |
581 | on_activate => sub { |
539 | $conn->send ("reply d"); |
582 | $conn->send ("reply d"); |
540 | destroy_query_dialog $conn; |
583 | destroy_query_dialog $conn; |
541 | 0 |
584 | 0 |
542 | }, |
585 | }, |
543 | ); |
586 | ); |
544 | |
587 | |
545 | if ($conn->{chargen_race_description}) { |
588 | if ($conn->{chargen_race_description}) { |
546 | unshift @dialog, new CFPlus::UI::Label |
589 | unshift @dialog, new DC::UI::Label |
547 | max_w => $::WIDTH * 0.8, |
590 | max_w => $::WIDTH * 0.8, |
548 | ellipsise => 0, |
591 | ellipsise => 0, |
549 | markup => "<span foreground='#ccccff'>$conn->{chargen_race_description}</span>", |
592 | markup => "<span foreground='#ccccff'>$conn->{chargen_race_description}</span>", |
550 | ; |
593 | ; |
551 | } |
594 | } |
552 | |
595 | |
553 | unshift @dialog, new CFPlus::UI::Face |
596 | unshift @dialog, new DC::UI::Face |
554 | face => $conn->{player}{face}, |
597 | face => $conn->{player}{face}, |
555 | bg => [.2, .2, .2, 1], |
598 | bg => [.2, .2, .2, 1], |
556 | min_w => 64, |
599 | min_w => 64, |
557 | min_h => 64, |
600 | min_h => 64, |
558 | ; |
601 | ; |
559 | |
602 | |
560 | if ($conn->{chargen_race_title}) { |
603 | if ($conn->{chargen_race_title}) { |
561 | unshift @dialog, new CFPlus::UI::Label |
604 | unshift @dialog, new DC::UI::Label |
562 | allign => 1, |
605 | allign => 1, |
563 | ellipsise => 0, |
606 | ellipsise => 0, |
564 | markup => "<span foreground='#ccccff' size='large'>Race: $conn->{chargen_race_title}</span>", |
607 | markup => "<span foreground='#ccccff' size='large'>Race: $conn->{chargen_race_title}</span>", |
565 | ; |
608 | ; |
566 | } |
609 | } |
567 | |
610 | |
568 | unshift @dialog, new CFPlus::UI::Label |
611 | unshift @dialog, new DC::UI::Label |
569 | max_w => $::WIDTH * 0.4, |
612 | max_w => $::WIDTH * 0.4, |
570 | ellipsise => 0, |
613 | ellipsise => 0, |
571 | markup => (CFPlus::Pod::section_label ui => "chargen_race"), |
614 | markup => (DC::Pod::section_label ui => "chargen_race"), |
572 | ; |
615 | ; |
573 | |
616 | |
574 | } elsif ($prompt =~ /roll new stats/) { |
617 | } elsif ($prompt =~ /roll new stats/) { |
575 | if (my $stat = delete $conn->{stat_change_with}) { |
618 | if (my $stat = delete $conn->{stat_change_with}) { |
576 | $conn->send ("reply $stat"); |
619 | $conn->send ("reply $stat"); |
577 | destroy_query_dialog $conn; |
620 | destroy_query_dialog $conn; |
578 | return; |
621 | return; |
579 | } |
622 | } |
580 | |
623 | |
581 | unshift @dialog, new CFPlus::UI::Label |
624 | unshift @dialog, new DC::UI::Label |
582 | max_w => $::WIDTH * 0.4, |
625 | max_w => $::WIDTH * 0.4, |
583 | ellipsise => 0, |
626 | ellipsise => 0, |
584 | markup => "\nOr use your keyboard and the text entry below:\n"; |
627 | markup => "\nOr use your keyboard and the text entry below:\n"; |
585 | |
628 | |
586 | unshift @dialog, my $table = new CFPlus::UI::Table; |
629 | unshift @dialog, my $table = new DC::UI::Table; |
587 | |
630 | |
588 | # left: re-roll |
631 | # left: re-roll |
589 | $table->add_at (0, 0, new CFPlus::UI::Button |
632 | $table->add_at (0, 0, new DC::UI::Button |
590 | text => "Roll Again", |
633 | text => "Roll Again", |
591 | on_activate => sub { |
634 | on_activate => sub { |
592 | $conn->send ("reply y"); |
635 | $conn->send ("reply y"); |
593 | destroy_query_dialog $conn; |
636 | destroy_query_dialog $conn; |
594 | 0 |
637 | 0 |
595 | }, |
638 | }, |
596 | ); |
639 | ); |
597 | |
640 | |
598 | # center: swap stats |
641 | # center: swap stats |
599 | my ($sw1, $sw2) = map +(new CFPlus::UI::Selector |
642 | my ($sw1, $sw2) = map +(new DC::UI::Selector |
600 | expand => 1, |
643 | expand => 1, |
601 | value => $_, |
644 | value => $_, |
602 | options => [ |
645 | options => [ |
603 | [1 => "Str", "Strength ($conn->{stat}{+CS_STAT_STR})"], |
646 | [1 => "Str", "Strength ($conn->{stat}{+CS_STAT_STR})"], |
604 | [2 => "Dex", "Dexterity ($conn->{stat}{+CS_STAT_DEX})"], |
647 | [2 => "Dex", "Dexterity ($conn->{stat}{+CS_STAT_DEX})"], |
… | |
… | |
608 | [6 => "Pow", "Power ($conn->{stat}{+CS_STAT_POW})"], |
651 | [6 => "Pow", "Power ($conn->{stat}{+CS_STAT_POW})"], |
609 | [7 => "Cha", "Charisma ($conn->{stat}{+CS_STAT_CHA})"], |
652 | [7 => "Cha", "Charisma ($conn->{stat}{+CS_STAT_CHA})"], |
610 | ], |
653 | ], |
611 | ), 1 .. 2; |
654 | ), 1 .. 2; |
612 | |
655 | |
613 | $table->add_at (2, 0, new CFPlus::UI::Button |
656 | $table->add_at (2, 0, new DC::UI::Button |
614 | text => "Swap Stats", |
657 | text => "Swap Stats", |
615 | on_activate => sub { |
658 | on_activate => sub { |
616 | $conn->{stat_change_with} = $sw2->{value}; |
659 | $conn->{stat_change_with} = $sw2->{value}; |
617 | $conn->send ("reply $sw1->{value}"); |
660 | $conn->send ("reply $sw1->{value}"); |
618 | destroy_query_dialog $conn; |
661 | destroy_query_dialog $conn; |
619 | 0 |
662 | 0 |
620 | }, |
663 | }, |
621 | ); |
664 | ); |
622 | $table->add_at (2, 1, new CFPlus::UI::HBox children => [$sw1, $sw2]); |
665 | $table->add_at (2, 1, new DC::UI::HBox children => [$sw1, $sw2]); |
623 | |
666 | |
624 | # right: accept |
667 | # right: accept |
625 | $table->add_at (4, 0, new CFPlus::UI::Button |
668 | $table->add_at (4, 0, new DC::UI::Button |
626 | text => "Accept", |
669 | text => "Accept", |
627 | on_activate => sub { |
670 | on_activate => sub { |
628 | $conn->send ("reply n"); |
671 | $conn->send ("reply n"); |
629 | $STATS_PAGE->hide; |
|
|
630 | destroy_query_dialog $conn; |
672 | destroy_query_dialog $conn; |
631 | 0 |
673 | 0 |
632 | }, |
674 | }, |
633 | ); |
675 | ); |
634 | |
676 | |
635 | unshift @dialog, my $hbox = new CFPlus::UI::HBox; |
677 | unshift @dialog, my $hbox = new DC::UI::HBox; |
636 | for ( |
678 | for ( |
637 | [Str => CS_STAT_STR], |
679 | [Str => CS_STAT_STR], |
638 | [Dex => CS_STAT_DEX], |
680 | [Dex => CS_STAT_DEX], |
639 | [Con => CS_STAT_CON], |
681 | [Con => CS_STAT_CON], |
640 | [Int => CS_STAT_INT], |
682 | [Int => CS_STAT_INT], |
641 | [Wis => CS_STAT_WIS], |
683 | [Wis => CS_STAT_WIS], |
642 | [Pow => CS_STAT_POW], |
684 | [Pow => CS_STAT_POW], |
643 | [Cha => CS_STAT_CHA], |
685 | [Cha => CS_STAT_CHA], |
644 | ) { |
686 | ) { |
645 | my ($name, $id) = @$_; |
687 | my ($name, $id) = @$_; |
646 | $hbox->add (new CFPlus::UI::Label |
688 | $hbox->add (new DC::UI::Label |
647 | markup => "$conn->{stat}{$id} <span foreground='yellow'>$name</span>", |
689 | markup => "$conn->{stat}{$id} <span foreground='yellow'>$name</span>", |
648 | align => 0, |
|
|
649 | expand => 1, |
690 | expand => 1, |
650 | can_events => 1, |
691 | can_events => 1, |
651 | can_hover => 1, |
692 | can_hover => 1, |
652 | tooltip => "#stat_$name", |
693 | tooltip => "#stat_$name", |
653 | ); |
694 | ); |
654 | } |
695 | } |
655 | |
696 | |
656 | unshift @dialog, new CFPlus::UI::Label |
697 | unshift @dialog, new DC::UI::Label |
657 | max_w => $::WIDTH * 0.4, |
698 | max_w => $::WIDTH * 0.4, |
658 | ellipsise => 0, |
699 | ellipsise => 0, |
659 | markup => (CFPlus::Pod::section_label ui => "chargen_stats"), |
700 | markup => (DC::Pod::section_label ui => "chargen_stats"), |
660 | ; |
701 | ; |
661 | } |
702 | } |
662 | |
703 | |
663 | push @dialog, my $entry = new CFPlus::UI::Entry |
704 | push @dialog, my $entry = new DC::UI::Entry |
664 | on_changed => sub { |
705 | on_changed => sub { |
665 | $conn->send ("reply $_[1]"); |
706 | $conn->send ("reply $_[1]"); |
666 | destroy_query_dialog $conn; |
707 | destroy_query_dialog $conn; |
667 | 0 |
708 | 0 |
668 | }, |
709 | }, |
… | |
… | |
671 | $entry->grab_focus; |
712 | $entry->grab_focus; |
672 | |
713 | |
673 | } else { |
714 | } else { |
674 | $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; |
715 | $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; |
675 | |
716 | |
676 | push @dialog, my $entry = new CFPlus::UI::Entry |
717 | push @dialog, my $entry = new DC::UI::Entry |
677 | $flags & CS_QUERY_HIDEINPUT ? (hidden => "*") : (), |
718 | $flags & CS_QUERY_HIDEINPUT ? (hidden => "*") : (), |
678 | on_activate => sub { |
719 | on_activate => sub { |
679 | $conn->send ("reply $_[1]"); |
720 | $conn->send ("reply $_[1]"); |
680 | destroy_query_dialog $conn; |
721 | destroy_query_dialog $conn; |
681 | 0 |
722 | 0 |
… | |
… | |
687 | |
728 | |
688 | $vbox->add (@dialog); |
729 | $vbox->add (@dialog); |
689 | $dialog->show; |
730 | $dialog->show; |
690 | } |
731 | } |
691 | |
732 | |
692 | sub start_game { |
733 | sub dc_connect { |
693 | status "logging in..."; |
734 | my ($host, $port) = @_; |
694 | |
|
|
695 | $LOGIN_BUTTON->set_text ("Logout"); |
|
|
696 | $SETUP_DIALOG->hide; |
|
|
697 | |
735 | |
698 | my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
736 | my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
699 | |
737 | |
700 | my ($host, $port) = split /:/, $PROFILE->{host}; |
|
|
701 | |
|
|
702 | $MAP = new CFPlus::Map; |
|
|
703 | |
|
|
704 | $CONN = eval { |
738 | $CONN = |
705 | new CFPlus::Protocol |
739 | new DC::Protocol |
706 | host => $host, |
740 | host => $host, |
707 | port => $port || 13327, |
741 | port => $port || 13327, |
708 | user => $PROFILE->{user}, |
742 | user => $PROFILE->{user}, |
709 | pass => $PROFILE->{password}, |
743 | pass => $PROFILE->{password}, |
710 | mapw => $mapsize, |
744 | mapw => $mapsize, |
711 | maph => $mapsize, |
745 | maph => $mapsize, |
712 | |
746 | |
713 | client => "cfplus $CFPlus::VERSION $] $^O", |
747 | client => "$DC::VERSION $] $^O", |
714 | |
748 | |
715 | map_widget => $MAPWIDGET, |
749 | map_widget => $MAPWIDGET, |
716 | statusbox => $STATUSBOX, |
750 | statusbox => $STATUSBOX, |
717 | map => $MAP, |
751 | map => $MAP, |
718 | mapmap => $MAPMAP, |
752 | mapmap => $MAPMAP, |
719 | query => \&server_query, |
753 | query => \&server_query, |
720 | |
754 | |
721 | setup_req => { |
755 | setup_req => { |
722 | smoothing => $CFG->{map_smoothing}*1, |
756 | smoothing => $CFG->{map_smoothing}*1, |
723 | }, |
757 | }, |
|
|
758 | |
|
|
759 | on_connect => sub { |
|
|
760 | if ($_[0]) { |
|
|
761 | DC::lowdelay fileno $CONN->{fh}; |
|
|
762 | |
|
|
763 | status "login successful"; |
|
|
764 | } else { |
|
|
765 | undef $CONN; |
|
|
766 | status "unable to connect: $!"; |
|
|
767 | stop_game(); |
|
|
768 | } |
|
|
769 | }, |
724 | }; |
770 | ; |
|
|
771 | } |
725 | |
772 | |
726 | if ($CONN) { |
773 | sub start_game { |
727 | CFPlus::lowdelay fileno $CONN->{fh}; |
774 | status "logging in..."; |
728 | |
775 | |
729 | status "login successful"; |
776 | $LOGIN_BUTTON->set_text ("Logout"); |
|
|
777 | $SETUP_DIALOG->hide; |
|
|
778 | |
|
|
779 | my ($host, $port) = split /:/, $PROFILE->{host}; |
|
|
780 | |
|
|
781 | $MAP = new DC::Map; |
|
|
782 | |
|
|
783 | # hack to make SURE we find the IP address all right |
|
|
784 | # can be removed once AnyEvent::DNS is proven stable. |
|
|
785 | if ($host eq "gameserver.deliantra.net") { |
|
|
786 | AnyEvent::DNS::a "dnstest.deliantra.net", sub { |
|
|
787 | if ($_[0] ne "80.101.114.108") { # Perl |
|
|
788 | status "dns failure, using hardcoded address"; |
|
|
789 | $host = "129.13.162.95"; |
|
|
790 | } |
|
|
791 | |
|
|
792 | dc_connect $host, $port; |
|
|
793 | }; |
730 | } else { |
794 | } else { |
731 | status "unable to connect"; |
795 | dc_connect $host, $port; |
732 | stop_game(); |
|
|
733 | } |
796 | } |
734 | } |
797 | } |
735 | |
798 | |
736 | sub stop_game { |
799 | sub stop_game { |
737 | $LOGIN_BUTTON->set_text ("Login / Register"); |
800 | $LOGIN_BUTTON->set_text ("Login / Register"); |
738 | $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN); |
801 | $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN); |
739 | $SETUP_DIALOG->show; |
802 | $SETUP_DIALOG->show; |
740 | $PL_WINDOW->hide; |
803 | $PL_WINDOW->hide; |
741 | $SPELL_LIST->clear_spells; |
804 | $SPELL_LIST->clear_spells; |
742 | $CFPlus::UI::ROOT->emit (stop_game => ! ! $CONN); |
805 | $DC::UI::ROOT->emit (stop_game => ! ! $CONN); |
743 | |
806 | |
744 | &audio_music_set_ambient ([]); |
807 | &audio_music_set_ambient ([]); |
745 | |
808 | |
746 | return unless $CONN; |
809 | return unless $CONN; |
747 | |
810 | |
… | |
… | |
753 | |
816 | |
754 | undef $MAP; |
817 | undef $MAP; |
755 | } |
818 | } |
756 | |
819 | |
757 | sub graphics_setup { |
820 | sub graphics_setup { |
758 | my $vbox = new CFPlus::UI::VBox; |
821 | my $vbox = new DC::UI::VBox; |
759 | |
822 | |
760 | $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]); |
823 | $vbox->add (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]); |
761 | |
824 | |
762 | my $row = 0; |
825 | my $row = 0; |
763 | |
826 | |
764 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "OpenGL Info"); |
827 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "OpenGL Info"); |
765 | $table->add_at (1, $row++, new CFPlus::UI::Label valign => 0, fontsize => 0.8, text => CFPlus::OpenGL::gl_vendor . ", " . CFPlus::OpenGL::gl_version, |
828 | $table->add_at (1, $row++, new DC::UI::Label fontsize => 0.8, text => DC::OpenGL::gl_vendor . ", " . DC::OpenGL::gl_version, |
766 | can_events => 1, |
829 | can_events => 1, |
767 | tooltip => "<tt><span size='8192'>" . (CFPlus::OpenGL::gl_extensions) . "</span></tt>"); |
830 | tooltip => "<tt><span size='8192'>" . (DC::OpenGL::gl_extensions) . "</span></tt>"); |
768 | |
831 | |
769 | my $vidmode_tooltip = |
832 | my $vidmode_tooltip = |
770 | "<b>Video Mode.</b> The video mode to use for fullscreen (and the window size for windowed operation). " |
833 | "<b>Video Mode.</b> The video mode to use for fullscreen (and the window size for windowed operation). " |
771 | . "The format is <i>width</i> x <i>height</i> \@ <i>depth-per-channel</i> + <i>alpha-channel</i>."; |
834 | . "The format is <i>width</i> x <i>height</i> \@ <i>depth-per-channel</i> + <i>alpha-channel</i>."; |
772 | |
835 | |
773 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Video Mode"); |
836 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Video Mode"); |
774 | $table->add_at (1, $row++, my $hbox = new CFPlus::UI::HBox); |
837 | $table->add_at (1, $row++, my $hbox = new DC::UI::HBox); |
775 | |
838 | |
776 | $hbox->add (my $mode_slider = new CFPlus::UI::Slider |
839 | $hbox->add (my $mode_slider = new DC::UI::Slider |
777 | force_w => $WIDTH * 0.1, expand => 1, range => [$CFG->{sdl_mode}, 0, $#SDL_MODES, 0, 1], |
840 | force_w => $WIDTH * 0.1, expand => 1, range => [$CFG->{sdl_mode}, 0, $#SDL_MODES, 0, 1], |
778 | tooltip => $vidmode_tooltip); |
841 | tooltip => $vidmode_tooltip); |
779 | $hbox->add (my $mode_label = new CFPlus::UI::Label |
842 | $hbox->add (my $mode_label = new DC::UI::Label |
780 | align => 0, valign => 0, height => 0.8, template => "9999x9999@9+9", |
843 | height => 0.8, template => "9999x9999@9+9", |
781 | can_events => 1, tooltip => $vidmode_tooltip); |
844 | can_events => 1, tooltip => $vidmode_tooltip); |
782 | |
845 | |
783 | $mode_slider->connect (changed => sub { |
846 | $mode_slider->connect (changed => sub { |
784 | my ($self, $value) = @_; |
847 | my ($self, $value) = @_; |
785 | |
848 | |
786 | $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; |
849 | $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; |
787 | $mode_label->set_text (sprintf '%dx%d@%d+%d', @{$SDL_MODES[$value]}); |
850 | $mode_label->set_text (sprintf '%dx%d@%d+%d', @{$SDL_MODES[$value]}); |
788 | }); |
851 | }); |
789 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
852 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
790 | |
853 | |
791 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fullscreen"); |
854 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fullscreen"); |
792 | $table->add_at (1, $row++, $FULLSCREEN_ENABLE = new CFPlus::UI::CheckBox |
855 | $table->add_at (1, $row++, $FULLSCREEN_ENABLE = new DC::UI::CheckBox |
793 | state => $CFG->{fullscreen}, |
856 | state => $CFG->{fullscreen}, |
794 | tooltip => "Bring the client into fullscreen mode.", |
857 | tooltip => "Bring the client into fullscreen mode.", |
795 | on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } |
858 | on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } |
796 | ); |
859 | ); |
797 | |
860 | |
798 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Force OpenGL 1.1"); |
861 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Force OpenGL 1.1"); |
799 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
862 | $table->add_at (1, $row++, new DC::UI::CheckBox |
800 | state => $CFG->{force_opengl11}, |
863 | state => $CFG->{force_opengl11}, |
801 | tooltip => "Limit CFPlus to use OpenGL 1.1 features only. This will normally result in " |
864 | tooltip => "Limit Deliantra to use OpenGL 1.1 features only. This will normally result in " |
802 | . "higher memory usage and slower performance. It will, however, help tremendously on " |
865 | . "higher memory usage and slower performance. It will, however, help tremendously on " |
803 | . "cards that claim to support a feature but fall back to software rendering. " |
866 | . "cards that claim to support a feature but fall back to software rendering. " |
804 | . "Nvidia Geforce FX cards are known to claim features the hardware doesn't support, " |
867 | . "Nvidia Geforce FX cards are known to claim features the hardware doesn't support, " |
805 | . "but cards and drivers from other vendors (ATI) are often just as bad. <b>If you " |
868 | . "but cards and drivers from other vendors (ATI) are often just as bad. <b>If you " |
806 | . "experience extremely low framerates and your card should do better, try this option.</b>", |
869 | . "experience extremely low framerates and your card should do better, try this option.</b>", |
807 | on_changed => sub { my ($self, $value) = @_; $CFG->{force_opengl11} = $value; 0 } |
870 | on_changed => sub { my ($self, $value) = @_; $CFG->{force_opengl11} = $value; 0 } |
808 | ); |
871 | ); |
809 | |
872 | |
810 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Compress Textures"); |
873 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Compress Textures"); |
811 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
874 | $table->add_at (1, $row++, new DC::UI::CheckBox |
812 | state => $CFG->{texture_compression}, |
875 | state => $CFG->{texture_compression}, |
813 | tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but " |
876 | tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but " |
814 | . "will save a lot of memory and increase performance. The compression algorithm " |
877 | . "will save a lot of memory and increase performance. The compression algorithm " |
815 | . "can differ form card to card, so your mileage may vary. This setting is ignored in " |
878 | . "can differ form card to card, so your mileage may vary. This setting is ignored in " |
816 | . "forced OpenGL 1.1 mode.", |
879 | . "forced OpenGL 1.1 mode.", |
817 | on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 } |
880 | on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 } |
818 | ); |
881 | ); |
819 | |
882 | |
820 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); |
883 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fast & Ugly"); |
821 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
884 | $table->add_at (1, $row++, new DC::UI::CheckBox |
822 | state => $CFG->{fast}, |
885 | state => $CFG->{fast}, |
823 | tooltip => "Lower the visual quality considerably to speed up rendering.", |
886 | tooltip => "Lower the visual quality considerably to speed up rendering.", |
824 | on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 } |
887 | on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 } |
825 | ); |
888 | ); |
826 | |
889 | |
827 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "GUI Fontsize"); |
890 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "GUI Fontsize"); |
828 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
891 | $table->add_at (1, $row++, new DC::UI::Slider |
829 | range => [$CFG->{gui_fontsize}, 0.5, 2, 0, 0.1], |
892 | range => [$CFG->{gui_fontsize}, 0.5, 2, 0, 0.1], |
830 | tooltip => "The base font size used by most GUI elements that do not have their own setting.", |
893 | tooltip => "The base font size used by most GUI elements that do not have their own setting.", |
831 | on_changed => sub { $CFG->{gui_fontsize} = $_[1]; 0 }, |
894 | on_changed => sub { $CFG->{gui_fontsize} = $_[1]; 0 }, |
832 | ); |
895 | ); |
833 | |
896 | |
834 | $table->add_at (1, $row++, new CFPlus::UI::Button |
897 | $table->add_at (1, $row++, new DC::UI::Button |
835 | expand => 1, align => 0, text => "Apply", |
898 | expand => 1, text => "Apply", |
836 | tooltip => "Apply the video settings above.", |
899 | tooltip => "Apply the video settings above.", |
837 | on_activate => sub { |
900 | on_activate => sub { |
838 | video_shutdown (); |
901 | video_shutdown (); |
839 | video_init (); |
902 | video_init (); |
840 | 0 |
903 | 0 |
841 | } |
904 | } |
842 | ); |
905 | ); |
843 | |
906 | |
844 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Scale"); |
907 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Map Scale"); |
845 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
908 | $table->add_at (1, $row++, new DC::UI::Slider |
846 | range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], |
909 | range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], |
847 | tooltip => "Enlarge or shrink the displayed map. Changes are instant.", |
910 | tooltip => "Enlarge or shrink the displayed map. Changes are instant.", |
848 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 } |
911 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 } |
849 | ); |
912 | ); |
850 | |
913 | |
851 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Smoothing"); |
914 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Map Smoothing"); |
852 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
915 | $table->add_at (1, $row++, new DC::UI::CheckBox |
853 | state => $CFG->{map_smoothing}, |
916 | state => $CFG->{map_smoothing}, |
854 | tooltip => "<b>Map Smoothing</b> tries to make tile borders less square. " |
917 | tooltip => "<b>Map Smoothing</b> tries to make tile borders less square. " |
855 | . "This increases load on the graphics subsystem and works only with TRT servers. " |
918 | . "This increases load on the graphics subsystem and works only with TRT servers. " |
856 | . "Changes take effect at next login only.", |
919 | . "Changes take effect at next login only.", |
857 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 } |
920 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 } |
858 | ); |
921 | ); |
859 | |
922 | |
860 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fog of War"); |
923 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fog of War"); |
861 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
924 | $table->add_at (1, $row++, new DC::UI::CheckBox |
862 | state => $CFG->{fow_enable}, |
925 | state => $CFG->{fow_enable}, |
863 | tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.", |
926 | tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.", |
864 | on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 } |
927 | on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 } |
865 | ); |
928 | ); |
866 | |
929 | |
867 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "FoW Intensity"); |
930 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Intensity"); |
868 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
931 | $table->add_at (1, $row++, new DC::UI::Slider |
869 | range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256], |
932 | range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256], |
870 | tooltip => "<b>Fog of War Lightness.</b> The higher the intensity, the lighter the Fog-of-War color. Changes are instant.", |
933 | tooltip => "<b>Fog of War Lightness.</b> The higher the intensity, the lighter the Fog-of-War color. Changes are instant.", |
871 | on_changed => sub { my ($self, $value) = @_; $CFG->{fow_intensity} = $value; 0 } |
934 | on_changed => sub { my ($self, $value) = @_; $CFG->{fow_intensity} = $value; 0 } |
872 | ); |
935 | ); |
873 | |
936 | |
874 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize"); |
937 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Message Fontsize"); |
875 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
938 | $table->add_at (1, $row++, new DC::UI::Slider |
876 | range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], |
939 | range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], |
877 | tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant, " |
940 | tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant, " |
878 | . "but you still need to press apply to correctly re-layout the widget.", |
941 | . "but you still need to press apply to correctly re-layout the widget.", |
879 | on_changed => sub { $MESSAGE_WINDOW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, |
942 | on_changed => sub { $MESSAGE_DIST->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, |
880 | ); |
943 | ); |
881 | |
944 | |
882 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); |
945 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Gauge fontsize"); |
883 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
946 | $table->add_at (1, $row++, new DC::UI::Slider |
884 | range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1], |
947 | range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1], |
885 | tooltip => "Adjusts the fontsize of the gauges at the bottom right. Changes are instant.", |
948 | tooltip => "Adjusts the fontsize of the gauges at the bottom right. Changes are instant.", |
886 | on_changed => sub { |
949 | on_changed => sub { |
887 | $CFG->{gauge_fontsize} = $_[1]; |
950 | $CFG->{gauge_fontsize} = $_[1]; |
888 | &set_gauge_window_fontsize; |
951 | &set_gauge_window_fontsize; |
889 | 0 |
952 | 0 |
890 | } |
953 | } |
891 | ); |
954 | ); |
892 | |
955 | |
893 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Gauge size"); |
956 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Gauge size"); |
894 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
957 | $table->add_at (1, $row++, new DC::UI::Slider |
895 | range => [$CFG->{gauge_size}, 0.2, 0.8], |
958 | range => [$CFG->{gauge_size}, 0.2, 0.8], |
896 | tooltip => "Adjust the size of the stats gauges at the bottom right. Changes are instant.", |
959 | tooltip => "Adjust the size of the stats gauges at the bottom right. Changes are instant.", |
897 | on_changed => sub { |
960 | on_changed => sub { |
898 | $CFG->{gauge_size} = $_[1]; |
961 | $CFG->{gauge_size} = $_[1]; |
899 | $GAUGES->{win}->set_size ($WIDTH, int $HEIGHT * $CFG->{gauge_size}); |
962 | $GAUGES->{win}->set_size ($WIDTH, int $HEIGHT * $CFG->{gauge_size}); |
… | |
… | |
906 | |
969 | |
907 | our $AUDIO_HW_CHUNKSIZE; |
970 | our $AUDIO_HW_CHUNKSIZE; |
908 | our $AUDIO_INFO; |
971 | our $AUDIO_INFO; |
909 | |
972 | |
910 | sub audio_tab_update { |
973 | sub audio_tab_update { |
911 | my ($freq, $format, $chans) = CFPlus::Mix_QuerySpec; |
974 | my ($freq, $format, $chans) = DC::Mix_QuerySpec; |
912 | |
975 | |
913 | $AUDIO_HW_CHUNKSIZE->set_options ([ |
976 | $AUDIO_HW_CHUNKSIZE->set_options ([ |
914 | [0, "default", "Use System Default"], |
977 | [0, "default", "Use System Default"], |
915 | map { |
978 | map { |
916 | my $ms = sprintf "%dms", 1000 * $_ / ($CFG->{audio_hw_frequency} || 22050); |
979 | my $ms = sprintf "%dms", 1000 * $_ / ($CFG->{audio_hw_frequency} || 22050); |
… | |
… | |
926 | |
989 | |
927 | $AUDIO_INFO->set_text ($text); |
990 | $AUDIO_INFO->set_text ($text); |
928 | } |
991 | } |
929 | |
992 | |
930 | sub audio_setup { |
993 | sub audio_setup { |
931 | my $vbox = new CFPlus::UI::VBox; |
994 | my $vbox = new DC::UI::VBox; |
932 | |
995 | |
933 | $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1]); |
996 | $vbox->add (my $table = new DC::UI::Table expand => 1, col_expand => [0, 0, 1]); |
934 | |
997 | |
935 | my $row = 0; |
998 | my $row = 0; |
936 | |
999 | |
937 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Audio Enable"); |
1000 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Audio Enable"); |
938 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
1001 | $table->add_at (1, $row++, new DC::UI::CheckBox |
939 | state => $CFG->{audio_enable}, |
1002 | state => $CFG->{audio_enable}, |
940 | tooltip => "<b>Master Audio Enable.</b> If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.", |
1003 | tooltip => "<b>Master Audio Enable.</b> If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.", |
941 | on_changed => sub { $CFG->{audio_enable} = $_[1]; 1 } |
1004 | on_changed => sub { $CFG->{audio_enable} = $_[1]; 1 } |
942 | ); |
1005 | ); |
943 | |
1006 | |
944 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Sound Effects"); |
1007 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Sound Effects"); |
945 | $table->add_at (1, $row, new CFPlus::UI::CheckBox |
1008 | $table->add_at (1, $row, new DC::UI::CheckBox |
946 | expand => 1, state => $CFG->{effects_enable}, |
1009 | expand => 1, state => $CFG->{effects_enable}, |
947 | tooltip => "If enabled, sound effects are enabled. If disabled, no sound effects will be played.", |
1010 | tooltip => "If enabled, sound effects are enabled. If disabled, no sound effects will be played.", |
948 | on_changed => sub { |
1011 | on_changed => sub { |
949 | $CFG->{effects_enable} = $_[1]; |
1012 | $CFG->{effects_enable} = $_[1]; |
950 | $CONN->update_fx_want if $CONN; |
1013 | $CONN->update_fx_want if $CONN; |
951 | 1 |
1014 | 1 |
952 | } |
1015 | } |
953 | ); |
1016 | ); |
954 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
1017 | $table->add_at (2, $row++, new DC::UI::Slider |
955 | expand => 1, range => [$CFG->{effects_volume}, 0, 1, 0, 1/128], |
1018 | expand => 1, range => [$CFG->{effects_volume}, 0, 1, 0, 1/128], |
956 | tooltip => "The relative volume of sound effects. Best audio quality is achieved if this " |
1019 | tooltip => "The relative volume of sound effects. Best audio quality is achieved if this " |
957 | . "is set highest (rightmost) and you use your operating system volume setting. Changes are instant.", |
1020 | . "is set highest (rightmost) and you use your operating system volume setting. Changes are instant.", |
958 | on_changed => sub { $CFG->{effects_volume} = $_[1]; 1 } |
1021 | on_changed => sub { $CFG->{effects_volume} = $_[1]; 1 } |
959 | ); |
1022 | ); |
960 | |
1023 | |
961 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Background Music"); |
1024 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Background Music"); |
962 | $table->add_at (1, $row, new CFPlus::UI::CheckBox |
1025 | $table->add_at (1, $row, new DC::UI::CheckBox |
963 | expand => 1, state => $CFG->{bgm_enable}, |
1026 | expand => 1, state => $CFG->{bgm_enable}, |
964 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", |
1027 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", |
965 | on_changed => sub { |
1028 | on_changed => sub { |
966 | $CFG->{bgm_enable} = $_[1]; |
1029 | $CFG->{bgm_enable} = $_[1]; |
967 | $CONN->update_fx_want if $CONN; |
1030 | $CONN->update_fx_want if $CONN; |
968 | audio_music_push; |
1031 | audio_music_push; |
969 | 1 |
1032 | 1 |
970 | } |
1033 | } |
971 | ); |
1034 | ); |
972 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
1035 | $table->add_at (2, $row++, new DC::UI::Slider |
973 | expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], |
1036 | expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], |
974 | tooltip => "The volume of the background music. Changes are instant.", |
1037 | tooltip => "The volume of the background music. Changes are instant.", |
975 | on_changed => sub { $CFG->{bgm_volume} = $_[1]; audio_music_update_volume; 0 } |
1038 | on_changed => sub { $CFG->{bgm_volume} = $_[1]; audio_music_update_volume; 0 } |
976 | ); |
1039 | ); |
977 | |
1040 | |
978 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Frequency"); |
1041 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Frequency"); |
979 | $table->add_at (1, $row++, new CFPlus::UI::Selector |
1042 | $table->add_at (1, $row++, new DC::UI::Selector |
980 | c_colspan => 2, expand => 1, |
1043 | c_colspan => 2, expand => 1, |
981 | value => $CFG->{audio_hw_frequency}, |
1044 | value => $CFG->{audio_hw_frequency}, |
982 | options => [ |
1045 | options => [ |
983 | [ 0, "default" , "Use System Default"], |
1046 | [ 0, "default" , "Use System Default"], |
984 | [11025, "11 kHz" , "11kHz (low quality)"], |
1047 | [11025, "11 kHz" , "11kHz (low quality)"], |
… | |
… | |
992 | audio_tab_update; |
1055 | audio_tab_update; |
993 | 1 |
1056 | 1 |
994 | } |
1057 | } |
995 | ); |
1058 | ); |
996 | |
1059 | |
997 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Channels"); |
1060 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Channels"); |
998 | $table->add_at (1, $row++, new CFPlus::UI::Selector |
1061 | $table->add_at (1, $row++, new DC::UI::Selector |
999 | c_colspan => 2, expand => 1, |
1062 | c_colspan => 2, expand => 1, |
1000 | value => $CFG->{audio_hw_channels}, |
1063 | value => $CFG->{audio_hw_channels}, |
1001 | options => [ |
1064 | options => [ |
1002 | [0, "default" , "Use System Default"], |
1065 | [0, "default" , "Use System Default"], |
1003 | [1, "Mono" , "Mono (single channel, low quality)"], |
1066 | [1, "Mono" , "Mono (single channel, low quality)"], |
… | |
… | |
1011 | audio_tab_update; |
1074 | audio_tab_update; |
1012 | 1 |
1075 | 1 |
1013 | } |
1076 | } |
1014 | ); |
1077 | ); |
1015 | |
1078 | |
1016 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Latency"); |
1079 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Latency"); |
1017 | $table->add_at (1, $row++, $AUDIO_HW_CHUNKSIZE = new CFPlus::UI::Selector |
1080 | $table->add_at (1, $row++, $AUDIO_HW_CHUNKSIZE = new DC::UI::Selector |
1018 | c_colspan => 2, expand => 1, |
1081 | c_colspan => 2, expand => 1, |
1019 | value => $CFG->{audio_hw_chunksize}, |
1082 | value => $CFG->{audio_hw_chunksize}, |
1020 | tooltip => "The guarenteed latency. Lower is better, but also more cpu-intensive and might cause stuttering. If music playback " |
1083 | tooltip => "The guarenteed latency. Lower is better, but also more cpu-intensive and might cause stuttering. If music playback " |
1021 | . "is stuttering, increase this value. Values of 50-100ms are optimal.", |
1084 | . "is stuttering, increase this value. Values of 50-100ms are optimal.", |
1022 | on_changed => sub { |
1085 | on_changed => sub { |
… | |
… | |
1025 | 1 |
1088 | 1 |
1026 | } |
1089 | } |
1027 | ); |
1090 | ); |
1028 | |
1091 | |
1029 | # should really be a slider |
1092 | # should really be a slider |
1030 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Mixer Voices"); |
1093 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Mixer Voices"); |
1031 | $table->add_at (1, $row++, new CFPlus::UI::ValSlider |
1094 | $table->add_at (1, $row++, new DC::UI::ValSlider |
1032 | c_colspan => 2, expand => 1, |
1095 | c_colspan => 2, expand => 1, |
1033 | tooltip => "The number of simultaneous sound effects possible. Higher is better, but also more cpu-intensive and might cause stuttering.", |
1096 | tooltip => "The number of simultaneous sound effects possible. Higher is better, but also more cpu-intensive and might cause stuttering.", |
1034 | range => [$::CFG->{audio_mix_channels}, 4, 32, 0, 1], |
1097 | range => [$::CFG->{audio_mix_channels}, 4, 32, 0, 1], |
1035 | template => ">= 99", |
1098 | template => ">= 99", |
1036 | on_changed => sub { |
1099 | on_changed => sub { |
… | |
… | |
1040 | if $value; |
1103 | if $value; |
1041 | 1; |
1104 | 1; |
1042 | } |
1105 | } |
1043 | ); |
1106 | ); |
1044 | |
1107 | |
1045 | $table->add_at (1, $row++, new CFPlus::UI::Button |
1108 | $table->add_at (1, $row++, new DC::UI::Button |
1046 | c_colspan => 2, expand => 1, align => 0, text => "Apply", |
1109 | c_colspan => 2, expand => 1, text => "Apply", |
1047 | tooltip => "Apply the audio settings", |
1110 | tooltip => "Apply the audio settings", |
1048 | on_activate => sub { |
1111 | on_activate => sub { |
1049 | audio_shutdown (); |
1112 | audio_shutdown (); |
1050 | audio_init (); |
1113 | audio_init (); |
1051 | 0 |
1114 | 0 |
1052 | } |
1115 | } |
1053 | ); |
1116 | ); |
1054 | |
1117 | |
1055 | $vbox->add (new CFPlus::UI::FancyFrame |
1118 | $vbox->add (new DC::UI::FancyFrame |
1056 | expand => 1, |
1119 | expand => 1, |
1057 | label => "Audio Info", |
1120 | label => "Audio Info", |
1058 | child => ($AUDIO_INFO = new CFPlus::UI::Label ellipsise => 0), |
1121 | child => ($AUDIO_INFO = new DC::UI::Label ellipsise => 0), |
1059 | ); |
1122 | ); |
1060 | |
1123 | |
1061 | audio_tab_update; |
1124 | audio_tab_update; |
1062 | |
1125 | |
1063 | $vbox |
1126 | $vbox |
… | |
… | |
1070 | } |
1133 | } |
1071 | |
1134 | |
1072 | sub make_gauge_window { |
1135 | sub make_gauge_window { |
1073 | my $gh = int $HEIGHT * $CFG->{gauge_size}; |
1136 | my $gh = int $HEIGHT * $CFG->{gauge_size}; |
1074 | |
1137 | |
1075 | my $win = new CFPlus::UI::Frame ( |
1138 | my $win = new DC::UI::Frame ( |
1076 | force_x => 0, |
1139 | force_x => 0, |
1077 | force_y => "max", |
1140 | force_y => "max", |
1078 | force_w => $WIDTH, |
1141 | force_w => $WIDTH, |
1079 | force_h => $gh, |
1142 | force_h => $gh, |
1080 | ); |
1143 | ); |
1081 | |
1144 | |
1082 | $win->add (my $hbox = new CFPlus::UI::HBox |
1145 | $win->add (my $hbox = new DC::UI::HBox |
1083 | children => [ |
1146 | children => [ |
1084 | (new CFPlus::UI::HBox expand => 1), |
1147 | (new DC::UI::HBox expand => 1), |
1085 | (new CFPlus::UI::VBox children => [ |
1148 | (new DC::UI::VBox children => [ |
1086 | (new CFPlus::UI::Empty expand => 1), |
1149 | (new DC::UI::Empty expand => 1), |
1087 | (new CFPlus::UI::Frame bg => [0, 0, 0, 0.4], child => ($FLOORBOX = new CFPlus::UI::Table)), |
1150 | (new DC::UI::Frame bg => [0, 0, 0, 0.4], child => ($FLOORBOX = new DC::UI::Table)), |
1088 | ]), |
1151 | ]), |
1089 | (my $vbox = new CFPlus::UI::VBox), |
1152 | (my $vbox = new DC::UI::VBox), |
1090 | ], |
1153 | ], |
1091 | ); |
1154 | ); |
1092 | |
1155 | |
1093 | $vbox->add (new CFPlus::UI::HBox |
1156 | $vbox->add (new DC::UI::HBox |
1094 | expand => 1, |
1157 | expand => 1, |
1095 | children => [ |
1158 | children => [ |
1096 | (new CFPlus::UI::Empty expand => 1), |
1159 | (new DC::UI::Empty expand => 1), |
1097 | (my $hb = new CFPlus::UI::HBox), |
1160 | (my $hb = new DC::UI::HBox), |
1098 | ], |
1161 | ], |
1099 | ); |
1162 | ); |
1100 | |
1163 | |
1101 | $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp', tooltip => "#stat_health"); |
1164 | $hb->add (my $hg = new DC::UI::Gauge type => 'hp', tooltip => "#stat_health"); |
1102 | $hb->add (my $mg = new CFPlus::UI::Gauge type => 'mana', tooltip => "#stat_mana"); |
1165 | $hb->add (my $mg = new DC::UI::Gauge type => 'mana', tooltip => "#stat_mana"); |
1103 | $hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace', tooltip => "#stat_grace"); |
1166 | $hb->add (my $gg = new DC::UI::Gauge type => 'grace', tooltip => "#stat_grace"); |
1104 | $hb->add (my $fg = new CFPlus::UI::Gauge type => 'food', tooltip => "#stat_food"); |
1167 | $hb->add (my $fg = new DC::UI::Gauge type => 'food', tooltip => "#stat_food"); |
1105 | |
1168 | |
1106 | $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp"); |
1169 | $vbox->add (my $exp = new DC::UI::Label align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp"); |
1107 | $vbox->add (my $prg = new CFPlus::UI::ExperienceProgress); |
1170 | $vbox->add (my $prg = new DC::UI::ExperienceProgress); |
1108 | $vbox->add (my $sklprg = new CFPlus::UI::ExperienceProgress); |
1171 | $vbox->add (my $sklprg = new DC::UI::ExperienceProgress); |
1109 | $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged"); |
1172 | $vbox->add (my $rng = new DC::UI::Label align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged"); |
1110 | |
1173 | |
1111 | $GAUGES = { |
1174 | $GAUGES = { |
1112 | exp => $exp, prg => $prg, sklprg => $sklprg, |
1175 | exp => $exp, prg => $prg, sklprg => $sklprg, |
1113 | win => $win, range => $rng, |
1176 | win => $win, range => $rng, |
1114 | hp => $hg, mana => $mg, grace => $gg, food => $fg, |
1177 | hp => $hg, mana => $mg, grace => $gg, food => $fg, |
… | |
… | |
1118 | |
1181 | |
1119 | $win |
1182 | $win |
1120 | } |
1183 | } |
1121 | |
1184 | |
1122 | sub debug_setup { |
1185 | sub debug_setup { |
1123 | my $table = new CFPlus::UI::Table; |
1186 | my $table = new DC::UI::Table; |
1124 | |
1187 | |
1125 | $table->add_at (0, 0, new CFPlus::UI::Label text => "Widget Borders"); |
1188 | $table->add_at (0, 0, new DC::UI::Label text => "Widget Borders"); |
1126 | $table->add_at (1, 0, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 1; 0 }); |
1189 | $table->add_at (1, 0, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 1; 0 }); |
1127 | $table->add_at (0, 1, new CFPlus::UI::Label text => "Tooltip Widget Info"); |
1190 | $table->add_at (0, 1, new DC::UI::Label text => "Tooltip Widget Info"); |
1128 | $table->add_at (1, 1, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2; 0 }); |
1191 | $table->add_at (1, 1, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2; 0 }); |
1129 | $table->add_at (0, 2, new CFPlus::UI::Label text => "Show FPS"); |
1192 | $table->add_at (0, 2, new DC::UI::Label text => "Show FPS"); |
1130 | $table->add_at (1, 2, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4; 0 }); |
1193 | $table->add_at (1, 2, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4; 0 }); |
1131 | $table->add_at (0, 3, new CFPlus::UI::Label text => "Suppress Tooltips"); |
1194 | $table->add_at (0, 3, new DC::UI::Label text => "Suppress Tooltips"); |
1132 | $table->add_at (1, 3, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 }); |
1195 | $table->add_at (1, 3, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 }); |
1133 | $table->add_at (0, 4, new CFPlus::UI::Button text => "die on click(tm)", on_activate => sub { &CFPlus::debug() } ); |
1196 | $table->add_at (0, 4, new DC::UI::Button text => "die on click(tm)", on_activate => sub { &DC::debug() } ); |
1134 | |
1197 | |
1135 | $table->add_at (0, 5, new CFPlus::UI::TextEdit text => "line1\0152\0153");#d# |
1198 | $table->add_at (0, 5, new DC::UI::TextEdit text => "line1\0152\0153\nµikachu\nづx゙つ゛");#d# |
1136 | |
1199 | |
1137 | $table->add_at (7,7, my $t = new CFPlus::UI::Table expand => 0); |
1200 | $table->add_at (7,7, my $t = new DC::UI::Table expand => 0); |
1138 | $t->add_at (0,0, new CFPlus::UI::Label text => "a a a a", c_rowspan => 1, c_colspan => 2); |
1201 | $t->add_at (0,0, new DC::UI::Label text => "a a", c_rowspan => 1, c_colspan => 2); |
1139 | $t->add_at (2,0, new CFPlus::UI::Label text => "b\nb", c_rowspan => 2, c_colspan => 1); |
1202 | $t->add_at (2,0, new DC::UI::Label text => "b\nb", c_rowspan => 2, c_colspan => 1, ellipsise => 0 ); |
1140 | $t->add_at (1,2, new CFPlus::UI::Label text => "c c c c", c_rowspan => 1, c_colspan => 2); |
1203 | $t->add_at (1,2, new DC::UI::Label text => "c c", c_rowspan => 1, c_colspan => 2); |
1141 | $t->add_at (0,1, new CFPlus::UI::Label text => "d\nd", c_rowspan => 2, c_colspan => 1); |
1204 | $t->add_at (0,1, new DC::UI::Label text => "d\nd", c_rowspan => 2, c_colspan => 1, ellipsise => 0 ); |
1142 | $t->add_at (1,1, new CFPlus::UI::Label text => "e"); |
1205 | $t->add_at (1,1, new DC::UI::Label text => "e"); |
1143 | |
1206 | |
1144 | $table->add_at (7, 6, my $c = new CFPlus::UI::Canvas); |
1207 | $table->add_at (7, 6, my $c = new DC::UI::Canvas); |
1145 | |
1208 | |
1146 | $c->add_items ({ |
1209 | $c->add_items ({ |
1147 | type => "line_loop", |
1210 | type => "line_loop", |
1148 | color => [0, 1, 0], |
1211 | color => [0, 1, 0], |
1149 | width => 9, |
1212 | width => 9, |
… | |
… | |
1169 | |
1232 | |
1170 | $table |
1233 | $table |
1171 | } |
1234 | } |
1172 | |
1235 | |
1173 | sub stats_window { |
1236 | sub stats_window { |
1174 | my $r = new CFPlus::UI::ScrolledWindow ( |
1237 | my $r = new DC::UI::ScrolledWindow ( |
1175 | expand => 1, |
1238 | expand => 1, |
1176 | scroll_y => 1 |
1239 | scroll_y => 1 |
1177 | ); |
1240 | ); |
1178 | $r->add (my $vb = new CFPlus::UI::VBox); |
1241 | $r->add (my $vb = new DC::UI::VBox); |
1179 | |
1242 | |
1180 | $vb->add (new CFPlus::UI::FancyFrame |
1243 | $vb->add (new DC::UI::FancyFrame |
1181 | label => "Player", |
1244 | label => "Player", |
1182 | child => (my $pi = new CFPlus::UI::VBox), |
1245 | child => (my $pi = new DC::UI::VBox), |
1183 | ); |
1246 | ); |
1184 | |
1247 | |
1185 | $pi->add ($STATWIDS->{title} = new CFPlus::UI::Label valign => 0, align => -1, text => "Title:", expand => 1, |
1248 | $pi->add ($STATWIDS->{title} = new DC::UI::Label text => "Title:", expand => 1, align => 0, |
1186 | can_hover => 1, can_events => 1, |
1249 | can_hover => 1, can_events => 1, |
1187 | tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server."); |
1250 | tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server."); |
1188 | $pi->add ($STATWIDS->{map} = new CFPlus::UI::Label valign => 0, align => -1, text => "Map:", expand => 1, |
1251 | $pi->add ($STATWIDS->{map} = new DC::UI::Label align => 0, text => "Map:", expand => 1, |
1189 | can_hover => 1, can_events => 1, |
1252 | can_hover => 1, can_events => 1, |
1190 | tooltip => "The map you are currently on (if supported by the server)."); |
1253 | tooltip => "The map you are currently on (if supported by the server)."); |
1191 | |
1254 | |
1192 | $pi->add (my $hb0 = new CFPlus::UI::HBox); |
1255 | $pi->add (my $hb0 = new DC::UI::HBox); |
1193 | $hb0->add ($STATWIDS->{weight} = new CFPlus::UI::Label valign => 0, align => -1, text => "Weight:", expand => 1, |
1256 | $hb0->add ($STATWIDS->{weight} = new DC::UI::Label text => "Weight:", expand => 1, align => 0, |
1194 | can_hover => 1, can_events => 1, |
1257 | can_hover => 1, can_events => 1, |
1195 | tooltip => "The weight of the player including all inventory items."); |
1258 | tooltip => "The weight of the player including all inventory items."); |
1196 | $hb0->add ($STATWIDS->{m_weight} = new CFPlus::UI::Label valign => 0, align => -1, text => "Max weight:", expand => 1, |
1259 | $hb0->add ($STATWIDS->{m_weight} = new DC::UI::Label align => 0, text => "Max weight:", expand => 1, |
1197 | can_hover => 1, can_events => 1, |
1260 | can_hover => 1, can_events => 1, |
1198 | tooltip => "The weight limit: you cannot carry more than this."); |
1261 | tooltip => "The weight limit: you cannot carry more than this."); |
1199 | |
1262 | |
1200 | $vb->add (new CFPlus::UI::FancyFrame |
1263 | $vb->add (new DC::UI::FancyFrame |
1201 | label => "Primary/Secondary Statistics", |
1264 | label => "Primary/Secondary Statistics", |
1202 | child => (my $hb = new CFPlus::UI::HBox expand => 1), |
1265 | child => (my $hb = new DC::UI::HBox expand => 1), |
1203 | ); |
1266 | ); |
1204 | $hb->add (my $tbl = new CFPlus::UI::Table expand => 1); |
1267 | $hb->add (my $tbl = new DC::UI::Table expand => 1); |
1205 | |
1268 | |
1206 | my $color2 = [1, 1, 0]; |
1269 | my $color2 = [1, 1, 0]; |
1207 | |
1270 | |
1208 | for ( |
1271 | for ( |
1209 | [0, 0, st_str => "Str", 30], |
1272 | [0, 0, st_str => "Str", 30], |
… | |
… | |
1221 | [2, 4, st_spd => "Spd", 10.54], |
1284 | [2, 4, st_spd => "Spd", 10.54], |
1222 | [2, 5, st_wspd => "WSp", 10.54], |
1285 | [2, 5, st_wspd => "WSp", 10.54], |
1223 | ) { |
1286 | ) { |
1224 | my ($col, $row, $id, $label, $template) = @$_; |
1287 | my ($col, $row, $id, $label, $template) = @$_; |
1225 | |
1288 | |
1226 | $tbl->add_at ($col , $row, $STATWIDS->{$id} = new CFPlus::UI::Label |
1289 | $tbl->add_at ($col , $row, $STATWIDS->{$id} = new DC::UI::Label |
1227 | font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0, |
1290 | font => $FONT_FIXED, can_hover => 1, can_events => 1, |
1228 | align => +1, template => $template, tooltip => "#stat_$label"); |
1291 | align => 1, template => $template, tooltip => "#stat_$label"); |
1229 | $tbl->add_at ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFPlus::UI::Label |
1292 | $tbl->add_at ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new DC::UI::Label |
1230 | font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, valign => 0, |
1293 | font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, |
1231 | align => -1, text => $label, tooltip => "#stat_$label"); |
1294 | align => 0, text => $label, tooltip => "#stat_$label"); |
1232 | } |
1295 | } |
1233 | |
1296 | |
1234 | $vb->add (new CFPlus::UI::FancyFrame |
1297 | $vb->add (new DC::UI::FancyFrame |
1235 | label => "Resistancies", |
1298 | label => "Resistancies", |
1236 | child => (my $tbl2 = new CFPlus::UI::Table expand => 1), |
1299 | child => (my $tbl2 = new DC::UI::Table expand => 1, col_expand => [1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0]), |
1237 | ); |
1300 | ); |
1238 | |
1301 | |
1239 | my $row = 0; |
1302 | my $row = 0; |
1240 | my $col = 0; |
1303 | my $col = 0; |
1241 | |
1304 | |
… | |
… | |
1280 | |
1343 | |
1281 | for (qw/slow holyw conf fire depl magic |
1344 | for (qw/slow holyw conf fire depl magic |
1282 | drain acid pois para deat phys |
1345 | drain acid pois para deat phys |
1283 | blind fear tund elec cold ghit/) |
1346 | blind fear tund elec cold ghit/) |
1284 | { |
1347 | { |
1285 | $tbl2->add_at ($col, $row, |
1348 | $tbl2->add_at ($col + 2, $row, |
1286 | $STATWIDS->{"res_$_"} = |
1349 | $STATWIDS->{"res_$_"} = |
1287 | new CFPlus::UI::Label |
1350 | new DC::UI::Label |
1288 | font => $FONT_FIXED, |
1351 | font => $FONT_FIXED, |
1289 | template => "-100%", |
1352 | template => "-100%", |
1290 | align => +1, |
1353 | align => 1, |
1291 | valign => 0, |
|
|
1292 | can_events => 1, |
1354 | can_events => 1, |
1293 | can_hover => 1, |
1355 | can_hover => 1, |
1294 | tooltip => $resist_names{$_}->[1], |
1356 | tooltip => $resist_names{$_}->[1], |
1295 | ); |
1357 | ); |
1296 | $tbl2->add_at ($col + 1, $row, new CFPlus::UI::Image |
1358 | $tbl2->add_at ($col + 1, $row, new DC::UI::Image |
1297 | font => $FONT_FIXED, |
1359 | font => $FONT_FIXED, |
1298 | can_hover => 1, |
1360 | can_hover => 1, |
1299 | can_events => 1, |
1361 | can_events => 1, |
1300 | path => "ui/resist/resist_$_.png", |
1362 | path => "ui/resist/resist_$_.png", |
1301 | tooltip => $resist_names{$_}->[1], |
1363 | tooltip => $resist_names{$_}->[1], |
1302 | ); |
1364 | ); |
1303 | $tbl2->add_at ($col + 2, $row, new CFPlus::UI::Label |
1365 | $tbl2->add_at ($col + 0, $row, new DC::UI::Label |
1304 | text => $resist_names{$_}->[0], |
1366 | text => $resist_names{$_}->[0], |
1305 | font => $FONT_FIXED, |
1367 | font => $FONT_FIXED, |
|
|
1368 | align => 1, |
1306 | can_hover => 1, |
1369 | can_hover => 1, |
1307 | can_events => 1, |
1370 | can_events => 1, |
1308 | tooltip => $resist_names{$_}->[1], |
1371 | tooltip => $resist_names{$_}->[1], |
1309 | ); |
1372 | ); |
1310 | |
1373 | |
1311 | $row++; |
1374 | $row++; |
1312 | if ($row % 6 == 0) { |
1375 | if ($row % 6 == 0) { |
1313 | $col += 3; |
1376 | $col += 4; |
1314 | $row = 0; |
1377 | $row = 0; |
1315 | } |
1378 | } |
1316 | } |
1379 | } |
1317 | |
1380 | |
1318 | #update_stats_window ({}); |
1381 | #update_stats_window ({}); |
1319 | |
1382 | |
1320 | $r |
1383 | $r |
1321 | } |
1384 | } |
1322 | |
1385 | |
1323 | sub skill_window { |
1386 | sub skill_window { |
1324 | my $sw = new CFPlus::UI::ScrolledWindow (expand => 1); |
1387 | my $sw = new DC::UI::ScrolledWindow (expand => 1); |
1325 | |
1388 | |
1326 | $sw->add ($STATWIDS->{skill_tbl} = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1, .1, 0, 0, 1, .1]); |
1389 | $sw->add ($STATWIDS->{skill_tbl} = new DC::UI::Table expand => 1, col_expand => [0, 0, 1, .1, 0, 0, 1, .1]); |
1327 | |
1390 | |
1328 | $sw |
1391 | $sw |
1329 | } |
1392 | } |
1330 | |
1393 | |
1331 | sub formsep($) { |
1394 | sub formsep($) { |
… | |
… | |
1343 | return if $METASERVER_ATIME > time; |
1406 | return if $METASERVER_ATIME > time; |
1344 | $METASERVER_ATIME = time + 60; |
1407 | $METASERVER_ATIME = time + 60; |
1345 | |
1408 | |
1346 | my $table = $METASERVER->{table}; |
1409 | my $table = $METASERVER->{table}; |
1347 | $table->clear; |
1410 | $table->clear; |
1348 | $table->add_at (0, 0, my $label = new CFPlus::UI::Label max_w => $WIDTH * 0.8, text => "fetching server list..."); |
1411 | $table->add_at (0, 0, my $label = new DC::UI::Label max_w => $WIDTH * 0.8, text => "fetching server list..."); |
1349 | |
1412 | |
1350 | my $ok = 0; |
1413 | my $ok = 0; |
1351 | |
1414 | |
1352 | CFPlus::background { |
1415 | DC::background { |
1353 | my $ua = CFPlus::lwp_useragent; |
1416 | my $ua = DC::lwp_useragent; |
1354 | |
1417 | |
1355 | CFPlus::background_msg CFPlus::decode_json +(CFPlus::lwp_check $ua->get ($META_SERVER))->decoded_content; |
1418 | DC::background_msg DC::decode_json +(DC::lwp_check $ua->get ($META_SERVER))->decoded_content; |
1356 | } sub { |
1419 | } sub { |
1357 | my ($msg) = @_; |
1420 | my ($msg) = @_; |
1358 | if ($msg) { |
1421 | if ($msg) { |
1359 | $table->clear; |
1422 | $table->clear; |
1360 | |
1423 | |
… | |
… | |
1363 | "The hostname of the server.", |
1426 | "The hostname of the server.", |
1364 | "The time this server has been running without being restarted.", |
1427 | "The time this server has been running without being restarted.", |
1365 | "Short information about this server provided by its admins.", |
1428 | "Short information about this server provided by its admins.", |
1366 | ); |
1429 | ); |
1367 | my @col = qw(#Users Host Uptime Version Description); |
1430 | my @col = qw(#Users Host Uptime Version Description); |
1368 | $table->add_at ($_, 0, new CFPlus::UI::Label |
1431 | $table->add_at ($_, 0, new DC::UI::Label |
1369 | can_hover => 1, can_events => 1, |
1432 | can_hover => 1, can_events => 1, fg => [1, 1, 0], |
1370 | align => 0, fg => [1, 1, 0], |
|
|
1371 | text => $col[$_], tooltip => $tip[$_]) |
1433 | text => $col[$_], tooltip => $tip[$_]) |
1372 | for 0 .. $#col; |
1434 | for 0 .. $#col; |
1373 | |
1435 | |
1374 | my @align = qw(1 0 1 1 -1); |
1436 | my @align = qw(1 0.5 1 1 0); |
1375 | |
1437 | |
1376 | my $y = 0; |
1438 | my $y = 0; |
1377 | for my $m (@{ $msg->{servers} }) { |
1439 | for my $m (@{ $msg->{servers} }) { |
1378 | my ($ip, $last, $host, $users, $version, $desc, $ibytes, $obytes, $uptime, $highlight) = |
1440 | my ($ip, $last, $host, $users, $version, $desc, $ibytes, $obytes, $uptime, $highlight) = |
1379 | @$m{qw(ip age hostname users version description ibytes obytes uptime highlight)}; |
1441 | @$m{qw(ip age hostname users version description ibytes obytes uptime highlight)}; |
… | |
… | |
1395 | |
1457 | |
1396 | $m = [$users, $host, $uptime, $version, $desc]; |
1458 | $m = [$users, $host, $uptime, $version, $desc]; |
1397 | |
1459 | |
1398 | $y++; |
1460 | $y++; |
1399 | |
1461 | |
1400 | $table->add_at (scalar @$m, $y, new CFPlus::UI::VBox children => [ |
1462 | $table->add_at (scalar @$m, $y, new DC::UI::VBox children => [ |
1401 | (new CFPlus::UI::Button |
1463 | (new DC::UI::Button |
1402 | text => "Use", |
1464 | text => "Use", |
1403 | tooltip => "Put this server into the <b>Host:Port</b> field", |
1465 | tooltip => "Put this server into the <b>Host:Port</b> field", |
1404 | on_activate => sub { |
1466 | on_activate => sub { |
1405 | $HOST_ENTRY->set_text ($CFG->{profile}{default}{host} = $host); |
1467 | $HOST_ENTRY->set_text ($CFG->{profile}{default}{host} = $host); |
1406 | $METASERVER->hide; |
1468 | $METASERVER->hide; |
1407 | 0 |
1469 | 0 |
1408 | }, |
1470 | }, |
1409 | ), |
1471 | ), |
1410 | (new CFPlus::UI::Empty expand => 1), |
1472 | (new DC::UI::Empty expand => 1), |
1411 | ]); |
1473 | ]); |
1412 | |
1474 | |
1413 | $table->add_at ($_, $y, new CFPlus::UI::Label |
1475 | $table->add_at ($_, $y, new DC::UI::Label |
1414 | max_w => $::WIDTH * 0.4, |
1476 | max_w => $::WIDTH * 0.4, |
1415 | ellipsise => 0, |
1477 | ellipsise => 0, |
1416 | align => $align[$_], |
1478 | align => $align[$_], |
1417 | text => $m->[$_], |
1479 | text => $m->[$_], |
1418 | tooltip => $tip[$_], |
1480 | tooltip => $tip[$_], |
… | |
… | |
1428 | }; |
1490 | }; |
1429 | |
1491 | |
1430 | } |
1492 | } |
1431 | |
1493 | |
1432 | sub metaserver_dialog { |
1494 | sub metaserver_dialog { |
1433 | my $vbox = new CFPlus::UI::VBox; |
1495 | my $vbox = new DC::UI::VBox; |
1434 | my $table = new CFPlus::UI::Table; |
1496 | my $table = new DC::UI::Table; |
1435 | $vbox->add (new CFPlus::UI::ScrolledWindow expand => 1, child => $table); |
1497 | $vbox->add (new DC::UI::ScrolledWindow expand => 1, child => $table); |
1436 | |
1498 | |
1437 | my $dialog = new CFPlus::UI::Toplevel |
1499 | my $dialog = new DC::UI::Toplevel |
1438 | title => "Server List", |
1500 | title => "Server List", |
1439 | name => 'metaserver_dialog', |
1501 | name => 'metaserver_dialog', |
1440 | x => 'center', |
1502 | x => 'center', |
1441 | y => 'center', |
1503 | y => 'center', |
1442 | z => 3, |
1504 | z => 3, |
… | |
… | |
1453 | |
1515 | |
1454 | $dialog |
1516 | $dialog |
1455 | } |
1517 | } |
1456 | |
1518 | |
1457 | sub login_setup { |
1519 | sub login_setup { |
1458 | my $vbox = new CFPlus::UI::VBox; |
1520 | my $vbox = new DC::UI::VBox; |
1459 | |
1521 | |
1460 | $vbox->add (new CFPlus::UI::FancyFrame |
1522 | $vbox->add (new DC::UI::FancyFrame |
1461 | label => "Login Settings", |
1523 | label => "Login Settings", |
1462 | child => (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]), |
1524 | child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]), |
1463 | ); |
1525 | ); |
1464 | |
1526 | |
1465 | $table->add_at (0, 4, new CFPlus::UI::Label valign => 0, align => 1, text => "Username"); |
1527 | $table->add_at (0, 4, new DC::UI::Label align => 1, text => "Username"); |
1466 | $table->add_at (1, 4, new CFPlus::UI::Entry |
1528 | $table->add_at (1, 4, new DC::UI::Entry |
1467 | text => $CFG->{profile}{default}{user}, |
1529 | text => $CFG->{profile}{default}{user}, |
1468 | tooltip => "The name of your character on the server.", |
1530 | tooltip => "The name of your character on the server.", |
1469 | on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value; 1 } |
1531 | on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value; 1 } |
1470 | ); |
1532 | ); |
1471 | |
1533 | |
1472 | $table->add_at (0, 5, new CFPlus::UI::Label valign => 0, align => 1, text => "Password"); |
1534 | $table->add_at (0, 5, new DC::UI::Label align => 1, text => "Password"); |
1473 | $table->add_at (1, 5, new CFPlus::UI::Entry |
1535 | $table->add_at (1, 5, new DC::UI::Entry |
1474 | text => $CFG->{profile}{default}{password}, |
1536 | text => $CFG->{profile}{default}{password}, |
1475 | hidden => 1, |
1537 | hidden => 1, |
1476 | tooltip => "The password for your character.", |
1538 | tooltip => "The password for your character.", |
1477 | on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value; 1 } |
1539 | on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value; 1 } |
1478 | ); |
1540 | ); |
1479 | |
1541 | |
1480 | $table->add_at (1, 11, $LOGIN_BUTTON = new CFPlus::UI::Button |
1542 | $table->add_at (1, 11, $LOGIN_BUTTON = new DC::UI::Button |
1481 | expand => 1, |
1543 | expand => 1, |
1482 | align => 0, |
|
|
1483 | text => "Login / Register", |
1544 | text => "Login / Register", |
1484 | tooltip => "This button will either login to the account configured above or register a new account.", |
1545 | tooltip => "This button will either login to the account configured above or register a new account.", |
1485 | on_activate => sub { |
1546 | on_activate => sub { |
1486 | $CONN ? stop_game |
1547 | $CONN ? stop_game |
1487 | : start_game; |
1548 | : start_game; |
1488 | 1 |
1549 | 1 |
1489 | }, |
1550 | }, |
1490 | ); |
1551 | ); |
1491 | |
1552 | |
1492 | $vbox->add (new CFPlus::UI::FancyFrame |
1553 | $vbox->add (new DC::UI::FancyFrame |
1493 | label => "Registering", |
1554 | label => "Registering", |
1494 | min_h => 200, |
1555 | min_h => 200, |
1495 | child => (new CFPlus::UI::Label valign => -1, ellipsise => 0, |
1556 | child => (new DC::UI::Label valign => 0, ellipsise => 0, |
1496 | markup => |
1557 | markup => |
1497 | "To register a new account, choose a username that hasn't been taken yet and " |
1558 | "To register a new account, choose a username that hasn't been taken yet and " |
1498 | . "try to log-in. Follow the instructions in the Log tab in the message window.", |
1559 | . "try to log-in. Follow the instructions in the Log tab in the message window.", |
1499 | ), |
1560 | ), |
1500 | ); |
1561 | ); |
1501 | |
1562 | |
1502 | $vbox |
1563 | $vbox |
1503 | } |
1564 | } |
1504 | |
1565 | |
1505 | sub server_setup { |
1566 | sub server_setup { |
1506 | my $vbox = new CFPlus::UI::VBox; |
1567 | my $vbox = new DC::UI::VBox; |
1507 | |
1568 | |
1508 | $vbox->add (new CFPlus::UI::FancyFrame |
1569 | $vbox->add (new DC::UI::FancyFrame |
1509 | label => "Connection Settings", |
1570 | label => "Connection Settings", |
1510 | child => (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]), |
1571 | child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]), |
1511 | ); |
1572 | ); |
1512 | |
1573 | |
1513 | my $row = 0; |
1574 | my $row = 0; |
1514 | |
1575 | |
1515 | $table->add_at (0, ++$row, new CFPlus::UI::Label valign => 0, align => 1, text => "Host:Port"); |
1576 | $table->add_at (0, ++$row, new DC::UI::Label align => 1, text => "Host:Port"); |
1516 | { |
1577 | { |
1517 | $table->add_at (1, $row, my $vbox = new CFPlus::UI::VBox); |
1578 | $table->add_at (1, $row, my $vbox = new DC::UI::VBox); |
1518 | |
1579 | |
1519 | $vbox->add ( |
1580 | $vbox->add ( |
1520 | $HOST_ENTRY = new CFPlus::UI::Entry |
1581 | $HOST_ENTRY = new DC::UI::Entry |
1521 | expand => 1, |
1582 | expand => 1, |
1522 | text => $CFG->{profile}{default}{host}, |
1583 | text => $CFG->{profile}{default}{host}, |
1523 | tooltip => "The hostname or ip address of the Deliantra server to connect to", |
1584 | tooltip => "The hostname or ip address of the Deliantra server to connect to (e.g. <b>gameserver.deliantra.net</b>)", |
1524 | on_changed => sub { |
1585 | on_changed => sub { |
1525 | my ($self, $value) = @_; |
1586 | my ($self, $value) = @_; |
1526 | $CFG->{profile}{default}{host} = $value; |
1587 | $CFG->{profile}{default}{host} = $value; |
1527 | 1 |
1588 | 1 |
1528 | } |
1589 | } |
1529 | ); |
1590 | ); |
1530 | |
1591 | |
1531 | if (0) { #d# disabled |
1592 | if (0) { #d# disabled |
1532 | $vbox->add (new CFPlus::UI::Button |
1593 | $vbox->add (new DC::UI::Button |
1533 | expand => 1, |
1594 | expand => 1, |
1534 | text => "Server List", |
1595 | text => "Server List", |
1535 | other => $METASERVER, |
1596 | other => $METASERVER, |
1536 | tooltip => "Show a list of available crossfire servers", |
1597 | tooltip => "Show a list of available Deliantra servers", |
1537 | on_activate => sub { $METASERVER->toggle_visibility; 0 }, |
1598 | on_activate => sub { $METASERVER->toggle_visibility; 0 }, |
1538 | on_visibility_change => sub { $METASERVER->hide unless $_[1]; 1 }, |
1599 | on_visibility_change => sub { $METASERVER->hide unless $_[1]; 1 }, |
1539 | ); |
1600 | ); |
1540 | }#d# |
1601 | }#d# |
1541 | } |
1602 | } |
1542 | |
1603 | |
1543 | $table->add_at (0, ++$row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Size"); |
1604 | $table->add_at (0, ++$row, new DC::UI::Label align => 1, text => "Map Size"); |
1544 | $table->add_at (1, $row, new CFPlus::UI::Slider |
1605 | $table->add_at (1, $row, new DC::UI::Slider |
1545 | force_w => 100, |
1606 | force_w => 100, |
1546 | range => [$CFG->{mapsize}, 10, 100, 0, 1], |
1607 | range => [$CFG->{mapsize}, 10, 100, 0, 1], |
1547 | tooltip => "This is the size of the portion of the map update the server sends you. " |
1608 | tooltip => "This is the size of the portion of the map update the server sends you. " |
1548 | . "If you set this to a high value you will be able to see further, " |
1609 | . "If you set this to a high value you will be able to see further, " |
1549 | . "but you also increase bandwidth requirements and latency. " |
1610 | . "but you also increase bandwidth requirements and latency. " |
1550 | . "This option is only used once at log-in.", |
1611 | . "This option is only used once at log-in.", |
1551 | on_changed => sub { my ($self, $value) = @_; $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 1 }, |
1612 | on_changed => sub { my ($self, $value) = @_; $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 1 }, |
1552 | ); |
1613 | ); |
1553 | |
1614 | |
1554 | $table->add_at (0, ++$row, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Rate"); |
1615 | $table->add_at (0, ++$row, new DC::UI::Label align => 1, text => "Output-Rate"); |
1555 | $table->add_at (1, $row, new CFPlus::UI::Entry |
1616 | $table->add_at (1, $row, new DC::UI::Entry |
1556 | text => $CFG->{output_rate}, |
1617 | text => $CFG->{output_rate}, |
1557 | tooltip => "The maximum bandwidth in bytes per second that the server should not exceed " |
1618 | tooltip => "The maximum bandwidth in bytes per second that the server should not exceed " |
1558 | . "when sending data. When 0 or unset, the server " |
1619 | . "when sending data. When 0 or unset, the server " |
1559 | . "default will be used, which is usually around 100kb/s. Most servers will " |
1620 | . "default will be used, which is usually around 100kb/s. Most servers will " |
1560 | . "dynamically find an optimal rate, so adjust this only when necessary.", |
1621 | . "dynamically find an optimal rate, so adjust this only when necessary.", |
1561 | on_changed => sub { $CFG->{output_rate} = $_[1]; 1 }, |
1622 | on_changed => sub { $CFG->{output_rate} = $_[1]; 1 }, |
1562 | ); |
1623 | ); |
1563 | |
1624 | |
1564 | $vbox->add (new CFPlus::UI::FancyFrame |
1625 | $vbox->add (new DC::UI::FancyFrame |
1565 | label => "Server Info", |
1626 | label => "Server Info", |
1566 | child => ($SERVER_INFO = new CFPlus::UI::Label ellipsise => 0), |
1627 | child => ($SERVER_INFO = new DC::UI::Label ellipsise => 0), |
1567 | ); |
1628 | ); |
1568 | |
1629 | |
1569 | $vbox |
1630 | $vbox |
1570 | } |
1631 | } |
1571 | |
1632 | |
1572 | sub client_setup { |
1633 | sub client_setup { |
1573 | my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]; |
1634 | my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]; |
1574 | |
1635 | |
1575 | my $row = 0; |
1636 | my $row = 0; |
1576 | |
1637 | |
1577 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Tip of the day"); |
1638 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Tip of the day"); |
1578 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
1639 | $table->add_at (1, $row++, new DC::UI::CheckBox |
1579 | state => $CFG->{show_tips}, |
1640 | state => $CFG->{show_tips}, |
1580 | tooltip => "Show the <b>Tip of the day</b> window at startup?", |
1641 | tooltip => "Show the <b>Tip of the day</b> window at startup?", |
1581 | on_changed => sub { |
1642 | on_changed => sub { |
1582 | my ($self, $value) = @_; |
1643 | my ($self, $value) = @_; |
1583 | $CFG->{show_tips} = $value; |
1644 | $CFG->{show_tips} = $value; |
1584 | 0 |
1645 | 0 |
1585 | } |
1646 | } |
1586 | ); |
1647 | ); |
1587 | |
1648 | |
1588 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Messages Window Size"); |
1649 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Message Window Size"); |
1589 | $table->add_at (1, $row++, my $saycmd = new CFPlus::UI::Entry |
1650 | $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry |
1590 | text => $CFG->{logview_max_par}, |
1651 | text => $CFG->{logview_max_par}, |
1591 | tooltip => "This is maximum number of messages remembered in the <b>Messages</b> window. If the server " |
1652 | tooltip => "This is maximum number of messages remembered in the <b>Message</b> window. If the server " |
1592 | . "sends more messages than this number, older messages get removed to save memory and " |
1653 | . "sends more messages than this number, older messages get removed to save memory and " |
1593 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
1654 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
1594 | on_changed => sub { |
1655 | on_changed => sub { |
1595 | my ($self, $value) = @_; |
1656 | my ($self, $value) = @_; |
1596 | $MESSAGE_WINDOW->set_max_para ($CFG->{logview_max_par} = $value*1); |
1657 | $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); |
1597 | 0 |
1658 | 0 |
1598 | }, |
1659 | }, |
1599 | ); |
1660 | ); |
1600 | |
1661 | |
1601 | $table |
1662 | $table |
1602 | } |
1663 | } |
1603 | |
1664 | |
1604 | sub autopickup_setup { |
1665 | sub autopickup_setup { |
1605 | my $r = new CFPlus::UI::ScrolledWindow ( |
1666 | my $r = new DC::UI::ScrolledWindow ( |
1606 | expand => 1, |
1667 | expand => 1, |
1607 | scroll_y => 1 |
1668 | scroll_y => 1 |
1608 | ); |
1669 | ); |
1609 | $r->add (my $table = new CFPlus::UI::Table |
1670 | $r->add (my $table = new DC::UI::Table |
1610 | row_expand => [0], |
1671 | row_expand => [0], |
1611 | col_expand => [0, 1, 0, 1], |
1672 | col_expand => [0, 1, 0, 1], |
1612 | ); |
1673 | ); |
1613 | |
1674 | |
1614 | for ( |
1675 | for ( |
… | |
… | |
1652 | ], |
1713 | ], |
1653 | ["Weight/Value ratio", 2, 17] |
1714 | ["Weight/Value ratio", 2, 17] |
1654 | ) |
1715 | ) |
1655 | { |
1716 | { |
1656 | my ($title, $x, $y, @bits) = @$_; |
1717 | my ($title, $x, $y, @bits) = @$_; |
1657 | $table->add_at ($x, $y, new CFPlus::UI::Label text => $title, align => 1, fg => [1, 1, 0]); |
1718 | $table->add_at ($x, $y, new DC::UI::Label text => $title, align => 1, fg => [1, 1, 0]); |
1658 | |
1719 | |
1659 | for (@bits) { |
1720 | for (@bits) { |
1660 | ++$y; |
1721 | ++$y; |
1661 | |
1722 | |
1662 | my $mask = $_->[1]; |
1723 | my $mask = $_->[1]; |
1663 | $table->add_at ($x , $y, new CFPlus::UI::Label text => $_->[0], align => 1, expand => 1); |
1724 | $table->add_at ($x , $y, new DC::UI::Label text => $_->[0], align => 1, expand => 1); |
1664 | $table->add_at ($x+1, $y, my $checkbox = new CFPlus::UI::CheckBox |
1725 | $table->add_at ($x+1, $y, my $checkbox = new DC::UI::CheckBox |
1665 | state => $::CFG->{pickup} & $mask, |
1726 | state => $::CFG->{pickup} & $mask, |
1666 | on_changed => sub { |
1727 | on_changed => sub { |
1667 | my ($box, $value) = @_; |
1728 | my ($box, $value) = @_; |
1668 | |
1729 | |
1669 | if ($value) { |
1730 | if ($value) { |
… | |
… | |
1680 | |
1741 | |
1681 | ${$_->[2]} = $checkbox if $_->[2]; |
1742 | ${$_->[2]} = $checkbox if $_->[2]; |
1682 | } |
1743 | } |
1683 | } |
1744 | } |
1684 | |
1745 | |
1685 | $table->add_at (2, 18, new CFPlus::UI::ValSlider |
1746 | $table->add_at (2, 18, new DC::UI::ValSlider |
1686 | range => [$::CFG->{pickup} & 0xF, 0, 16, 1, 1], |
1747 | range => [$::CFG->{pickup} & 0xF, 0, 16, 1, 1], |
1687 | template => ">= 99", |
1748 | template => ">= 99", |
1688 | to_value => sub { ">= " . 5 * $_[0] }, |
1749 | to_value => sub { ">= " . 5 * $_[0] }, |
1689 | on_changed => sub { |
1750 | on_changed => sub { |
1690 | my ($slider, $value) = @_; |
1751 | my ($slider, $value) = @_; |
… | |
… | |
1693 | $::CFG->{pickup} |= int $value |
1754 | $::CFG->{pickup} |= int $value |
1694 | if $value; |
1755 | if $value; |
1695 | 1; |
1756 | 1; |
1696 | }); |
1757 | }); |
1697 | |
1758 | |
1698 | $table->add_at (3, 18, new CFPlus::UI::Button |
1759 | $table->add_at (3, 18, new DC::UI::Button |
1699 | text => "set", |
1760 | text => "set", |
1700 | on_activate => sub { |
1761 | on_activate => sub { |
1701 | $::CONN->send_command ("pickup $::CFG->{pickup}") |
1762 | $::CONN->send_command ("pickup $::CFG->{pickup}") |
1702 | if defined $::CONN; |
1763 | if defined $::CONN; |
1703 | 0 |
1764 | 0 |
… | |
… | |
1705 | |
1766 | |
1706 | $r |
1767 | $r |
1707 | } |
1768 | } |
1708 | |
1769 | |
1709 | my %SORT_ORDER = ( |
1770 | my %SORT_ORDER = ( |
1710 | type => undef, |
1771 | type => sub { |
|
|
1772 | sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ |
|
|
1773 | }, |
1711 | mtime => sub { |
1774 | mtime => sub { |
1712 | my $NOW = time; |
1775 | my $NOW = time; |
1713 | sort { |
1776 | sort { |
1714 | my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; |
1777 | my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; |
1715 | my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; |
1778 | my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; |
… | |
… | |
1724 | or $a->{type} <=> $b->{type} |
1787 | or $a->{type} <=> $b->{type} |
1725 | } @_ }, |
1788 | } @_ }, |
1726 | ); |
1789 | ); |
1727 | |
1790 | |
1728 | sub inventory_widget { |
1791 | sub inventory_widget { |
1729 | my $hb = new CFPlus::UI::HBox homogeneous => 1; |
1792 | my $hb = new DC::UI::HBox homogeneous => 1; |
1730 | |
1793 | |
1731 | $hb->add (my $vb1 = new CFPlus::UI::VBox); |
1794 | $hb->add (my $vb1 = new DC::UI::VBox); |
1732 | $vb1->add (new CFPlus::UI::Label align => 0, text => "Player"); |
1795 | $vb1->add (new DC::UI::Label text => "Player"); |
1733 | |
1796 | |
1734 | $vb1->add (my $hb1 = new CFPlus::UI::HBox); |
1797 | $vb1->add (my $hb1 = new DC::UI::HBox); |
1735 | |
1798 | |
1736 | use sort 'stable'; |
1799 | use sort 'stable'; |
1737 | |
1800 | |
1738 | $hb1->add (new CFPlus::UI::Selector |
1801 | $hb1->add (new DC::UI::Selector |
1739 | value => $::CFG->{inv_sort}, |
1802 | value => $::CFG->{inv_sort}, |
1740 | options => [ |
1803 | options => [ |
1741 | [type => "Type/Name"], |
1804 | [type => "Type/Name"], |
1742 | [mtime => "Recent/Normal/Locked"], |
1805 | [mtime => "Recent/Normal/Locked"], |
1743 | [weight => "Weight/Type"], |
1806 | [weight => "Weight/Type"], |
… | |
… | |
1745 | on_changed => sub { |
1808 | on_changed => sub { |
1746 | $::CFG->{inv_sort} = $_[1]; |
1809 | $::CFG->{inv_sort} = $_[1]; |
1747 | $INV->set_sort_order ($SORT_ORDER{$_[1]}); |
1810 | $INV->set_sort_order ($SORT_ORDER{$_[1]}); |
1748 | }, |
1811 | }, |
1749 | ); |
1812 | ); |
1750 | $hb1->add (new CFPlus::UI::Label text => "Weight: ", align => 1, expand => 1); |
1813 | $hb1->add (new DC::UI::Label text => "Weight: ", align => 1, expand => 1); |
1751 | #TODO# update to weigh/maxweight |
1814 | #TODO# update to weigh/maxweight |
1752 | $hb1->add ($STATWIDS->{i_weight} = new CFPlus::UI::Label align => -1); |
1815 | $hb1->add ($STATWIDS->{i_weight} = new DC::UI::Label align => 0); |
1753 | |
1816 | |
1754 | $vb1->add (my $sw1 = new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1817 | $vb1->add (my $sw1 = new DC::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1755 | $sw1->add ($INV = new CFPlus::UI::Inventory); |
1818 | $sw1->add ($INV = new DC::UI::Inventory); |
1756 | $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}}); |
1819 | $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}}); |
1757 | |
1820 | |
1758 | $hb->add (my $vb2 = new CFPlus::UI::VBox); |
1821 | $hb->add (my $vb2 = new DC::UI::VBox); |
1759 | |
1822 | |
1760 | $vb2->add ($INVR_HB = new CFPlus::UI::HBox); |
1823 | $vb2->add ($INVR_HB = new DC::UI::HBox); |
1761 | |
1824 | |
1762 | $vb2->add (my $sw2 = new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1825 | $vb2->add (my $sw2 = new DC::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1763 | $sw2->add ($INVR = new CFPlus::UI::Inventory); |
1826 | $sw2->add ($INVR = new DC::UI::Inventory); |
1764 | |
1827 | |
1765 | # XXX: Call after $INVR = ... because set_opencont sets the items |
1828 | # XXX: Call after $INVR = ... because set_opencont sets the items |
1766 | CFPlus::Protocol::set_opencont ($::CONN, 0, "Floor"); |
1829 | DC::Protocol::set_opencont ($::CONN, 0, "Floor"); |
1767 | |
1830 | |
1768 | $hb |
1831 | $hb |
1769 | } |
1832 | } |
1770 | |
1833 | |
1771 | sub media_window { |
1834 | sub media_window { |
1772 | my $vb = new CFPlus::UI::VBox; |
1835 | my $vb = new DC::UI::VBox; |
1773 | |
1836 | |
1774 | $vb->add (new CFPlus::UI::FancyFrame |
1837 | $vb->add (new DC::UI::FancyFrame |
1775 | label => "Currently playing music", |
1838 | label => "Currently playing music", |
1776 | child => new CFPlus::UI::ScrolledWindow scroll_x => 1, scroll_y => 0, |
1839 | child => new DC::UI::ScrolledWindow scroll_x => 1, scroll_y => 0, |
1777 | child => ($MUSIC_PLAYING_WIDGET = new CFPlus::UI::Label ellipsise => 0, fontsize => 0.8), |
1840 | child => ($MUSIC_PLAYING_WIDGET = new DC::UI::Label ellipsise => 0, fontsize => 0.8), |
1778 | ); |
1841 | ); |
1779 | |
1842 | |
1780 | $vb->add (new CFPlus::UI::FancyFrame |
1843 | $vb->add (new DC::UI::FancyFrame |
1781 | label => "Other media used in this session", |
1844 | label => "Other media used in this session", |
1782 | expand => 1, |
1845 | expand => 1, |
1783 | child => ($LICENSE_WIDGET = new CFPlus::UI::TextScroller |
1846 | child => ($LICENSE_WIDGET = new DC::UI::TextScroller |
1784 | expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4), |
1847 | expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4), |
1785 | ); |
1848 | ); |
1786 | |
1849 | |
1787 | $vb |
1850 | $vb |
1788 | } |
1851 | } |
… | |
… | |
1797 | or return; |
1860 | or return; |
1798 | |
1861 | |
1799 | $LICENSE_WIDGET->add_paragraph ({ |
1862 | $LICENSE_WIDGET->add_paragraph ({ |
1800 | fg => [1, 1, 1, 1], |
1863 | fg => [1, 1, 1, 1], |
1801 | markup => "<small>" |
1864 | markup => "<small>" |
1802 | . "<b>Name:</b> " . (CFPlus::asxml $meta->{name}) . "\n" |
1865 | . "<b>Name:</b> " . (DC::asxml $meta->{name}) . "\n" |
1803 | . "<b>Author:</b> " . (CFPlus::asxml $meta->{author}) . "\n" |
1866 | . "<b>Author:</b> " . (DC::asxml $meta->{author}) . "\n" |
1804 | . "<b>Source:</b> " . (CFPlus::asxml $meta->{source}) . "\n" |
1867 | . "<b>Source:</b> " . (DC::asxml $meta->{source}) . "\n" |
1805 | . "<b>License:</b> " . (CFPlus::asxml $meta->{license}) . "\n" |
1868 | . "<b>License:</b> " . (DC::asxml $meta->{license}) . "\n" |
1806 | . "</small>", |
1869 | . "</small>", |
1807 | }); |
1870 | }); |
1808 | $LICENSE_WIDGET->scroll_to_bottom; |
1871 | $LICENSE_WIDGET->scroll_to_bottom; |
1809 | } |
1872 | } |
1810 | |
1873 | |
… | |
… | |
1818 | $PL_WINDOW->show; |
1881 | $PL_WINDOW->show; |
1819 | } |
1882 | } |
1820 | } |
1883 | } |
1821 | |
1884 | |
1822 | sub player_window { |
1885 | sub player_window { |
1823 | my $plwin = $PL_WINDOW = new CFPlus::UI::Toplevel |
1886 | my $plwin = $PL_WINDOW = new DC::UI::Toplevel |
1824 | x => "center", |
1887 | x => "center", |
1825 | y => "center", |
1888 | y => "center", |
1826 | force_w => $WIDTH * 9/10, |
1889 | force_w => $WIDTH * 9/10, |
1827 | force_h => $HEIGHT * 9/10, |
1890 | force_h => $HEIGHT * 9/10, |
1828 | title => "Player", |
1891 | title => "Player", |
… | |
… | |
1830 | has_close_button => 1 |
1893 | has_close_button => 1 |
1831 | ; |
1894 | ; |
1832 | |
1895 | |
1833 | my $ntb = |
1896 | my $ntb = |
1834 | $PL_NOTEBOOK = |
1897 | $PL_NOTEBOOK = |
1835 | new CFPlus::UI::Notebook expand => 1; |
1898 | new DC::UI::Notebook expand => 1; |
1836 | |
1899 | |
1837 | $ntb->add_tab ( |
1900 | $ntb->add_tab ( |
1838 | "Statistics (F2)" => $STATS_PAGE = stats_window, |
1901 | "Statistics (F2)" => $STATS_PAGE = stats_window, |
1839 | "Shows statistics, where all your Stats and Resistances are shown." |
1902 | "Shows statistics, where all your Stats and Resistances are shown." |
1840 | ); |
1903 | ); |
1841 | $ntb->add_tab ( |
1904 | $ntb->add_tab ( |
1842 | "Skills (F3)" => $SKILL_PAGE = skill_window, |
1905 | "Skills (F3)" => $SKILL_PAGE = skill_window, |
1843 | "Shows all your Skills." |
1906 | "Shows all your Skills." |
1844 | ); |
1907 | ); |
1845 | |
1908 | |
1846 | my $spellsw = $SPELL_PAGE = new CFPlus::UI::ScrolledWindow (expand => 1, scroll_y => 1); |
1909 | my $spellsw = $SPELL_PAGE = new DC::UI::ScrolledWindow (expand => 1, scroll_y => 1); |
1847 | $spellsw->add ($SPELL_LIST = new CFPlus::UI::SpellList); |
1910 | $spellsw->add ($SPELL_LIST = new DC::UI::SpellList); |
1848 | $ntb->add_tab ( |
1911 | $ntb->add_tab ( |
1849 | "Spellbook (F4)" => $spellsw, |
1912 | "Spellbook (F4)" => $spellsw, |
1850 | "Displays all spells you have and lets you edit keyboard shortcuts for them." |
1913 | "Displays all spells you have and lets you edit keyboard shortcuts for them." |
1851 | ); |
1914 | ); |
1852 | $ntb->add_tab ( |
1915 | $ntb->add_tab ( |
… | |
… | |
1865 | $plwin->add ($ntb); |
1928 | $plwin->add ($ntb); |
1866 | $plwin |
1929 | $plwin |
1867 | } |
1930 | } |
1868 | |
1931 | |
1869 | sub keyboard_setup { |
1932 | sub keyboard_setup { |
1870 | CFPlus::Macro::keyboard_setup |
1933 | DC::Macro::keyboard_setup |
1871 | } |
1934 | } |
1872 | |
1935 | |
1873 | sub help_window { |
1936 | sub help_window { |
1874 | my $win = new CFPlus::UI::Toplevel |
1937 | my $win = new DC::UI::Toplevel |
1875 | x => 'center', |
1938 | x => 'center', |
1876 | y => 'center', |
1939 | y => 'center', |
1877 | z => 4, |
1940 | z => 4, |
1878 | name => 'doc_browser', |
1941 | name => 'doc_browser', |
1879 | force_w => int $WIDTH * 7/8, |
1942 | force_w => int $WIDTH * 7/8, |
1880 | force_h => int $HEIGHT * 7/8, |
1943 | force_h => int $HEIGHT * 7/8, |
1881 | title => "Help Browser", |
1944 | title => "Help Browser", |
1882 | has_close_button => 1; |
1945 | has_close_button => 1; |
1883 | |
1946 | |
1884 | $win->add (my $vbox = new CFPlus::UI::VBox); |
1947 | $win->add (my $vbox = new DC::UI::VBox); |
1885 | |
1948 | |
1886 | $vbox->add (new CFPlus::UI::FancyFrame |
1949 | $vbox->add (new DC::UI::FancyFrame |
1887 | label => "Navigation", |
1950 | label => "Navigation", |
1888 | child => (my $buttons = new CFPlus::UI::HBox), |
1951 | child => (my $buttons = new DC::UI::HBox), |
1889 | ); |
1952 | ); |
1890 | $vbox->add (my $viewer = new CFPlus::UI::TextScroller |
1953 | $vbox->add (my $viewer = new DC::UI::TextScroller |
1891 | expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4); |
1954 | expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4); |
1892 | |
1955 | |
1893 | my @history; |
1956 | my @history; |
1894 | my @future; |
1957 | my @future; |
1895 | my $curnode; |
1958 | my $curnode; |
… | |
… | |
1897 | my $load_node; $load_node = sub { |
1960 | my $load_node; $load_node = sub { |
1898 | my ($node, $para) = @_; |
1961 | my ($node, $para) = @_; |
1899 | |
1962 | |
1900 | $buttons->clear; |
1963 | $buttons->clear; |
1901 | |
1964 | |
1902 | $buttons->add (new CFPlus::UI::Button |
1965 | $buttons->add (new DC::UI::Button |
1903 | text => "⇤", |
1966 | text => "⇤", |
1904 | tooltip => "back to the starting page", |
1967 | tooltip => "back to the starting page", |
1905 | on_activate => sub { |
1968 | on_activate => sub { |
1906 | unshift @future, [$curnode, $viewer->current_paragraph] if $curnode; |
1969 | unshift @future, [$curnode, $viewer->current_paragraph] if $curnode; |
1907 | unshift @future, @history; |
1970 | unshift @future, @history; |
… | |
… | |
1909 | $load_node->(@{shift @future}); |
1972 | $load_node->(@{shift @future}); |
1910 | }, |
1973 | }, |
1911 | ); |
1974 | ); |
1912 | |
1975 | |
1913 | if (@history) { |
1976 | if (@history) { |
1914 | $buttons->add (new CFPlus::UI::Button |
1977 | $buttons->add (new DC::UI::Button |
1915 | text => "⋘", |
1978 | text => "⋘", |
1916 | tooltip => "back to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $history[-1][0]) . "</i>", |
1979 | tooltip => "back to <i>" . (DC::asxml DC::Pod::full_path $history[-1][0]) . "</i>", |
1917 | on_activate => sub { |
1980 | on_activate => sub { |
1918 | unshift @future, [$curnode, $viewer->current_paragraph] if $curnode; |
1981 | unshift @future, [$curnode, $viewer->current_paragraph] if $curnode; |
1919 | $load_node->(@{pop @history}); |
1982 | $load_node->(@{pop @history}); |
1920 | }, |
1983 | }, |
1921 | ); |
1984 | ); |
1922 | } |
1985 | } |
1923 | |
1986 | |
1924 | if (@future) { |
1987 | if (@future) { |
1925 | $buttons->add (new CFPlus::UI::Button |
1988 | $buttons->add (new DC::UI::Button |
1926 | text => "⋙", |
1989 | text => "⋙", |
1927 | tooltip => "forward to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $future[0][0]) . "</i>", |
1990 | tooltip => "forward to <i>" . (DC::asxml DC::Pod::full_path $future[0][0]) . "</i>", |
1928 | on_activate => sub { |
1991 | on_activate => sub { |
1929 | push @history, [$curnode, $viewer->current_paragraph]; |
1992 | push @history, [$curnode, $viewer->current_paragraph]; |
1930 | $load_node->(@{shift @future}); |
1993 | $load_node->(@{shift @future}); |
1931 | }, |
1994 | }, |
1932 | ); |
1995 | ); |
1933 | } |
1996 | } |
1934 | |
1997 | |
1935 | $buttons->add (new CFPlus::UI::Label text => " "); |
1998 | $buttons->add (new DC::UI::Label text => " "); |
1936 | |
1999 | |
1937 | my @path = CFPlus::Pod::full_path_of $node; |
2000 | my @path = DC::Pod::full_path_of $node; |
1938 | pop @path; # drop current node |
2001 | pop @path; # drop current node |
1939 | |
2002 | |
1940 | for my $node (@path) { |
2003 | for my $node (@path) { |
1941 | $buttons->add (new CFPlus::UI::Button |
2004 | $buttons->add (new DC::UI::Button |
1942 | text => $node->{kw}[0], |
2005 | text => $node->[DC::Pod::N_KW][0], |
1943 | tooltip => "go to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $node) . "</i>", |
2006 | tooltip => "go to <i>" . (DC::asxml DC::Pod::full_path $node) . "</i>", |
1944 | on_activate => sub { |
2007 | on_activate => sub { |
1945 | push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); |
2008 | push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); |
1946 | $load_node->($node); |
2009 | $load_node->($node); |
1947 | }, |
2010 | }, |
1948 | ); |
2011 | ); |
1949 | $buttons->add (new CFPlus::UI::Label text => "/"); |
2012 | $buttons->add (new DC::UI::Label text => "/"); |
1950 | } |
2013 | } |
1951 | |
2014 | |
1952 | $buttons->add (new CFPlus::UI::Label text => $node->{kw}[0], padding_x => 4, padding_y => 4); |
2015 | $buttons->add (new DC::UI::Label text => $node->[DC::Pod::N_KW][0], padding_x => 4, padding_y => 4); |
1953 | |
2016 | |
1954 | $curnode = $node; |
2017 | $curnode = $node; |
1955 | |
2018 | |
1956 | $viewer->clear; |
2019 | $viewer->clear; |
1957 | $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $curnode); |
2020 | $viewer->add_paragraph (DC::Pod::as_paragraphs DC::Pod::section_of $curnode); |
1958 | $viewer->scroll_to ($para); |
2021 | $viewer->scroll_to ($para); |
1959 | }; |
2022 | }; |
1960 | |
2023 | |
1961 | $load_node->(CFPlus::Pod::find pod => "mainpage"); |
2024 | $load_node->(DC::Pod::find pod => "mainpage"); |
1962 | |
2025 | |
1963 | $CFPlus::Pod::goto_document = sub { |
2026 | $DC::Pod::goto_document = sub { |
1964 | my (@path) = @_; |
2027 | my (@path) = @_; |
1965 | |
2028 | |
1966 | push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); |
2029 | push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); |
1967 | |
2030 | |
1968 | $load_node->((CFPlus::Pod::find @path)[0]); |
2031 | $load_node->((DC::Pod::find @path)[0]); |
1969 | $win->show; |
2032 | $win->show; |
1970 | }; |
2033 | }; |
1971 | |
2034 | |
1972 | $win |
2035 | $win |
1973 | } |
2036 | } |
1974 | |
2037 | |
1975 | sub open_string_query { |
2038 | sub open_string_query { |
1976 | my ($title, $cb, $txt, $tooltip) = @_; |
2039 | my ($title, $cb, $txt, $tooltip) = @_; |
1977 | my $dialog = new CFPlus::UI::Toplevel |
2040 | my $dialog = new DC::UI::Toplevel |
1978 | x => "center", |
2041 | x => "center", |
1979 | y => "center", |
2042 | y => "center", |
1980 | z => 50, |
2043 | z => 50, |
1981 | force_w => $WIDTH * 4/5, |
2044 | force_w => $WIDTH * 4/5, |
1982 | title => $title; |
2045 | title => $title; |
1983 | |
2046 | |
1984 | $dialog->add ( |
2047 | $dialog->add ( |
1985 | my $e = new CFPlus::UI::Entry |
2048 | my $e = new DC::UI::Entry |
1986 | on_activate => sub { $cb->(@_); $dialog->hide; 0 }, |
2049 | on_activate => sub { $cb->(@_); $dialog->hide; 0 }, |
1987 | on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 }, |
2050 | on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 }, |
1988 | tooltip => $tooltip |
2051 | tooltip => $tooltip |
1989 | ); |
2052 | ); |
1990 | |
2053 | |
… | |
… | |
1993 | $dialog->show; |
2056 | $dialog->show; |
1994 | } |
2057 | } |
1995 | |
2058 | |
1996 | sub open_quit_dialog { |
2059 | sub open_quit_dialog { |
1997 | unless ($QUIT_DIALOG) { |
2060 | unless ($QUIT_DIALOG) { |
1998 | $QUIT_DIALOG = new CFPlus::UI::Toplevel |
2061 | $QUIT_DIALOG = new DC::UI::Toplevel |
1999 | x => "center", |
2062 | x => "center", |
2000 | y => "center", |
2063 | y => "center", |
2001 | z => 50, |
2064 | z => 50, |
2002 | title => "Really Quit?", |
2065 | title => "Really Quit?", |
2003 | on_key_down => sub { |
2066 | on_key_down => sub { |
2004 | my ($dialog, $ev) = @_; |
2067 | my ($dialog, $ev) = @_; |
2005 | $ev->{sym} == 27 and $dialog->hide; |
2068 | $ev->{sym} == 27 and $dialog->hide; |
2006 | } |
2069 | } |
2007 | ; |
2070 | ; |
2008 | |
2071 | |
2009 | $QUIT_DIALOG->add (my $vb = new CFPlus::UI::VBox expand => 1); |
2072 | $QUIT_DIALOG->add (my $vb = new DC::UI::VBox expand => 1); |
2010 | |
2073 | |
2011 | $vb->add (new CFPlus::UI::Label |
2074 | $vb->add (new DC::UI::Label |
2012 | text => "You should find a savebed and apply it first!", |
2075 | text => "You should find a savebed and apply it first!", |
2013 | max_w => $WIDTH * 0.25, |
2076 | max_w => $WIDTH * 0.25, |
2014 | ellipsize => 0, |
2077 | ellipsize => 0, |
2015 | ); |
2078 | ); |
2016 | $vb->add (my $hb = new CFPlus::UI::HBox expand => 1); |
2079 | $vb->add (my $hb = new DC::UI::HBox expand => 1); |
2017 | $hb->add (new CFPlus::UI::Button |
2080 | $hb->add (new DC::UI::Button |
2018 | text => "Ok", |
2081 | text => "Ok", |
2019 | expand => 1, |
2082 | expand => 1, |
2020 | on_activate => sub { $QUIT_DIALOG->hide; 0 }, |
2083 | on_activate => sub { $QUIT_DIALOG->hide; 0 }, |
2021 | ); |
2084 | ); |
2022 | $hb->add (new CFPlus::UI::Button |
2085 | $hb->add (new DC::UI::Button |
2023 | text => "Quit anyway", |
2086 | text => "Quit anyway", |
2024 | expand => 1, |
2087 | expand => 1, |
2025 | on_activate => sub { EV::unloop EV::UNLOOP_ALL }, |
2088 | on_activate => sub { EV::unloop EV::UNLOOP_ALL }, |
2026 | ); |
2089 | ); |
2027 | } |
2090 | } |
… | |
… | |
2030 | $QUIT_DIALOG->grab_focus; |
2093 | $QUIT_DIALOG->grab_focus; |
2031 | } |
2094 | } |
2032 | |
2095 | |
2033 | sub show_tip_of_the_day { |
2096 | sub show_tip_of_the_day { |
2034 | # find all tips |
2097 | # find all tips |
2035 | my @tod = CFPlus::Pod::find tip_of_the_day => "*"; |
2098 | my @tod = DC::Pod::find tip_of_the_day => "*"; |
2036 | |
2099 | |
2037 | CFPlus::DB::get state => "tip_of_the_day", sub { |
2100 | DC::DB::get state => "tip_of_the_day", sub { |
2038 | my ($todindex) = @_; |
2101 | my ($todindex) = @_; |
2039 | $todindex = 0 if $todindex >= @tod; |
2102 | $todindex = 0 if $todindex >= @tod; |
2040 | CFPlus::DB::put state => tip_of_the_day => $todindex + 1, sub { }; |
2103 | DC::DB::put state => tip_of_the_day => $todindex + 1, sub { }; |
2041 | |
2104 | |
2042 | # create dialog |
2105 | # create dialog |
2043 | my $dialog; |
2106 | my $dialog; |
2044 | |
2107 | |
2045 | my $close = sub { |
2108 | my $close = sub { |
2046 | $dialog->destroy; |
2109 | $dialog->destroy; |
2047 | }; |
2110 | }; |
2048 | |
2111 | |
2049 | $dialog = new CFPlus::UI::Toplevel |
2112 | $dialog = new DC::UI::Toplevel |
2050 | x => "center", |
2113 | x => "center", |
2051 | y => "center", |
2114 | y => "center", |
2052 | z => 3, |
2115 | z => 3, |
2053 | name => 'tip_of_the_day', |
2116 | name => 'tip_of_the_day', |
2054 | force_w => int $WIDTH * 4/9, |
2117 | force_w => int $WIDTH * 4/9, |
2055 | force_h => int $WIDTH * 2/9, |
2118 | force_h => int $WIDTH * 2/9, |
2056 | title => "Tip of the day #" . (1 + $todindex), |
2119 | title => "Tip of the day #" . (1 + $todindex), |
2057 | child => my $vbox = new CFPlus::UI::VBox, |
2120 | child => my $vbox = new DC::UI::VBox, |
2058 | has_close_button => 1, |
2121 | has_close_button => 1, |
2059 | on_delete => $close, |
2122 | on_delete => $close, |
2060 | ; |
2123 | ; |
2061 | |
2124 | |
2062 | $vbox->add (my $viewer = new CFPlus::UI::TextScroller |
2125 | $vbox->add (my $viewer = new DC::UI::TextScroller |
2063 | expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4); |
2126 | expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4); |
2064 | $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $tod[$todindex]); |
2127 | $viewer->add_paragraph (DC::Pod::as_paragraphs DC::Pod::section_of $tod[$todindex]); |
2065 | |
2128 | |
2066 | $vbox->add (my $table = new CFPlus::UI::Table col_expand => [0, 1]); |
2129 | $vbox->add (my $table = new DC::UI::Table col_expand => [0, 1]); |
2067 | |
2130 | |
2068 | $table->add_at (0, 0, new CFPlus::UI::Button |
2131 | $table->add_at (0, 0, new DC::UI::Button |
2069 | text => "Close", |
2132 | text => "Close", |
2070 | tooltip => "Close the tip of the day window. To never see it again, disable the tip of the day in the <b>Server Setup</b>.", |
2133 | tooltip => "Close the tip of the day window. To never see it again, disable the tip of the day in the <b>Server Setup</b>.", |
2071 | on_activate => $close, |
2134 | on_activate => $close, |
2072 | ); |
2135 | ); |
2073 | |
2136 | |
2074 | $table->add_at (2, 0, new CFPlus::UI::Button |
2137 | $table->add_at (2, 0, new DC::UI::Button |
2075 | text => "Next", |
2138 | text => "Next", |
2076 | tooltip => "Show the next <b>Tip of the day</b>.", |
2139 | tooltip => "Show the next <b>Tip of the day</b>.", |
2077 | on_activate => sub { |
2140 | on_activate => sub { |
2078 | $close->(); |
2141 | $close->(); |
2079 | &show_tip_of_the_day; |
2142 | &show_tip_of_the_day; |
… | |
… | |
2083 | $dialog->show; |
2146 | $dialog->show; |
2084 | }; |
2147 | }; |
2085 | } |
2148 | } |
2086 | |
2149 | |
2087 | sub sdl_init { |
2150 | sub sdl_init { |
2088 | CFPlus::SDL_Init |
2151 | DC::SDL_Init |
2089 | and die "SDL::Init failed!\n"; |
2152 | and die "SDL::Init failed!\n"; |
2090 | } |
2153 | } |
2091 | |
2154 | |
2092 | sub video_init { |
2155 | sub video_init { |
2093 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} >= @SDL_MODES; |
2156 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} >= @SDL_MODES; |
… | |
… | |
2096 | |
2159 | |
2097 | ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
2160 | ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
2098 | $FULLSCREEN = $CFG->{fullscreen}; |
2161 | $FULLSCREEN = $CFG->{fullscreen}; |
2099 | $FAST = $CFG->{fast}; |
2162 | $FAST = $CFG->{fast}; |
2100 | |
2163 | |
2101 | CFPlus::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, $FULLSCREEN |
2164 | DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, $FULLSCREEN |
2102 | or die "SDL_SetVideoMode failed: " . (CFPlus::SDL_GetError) . "\n"; |
2165 | or die "SDL_SetVideoMode failed: " . (DC::SDL_GetError) . "\n"; |
2103 | |
2166 | |
2104 | $SDL_ACTIVE = 1; |
2167 | $SDL_ACTIVE = 1; |
2105 | $LAST_REFRESH = time - 0.01; |
2168 | $LAST_REFRESH = time - 0.01; |
2106 | |
2169 | |
2107 | CFPlus::OpenGL::init; |
2170 | DC::OpenGL::init; |
2108 | CFPlus::Macro::init; |
2171 | DC::Macro::init; |
2109 | |
2172 | |
2110 | $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
2173 | $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
2111 | |
2174 | |
2112 | $CFPlus::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d# |
2175 | $DC::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d# |
2113 | |
2176 | |
2114 | ############################################################################# |
2177 | ############################################################################# |
2115 | |
2178 | |
2116 | if ($DEBUG_STATUS) { |
2179 | if ($DEBUG_STATUS) { |
2117 | CFPlus::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h; |
2180 | DC::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h; |
2118 | } else { |
2181 | } else { |
2119 | # create/configure the widgets |
2182 | # create/configure the widgets |
2120 | |
2183 | |
2121 | $CFPlus::UI::ROOT->connect (key_down => sub { |
2184 | $DC::UI::ROOT->connect (key_down => sub { |
2122 | my (undef, $ev) = @_; |
2185 | my (undef, $ev) = @_; |
2123 | |
2186 | |
2124 | if (my @macros = CFPlus::Macro::find $ev) { |
2187 | if (my @macros = DC::Macro::find $ev) { |
2125 | CFPlus::Macro::execute $_ for @macros; |
2188 | DC::Macro::execute $_ for @macros; |
2126 | |
2189 | |
2127 | return 1; |
2190 | return 1; |
2128 | } |
2191 | } |
2129 | |
2192 | |
2130 | 0 |
2193 | 0 |
2131 | }); |
2194 | }); |
2132 | |
2195 | |
2133 | $DEBUG_STATUS = new CFPlus::UI::Label |
2196 | $DEBUG_STATUS = new DC::UI::Label |
2134 | padding => 0, |
2197 | padding => 0, |
2135 | z => 100, |
2198 | z => 100, |
2136 | force_x => "max", |
2199 | force_x => "max", |
2137 | force_y => 0; |
2200 | force_y => 0; |
2138 | $DEBUG_STATUS->show; |
2201 | $DEBUG_STATUS->show; |
2139 | |
2202 | |
2140 | $STATUSBOX = new CFPlus::UI::Statusbox; |
2203 | $STATUSBOX = new DC::UI::Statusbox; |
2141 | $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", timeout => 864000, pri => -100, color => [1, 1, 1, 0.8]); |
|
|
2142 | |
2204 | |
|
|
2205 | $MODBOX = new DC::UI::Label |
|
|
2206 | can_events => 1, |
|
|
2207 | can_hover => 1, |
|
|
2208 | markup => "", |
|
|
2209 | align => 0, |
|
|
2210 | font => $FONT_FIXED, |
|
|
2211 | tooltip => "#modifier_box", |
|
|
2212 | tooltip_width => 0.67, |
|
|
2213 | ; |
|
|
2214 | |
|
|
2215 | update_modbox; |
|
|
2216 | |
2143 | (new CFPlus::UI::Frame |
2217 | (new DC::UI::Frame |
2144 | bg => [0, 0, 0, 0.4], |
2218 | bg => [0, 0, 0, 0.4], |
2145 | force_x => 0, |
2219 | force_x => 0, |
2146 | force_y => "max", |
2220 | force_y => "max", |
2147 | child => $STATUSBOX, |
2221 | child => (my $LR = new DC::UI::VBox), |
2148 | )->show; |
2222 | )->show; |
2149 | |
2223 | |
|
|
2224 | $LR->add ($STATUSBOX); |
|
|
2225 | $LR->add ($MODBOX); |
|
|
2226 | $LR->add (new DC::UI::Label |
|
|
2227 | align => 0, |
|
|
2228 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode", |
|
|
2229 | fontsize => 0.5, |
|
|
2230 | fg => [1, 1, 0, 0.7], |
|
|
2231 | ); |
|
|
2232 | |
2150 | CFPlus::UI::Toplevel->new ( |
2233 | DC::UI::Toplevel->new ( |
2151 | title => "Minimap", |
2234 | title => "Minimap", |
2152 | name => "mapmap", |
2235 | name => "mapmap", |
2153 | x => 0, |
2236 | x => 0, |
2154 | y => $FONTSIZE + 8, |
2237 | y => $FONTSIZE + 8, |
2155 | border_bg => [1, 1, 1, 192/255], |
2238 | border_bg => [1, 1, 1, 192/255], |
2156 | bg => [1, 1, 1, 0], |
2239 | bg => [1, 1, 1, 0], |
2157 | child => ($MAPMAP = new CFPlus::MapWidget::MapMap |
2240 | child => ($MAPMAP = new DC::MapWidget::MapMap |
2158 | tooltip => "<b>Map</b>. On servers that support this feature, this will display an overview of the surrounding areas.", |
2241 | tooltip => "<b>Map</b>. On servers that support this feature, this will display an overview of the surrounding areas.", |
2159 | ), |
2242 | ), |
2160 | )->show; |
2243 | )->show; |
2161 | |
2244 | |
2162 | $MAPWIDGET = new CFPlus::MapWidget; |
2245 | $MAPWIDGET = new DC::MapWidget; |
2163 | $MAPWIDGET->connect (activate_console => sub { |
2246 | $MAPWIDGET->connect (activate_console => sub { |
2164 | my ($mapwidget, $preset) = @_; |
2247 | my ($mapwidget, $preset) = @_; |
2165 | |
2248 | |
2166 | $MESSAGE_WINDOW->activate_console ($preset) |
2249 | $MESSAGE_DIST->activate_console ($preset) |
2167 | if $MESSAGE_WINDOW; |
2250 | if $MESSAGE_DIST; |
2168 | }); |
2251 | }); |
2169 | $MAPWIDGET->show; |
2252 | $MAPWIDGET->show; |
2170 | $MAPWIDGET->grab_focus; |
2253 | $MAPWIDGET->grab_focus; |
2171 | |
2254 | |
2172 | $COMPLETER = new CFPlus::MapWidget::Command:: |
2255 | $COMPLETER = new DC::MapWidget::Command:: |
2173 | command => { }, |
2256 | command => { }, |
2174 | tooltip => "#completer_help", |
2257 | tooltip => "#completer_help", |
2175 | ; |
2258 | ; |
2176 | |
2259 | |
2177 | $SETUP_DIALOG = new CFPlus::UI::Toplevel |
2260 | $SETUP_DIALOG = new DC::UI::Toplevel |
2178 | title => "Setup", |
2261 | title => "Setup", |
2179 | name => "setup_dialog", |
2262 | name => "setup_dialog", |
2180 | x => 'center', |
2263 | x => 'center', |
2181 | y => 'center', |
2264 | y => 'center', |
2182 | z => 2, |
2265 | z => 2, |
… | |
… | |
2184 | force_h => $::HEIGHT * 0.6, |
2267 | force_h => $::HEIGHT * 0.6, |
2185 | has_close_button => 1, |
2268 | has_close_button => 1, |
2186 | ; |
2269 | ; |
2187 | |
2270 | |
2188 | $METASERVER = metaserver_dialog; |
2271 | $METASERVER = metaserver_dialog; |
2189 | $MESSAGE_WINDOW = new CFPlus::UI::MessageWindow; |
2272 | # the name is changed to not conflict with the older name as users could have hidden it |
|
|
2273 | $MESSAGE_WINDOW = new DC::UI::Dockbar |
|
|
2274 | name => "message_window2", |
|
|
2275 | title => 'Messages', |
|
|
2276 | force_w => $::WIDTH * 0.6, |
|
|
2277 | force_h => $::HEIGHT * 0.25, |
|
|
2278 | ; |
2190 | |
2279 | |
|
|
2280 | $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; |
|
|
2281 | |
2191 | $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFPlus::UI::Notebook expand => 1, debug => 1, |
2282 | $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new DC::UI::Notebook expand => 1, |
2192 | filter => new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); |
2283 | filter => new DC::UI::ScrolledWindow expand => 1, scroll_y => 1); |
2193 | |
2284 | |
2194 | $SETUP_NOTEBOOK->add_tab (Login => $SETUP_LOGIN = login_setup, |
2285 | $SETUP_NOTEBOOK->add_tab (Login => $SETUP_LOGIN = login_setup, |
2195 | "Configure the server to play on, your username and password."); |
2286 | "Configure the server to play on, your username and password."); |
2196 | $SETUP_NOTEBOOK->add_tab (Server => $SETUP_SERVER = server_setup, |
2287 | $SETUP_NOTEBOOK->add_tab (Server => $SETUP_SERVER = server_setup, |
2197 | "Configure other server related options."); |
2288 | "Configure other server related options."); |
… | |
… | |
2209 | . "After pressing the combo the binding will be saved automatically and the " |
2300 | . "After pressing the combo the binding will be saved automatically and the " |
2210 | . "binding editor closes"); |
2301 | . "binding editor closes"); |
2211 | $SETUP_NOTEBOOK->add_tab (Debug => debug_setup, |
2302 | $SETUP_NOTEBOOK->add_tab (Debug => debug_setup, |
2212 | "Some debuggin' options. Do not ask."); |
2303 | "Some debuggin' options. Do not ask."); |
2213 | |
2304 | |
2214 | $BUTTONBAR = new CFPlus::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
2305 | $BUTTONBAR = new DC::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
2215 | |
2306 | |
2216 | $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
2307 | $BUTTONBAR->add (new DC::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
2217 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
2308 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
2218 | |
2309 | |
2219 | $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, |
2310 | # $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, |
2220 | tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
2311 | # tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
2221 | |
2312 | |
2222 | make_gauge_window->show; # 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 |
2313 | make_gauge_window->show; # 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 |
2223 | |
2314 | |
2224 | $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Playerbook", other => player_window, |
2315 | $BUTTONBAR->add (new DC::UI::Flopper text => "Playerbook", other => player_window, |
2225 | tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats."); |
2316 | tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats."); |
2226 | |
2317 | |
2227 | $BUTTONBAR->add (new CFPlus::UI::Button |
2318 | $BUTTONBAR->add (new DC::UI::Button |
2228 | text => "Save Config", |
2319 | text => "Save Config", |
2229 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
2320 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
2230 | on_activate => sub { |
2321 | on_activate => sub { |
2231 | $::CFG->{layout} = CFPlus::UI::get_layout; |
2322 | $::CFG->{layout} = DC::UI::get_layout; |
2232 | CFPlus::write_cfg "$Deliantra::VARDIR/cfplusrc"; |
2323 | DC::write_cfg; |
2233 | status "Configuration Saved"; |
2324 | status "Configuration Saved"; |
2234 | 0 |
2325 | 0 |
2235 | }, |
2326 | }, |
2236 | ); |
2327 | ); |
2237 | |
2328 | |
2238 | $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, |
2329 | $BUTTONBAR->add (new DC::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, |
2239 | tooltip => "View Documentation"); |
2330 | tooltip => "View Documentation"); |
2240 | |
2331 | |
2241 | |
|
|
2242 | $BUTTONBAR->add (new CFPlus::UI::Button |
2332 | $BUTTONBAR->add (new DC::UI::Button |
2243 | text => "Quit", |
2333 | text => "Quit", |
2244 | tooltip => "Terminates the program", |
2334 | tooltip => "Terminates the program", |
2245 | on_activate => sub { |
2335 | on_activate => sub { |
2246 | if ($CONN) { |
2336 | if ($CONN) { |
2247 | open_quit_dialog; |
2337 | open_quit_dialog; |
… | |
… | |
2259 | |
2349 | |
2260 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
2350 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
2261 | } |
2351 | } |
2262 | |
2352 | |
2263 | sub video_shutdown { |
2353 | sub video_shutdown { |
2264 | CFPlus::OpenGL::shutdown; |
2354 | DC::OpenGL::shutdown; |
2265 | |
2355 | |
2266 | undef $SDL_ACTIVE; |
2356 | undef $SDL_ACTIVE; |
2267 | } |
2357 | } |
2268 | |
2358 | |
2269 | my %animate_object; |
2359 | my %animate_object; |
… | |
… | |
2275 | if ($ENV{CFPLUS_DEBUG} & 4) { |
2365 | if ($ENV{CFPLUS_DEBUG} & 4) { |
2276 | $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; |
2366 | $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; |
2277 | debug sprintf "%3.2f", $fps; |
2367 | debug sprintf "%3.2f", $fps; |
2278 | } |
2368 | } |
2279 | |
2369 | |
2280 | $WANT_REFRESH->stop; |
2370 | undef $WANT_REFRESH; |
|
|
2371 | $_[0]->stop; |
2281 | |
2372 | |
2282 | $CFPlus::UI::ROOT->draw; |
2373 | $DC::UI::ROOT->draw; |
2283 | CFPlus::SDL_GL_SwapBuffers; |
2374 | DC::SDL_GL_SwapBuffers; |
2284 | $LAST_REFRESH = $NOW; |
2375 | $LAST_REFRESH = $NOW; |
2285 | } |
2376 | } |
2286 | |
2377 | |
2287 | $WANT_REFRESH = EV::idle_ns \&force_refresh; |
2378 | my $want_refresh = EV::prepare_ns \&force_refresh; |
2288 | |
2379 | |
2289 | # 0.015 is server tick time / 8 ~~ 66.6...hz |
|
|
2290 | my $input = EV::periodic 0, 0.015, undef, sub { |
2380 | my $input = EV::periodic 0, 1 / $MAX_FPS, undef, sub { |
2291 | $NOW = time; |
2381 | $NOW = EV::now; |
2292 | |
2382 | |
2293 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
2383 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
2294 | for CFPlus::poll_events; |
2384 | for DC::poll_events; |
2295 | |
2385 | |
2296 | if (%animate_object) { |
2386 | if (%animate_object) { |
2297 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2387 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2298 | $WANT_REFRESH->start; |
2388 | $WANT_REFRESH = 1; |
2299 | } |
2389 | } |
|
|
2390 | |
|
|
2391 | $want_refresh->start |
|
|
2392 | if $WANT_REFRESH; |
2300 | }; |
2393 | }; |
2301 | |
2394 | |
2302 | sub animation_start { |
2395 | sub animation_start { |
2303 | my ($widget) = @_; |
2396 | my ($widget) = @_; |
2304 | $animate_object{$widget} = $widget; |
2397 | $animate_object{$widget} = $widget; |
… | |
… | |
2308 | my ($widget) = @_; |
2401 | my ($widget) = @_; |
2309 | delete $animate_object{$widget}; |
2402 | delete $animate_object{$widget}; |
2310 | } |
2403 | } |
2311 | |
2404 | |
2312 | %SDL_CB = ( |
2405 | %SDL_CB = ( |
2313 | CFPlus::SDL_QUIT => sub { |
2406 | DC::SDL_QUIT => sub { |
2314 | EV::unloop EV::UNLOOP_ALL; |
2407 | EV::unloop EV::UNLOOP_ALL; |
2315 | }, |
2408 | }, |
2316 | CFPlus::SDL_VIDEORESIZE => sub { |
2409 | DC::SDL_VIDEORESIZE => sub { |
2317 | }, |
2410 | }, |
2318 | CFPlus::SDL_VIDEOEXPOSE => sub { |
2411 | DC::SDL_VIDEOEXPOSE => sub { |
2319 | CFPlus::UI::full_refresh; |
2412 | DC::UI::full_refresh; |
2320 | }, |
2413 | }, |
2321 | CFPlus::SDL_ACTIVEEVENT => sub { |
2414 | DC::SDL_ACTIVEEVENT => sub { |
2322 | # not useful, as APPACTIVE includes only iconified state, not unmapped |
2415 | # not useful, as APPACTIVE includes only iconified state, not unmapped |
2323 | # printf "active %x %x %x\n", $_[0]{gain}, $_[0]{state}, CFPlus::SDL_GetAppState;#d# |
2416 | # printf "active %x %x %x\n", $_[0]{gain}, $_[0]{state}, DC::SDL_GetAppState;#d# |
2324 | # printf "a %x\n", CFPlus::SDL_GetAppState & CFPlus::SDL_APPACTIVE;#d# |
2417 | # printf "a %x\n", DC::SDL_GetAppState & DC::SDL_APPACTIVE;#d# |
2325 | # printf "A\n" if $_[0]{state} & CFPlus::SDL_APPACTIVE; |
2418 | # printf "A\n" if $_[0]{state} & DC::SDL_APPACTIVE; |
2326 | # printf "K\n" if $_[0]{state} & CFPlus::SDL_APPINPUTFOCUS; |
2419 | # printf "K\n" if $_[0]{state} & DC::SDL_APPINPUTFOCUS; |
2327 | # printf "M\n" if $_[0]{state} & CFPlus::SDL_APPMOUSEFOCUS; |
2420 | # printf "M\n" if $_[0]{state} & DC::SDL_APPMOUSEFOCUS; |
2328 | }, |
2421 | }, |
2329 | CFPlus::SDL_KEYDOWN => sub { |
2422 | DC::SDL_KEYDOWN => sub { |
2330 | if ($_[0]{mod} & CFPlus::KMOD_ALT && $_[0]{sym} == 13) { |
2423 | if ($_[0]{mod} & DC::KMOD_ALT && $_[0]{sym} == 13) { |
2331 | # alt-enter |
2424 | # alt-enter |
2332 | $FULLSCREEN_ENABLE->toggle; |
2425 | $FULLSCREEN_ENABLE->toggle; |
2333 | video_shutdown; |
2426 | video_shutdown; |
2334 | video_init; |
2427 | video_init; |
2335 | } else { |
2428 | } else { |
2336 | CFPlus::UI::feed_sdl_key_down_event ($_[0]); |
2429 | &DC::UI::feed_sdl_key_down_event; |
2337 | } |
2430 | } |
|
|
2431 | update_modbox; |
2338 | }, |
2432 | }, |
2339 | CFPlus::SDL_KEYUP => \&CFPlus::UI::feed_sdl_key_up_event, |
2433 | DC::SDL_KEYUP => sub { |
|
|
2434 | &DC::UI::feed_sdl_key_up_event; |
|
|
2435 | update_modbox; |
|
|
2436 | }, |
2340 | CFPlus::SDL_MOUSEMOTION => \&CFPlus::UI::feed_sdl_motion_event, |
2437 | DC::SDL_MOUSEMOTION => \&DC::UI::feed_sdl_motion_event, |
2341 | CFPlus::SDL_MOUSEBUTTONDOWN => \&CFPlus::UI::feed_sdl_button_down_event, |
2438 | DC::SDL_MOUSEBUTTONDOWN => \&DC::UI::feed_sdl_button_down_event, |
2342 | CFPlus::SDL_MOUSEBUTTONUP => \&CFPlus::UI::feed_sdl_button_up_event, |
2439 | DC::SDL_MOUSEBUTTONUP => \&DC::UI::feed_sdl_button_up_event, |
2343 | CFPlus::SDL_USEREVENT => sub { |
2440 | DC::SDL_USEREVENT => sub { |
2344 | if ($_[0]{code} == 1) { |
2441 | if ($_[0]{code} == 1) { |
2345 | audio_channel_finished $_[0]{data1}; |
2442 | audio_channel_finished $_[0]{data1}; |
2346 | } elsif ($_[0]{code} == 0) { |
2443 | } elsif ($_[0]{code} == 0) { |
2347 | audio_music_finished; |
2444 | audio_music_finished; |
2348 | } |
2445 | } |
… | |
… | |
2355 | EV::unloop; |
2452 | EV::unloop; |
2356 | #d# TODO calling exit here hangs the process in some futex |
2453 | #d# TODO calling exit here hangs the process in some futex |
2357 | }; |
2454 | }; |
2358 | |
2455 | |
2359 | { |
2456 | { |
|
|
2457 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
|
|
2458 | |
|
|
2459 | if (-e "$Deliantra::VARDIR/client.cf") { |
|
|
2460 | DC::read_cfg "$Deliantra::VARDIR/client.cf"; |
|
|
2461 | } else { |
|
|
2462 | #TODO: compatibility cruft |
2360 | CFPlus::read_cfg "$Deliantra::VARDIR/cfplusrc"; |
2463 | DC::read_cfg "$Deliantra::OLDDIR/cfplusrc"; |
|
|
2464 | print STDERR "INFO: used old configuration file\n"; |
|
|
2465 | } |
|
|
2466 | |
2361 | CFPlus::DB::Server::run; |
2467 | DC::DB::Server::run; |
2362 | |
2468 | |
|
|
2469 | if ($CFG->{db_schema} < 1) { |
|
|
2470 | warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n"; |
|
|
2471 | DC::DB::nuke_db; |
|
|
2472 | $CFG->{db_schema} = 1; |
|
|
2473 | DC::write_cfg; |
|
|
2474 | } |
|
|
2475 | |
|
|
2476 | DC::DB::open_db; |
|
|
2477 | |
2363 | CFPlus::UI::set_layout ($::CFG->{layout}); |
2478 | DC::UI::set_layout ($::CFG->{layout}); |
2364 | |
2479 | |
2365 | my %DEF_CFG = ( |
2480 | my %DEF_CFG = ( |
2366 | sdl_mode => 0, |
2481 | sdl_mode => 0, |
2367 | fullscreen => 1, |
2482 | fullscreen => 1, |
2368 | fast => 0, |
2483 | fast => 0, |
… | |
… | |
2391 | pickup => 0, |
2506 | pickup => 0, |
2392 | inv_sort => "mtime", |
2507 | inv_sort => "mtime", |
2393 | default => "profile", # default profile |
2508 | default => "profile", # default profile |
2394 | show_tips => 1, |
2509 | show_tips => 1, |
2395 | logview_max_par => 1000, |
2510 | logview_max_par => 1000, |
|
|
2511 | shift_fire_stop => 0, |
2396 | ); |
2512 | ); |
2397 | |
2513 | |
2398 | while (my ($k, $v) = each %DEF_CFG) { |
2514 | while (my ($k, $v) = each %DEF_CFG) { |
2399 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2515 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2400 | } |
2516 | } |
… | |
… | |
2414 | } |
2530 | } |
2415 | } |
2531 | } |
2416 | |
2532 | |
2417 | sdl_init; |
2533 | sdl_init; |
2418 | |
2534 | |
2419 | @SDL_MODES = CFPlus::SDL_ListModes 8, 8; |
2535 | @SDL_MODES = DC::SDL_ListModes 8, 8; |
2420 | @SDL_MODES = CFPlus::SDL_ListModes 5, 0 unless @SDL_MODES; |
2536 | @SDL_MODES = DC::SDL_ListModes 5, 0 unless @SDL_MODES; |
2421 | @SDL_MODES or CFPlus::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
2537 | @SDL_MODES or DC::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
2422 | |
2538 | |
2423 | @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES; |
2539 | @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES; |
2424 | |
2540 | |
2425 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
2541 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
2426 | |
2542 | |
2427 | { |
2543 | { |
2428 | my @fonts = map CFPlus::find_rcfile "fonts/$_", qw( |
2544 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
2429 | DejaVuSans.ttf |
2545 | DejaVuSans.ttf |
2430 | DejaVuSansMono.ttf |
2546 | DejaVuSansMono.ttf |
2431 | DejaVuSans-Bold.ttf |
2547 | DejaVuSans-Bold.ttf |
2432 | DejaVuSansMono-Bold.ttf |
2548 | DejaVuSansMono-Bold.ttf |
2433 | DejaVuSans-Oblique.ttf |
2549 | DejaVuSans-Oblique.ttf |
2434 | DejaVuSansMono-Oblique.ttf |
2550 | DejaVuSansMono-Oblique.ttf |
2435 | DejaVuSans-BoldOblique.ttf |
2551 | DejaVuSans-BoldOblique.ttf |
2436 | DejaVuSansMono-BoldOblique.ttf |
2552 | DejaVuSansMono-BoldOblique.ttf |
2437 | ); |
2553 | ); |
2438 | |
2554 | |
2439 | CFPlus::add_font $_ for @fonts; |
2555 | DC::add_font $_ for @fonts; |
2440 | |
2556 | |
2441 | CFPlus::pango_init; |
|
|
2442 | |
|
|
2443 | $FONT_PROP = new_from_file CFPlus::Font $fonts[0]; |
2557 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2444 | $FONT_FIXED = new_from_file CFPlus::Font $fonts[1]; |
2558 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2445 | |
2559 | |
2446 | $FONT_PROP->make_default; |
2560 | $FONT_PROP->make_default; |
|
|
2561 | |
|
|
2562 | DC::pango_init; |
2447 | } |
2563 | } |
2448 | |
2564 | |
2449 | # compare mono (ft) vs. rgba (cairo) |
2565 | # compare mono (ft) vs. rgba (cairo) |
2450 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
2566 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
2451 | # for my $rgba (0..1) { |
2567 | # for my $rgba (0..1) { |
2452 | # my $t1 = Time::HiRes::time; |
2568 | # my $t1 = Time::HiRes::time; |
2453 | # for (1..1000) { |
2569 | # for (1..1000) { |
2454 | # my $layout = CFPlus::Layout->new ($rgba); |
2570 | # my $layout = DC::Layout->new ($rgba); |
2455 | # $layout->set_text ("hallo" x 100); |
2571 | # $layout->set_text ("hallo" x 100); |
2456 | # $layout->render; |
2572 | # $layout->render; |
2457 | # } |
2573 | # } |
2458 | # my $t2 = Time::HiRes::time; |
2574 | # my $t2 = Time::HiRes::time; |
2459 | # warn $t2-$t1; |
2575 | # warn $t2-$t1; |
… | |
… | |
2468 | our $STARTUP_CANCEL = EV::idle sub { |
2584 | our $STARTUP_CANCEL = EV::idle sub { |
2469 | undef $::STARTUP_CANCEL; |
2585 | undef $::STARTUP_CANCEL; |
2470 | $startup_done->(); |
2586 | $startup_done->(); |
2471 | }; |
2587 | }; |
2472 | |
2588 | |
|
|
2589 | delete $SIG{__DIE__}; |
2473 | EV::loop; |
2590 | EV::loop; |
2474 | |
2591 | |
2475 | #video_shutdown; |
2592 | #video_shutdown; |
2476 | #audio_shutdown; |
2593 | #audio_shutdown; |
|
|
2594 | DC::OpenGL::quit; |
2477 | CFPlus::SDL_Quit; |
2595 | DC::SDL_Quit; |
2478 | CFPlus::DB::Server::stop; |
2596 | DC::DB::Server::stop; |
2479 | |
2597 | |
2480 | =head1 NAME |
2598 | =head1 NAME |
2481 | |
2599 | |
2482 | deliantra - A Deliantra MORPG game client |
2600 | deliantra - A Deliantra MORPG game client |
2483 | |
2601 | |