… | |
… | |
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; |
… | |
… | |
125 | |
130 | |
126 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
131 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
127 | $SIG{PIPE} = 'IGNORE'; |
132 | $SIG{PIPE} = 'IGNORE'; |
128 | |
133 | |
129 | $EV::DIED = sub { |
134 | $EV::DIED = sub { |
130 | crash "CRASH/EV::DIED: $@" => 1; |
135 | crash "CRASH/EV::DIED: $@" => 0; |
131 | DC::fatal Carp::longmess $@; |
136 | DC::fatal Carp::longmess $@; |
132 | }; |
137 | }; |
133 | |
138 | |
134 | my $MAX_FPS = 60; |
139 | my $MAX_FPS = 60; |
135 | |
140 | |
… | |
… | |
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; |
… | |
… | |
215 | # write a crash message blockingly to the socket, if possible |
223 | # write a crash message blockingly to the socket, if possible |
216 | # this is a bit too complicated for my tastes, but it was easy. |
224 | # this is a bit too complicated for my tastes, but it was easy. |
217 | *crash = sub($;$) { |
225 | *crash = sub($;$) { |
218 | my ($msg, $backtrace) = @_; |
226 | my ($msg, $backtrace) = @_; |
219 | |
227 | |
|
|
228 | warn $msg; |
|
|
229 | |
220 | return unless $CONN; |
230 | return unless $CONN; |
221 | |
231 | |
222 | my $fh = $CONN->{fh} |
232 | my $fh = $CONN->{fh} |
223 | or return; |
233 | or return; |
224 | |
234 | |
… | |
… | |
234 | |
244 | |
235 | # backtrace as second step, in case it crashes, too |
245 | # backtrace as second step, in case it crashes, too |
236 | crash Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated" |
246 | crash Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated" |
237 | if $backtrace; |
247 | if $backtrace; |
238 | }; |
248 | }; |
|
|
249 | |
|
|
250 | sub clienterror($;$) { |
|
|
251 | my ($msg, $backtrace) = @_; |
|
|
252 | |
|
|
253 | warn $msg; |
|
|
254 | |
|
|
255 | return unless $CONN; |
|
|
256 | |
|
|
257 | $CONN->send_exti_msg (clientlog => $msg); |
|
|
258 | $CONN->send_exti_msg (clientlog => Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated") if $backtrace; |
|
|
259 | } |
239 | |
260 | |
240 | ############################################################################# |
261 | ############################################################################# |
241 | |
262 | |
242 | sub status { |
263 | sub status { |
243 | $STATUSBOX->add (DC::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
264 | $STATUSBOX->add (DC::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
… | |
… | |
325 | or return; |
346 | or return; |
326 | |
347 | |
327 | $meta->{data} |
348 | $meta->{data} |
328 | or return; |
349 | or return; |
329 | |
350 | |
330 | # if its a jingle, play it as ambient music |
351 | # if it's a jingle, play it as ambient music |
331 | if ($meta->{data}{jingle}) { |
352 | if ($meta->{data}{jingle}) { |
332 | 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 |
333 | push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue |
354 | push @MUSIC_JINGLE, $meta; # push it unto the music/jingle queue |
334 | &audio_music_push ($face); |
355 | &audio_music_push ($face); |
335 | } |
356 | } |
336 | } else { |
357 | } else { |
337 | # fetch from database |
358 | # fetch from database |
338 | DC::DB::get res_data => $meta->{name}, sub { |
359 | DC::DB::get res_data => $meta->{name}, sub { |
339 | my $rwops = new DC::RW $_[0]; |
360 | my $rwops = new DC::RW $_[0]; |
340 | my $chunk = new DC::MixChunk $rwops |
361 | my $chunk = new DC::MixChunk $rwops |
341 | 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; |
342 | $chunk->volume (($meta->{data}{volume} || 1) * 128); |
363 | $chunk->volume (($meta->{data}{volume} || 1) * 128); |
343 | $AUDIO_CHUNK{$face} = $chunk; |
364 | $AUDIO_CHUNK{$face} = $chunk; |
344 | |
365 | |
345 | audio_sound_push ($face); |
366 | audio_sound_push ($face); |
346 | }; |
367 | }; |
… | |
… | |
393 | |
414 | |
394 | audio_music_update_volume; |
415 | audio_music_update_volume; |
395 | |
416 | |
396 | $MUSIC_PLAYING_DATA = \$_[0]; |
417 | $MUSIC_PLAYING_DATA = \$_[0]; |
397 | |
418 | |
|
|
419 | $meta->{path} or length $_[0] |
|
|
420 | or return clienterror "empty music face from res_data ($meta->{face})";#d# |
|
|
421 | |
398 | my $rwops = $meta->{path} |
422 | my $rwops = $meta->{path} |
399 | ? 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 |
400 | : new DC::RW $$MUSIC_PLAYING_DATA; |
424 | : new DC::RW $$MUSIC_PLAYING_DATA; |
401 | |
425 | |
402 | $MUSIC_PLAYER = new DC::MixMusic $rwops |
426 | $MUSIC_PLAYER = new DC::MixMusic $rwops |
403 | or Carp::confess "music face $meta->{face} unloadable: " . DC::Mix_GetError; |
427 | or return clienterror "music face $meta->{face} unloadable: " . DC::Mix_GetError => 1; |
404 | |
428 | |
405 | my $NOW = time; |
429 | my $NOW = time; |
406 | |
430 | |
407 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
431 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
408 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |
432 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |
… | |
… | |
766 | } |
790 | } |
767 | |
791 | |
768 | sub dc_connect { |
792 | sub dc_connect { |
769 | my ($host, $port) = @_; |
793 | my ($host, $port) = @_; |
770 | |
794 | |
771 | my $mapw = List::Util::min 48, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
795 | my $mapw = List::Util::min 48, List::Util::max 11, int 1.5 + $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
772 | my $maph = List::Util::min 48, List::Util::max 11, int $HEIGHT * $CFG->{mapsize} * 0.01 / 32; |
796 | my $maph = List::Util::min 48, List::Util::max 11, int 1.5 + $HEIGHT * $CFG->{mapsize} * 0.01 / 32; |
773 | |
797 | |
774 | $CONN = |
798 | $CONN = |
775 | new DC::Protocol |
799 | new DC::Protocol |
776 | host => $host, |
800 | host => $host, |
777 | port => $port, |
801 | port => $port, |
… | |
… | |
897 | |
921 | |
898 | $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"); |
899 | $table->add_at (1, $row++, my $hbox = new DC::UI::HBox); |
923 | $table->add_at (1, $row++, my $hbox = new DC::UI::HBox); |
900 | |
924 | |
901 | $hbox->add ($MODE_SLIDER = new DC::UI::Slider |
925 | $hbox->add ($MODE_SLIDER = new DC::UI::Slider |
|
|
926 | c_rescale => 1, |
902 | force_w => $WIDTH * 0.1, expand => 1, |
927 | force_w => $WIDTH * 0.1, expand => 1, |
903 | range => [ ($CFG->{sdl_mode}) x 3 ], |
928 | range => [ ($CFG->{sdl_mode}) x 3 ], |
904 | tooltip => $vidmode_tooltip); |
929 | tooltip => $vidmode_tooltip); |
905 | $hbox->add (my $mode_label = new DC::UI::Label |
930 | $hbox->add (my $mode_label = new DC::UI::Label |
906 | height => 0.8, template => "9999x9999@9+9", |
931 | height => 0.8, template => "9999x9999@9+9", |
… | |
… | |
934 | ); |
959 | ); |
935 | |
960 | |
936 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Forbid Alpha"); |
961 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Forbid Alpha"); |
937 | $table->add_at (1, $row++, new DC::UI::CheckBox |
962 | $table->add_at (1, $row++, new DC::UI::CheckBox |
938 | state => $CFG->{disable_alpha}, |
963 | state => $CFG->{disable_alpha}, |
939 | tooltip => "Forbid off the use of the alpha channel. This makes Deliantra look a lot worse " |
964 | tooltip => "Forbid the use of the alpha channel. This makes Deliantra look a lot worse " |
940 | . "by disabling a number of textures and transparency effects. Normally, these " |
965 | . "by disabling a number of textures and transparency effects. Normally, these " |
941 | . "effects do not cost a lot of resources, but some graphics cards might fall " |
966 | . "effects do not cost a lot of resources, but some graphics cards might fall " |
942 | . "back to extremely slow rendering if this is enabled. If disabling this option " |
967 | . "back to extremely slow rendering if this is enabled. If disabling this option " |
943 | . "noticably improves the framerate of the client please report this! " |
968 | . "noticably improves the framerate of the client please report this! " |
944 | . "<b>If you experience extremely low framerates and your card should do better, try this option.</b>", |
969 | . "<b>If you experience extremely low framerates and your card should do better, try this option.</b>", |
… | |
… | |
1230 | } |
1255 | } |
1231 | |
1256 | |
1232 | sub make_gauge_window { |
1257 | sub make_gauge_window { |
1233 | my $gh = int $HEIGHT * $CFG->{gauge_size}; |
1258 | my $gh = int $HEIGHT * $CFG->{gauge_size}; |
1234 | |
1259 | |
1235 | my $win = new DC::UI::Frame ( |
1260 | $GAUGES->{win} = my $win = new DC::UI::Frame ( |
1236 | force_x => 0, |
1261 | force_x => 0, |
1237 | force_y => "max", |
1262 | force_y => "max", |
1238 | force_w => $WIDTH, |
1263 | force_w => $WIDTH, |
1239 | force_h => $gh, |
1264 | force_h => $gh, |
1240 | ); |
1265 | ); |
… | |
… | |
1256 | (new DC::UI::Empty expand => 1), |
1281 | (new DC::UI::Empty expand => 1), |
1257 | (my $hb = new DC::UI::HBox), |
1282 | (my $hb = new DC::UI::HBox), |
1258 | ], |
1283 | ], |
1259 | ); |
1284 | ); |
1260 | |
1285 | |
1261 | $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"); |
1262 | $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"); |
1263 | $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"); |
1264 | $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"); |
1265 | |
|
|
1266 | $vbox->add (my $exp = new DC::UI::Label align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp"); |
|
|
1267 | $vbox->add (my $prg = new DC::UI::ExperienceProgress); |
|
|
1268 | $vbox->add (my $sklprg = new DC::UI::ExperienceProgress); |
|
|
1269 | $vbox->add (my $rng = new DC::UI::Label align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged"); |
|
|
1270 | |
|
|
1271 | $GAUGES = { |
|
|
1272 | exp => $exp, prg => $prg, sklprg => $sklprg, |
|
|
1273 | win => $win, range => $rng, |
|
|
1274 | hp => $hg, mana => $mg, grace => $gg, food => $fg, |
|
|
1275 | }; |
|
|
1276 | |
1290 | |
1277 | &set_gauge_window_fontsize; |
1291 | &set_gauge_window_fontsize; |
1278 | |
1292 | |
1279 | $win |
1293 | $win |
1280 | } |
1294 | } |
… | |
… | |
1622 | ); |
1636 | ); |
1623 | |
1637 | |
1624 | $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"); |
1625 | $table->add_at (1, 4, new DC::UI::Entry |
1639 | $table->add_at (1, 4, new DC::UI::Entry |
1626 | text => $CFG->{profile}{default}{user}, |
1640 | text => $CFG->{profile}{default}{user}, |
1627 | tooltip => "The name of your character on the server.", |
1641 | tooltip => "The name of your character on the server. The name is case-sensitive!", |
1628 | 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 } |
1629 | ); |
1643 | ); |
1630 | |
1644 | |
1631 | $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"); |
1632 | $table->add_at (1, 5, new DC::UI::Entry |
1646 | $table->add_at (1, 5, new DC::UI::Entry |
… | |
… | |
1734 | |
1748 | |
1735 | my $row = 0; |
1749 | my $row = 0; |
1736 | |
1750 | |
1737 | $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"); |
1738 | $table->add_at (1, $row++, new DC::UI::CheckBox |
1752 | $table->add_at (1, $row++, new DC::UI::CheckBox |
|
|
1753 | c_colspan => 2, |
1739 | state => $CFG->{show_tips}, |
1754 | state => $CFG->{show_tips}, |
1740 | 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?", |
1741 | on_changed => sub { |
1756 | on_changed => sub { |
1742 | my ($self, $value) = @_; |
1757 | my ($self, $value) = @_; |
1743 | $CFG->{show_tips} = $value; |
1758 | $CFG->{show_tips} = $value; |
… | |
… | |
1745 | } |
1760 | } |
1746 | ); |
1761 | ); |
1747 | |
1762 | |
1748 | $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"); |
1749 | $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, |
1750 | text => $CFG->{logview_max_par}, |
1766 | text => $CFG->{logview_max_par}, |
1751 | 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 " |
1752 | . "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 " |
1753 | . "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.", |
1754 | on_changed => sub { |
1770 | on_changed => sub { |
… | |
… | |
1756 | $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); |
1772 | $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); |
1757 | 0 |
1773 | 0 |
1758 | }, |
1774 | }, |
1759 | ); |
1775 | ); |
1760 | |
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 | |
1761 | $table |
1799 | $table |
1762 | } |
1800 | } |
1763 | |
1801 | |
1764 | sub autopickup_setup { |
1802 | sub autopickup_setup { |
1765 | my $r = new DC::UI::ScrolledWindow ( |
1803 | my $r = new DC::UI::ScrolledWindow ( |
… | |
… | |
1771 | col_expand => [0, 1, 0, 1], |
1809 | col_expand => [0, 1, 0, 1], |
1772 | ); |
1810 | ); |
1773 | |
1811 | |
1774 | for ( |
1812 | for ( |
1775 | ["General", 0, 0, |
1813 | ["General", 0, 0, |
1776 | ["Enable autopickup" => PICKUP_NEWMODE, \$PICKUP_ENABLE], |
|
|
1777 | ["Inhibit autopickup" => PICKUP_INHIBIT], |
1814 | ["Inhibit autopickup" => PICKUP_INHIBIT], |
1778 | ["Stop before pickup" => PICKUP_STOP], |
1815 | ["Stop before pickup" => PICKUP_STOP], |
1779 | ["Debug autopickup" => PICKUP_DEBUG], |
1816 | ["Debug autopickup" => PICKUP_DEBUG], |
1780 | ], |
1817 | ], |
1781 | ["Weapons", 0, 6, |
1818 | ["Weapons", 0, 6, |
… | |
… | |
1830 | $::CFG->{pickup} |= $mask; |
1867 | $::CFG->{pickup} |= $mask; |
1831 | } else { |
1868 | } else { |
1832 | $::CFG->{pickup} &= ~$mask; |
1869 | $::CFG->{pickup} &= ~$mask; |
1833 | } |
1870 | } |
1834 | |
1871 | |
1835 | $::CONN->send_command ("pickup $::CFG->{pickup}") |
1872 | $::CONN->send_pickup ($::CFG->{pickup}) |
1836 | if defined $::CONN; |
1873 | if defined $::CONN; |
1837 | |
1874 | |
1838 | 0 |
1875 | 0 |
1839 | }); |
1876 | }); |
1840 | |
1877 | |
… | |
… | |
1857 | }); |
1894 | }); |
1858 | |
1895 | |
1859 | $table->add_at (3, 18, new DC::UI::Button |
1896 | $table->add_at (3, 18, new DC::UI::Button |
1860 | text => "set", |
1897 | text => "set", |
1861 | on_activate => sub { |
1898 | on_activate => sub { |
1862 | $::CONN->send_command ("pickup $::CFG->{pickup}") |
1899 | $::CONN->send_pickup ($::CFG->{pickup}) |
1863 | if defined $::CONN; |
1900 | if defined $::CONN; |
1864 | 0 |
1901 | 0 |
1865 | }); |
1902 | }); |
1866 | |
1903 | |
1867 | $r |
1904 | $r |
… | |
… | |
1980 | $PL_NOTEBOOK->set_current_page ($widget); |
2017 | $PL_NOTEBOOK->set_current_page ($widget); |
1981 | $PL_WINDOW->show; |
2018 | $PL_WINDOW->show; |
1982 | } |
2019 | } |
1983 | } |
2020 | } |
1984 | |
2021 | |
1985 | sub player_window { |
2022 | sub make_playerbook { |
1986 | my $plwin = $PL_WINDOW = new DC::UI::Toplevel |
2023 | my $plwin = $PL_WINDOW = new DC::UI::Toplevel |
1987 | x => "center", |
2024 | x => "center", |
1988 | y => "center", |
2025 | y => "center", |
1989 | force_w => $WIDTH * 9/10, |
2026 | force_w => $WIDTH * 9/10, |
1990 | force_h => $HEIGHT * 9/10, |
2027 | force_h => $HEIGHT * 9/10, |
… | |
… | |
2024 | "License, Author and Source info for media sent by the server."); |
2061 | "License, Author and Source info for media sent by the server."); |
2025 | |
2062 | |
2026 | $ntb->set_current_page ($INVENTORY_PAGE); |
2063 | $ntb->set_current_page ($INVENTORY_PAGE); |
2027 | |
2064 | |
2028 | $plwin->add ($ntb); |
2065 | $plwin->add ($ntb); |
2029 | $plwin |
|
|
2030 | } |
2066 | } |
2031 | |
2067 | |
2032 | sub keyboard_setup { |
2068 | sub keyboard_setup { |
2033 | DC::Macro::keyboard_setup |
2069 | DC::Macro::keyboard_setup |
2034 | } |
2070 | } |
2035 | |
2071 | |
2036 | sub help_window { |
2072 | sub make_help_window { |
2037 | my $win = new DC::UI::Toplevel |
2073 | my $win = new DC::UI::Toplevel |
2038 | x => 'center', |
2074 | x => 'center', |
2039 | y => 'center', |
2075 | y => 'center', |
2040 | z => 4, |
2076 | z => 4, |
2041 | name => 'doc_browser', |
2077 | name => 'doc_browser', |
… | |
… | |
2130 | |
2166 | |
2131 | $load_node->((DC::Pod::find @path)[0]); |
2167 | $load_node->((DC::Pod::find @path)[0]); |
2132 | $win->show; |
2168 | $win->show; |
2133 | }; |
2169 | }; |
2134 | |
2170 | |
2135 | $win |
2171 | $HELP_WINDOW = $win; |
2136 | } |
|
|
2137 | |
|
|
2138 | sub open_string_query { |
|
|
2139 | my ($title, $cb, $txt, $tooltip) = @_; |
|
|
2140 | my $dialog = new DC::UI::Toplevel |
|
|
2141 | x => "center", |
|
|
2142 | y => "center", |
|
|
2143 | z => 50, |
|
|
2144 | force_w => $WIDTH * 4/5, |
|
|
2145 | title => $title; |
|
|
2146 | |
|
|
2147 | $dialog->add ( |
|
|
2148 | my $e = new DC::UI::Entry |
|
|
2149 | on_activate => sub { $cb->(@_); $dialog->hide; 0 }, |
|
|
2150 | on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 }, |
|
|
2151 | tooltip => $tooltip |
|
|
2152 | ); |
|
|
2153 | |
|
|
2154 | $e->grab_focus; |
|
|
2155 | $e->set_text ($txt) if $txt; |
|
|
2156 | $dialog->show; |
|
|
2157 | } |
2172 | } |
2158 | |
2173 | |
2159 | sub open_quit_dialog { |
2174 | sub open_quit_dialog { |
2160 | unless ($QUIT_DIALOG) { |
2175 | unless ($QUIT_DIALOG) { |
2161 | $QUIT_DIALOG = new DC::UI::Toplevel |
2176 | $QUIT_DIALOG = new DC::UI::Toplevel |
… | |
… | |
2194 | |
2209 | |
2195 | $QUIT_DIALOG->show; |
2210 | $QUIT_DIALOG->show; |
2196 | $QUIT_DIALOG->grab_focus; |
2211 | $QUIT_DIALOG->grab_focus; |
2197 | } |
2212 | } |
2198 | |
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 progress towards the next character level.", |
|
|
2264 | template => " Exp: 8,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 disdabling 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 | |
2199 | sub show_tip_of_the_day { |
2322 | sub show_tip_of_the_day { |
2200 | # find all tips |
2323 | # find all tips |
2201 | my @tod = DC::Pod::find tip_of_the_day => "*"; |
2324 | my @tod = DC::Pod::find tip_of_the_day => "*"; |
2202 | |
2325 | |
2203 | DC::DB::get state => "tip_of_the_day", sub { |
2326 | DC::DB::get state => "tip_of_the_day", sub { |
… | |
… | |
2342 | |
2465 | |
2343 | (new DC::UI::Frame |
2466 | (new DC::UI::Frame |
2344 | bg => [0, 0, 0, 0.4], |
2467 | bg => [0, 0, 0, 0.4], |
2345 | force_x => 0, |
2468 | force_x => 0, |
2346 | force_y => "max", |
2469 | force_y => "max", |
2347 | child => (my $LR = new DC::UI::VBox), |
2470 | child => (my $LL = new DC::UI::VBox), |
2348 | )->show; |
2471 | )->show; |
2349 | |
2472 | |
2350 | $LR->add ($STATUSBOX); |
2473 | $LL->add ($STATUSBOX); |
2351 | $LR->add ($MODBOX); |
2474 | $LL->add ($MODBOX); |
2352 | $LR->add (new DC::UI::Label |
2475 | $LL->add (new DC::UI::Label |
2353 | align => 0, |
2476 | align => 0, |
2354 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode", |
2477 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode", |
2355 | fontsize => 0.5, |
2478 | fontsize => 0.5, |
2356 | fg => [1, 1, 0, 0.7], |
2479 | fg => [1, 1, 0, 0.7], |
2357 | ); |
2480 | ); |
… | |
… | |
2426 | . "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 " |
2427 | . "binding editor closes"); |
2550 | . "binding editor closes"); |
2428 | $SETUP_NOTEBOOK->add_tab (Debug => debug_setup, |
2551 | $SETUP_NOTEBOOK->add_tab (Debug => debug_setup, |
2429 | "Some debuggin' options. Do not ask."); |
2552 | "Some debuggin' options. Do not ask."); |
2430 | |
2553 | |
2431 | $BUTTONBAR = new DC::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
2554 | make_help_window; |
|
|
2555 | make_menubar; |
2432 | |
2556 | |
2433 | $BUTTONBAR->add (new DC::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
|
|
2434 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
|
|
2435 | |
|
|
2436 | # $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, |
|
|
2437 | # tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
|
|
2438 | |
|
|
2439 | 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 |
|
|
2440 | |
|
|
2441 | $BUTTONBAR->add (new DC::UI::Flopper text => "Playerbook", other => player_window, |
|
|
2442 | tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats."); |
|
|
2443 | |
|
|
2444 | $BUTTONBAR->add (new DC::UI::Button |
|
|
2445 | text => "Save Config", |
|
|
2446 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
|
|
2447 | on_activate => sub { |
|
|
2448 | $::CFG->{layout} = DC::UI::get_layout; |
|
|
2449 | DC::write_cfg; |
|
|
2450 | status "Configuration Saved"; |
|
|
2451 | 0 |
|
|
2452 | }, |
|
|
2453 | ); |
|
|
2454 | |
|
|
2455 | $BUTTONBAR->add (new DC::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, |
|
|
2456 | tooltip => "View Documentation"); |
|
|
2457 | |
|
|
2458 | $BUTTONBAR->add (new DC::UI::Button |
|
|
2459 | text => "Quit", |
|
|
2460 | tooltip => "Terminates the program", |
|
|
2461 | on_activate => sub { |
|
|
2462 | if ($CONN) { |
|
|
2463 | open_quit_dialog; |
|
|
2464 | } else { |
|
|
2465 | EV::unloop EV::UNLOOP_ALL; |
|
|
2466 | } |
|
|
2467 | 0 |
|
|
2468 | }, |
|
|
2469 | ); |
|
|
2470 | |
|
|
2471 | $BUTTONBAR->show; |
|
|
2472 | $SETUP_DIALOG->show; |
2557 | $SETUP_DIALOG->show; |
2473 | $MESSAGE_WINDOW->show; |
2558 | $MESSAGE_WINDOW->show; |
2474 | } |
2559 | } |
2475 | |
2560 | |
2476 | $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]); |
… | |
… | |
2586 | $SIG{INT} = $SIG{TERM} = sub { |
2671 | $SIG{INT} = $SIG{TERM} = sub { |
2587 | EV::unloop; |
2672 | EV::unloop; |
2588 | #d# TODO calling exit here hangs the process in some futex |
2673 | #d# TODO calling exit here hangs the process in some futex |
2589 | }; |
2674 | }; |
2590 | |
2675 | |
2591 | # due to mac os x + sdl combined briandamage, we need this contortion |
2676 | # due to mac os x + sdl combined braindamage, we need this contortion |
2592 | sub main { |
2677 | sub main { |
2593 | { |
2678 | { |
2594 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
2679 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
2595 | |
2680 | |
2596 | if (-e "$Deliantra::VARDIR/client.cf") { |
2681 | if (-e "$Deliantra::VARDIR/client.cf") { |
… | |
… | |
2613 | DC::DB::open_db; |
2698 | DC::DB::open_db; |
2614 | |
2699 | |
2615 | DC::UI::set_layout ($::CFG->{layout}); |
2700 | DC::UI::set_layout ($::CFG->{layout}); |
2616 | |
2701 | |
2617 | my %DEF_CFG = ( |
2702 | my %DEF_CFG = ( |
|
|
2703 | config_autosave => 1, |
2618 | sdl_mode => undef, |
2704 | sdl_mode => undef, |
2619 | fullscreen => 1, |
2705 | fullscreen => 1, |
2620 | fast => 0, |
2706 | fast => 0, |
2621 | force_opengl11 => undef, |
2707 | force_opengl11 => undef, |
2622 | disable_alpha => 0, |
2708 | disable_alpha => 0, |
… | |
… | |
2640 | effects_enable => 1, |
2726 | effects_enable => 1, |
2641 | effects_volume => 1, |
2727 | effects_volume => 1, |
2642 | bgm_enable => 1, |
2728 | bgm_enable => 1, |
2643 | bgm_volume => 0.5, |
2729 | bgm_volume => 0.5, |
2644 | output_rate => "", |
2730 | output_rate => "", |
2645 | pickup => 0, |
2731 | pickup => PICKUP_SPELLBOOK | PICKUP_SKILLSCROLL | PICKUP_VALUABLES, |
2646 | inv_sort => "mtime", |
2732 | inv_sort => "mtime", |
2647 | default => "profile", # default profile |
2733 | default => "profile", # default profile |
2648 | show_tips => 1, |
2734 | show_tips => 1, |
2649 | logview_max_par => 1000, |
2735 | logview_max_par => 1000, |
2650 | shift_fire_stop => 0, |
2736 | shift_fire_stop => 0, |
… | |
… | |
2719 | }; |
2805 | }; |
2720 | |
2806 | |
2721 | delete $SIG{__DIE__}; |
2807 | delete $SIG{__DIE__}; |
2722 | EV::loop; |
2808 | EV::loop; |
2723 | |
2809 | |
|
|
2810 | DC::write_cfg if $CFG->{config_autosave}; |
|
|
2811 | |
2724 | #video_shutdown; |
2812 | #video_shutdown; |
2725 | #audio_shutdown; |
2813 | #audio_shutdown; |
|
|
2814 | |
2726 | DC::OpenGL::quit; |
2815 | DC::OpenGL::quit; |
2727 | DC::SDL_Quit; |
2816 | DC::SDL_Quit; |
2728 | DC::DB::Server::stop; |
2817 | DC::DB::Server::stop; |
2729 | } |
2818 | } |
2730 | |
2819 | |