… | |
… | |
73 | use DC::UI::ChatView; |
73 | use DC::UI::ChatView; |
74 | use DC::MessageDistributor; |
74 | use DC::MessageDistributor; |
75 | use DC::Pod; |
75 | use DC::Pod; |
76 | use DC::MapWidget; |
76 | use DC::MapWidget; |
77 | use DC::Macro; |
77 | use DC::Macro; |
|
|
78 | |
|
|
79 | # printf "%5d %5d %5d %5d\n", $_, DC::minpot $_, DC::ld32 $_, 2 << ((DC::ld32 $_ - 1)); |
78 | |
80 | |
79 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
81 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
80 | $SIG{PIPE} = 'IGNORE'; |
82 | $SIG{PIPE} = 'IGNORE'; |
81 | |
83 | |
82 | $EV::DIED = sub { |
84 | $EV::DIED = sub { |
… | |
… | |
511 | audio_music_push; |
513 | audio_music_push; |
512 | } |
514 | } |
513 | |
515 | |
514 | sub audio_init { |
516 | sub audio_init { |
515 | if ($CFG->{audio_enable}) { |
517 | if ($CFG->{audio_enable}) { |
516 | DC::Audio::init $CFG->{audio_driver}; |
518 | DC::Audio::init; |
517 | |
519 | |
518 | if ($SDL_MIXER) { |
520 | if ($SDL_MIXER) { |
519 | audio_music_finished; |
521 | audio_music_finished; |
520 | } else { |
522 | } else { |
521 | status "Unable to open sound device: there will be no sound"; |
523 | status "Unable to open sound device: there will be no sound"; |
… | |
… | |
1178 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Compress Textures"); |
1180 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Compress Textures"); |
1179 | $table->add_at (1, $row++, new DC::UI::CheckBox |
1181 | $table->add_at (1, $row++, new DC::UI::CheckBox |
1180 | state => $CFG->{texture_compression}, |
1182 | state => $CFG->{texture_compression}, |
1181 | tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but " |
1183 | tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but " |
1182 | . "will save a lot of memory and increase performance (and also fall prey to the ever-buggy Mac OS X software renderer). " |
1184 | . "will save a lot of memory and increase performance (and also fall prey to the ever-buggy Mac OS X software renderer). " |
1183 | . "The compression algorithm can differ form card to card, so your mileage may vary. This setting is ignored in " |
1185 | . "The compression algorithm can differ from card to card, so your mileage may vary. This setting is ignored in " |
1184 | . "forced OpenGL 1.1 mode and when using the Apple renderer.", |
1186 | . "forced OpenGL 1.1 mode and when using the Apple renderer.", |
1185 | on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 } |
1187 | on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 } |
1186 | ); |
1188 | ); |
1187 | |
1189 | |
1188 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fast & Ugly"); |
1190 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fast & Ugly"); |
… | |
… | |
1540 | $DELIANTRA_DEBUG ^= $_[0]; |
1542 | $DELIANTRA_DEBUG ^= $_[0]; |
1541 | |
1543 | |
1542 | if ($DELIANTRA_DEBUG & 16) { |
1544 | if ($DELIANTRA_DEBUG & 16) { |
1543 | $BW_WATCHER = EV::periodic 0, 1, 0, sub { |
1545 | $BW_WATCHER = EV::periodic 0, 1, 0, sub { |
1544 | return unless $CONN; |
1546 | return unless $CONN; |
1545 | debug sprintf "%8.2gKB/s", $CONN->{octets_in} / 1e3; |
1547 | debug sprintf "%8.2gkB/s", $CONN->{octets_in} / 1e3; |
1546 | $CONN->{octets_in} = 0; |
1548 | $CONN->{octets_in} = 0; |
1547 | }; |
1549 | }; |
1548 | } else { |
1550 | } else { |
1549 | undef $BW_WATCHER; |
1551 | undef $BW_WATCHER; |
1550 | } |
1552 | } |
… | |
… | |
1915 | if $self->{text} eq $nullpw; |
1917 | if $self->{text} eq $nullpw; |
1916 | 0 |
1918 | 0 |
1917 | }, |
1919 | }, |
1918 | on_changed => sub { |
1920 | on_changed => sub { |
1919 | my ($self, $value) = @_; |
1921 | my ($self, $value) = @_; |
1920 | $PROFILE->{password} = pack "H*", Deliantra::Util::hash_pw $value |
1922 | $PROFILE->{password} = unpack "H*", Deliantra::Util::hash_pw $value |
1921 | if length $value && $value ne $nullpw; |
1923 | if length $value && $value ne $nullpw; |
1922 | 1 |
1924 | 1 |
1923 | }, |
1925 | }, |
1924 | ); |
1926 | ); |
1925 | |
1927 | |
… | |
… | |
1955 | }, |
1957 | }, |
1956 | ); |
1958 | ); |
1957 | |
1959 | |
1958 | $vbox->add (new DC::UI::FancyFrame |
1960 | $vbox->add (new DC::UI::FancyFrame |
1959 | label => "Server Message", |
1961 | label => "Server Message", |
1960 | tooltip => "The last message, or error, form the server.", |
1962 | tooltip => "The last message, or error, from the server.", |
1961 | child => ($LOGIN_ERROR = new DC::UI::Label valign => 0, ellipsise => 0), |
1963 | child => ($LOGIN_ERROR = new DC::UI::Label valign => 0, ellipsise => 0), |
1962 | ); |
1964 | ); |
1963 | |
1965 | |
1964 | $vbox->add (new DC::UI::FancyFrame |
1966 | $vbox->add (new DC::UI::FancyFrame |
1965 | label => "How to Play", |
1967 | label => "How to Play", |
… | |
… | |
2028 | $table->add_at (0, ++$row, new DC::UI::Label align => 1, text => "Output-Rate"); |
2030 | $table->add_at (0, ++$row, new DC::UI::Label align => 1, text => "Output-Rate"); |
2029 | $table->add_at (1, $row, new DC::UI::Entry |
2031 | $table->add_at (1, $row, new DC::UI::Entry |
2030 | text => $CFG->{output_rate}, |
2032 | text => $CFG->{output_rate}, |
2031 | tooltip => "The maximum bandwidth in bytes per second that the server should not exceed " |
2033 | tooltip => "The maximum bandwidth in bytes per second that the server should not exceed " |
2032 | . "when sending data. When 0 or unset, the server " |
2034 | . "when sending data. When 0 or unset, the server " |
2033 | . "default will be used, which is usually around 100kb/s. Most servers will " |
2035 | . "default will be used, which is usually around 100kB/s. Most servers will " |
2034 | . "dynamically find an optimal rate, so adjust this only when necessary.", |
2036 | . "dynamically find an optimal rate, so adjust this only when necessary.", |
2035 | on_changed => sub { $CFG->{output_rate} = $_[1]; 1 }, |
2037 | on_changed => sub { $CFG->{output_rate} = $_[1]; 1 }, |
2036 | ); |
2038 | ); |
2037 | |
2039 | |
2038 | $vbox->add (new DC::UI::FancyFrame |
2040 | $vbox->add (new DC::UI::FancyFrame |
… | |
… | |
2595 | make_playerbook; |
2597 | make_playerbook; |
2596 | |
2598 | |
2597 | $MENUPOPUP = DC::UI::Menu->new (items => [ |
2599 | $MENUPOPUP = DC::UI::Menu->new (items => [ |
2598 | ["Setup…\tF9" , sub { $SETUP_DIALOG->toggle_visibility }], |
2600 | ["Setup…\tF9" , sub { $SETUP_DIALOG->toggle_visibility }], |
2599 | ["Playerbook…\tTab" , sub { $PL_WINDOW ->toggle_visibility }], |
2601 | ["Playerbook…\tTab" , sub { $PL_WINDOW ->toggle_visibility }], |
2600 | ["…Statistics\tF2" , sub { toggle_player_page ($::STATS_PAGE) }], |
2602 | ["…Statistics\tF2" , sub { toggle_player_page ($::STATS_PAGE) }], |
2601 | ["…Skills\tF3" , sub { toggle_player_page ($::SKILL_PAGE) }], |
2603 | ["…Skills\tF3" , sub { toggle_player_page ($::SKILL_PAGE) }], |
2602 | ["…Spells\tF4" , sub { toggle_player_page ($::SPELL_PAGE) }], |
2604 | ["…Spells\tF4" , sub { toggle_player_page ($::SPELL_PAGE) }], |
2603 | ["…Inventory\tF5" , sub { toggle_player_page ($::INVENTORY_PAGE) }], |
2605 | ["…Inventory\tF5" , sub { toggle_player_page ($::INVENTORY_PAGE) }], |
2604 | ["Help Browser…\tF1" , sub { $HELP_WINDOW ->toggle_visibility }], |
2606 | ["Help Browser…\tF1" , sub { $HELP_WINDOW ->toggle_visibility }], |
2605 | ["Quit…" , sub { |
2607 | ["Quit…" , sub { |
2606 | if ($CONN) { |
2608 | if ($CONN) { |
2607 | open_quit_dialog; |
2609 | open_quit_dialog; |
2608 | } else { |
2610 | } else { |
2609 | EV::unloop EV::UNLOOP_ALL; |
2611 | EV::break EV::BREAK_ALL; |
2610 | } |
2612 | } |
2611 | }], |
2613 | }], |
2612 | ]); |
2614 | ]); |
2613 | |
2615 | |
2614 | $BUTTONBAR->add (new DC::UI::Button text => "Menu…", |
2616 | $BUTTONBAR->add (new DC::UI::Button text => "Menu…", |
… | |
… | |
2985 | delete $animate_object{$widget}; |
2987 | delete $animate_object{$widget}; |
2986 | } |
2988 | } |
2987 | |
2989 | |
2988 | $SDL_CB[DC::SDL_QUIT] = sub { |
2990 | $SDL_CB[DC::SDL_QUIT] = sub { |
2989 | crash "SDL_QUIT"; |
2991 | crash "SDL_QUIT"; |
2990 | EV::unloop EV::UNLOOP_ALL; |
2992 | EV::break EV::BREAK_ALL; |
2991 | }; |
2993 | }; |
2992 | $SDL_CB[DC::SDL_VIDEORESIZE] = sub { }; |
2994 | $SDL_CB[DC::SDL_VIDEORESIZE] = sub { }; |
2993 | $SDL_CB[DC::SDL_VIDEOEXPOSE] = sub { |
2995 | $SDL_CB[DC::SDL_VIDEOEXPOSE] = sub { |
2994 | DC::UI::full_refresh; |
2996 | DC::UI::full_refresh; |
2995 | }; |
2997 | }; |
… | |
… | |
3028 | }; |
3030 | }; |
3029 | |
3031 | |
3030 | ############################################################################# |
3032 | ############################################################################# |
3031 | |
3033 | |
3032 | $SIG{INT} = $SIG{TERM} = sub { |
3034 | $SIG{INT} = $SIG{TERM} = sub { |
3033 | EV::unloop; |
3035 | EV::break; |
3034 | #d# TODO calling exit here hangs the process in some futex |
3036 | #d# TODO calling exit here hangs the process in some futex |
3035 | }; |
3037 | }; |
3036 | |
3038 | |
3037 | # due to mac os x + sdl combined braindamage, we need this contortion |
3039 | # due to mac os x + sdl combined braindamage, we need this contortion |
3038 | sub DC::Main::run { |
3040 | sub DC::Main::run { |
… | |
… | |
3155 | }; |
3157 | }; |
3156 | |
3158 | |
3157 | debug_toggle 0; |
3159 | debug_toggle 0; |
3158 | |
3160 | |
3159 | delete $SIG{__DIE__}; |
3161 | delete $SIG{__DIE__}; |
3160 | EV::loop; |
3162 | EV::run; |
3161 | |
3163 | |
3162 | DC::save_cfg if $CFG->{config_autosave}; |
3164 | DC::save_cfg if $CFG->{config_autosave}; |
3163 | |
3165 | |
3164 | #video_shutdown; |
3166 | #video_shutdown; |
3165 | #audio_shutdown; |
3167 | #audio_shutdown; |