… | |
… | |
16 | while (my ($filename, $zip) = each %PAR::LibCache) { |
16 | while (my ($filename, $zip) = each %PAR::LibCache) { |
17 | $zip->extractMember ("SPLASH.bmp", "$ENV{PAR_TEMP}/SPLASH.bmp"); |
17 | $zip->extractMember ("SPLASH.bmp", "$ENV{PAR_TEMP}/SPLASH.bmp"); |
18 | } |
18 | } |
19 | |
19 | |
20 | require Win32::GUI::SplashScreen; |
20 | require Win32::GUI::SplashScreen; |
|
|
21 | |
|
|
22 | # initialise the resolver now, as vista forces us back to the desktop |
|
|
23 | # when doing this. |
|
|
24 | use AnyEvent::DNS (); |
|
|
25 | AnyEvent::DNS::resolver; |
21 | |
26 | |
22 | Win32::GUI::SplashScreen::Show ( |
27 | Win32::GUI::SplashScreen::Show ( |
23 | -file => "$ENV{PAR_TEMP}/SPLASH.bmp", |
28 | -file => "$ENV{PAR_TEMP}/SPLASH.bmp", |
24 | ); |
29 | ); |
25 | |
30 | |
… | |
… | |
86 | |
91 | |
87 | use Deliantra; |
92 | use Deliantra; |
88 | use Deliantra::Protocol::Constants; |
93 | use Deliantra::Protocol::Constants; |
89 | |
94 | |
90 | use AnyEvent::Util (); |
95 | use AnyEvent::Util (); |
91 | use AnyEvent::DNS; |
|
|
92 | use AnyEvent::Socket (); |
96 | use AnyEvent::Socket (); |
|
|
97 | use AnyEvent::DNS (); |
93 | |
98 | |
94 | use Compress::LZF; |
99 | use Compress::LZF; |
95 | use JSON::XS; |
100 | use JSON::XS; |
96 | |
101 | |
97 | use DC; |
102 | use DC; |
… | |
… | |
161 | |
166 | |
162 | our $MAP; |
167 | our $MAP; |
163 | our $MAPMAP; |
168 | our $MAPMAP; |
164 | our $MAPWIDGET; |
169 | our $MAPWIDGET; |
165 | our $COMPLETER; |
170 | our $COMPLETER; |
166 | our $BUTTONBAR; |
171 | our $MENUFRAME; # the rectangle at the top |
|
|
172 | our $MENUBAR; # the hbox at the top |
|
|
173 | our $MENUPOPUP; |
|
|
174 | our $BUTTONBAR; # the menu buttons |
167 | our $METASERVER; |
175 | our $METASERVER; |
168 | our $LOGIN_BUTTON; |
176 | our $LOGIN_BUTTON; |
169 | our $QUIT_DIALOG; |
177 | our $QUIT_DIALOG; |
170 | our $HOST_ENTRY; |
178 | our $HOST_ENTRY; |
171 | our $FULLSCREEN_ENABLE; |
179 | our $FULLSCREEN_ENABLE; |
… | |
… | |
197 | our $FLOORBOX; |
205 | our $FLOORBOX; |
198 | our $GAUGES; |
206 | our $GAUGES; |
199 | our $STATWIDS; |
207 | our $STATWIDS; |
200 | |
208 | |
201 | our $SDL_ACTIVE; |
209 | our $SDL_ACTIVE; |
202 | our %SDL_CB; |
210 | our @SDL_CB; |
203 | |
211 | |
204 | our $ALT_ENTER_MESSAGE; |
212 | our $ALT_ENTER_MESSAGE; |
205 | our $STATUSBOX; |
213 | our $STATUSBOX; |
206 | our $MODBOX; |
214 | our $MODBOX; |
207 | our $DEBUG_STATUS; |
215 | our $DEBUG_STATUS; |
… | |
… | |
338 | or return; |
346 | or return; |
339 | |
347 | |
340 | $meta->{data} |
348 | $meta->{data} |
341 | or return; |
349 | or return; |
342 | |
350 | |
343 | # if its a jingle, play it as ambient music |
351 | # if it's a jingle, play it as ambient music |
344 | if ($meta->{data}{jingle}) { |
352 | if ($meta->{data}{jingle}) { |
345 | if (delete $AUDIO_PLAY{$face}) { # take the jingle out of the sound queue |
353 | if (delete $AUDIO_PLAY{$face}) { # take the jingle out of the sound queue |
346 | push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue |
354 | push @MUSIC_JINGLE, $meta; # push it unto the music/jingle queue |
347 | &audio_music_push ($face); |
355 | &audio_music_push ($face); |
348 | } |
356 | } |
349 | } else { |
357 | } else { |
350 | # fetch from database |
358 | # fetch from database |
351 | DC::DB::get res_data => $meta->{name}, sub { |
359 | DC::DB::get res_data => $meta->{name}, sub { |
352 | my $rwops = new DC::RW $_[0]; |
360 | my $rwops = new DC::RW $_[0]; |
353 | my $chunk = new DC::MixChunk $rwops |
361 | my $chunk = new DC::MixChunk $rwops |
354 | or Carp::confess "sound face " . (JSON::XS::encode_json $meta) . " unloadable: " . DC::Mix_GetError; |
362 | or Carp::confess "sound face " . (JSON::XS::encode_json $meta) . " (" . (unpack "H64", $_[0]) . ") unloadable: " . DC::Mix_GetError; |
355 | $chunk->volume (($meta->{data}{volume} || 1) * 128); |
363 | $chunk->volume (($meta->{data}{volume} || 1) * 128); |
356 | $AUDIO_CHUNK{$face} = $chunk; |
364 | $AUDIO_CHUNK{$face} = $chunk; |
357 | |
365 | |
358 | audio_sound_push ($face); |
366 | audio_sound_push ($face); |
359 | }; |
367 | }; |
… | |
… | |
406 | |
414 | |
407 | audio_music_update_volume; |
415 | audio_music_update_volume; |
408 | |
416 | |
409 | $MUSIC_PLAYING_DATA = \$_[0]; |
417 | $MUSIC_PLAYING_DATA = \$_[0]; |
410 | |
418 | |
|
|
419 | $meta->{path} or length $_[0] |
|
|
420 | or return clienterror "empty music face from res_data ($meta->{face})";#d# |
|
|
421 | |
411 | my $rwops = $meta->{path} |
422 | my $rwops = $meta->{path} |
412 | ? new_from_file DC::RW $meta->{path} |
423 | ? (new_from_file DC::RW $meta->{path} or return clienterror "unable to load music face $meta->{path}: $!")#d#clienterror |
413 | : new DC::RW $$MUSIC_PLAYING_DATA; |
424 | : new DC::RW $$MUSIC_PLAYING_DATA; |
414 | |
425 | |
415 | $MUSIC_PLAYER = new DC::MixMusic $rwops |
426 | $MUSIC_PLAYER = new DC::MixMusic $rwops |
416 | or return clienterror "music face $meta->{face} unloadable: " . DC::Mix_GetError => 1; |
427 | or return clienterror "music face $meta->{face} unloadable: " . DC::Mix_GetError => 1; |
417 | |
428 | |
… | |
… | |
910 | |
921 | |
911 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Video Mode"); |
922 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Video Mode"); |
912 | $table->add_at (1, $row++, my $hbox = new DC::UI::HBox); |
923 | $table->add_at (1, $row++, my $hbox = new DC::UI::HBox); |
913 | |
924 | |
914 | $hbox->add ($MODE_SLIDER = new DC::UI::Slider |
925 | $hbox->add ($MODE_SLIDER = new DC::UI::Slider |
|
|
926 | c_rescale => 1, |
915 | force_w => $WIDTH * 0.1, expand => 1, |
927 | force_w => $WIDTH * 0.1, expand => 1, |
916 | range => [ ($CFG->{sdl_mode}) x 3 ], |
928 | range => [ ($CFG->{sdl_mode}) x 3 ], |
917 | tooltip => $vidmode_tooltip); |
929 | tooltip => $vidmode_tooltip); |
918 | $hbox->add (my $mode_label = new DC::UI::Label |
930 | $hbox->add (my $mode_label = new DC::UI::Label |
919 | height => 0.8, template => "9999x9999@9+9", |
931 | height => 0.8, template => "9999x9999@9+9", |
… | |
… | |
1243 | } |
1255 | } |
1244 | |
1256 | |
1245 | sub make_gauge_window { |
1257 | sub make_gauge_window { |
1246 | my $gh = int $HEIGHT * $CFG->{gauge_size}; |
1258 | my $gh = int $HEIGHT * $CFG->{gauge_size}; |
1247 | |
1259 | |
1248 | my $win = new DC::UI::Frame ( |
1260 | $GAUGES->{win} = my $win = new DC::UI::Frame ( |
1249 | force_x => 0, |
1261 | force_x => 0, |
1250 | force_y => "max", |
1262 | force_y => "max", |
1251 | force_w => $WIDTH, |
1263 | force_w => $WIDTH, |
1252 | force_h => $gh, |
1264 | force_h => $gh, |
1253 | ); |
1265 | ); |
… | |
… | |
1269 | (new DC::UI::Empty expand => 1), |
1281 | (new DC::UI::Empty expand => 1), |
1270 | (my $hb = new DC::UI::HBox), |
1282 | (my $hb = new DC::UI::HBox), |
1271 | ], |
1283 | ], |
1272 | ); |
1284 | ); |
1273 | |
1285 | |
1274 | $hb->add (my $hg = new DC::UI::Gauge type => 'hp', tooltip => "#stat_health"); |
1286 | $hb->add ($GAUGES->{hp} = new DC::UI::Gauge type => 'hp', tooltip => "#stat_health"); |
1275 | $hb->add (my $mg = new DC::UI::Gauge type => 'mana', tooltip => "#stat_mana"); |
1287 | $hb->add ($GAUGES->{mana} = new DC::UI::Gauge type => 'mana', tooltip => "#stat_mana"); |
1276 | $hb->add (my $gg = new DC::UI::Gauge type => 'grace', tooltip => "#stat_grace"); |
1288 | $hb->add ($GAUGES->{grace} = new DC::UI::Gauge type => 'grace', tooltip => "#stat_grace"); |
1277 | $hb->add (my $fg = new DC::UI::Gauge type => 'food', tooltip => "#stat_food"); |
1289 | $hb->add ($GAUGES->{food} = new DC::UI::Gauge type => 'food', tooltip => "#stat_food"); |
1278 | |
|
|
1279 | $vbox->add (my $exp = new DC::UI::Label align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp"); |
|
|
1280 | $vbox->add (my $prg = new DC::UI::ExperienceProgress); |
|
|
1281 | $vbox->add (my $sklprg = new DC::UI::ExperienceProgress); |
|
|
1282 | $vbox->add (my $rng = new DC::UI::Label align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged"); |
|
|
1283 | |
|
|
1284 | $GAUGES = { |
|
|
1285 | exp => $exp, prg => $prg, sklprg => $sklprg, |
|
|
1286 | win => $win, range => $rng, |
|
|
1287 | hp => $hg, mana => $mg, grace => $gg, food => $fg, |
|
|
1288 | }; |
|
|
1289 | |
1290 | |
1290 | &set_gauge_window_fontsize; |
1291 | &set_gauge_window_fontsize; |
1291 | |
1292 | |
1292 | $win |
1293 | $win |
1293 | } |
1294 | } |
… | |
… | |
1635 | ); |
1636 | ); |
1636 | |
1637 | |
1637 | $table->add_at (0, 4, new DC::UI::Label align => 1, text => "Username"); |
1638 | $table->add_at (0, 4, new DC::UI::Label align => 1, text => "Username"); |
1638 | $table->add_at (1, 4, new DC::UI::Entry |
1639 | $table->add_at (1, 4, new DC::UI::Entry |
1639 | text => $CFG->{profile}{default}{user}, |
1640 | text => $CFG->{profile}{default}{user}, |
1640 | tooltip => "The name of your character on the server.", |
1641 | tooltip => "The name of your character on the server. The name is case-sensitive!", |
1641 | on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value; 1 } |
1642 | on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value; 1 } |
1642 | ); |
1643 | ); |
1643 | |
1644 | |
1644 | $table->add_at (0, 5, new DC::UI::Label align => 1, text => "Password"); |
1645 | $table->add_at (0, 5, new DC::UI::Label align => 1, text => "Password"); |
1645 | $table->add_at (1, 5, new DC::UI::Entry |
1646 | $table->add_at (1, 5, new DC::UI::Entry |
… | |
… | |
1747 | |
1748 | |
1748 | my $row = 0; |
1749 | my $row = 0; |
1749 | |
1750 | |
1750 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Tip of the day"); |
1751 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Tip of the day"); |
1751 | $table->add_at (1, $row++, new DC::UI::CheckBox |
1752 | $table->add_at (1, $row++, new DC::UI::CheckBox |
|
|
1753 | c_colspan => 2, |
1752 | state => $CFG->{show_tips}, |
1754 | state => $CFG->{show_tips}, |
1753 | tooltip => "Show the <b>Tip of the day</b> window at startup?", |
1755 | tooltip => "Show the <b>Tip of the day</b> window at startup?", |
1754 | on_changed => sub { |
1756 | on_changed => sub { |
1755 | my ($self, $value) = @_; |
1757 | my ($self, $value) = @_; |
1756 | $CFG->{show_tips} = $value; |
1758 | $CFG->{show_tips} = $value; |
… | |
… | |
1758 | } |
1760 | } |
1759 | ); |
1761 | ); |
1760 | |
1762 | |
1761 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Message Window Size"); |
1763 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Message Window Size"); |
1762 | $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry |
1764 | $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry |
|
|
1765 | c_colspan => 2, |
1763 | text => $CFG->{logview_max_par}, |
1766 | text => $CFG->{logview_max_par}, |
1764 | tooltip => "This is maximum number of messages remembered in the <b>Message</b> window. If the server " |
1767 | tooltip => "This is maximum number of messages remembered in the <b>Message</b> window. If the server " |
1765 | . "sends more messages than this number, older messages get removed to save memory and " |
1768 | . "sends more messages than this number, older messages get removed to save memory and " |
1766 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
1769 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
1767 | on_changed => sub { |
1770 | on_changed => sub { |
… | |
… | |
1769 | $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); |
1772 | $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); |
1770 | 0 |
1773 | 0 |
1771 | }, |
1774 | }, |
1772 | ); |
1775 | ); |
1773 | |
1776 | |
|
|
1777 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Config Autosave"); |
|
|
1778 | $table->add_at (1, $row, new DC::UI::CheckBox |
|
|
1779 | state => $CFG->{config_autosave}, |
|
|
1780 | tooltip => "Normally, configuration settings and the user interface layout " |
|
|
1781 | . "are saved on client exit. You can disable this behaviour by " |
|
|
1782 | . "unchecking this checkbox.", |
|
|
1783 | on_changed => sub { |
|
|
1784 | my ($self, $value) = @_; |
|
|
1785 | $CFG->{config_autosave} = $value; |
|
|
1786 | 0 |
|
|
1787 | } |
|
|
1788 | ); |
|
|
1789 | $table->add_at (2, $row++, new DC::UI::Button |
|
|
1790 | text => "Save Now", |
|
|
1791 | tooltip => "Use this to manually save configuration and UI layout when " |
|
|
1792 | . "autosave is disabled.", |
|
|
1793 | on_activate => sub { |
|
|
1794 | DC::write_cfg; |
|
|
1795 | 0 |
|
|
1796 | } |
|
|
1797 | ); |
|
|
1798 | |
1774 | $table |
1799 | $table |
1775 | } |
1800 | } |
1776 | |
1801 | |
1777 | sub autopickup_setup { |
1802 | sub autopickup_setup { |
1778 | my $r = new DC::UI::ScrolledWindow ( |
1803 | my $r = new DC::UI::ScrolledWindow ( |
… | |
… | |
1784 | col_expand => [0, 1, 0, 1], |
1809 | col_expand => [0, 1, 0, 1], |
1785 | ); |
1810 | ); |
1786 | |
1811 | |
1787 | for ( |
1812 | for ( |
1788 | ["General", 0, 0, |
1813 | ["General", 0, 0, |
1789 | ["Enable autopickup" => PICKUP_NEWMODE, \$PICKUP_ENABLE], |
|
|
1790 | ["Inhibit autopickup" => PICKUP_INHIBIT], |
1814 | # ["Inhibit autopickup" => PICKUP_INHIBIT], |
1791 | ["Stop before pickup" => PICKUP_STOP], |
1815 | ["Stop before pickup" => PICKUP_STOP], |
1792 | ["Debug autopickup" => PICKUP_DEBUG], |
1816 | ["Debug autopickup" => PICKUP_DEBUG], |
1793 | ], |
1817 | ], |
1794 | ["Weapons", 0, 6, |
1818 | ["Weapons", 0, 6, |
1795 | ["All weapons" => PICKUP_ALLWEAPON], |
1819 | ["All weapons" => PICKUP_ALLWEAPON], |
… | |
… | |
1843 | $::CFG->{pickup} |= $mask; |
1867 | $::CFG->{pickup} |= $mask; |
1844 | } else { |
1868 | } else { |
1845 | $::CFG->{pickup} &= ~$mask; |
1869 | $::CFG->{pickup} &= ~$mask; |
1846 | } |
1870 | } |
1847 | |
1871 | |
1848 | $::CONN->send_command ("pickup $::CFG->{pickup}") |
1872 | $::CONN->send_pickup ($::CFG->{pickup}) |
1849 | if defined $::CONN; |
1873 | if defined $::CONN; |
1850 | |
1874 | |
1851 | 0 |
1875 | 0 |
1852 | }); |
1876 | }); |
1853 | |
1877 | |
… | |
… | |
1870 | }); |
1894 | }); |
1871 | |
1895 | |
1872 | $table->add_at (3, 18, new DC::UI::Button |
1896 | $table->add_at (3, 18, new DC::UI::Button |
1873 | text => "set", |
1897 | text => "set", |
1874 | on_activate => sub { |
1898 | on_activate => sub { |
1875 | $::CONN->send_command ("pickup $::CFG->{pickup}") |
1899 | $::CONN->send_pickup ($::CFG->{pickup}) |
1876 | if defined $::CONN; |
1900 | if defined $::CONN; |
1877 | 0 |
1901 | 0 |
1878 | }); |
1902 | }); |
1879 | |
1903 | |
1880 | $r |
1904 | $r |
… | |
… | |
1993 | $PL_NOTEBOOK->set_current_page ($widget); |
2017 | $PL_NOTEBOOK->set_current_page ($widget); |
1994 | $PL_WINDOW->show; |
2018 | $PL_WINDOW->show; |
1995 | } |
2019 | } |
1996 | } |
2020 | } |
1997 | |
2021 | |
1998 | sub player_window { |
2022 | sub make_playerbook { |
1999 | my $plwin = $PL_WINDOW = new DC::UI::Toplevel |
2023 | my $plwin = $PL_WINDOW = new DC::UI::Toplevel |
2000 | x => "center", |
2024 | x => "center", |
2001 | y => "center", |
2025 | y => "center", |
2002 | force_w => $WIDTH * 9/10, |
2026 | force_w => $WIDTH * 9/10, |
2003 | force_h => $HEIGHT * 9/10, |
2027 | force_h => $HEIGHT * 9/10, |
… | |
… | |
2037 | "License, Author and Source info for media sent by the server."); |
2061 | "License, Author and Source info for media sent by the server."); |
2038 | |
2062 | |
2039 | $ntb->set_current_page ($INVENTORY_PAGE); |
2063 | $ntb->set_current_page ($INVENTORY_PAGE); |
2040 | |
2064 | |
2041 | $plwin->add ($ntb); |
2065 | $plwin->add ($ntb); |
2042 | $plwin |
|
|
2043 | } |
2066 | } |
2044 | |
2067 | |
2045 | sub keyboard_setup { |
2068 | sub keyboard_setup { |
2046 | DC::Macro::keyboard_setup |
2069 | DC::Macro::keyboard_setup |
2047 | } |
2070 | } |
2048 | |
2071 | |
2049 | sub help_window { |
2072 | sub make_help_window { |
2050 | my $win = new DC::UI::Toplevel |
2073 | my $win = new DC::UI::Toplevel |
2051 | x => 'center', |
2074 | x => 'center', |
2052 | y => 'center', |
2075 | y => 'center', |
2053 | z => 4, |
2076 | z => 4, |
2054 | name => 'doc_browser', |
2077 | name => 'doc_browser', |
… | |
… | |
2143 | |
2166 | |
2144 | $load_node->((DC::Pod::find @path)[0]); |
2167 | $load_node->((DC::Pod::find @path)[0]); |
2145 | $win->show; |
2168 | $win->show; |
2146 | }; |
2169 | }; |
2147 | |
2170 | |
2148 | $win |
2171 | $HELP_WINDOW = $win; |
2149 | } |
|
|
2150 | |
|
|
2151 | sub open_string_query { |
|
|
2152 | my ($title, $cb, $txt, $tooltip) = @_; |
|
|
2153 | my $dialog = new DC::UI::Toplevel |
|
|
2154 | x => "center", |
|
|
2155 | y => "center", |
|
|
2156 | z => 50, |
|
|
2157 | force_w => $WIDTH * 4/5, |
|
|
2158 | title => $title; |
|
|
2159 | |
|
|
2160 | $dialog->add ( |
|
|
2161 | my $e = new DC::UI::Entry |
|
|
2162 | on_activate => sub { $cb->(@_); $dialog->hide; 0 }, |
|
|
2163 | on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 }, |
|
|
2164 | tooltip => $tooltip |
|
|
2165 | ); |
|
|
2166 | |
|
|
2167 | $e->grab_focus; |
|
|
2168 | $e->set_text ($txt) if $txt; |
|
|
2169 | $dialog->show; |
|
|
2170 | } |
2172 | } |
2171 | |
2173 | |
2172 | sub open_quit_dialog { |
2174 | sub open_quit_dialog { |
2173 | unless ($QUIT_DIALOG) { |
2175 | unless ($QUIT_DIALOG) { |
2174 | $QUIT_DIALOG = new DC::UI::Toplevel |
2176 | $QUIT_DIALOG = new DC::UI::Toplevel |
… | |
… | |
2207 | |
2209 | |
2208 | $QUIT_DIALOG->show; |
2210 | $QUIT_DIALOG->show; |
2209 | $QUIT_DIALOG->grab_focus; |
2211 | $QUIT_DIALOG->grab_focus; |
2210 | } |
2212 | } |
2211 | |
2213 | |
|
|
2214 | sub make_menubar { |
|
|
2215 | $MENUFRAME = new DC::UI::Toplevel |
|
|
2216 | border => 0, |
|
|
2217 | force_x => 0, |
|
|
2218 | force_y => 0, |
|
|
2219 | force_w => $::WIDTH, |
|
|
2220 | child => ($MENUBAR = new DC::UI::HBox), |
|
|
2221 | ; |
|
|
2222 | |
|
|
2223 | $MENUBAR->add ($BUTTONBAR = new DC::UI::Buttonbar); |
|
|
2224 | |
|
|
2225 | # XXX: this has to be done before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D |
|
|
2226 | make_gauge_window->show; |
|
|
2227 | |
|
|
2228 | # $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, |
|
|
2229 | # tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
|
|
2230 | |
|
|
2231 | make_playerbook; |
|
|
2232 | |
|
|
2233 | $MENUPOPUP = DC::UI::Menu->new (items => [ |
|
|
2234 | ["Setup…\tF9" , sub { $SETUP_DIALOG->toggle_visibility }], |
|
|
2235 | ["Playerbook…\tTab" , sub { $PL_WINDOW ->toggle_visibility }], |
|
|
2236 | ["…Statistics\tF2" , sub { toggle_player_page ($::STATS_PAGE) }], |
|
|
2237 | ["…Skills\tF3" , sub { toggle_player_page ($::SKILL_PAGE) }], |
|
|
2238 | ["…Spells\tF4" , sub { toggle_player_page ($::SPELL_PAGE) }], |
|
|
2239 | ["…Inventory\tF5" , sub { toggle_player_page ($::INVENTORY_PAGE) }], |
|
|
2240 | ["Help Browser…\tF1" , sub { $HELP_WINDOW ->toggle_visibility }], |
|
|
2241 | ["Quit…" , sub { |
|
|
2242 | if ($CONN) { |
|
|
2243 | open_quit_dialog; |
|
|
2244 | } else { |
|
|
2245 | EV::unloop EV::UNLOOP_ALL; |
|
|
2246 | } |
|
|
2247 | }], |
|
|
2248 | ]); |
|
|
2249 | |
|
|
2250 | $BUTTONBAR->add (new DC::UI::Button text => "Menu…", |
|
|
2251 | tooltip => "Shows the main menu", |
|
|
2252 | on_button_down => sub { |
|
|
2253 | my ($self, $ev) = @_; |
|
|
2254 | local $ev->{x} = 0; |
|
|
2255 | local $ev->{y} = 0; |
|
|
2256 | $MENUPOPUP->popup ($ev); |
|
|
2257 | }, |
|
|
2258 | ); |
|
|
2259 | |
|
|
2260 | $MENUBAR->add ($GAUGES->{exp} = new DC::UI::ExperienceProgress |
|
|
2261 | padding_x => 6, |
|
|
2262 | padding_y => 3, |
|
|
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) ", |
|
|
2265 | ); |
|
|
2266 | |
|
|
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 " |
|
|
2269 | . "will automatically pick up items as defined by your item pickup settings " |
|
|
2270 | . "in the playerbook. Often (e.g. in apartments) you want to temporarily " |
|
|
2271 | . "disable autopickup by disabling this checkbox.", |
|
|
2272 | state => $CFG->{pickup} & PICKUP_INHIBIT ? 0 : 1, |
|
|
2273 | on_changed => sub { |
|
|
2274 | my ($self, $value) = @_; |
|
|
2275 | $CFG->{pickup} &= ~PICKUP_INHIBIT; |
|
|
2276 | $CFG->{pickup} |= PICKUP_INHIBIT unless $_[1]; |
|
|
2277 | $CONN->send_pickup ($CFG->{pickup}) |
|
|
2278 | if $CONN; |
|
|
2279 | }, |
|
|
2280 | ); |
|
|
2281 | |
|
|
2282 | $MENUBAR->add ($GAUGES->{skillexp} = new DC::UI::ExperienceProgress |
|
|
2283 | c_rescale => 1, |
|
|
2284 | padding_x => 6, |
|
|
2285 | padding_y => 3, |
|
|
2286 | force_w => $::WIDTH * 0.2, |
|
|
2287 | tooltip => "This progress bar shows the currently used skill and your progress towards the next skill level of that skill.", |
|
|
2288 | template => "two handed weapons 99%", |
|
|
2289 | ); |
|
|
2290 | |
|
|
2291 | $MENUBAR->add ($GAUGES->{range} = new DC::UI::Label |
|
|
2292 | expand => 1, |
|
|
2293 | align => 1, can_hover => 1, can_events => 1, |
|
|
2294 | text => "Range and Combat Slots", |
|
|
2295 | tooltip => "#stat_ranged", |
|
|
2296 | ); |
|
|
2297 | |
|
|
2298 | $MENUFRAME->show; |
|
|
2299 | } |
|
|
2300 | |
|
|
2301 | sub open_string_query { |
|
|
2302 | my ($title, $cb, $txt, $tooltip) = @_; |
|
|
2303 | my $dialog = new DC::UI::Toplevel |
|
|
2304 | x => "center", |
|
|
2305 | y => "center", |
|
|
2306 | z => 50, |
|
|
2307 | force_w => $WIDTH * 4/5, |
|
|
2308 | title => $title; |
|
|
2309 | |
|
|
2310 | $dialog->add ( |
|
|
2311 | my $e = new DC::UI::Entry |
|
|
2312 | on_activate => sub { $cb->(@_); $dialog->hide; 0 }, |
|
|
2313 | on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 }, |
|
|
2314 | tooltip => $tooltip |
|
|
2315 | ); |
|
|
2316 | |
|
|
2317 | $e->grab_focus; |
|
|
2318 | $e->set_text ($txt) if $txt; |
|
|
2319 | $dialog->show; |
|
|
2320 | } |
|
|
2321 | |
2212 | sub show_tip_of_the_day { |
2322 | sub show_tip_of_the_day { |
2213 | # find all tips |
2323 | # find all tips |
2214 | my @tod = DC::Pod::find tip_of_the_day => "*"; |
2324 | my @tod = DC::Pod::find tip_of_the_day => "*"; |
2215 | |
2325 | |
2216 | DC::DB::get state => "tip_of_the_day", sub { |
2326 | DC::DB::get state => "tip_of_the_day", sub { |
… | |
… | |
2355 | |
2465 | |
2356 | (new DC::UI::Frame |
2466 | (new DC::UI::Frame |
2357 | bg => [0, 0, 0, 0.4], |
2467 | bg => [0, 0, 0, 0.4], |
2358 | force_x => 0, |
2468 | force_x => 0, |
2359 | force_y => "max", |
2469 | force_y => "max", |
2360 | child => (my $LR = new DC::UI::VBox), |
2470 | child => (my $LL = new DC::UI::VBox), |
2361 | )->show; |
2471 | )->show; |
2362 | |
2472 | |
2363 | $LR->add ($STATUSBOX); |
2473 | $LL->add ($STATUSBOX); |
2364 | $LR->add ($MODBOX); |
2474 | $LL->add ($MODBOX); |
2365 | $LR->add (new DC::UI::Label |
2475 | $LL->add (new DC::UI::Label |
2366 | align => 0, |
2476 | align => 0, |
2367 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode", |
2477 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode", |
2368 | fontsize => 0.5, |
2478 | fontsize => 0.5, |
2369 | fg => [1, 1, 0, 0.7], |
2479 | fg => [1, 1, 0, 0.7], |
2370 | ); |
2480 | ); |
… | |
… | |
2439 | . "After pressing the combo the binding will be saved automatically and the " |
2549 | . "After pressing the combo the binding will be saved automatically and the " |
2440 | . "binding editor closes"); |
2550 | . "binding editor closes"); |
2441 | $SETUP_NOTEBOOK->add_tab (Debug => debug_setup, |
2551 | $SETUP_NOTEBOOK->add_tab (Debug => debug_setup, |
2442 | "Some debuggin' options. Do not ask."); |
2552 | "Some debuggin' options. Do not ask."); |
2443 | |
2553 | |
2444 | $BUTTONBAR = new DC::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
2554 | make_help_window; |
|
|
2555 | make_menubar; |
2445 | |
2556 | |
2446 | $BUTTONBAR->add (new DC::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
|
|
2447 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
|
|
2448 | |
|
|
2449 | # $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, |
|
|
2450 | # tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
|
|
2451 | |
|
|
2452 | 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 |
|
|
2453 | |
|
|
2454 | $BUTTONBAR->add (new DC::UI::Flopper text => "Playerbook", other => player_window, |
|
|
2455 | tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats."); |
|
|
2456 | |
|
|
2457 | $BUTTONBAR->add (new DC::UI::Button |
|
|
2458 | text => "Save Config", |
|
|
2459 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
|
|
2460 | on_activate => sub { |
|
|
2461 | $::CFG->{layout} = DC::UI::get_layout; |
|
|
2462 | DC::write_cfg; |
|
|
2463 | status "Configuration Saved"; |
|
|
2464 | 0 |
|
|
2465 | }, |
|
|
2466 | ); |
|
|
2467 | |
|
|
2468 | $BUTTONBAR->add (new DC::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, |
|
|
2469 | tooltip => "View Documentation"); |
|
|
2470 | |
|
|
2471 | $BUTTONBAR->add (new DC::UI::Button |
|
|
2472 | text => "Quit", |
|
|
2473 | tooltip => "Terminates the program", |
|
|
2474 | on_activate => sub { |
|
|
2475 | if ($CONN) { |
|
|
2476 | open_quit_dialog; |
|
|
2477 | } else { |
|
|
2478 | EV::unloop EV::UNLOOP_ALL; |
|
|
2479 | } |
|
|
2480 | 0 |
|
|
2481 | }, |
|
|
2482 | ); |
|
|
2483 | |
|
|
2484 | $BUTTONBAR->show; |
|
|
2485 | $SETUP_DIALOG->show; |
2557 | $SETUP_DIALOG->show; |
2486 | $MESSAGE_WINDOW->show; |
2558 | $MESSAGE_WINDOW->show; |
2487 | } |
2559 | } |
2488 | |
2560 | |
2489 | $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1, 1]); |
2561 | $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1, 1]); |
… | |
… | |
2525 | my $want_refresh = EV::prepare_ns \&force_refresh; |
2597 | my $want_refresh = EV::prepare_ns \&force_refresh; |
2526 | |
2598 | |
2527 | my $input = EV::periodic 0, 1 / $MAX_FPS, undef, sub { |
2599 | my $input = EV::periodic 0, 1 / $MAX_FPS, undef, sub { |
2528 | $NOW = EV::now; |
2600 | $NOW = EV::now; |
2529 | |
2601 | |
2530 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
2602 | ($SDL_CB[$_->{type}] || sub { warn "unhandled event $_->{type}" })->($_) |
2531 | for DC::poll_events; |
2603 | for DC::poll_events; |
2532 | |
2604 | |
2533 | if (%animate_object) { |
2605 | if (%animate_object) { |
2534 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2606 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2535 | $WANT_REFRESH = 1; |
2607 | $WANT_REFRESH = 1; |
… | |
… | |
2547 | sub animation_stop { |
2619 | sub animation_stop { |
2548 | my ($widget) = @_; |
2620 | my ($widget) = @_; |
2549 | delete $animate_object{$widget}; |
2621 | delete $animate_object{$widget}; |
2550 | } |
2622 | } |
2551 | |
2623 | |
2552 | %SDL_CB = ( |
|
|
2553 | DC::SDL_QUIT => sub { |
2624 | $SDL_CB[DC::SDL_QUIT] = sub { |
2554 | crash "SDL_QUIT"; |
2625 | crash "SDL_QUIT"; |
2555 | EV::unloop EV::UNLOOP_ALL; |
2626 | EV::unloop EV::UNLOOP_ALL; |
2556 | }, |
2627 | }; |
2557 | DC::SDL_VIDEORESIZE => sub { |
2628 | $SDL_CB[DC::SDL_VIDEORESIZE] = sub { }; |
2558 | }, |
|
|
2559 | DC::SDL_VIDEOEXPOSE => sub { |
2629 | $SDL_CB[DC::SDL_VIDEOEXPOSE] = sub { |
2560 | DC::UI::full_refresh; |
2630 | DC::UI::full_refresh; |
2561 | }, |
2631 | }; |
2562 | DC::SDL_ACTIVEEVENT => sub { |
2632 | $SDL_CB[DC::SDL_ACTIVEEVENT] = sub { |
2563 | # not useful, as APPACTIVE includes only iconified state, not unmapped |
2633 | # not useful, as APPACTIVE includes only iconified state, not unmapped |
2564 | # printf "active %x %x %x\n", $_[0]{gain}, $_[0]{state}, DC::SDL_GetAppState;#d# |
2634 | # printf "active %x %x %x\n", $_[0]{gain}, $_[0]{state}, DC::SDL_GetAppState;#d# |
2565 | # printf "a %x\n", DC::SDL_GetAppState & DC::SDL_APPACTIVE;#d# |
2635 | # printf "a %x\n", DC::SDL_GetAppState & DC::SDL_APPACTIVE;#d# |
2566 | # printf "A\n" if $_[0]{state} & DC::SDL_APPACTIVE; |
2636 | # printf "A\n" if $_[0]{state} & DC::SDL_APPACTIVE; |
2567 | # printf "K\n" if $_[0]{state} & DC::SDL_APPINPUTFOCUS; |
2637 | # printf "K\n" if $_[0]{state} & DC::SDL_APPINPUTFOCUS; |
2568 | # printf "M\n" if $_[0]{state} & DC::SDL_APPMOUSEFOCUS; |
2638 | # printf "M\n" if $_[0]{state} & DC::SDL_APPMOUSEFOCUS; |
2569 | }, |
2639 | }; |
2570 | DC::SDL_KEYDOWN => sub { |
2640 | $SDL_CB[DC::SDL_KEYDOWN] = sub { |
2571 | if ($_[0]{mod} & DC::KMOD_ALT && $_[0]{sym} == 13) { |
2641 | if ($_[0]{mod} & DC::KMOD_ALT && $_[0]{sym} == 13) { |
2572 | # alt-enter |
2642 | # alt-enter |
2573 | video_shutdown; |
2643 | video_shutdown; |
2574 | $FULLSCREEN_ENABLE->toggle; |
2644 | $FULLSCREEN_ENABLE->toggle; |
2575 | video_init; |
2645 | video_init; |
2576 | } else { |
2646 | } else { |
2577 | &DC::UI::feed_sdl_key_down_event; |
2647 | &DC::UI::feed_sdl_key_down_event; |
2578 | } |
2648 | } |
2579 | update_modbox; |
2649 | update_modbox; |
2580 | }, |
2650 | }; |
2581 | DC::SDL_KEYUP => sub { |
2651 | $SDL_CB[DC::SDL_KEYUP] = sub { |
2582 | &DC::UI::feed_sdl_key_up_event; |
2652 | &DC::UI::feed_sdl_key_up_event; |
2583 | update_modbox; |
2653 | update_modbox; |
2584 | }, |
2654 | }; |
2585 | DC::SDL_MOUSEMOTION => \&DC::UI::feed_sdl_motion_event, |
2655 | $SDL_CB[DC::SDL_MOUSEMOTION] = \&DC::UI::feed_sdl_motion_event, |
2586 | DC::SDL_MOUSEBUTTONDOWN => \&DC::UI::feed_sdl_button_down_event, |
2656 | $SDL_CB[DC::SDL_MOUSEBUTTONDOWN] = \&DC::UI::feed_sdl_button_down_event, |
2587 | DC::SDL_MOUSEBUTTONUP => \&DC::UI::feed_sdl_button_up_event, |
2657 | $SDL_CB[DC::SDL_MOUSEBUTTONUP] = \&DC::UI::feed_sdl_button_up_event, |
2588 | DC::SDL_USEREVENT => sub { |
2658 | $SDL_CB[DC::SDL_USEREVENT] = sub { |
2589 | if ($_[0]{code} == 1) { |
2659 | if ($_[0]{code} == 1) { |
2590 | audio_channel_finished $_[0]{data1}; |
2660 | audio_channel_finished $_[0]{data1}; |
2591 | } elsif ($_[0]{code} == 0) { |
2661 | } elsif ($_[0]{code} == 0) { |
2592 | audio_music_finished; |
2662 | audio_music_finished; |
2593 | } |
|
|
2594 | }, |
2663 | } |
2595 | ); |
2664 | }; |
2596 | |
2665 | |
2597 | ############################################################################# |
2666 | ############################################################################# |
2598 | |
2667 | |
2599 | $SIG{INT} = $SIG{TERM} = sub { |
2668 | $SIG{INT} = $SIG{TERM} = sub { |
2600 | EV::unloop; |
2669 | EV::unloop; |
2601 | #d# TODO calling exit here hangs the process in some futex |
2670 | #d# TODO calling exit here hangs the process in some futex |
2602 | }; |
2671 | }; |
2603 | |
2672 | |
2604 | # due to mac os x + sdl combined briandamage, we need this contortion |
2673 | # due to mac os x + sdl combined braindamage, we need this contortion |
2605 | sub main { |
2674 | sub main { |
2606 | { |
2675 | { |
2607 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
2676 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
2608 | |
2677 | |
2609 | if (-e "$Deliantra::VARDIR/client.cf") { |
2678 | if (-e "$Deliantra::VARDIR/client.cf") { |
… | |
… | |
2626 | DC::DB::open_db; |
2695 | DC::DB::open_db; |
2627 | |
2696 | |
2628 | DC::UI::set_layout ($::CFG->{layout}); |
2697 | DC::UI::set_layout ($::CFG->{layout}); |
2629 | |
2698 | |
2630 | my %DEF_CFG = ( |
2699 | my %DEF_CFG = ( |
|
|
2700 | config_autosave => 1, |
2631 | sdl_mode => undef, |
2701 | sdl_mode => undef, |
2632 | fullscreen => 1, |
2702 | fullscreen => 1, |
2633 | fast => 0, |
2703 | fast => 0, |
2634 | force_opengl11 => undef, |
2704 | force_opengl11 => undef, |
2635 | disable_alpha => 0, |
2705 | disable_alpha => 0, |
… | |
… | |
2653 | effects_enable => 1, |
2723 | effects_enable => 1, |
2654 | effects_volume => 1, |
2724 | effects_volume => 1, |
2655 | bgm_enable => 1, |
2725 | bgm_enable => 1, |
2656 | bgm_volume => 0.5, |
2726 | bgm_volume => 0.5, |
2657 | output_rate => "", |
2727 | output_rate => "", |
2658 | pickup => 0, |
2728 | pickup => PICKUP_SPELLBOOK | PICKUP_SKILLSCROLL | PICKUP_VALUABLES, |
2659 | inv_sort => "mtime", |
2729 | inv_sort => "mtime", |
2660 | default => "profile", # default profile |
2730 | default => "profile", # default profile |
2661 | show_tips => 1, |
2731 | show_tips => 1, |
2662 | logview_max_par => 1000, |
2732 | logview_max_par => 1000, |
2663 | shift_fire_stop => 0, |
2733 | shift_fire_stop => 0, |
… | |
… | |
2732 | }; |
2802 | }; |
2733 | |
2803 | |
2734 | delete $SIG{__DIE__}; |
2804 | delete $SIG{__DIE__}; |
2735 | EV::loop; |
2805 | EV::loop; |
2736 | |
2806 | |
|
|
2807 | DC::write_cfg if $CFG->{config_autosave}; |
|
|
2808 | |
2737 | #video_shutdown; |
2809 | #video_shutdown; |
2738 | #audio_shutdown; |
2810 | #audio_shutdown; |
|
|
2811 | |
2739 | DC::OpenGL::quit; |
2812 | DC::OpenGL::quit; |
2740 | DC::SDL_Quit; |
2813 | DC::SDL_Quit; |
2741 | DC::DB::Server::stop; |
2814 | DC::DB::Server::stop; |
2742 | } |
2815 | } |
2743 | |
2816 | |