… | |
… | |
32 | Win32::GUI::SplashScreen::Done (1); |
32 | Win32::GUI::SplashScreen::Done (1); |
33 | }; |
33 | }; |
34 | } |
34 | } |
35 | } |
35 | } |
36 | |
36 | |
37 | use strict; |
37 | use common::sense; |
38 | use utf8; |
|
|
39 | |
38 | |
40 | use Carp 'verbose'; |
39 | use Carp 'verbose'; |
41 | |
40 | |
42 | # do things only needed for single-binary version (par) |
41 | # do things only needed for single-binary version (par) |
43 | BEGIN { |
42 | BEGIN { |
… | |
… | |
56 | |
55 | |
57 | if ($^O eq "MSWin32") { |
56 | if ($^O eq "MSWin32") { |
58 | # pango is relocatable on win32 |
57 | # pango is relocatable on win32 |
59 | } else { |
58 | } else { |
60 | # OS X |
59 | # OS X |
61 | $ENV{FONTCONFIG_FILE} = "$root/fonts.conf"; # no effect??!?! |
|
|
62 | $ENV{FONTCONFIG_DIR} = $root; # no effect??!?! |
|
|
63 | $ENV{PANGO_RC_FILE} = "$root/pango.rc"; |
60 | $ENV{PANGO_RC_FILE} = "$root/pango.rc"; |
64 | $ENV{DYLD_LIBRARY_PATH} = $root; |
61 | $ENV{DYLD_LIBRARY_PATH} = $root; |
65 | chdir $root; # for pango modules, maybe other things |
62 | chdir $root; # for pango modules, maybe other things |
66 | } |
63 | } |
67 | |
64 | |
68 | unshift @INC, $root; |
65 | unshift @INC, $root; |
69 | } |
66 | } |
70 | } |
67 | } |
71 | |
68 | |
72 | # prepend private library directory |
69 | # prepend private library directory and prepare env |
73 | BEGIN { |
70 | BEGIN { |
74 | for (grep !ref, @INC) { |
71 | for (grep !ref, @INC) { |
75 | my $path = "$_/Deliantra/Client/private"; |
72 | my $path = "$_/Deliantra/Client/private"; |
76 | if (-d $path) { |
73 | if (-d $path) { |
77 | unshift @INC, $path; |
74 | unshift @INC, $path; |
… | |
… | |
136 | DC::fatal Carp::longmess $@; |
133 | DC::fatal Carp::longmess $@; |
137 | }; |
134 | }; |
138 | |
135 | |
139 | my $MAX_FPS = 60; |
136 | my $MAX_FPS = 60; |
140 | |
137 | |
|
|
138 | our $DEFAULT_SERVER = "gameserver.deliantra.net"; |
|
|
139 | |
141 | our $META_SERVER = "http://metaserver.schmorp.de/current.json"; |
140 | our $META_SERVER = "http://metaserver.schmorp.de/current.json"; |
142 | |
141 | |
143 | our $LAST_REFRESH; |
142 | our $LAST_REFRESH; |
144 | our $NOW; |
143 | our $NOW; |
145 | |
144 | |
146 | our $CFG; |
145 | our $CFG; |
147 | our $PROFILE; # current profile |
146 | our $PROFILE; # current profile |
148 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
147 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
|
|
148 | our $DELIANTRA_DEBUG = $ENV{DELIANTRA_DEBUG} * 1; |
149 | |
149 | |
150 | our $WANT_REFRESH; |
150 | our $WANT_REFRESH; |
151 | |
151 | |
152 | our $MODE_SLIDER; |
152 | our $MODE_SLIDER; |
153 | our $CAVEAT_LABEL; |
153 | our $CAVEAT_LABEL; |
… | |
… | |
166 | |
166 | |
167 | our $MAP; |
167 | our $MAP; |
168 | our $MAPMAP; |
168 | our $MAPMAP; |
169 | our $MAPWIDGET; |
169 | our $MAPWIDGET; |
170 | our $COMPLETER; |
170 | our $COMPLETER; |
171 | 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 |
172 | our $METASERVER; |
175 | our $METASERVER; |
173 | our $LOGIN_BUTTON; |
176 | our $LOGIN_BUTTON; |
174 | our $QUIT_DIALOG; |
177 | our $QUIT_DIALOG; |
175 | our $HOST_ENTRY; |
178 | our $HOST_ENTRY; |
176 | our $FULLSCREEN_ENABLE; |
179 | our $FULLSCREEN_ENABLE; |
… | |
… | |
202 | our $FLOORBOX; |
205 | our $FLOORBOX; |
203 | our $GAUGES; |
206 | our $GAUGES; |
204 | our $STATWIDS; |
207 | our $STATWIDS; |
205 | |
208 | |
206 | our $SDL_ACTIVE; |
209 | our $SDL_ACTIVE; |
207 | our %SDL_CB; |
210 | our @SDL_CB; |
208 | |
211 | |
209 | our $ALT_ENTER_MESSAGE; |
212 | our $ALT_ENTER_MESSAGE; |
210 | our $STATUSBOX; |
213 | our $STATUSBOX; |
211 | our $MODBOX; |
214 | our $MODBOX; |
212 | our $DEBUG_STATUS; |
215 | our $DEBUG_STATUS; |
… | |
… | |
343 | or return; |
346 | or return; |
344 | |
347 | |
345 | $meta->{data} |
348 | $meta->{data} |
346 | or return; |
349 | or return; |
347 | |
350 | |
348 | # if its a jingle, play it as ambient music |
351 | # if it's a jingle, play it as ambient music |
349 | if ($meta->{data}{jingle}) { |
352 | if ($meta->{data}{jingle}) { |
350 | 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 |
351 | push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue |
354 | push @MUSIC_JINGLE, $meta; # push it unto the music/jingle queue |
352 | &audio_music_push ($face); |
355 | &audio_music_push ($face); |
353 | } |
356 | } |
354 | } else { |
357 | } else { |
355 | # fetch from database |
358 | # fetch from database |
356 | DC::DB::get res_data => $meta->{name}, sub { |
359 | DC::DB::get res_data => $meta->{name}, sub { |
357 | my $rwops = new DC::RW $_[0]; |
360 | my $rwops = new DC::RW $_[0]; |
358 | my $chunk = new DC::MixChunk $rwops |
361 | my $chunk = new DC::MixChunk $rwops |
359 | 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; |
360 | $chunk->volume (($meta->{data}{volume} || 1) * 128); |
363 | $chunk->volume (($meta->{data}{volume} || 1) * 128); |
361 | $AUDIO_CHUNK{$face} = $chunk; |
364 | $AUDIO_CHUNK{$face} = $chunk; |
362 | |
365 | |
363 | audio_sound_push ($face); |
366 | audio_sound_push ($face); |
364 | }; |
367 | }; |
… | |
… | |
411 | |
414 | |
412 | audio_music_update_volume; |
415 | audio_music_update_volume; |
413 | |
416 | |
414 | $MUSIC_PLAYING_DATA = \$_[0]; |
417 | $MUSIC_PLAYING_DATA = \$_[0]; |
415 | |
418 | |
|
|
419 | $meta->{path} or length $_[0] |
|
|
420 | or return clienterror "empty music face from res_data ($meta->{face})";#d# |
|
|
421 | |
416 | my $rwops = $meta->{path} |
422 | my $rwops = $meta->{path} |
417 | ? 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 |
418 | : new DC::RW $$MUSIC_PLAYING_DATA; |
424 | : new DC::RW $$MUSIC_PLAYING_DATA; |
419 | |
425 | |
420 | $MUSIC_PLAYER = new DC::MixMusic $rwops |
426 | $MUSIC_PLAYER = new DC::MixMusic $rwops |
421 | 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; |
422 | |
428 | |
… | |
… | |
535 | sub audio_tab_update; |
541 | sub audio_tab_update; |
536 | audio_tab_update; |
542 | audio_tab_update; |
537 | } |
543 | } |
538 | |
544 | |
539 | sub audio_shutdown { |
545 | sub audio_shutdown { |
|
|
546 | if ($SDL_MIXER) { |
|
|
547 | DC::MixMusic::halt; |
|
|
548 | DC::Mix_AllocateChannels 0; |
|
|
549 | } |
|
|
550 | |
540 | undef $MUSIC_PLAYER; |
551 | undef $MUSIC_PLAYER; |
541 | undef $MUSIC_PLAYING_META; |
552 | undef $MUSIC_PLAYING_META; |
542 | undef $MUSIC_PLAYING_DATA; |
553 | undef $MUSIC_PLAYING_DATA; |
543 | |
554 | |
544 | $MUSIC_WANT = []; |
555 | $MUSIC_WANT = []; |
… | |
… | |
796 | user => $PROFILE->{user}, |
807 | user => $PROFILE->{user}, |
797 | pass => $PROFILE->{password}, |
808 | pass => $PROFILE->{password}, |
798 | mapw => $mapw, |
809 | mapw => $mapw, |
799 | maph => $maph, |
810 | maph => $maph, |
800 | |
811 | |
|
|
812 | c_version => { |
|
|
813 | client => "deliantra", |
801 | client => "$DC::VERSION $] $^O", |
814 | clientver => $DC::VERSION, |
|
|
815 | gl_vendor => DC::OpenGL::gl_vendor, |
|
|
816 | gl_version => DC::OpenGL::gl_version, |
|
|
817 | }, |
802 | |
818 | |
803 | map_widget => $MAPWIDGET, |
819 | map_widget => $MAPWIDGET, |
804 | statusbox => $STATUSBOX, |
820 | statusbox => $STATUSBOX, |
805 | map => $MAP, |
821 | map => $MAP, |
806 | mapmap => $MAPMAP, |
822 | mapmap => $MAPMAP, |
… | |
… | |
812 | |
828 | |
813 | on_connect => sub { |
829 | on_connect => sub { |
814 | if ($_[0]) { |
830 | if ($_[0]) { |
815 | DC::lowdelay fileno $CONN->{fh}; |
831 | DC::lowdelay fileno $CONN->{fh}; |
816 | |
832 | |
817 | status "login successful"; |
833 | status "successfully connected to the server"; |
818 | } else { |
834 | } else { |
819 | undef $CONN; |
835 | undef $CONN; |
820 | status "unable to connect: $!"; |
836 | status "unable to connect: $!"; |
821 | stop_game(); |
837 | stop_game(); |
822 | } |
838 | } |
… | |
… | |
824 | ; |
840 | ; |
825 | } |
841 | } |
826 | |
842 | |
827 | sub start_game { |
843 | sub start_game { |
828 | status "logging in..."; |
844 | status "logging in..."; |
|
|
845 | |
|
|
846 | my $server = $PROFILE->{host} || $DEFAULT_SERVER; |
|
|
847 | my ($host, $port) = AnyEvent::Socket::parse_hostport $server, "deliantra=13327" |
|
|
848 | or return status "$server: unable to parse server address, try an empty field."; |
829 | |
849 | |
830 | $LOGIN_BUTTON->set_text ("Logout"); |
850 | $LOGIN_BUTTON->set_text ("Logout"); |
831 | $SETUP_DIALOG->hide; |
851 | $SETUP_DIALOG->hide; |
832 | |
|
|
833 | my ($host, $port) = AnyEvent::Socket::parse_hostport $PROFILE->{host}, "deliantra=13327"; |
|
|
834 | |
852 | |
835 | $MAP = new DC::Map; |
853 | $MAP = new DC::Map; |
836 | |
854 | |
837 | # hack to make SURE we find the IP address all right |
855 | # hack to make SURE we find the IP address all right |
838 | # can be removed once AnyEvent::DNS is proven stable. |
856 | # can be removed once AnyEvent::DNS is proven stable. |
839 | if ($host eq "gameserver.deliantra.net") { |
857 | if ($host eq "gameserver.deliantra.net") { |
840 | AnyEvent::DNS::a "dnstest.deliantra.net", sub { |
858 | AnyEvent::DNS::a "dnstest.deliantra.net", sub { |
841 | if ($_[0] ne "80.101.114.108") { # Perl |
859 | if ($_[0] ne "80.101.114.108") { # Perl |
|
|
860 | status "dns failure, trying differently"; |
|
|
861 | $host = eval { Socket::inet_ntoa Socket::inet_aton "gameserver.deliantra.net" }; |
|
|
862 | unless (defined $host) { |
842 | status "dns failure, using hardcoded address"; |
863 | status "dns failure, using hardcoded address"; |
843 | $host = "129.13.162.95"; |
864 | $host = "129.13.162.95"; |
|
|
865 | } |
844 | } |
866 | } |
845 | |
867 | |
846 | dc_connect $host, $port; |
868 | dc_connect $host, $port; |
847 | }; |
869 | }; |
848 | } else { |
870 | } else { |
… | |
… | |
915 | |
937 | |
916 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Video Mode"); |
938 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Video Mode"); |
917 | $table->add_at (1, $row++, my $hbox = new DC::UI::HBox); |
939 | $table->add_at (1, $row++, my $hbox = new DC::UI::HBox); |
918 | |
940 | |
919 | $hbox->add ($MODE_SLIDER = new DC::UI::Slider |
941 | $hbox->add ($MODE_SLIDER = new DC::UI::Slider |
|
|
942 | c_rescale => 1, |
920 | force_w => $WIDTH * 0.1, expand => 1, |
943 | force_w => $WIDTH * 0.1, expand => 1, |
921 | range => [ ($CFG->{sdl_mode}) x 3 ], |
944 | range => [ ($CFG->{sdl_mode}) x 3 ], |
922 | tooltip => $vidmode_tooltip); |
945 | tooltip => $vidmode_tooltip); |
923 | $hbox->add (my $mode_label = new DC::UI::Label |
946 | $hbox->add (my $mode_label = new DC::UI::Label |
924 | height => 0.8, template => "9999x9999@9+9", |
947 | height => 0.8, template => "9999x9999@9+9", |
… | |
… | |
1016 | . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, " |
1039 | . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, " |
1017 | . "then disable this option. Changes take effect immdiately.", |
1040 | . "then disable this option. Changes take effect immdiately.", |
1018 | on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_movement} = $value; 0 } |
1041 | on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_movement} = $value; 0 } |
1019 | ); |
1042 | ); |
1020 | |
1043 | |
|
|
1044 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Smooth Transitions"); |
|
|
1045 | $table->add_at (1, $row++, new DC::UI::CheckBox |
|
|
1046 | state => $CFG->{smooth_transitions}, |
|
|
1047 | tooltip => "<b>Smooth Transitions</b> tries to blend the fog of war and lighting smoothly between updates. " |
|
|
1048 | . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, " |
|
|
1049 | . "then disable this option. Requires Smooth Movement and OpenGL Multitexturing. Changes take effect immdiately.", |
|
|
1050 | on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_transitions} = $value; 0 } |
|
|
1051 | ); |
|
|
1052 | |
|
|
1053 | |
1021 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Map Scale"); |
1054 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Map Scale"); |
1022 | $table->add_at (1, $row++, new DC::UI::Slider |
1055 | $table->add_at (1, $row++, new DC::UI::Slider |
1023 | range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], |
1056 | range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], |
1024 | tooltip => "Enlarge or shrink the displayed map. Changes are instant.", |
1057 | tooltip => "Enlarge or shrink the displayed map. Changes are instant.", |
1025 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 } |
1058 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 } |
… | |
… | |
1037 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fog of War"); |
1070 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fog of War"); |
1038 | $table->add_at (1, $row++, new DC::UI::CheckBox |
1071 | $table->add_at (1, $row++, new DC::UI::CheckBox |
1039 | state => $CFG->{fow_enable}, |
1072 | state => $CFG->{fow_enable}, |
1040 | tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.", |
1073 | tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.", |
1041 | on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 } |
1074 | on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 } |
|
|
1075 | ); |
|
|
1076 | |
|
|
1077 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Pattern"); |
|
|
1078 | $table->add_at (1, $row++, new DC::UI::ImageButton |
|
|
1079 | tex => $DC::MapWidget::TEX_HIDDEN[$CFG->{fow_texture}], |
|
|
1080 | bg => [0.3, 0.3, 0.2], |
|
|
1081 | force_w => 64, |
|
|
1082 | force_h => 64, |
|
|
1083 | tooltip => "<b>Fog of War Pattern.</b> The pattern that is overlaid over areas hidden from view. Click to cycle through various alternatives. Changes are instant.", |
|
|
1084 | on_activate => sub { |
|
|
1085 | my ($self) = @_; |
|
|
1086 | $CFG->{fow_texture} = ($CFG->{fow_texture} + 1) % @DC::MapWidget::TEX_HIDDEN; |
|
|
1087 | $self->set_texture ($DC::MapWidget::TEX_HIDDEN[$CFG->{fow_texture}]); |
|
|
1088 | $MAPWIDGET->update; |
|
|
1089 | } |
1042 | ); |
1090 | ); |
1043 | |
1091 | |
1044 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Intensity"); |
1092 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Intensity"); |
1045 | $table->add_at (1, $row++, new DC::UI::Slider |
1093 | $table->add_at (1, $row++, new DC::UI::Slider |
1046 | range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256], |
1094 | range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256], |
… | |
… | |
1098 | |
1146 | |
1099 | my $text = !$freq |
1147 | my $text = !$freq |
1100 | ? "audio is off" |
1148 | ? "audio is off" |
1101 | : "audio is enabled\n" |
1149 | : "audio is enabled\n" |
1102 | . "frequency (Hz): $freq\n" |
1150 | . "frequency (Hz): $freq\n" |
1103 | . "channels: $chans"; |
1151 | . "channels: $chans\n" |
|
|
1152 | . "chunk decoders available: " . (join ", ", DC::MixChunk::decoders) . "\n" |
|
|
1153 | . "music decoders available: " . (join ", ", DC::MixMusic::decoders); |
1104 | |
1154 | |
1105 | $AUDIO_INFO->set_text ($text); |
1155 | $AUDIO_INFO->set_text ($text); |
1106 | } |
1156 | } |
1107 | |
1157 | |
1108 | sub audio_setup { |
1158 | sub audio_setup { |
… | |
… | |
1137 | ); |
1187 | ); |
1138 | |
1188 | |
1139 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Background Music"); |
1189 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Background Music"); |
1140 | $table->add_at (1, $row, new DC::UI::CheckBox |
1190 | $table->add_at (1, $row, new DC::UI::CheckBox |
1141 | expand => 1, state => $CFG->{bgm_enable}, |
1191 | expand => 1, state => $CFG->{bgm_enable}, |
1142 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", |
1192 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played. Needs server reconnect to take effect.", |
1143 | on_changed => sub { |
1193 | on_changed => sub { |
1144 | $CFG->{bgm_enable} = $_[1]; |
1194 | $CFG->{bgm_enable} = $_[1]; |
1145 | $CONN->update_fx_want if $CONN; |
1195 | $CONN->update_fx_want if $CONN; |
1146 | audio_music_push; |
1196 | audio_music_push; |
1147 | 1 |
1197 | 1 |
… | |
… | |
1248 | } |
1298 | } |
1249 | |
1299 | |
1250 | sub make_gauge_window { |
1300 | sub make_gauge_window { |
1251 | my $gh = int $HEIGHT * $CFG->{gauge_size}; |
1301 | my $gh = int $HEIGHT * $CFG->{gauge_size}; |
1252 | |
1302 | |
1253 | my $win = new DC::UI::Frame ( |
1303 | $GAUGES->{win} = my $win = new DC::UI::Frame ( |
1254 | force_x => 0, |
1304 | force_x => 0, |
1255 | force_y => "max", |
1305 | force_y => "max", |
1256 | force_w => $WIDTH, |
1306 | force_w => $WIDTH, |
1257 | force_h => $gh, |
1307 | force_h => $gh, |
1258 | ); |
1308 | ); |
… | |
… | |
1274 | (new DC::UI::Empty expand => 1), |
1324 | (new DC::UI::Empty expand => 1), |
1275 | (my $hb = new DC::UI::HBox), |
1325 | (my $hb = new DC::UI::HBox), |
1276 | ], |
1326 | ], |
1277 | ); |
1327 | ); |
1278 | |
1328 | |
1279 | $hb->add (my $hg = new DC::UI::Gauge type => 'hp', tooltip => "#stat_health"); |
1329 | $hb->add ($GAUGES->{hp} = new DC::UI::Gauge type => 'hp', tooltip => "#stat_health"); |
1280 | $hb->add (my $mg = new DC::UI::Gauge type => 'mana', tooltip => "#stat_mana"); |
1330 | $hb->add ($GAUGES->{mana} = new DC::UI::Gauge type => 'mana', tooltip => "#stat_mana"); |
1281 | $hb->add (my $gg = new DC::UI::Gauge type => 'grace', tooltip => "#stat_grace"); |
1331 | $hb->add ($GAUGES->{grace} = new DC::UI::Gauge type => 'grace', tooltip => "#stat_grace"); |
1282 | $hb->add (my $fg = new DC::UI::Gauge type => 'food', tooltip => "#stat_food"); |
1332 | $hb->add ($GAUGES->{food} = new DC::UI::Gauge type => 'food', tooltip => "#stat_food"); |
1283 | |
|
|
1284 | $vbox->add (my $exp = new DC::UI::Label align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp"); |
|
|
1285 | $vbox->add (my $prg = new DC::UI::ExperienceProgress); |
|
|
1286 | $vbox->add (my $sklprg = new DC::UI::ExperienceProgress); |
|
|
1287 | $vbox->add (my $rng = new DC::UI::Label align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged"); |
|
|
1288 | |
|
|
1289 | $GAUGES = { |
|
|
1290 | exp => $exp, prg => $prg, sklprg => $sklprg, |
|
|
1291 | win => $win, range => $rng, |
|
|
1292 | hp => $hg, mana => $mg, grace => $gg, food => $fg, |
|
|
1293 | }; |
|
|
1294 | |
1333 | |
1295 | &set_gauge_window_fontsize; |
1334 | &set_gauge_window_fontsize; |
1296 | |
1335 | |
1297 | $win |
1336 | $win |
|
|
1337 | } |
|
|
1338 | |
|
|
1339 | our $BW_WATCHER; |
|
|
1340 | |
|
|
1341 | sub debug_toggle($) { |
|
|
1342 | $DELIANTRA_DEBUG ^= $_[0]; |
|
|
1343 | |
|
|
1344 | if ($DELIANTRA_DEBUG & 16) { |
|
|
1345 | $BW_WATCHER = EV::periodic 0, 1, 0, sub { |
|
|
1346 | return unless $CONN; |
|
|
1347 | debug sprintf "%.2gKB/s", $CONN->{octets_in} / 1e3; |
|
|
1348 | $CONN->{octets_in} = 0; |
|
|
1349 | }; |
|
|
1350 | } else { |
|
|
1351 | undef $BW_WATCHER; |
|
|
1352 | } |
|
|
1353 | |
1298 | } |
1354 | } |
1299 | |
1355 | |
1300 | sub debug_setup { |
1356 | sub debug_setup { |
1301 | my $table = new DC::UI::Table; |
1357 | my $table = new DC::UI::Table; |
1302 | |
1358 | |
1303 | $table->add_at (0, 0, new DC::UI::Label text => "Widget Borders"); |
1359 | $table->add_at (0, 0, new DC::UI::Label text => "Widget Borders"); |
1304 | $table->add_at (1, 0, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 1; 0 }); |
1360 | $table->add_at (1, 0, new DC::UI::CheckBox on_changed => sub { debug_toggle 1; 0 }); |
1305 | $table->add_at (0, 1, new DC::UI::Label text => "Tooltip Widget Info"); |
1361 | $table->add_at (0, 1, new DC::UI::Label text => "Tooltip Widget Info"); |
1306 | $table->add_at (1, 1, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2; 0 }); |
1362 | $table->add_at (1, 1, new DC::UI::CheckBox on_changed => sub { debug_toggle 2; 0 }); |
1307 | $table->add_at (0, 2, new DC::UI::Label text => "Show FPS"); |
1363 | $table->add_at (0, 2, new DC::UI::Label text => "Show FPS"); |
1308 | $table->add_at (1, 2, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4; 0 }); |
1364 | $table->add_at (1, 2, new DC::UI::CheckBox on_changed => sub { debug_toggle 4; 0 }); |
1309 | $table->add_at (0, 3, new DC::UI::Label text => "Suppress Tooltips"); |
1365 | $table->add_at (0, 3, new DC::UI::Label text => "Suppress Tooltips"); |
1310 | $table->add_at (1, 3, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 }); |
1366 | $table->add_at (1, 3, new DC::UI::CheckBox on_changed => sub { debug_toggle 8; 0 }); |
|
|
1367 | $table->add_at (0, 4, new DC::UI::Label text => "Show Bandwidth"); |
|
|
1368 | $table->add_at (1, 4, new DC::UI::CheckBox on_changed => sub { debug_toggle 16; 0 }); |
|
|
1369 | |
1311 | $table->add_at (0, 4, new DC::UI::Button text => "die on click(tm)", on_activate => sub { &DC::debug() } ); |
1370 | $table->add_at (0, 6, new DC::UI::Button text => "die on click(tm)", on_activate => sub { &DC::debug() } ); |
1312 | |
|
|
1313 | $table->add_at (0, 5, new DC::UI::TextEdit text => "line1\0152\0153\nµikachu\nづx゙つ゛");#d# |
1371 | $table->add_at (0, 7, new DC::UI::TextEdit text => "line1\0152\0153\nµikachu\nづx゙つ゛");#d# |
1314 | |
1372 | |
1315 | $table->add_at (7,7, my $t = new DC::UI::Table expand => 0); |
1373 | $table->add_at (7,7, my $t = new DC::UI::Table expand => 0); |
1316 | $t->add_at (0,0, new DC::UI::Label text => "a a", c_rowspan => 1, c_colspan => 2); |
1374 | $t->add_at (0,0, new DC::UI::Label text => "a a", c_rowspan => 1, c_colspan => 2); |
1317 | $t->add_at (2,0, new DC::UI::Label text => "b\nb", c_rowspan => 2, c_colspan => 1, ellipsise => 0 ); |
1375 | $t->add_at (2,0, new DC::UI::Label text => "b\nb", c_rowspan => 2, c_colspan => 1, ellipsise => 0 ); |
1318 | $t->add_at (1,2, new DC::UI::Label text => "c c", c_rowspan => 1, c_colspan => 2); |
1376 | $t->add_at (1,2, new DC::UI::Label text => "c c", c_rowspan => 1, c_colspan => 2); |
… | |
… | |
1639 | child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]), |
1697 | child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]), |
1640 | ); |
1698 | ); |
1641 | |
1699 | |
1642 | $table->add_at (0, 4, new DC::UI::Label align => 1, text => "Username"); |
1700 | $table->add_at (0, 4, new DC::UI::Label align => 1, text => "Username"); |
1643 | $table->add_at (1, 4, new DC::UI::Entry |
1701 | $table->add_at (1, 4, new DC::UI::Entry |
1644 | text => $CFG->{profile}{default}{user}, |
1702 | text => $PROFILE->{user}, |
1645 | tooltip => "The name of your character on the server.", |
1703 | tooltip => "The name of your character on the server. The name is case-sensitive!", |
1646 | on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value; 1 } |
1704 | on_changed => sub { my ($self, $value) = @_; $PROFILE->{user} = $value; 1 } |
1647 | ); |
1705 | ); |
1648 | |
1706 | |
1649 | $table->add_at (0, 5, new DC::UI::Label align => 1, text => "Password"); |
1707 | $table->add_at (0, 5, new DC::UI::Label align => 1, text => "Password"); |
1650 | $table->add_at (1, 5, new DC::UI::Entry |
1708 | $table->add_at (1, 5, new DC::UI::Entry |
1651 | text => $CFG->{profile}{default}{password}, |
1709 | text => $PROFILE->{password}, |
1652 | hidden => 1, |
1710 | hidden => 1, |
1653 | tooltip => "The password for your character.", |
1711 | tooltip => "The password for your character.", |
1654 | on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value; 1 } |
1712 | on_changed => sub { my ($self, $value) = @_; $PROFILE->{password} = $value; 1 } |
1655 | ); |
1713 | ); |
1656 | |
1714 | |
1657 | $table->add_at (1, 11, $LOGIN_BUTTON = new DC::UI::Button |
1715 | $table->add_at (1, 11, $LOGIN_BUTTON = new DC::UI::Button |
1658 | expand => 1, |
1716 | expand => 1, |
1659 | text => "Login / Register", |
1717 | text => "Login / Register", |
… | |
… | |
1695 | $table->add_at (1, $row, my $vbox = new DC::UI::VBox); |
1753 | $table->add_at (1, $row, my $vbox = new DC::UI::VBox); |
1696 | |
1754 | |
1697 | $vbox->add ( |
1755 | $vbox->add ( |
1698 | $HOST_ENTRY = new DC::UI::Entry |
1756 | $HOST_ENTRY = new DC::UI::Entry |
1699 | expand => 1, |
1757 | expand => 1, |
1700 | text => $CFG->{profile}{default}{host}, |
1758 | text => $PROFILE->{host}, |
1701 | tooltip => "The hostname or ip address of the Deliantra server to connect to (e.g. <b>gameserver.deliantra.net</b>)", |
1759 | tooltip => "The hostname or ip address of the Deliantra server to connect to (e.g. <b>gameserver.deliantra.net</b>)", |
1702 | on_changed => sub { |
1760 | on_changed => sub { |
1703 | my ($self, $value) = @_; |
1761 | my ($self, $value) = @_; |
1704 | $CFG->{profile}{default}{host} = $value; |
1762 | $PROFILE->{host} = $value; |
1705 | 1 |
1763 | 1 |
1706 | } |
1764 | } |
1707 | ); |
1765 | ); |
1708 | |
1766 | |
1709 | if (0) { #d# disabled |
1767 | if (0) { #d# disabled |
… | |
… | |
1752 | |
1810 | |
1753 | my $row = 0; |
1811 | my $row = 0; |
1754 | |
1812 | |
1755 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Tip of the day"); |
1813 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Tip of the day"); |
1756 | $table->add_at (1, $row++, new DC::UI::CheckBox |
1814 | $table->add_at (1, $row++, new DC::UI::CheckBox |
|
|
1815 | c_colspan => 2, |
1757 | state => $CFG->{show_tips}, |
1816 | state => $CFG->{show_tips}, |
1758 | tooltip => "Show the <b>Tip of the day</b> window at startup?", |
1817 | tooltip => "Show the <b>Tip of the day</b> window at startup?", |
1759 | on_changed => sub { |
1818 | on_changed => sub { |
1760 | my ($self, $value) = @_; |
1819 | my ($self, $value) = @_; |
1761 | $CFG->{show_tips} = $value; |
1820 | $CFG->{show_tips} = $value; |
… | |
… | |
1763 | } |
1822 | } |
1764 | ); |
1823 | ); |
1765 | |
1824 | |
1766 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Message Window Size"); |
1825 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Message Window Size"); |
1767 | $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry |
1826 | $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry |
|
|
1827 | c_colspan => 2, |
1768 | text => $CFG->{logview_max_par}, |
1828 | text => $CFG->{logview_max_par}, |
1769 | tooltip => "This is maximum number of messages remembered in the <b>Message</b> window. If the server " |
1829 | tooltip => "This is maximum number of messages remembered in the <b>Message</b> window. If the server " |
1770 | . "sends more messages than this number, older messages get removed to save memory and " |
1830 | . "sends more messages than this number, older messages get removed to save memory and " |
1771 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
1831 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
1772 | on_changed => sub { |
1832 | on_changed => sub { |
… | |
… | |
1774 | $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); |
1834 | $MESSAGE_DIST->set_max_par ($CFG->{logview_max_par} = $value*1); |
1775 | 0 |
1835 | 0 |
1776 | }, |
1836 | }, |
1777 | ); |
1837 | ); |
1778 | |
1838 | |
|
|
1839 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Config Autosave"); |
|
|
1840 | $table->add_at (1, $row, new DC::UI::CheckBox |
|
|
1841 | state => $CFG->{config_autosave}, |
|
|
1842 | tooltip => "Normally, configuration settings and the user interface layout " |
|
|
1843 | . "are saved on client exit. You can disable this behaviour by " |
|
|
1844 | . "unchecking this checkbox.", |
|
|
1845 | on_changed => sub { |
|
|
1846 | my ($self, $value) = @_; |
|
|
1847 | $CFG->{config_autosave} = $value; |
|
|
1848 | 0 |
|
|
1849 | } |
|
|
1850 | ); |
|
|
1851 | $table->add_at (2, $row++, new DC::UI::Button |
|
|
1852 | text => "Save Now", |
|
|
1853 | tooltip => "Use this to manually save configuration and UI layout when " |
|
|
1854 | . "autosave is disabled.", |
|
|
1855 | on_activate => sub { |
|
|
1856 | DC::write_cfg; |
|
|
1857 | 0 |
|
|
1858 | } |
|
|
1859 | ); |
|
|
1860 | |
1779 | $table |
1861 | $table |
1780 | } |
1862 | } |
1781 | |
1863 | |
1782 | sub autopickup_setup { |
1864 | sub autopickup_setup { |
1783 | my $r = new DC::UI::ScrolledWindow ( |
1865 | my $r = new DC::UI::ScrolledWindow ( |
… | |
… | |
1789 | col_expand => [0, 1, 0, 1], |
1871 | col_expand => [0, 1, 0, 1], |
1790 | ); |
1872 | ); |
1791 | |
1873 | |
1792 | for ( |
1874 | for ( |
1793 | ["General", 0, 0, |
1875 | ["General", 0, 0, |
1794 | ["Enable autopickup" => PICKUP_NEWMODE, \$PICKUP_ENABLE], |
|
|
1795 | ["Inhibit autopickup" => PICKUP_INHIBIT], |
1876 | # ["Inhibit autopickup" => PICKUP_INHIBIT], |
1796 | ["Stop before pickup" => PICKUP_STOP], |
1877 | ["Stop before pickup" => PICKUP_STOP], |
1797 | ["Debug autopickup" => PICKUP_DEBUG], |
1878 | ["Debug autopickup" => PICKUP_DEBUG], |
1798 | ], |
1879 | ], |
1799 | ["Weapons", 0, 6, |
1880 | ["Weapons", 0, 6, |
1800 | ["All weapons" => PICKUP_ALLWEAPON], |
1881 | ["All weapons" => PICKUP_ALLWEAPON], |
… | |
… | |
1848 | $::CFG->{pickup} |= $mask; |
1929 | $::CFG->{pickup} |= $mask; |
1849 | } else { |
1930 | } else { |
1850 | $::CFG->{pickup} &= ~$mask; |
1931 | $::CFG->{pickup} &= ~$mask; |
1851 | } |
1932 | } |
1852 | |
1933 | |
1853 | $::CONN->send_command ("pickup $::CFG->{pickup}") |
1934 | $::CONN->send_pickup ($::CFG->{pickup}) |
1854 | if defined $::CONN; |
1935 | if defined $::CONN; |
1855 | |
1936 | |
1856 | 0 |
1937 | 0 |
1857 | }); |
1938 | }); |
1858 | |
1939 | |
… | |
… | |
1875 | }); |
1956 | }); |
1876 | |
1957 | |
1877 | $table->add_at (3, 18, new DC::UI::Button |
1958 | $table->add_at (3, 18, new DC::UI::Button |
1878 | text => "set", |
1959 | text => "set", |
1879 | on_activate => sub { |
1960 | on_activate => sub { |
1880 | $::CONN->send_command ("pickup $::CFG->{pickup}") |
1961 | $::CONN->send_pickup ($::CFG->{pickup}) |
1881 | if defined $::CONN; |
1962 | if defined $::CONN; |
1882 | 0 |
1963 | 0 |
1883 | }); |
1964 | }); |
1884 | |
1965 | |
1885 | $r |
1966 | $r |
1886 | } |
1967 | } |
1887 | |
1968 | |
1888 | my %SORT_ORDER = ( |
1969 | my %SORT_ORDER = ( |
1889 | type => sub { |
1970 | type => sub { |
|
|
1971 | use sort 'stable'; |
1890 | sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ |
1972 | sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ |
1891 | }, |
1973 | }, |
1892 | mtime => sub { |
1974 | mtime => sub { |
|
|
1975 | use sort 'stable'; |
1893 | my $NOW = time; |
1976 | my $NOW = time; |
1894 | sort { |
1977 | sort { |
1895 | my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; |
1978 | my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; |
1896 | my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; |
1979 | my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; |
1897 | |
1980 | |
1898 | ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED) |
1981 | ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED) |
1899 | or $btime <=> $atime |
1982 | or $btime <=> $atime |
1900 | or $a->{type} <=> $b->{type} |
1983 | or $a->{type} <=> $b->{type} |
1901 | } @_ |
1984 | } @_ |
1902 | }, |
1985 | }, |
1903 | weight => sub { sort { |
1986 | weight => sub { |
|
|
1987 | use sort 'stable'; |
|
|
1988 | sort { |
1904 | $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) |
1989 | $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) |
1905 | or $a->{type} <=> $b->{type} |
1990 | or $a->{type} <=> $b->{type} |
1906 | } @_ }, |
1991 | } @_ |
|
|
1992 | }, |
1907 | ); |
1993 | ); |
1908 | |
1994 | |
1909 | sub inventory_widget { |
1995 | sub inventory_widget { |
1910 | my $hb = new DC::UI::HBox homogeneous => 1; |
1996 | my $hb = new DC::UI::HBox homogeneous => 1; |
1911 | |
1997 | |
… | |
… | |
1998 | $PL_NOTEBOOK->set_current_page ($widget); |
2084 | $PL_NOTEBOOK->set_current_page ($widget); |
1999 | $PL_WINDOW->show; |
2085 | $PL_WINDOW->show; |
2000 | } |
2086 | } |
2001 | } |
2087 | } |
2002 | |
2088 | |
2003 | sub player_window { |
2089 | sub make_playerbook { |
2004 | my $plwin = $PL_WINDOW = new DC::UI::Toplevel |
2090 | my $plwin = $PL_WINDOW = new DC::UI::Toplevel |
2005 | x => "center", |
2091 | x => "center", |
2006 | y => "center", |
2092 | y => "center", |
2007 | force_w => $WIDTH * 9/10, |
2093 | force_w => $WIDTH * 9/10, |
2008 | force_h => $HEIGHT * 9/10, |
2094 | force_h => $HEIGHT * 9/10, |
… | |
… | |
2042 | "License, Author and Source info for media sent by the server."); |
2128 | "License, Author and Source info for media sent by the server."); |
2043 | |
2129 | |
2044 | $ntb->set_current_page ($INVENTORY_PAGE); |
2130 | $ntb->set_current_page ($INVENTORY_PAGE); |
2045 | |
2131 | |
2046 | $plwin->add ($ntb); |
2132 | $plwin->add ($ntb); |
2047 | $plwin |
|
|
2048 | } |
2133 | } |
2049 | |
2134 | |
2050 | sub keyboard_setup { |
2135 | sub keyboard_setup { |
2051 | DC::Macro::keyboard_setup |
2136 | DC::Macro::keyboard_setup |
2052 | } |
2137 | } |
2053 | |
2138 | |
2054 | sub help_window { |
2139 | sub make_help_window { |
2055 | my $win = new DC::UI::Toplevel |
2140 | my $win = new DC::UI::Toplevel |
2056 | x => 'center', |
2141 | x => 'center', |
2057 | y => 'center', |
2142 | y => 'center', |
2058 | z => 4, |
2143 | z => 4, |
2059 | name => 'doc_browser', |
2144 | name => 'doc_browser', |
… | |
… | |
2148 | |
2233 | |
2149 | $load_node->((DC::Pod::find @path)[0]); |
2234 | $load_node->((DC::Pod::find @path)[0]); |
2150 | $win->show; |
2235 | $win->show; |
2151 | }; |
2236 | }; |
2152 | |
2237 | |
2153 | $win |
2238 | $HELP_WINDOW = $win; |
2154 | } |
|
|
2155 | |
|
|
2156 | sub open_string_query { |
|
|
2157 | my ($title, $cb, $txt, $tooltip) = @_; |
|
|
2158 | my $dialog = new DC::UI::Toplevel |
|
|
2159 | x => "center", |
|
|
2160 | y => "center", |
|
|
2161 | z => 50, |
|
|
2162 | force_w => $WIDTH * 4/5, |
|
|
2163 | title => $title; |
|
|
2164 | |
|
|
2165 | $dialog->add ( |
|
|
2166 | my $e = new DC::UI::Entry |
|
|
2167 | on_activate => sub { $cb->(@_); $dialog->hide; 0 }, |
|
|
2168 | on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 }, |
|
|
2169 | tooltip => $tooltip |
|
|
2170 | ); |
|
|
2171 | |
|
|
2172 | $e->grab_focus; |
|
|
2173 | $e->set_text ($txt) if $txt; |
|
|
2174 | $dialog->show; |
|
|
2175 | } |
2239 | } |
2176 | |
2240 | |
2177 | sub open_quit_dialog { |
2241 | sub open_quit_dialog { |
2178 | unless ($QUIT_DIALOG) { |
2242 | unless ($QUIT_DIALOG) { |
2179 | $QUIT_DIALOG = new DC::UI::Toplevel |
2243 | $QUIT_DIALOG = new DC::UI::Toplevel |
… | |
… | |
2212 | |
2276 | |
2213 | $QUIT_DIALOG->show; |
2277 | $QUIT_DIALOG->show; |
2214 | $QUIT_DIALOG->grab_focus; |
2278 | $QUIT_DIALOG->grab_focus; |
2215 | } |
2279 | } |
2216 | |
2280 | |
|
|
2281 | sub make_menubar { |
|
|
2282 | $MENUFRAME = new DC::UI::Toplevel |
|
|
2283 | border => 0, |
|
|
2284 | force_x => 0, |
|
|
2285 | force_y => 0, |
|
|
2286 | force_w => $::WIDTH, |
|
|
2287 | child => ($MENUBAR = new DC::UI::HBox), |
|
|
2288 | ; |
|
|
2289 | |
|
|
2290 | $MENUBAR->add ($BUTTONBAR = new DC::UI::Buttonbar); |
|
|
2291 | |
|
|
2292 | # 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 |
|
|
2293 | make_gauge_window->show; |
|
|
2294 | |
|
|
2295 | # $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, |
|
|
2296 | # tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
|
|
2297 | |
|
|
2298 | make_playerbook; |
|
|
2299 | |
|
|
2300 | $MENUPOPUP = DC::UI::Menu->new (items => [ |
|
|
2301 | ["Setup…\tF9" , sub { $SETUP_DIALOG->toggle_visibility }], |
|
|
2302 | ["Playerbook…\tTab" , sub { $PL_WINDOW ->toggle_visibility }], |
|
|
2303 | ["…Statistics\tF2" , sub { toggle_player_page ($::STATS_PAGE) }], |
|
|
2304 | ["…Skills\tF3" , sub { toggle_player_page ($::SKILL_PAGE) }], |
|
|
2305 | ["…Spells\tF4" , sub { toggle_player_page ($::SPELL_PAGE) }], |
|
|
2306 | ["…Inventory\tF5" , sub { toggle_player_page ($::INVENTORY_PAGE) }], |
|
|
2307 | ["Help Browser…\tF1" , sub { $HELP_WINDOW ->toggle_visibility }], |
|
|
2308 | ["Quit…" , sub { |
|
|
2309 | if ($CONN) { |
|
|
2310 | open_quit_dialog; |
|
|
2311 | } else { |
|
|
2312 | EV::unloop EV::UNLOOP_ALL; |
|
|
2313 | } |
|
|
2314 | }], |
|
|
2315 | ]); |
|
|
2316 | |
|
|
2317 | $BUTTONBAR->add (new DC::UI::Button text => "Menu…", |
|
|
2318 | tooltip => "Shows the main menu", |
|
|
2319 | on_button_down => sub { |
|
|
2320 | my ($self, $ev) = @_; |
|
|
2321 | local $ev->{x} = 0; |
|
|
2322 | local $ev->{y} = 0; |
|
|
2323 | $MENUPOPUP->popup ($ev); |
|
|
2324 | }, |
|
|
2325 | ); |
|
|
2326 | |
|
|
2327 | $MENUBAR->add ($GAUGES->{exp} = new DC::UI::ExperienceProgress |
|
|
2328 | padding_x => 6, |
|
|
2329 | padding_y => 3, |
|
|
2330 | tooltip => "This progress bar shows your overall experience and your progress towards the next character level.", |
|
|
2331 | template => " Exp: 888,888,888,888 (lvl 188) ", |
|
|
2332 | ); |
|
|
2333 | |
|
|
2334 | $MENUBAR->add ($PICKUP_ENABLE = new DC::UI::CheckBox # checkbox bad, button better? |
|
|
2335 | tooltip => "Automatic Pickup Enable - when this checkbox is enabled, then your character " |
|
|
2336 | . "will automatically pick up items as defined by your item pickup settings " |
|
|
2337 | . "in the playerbook. Often (e.g. in apartments) you want to temporarily " |
|
|
2338 | . "disable autopickup by disabling this checkbox.", |
|
|
2339 | state => $CFG->{pickup} & PICKUP_INHIBIT ? 0 : 1, |
|
|
2340 | on_changed => sub { |
|
|
2341 | my ($self, $value) = @_; |
|
|
2342 | $CFG->{pickup} &= ~PICKUP_INHIBIT; |
|
|
2343 | $CFG->{pickup} |= PICKUP_INHIBIT unless $_[1]; |
|
|
2344 | $CONN->send_pickup ($CFG->{pickup}) |
|
|
2345 | if $CONN; |
|
|
2346 | }, |
|
|
2347 | ); |
|
|
2348 | |
|
|
2349 | $MENUBAR->add ($GAUGES->{skillexp} = new DC::UI::ExperienceProgress |
|
|
2350 | c_rescale => 1, |
|
|
2351 | padding_x => 6, |
|
|
2352 | padding_y => 3, |
|
|
2353 | force_w => $::WIDTH * 0.2, |
|
|
2354 | tooltip => "This progress bar shows the currently used skill and your progress towards the next skill level of that skill.", |
|
|
2355 | template => "two handed weapons 99%", |
|
|
2356 | ); |
|
|
2357 | |
|
|
2358 | $MENUBAR->add ($GAUGES->{range} = new DC::UI::Label |
|
|
2359 | expand => 1, |
|
|
2360 | align => 1, can_hover => 1, can_events => 1, |
|
|
2361 | text => "Range and Combat Slots", |
|
|
2362 | tooltip => "#stat_ranged", |
|
|
2363 | ); |
|
|
2364 | |
|
|
2365 | $MENUFRAME->show; |
|
|
2366 | } |
|
|
2367 | |
|
|
2368 | sub open_string_query { |
|
|
2369 | my ($title, $cb, $txt, $tooltip) = @_; |
|
|
2370 | my $dialog = new DC::UI::Toplevel |
|
|
2371 | x => "center", |
|
|
2372 | y => "center", |
|
|
2373 | z => 50, |
|
|
2374 | force_w => $WIDTH * 4/5, |
|
|
2375 | title => $title; |
|
|
2376 | |
|
|
2377 | $dialog->add ( |
|
|
2378 | my $e = new DC::UI::Entry |
|
|
2379 | on_activate => sub { $cb->(@_); $dialog->hide; 0 }, |
|
|
2380 | on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 }, |
|
|
2381 | tooltip => $tooltip |
|
|
2382 | ); |
|
|
2383 | |
|
|
2384 | $e->grab_focus; |
|
|
2385 | $e->set_text ($txt) if $txt; |
|
|
2386 | $dialog->show; |
|
|
2387 | } |
|
|
2388 | |
2217 | sub show_tip_of_the_day { |
2389 | sub show_tip_of_the_day { |
2218 | # find all tips |
2390 | # find all tips |
2219 | my @tod = DC::Pod::find tip_of_the_day => "*"; |
2391 | my @tod = DC::Pod::find tip_of_the_day => "*"; |
2220 | |
2392 | |
2221 | DC::DB::get state => "tip_of_the_day", sub { |
2393 | DC::DB::get state => "tip_of_the_day", sub { |
… | |
… | |
2339 | |
2511 | |
2340 | $DEBUG_STATUS = new DC::UI::Label |
2512 | $DEBUG_STATUS = new DC::UI::Label |
2341 | padding => 0, |
2513 | padding => 0, |
2342 | z => 100, |
2514 | z => 100, |
2343 | force_x => "max", |
2515 | force_x => "max", |
2344 | force_y => 0; |
2516 | force_y => 20; |
2345 | $DEBUG_STATUS->show; |
2517 | $DEBUG_STATUS->show; |
2346 | |
2518 | |
2347 | $STATUSBOX = new DC::UI::Statusbox; |
2519 | $STATUSBOX = new DC::UI::Statusbox; |
2348 | |
2520 | |
2349 | $MODBOX = new DC::UI::Label |
2521 | $MODBOX = new DC::UI::Label |
… | |
… | |
2360 | |
2532 | |
2361 | (new DC::UI::Frame |
2533 | (new DC::UI::Frame |
2362 | bg => [0, 0, 0, 0.4], |
2534 | bg => [0, 0, 0, 0.4], |
2363 | force_x => 0, |
2535 | force_x => 0, |
2364 | force_y => "max", |
2536 | force_y => "max", |
2365 | child => (my $LR = new DC::UI::VBox), |
2537 | child => (my $LL = new DC::UI::VBox), |
2366 | )->show; |
2538 | )->show; |
2367 | |
2539 | |
2368 | $LR->add ($STATUSBOX); |
2540 | $LL->add ($STATUSBOX); |
2369 | $LR->add ($MODBOX); |
2541 | $LL->add ($MODBOX); |
2370 | $LR->add (new DC::UI::Label |
2542 | $LL->add (new DC::UI::Label |
2371 | align => 0, |
2543 | align => 0, |
2372 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode", |
2544 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode", |
2373 | fontsize => 0.5, |
2545 | fontsize => 0.5, |
2374 | fg => [1, 1, 0, 0.7], |
2546 | fg => [1, 1, 0, 0.7], |
2375 | ); |
2547 | ); |
2376 | |
2548 | |
2377 | DC::UI::Toplevel->new ( |
2549 | DC::UI::Toplevel->new ( |
2378 | title => "Minimap", |
2550 | title => "Minimap", |
2379 | name => "mapmap", |
2551 | name => "mapmap", |
2380 | x => 0, |
2552 | x => 0, |
2381 | y => $FONTSIZE + 8, |
2553 | y => $::FONTSIZE + 8,#d# hack to move messages window below the menubar |
2382 | border_bg => [1, 1, 1, 192/255], |
2554 | border_bg => [1, 1, 1, 192/255], |
2383 | bg => [1, 1, 1, 0], |
2555 | bg => [1, 1, 1, 0], |
2384 | child => ($MAPMAP = new DC::MapWidget::MapMap |
2556 | child => ($MAPMAP = new DC::MapWidget::MapMap |
2385 | tooltip => "<b>Minimap</b>. This will display an overview of the surrounding areas.", |
2557 | tooltip => "<b>Minimap</b>. This will display an overview of the surrounding areas.", |
2386 | ), |
2558 | ), |
… | |
… | |
2415 | $METASERVER = metaserver_dialog; |
2587 | $METASERVER = metaserver_dialog; |
2416 | # the name is changed to not conflict with the older name as users could have hidden it |
2588 | # the name is changed to not conflict with the older name as users could have hidden it |
2417 | $MESSAGE_WINDOW = new DC::UI::Dockbar |
2589 | $MESSAGE_WINDOW = new DC::UI::Dockbar |
2418 | name => "message_window2", |
2590 | name => "message_window2", |
2419 | title => 'Messages', |
2591 | title => 'Messages', |
|
|
2592 | y => $::FONTSIZE + 8,#d# hack to move messages window below the menubar |
2420 | force_w => $::WIDTH * 0.6, |
2593 | force_w => $::WIDTH * 0.6, |
2421 | force_h => $::HEIGHT * 0.25, |
2594 | force_h => $::HEIGHT * 0.25, |
2422 | ; |
2595 | ; |
2423 | |
2596 | |
2424 | $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; |
2597 | $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; |
… | |
… | |
2444 | . "After pressing the combo the binding will be saved automatically and the " |
2617 | . "After pressing the combo the binding will be saved automatically and the " |
2445 | . "binding editor closes"); |
2618 | . "binding editor closes"); |
2446 | $SETUP_NOTEBOOK->add_tab (Debug => debug_setup, |
2619 | $SETUP_NOTEBOOK->add_tab (Debug => debug_setup, |
2447 | "Some debuggin' options. Do not ask."); |
2620 | "Some debuggin' options. Do not ask."); |
2448 | |
2621 | |
2449 | $BUTTONBAR = new DC::UI::Buttonbar x => 0, y => 0, z => 200; # put on top |
2622 | make_help_window; |
|
|
2623 | make_menubar; |
2450 | |
2624 | |
2451 | $BUTTONBAR->add (new DC::UI::Flopper text => "Setup", other => $SETUP_DIALOG, |
|
|
2452 | tooltip => "Toggles a dialog where you can configure all aspects of this client."); |
|
|
2453 | |
|
|
2454 | # $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, |
|
|
2455 | # tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); |
|
|
2456 | |
|
|
2457 | 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 |
|
|
2458 | |
|
|
2459 | $BUTTONBAR->add (new DC::UI::Flopper text => "Playerbook", other => player_window, |
|
|
2460 | tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats."); |
|
|
2461 | |
|
|
2462 | $BUTTONBAR->add (new DC::UI::Button |
|
|
2463 | text => "Save Config", |
|
|
2464 | tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", |
|
|
2465 | on_activate => sub { |
|
|
2466 | $::CFG->{layout} = DC::UI::get_layout; |
|
|
2467 | DC::write_cfg; |
|
|
2468 | status "Configuration Saved"; |
|
|
2469 | 0 |
|
|
2470 | }, |
|
|
2471 | ); |
|
|
2472 | |
|
|
2473 | $BUTTONBAR->add (new DC::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, |
|
|
2474 | tooltip => "View Documentation"); |
|
|
2475 | |
|
|
2476 | $BUTTONBAR->add (new DC::UI::Button |
|
|
2477 | text => "Quit", |
|
|
2478 | tooltip => "Terminates the program", |
|
|
2479 | on_activate => sub { |
|
|
2480 | if ($CONN) { |
|
|
2481 | open_quit_dialog; |
|
|
2482 | } else { |
|
|
2483 | EV::unloop EV::UNLOOP_ALL; |
|
|
2484 | } |
|
|
2485 | 0 |
|
|
2486 | }, |
|
|
2487 | ); |
|
|
2488 | |
|
|
2489 | $BUTTONBAR->show; |
|
|
2490 | $SETUP_DIALOG->show; |
2625 | $SETUP_DIALOG->show; |
2491 | $MESSAGE_WINDOW->show; |
2626 | $MESSAGE_WINDOW->show; |
2492 | } |
2627 | } |
2493 | |
2628 | |
2494 | $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1, 1]); |
2629 | $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1, 1]); |
2495 | $MODE_SLIDER->emit (changed => $CFG->{sdl_mode}); |
2630 | $MODE_SLIDER->emit (changed => $CFG->{sdl_mode}); |
2496 | |
2631 | |
2497 | $CAVEAT_LABEL->set_text ("None :)"); |
2632 | $CAVEAT_LABEL->set_text ("None :)"); |
|
|
2633 | $CAVEAT_LABEL->set_text ("Apple/NVIDIA Texture bug (slow)") |
|
|
2634 | if $DC::OpenGL::APPLE_NVIDIA_BUG; |
2498 | $CAVEAT_LABEL->set_text ("Software Rendering (very slow)") |
2635 | $CAVEAT_LABEL->set_text ("Software Rendering (very slow)") |
2499 | unless DC::SDL_GL_GetAttribute DC::SDL_GL_ACCELERATED_VISUAL; |
2636 | unless DC::SDL_GL_GetAttribute DC::SDL_GL_ACCELERATED_VISUAL; |
2500 | |
2637 | |
2501 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
2638 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
2502 | } |
2639 | } |
… | |
… | |
2512 | my $animate_timer; |
2649 | my $animate_timer; |
2513 | |
2650 | |
2514 | my $fps = 9; |
2651 | my $fps = 9; |
2515 | |
2652 | |
2516 | sub force_refresh { |
2653 | sub force_refresh { |
2517 | if ($ENV{CFPLUS_DEBUG} & 4) { |
2654 | if ($DELIANTRA_DEBUG & 4) { |
2518 | $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; |
2655 | $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; |
2519 | debug sprintf "%3.2f", $fps; |
2656 | debug sprintf "%3.2f", $fps; |
2520 | } |
2657 | } |
2521 | |
2658 | |
2522 | undef $WANT_REFRESH; |
2659 | undef $WANT_REFRESH; |
… | |
… | |
2530 | my $want_refresh = EV::prepare_ns \&force_refresh; |
2667 | my $want_refresh = EV::prepare_ns \&force_refresh; |
2531 | |
2668 | |
2532 | my $input = EV::periodic 0, 1 / $MAX_FPS, undef, sub { |
2669 | my $input = EV::periodic 0, 1 / $MAX_FPS, undef, sub { |
2533 | $NOW = EV::now; |
2670 | $NOW = EV::now; |
2534 | |
2671 | |
2535 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
2672 | ($SDL_CB[$_->{type}] || sub { warn "unhandled event $_->{type}" })->($_) |
2536 | for DC::poll_events; |
2673 | for DC::poll_events; |
2537 | |
2674 | |
2538 | if (%animate_object) { |
2675 | if (%animate_object) { |
2539 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2676 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2540 | $WANT_REFRESH = 1; |
2677 | $WANT_REFRESH = 1; |
… | |
… | |
2552 | sub animation_stop { |
2689 | sub animation_stop { |
2553 | my ($widget) = @_; |
2690 | my ($widget) = @_; |
2554 | delete $animate_object{$widget}; |
2691 | delete $animate_object{$widget}; |
2555 | } |
2692 | } |
2556 | |
2693 | |
2557 | %SDL_CB = ( |
|
|
2558 | DC::SDL_QUIT => sub { |
2694 | $SDL_CB[DC::SDL_QUIT] = sub { |
2559 | crash "SDL_QUIT"; |
2695 | crash "SDL_QUIT"; |
2560 | EV::unloop EV::UNLOOP_ALL; |
2696 | EV::unloop EV::UNLOOP_ALL; |
2561 | }, |
2697 | }; |
2562 | DC::SDL_VIDEORESIZE => sub { |
2698 | $SDL_CB[DC::SDL_VIDEORESIZE] = sub { }; |
2563 | }, |
|
|
2564 | DC::SDL_VIDEOEXPOSE => sub { |
2699 | $SDL_CB[DC::SDL_VIDEOEXPOSE] = sub { |
2565 | DC::UI::full_refresh; |
2700 | DC::UI::full_refresh; |
2566 | }, |
2701 | }; |
2567 | DC::SDL_ACTIVEEVENT => sub { |
2702 | $SDL_CB[DC::SDL_ACTIVEEVENT] = sub { |
2568 | # not useful, as APPACTIVE includes only iconified state, not unmapped |
2703 | # not useful, as APPACTIVE includes only iconified state, not unmapped |
2569 | # printf "active %x %x %x\n", $_[0]{gain}, $_[0]{state}, DC::SDL_GetAppState;#d# |
2704 | # printf "active %x %x %x\n", $_[0]{gain}, $_[0]{state}, DC::SDL_GetAppState;#d# |
2570 | # printf "a %x\n", DC::SDL_GetAppState & DC::SDL_APPACTIVE;#d# |
2705 | # printf "a %x\n", DC::SDL_GetAppState & DC::SDL_APPACTIVE;#d# |
2571 | # printf "A\n" if $_[0]{state} & DC::SDL_APPACTIVE; |
2706 | # printf "A\n" if $_[0]{state} & DC::SDL_APPACTIVE; |
2572 | # printf "K\n" if $_[0]{state} & DC::SDL_APPINPUTFOCUS; |
2707 | # printf "K\n" if $_[0]{state} & DC::SDL_APPINPUTFOCUS; |
2573 | # printf "M\n" if $_[0]{state} & DC::SDL_APPMOUSEFOCUS; |
2708 | # printf "M\n" if $_[0]{state} & DC::SDL_APPMOUSEFOCUS; |
2574 | }, |
2709 | }; |
2575 | DC::SDL_KEYDOWN => sub { |
2710 | $SDL_CB[DC::SDL_KEYDOWN] = sub { |
2576 | if ($_[0]{mod} & DC::KMOD_ALT && $_[0]{sym} == 13) { |
2711 | if ($_[0]{mod} & DC::KMOD_ALT && $_[0]{sym} == 13) { |
2577 | # alt-enter |
2712 | # alt-enter |
2578 | video_shutdown; |
2713 | video_shutdown; |
2579 | $FULLSCREEN_ENABLE->toggle; |
2714 | $FULLSCREEN_ENABLE->toggle; |
2580 | video_init; |
2715 | video_init; |
2581 | } else { |
2716 | } else { |
2582 | &DC::UI::feed_sdl_key_down_event; |
2717 | &DC::UI::feed_sdl_key_down_event; |
2583 | } |
2718 | } |
2584 | update_modbox; |
2719 | update_modbox; |
2585 | }, |
2720 | }; |
2586 | DC::SDL_KEYUP => sub { |
2721 | $SDL_CB[DC::SDL_KEYUP] = sub { |
2587 | &DC::UI::feed_sdl_key_up_event; |
2722 | &DC::UI::feed_sdl_key_up_event; |
2588 | update_modbox; |
2723 | update_modbox; |
2589 | }, |
2724 | }; |
2590 | DC::SDL_MOUSEMOTION => \&DC::UI::feed_sdl_motion_event, |
2725 | $SDL_CB[DC::SDL_MOUSEMOTION] = \&DC::UI::feed_sdl_motion_event, |
2591 | DC::SDL_MOUSEBUTTONDOWN => \&DC::UI::feed_sdl_button_down_event, |
2726 | $SDL_CB[DC::SDL_MOUSEBUTTONDOWN] = \&DC::UI::feed_sdl_button_down_event, |
2592 | DC::SDL_MOUSEBUTTONUP => \&DC::UI::feed_sdl_button_up_event, |
2727 | $SDL_CB[DC::SDL_MOUSEBUTTONUP] = \&DC::UI::feed_sdl_button_up_event, |
2593 | DC::SDL_USEREVENT => sub { |
2728 | $SDL_CB[DC::SDL_USEREVENT] = sub { |
2594 | if ($_[0]{code} == 1) { |
2729 | if ($_[0]{code} == 1) { |
2595 | audio_channel_finished $_[0]{data1}; |
2730 | audio_channel_finished $_[0]{data1}; |
2596 | } elsif ($_[0]{code} == 0) { |
2731 | } elsif ($_[0]{code} == 0) { |
2597 | audio_music_finished; |
2732 | audio_music_finished; |
2598 | } |
|
|
2599 | }, |
2733 | } |
2600 | ); |
2734 | }; |
2601 | |
2735 | |
2602 | ############################################################################# |
2736 | ############################################################################# |
2603 | |
2737 | |
2604 | $SIG{INT} = $SIG{TERM} = sub { |
2738 | $SIG{INT} = $SIG{TERM} = sub { |
2605 | EV::unloop; |
2739 | EV::unloop; |
… | |
… | |
2631 | DC::DB::open_db; |
2765 | DC::DB::open_db; |
2632 | |
2766 | |
2633 | DC::UI::set_layout ($::CFG->{layout}); |
2767 | DC::UI::set_layout ($::CFG->{layout}); |
2634 | |
2768 | |
2635 | my %DEF_CFG = ( |
2769 | my %DEF_CFG = ( |
|
|
2770 | config_autosave => 1, |
2636 | sdl_mode => undef, |
2771 | sdl_mode => undef, |
2637 | fullscreen => 1, |
2772 | fullscreen => 1, |
2638 | fast => 0, |
2773 | fast => 0, |
2639 | force_opengl11 => undef, |
2774 | force_opengl11 => undef, |
2640 | disable_alpha => 0, |
2775 | disable_alpha => 0, |
2641 | smooth_movement => 1, |
2776 | smooth_movement => 1, |
|
|
2777 | smooth_transitions => 1, |
2642 | texture_compression => 1, |
2778 | texture_compression => 1, |
2643 | map_scale => 1, |
2779 | map_scale => 1, |
2644 | fow_enable => 1, |
2780 | fow_enable => 1, |
2645 | fow_intensity => 0, |
2781 | fow_intensity => 0, |
|
|
2782 | fow_texture => 0, |
2646 | map_smoothing => 1, |
2783 | map_smoothing => 1, |
2647 | gui_fontsize => 1, |
2784 | gui_fontsize => 1, |
2648 | log_fontsize => 0.7, |
2785 | log_fontsize => 0.7, |
2649 | gauge_fontsize => 1, |
2786 | gauge_fontsize => 1, |
2650 | gauge_size => 0.35, |
2787 | gauge_size => 0.35, |
… | |
… | |
2658 | effects_enable => 1, |
2795 | effects_enable => 1, |
2659 | effects_volume => 1, |
2796 | effects_volume => 1, |
2660 | bgm_enable => 1, |
2797 | bgm_enable => 1, |
2661 | bgm_volume => 0.5, |
2798 | bgm_volume => 0.5, |
2662 | output_rate => "", |
2799 | output_rate => "", |
2663 | pickup => 0, |
2800 | pickup => PICKUP_SPELLBOOK | PICKUP_SKILLSCROLL | PICKUP_VALUABLES, |
2664 | inv_sort => "mtime", |
2801 | inv_sort => "mtime", |
2665 | default => "profile", # default profile |
2802 | default => "profile", # default profile |
2666 | show_tips => 1, |
2803 | show_tips => 1, |
2667 | logview_max_par => 1000, |
2804 | logview_max_par => 1000, |
2668 | shift_fire_stop => 0, |
2805 | shift_fire_stop => 0, |
2669 | uitheme => "wood", |
2806 | uitheme => "wood", |
2670 | ); |
2807 | map_shift_x => -24, # arbitrary |
|
|
2808 | map_shift_y => +24, # arbitrary |
2671 | |
2809 | ); |
|
|
2810 | |
2672 | while (my ($k, $v) = each %DEF_CFG) { |
2811 | while (my ($k, $v) = each %DEF_CFG) { |
2673 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2812 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2674 | } |
2813 | } |
2675 | |
2814 | |
2676 | $CFG->{profile}{default}{host} ||= "gameserver.deliantra.net"; |
2815 | my @args = @ARGV; |
|
|
2816 | |
|
|
2817 | my $profile = 'default'; |
|
|
2818 | |
|
|
2819 | for (my $i = 0; $i < @args; $i++) { |
|
|
2820 | if ($args[$i] =~ /^--?profile$/) { |
|
|
2821 | $profile = $args[$i + 1]; |
|
|
2822 | splice @args, $i, 2, (); |
|
|
2823 | $i = 0; |
|
|
2824 | } elsif ($args[$i] =~ /^--?h/) { |
|
|
2825 | print STDERR "Usage: $0 [--profile name] [host [user [password]]]\n"; |
|
|
2826 | exit 0; |
|
|
2827 | } |
|
|
2828 | } |
|
|
2829 | |
|
|
2830 | $CFG->{profile}{$profile} ||= {}; |
2677 | $PROFILE = $CFG->{profile}{default}; |
2831 | $PROFILE = $CFG->{profile}{$profile}; |
|
|
2832 | $PROFILE->{host} ||= "gameserver.deliantra.net"; |
|
|
2833 | |
|
|
2834 | $PROFILE->{host} = $args[0] if @args > 0; |
|
|
2835 | $PROFILE->{user} = $args[1] if @args > 1; |
|
|
2836 | $PROFILE->{password} = $args[2] if @args > 2; |
2678 | |
2837 | |
2679 | # convert old bindings (only default profile matters) |
2838 | # convert old bindings (only default profile matters) |
2680 | if (my $bindings = delete $PROFILE->{bindings}) { |
2839 | if (my $bindings = delete $PROFILE->{bindings}) { |
2681 | while (my ($mod, $syms) = each %$bindings) { |
2840 | while (my ($mod, $syms) = each %$bindings) { |
2682 | while (my ($sym, $cmds) = each %$syms) { |
2841 | while (my ($sym, $cmds) = each %$syms) { |
… | |
… | |
2688 | } |
2847 | } |
2689 | } |
2848 | } |
2690 | |
2849 | |
2691 | sdl_init; |
2850 | sdl_init; |
2692 | |
2851 | |
|
|
2852 | $ENV{FONTCONFIG_FILE} = DC::find_rcfile "fonts/fonts.conf"; |
|
|
2853 | $ENV{FONTCONFIG_DIR} = DC::find_rcfile "fonts"; |
|
|
2854 | |
2693 | { |
2855 | { |
2694 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
2856 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
2695 | DejaVuSans.ttf |
2857 | DejaVuSans.ttf |
2696 | DejaVuSansMono.ttf |
2858 | DejaVuSansMono.ttf |
2697 | DejaVuSans-Bold.ttf |
2859 | DejaVuSans-Bold.ttf |
2698 | DejaVuSansMono-Bold.ttf |
2860 | DejaVuSansMono-Bold.ttf |
2699 | DejaVuSans-Oblique.ttf |
2861 | DejaVuSans-Oblique.ttf |
2700 | DejaVuSansMono-Oblique.ttf |
2862 | DejaVuSansMono-Oblique.ttf |
2701 | DejaVuSans-BoldOblique.ttf |
2863 | DejaVuSans-BoldOblique.ttf |
2702 | DejaVuSansMono-BoldOblique.ttf |
2864 | DejaVuSansMono-BoldOblique.ttf |
|
|
2865 | mona.ttf |
2703 | ); |
2866 | ); |
2704 | |
2867 | |
2705 | DC::add_font $_ for @fonts; |
2868 | DC::add_font $_ for @fonts; |
2706 | |
2869 | |
2707 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2870 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2708 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2871 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2709 | |
2872 | |
2710 | $FONT_PROP->make_default; |
2873 | $FONT_PROP->make_default; |
2711 | |
2874 | |
… | |
… | |
2734 | our $STARTUP_CANCEL = EV::idle sub { |
2897 | our $STARTUP_CANCEL = EV::idle sub { |
2735 | undef $::STARTUP_CANCEL; |
2898 | undef $::STARTUP_CANCEL; |
2736 | $startup_done->(); |
2899 | $startup_done->(); |
2737 | }; |
2900 | }; |
2738 | |
2901 | |
|
|
2902 | debug_toggle 0; |
|
|
2903 | |
2739 | delete $SIG{__DIE__}; |
2904 | delete $SIG{__DIE__}; |
2740 | EV::loop; |
2905 | EV::loop; |
2741 | |
2906 | |
|
|
2907 | DC::write_cfg if $CFG->{config_autosave}; |
|
|
2908 | |
2742 | #video_shutdown; |
2909 | #video_shutdown; |
2743 | #audio_shutdown; |
2910 | #audio_shutdown; |
|
|
2911 | |
2744 | DC::OpenGL::quit; |
2912 | DC::OpenGL::quit; |
2745 | DC::SDL_Quit; |
2913 | DC::SDL_Quit; |
2746 | DC::DB::Server::stop; |
2914 | DC::DB::Server::stop; |
2747 | } |
2915 | } |
2748 | |
2916 | |
… | |
… | |
2752 | |
2920 | |
2753 | deliantra - A Deliantra MORPG game client |
2921 | deliantra - A Deliantra MORPG game client |
2754 | |
2922 | |
2755 | =head1 SYNOPSIS |
2923 | =head1 SYNOPSIS |
2756 | |
2924 | |
2757 | Just run it - no commandline arguments are supported. |
2925 | deliantra [--profile name] [host [user [password]]] |
|
|
2926 | deliantra --help |
2758 | |
2927 | |
2759 | =head1 USAGE |
2928 | =head1 USAGE |
2760 | |
2929 | |
2761 | deliantra utilises OpenGL for all UI elements and the game. It is supposed to |
2930 | The deliantra client utilises OpenGL for all UI elements and the game. It |
2762 | be used in fullscreen mode and interactively. |
2931 | is supposed to be used in fullscreen mode and interactively. |
2763 | |
2932 | |
2764 | =head1 DEBUGGING |
2933 | =head1 DEBUGGING |
2765 | |
2934 | |
2766 | |
|
|
2767 | CFPLUS_DEBUG - environment variable |
2935 | DELIANTRA_DEBUG - environment variable |
2768 | |
2936 | |
2769 | 1 draw borders around widgets |
2937 | 1 draw borders around widgets |
2770 | 2 add low-level widget info to tooltips |
2938 | 2 add low-level widget info to tooltips |
2771 | 4 show fps |
2939 | 4 show fps |
2772 | 8 suppress tooltips |
2940 | 8 suppress tooltips |
|
|
2941 | 16 show bandwidth downstream |
2773 | |
2942 | |
2774 | =head1 AUTHOR |
2943 | =head1 AUTHOR |
2775 | |
2944 | |
2776 | Marc Lehmann <deliantra@schmorp.de>, Robin Redeker <elmex@ta-sa.org> |
2945 | Marc Lehmann <deliantra@schmorp.de>, Robin Redeker <elmex@ta-sa.org> |
2777 | |
2946 | |