… | |
… | |
205 | our $FLOORBOX; |
205 | our $FLOORBOX; |
206 | our $GAUGES; |
206 | our $GAUGES; |
207 | our $STATWIDS; |
207 | our $STATWIDS; |
208 | |
208 | |
209 | our $SDL_ACTIVE; |
209 | our $SDL_ACTIVE; |
210 | our %SDL_CB; |
210 | our @SDL_CB; |
211 | |
211 | |
212 | our $ALT_ENTER_MESSAGE; |
212 | our $ALT_ENTER_MESSAGE; |
213 | our $STATUSBOX; |
213 | our $STATUSBOX; |
214 | our $MODBOX; |
214 | our $MODBOX; |
215 | our $DEBUG_STATUS; |
215 | our $DEBUG_STATUS; |
… | |
… | |
818 | |
818 | |
819 | on_connect => sub { |
819 | on_connect => sub { |
820 | if ($_[0]) { |
820 | if ($_[0]) { |
821 | DC::lowdelay fileno $CONN->{fh}; |
821 | DC::lowdelay fileno $CONN->{fh}; |
822 | |
822 | |
823 | status "login successful"; |
823 | status "successfully connected to the server"; |
824 | } else { |
824 | } else { |
825 | undef $CONN; |
825 | undef $CONN; |
826 | status "unable to connect: $!"; |
826 | status "unable to connect: $!"; |
827 | stop_game(); |
827 | stop_game(); |
828 | } |
828 | } |
… | |
… | |
2258 | ); |
2258 | ); |
2259 | |
2259 | |
2260 | $MENUBAR->add ($GAUGES->{exp} = new DC::UI::ExperienceProgress |
2260 | $MENUBAR->add ($GAUGES->{exp} = new DC::UI::ExperienceProgress |
2261 | padding_x => 6, |
2261 | padding_x => 6, |
2262 | padding_y => 3, |
2262 | padding_y => 3, |
2263 | tooltip => "This progress bar shows your progress towards the next character level.", |
2263 | tooltip => "This progress bar shows your overall experience and your progress towards the next character level.", |
2264 | template => " Exp: 888,888,888,888 (lvl 188) ", |
2264 | template => " Exp: 888,888,888,888 (lvl 188) ", |
2265 | ); |
2265 | ); |
2266 | |
2266 | |
2267 | $MENUBAR->add ($PICKUP_ENABLE = new DC::UI::CheckBox # checkbox bad, button better? |
2267 | $MENUBAR->add ($PICKUP_ENABLE = new DC::UI::CheckBox # checkbox bad, button better? |
2268 | tooltip => "Automatic Pickup Enable - when this checkbox is enabled, then your character " |
2268 | tooltip => "Automatic Pickup Enable - when this checkbox is enabled, then your character " |
… | |
… | |
2481 | |
2481 | |
2482 | DC::UI::Toplevel->new ( |
2482 | DC::UI::Toplevel->new ( |
2483 | title => "Minimap", |
2483 | title => "Minimap", |
2484 | name => "mapmap", |
2484 | name => "mapmap", |
2485 | x => 0, |
2485 | x => 0, |
2486 | y => $FONTSIZE + 8, |
2486 | y => $::FONTSIZE + 8,#d# hack to move messages window below the menubar |
2487 | border_bg => [1, 1, 1, 192/255], |
2487 | border_bg => [1, 1, 1, 192/255], |
2488 | bg => [1, 1, 1, 0], |
2488 | bg => [1, 1, 1, 0], |
2489 | child => ($MAPMAP = new DC::MapWidget::MapMap |
2489 | child => ($MAPMAP = new DC::MapWidget::MapMap |
2490 | tooltip => "<b>Minimap</b>. This will display an overview of the surrounding areas.", |
2490 | tooltip => "<b>Minimap</b>. This will display an overview of the surrounding areas.", |
2491 | ), |
2491 | ), |
… | |
… | |
2520 | $METASERVER = metaserver_dialog; |
2520 | $METASERVER = metaserver_dialog; |
2521 | # the name is changed to not conflict with the older name as users could have hidden it |
2521 | # the name is changed to not conflict with the older name as users could have hidden it |
2522 | $MESSAGE_WINDOW = new DC::UI::Dockbar |
2522 | $MESSAGE_WINDOW = new DC::UI::Dockbar |
2523 | name => "message_window2", |
2523 | name => "message_window2", |
2524 | title => 'Messages', |
2524 | title => 'Messages', |
|
|
2525 | y => $::FONTSIZE + 8,#d# hack to move messages window below the menubar |
2525 | force_w => $::WIDTH * 0.6, |
2526 | force_w => $::WIDTH * 0.6, |
2526 | force_h => $::HEIGHT * 0.25, |
2527 | force_h => $::HEIGHT * 0.25, |
2527 | ; |
2528 | ; |
2528 | |
2529 | |
2529 | $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; |
2530 | $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; |
… | |
… | |
2597 | my $want_refresh = EV::prepare_ns \&force_refresh; |
2598 | my $want_refresh = EV::prepare_ns \&force_refresh; |
2598 | |
2599 | |
2599 | my $input = EV::periodic 0, 1 / $MAX_FPS, undef, sub { |
2600 | my $input = EV::periodic 0, 1 / $MAX_FPS, undef, sub { |
2600 | $NOW = EV::now; |
2601 | $NOW = EV::now; |
2601 | |
2602 | |
2602 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
2603 | ($SDL_CB[$_->{type}] || sub { warn "unhandled event $_->{type}" })->($_) |
2603 | for DC::poll_events; |
2604 | for DC::poll_events; |
2604 | |
2605 | |
2605 | if (%animate_object) { |
2606 | if (%animate_object) { |
2606 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2607 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2607 | $WANT_REFRESH = 1; |
2608 | $WANT_REFRESH = 1; |
… | |
… | |
2619 | sub animation_stop { |
2620 | sub animation_stop { |
2620 | my ($widget) = @_; |
2621 | my ($widget) = @_; |
2621 | delete $animate_object{$widget}; |
2622 | delete $animate_object{$widget}; |
2622 | } |
2623 | } |
2623 | |
2624 | |
2624 | %SDL_CB = ( |
|
|
2625 | DC::SDL_QUIT => sub { |
2625 | $SDL_CB[DC::SDL_QUIT] = sub { |
2626 | crash "SDL_QUIT"; |
2626 | crash "SDL_QUIT"; |
2627 | EV::unloop EV::UNLOOP_ALL; |
2627 | EV::unloop EV::UNLOOP_ALL; |
2628 | }, |
2628 | }; |
2629 | DC::SDL_VIDEORESIZE => sub { |
2629 | $SDL_CB[DC::SDL_VIDEORESIZE] = sub { }; |
2630 | }, |
|
|
2631 | DC::SDL_VIDEOEXPOSE => sub { |
2630 | $SDL_CB[DC::SDL_VIDEOEXPOSE] = sub { |
2632 | DC::UI::full_refresh; |
2631 | DC::UI::full_refresh; |
2633 | }, |
2632 | }; |
2634 | DC::SDL_ACTIVEEVENT => sub { |
2633 | $SDL_CB[DC::SDL_ACTIVEEVENT] = sub { |
2635 | # not useful, as APPACTIVE includes only iconified state, not unmapped |
2634 | # not useful, as APPACTIVE includes only iconified state, not unmapped |
2636 | # printf "active %x %x %x\n", $_[0]{gain}, $_[0]{state}, DC::SDL_GetAppState;#d# |
2635 | # printf "active %x %x %x\n", $_[0]{gain}, $_[0]{state}, DC::SDL_GetAppState;#d# |
2637 | # printf "a %x\n", DC::SDL_GetAppState & DC::SDL_APPACTIVE;#d# |
2636 | # printf "a %x\n", DC::SDL_GetAppState & DC::SDL_APPACTIVE;#d# |
2638 | # printf "A\n" if $_[0]{state} & DC::SDL_APPACTIVE; |
2637 | # printf "A\n" if $_[0]{state} & DC::SDL_APPACTIVE; |
2639 | # printf "K\n" if $_[0]{state} & DC::SDL_APPINPUTFOCUS; |
2638 | # printf "K\n" if $_[0]{state} & DC::SDL_APPINPUTFOCUS; |
2640 | # printf "M\n" if $_[0]{state} & DC::SDL_APPMOUSEFOCUS; |
2639 | # printf "M\n" if $_[0]{state} & DC::SDL_APPMOUSEFOCUS; |
2641 | }, |
2640 | }; |
2642 | DC::SDL_KEYDOWN => sub { |
2641 | $SDL_CB[DC::SDL_KEYDOWN] = sub { |
2643 | if ($_[0]{mod} & DC::KMOD_ALT && $_[0]{sym} == 13) { |
2642 | if ($_[0]{mod} & DC::KMOD_ALT && $_[0]{sym} == 13) { |
2644 | # alt-enter |
2643 | # alt-enter |
2645 | video_shutdown; |
2644 | video_shutdown; |
2646 | $FULLSCREEN_ENABLE->toggle; |
2645 | $FULLSCREEN_ENABLE->toggle; |
2647 | video_init; |
2646 | video_init; |
2648 | } else { |
2647 | } else { |
2649 | &DC::UI::feed_sdl_key_down_event; |
2648 | &DC::UI::feed_sdl_key_down_event; |
2650 | } |
2649 | } |
2651 | update_modbox; |
2650 | update_modbox; |
2652 | }, |
2651 | }; |
2653 | DC::SDL_KEYUP => sub { |
2652 | $SDL_CB[DC::SDL_KEYUP] = sub { |
2654 | &DC::UI::feed_sdl_key_up_event; |
2653 | &DC::UI::feed_sdl_key_up_event; |
2655 | update_modbox; |
2654 | update_modbox; |
2656 | }, |
2655 | }; |
2657 | DC::SDL_MOUSEMOTION => \&DC::UI::feed_sdl_motion_event, |
2656 | $SDL_CB[DC::SDL_MOUSEMOTION] = \&DC::UI::feed_sdl_motion_event, |
2658 | DC::SDL_MOUSEBUTTONDOWN => \&DC::UI::feed_sdl_button_down_event, |
2657 | $SDL_CB[DC::SDL_MOUSEBUTTONDOWN] = \&DC::UI::feed_sdl_button_down_event, |
2659 | DC::SDL_MOUSEBUTTONUP => \&DC::UI::feed_sdl_button_up_event, |
2658 | $SDL_CB[DC::SDL_MOUSEBUTTONUP] = \&DC::UI::feed_sdl_button_up_event, |
2660 | DC::SDL_USEREVENT => sub { |
2659 | $SDL_CB[DC::SDL_USEREVENT] = sub { |
2661 | if ($_[0]{code} == 1) { |
2660 | if ($_[0]{code} == 1) { |
2662 | audio_channel_finished $_[0]{data1}; |
2661 | audio_channel_finished $_[0]{data1}; |
2663 | } elsif ($_[0]{code} == 0) { |
2662 | } elsif ($_[0]{code} == 0) { |
2664 | audio_music_finished; |
2663 | audio_music_finished; |
2665 | } |
|
|
2666 | }, |
2664 | } |
2667 | ); |
2665 | }; |
2668 | |
2666 | |
2669 | ############################################################################# |
2667 | ############################################################################# |
2670 | |
2668 | |
2671 | $SIG{INT} = $SIG{TERM} = sub { |
2669 | $SIG{INT} = $SIG{TERM} = sub { |
2672 | EV::unloop; |
2670 | EV::unloop; |
… | |
… | |
2733 | default => "profile", # default profile |
2731 | default => "profile", # default profile |
2734 | show_tips => 1, |
2732 | show_tips => 1, |
2735 | logview_max_par => 1000, |
2733 | logview_max_par => 1000, |
2736 | shift_fire_stop => 0, |
2734 | shift_fire_stop => 0, |
2737 | uitheme => "wood", |
2735 | uitheme => "wood", |
|
|
2736 | map_shift_x => -24, # arbitrary |
|
|
2737 | map_shift_y => +24, # arbitrary |
2738 | ); |
2738 | ); |
2739 | |
2739 | |
2740 | while (my ($k, $v) = each %DEF_CFG) { |
2740 | while (my ($k, $v) = each %DEF_CFG) { |
2741 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2741 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2742 | } |
2742 | } |