ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/deliantra
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/deliantra (file contents):
Revision 1.96 by root, Mon Jul 27 23:08:41 2009 UTC vs.
Revision 1.118 by root, Mon Dec 26 03:58:12 2011 UTC

5 use Coro; 5 use Coro;
6 use Coro::EV; 6 use Coro::EV;
7 use Coro::Debug; 7 use Coro::Debug;
8 our $debug = new_unix_server Coro::Debug "/tmp/dc"; 8 our $debug = new_unix_server Coro::Debug "/tmp/dc";
9 '; 9 ';
10 die if $@;
10} 11}
11 12
12# do splash-screen thingy on win32 13# do splash-screen thingy on win32
13my $startup_done = sub { }; 14my $startup_done = sub { };
14BEGIN { 15BEGIN {
17 $zip->extractMember ("SPLASH.bmp", "$ENV{PAR_TEMP}/SPLASH.bmp"); 18 $zip->extractMember ("SPLASH.bmp", "$ENV{PAR_TEMP}/SPLASH.bmp");
18 } 19 }
19 20
20 require Win32::GUI::SplashScreen; 21 require Win32::GUI::SplashScreen;
21 22
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 ( 23 Win32::GUI::SplashScreen::Show (
28 -file => "$ENV{PAR_TEMP}/SPLASH.bmp", 24 -file => "$ENV{PAR_TEMP}/SPLASH.bmp",
29 ); 25 );
26
27 # initialise the resolver now, as vista forces us back to the desktop
28 # when doing this later.
29 require AnyEvent::DNS;
30 AnyEvent::DNS::resolver ();
30 31
31 $startup_done = sub { 32 $startup_done = sub {
32 Win32::GUI::SplashScreen::Done (1); 33 Win32::GUI::SplashScreen::Done (1);
33 }; 34 };
34 } 35 }
35} 36}
36 37
37use strict; 38use common::sense;
38use utf8;
39 39
40use Carp 'verbose'; 40use Carp 'verbose';
41 41
42# do things only needed for single-binary version (par) 42# do things only needed for single-binary version (par)
43BEGIN { 43BEGIN {
134 DC::fatal Carp::longmess $@; 134 DC::fatal Carp::longmess $@;
135}; 135};
136 136
137my $MAX_FPS = 60; 137my $MAX_FPS = 60;
138 138
139our $DEFAULT_SERVER = "gameserver.deliantra.net";
140
139our $META_SERVER = "http://metaserver.schmorp.de/current.json"; 141our $META_SERVER = "http://metaserver.schmorp.de/current.json";
140 142
141our $LAST_REFRESH; 143our $LAST_REFRESH;
142our $NOW; 144our $NOW;
143 145
144our $CFG; 146our $CFG;
145our $PROFILE; # current profile 147our $PROFILE; # current profile
146our $FAST; # fast, low-quality mode, possibly useful for software-rendering 148our $FAST; # fast, low-quality mode, possibly useful for software-rendering
149our $DELIANTRA_DEBUG = $ENV{DELIANTRA_DEBUG} * 1;
147 150
148our $WANT_REFRESH; 151our $WANT_REFRESH;
149 152
150our $MODE_SLIDER; 153our $MODE_SLIDER;
151our $CAVEAT_LABEL; 154our $CAVEAT_LABEL;
516 audio_music_push; 519 audio_music_push;
517} 520}
518 521
519sub audio_init { 522sub audio_init {
520 if ($CFG->{audio_enable}) { 523 if ($CFG->{audio_enable}) {
524 if (length $CFG->{audio_driver}) {
525 local $ENV{SDL_AUDIODRIVER} = $CFG->{audio_driver};
526 DC::SDL_Init DC::SDL_INIT_AUDIO
527 and die "SDL::Init failed!\n";
528 } else {
529 DC::SDL_Init DC::SDL_INIT_AUDIO
530 and die "SDL::Init failed!\n";
531 }
532
521 $ENV{MIX_EFFECTSMAXSPEED} = 1; 533 $ENV{MIX_EFFECTSMAXSPEED} = 1;
522 $SDL_MIXER = !DC::Mix_OpenAudio 534 $SDL_MIXER = !DC::Mix_OpenAudio
523 $CFG->{audio_hw_frequency}, 535 $CFG->{audio_hw_frequency},
524 DC::MIX_DEFAULT_FORMAT, 536 DC::MIX_DEFAULT_FORMAT,
525 $CFG->{audio_hw_channels}, 537 $CFG->{audio_hw_channels},
539 sub audio_tab_update; 551 sub audio_tab_update;
540 audio_tab_update; 552 audio_tab_update;
541} 553}
542 554
543sub audio_shutdown { 555sub audio_shutdown {
556 if ($SDL_MIXER) {
557 DC::MixMusic::halt;
558 DC::Mix_AllocateChannels 0;
559 }
560
544 undef $MUSIC_PLAYER; 561 undef $MUSIC_PLAYER;
545 undef $MUSIC_PLAYING_META; 562 undef $MUSIC_PLAYING_META;
546 undef $MUSIC_PLAYING_DATA; 563 undef $MUSIC_PLAYING_DATA;
547 564
548 $MUSIC_WANT = []; 565 $MUSIC_WANT = [];
549 @MUSIC_JINGLE = (); 566 @MUSIC_JINGLE = ();
550 %AUDIO_PLAY = (); 567 %AUDIO_PLAY = ();
551 %AUDIO_CHUNK = (); 568 %AUDIO_CHUNK = ();
552 569
553 DC::MixMusic::halt;
554 DC::Mix_AllocateChannels 0;
555 DC::Mix_CloseAudio if $SDL_MIXER; 570 DC::Mix_CloseAudio if $SDL_MIXER;
556 undef $SDL_MIXER; 571 undef $SDL_MIXER;
572
573 DC::SDL_QuitSubSystem DC::SDL_INIT_AUDIO;
557} 574}
558 575
559############################################################################# 576#############################################################################
560 577
561sub destroy_query_dialog { 578sub destroy_query_dialog {
802 user => $PROFILE->{user}, 819 user => $PROFILE->{user},
803 pass => $PROFILE->{password}, 820 pass => $PROFILE->{password},
804 mapw => $mapw, 821 mapw => $mapw,
805 maph => $maph, 822 maph => $maph,
806 823
824 c_version => {
825 client => "deliantra",
807 client => "$DC::VERSION $] $^O", 826 clientver => $DC::VERSION,
827 gl_vendor => DC::OpenGL::gl_vendor,
828 gl_version => DC::OpenGL::gl_version,
829 },
808 830
809 map_widget => $MAPWIDGET, 831 map_widget => $MAPWIDGET,
810 statusbox => $STATUSBOX, 832 statusbox => $STATUSBOX,
811 map => $MAP, 833 map => $MAP,
812 mapmap => $MAPMAP, 834 mapmap => $MAPMAP,
830 ; 852 ;
831} 853}
832 854
833sub start_game { 855sub start_game {
834 status "logging in..."; 856 status "logging in...";
857
858 my $server = $PROFILE->{host} || $DEFAULT_SERVER;
859 my ($host, $port) = AnyEvent::Socket::parse_hostport $server, "deliantra=13327"
860 or return status "$server: unable to parse server address, try an empty field.";
835 861
836 $LOGIN_BUTTON->set_text ("Logout"); 862 $LOGIN_BUTTON->set_text ("Logout");
837 $SETUP_DIALOG->hide; 863 $SETUP_DIALOG->hide;
838
839 my ($host, $port) = AnyEvent::Socket::parse_hostport $PROFILE->{host}, "deliantra=13327";
840 864
841 $MAP = new DC::Map; 865 $MAP = new DC::Map;
842 866
843 # hack to make SURE we find the IP address all right 867 # hack to make SURE we find the IP address all right
844 # can be removed once AnyEvent::DNS is proven stable. 868 # can be removed once AnyEvent::DNS is proven stable.
845 if ($host eq "gameserver.deliantra.net") { 869 if ($host eq "gameserver.deliantra.net") {
846 AnyEvent::DNS::a "dnstest.deliantra.net", sub { 870 AnyEvent::DNS::a "dnstest.deliantra.net", sub {
847 if ($_[0] ne "80.101.114.108") { # Perl 871 if ($_[0] ne "80.101.114.108") { # P-e-r-l
848 status "dns failure, trying differently"; 872 status "dns failure, trying differently";
849 $host = eval { Socket::inet_ntoa Socket::inet_aton "gameserver.deliantra.net" }; 873 $host = eval { Socket::inet_ntoa Socket::inet_aton "gameserver.deliantra.net" };
850 unless (defined $host) { 874 unless (defined $host) {
851 status "dns failure, using hardcoded address"; 875 status "dns failure, using hardcoded address";
852 $host = "129.13.162.95"; 876 $host = "194.126.175.154";
853 } 877 }
854 } 878 }
855 879
856 dc_connect $host, $port; 880 dc_connect $host, $port;
857 }; 881 };
1027 . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, " 1051 . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, "
1028 . "then disable this option. Changes take effect immdiately.", 1052 . "then disable this option. Changes take effect immdiately.",
1029 on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_movement} = $value; 0 } 1053 on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_movement} = $value; 0 }
1030 ); 1054 );
1031 1055
1056 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Smooth Transitions");
1057 $table->add_at (1, $row++, new DC::UI::CheckBox
1058 state => $CFG->{smooth_transitions},
1059 tooltip => "<b>Smooth Transitions</b> tries to blend the fog of war and lighting smoothly between updates. "
1060 . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, "
1061 . "then disable this option. Requires Smooth Movement and OpenGL Multitexturing. Changes take effect immdiately.",
1062 on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_transitions} = $value; 0 }
1063 );
1064
1065
1032 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Map Scale"); 1066 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Map Scale");
1033 $table->add_at (1, $row++, new DC::UI::Slider 1067 $table->add_at (1, $row++, new DC::UI::Slider
1034 range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], 1068 range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1],
1035 tooltip => "Enlarge or shrink the displayed map. Changes are instant.", 1069 tooltip => "Enlarge or shrink the displayed map. Changes are instant.",
1036 on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 } 1070 on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 }
1048 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fog of War"); 1082 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fog of War");
1049 $table->add_at (1, $row++, new DC::UI::CheckBox 1083 $table->add_at (1, $row++, new DC::UI::CheckBox
1050 state => $CFG->{fow_enable}, 1084 state => $CFG->{fow_enable},
1051 tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.", 1085 tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.",
1052 on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 } 1086 on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 }
1087 );
1088
1089 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Pattern");
1090 $table->add_at (1, $row++, new DC::UI::ImageButton
1091 tex => $DC::MapWidget::TEX_HIDDEN[$CFG->{fow_texture}],
1092 bg => [0.3, 0.3, 0.2],
1093 force_w => 64,
1094 force_h => 64,
1095 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.",
1096 on_activate => sub {
1097 my ($self) = @_;
1098 $CFG->{fow_texture} = ($CFG->{fow_texture} + 1) % @DC::MapWidget::TEX_HIDDEN;
1099 $self->set_texture ($DC::MapWidget::TEX_HIDDEN[$CFG->{fow_texture}]);
1100 $MAPWIDGET->update;
1101 }
1053 ); 1102 );
1054 1103
1055 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Intensity"); 1104 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Intensity");
1056 $table->add_at (1, $row++, new DC::UI::Slider 1105 $table->add_at (1, $row++, new DC::UI::Slider
1057 range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256], 1106 range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256],
1108 ]); 1157 ]);
1109 1158
1110 my $text = !$freq 1159 my $text = !$freq
1111 ? "audio is off" 1160 ? "audio is off"
1112 : "audio is enabled\n" 1161 : "audio is enabled\n"
1162 . "driver: " . DC::SDL_AudioDriverName . "\n"
1113 . "frequency (Hz): $freq\n" 1163 . "frequency (Hz): $freq\n"
1114 . "channels: $chans"; 1164 . "channels: $chans\n"
1165 . "chunk decoders available: " . (join ", ", DC::MixChunk::decoders) . "\n"
1166 . "music decoders available: " . (join ", ", DC::MixMusic::decoders);
1115 1167
1116 $AUDIO_INFO->set_text ($text); 1168 $AUDIO_INFO->set_text ($text);
1117} 1169}
1118 1170
1119sub audio_setup { 1171sub audio_setup {
1122 $vbox->add (my $table = new DC::UI::Table expand => 1, col_expand => [0, 0, 1]); 1174 $vbox->add (my $table = new DC::UI::Table expand => 1, col_expand => [0, 0, 1]);
1123 1175
1124 my $row = 0; 1176 my $row = 0;
1125 1177
1126 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Audio Enable"); 1178 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Audio Enable");
1127 $table->add_at (1, $row++, new DC::UI::CheckBox 1179 $table->add_at (1, $row, new DC::UI::CheckBox
1128 state => $CFG->{audio_enable}, 1180 state => $CFG->{audio_enable},
1129 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.", 1181 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.",
1130 on_changed => sub { $CFG->{audio_enable} = $_[1]; 1 } 1182 on_changed => sub { $CFG->{audio_enable} = $_[1]; 1 }
1183 );
1184 $table->add_at (2, $row++, my $driver = new DC::UI::HBox expand => 1);
1185
1186 $driver->add (new DC::UI::Label align => 1, text => " Audio driver override");
1187 $driver->add (new DC::UI::Entry
1188 text => $CFG->{audio_driver},
1189 template => "dsound1234",
1190 tooltip => "You can override the audio driver to use here. Leaving it empty will result "
1191 . "in Deliantra picking one automatically. GNU/Linux users often prefer specific "
1192 . "drivers though, and can experiment with <b>alsa</b>, <b>dsp</b>, <b>esd</b>, <b>pulse</b>, <b>arts</b>, <b>nas</b> "
1193 . "or other system-specific drivers. Selecting the wrong driver here will simply result"
1194 . "in no sound.",
1195 on_changed => sub { my ($self, $value) = @_; $CFG->{audio_driver} = $value; 1 }
1131 ); 1196 );
1132 1197
1133 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Sound Effects"); 1198 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Sound Effects");
1134 $table->add_at (1, $row, new DC::UI::CheckBox 1199 $table->add_at (1, $row, new DC::UI::CheckBox
1135 expand => 1, state => $CFG->{effects_enable}, 1200 expand => 1, state => $CFG->{effects_enable},
1148 ); 1213 );
1149 1214
1150 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Background Music"); 1215 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Background Music");
1151 $table->add_at (1, $row, new DC::UI::CheckBox 1216 $table->add_at (1, $row, new DC::UI::CheckBox
1152 expand => 1, state => $CFG->{bgm_enable}, 1217 expand => 1, state => $CFG->{bgm_enable},
1153 tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", 1218 tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played. Needs server reconnect to take effect.",
1154 on_changed => sub { 1219 on_changed => sub {
1155 $CFG->{bgm_enable} = $_[1]; 1220 $CFG->{bgm_enable} = $_[1];
1156 $CONN->update_fx_want if $CONN; 1221 $CONN->update_fx_want if $CONN;
1157 audio_music_push; 1222 audio_music_push;
1158 1 1223 1
1169 c_colspan => 2, expand => 1, 1234 c_colspan => 2, expand => 1,
1170 value => $CFG->{audio_hw_frequency}, 1235 value => $CFG->{audio_hw_frequency},
1171 options => [ 1236 options => [
1172 [ 0, "default" , "Use System Default"], 1237 [ 0, "default" , "Use System Default"],
1173 [11025, "11 kHz" , "11kHz (low quality)"], 1238 [11025, "11 kHz" , "11kHz (low quality)"],
1174 [22050, "22 kHz" , "22kHz (reduced quality)"], 1239 [22050, "22 kHz" , "22kHz (reduced quality, recommended)"],
1175 [44100, "44.1 kHz", "44.1kHz (cd quality)"], 1240 [44100, "44.1 kHz", "44.1kHz (cd quality)"],
1176 [48000, "48 kHz" , "48kHz (studio quality)"], 1241 [48000, "48 kHz" , "48kHz (studio quality, not recommended)"],
1177 ], 1242 ],
1178 tooltip => "The sampling frequency to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.", 1243 tooltip => "The sampling frequency to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.",
1179 on_changed => sub { 1244 on_changed => sub {
1180 $CFG->{audio_hw_frequency} = $_[1]; 1245 $CFG->{audio_hw_frequency} = $_[1];
1181 audio_tab_update; 1246 audio_tab_update;
1205 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Latency"); 1270 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Latency");
1206 $table->add_at (1, $row++, $AUDIO_HW_CHUNKSIZE = new DC::UI::Selector 1271 $table->add_at (1, $row++, $AUDIO_HW_CHUNKSIZE = new DC::UI::Selector
1207 c_colspan => 2, expand => 1, 1272 c_colspan => 2, expand => 1,
1208 value => $CFG->{audio_hw_chunksize}, 1273 value => $CFG->{audio_hw_chunksize},
1209 tooltip => "The guarenteed latency. Lower is better, but also more cpu-intensive and might cause stuttering. If music playback " 1274 tooltip => "The guarenteed latency. Lower is better, but also more cpu-intensive and might cause stuttering. If music playback "
1210 . "is stuttering, increase this value. Values of 50-100ms are optimal.", 1275 . "is stuttering, increase this value. Values of 50-150ms are optimal.",
1211 on_changed => sub { 1276 on_changed => sub {
1212 $CFG->{audio_hw_chunksize} = $_[1]; 1277 $CFG->{audio_hw_chunksize} = $_[1];
1213 audio_tab_update; 1278 audio_tab_update;
1214 1 1279 1
1215 } 1280 }
1295 &set_gauge_window_fontsize; 1360 &set_gauge_window_fontsize;
1296 1361
1297 $win 1362 $win
1298} 1363}
1299 1364
1365our $BW_WATCHER;
1366
1367sub debug_toggle($) {
1368 $DELIANTRA_DEBUG ^= $_[0];
1369
1370 if ($DELIANTRA_DEBUG & 16) {
1371 $BW_WATCHER = EV::periodic 0, 1, 0, sub {
1372 return unless $CONN;
1373 debug sprintf "%8.2gKB/s", $CONN->{octets_in} / 1e3;
1374 $CONN->{octets_in} = 0;
1375 };
1376 } else {
1377 undef $BW_WATCHER;
1378 }
1379
1380}
1381
1300sub debug_setup { 1382sub debug_setup {
1301 my $table = new DC::UI::Table; 1383 my $table = new DC::UI::Table;
1302 1384
1303 $table->add_at (0, 0, new DC::UI::Label text => "Widget Borders"); 1385 $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 }); 1386 $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"); 1387 $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 }); 1388 $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"); 1389 $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 }); 1390 $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"); 1391 $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 }); 1392 $table->add_at (1, 3, new DC::UI::CheckBox on_changed => sub { debug_toggle 8; 0 });
1393 $table->add_at (0, 4, new DC::UI::Label text => "Show Bandwidth");
1394 $table->add_at (1, 4, new DC::UI::CheckBox on_changed => sub { debug_toggle 16; 0 });
1395
1311 $table->add_at (0, 4, new DC::UI::Button text => "die on click(tm)", on_activate => sub { &DC::debug() } ); 1396 $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# 1397 $table->add_at (0, 7, new DC::UI::TextEdit text => "line1\0152\0153\nµikachu\nづx゙つ゛");#d#
1314 1398
1315 $table->add_at (7,7, my $t = new DC::UI::Table expand => 0); 1399 $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); 1400 $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 ); 1401 $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); 1402 $t->add_at (1,2, new DC::UI::Label text => "c c", c_rowspan => 1, c_colspan => 2);
1439 para => ["Paralysation", 1523 para => ["Paralysation",
1440 "<b>Paralysation</b> (this resistance affects the chance you get paralysed)"], 1524 "<b>Paralysation</b> (this resistance affects the chance you get paralysed)"],
1441 deat => ["Death", 1525 deat => ["Death",
1442 "<b>Death</b> (resistance against death spells)"], 1526 "<b>Death</b> (resistance against death spells)"],
1443 phys => ["Physical", 1527 phys => ["Physical",
1444 "<b>Physical</b> (this is the resistance against physical attacks, like when a monster hit you in melee combat. The value displayed here is also displayed in the 'Arm' field on the left.)"], 1528 "<b>Physical</b> (this is the resistance against physical attacks, like when a monster hit you in melee combat. The value displayed here is also displayed as the 'Arm' secondary stat.)"],
1445 blind => ["Blind", 1529 blind => ["Blind",
1446 "<b>Blind</b> (blind resistance affects the chance of a successful blinding attack)"], 1530 "<b>Blind</b> (blind resistance affects the chance of a successful blinding attack)"],
1447 fear => ["Fear", 1531 fear => ["Fear",
1448 "<b>Fear</b> (this attack will drive you away from monsters who cast this and hit you successfully, being resistant to this helps a lot when fighting those monsters)"], 1532 "<b>Fear</b> (this attack will drive you away from monsters who cast this and hit you successfully, being resistant to this helps a lot when fighting those monsters)"],
1449 tund => ["Turn undead", 1533 tund => ["Turn undead",
1639 child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]), 1723 child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]),
1640 ); 1724 );
1641 1725
1642 $table->add_at (0, 4, new DC::UI::Label align => 1, text => "Username"); 1726 $table->add_at (0, 4, new DC::UI::Label align => 1, text => "Username");
1643 $table->add_at (1, 4, new DC::UI::Entry 1727 $table->add_at (1, 4, new DC::UI::Entry
1644 text => $CFG->{profile}{default}{user}, 1728 text => $PROFILE->{user},
1645 tooltip => "The name of your character on the server. The name is case-sensitive!", 1729 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 } 1730 on_changed => sub { my ($self, $value) = @_; $PROFILE->{user} = $value; 1 }
1647 ); 1731 );
1648 1732
1649 $table->add_at (0, 5, new DC::UI::Label align => 1, text => "Password"); 1733 $table->add_at (0, 5, new DC::UI::Label align => 1, text => "Password");
1650 $table->add_at (1, 5, new DC::UI::Entry 1734 $table->add_at (1, 5, new DC::UI::Entry
1651 text => $CFG->{profile}{default}{password}, 1735 text => $PROFILE->{password},
1652 hidden => 1, 1736 hidden => 1,
1653 tooltip => "The password for your character.", 1737 tooltip => "The password for your character.",
1654 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value; 1 } 1738 on_changed => sub { my ($self, $value) = @_; $PROFILE->{password} = $value; 1 }
1655 ); 1739 );
1656 1740
1657 $table->add_at (1, 11, $LOGIN_BUTTON = new DC::UI::Button 1741 $table->add_at (1, 11, $LOGIN_BUTTON = new DC::UI::Button
1658 expand => 1, 1742 expand => 1,
1659 text => "Login / Register", 1743 text => "Login / Register",
1695 $table->add_at (1, $row, my $vbox = new DC::UI::VBox); 1779 $table->add_at (1, $row, my $vbox = new DC::UI::VBox);
1696 1780
1697 $vbox->add ( 1781 $vbox->add (
1698 $HOST_ENTRY = new DC::UI::Entry 1782 $HOST_ENTRY = new DC::UI::Entry
1699 expand => 1, 1783 expand => 1,
1700 text => $CFG->{profile}{default}{host}, 1784 text => $PROFILE->{host},
1701 tooltip => "The hostname or ip address of the Deliantra server to connect to (e.g. <b>gameserver.deliantra.net</b>)", 1785 tooltip => "The hostname or ip address of the Deliantra server to connect to (e.g. <b>gameserver.deliantra.net</b>)",
1702 on_changed => sub { 1786 on_changed => sub {
1703 my ($self, $value) = @_; 1787 my ($self, $value) = @_;
1704 $CFG->{profile}{default}{host} = $value; 1788 $PROFILE->{host} = $value;
1705 1 1789 1
1706 } 1790 }
1707 ); 1791 );
1708 1792
1709 if (0) { #d# disabled 1793 if (0) { #d# disabled
1908 $r 1992 $r
1909} 1993}
1910 1994
1911my %SORT_ORDER = ( 1995my %SORT_ORDER = (
1912 type => sub { 1996 type => sub {
1997 use sort 'stable';
1913 sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ 1998 sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_
1914 }, 1999 },
1915 mtime => sub { 2000 mtime => sub {
2001 use sort 'stable';
1916 my $NOW = time; 2002 my $NOW = time;
1917 sort { 2003 sort {
1918 my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; 2004 my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6;
1919 my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; 2005 my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6;
1920 2006
1921 ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED) 2007 ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED)
1922 or $btime <=> $atime 2008 or $btime <=> $atime
1923 or $a->{type} <=> $b->{type} 2009 or $a->{type} <=> $b->{type}
1924 } @_ 2010 } @_
1925 }, 2011 },
1926 weight => sub { sort { 2012 weight => sub {
2013 use sort 'stable';
2014 sort {
1927 $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) 2015 $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1)
1928 or $a->{type} <=> $b->{type} 2016 or $a->{type} <=> $b->{type}
1929 } @_ }, 2017 } @_
2018 },
1930); 2019);
1931 2020
1932sub inventory_widget { 2021sub inventory_widget {
1933 my $hb = new DC::UI::HBox homogeneous => 1; 2022 my $hb = new DC::UI::HBox homogeneous => 1;
1934 2023
2375 2464
2376 $dialog->show; 2465 $dialog->show;
2377 }; 2466 };
2378} 2467}
2379 2468
2380sub sdl_init {
2381 DC::SDL_Init DC::SDL_INIT_AUDIO #| DC::SDL_NOPARACHUTE
2382 and die "SDL::Init failed!\n";
2383}
2384
2385sub video_init { 2469sub video_init {
2386 DC::set_theme $CFG->{uitheme}; 2470 DC::set_theme $CFG->{uitheme};
2387 2471
2388 DC::SDL_InitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT; 2472 DC::SDL_InitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT;
2389 $SDL_REINIT = 0; 2473 $SDL_REINIT = 0;
2448 2532
2449 $DEBUG_STATUS = new DC::UI::Label 2533 $DEBUG_STATUS = new DC::UI::Label
2450 padding => 0, 2534 padding => 0,
2451 z => 100, 2535 z => 100,
2452 force_x => "max", 2536 force_x => "max",
2453 force_y => 0; 2537 force_y => 20;
2454 $DEBUG_STATUS->show; 2538 $DEBUG_STATUS->show;
2455 2539
2456 $STATUSBOX = new DC::UI::Statusbox; 2540 $STATUSBOX = new DC::UI::Statusbox;
2457 2541
2458 $MODBOX = new DC::UI::Label 2542 $MODBOX = new DC::UI::Label
2565 2649
2566 $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1, 1]); 2650 $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1, 1]);
2567 $MODE_SLIDER->emit (changed => $CFG->{sdl_mode}); 2651 $MODE_SLIDER->emit (changed => $CFG->{sdl_mode});
2568 2652
2569 $CAVEAT_LABEL->set_text ("None :)"); 2653 $CAVEAT_LABEL->set_text ("None :)");
2654 $CAVEAT_LABEL->set_text ("Apple/NVIDIA Texture bug (slow)")
2655 if $DC::OpenGL::APPLE_NVIDIA_BUG;
2570 $CAVEAT_LABEL->set_text ("Software Rendering (very slow)") 2656 $CAVEAT_LABEL->set_text ("Software Rendering (very slow)")
2571 unless DC::SDL_GL_GetAttribute DC::SDL_GL_ACCELERATED_VISUAL; 2657 unless DC::SDL_GL_GetAttribute DC::SDL_GL_ACCELERATED_VISUAL;
2572 2658
2573 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); 2659 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]);
2574} 2660}
2584my $animate_timer; 2670my $animate_timer;
2585 2671
2586my $fps = 9; 2672my $fps = 9;
2587 2673
2588sub force_refresh { 2674sub force_refresh {
2589 if ($ENV{CFPLUS_DEBUG} & 4) { 2675 if ($DELIANTRA_DEBUG & 4) {
2590 $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; 2676 $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02;
2591 debug sprintf "%3.2f", $fps; 2677 debug sprintf "%3.2f", $fps;
2592 } 2678 }
2593 2679
2594 undef $WANT_REFRESH; 2680 undef $WANT_REFRESH;
2707 fullscreen => 1, 2793 fullscreen => 1,
2708 fast => 0, 2794 fast => 0,
2709 force_opengl11 => undef, 2795 force_opengl11 => undef,
2710 disable_alpha => 0, 2796 disable_alpha => 0,
2711 smooth_movement => 1, 2797 smooth_movement => 1,
2798 smooth_transitions => 1,
2712 texture_compression => 1, 2799 texture_compression => 1,
2713 map_scale => 1, 2800 map_scale => 1,
2714 fow_enable => 1, 2801 fow_enable => 1,
2715 fow_intensity => 0, 2802 fow_intensity => 0,
2803 fow_texture => 0,
2716 map_smoothing => 1, 2804 map_smoothing => 1,
2717 gui_fontsize => 1, 2805 gui_fontsize => 1,
2718 log_fontsize => 0.7, 2806 log_fontsize => 0.7,
2719 gauge_fontsize => 1, 2807 gauge_fontsize => 1,
2720 gauge_size => 0.35, 2808 gauge_size => 0.35,
2738 shift_fire_stop => 0, 2826 shift_fire_stop => 0,
2739 uitheme => "wood", 2827 uitheme => "wood",
2740 map_shift_x => -24, # arbitrary 2828 map_shift_x => -24, # arbitrary
2741 map_shift_y => +24, # arbitrary 2829 map_shift_y => +24, # arbitrary
2742 ); 2830 );
2743 2831
2744 while (my ($k, $v) = each %DEF_CFG) { 2832 while (my ($k, $v) = each %DEF_CFG) {
2745 $CFG->{$k} = $v unless exists $CFG->{$k}; 2833 $CFG->{$k} = $v unless exists $CFG->{$k};
2746 } 2834 }
2747 2835
2748 $CFG->{profile}{default}{host} ||= "gameserver.deliantra.net"; 2836 my @args = @ARGV;
2837
2838 # OS X passes some process serial number of other shit. they
2839 # could have used an env var or any other sane mechanism. but
2840 # would it be os x then? no...
2841 shift @args if $args[0] =~ /^-psn_/;
2842
2843 my $profile = 'default';
2844
2845 for (my $i = 0; $i < @args; $i++) {
2846 if ($args[$i] =~ /^--?profile$/) {
2847 $profile = $args[$i + 1];
2848 splice @args, $i, 2, ();
2849 $i = 0;
2850 } elsif ($args[$i] =~ /^--?h/) {
2851 print STDERR "Usage: $0 [--profile name] [host [user [password]]]\n";
2852 exit 0;
2853 }
2854 }
2855
2856 $CFG->{profile}{$profile} ||= {};
2749 $PROFILE = $CFG->{profile}{default}; 2857 $PROFILE = $CFG->{profile}{$profile};
2858 $PROFILE->{host} ||= "gameserver.deliantra.net";
2859
2860 $PROFILE->{host} = $args[0] if @args > 0;
2861 $PROFILE->{user} = $args[1] if @args > 1;
2862 $PROFILE->{password} = $args[2] if @args > 2;
2750 2863
2751 # convert old bindings (only default profile matters) 2864 # convert old bindings (only default profile matters)
2752 if (my $bindings = delete $PROFILE->{bindings}) { 2865 if (my $bindings = delete $PROFILE->{bindings}) {
2753 while (my ($mod, $syms) = each %$bindings) { 2866 while (my ($mod, $syms) = each %$bindings) {
2754 while (my ($sym, $cmds) = each %$syms) { 2867 while (my ($sym, $cmds) = each %$syms) {
2757 action => $cmds, 2870 action => $cmds,
2758 }; 2871 };
2759 } 2872 }
2760 } 2873 }
2761 } 2874 }
2762
2763 sdl_init;
2764 2875
2765 $ENV{FONTCONFIG_FILE} = DC::find_rcfile "fonts/fonts.conf"; 2876 $ENV{FONTCONFIG_FILE} = DC::find_rcfile "fonts/fonts.conf";
2766 $ENV{FONTCONFIG_DIR} = DC::find_rcfile "fonts"; 2877 $ENV{FONTCONFIG_DIR} = DC::find_rcfile "fonts";
2767 2878
2768 { 2879 {
2777 DejaVuSansMono-BoldOblique.ttf 2888 DejaVuSansMono-BoldOblique.ttf
2778 mona.ttf 2889 mona.ttf
2779 ); 2890 );
2780 2891
2781 DC::add_font $_ for @fonts; 2892 DC::add_font $_ for @fonts;
2782 2893
2783 $FONT_PROP = new_from_file DC::Font $fonts[0]; 2894 $FONT_PROP = new_from_file DC::Font $fonts[0];
2784 $FONT_FIXED = new_from_file DC::Font $fonts[1]; 2895 $FONT_FIXED = new_from_file DC::Font $fonts[1];
2785 2896
2786 $FONT_PROP->make_default; 2897 $FONT_PROP->make_default;
2787 2898
2799# } 2910# }
2800# my $t2 = Time::HiRes::time; 2911# my $t2 = Time::HiRes::time;
2801# warn $t2-$t1; 2912# warn $t2-$t1;
2802# } 2913# }
2803 2914
2915 DC::IMG_Init;
2804 video_init; 2916 video_init;
2805 audio_init; 2917 audio_init;
2806 } 2918 }
2807 2919
2808 show_tip_of_the_day if $CFG->{show_tips}; 2920 show_tip_of_the_day if $CFG->{show_tips};
2810 our $STARTUP_CANCEL = EV::idle sub { 2922 our $STARTUP_CANCEL = EV::idle sub {
2811 undef $::STARTUP_CANCEL; 2923 undef $::STARTUP_CANCEL;
2812 $startup_done->(); 2924 $startup_done->();
2813 }; 2925 };
2814 2926
2927 debug_toggle 0;
2928
2815 delete $SIG{__DIE__}; 2929 delete $SIG{__DIE__};
2816 EV::loop; 2930 EV::loop;
2817 2931
2818 DC::write_cfg if $CFG->{config_autosave}; 2932 DC::write_cfg if $CFG->{config_autosave};
2819 2933
2831 2945
2832deliantra - A Deliantra MORPG game client 2946deliantra - A Deliantra MORPG game client
2833 2947
2834=head1 SYNOPSIS 2948=head1 SYNOPSIS
2835 2949
2836Just run it - no commandline arguments are supported. 2950 deliantra [--profile name] [host [user [password]]]
2951 deliantra --help
2837 2952
2838=head1 USAGE 2953=head1 USAGE
2839 2954
2840deliantra utilises OpenGL for all UI elements and the game. It is supposed to 2955The deliantra client utilises OpenGL for all UI elements and the game. It
2841be used in fullscreen mode and interactively. 2956is supposed to be used in fullscreen mode and interactively.
2842 2957
2843=head1 DEBUGGING 2958=head1 DEBUGGING
2844 2959
2845
2846CFPLUS_DEBUG - environment variable 2960DELIANTRA_DEBUG - environment variable
2847 2961
2848 1 draw borders around widgets 2962 1 draw borders around widgets
2849 2 add low-level widget info to tooltips 2963 2 add low-level widget info to tooltips
2850 4 show fps 2964 4 show fps
2851 8 suppress tooltips 2965 8 suppress tooltips
2966 16 show bandwidth downstream
2852 2967
2853=head1 AUTHOR 2968=head1 AUTHOR
2854 2969
2855Marc Lehmann <deliantra@schmorp.de>, Robin Redeker <elmex@ta-sa.org> 2970Marc Lehmann <deliantra@schmorp.de>, Robin Redeker <elmex@ta-sa.org>
2856 2971

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines