… | |
… | |
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 | |
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; |
|
|
26 | |
|
|
27 | Win32::GUI::SplashScreen::Show ( |
22 | Win32::GUI::SplashScreen::Show ( |
28 | -file => "$ENV{PAR_TEMP}/SPLASH.bmp", |
23 | -file => "$ENV{PAR_TEMP}/SPLASH.bmp", |
29 | ); |
24 | ); |
|
|
25 | |
|
|
26 | # initialise the resolver now, as vista forces us back to the desktop |
|
|
27 | # when doing this later. |
|
|
28 | require AnyEvent::DNS; |
|
|
29 | AnyEvent::DNS::resolver (); |
30 | |
30 | |
31 | $startup_done = sub { |
31 | $startup_done = sub { |
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 { |
… | |
… | |
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; |
… | |
… | |
518 | audio_music_push; |
518 | audio_music_push; |
519 | } |
519 | } |
520 | |
520 | |
521 | sub audio_init { |
521 | sub audio_init { |
522 | if ($CFG->{audio_enable}) { |
522 | if ($CFG->{audio_enable}) { |
|
|
523 | if (length $CFG->{audio_driver}) { |
|
|
524 | local $ENV{SDL_AUDIODRIVER} = $CFG->{audio_driver}; |
|
|
525 | DC::SDL_Init DC::SDL_INIT_AUDIO |
|
|
526 | and die "SDL::Init failed!\n"; |
|
|
527 | } else { |
|
|
528 | DC::SDL_Init DC::SDL_INIT_AUDIO |
|
|
529 | and die "SDL::Init failed!\n"; |
|
|
530 | } |
|
|
531 | |
523 | $ENV{MIX_EFFECTSMAXSPEED} = 1; |
532 | $ENV{MIX_EFFECTSMAXSPEED} = 1; |
524 | $SDL_MIXER = !DC::Mix_OpenAudio |
533 | $SDL_MIXER = !DC::Mix_OpenAudio |
525 | $CFG->{audio_hw_frequency}, |
534 | $CFG->{audio_hw_frequency}, |
526 | DC::MIX_DEFAULT_FORMAT, |
535 | DC::MIX_DEFAULT_FORMAT, |
527 | $CFG->{audio_hw_channels}, |
536 | $CFG->{audio_hw_channels}, |
… | |
… | |
541 | sub audio_tab_update; |
550 | sub audio_tab_update; |
542 | audio_tab_update; |
551 | audio_tab_update; |
543 | } |
552 | } |
544 | |
553 | |
545 | sub audio_shutdown { |
554 | sub audio_shutdown { |
|
|
555 | if ($SDL_MIXER) { |
|
|
556 | DC::MixMusic::halt; |
|
|
557 | DC::Mix_AllocateChannels 0; |
|
|
558 | } |
|
|
559 | |
546 | undef $MUSIC_PLAYER; |
560 | undef $MUSIC_PLAYER; |
547 | undef $MUSIC_PLAYING_META; |
561 | undef $MUSIC_PLAYING_META; |
548 | undef $MUSIC_PLAYING_DATA; |
562 | undef $MUSIC_PLAYING_DATA; |
549 | |
563 | |
550 | $MUSIC_WANT = []; |
564 | $MUSIC_WANT = []; |
551 | @MUSIC_JINGLE = (); |
565 | @MUSIC_JINGLE = (); |
552 | %AUDIO_PLAY = (); |
566 | %AUDIO_PLAY = (); |
553 | %AUDIO_CHUNK = (); |
567 | %AUDIO_CHUNK = (); |
554 | |
568 | |
555 | DC::MixMusic::halt; |
|
|
556 | DC::Mix_AllocateChannels 0; |
|
|
557 | DC::Mix_CloseAudio if $SDL_MIXER; |
569 | DC::Mix_CloseAudio if $SDL_MIXER; |
558 | undef $SDL_MIXER; |
570 | undef $SDL_MIXER; |
|
|
571 | |
|
|
572 | DC::SDL_QuitSubSystem DC::SDL_INIT_AUDIO; |
559 | } |
573 | } |
560 | |
574 | |
561 | ############################################################################# |
575 | ############################################################################# |
562 | |
576 | |
563 | sub destroy_query_dialog { |
577 | sub destroy_query_dialog { |
… | |
… | |
804 | user => $PROFILE->{user}, |
818 | user => $PROFILE->{user}, |
805 | pass => $PROFILE->{password}, |
819 | pass => $PROFILE->{password}, |
806 | mapw => $mapw, |
820 | mapw => $mapw, |
807 | maph => $maph, |
821 | maph => $maph, |
808 | |
822 | |
|
|
823 | c_version => { |
|
|
824 | client => "deliantra", |
809 | client => "$DC::VERSION $] $^O", |
825 | clientver => $DC::VERSION, |
|
|
826 | gl_vendor => DC::OpenGL::gl_vendor, |
|
|
827 | gl_version => DC::OpenGL::gl_version, |
|
|
828 | }, |
810 | |
829 | |
811 | map_widget => $MAPWIDGET, |
830 | map_widget => $MAPWIDGET, |
812 | statusbox => $STATUSBOX, |
831 | statusbox => $STATUSBOX, |
813 | map => $MAP, |
832 | map => $MAP, |
814 | mapmap => $MAPMAP, |
833 | mapmap => $MAPMAP, |
… | |
… | |
846 | |
865 | |
847 | # hack to make SURE we find the IP address all right |
866 | # hack to make SURE we find the IP address all right |
848 | # can be removed once AnyEvent::DNS is proven stable. |
867 | # can be removed once AnyEvent::DNS is proven stable. |
849 | if ($host eq "gameserver.deliantra.net") { |
868 | if ($host eq "gameserver.deliantra.net") { |
850 | AnyEvent::DNS::a "dnstest.deliantra.net", sub { |
869 | AnyEvent::DNS::a "dnstest.deliantra.net", sub { |
851 | if ($_[0] ne "80.101.114.108") { # Perl |
870 | if ($_[0] ne "80.101.114.108") { # P-e-r-l |
852 | status "dns failure, trying differently"; |
871 | status "dns failure, trying differently"; |
853 | $host = eval { Socket::inet_ntoa Socket::inet_aton "gameserver.deliantra.net" }; |
872 | $host = eval { Socket::inet_ntoa Socket::inet_aton "gameserver.deliantra.net" }; |
854 | unless (defined $host) { |
873 | unless (defined $host) { |
855 | status "dns failure, using hardcoded address"; |
874 | status "dns failure, using hardcoded address"; |
856 | $host = "129.13.162.95"; |
875 | $host = "194.126.175.154"; |
857 | } |
876 | } |
858 | } |
877 | } |
859 | |
878 | |
860 | dc_connect $host, $port; |
879 | dc_connect $host, $port; |
861 | }; |
880 | }; |
… | |
… | |
1036 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Smooth Transitions"); |
1055 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Smooth Transitions"); |
1037 | $table->add_at (1, $row++, new DC::UI::CheckBox |
1056 | $table->add_at (1, $row++, new DC::UI::CheckBox |
1038 | state => $CFG->{smooth_transitions}, |
1057 | state => $CFG->{smooth_transitions}, |
1039 | tooltip => "<b>Smooth Transitions</b> tries to blend the fog of war and lighting smoothly between updates. " |
1058 | tooltip => "<b>Smooth Transitions</b> tries to blend the fog of war and lighting smoothly between updates. " |
1040 | . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, " |
1059 | . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, " |
1041 | . "then disable this option. Requires Smooth Movement and OpenGL 1.4 or up. Changes take effect immdiately.", |
1060 | . "then disable this option. Requires Smooth Movement and OpenGL Multitexturing. Changes take effect immdiately.", |
1042 | on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_transitions} = $value; 0 } |
1061 | on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_transitions} = $value; 0 } |
1043 | ); |
1062 | ); |
1044 | |
1063 | |
1045 | |
1064 | |
1046 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Map Scale"); |
1065 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Map Scale"); |
… | |
… | |
1075 | 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.", |
1094 | 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.", |
1076 | on_activate => sub { |
1095 | on_activate => sub { |
1077 | my ($self) = @_; |
1096 | my ($self) = @_; |
1078 | $CFG->{fow_texture} = ($CFG->{fow_texture} + 1) % @DC::MapWidget::TEX_HIDDEN; |
1097 | $CFG->{fow_texture} = ($CFG->{fow_texture} + 1) % @DC::MapWidget::TEX_HIDDEN; |
1079 | $self->set_texture ($DC::MapWidget::TEX_HIDDEN[$CFG->{fow_texture}]); |
1098 | $self->set_texture ($DC::MapWidget::TEX_HIDDEN[$CFG->{fow_texture}]); |
|
|
1099 | $MAPWIDGET->update; |
1080 | } |
1100 | } |
1081 | ); |
1101 | ); |
1082 | |
1102 | |
1083 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Intensity"); |
1103 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Intensity"); |
1084 | $table->add_at (1, $row++, new DC::UI::Slider |
1104 | $table->add_at (1, $row++, new DC::UI::Slider |
… | |
… | |
1136 | ]); |
1156 | ]); |
1137 | |
1157 | |
1138 | my $text = !$freq |
1158 | my $text = !$freq |
1139 | ? "audio is off" |
1159 | ? "audio is off" |
1140 | : "audio is enabled\n" |
1160 | : "audio is enabled\n" |
|
|
1161 | . "driver: " . DC::SDL_AudioDriverName . "\n" |
1141 | . "frequency (Hz): $freq\n" |
1162 | . "frequency (Hz): $freq\n" |
1142 | . "channels: $chans"; |
1163 | . "channels: $chans\n" |
|
|
1164 | . "chunk decoders available: " . (join ", ", DC::MixChunk::decoders) . "\n" |
|
|
1165 | . "music decoders available: " . (join ", ", DC::MixMusic::decoders); |
1143 | |
1166 | |
1144 | $AUDIO_INFO->set_text ($text); |
1167 | $AUDIO_INFO->set_text ($text); |
1145 | } |
1168 | } |
1146 | |
1169 | |
1147 | sub audio_setup { |
1170 | sub audio_setup { |
… | |
… | |
1150 | $vbox->add (my $table = new DC::UI::Table expand => 1, col_expand => [0, 0, 1]); |
1173 | $vbox->add (my $table = new DC::UI::Table expand => 1, col_expand => [0, 0, 1]); |
1151 | |
1174 | |
1152 | my $row = 0; |
1175 | my $row = 0; |
1153 | |
1176 | |
1154 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Audio Enable"); |
1177 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Audio Enable"); |
1155 | $table->add_at (1, $row++, new DC::UI::CheckBox |
1178 | $table->add_at (1, $row, new DC::UI::CheckBox |
1156 | state => $CFG->{audio_enable}, |
1179 | state => $CFG->{audio_enable}, |
1157 | tooltip => "<b>Master Audio Enable.</b> If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.", |
1180 | tooltip => "<b>Master Audio Enable.</b> If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.", |
1158 | on_changed => sub { $CFG->{audio_enable} = $_[1]; 1 } |
1181 | on_changed => sub { $CFG->{audio_enable} = $_[1]; 1 } |
|
|
1182 | ); |
|
|
1183 | $table->add_at (2, $row++, my $driver = new DC::UI::HBox expand => 1); |
|
|
1184 | |
|
|
1185 | $driver->add (new DC::UI::Label align => 1, text => " Audio driver override"); |
|
|
1186 | $driver->add (new DC::UI::Entry |
|
|
1187 | text => $CFG->{audio_driver}, |
|
|
1188 | template => "dsound1234", |
|
|
1189 | tooltip => "You can override the audio driver to use here. Leaving it empty will result " |
|
|
1190 | . "in Deliantra picking one automatically. GNU/Linux users often prefer specific " |
|
|
1191 | . "drivers though, and can experiment with <b>alsa</b>, <b>dsp</b>, <b>esd</b>, <b>pulse</b>, <b>arts</b>, <b>nas</b> " |
|
|
1192 | . "or other system-specific drivers. Selecting the wrong driver here will simply result" |
|
|
1193 | . "in no sound.", |
|
|
1194 | on_changed => sub { my ($self, $value) = @_; $CFG->{audio_driver} = $value; 1 } |
1159 | ); |
1195 | ); |
1160 | |
1196 | |
1161 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Sound Effects"); |
1197 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Sound Effects"); |
1162 | $table->add_at (1, $row, new DC::UI::CheckBox |
1198 | $table->add_at (1, $row, new DC::UI::CheckBox |
1163 | expand => 1, state => $CFG->{effects_enable}, |
1199 | expand => 1, state => $CFG->{effects_enable}, |
… | |
… | |
1176 | ); |
1212 | ); |
1177 | |
1213 | |
1178 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Background Music"); |
1214 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Background Music"); |
1179 | $table->add_at (1, $row, new DC::UI::CheckBox |
1215 | $table->add_at (1, $row, new DC::UI::CheckBox |
1180 | expand => 1, state => $CFG->{bgm_enable}, |
1216 | expand => 1, state => $CFG->{bgm_enable}, |
1181 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", |
1217 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played. Needs server reconnect to take effect.", |
1182 | on_changed => sub { |
1218 | on_changed => sub { |
1183 | $CFG->{bgm_enable} = $_[1]; |
1219 | $CFG->{bgm_enable} = $_[1]; |
1184 | $CONN->update_fx_want if $CONN; |
1220 | $CONN->update_fx_want if $CONN; |
1185 | audio_music_push; |
1221 | audio_music_push; |
1186 | 1 |
1222 | 1 |
… | |
… | |
1197 | c_colspan => 2, expand => 1, |
1233 | c_colspan => 2, expand => 1, |
1198 | value => $CFG->{audio_hw_frequency}, |
1234 | value => $CFG->{audio_hw_frequency}, |
1199 | options => [ |
1235 | options => [ |
1200 | [ 0, "default" , "Use System Default"], |
1236 | [ 0, "default" , "Use System Default"], |
1201 | [11025, "11 kHz" , "11kHz (low quality)"], |
1237 | [11025, "11 kHz" , "11kHz (low quality)"], |
1202 | [22050, "22 kHz" , "22kHz (reduced quality)"], |
1238 | [22050, "22 kHz" , "22kHz (reduced quality, recommended)"], |
1203 | [44100, "44.1 kHz", "44.1kHz (cd quality)"], |
1239 | [44100, "44.1 kHz", "44.1kHz (cd quality)"], |
1204 | [48000, "48 kHz" , "48kHz (studio quality)"], |
1240 | [48000, "48 kHz" , "48kHz (studio quality, not recommended)"], |
1205 | ], |
1241 | ], |
1206 | tooltip => "The sampling frequency to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.", |
1242 | tooltip => "The sampling frequency to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.", |
1207 | on_changed => sub { |
1243 | on_changed => sub { |
1208 | $CFG->{audio_hw_frequency} = $_[1]; |
1244 | $CFG->{audio_hw_frequency} = $_[1]; |
1209 | audio_tab_update; |
1245 | audio_tab_update; |
… | |
… | |
1233 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Latency"); |
1269 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Latency"); |
1234 | $table->add_at (1, $row++, $AUDIO_HW_CHUNKSIZE = new DC::UI::Selector |
1270 | $table->add_at (1, $row++, $AUDIO_HW_CHUNKSIZE = new DC::UI::Selector |
1235 | c_colspan => 2, expand => 1, |
1271 | c_colspan => 2, expand => 1, |
1236 | value => $CFG->{audio_hw_chunksize}, |
1272 | value => $CFG->{audio_hw_chunksize}, |
1237 | tooltip => "The guarenteed latency. Lower is better, but also more cpu-intensive and might cause stuttering. If music playback " |
1273 | tooltip => "The guarenteed latency. Lower is better, but also more cpu-intensive and might cause stuttering. If music playback " |
1238 | . "is stuttering, increase this value. Values of 50-100ms are optimal.", |
1274 | . "is stuttering, increase this value. Values of 50-150ms are optimal.", |
1239 | on_changed => sub { |
1275 | on_changed => sub { |
1240 | $CFG->{audio_hw_chunksize} = $_[1]; |
1276 | $CFG->{audio_hw_chunksize} = $_[1]; |
1241 | audio_tab_update; |
1277 | audio_tab_update; |
1242 | 1 |
1278 | 1 |
1243 | } |
1279 | } |
… | |
… | |
1323 | &set_gauge_window_fontsize; |
1359 | &set_gauge_window_fontsize; |
1324 | |
1360 | |
1325 | $win |
1361 | $win |
1326 | } |
1362 | } |
1327 | |
1363 | |
|
|
1364 | our $BW_WATCHER; |
|
|
1365 | |
|
|
1366 | sub debug_toggle($) { |
|
|
1367 | $DELIANTRA_DEBUG ^= $_[0]; |
|
|
1368 | |
|
|
1369 | if ($DELIANTRA_DEBUG & 16) { |
|
|
1370 | $BW_WATCHER = EV::periodic 0, 1, 0, sub { |
|
|
1371 | return unless $CONN; |
|
|
1372 | debug sprintf "%8.2gKB/s", $CONN->{octets_in} / 1e3; |
|
|
1373 | $CONN->{octets_in} = 0; |
|
|
1374 | }; |
|
|
1375 | } else { |
|
|
1376 | undef $BW_WATCHER; |
|
|
1377 | } |
|
|
1378 | |
|
|
1379 | } |
|
|
1380 | |
1328 | sub debug_setup { |
1381 | sub debug_setup { |
1329 | my $table = new DC::UI::Table; |
1382 | my $table = new DC::UI::Table; |
1330 | |
1383 | |
1331 | $table->add_at (0, 0, new DC::UI::Label text => "Widget Borders"); |
1384 | $table->add_at (0, 0, new DC::UI::Label text => "Widget Borders"); |
1332 | $table->add_at (1, 0, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 1; 0 }); |
1385 | $table->add_at (1, 0, new DC::UI::CheckBox on_changed => sub { debug_toggle 1; 0 }); |
1333 | $table->add_at (0, 1, new DC::UI::Label text => "Tooltip Widget Info"); |
1386 | $table->add_at (0, 1, new DC::UI::Label text => "Tooltip Widget Info"); |
1334 | $table->add_at (1, 1, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2; 0 }); |
1387 | $table->add_at (1, 1, new DC::UI::CheckBox on_changed => sub { debug_toggle 2; 0 }); |
1335 | $table->add_at (0, 2, new DC::UI::Label text => "Show FPS"); |
1388 | $table->add_at (0, 2, new DC::UI::Label text => "Show FPS"); |
1336 | $table->add_at (1, 2, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4; 0 }); |
1389 | $table->add_at (1, 2, new DC::UI::CheckBox on_changed => sub { debug_toggle 4; 0 }); |
1337 | $table->add_at (0, 3, new DC::UI::Label text => "Suppress Tooltips"); |
1390 | $table->add_at (0, 3, new DC::UI::Label text => "Suppress Tooltips"); |
1338 | $table->add_at (1, 3, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 }); |
1391 | $table->add_at (1, 3, new DC::UI::CheckBox on_changed => sub { debug_toggle 8; 0 }); |
|
|
1392 | $table->add_at (0, 4, new DC::UI::Label text => "Show Bandwidth"); |
|
|
1393 | $table->add_at (1, 4, new DC::UI::CheckBox on_changed => sub { debug_toggle 16; 0 }); |
|
|
1394 | |
1339 | $table->add_at (0, 4, new DC::UI::Button text => "die on click(tm)", on_activate => sub { &DC::debug() } ); |
1395 | $table->add_at (0, 6, new DC::UI::Button text => "die on click(tm)", on_activate => sub { &DC::debug() } ); |
1340 | |
|
|
1341 | $table->add_at (0, 5, new DC::UI::TextEdit text => "line1\0152\0153\nµikachu\nづx゙つ゛");#d# |
1396 | $table->add_at (0, 7, new DC::UI::TextEdit text => "line1\0152\0153\nµikachu\nづx゙つ゛");#d# |
1342 | |
1397 | |
1343 | $table->add_at (7,7, my $t = new DC::UI::Table expand => 0); |
1398 | $table->add_at (7,7, my $t = new DC::UI::Table expand => 0); |
1344 | $t->add_at (0,0, new DC::UI::Label text => "a a", c_rowspan => 1, c_colspan => 2); |
1399 | $t->add_at (0,0, new DC::UI::Label text => "a a", c_rowspan => 1, c_colspan => 2); |
1345 | $t->add_at (2,0, new DC::UI::Label text => "b\nb", c_rowspan => 2, c_colspan => 1, ellipsise => 0 ); |
1400 | $t->add_at (2,0, new DC::UI::Label text => "b\nb", c_rowspan => 2, c_colspan => 1, ellipsise => 0 ); |
1346 | $t->add_at (1,2, new DC::UI::Label text => "c c", c_rowspan => 1, c_colspan => 2); |
1401 | $t->add_at (1,2, new DC::UI::Label text => "c c", c_rowspan => 1, c_colspan => 2); |
… | |
… | |
1667 | child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]), |
1722 | child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]), |
1668 | ); |
1723 | ); |
1669 | |
1724 | |
1670 | $table->add_at (0, 4, new DC::UI::Label align => 1, text => "Username"); |
1725 | $table->add_at (0, 4, new DC::UI::Label align => 1, text => "Username"); |
1671 | $table->add_at (1, 4, new DC::UI::Entry |
1726 | $table->add_at (1, 4, new DC::UI::Entry |
1672 | text => $CFG->{profile}{default}{user}, |
1727 | text => $PROFILE->{user}, |
1673 | tooltip => "The name of your character on the server. The name is case-sensitive!", |
1728 | tooltip => "The name of your character on the server. The name is case-sensitive!", |
1674 | on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value; 1 } |
1729 | on_changed => sub { my ($self, $value) = @_; $PROFILE->{user} = $value; 1 } |
1675 | ); |
1730 | ); |
1676 | |
1731 | |
1677 | $table->add_at (0, 5, new DC::UI::Label align => 1, text => "Password"); |
1732 | $table->add_at (0, 5, new DC::UI::Label align => 1, text => "Password"); |
1678 | $table->add_at (1, 5, new DC::UI::Entry |
1733 | $table->add_at (1, 5, new DC::UI::Entry |
1679 | text => $CFG->{profile}{default}{password}, |
1734 | text => $PROFILE->{password}, |
1680 | hidden => 1, |
1735 | hidden => 1, |
1681 | tooltip => "The password for your character.", |
1736 | tooltip => "The password for your character.", |
1682 | on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value; 1 } |
1737 | on_changed => sub { my ($self, $value) = @_; $PROFILE->{password} = $value; 1 } |
1683 | ); |
1738 | ); |
1684 | |
1739 | |
1685 | $table->add_at (1, 11, $LOGIN_BUTTON = new DC::UI::Button |
1740 | $table->add_at (1, 11, $LOGIN_BUTTON = new DC::UI::Button |
1686 | expand => 1, |
1741 | expand => 1, |
1687 | text => "Login / Register", |
1742 | text => "Login / Register", |
… | |
… | |
1723 | $table->add_at (1, $row, my $vbox = new DC::UI::VBox); |
1778 | $table->add_at (1, $row, my $vbox = new DC::UI::VBox); |
1724 | |
1779 | |
1725 | $vbox->add ( |
1780 | $vbox->add ( |
1726 | $HOST_ENTRY = new DC::UI::Entry |
1781 | $HOST_ENTRY = new DC::UI::Entry |
1727 | expand => 1, |
1782 | expand => 1, |
1728 | text => $CFG->{profile}{default}{host}, |
1783 | text => $PROFILE->{host}, |
1729 | tooltip => "The hostname or ip address of the Deliantra server to connect to (e.g. <b>gameserver.deliantra.net</b>)", |
1784 | tooltip => "The hostname or ip address of the Deliantra server to connect to (e.g. <b>gameserver.deliantra.net</b>)", |
1730 | on_changed => sub { |
1785 | on_changed => sub { |
1731 | my ($self, $value) = @_; |
1786 | my ($self, $value) = @_; |
1732 | $CFG->{profile}{default}{host} = $value; |
1787 | $PROFILE->{host} = $value; |
1733 | 1 |
1788 | 1 |
1734 | } |
1789 | } |
1735 | ); |
1790 | ); |
1736 | |
1791 | |
1737 | if (0) { #d# disabled |
1792 | if (0) { #d# disabled |
… | |
… | |
1936 | $r |
1991 | $r |
1937 | } |
1992 | } |
1938 | |
1993 | |
1939 | my %SORT_ORDER = ( |
1994 | my %SORT_ORDER = ( |
1940 | type => sub { |
1995 | type => sub { |
|
|
1996 | use sort 'stable'; |
1941 | sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ |
1997 | sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ |
1942 | }, |
1998 | }, |
1943 | mtime => sub { |
1999 | mtime => sub { |
|
|
2000 | use sort 'stable'; |
1944 | my $NOW = time; |
2001 | my $NOW = time; |
1945 | sort { |
2002 | sort { |
1946 | my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; |
2003 | my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; |
1947 | my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; |
2004 | my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; |
1948 | |
2005 | |
1949 | ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED) |
2006 | ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED) |
1950 | or $btime <=> $atime |
2007 | or $btime <=> $atime |
1951 | or $a->{type} <=> $b->{type} |
2008 | or $a->{type} <=> $b->{type} |
1952 | } @_ |
2009 | } @_ |
1953 | }, |
2010 | }, |
1954 | weight => sub { sort { |
2011 | weight => sub { |
|
|
2012 | use sort 'stable'; |
|
|
2013 | sort { |
1955 | $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) |
2014 | $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) |
1956 | or $a->{type} <=> $b->{type} |
2015 | or $a->{type} <=> $b->{type} |
1957 | } @_ }, |
2016 | } @_ |
|
|
2017 | }, |
1958 | ); |
2018 | ); |
1959 | |
2019 | |
1960 | sub inventory_widget { |
2020 | sub inventory_widget { |
1961 | my $hb = new DC::UI::HBox homogeneous => 1; |
2021 | my $hb = new DC::UI::HBox homogeneous => 1; |
1962 | |
2022 | |
… | |
… | |
2403 | |
2463 | |
2404 | $dialog->show; |
2464 | $dialog->show; |
2405 | }; |
2465 | }; |
2406 | } |
2466 | } |
2407 | |
2467 | |
2408 | sub sdl_init { |
|
|
2409 | DC::SDL_Init DC::SDL_INIT_AUDIO #| DC::SDL_NOPARACHUTE |
|
|
2410 | and die "SDL::Init failed!\n"; |
|
|
2411 | } |
|
|
2412 | |
|
|
2413 | sub video_init { |
2468 | sub video_init { |
2414 | DC::set_theme $CFG->{uitheme}; |
2469 | DC::set_theme $CFG->{uitheme}; |
2415 | |
2470 | |
2416 | DC::SDL_InitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT; |
2471 | DC::SDL_InitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT; |
2417 | $SDL_REINIT = 0; |
2472 | $SDL_REINIT = 0; |
… | |
… | |
2476 | |
2531 | |
2477 | $DEBUG_STATUS = new DC::UI::Label |
2532 | $DEBUG_STATUS = new DC::UI::Label |
2478 | padding => 0, |
2533 | padding => 0, |
2479 | z => 100, |
2534 | z => 100, |
2480 | force_x => "max", |
2535 | force_x => "max", |
2481 | force_y => 0; |
2536 | force_y => 20; |
2482 | $DEBUG_STATUS->show; |
2537 | $DEBUG_STATUS->show; |
2483 | |
2538 | |
2484 | $STATUSBOX = new DC::UI::Statusbox; |
2539 | $STATUSBOX = new DC::UI::Statusbox; |
2485 | |
2540 | |
2486 | $MODBOX = new DC::UI::Label |
2541 | $MODBOX = new DC::UI::Label |
… | |
… | |
2614 | my $animate_timer; |
2669 | my $animate_timer; |
2615 | |
2670 | |
2616 | my $fps = 9; |
2671 | my $fps = 9; |
2617 | |
2672 | |
2618 | sub force_refresh { |
2673 | sub force_refresh { |
2619 | if ($ENV{CFPLUS_DEBUG} & 4) { |
2674 | if ($DELIANTRA_DEBUG & 4) { |
2620 | $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; |
2675 | $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; |
2621 | debug sprintf "%3.2f", $fps; |
2676 | debug sprintf "%3.2f", $fps; |
2622 | } |
2677 | } |
2623 | |
2678 | |
2624 | undef $WANT_REFRESH; |
2679 | undef $WANT_REFRESH; |
… | |
… | |
2770 | shift_fire_stop => 0, |
2825 | shift_fire_stop => 0, |
2771 | uitheme => "wood", |
2826 | uitheme => "wood", |
2772 | map_shift_x => -24, # arbitrary |
2827 | map_shift_x => -24, # arbitrary |
2773 | map_shift_y => +24, # arbitrary |
2828 | map_shift_y => +24, # arbitrary |
2774 | ); |
2829 | ); |
2775 | |
2830 | |
2776 | while (my ($k, $v) = each %DEF_CFG) { |
2831 | while (my ($k, $v) = each %DEF_CFG) { |
2777 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2832 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2778 | } |
2833 | } |
2779 | |
2834 | |
2780 | $CFG->{profile}{default}{host} ||= "gameserver.deliantra.net"; |
2835 | my @args = @ARGV; |
|
|
2836 | |
|
|
2837 | # OS X passes some process serial number of other shit. they |
|
|
2838 | # could have used an env var or any other sane mechanism. but |
|
|
2839 | # would it be os x then? no... |
|
|
2840 | shift @args if $args[0] =~ /^-psn_/; |
|
|
2841 | |
|
|
2842 | my $profile = 'default'; |
|
|
2843 | |
|
|
2844 | for (my $i = 0; $i < @args; $i++) { |
|
|
2845 | if ($args[$i] =~ /^--?profile$/) { |
|
|
2846 | $profile = $args[$i + 1]; |
|
|
2847 | splice @args, $i, 2, (); |
|
|
2848 | $i = 0; |
|
|
2849 | } elsif ($args[$i] =~ /^--?h/) { |
|
|
2850 | print STDERR "Usage: $0 [--profile name] [host [user [password]]]\n"; |
|
|
2851 | exit 0; |
|
|
2852 | } |
|
|
2853 | } |
|
|
2854 | |
|
|
2855 | $CFG->{profile}{$profile} ||= {}; |
2781 | $PROFILE = $CFG->{profile}{default}; |
2856 | $PROFILE = $CFG->{profile}{$profile}; |
|
|
2857 | $PROFILE->{host} ||= "gameserver.deliantra.net"; |
|
|
2858 | |
|
|
2859 | $PROFILE->{host} = $args[0] if @args > 0; |
|
|
2860 | $PROFILE->{user} = $args[1] if @args > 1; |
|
|
2861 | $PROFILE->{password} = $args[2] if @args > 2; |
2782 | |
2862 | |
2783 | # convert old bindings (only default profile matters) |
2863 | # convert old bindings (only default profile matters) |
2784 | if (my $bindings = delete $PROFILE->{bindings}) { |
2864 | if (my $bindings = delete $PROFILE->{bindings}) { |
2785 | while (my ($mod, $syms) = each %$bindings) { |
2865 | while (my ($mod, $syms) = each %$bindings) { |
2786 | while (my ($sym, $cmds) = each %$syms) { |
2866 | while (my ($sym, $cmds) = each %$syms) { |
… | |
… | |
2789 | action => $cmds, |
2869 | action => $cmds, |
2790 | }; |
2870 | }; |
2791 | } |
2871 | } |
2792 | } |
2872 | } |
2793 | } |
2873 | } |
2794 | |
|
|
2795 | sdl_init; |
|
|
2796 | |
2874 | |
2797 | $ENV{FONTCONFIG_FILE} = DC::find_rcfile "fonts/fonts.conf"; |
2875 | $ENV{FONTCONFIG_FILE} = DC::find_rcfile "fonts/fonts.conf"; |
2798 | $ENV{FONTCONFIG_DIR} = DC::find_rcfile "fonts"; |
2876 | $ENV{FONTCONFIG_DIR} = DC::find_rcfile "fonts"; |
2799 | |
2877 | |
2800 | { |
2878 | { |
… | |
… | |
2809 | DejaVuSansMono-BoldOblique.ttf |
2887 | DejaVuSansMono-BoldOblique.ttf |
2810 | mona.ttf |
2888 | mona.ttf |
2811 | ); |
2889 | ); |
2812 | |
2890 | |
2813 | DC::add_font $_ for @fonts; |
2891 | DC::add_font $_ for @fonts; |
2814 | |
2892 | |
2815 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2893 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2816 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2894 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2817 | |
2895 | |
2818 | $FONT_PROP->make_default; |
2896 | $FONT_PROP->make_default; |
2819 | |
2897 | |
… | |
… | |
2842 | our $STARTUP_CANCEL = EV::idle sub { |
2920 | our $STARTUP_CANCEL = EV::idle sub { |
2843 | undef $::STARTUP_CANCEL; |
2921 | undef $::STARTUP_CANCEL; |
2844 | $startup_done->(); |
2922 | $startup_done->(); |
2845 | }; |
2923 | }; |
2846 | |
2924 | |
|
|
2925 | debug_toggle 0; |
|
|
2926 | |
2847 | delete $SIG{__DIE__}; |
2927 | delete $SIG{__DIE__}; |
2848 | EV::loop; |
2928 | EV::loop; |
2849 | |
2929 | |
2850 | DC::write_cfg if $CFG->{config_autosave}; |
2930 | DC::write_cfg if $CFG->{config_autosave}; |
2851 | |
2931 | |
… | |
… | |
2863 | |
2943 | |
2864 | deliantra - A Deliantra MORPG game client |
2944 | deliantra - A Deliantra MORPG game client |
2865 | |
2945 | |
2866 | =head1 SYNOPSIS |
2946 | =head1 SYNOPSIS |
2867 | |
2947 | |
2868 | Just run it - no commandline arguments are supported. |
2948 | deliantra [--profile name] [host [user [password]]] |
|
|
2949 | deliantra --help |
2869 | |
2950 | |
2870 | =head1 USAGE |
2951 | =head1 USAGE |
2871 | |
2952 | |
2872 | deliantra utilises OpenGL for all UI elements and the game. It is supposed to |
2953 | The deliantra client utilises OpenGL for all UI elements and the game. It |
2873 | be used in fullscreen mode and interactively. |
2954 | is supposed to be used in fullscreen mode and interactively. |
2874 | |
2955 | |
2875 | =head1 DEBUGGING |
2956 | =head1 DEBUGGING |
2876 | |
2957 | |
2877 | |
|
|
2878 | CFPLUS_DEBUG - environment variable |
2958 | DELIANTRA_DEBUG - environment variable |
2879 | |
2959 | |
2880 | 1 draw borders around widgets |
2960 | 1 draw borders around widgets |
2881 | 2 add low-level widget info to tooltips |
2961 | 2 add low-level widget info to tooltips |
2882 | 4 show fps |
2962 | 4 show fps |
2883 | 8 suppress tooltips |
2963 | 8 suppress tooltips |
|
|
2964 | 16 show bandwidth downstream |
2884 | |
2965 | |
2885 | =head1 AUTHOR |
2966 | =head1 AUTHOR |
2886 | |
2967 | |
2887 | Marc Lehmann <deliantra@schmorp.de>, Robin Redeker <elmex@ta-sa.org> |
2968 | Marc Lehmann <deliantra@schmorp.de>, Robin Redeker <elmex@ta-sa.org> |
2888 | |
2969 | |