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.90 by root, Mon Jan 12 03:49:35 2009 UTC vs.
Revision 1.115 by root, Sat Apr 24 09:53:09 2010 UTC

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
37use strict; 37use common::sense;
38use utf8;
39 38
40use Carp 'verbose'; 39use Carp 'verbose';
41 40
42# do things only needed for single-binary version (par) 41# do things only needed for single-binary version (par)
43BEGIN { 42BEGIN {
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
73BEGIN { 70BEGIN {
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
139my $MAX_FPS = 60; 136my $MAX_FPS = 60;
140 137
138our $DEFAULT_SERVER = "gameserver.deliantra.net";
139
141our $META_SERVER = "http://metaserver.schmorp.de/current.json"; 140our $META_SERVER = "http://metaserver.schmorp.de/current.json";
142 141
143our $LAST_REFRESH; 142our $LAST_REFRESH;
144our $NOW; 143our $NOW;
145 144
146our $CFG; 145our $CFG;
147our $PROFILE; # current profile 146our $PROFILE; # current profile
148our $FAST; # fast, low-quality mode, possibly useful for software-rendering 147our $FAST; # fast, low-quality mode, possibly useful for software-rendering
148our $DELIANTRA_DEBUG = $ENV{DELIANTRA_DEBUG} * 1;
149 149
150our $WANT_REFRESH; 150our $WANT_REFRESH;
151 151
152our $MODE_SLIDER; 152our $MODE_SLIDER;
153our $CAVEAT_LABEL; 153our $CAVEAT_LABEL;
518 audio_music_push; 518 audio_music_push;
519} 519}
520 520
521sub audio_init { 521sub 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
545sub audio_shutdown { 554sub 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 = [];
552 %AUDIO_PLAY = (); 566 %AUDIO_PLAY = ();
553 %AUDIO_CHUNK = (); 567 %AUDIO_CHUNK = ();
554 568
555 DC::Mix_CloseAudio if $SDL_MIXER; 569 DC::Mix_CloseAudio if $SDL_MIXER;
556 undef $SDL_MIXER; 570 undef $SDL_MIXER;
571
572 DC::SDL_QuitSubSystem DC::SDL_INIT_AUDIO;
557} 573}
558 574
559############################################################################# 575#############################################################################
560 576
561sub destroy_query_dialog { 577sub destroy_query_dialog {
802 user => $PROFILE->{user}, 818 user => $PROFILE->{user},
803 pass => $PROFILE->{password}, 819 pass => $PROFILE->{password},
804 mapw => $mapw, 820 mapw => $mapw,
805 maph => $maph, 821 maph => $maph,
806 822
823 c_version => {
824 client => "deliantra",
807 client => "$DC::VERSION $] $^O", 825 clientver => $DC::VERSION,
826 gl_vendor => DC::OpenGL::gl_vendor,
827 gl_version => DC::OpenGL::gl_version,
828 },
808 829
809 map_widget => $MAPWIDGET, 830 map_widget => $MAPWIDGET,
810 statusbox => $STATUSBOX, 831 statusbox => $STATUSBOX,
811 map => $MAP, 832 map => $MAP,
812 mapmap => $MAPMAP, 833 mapmap => $MAPMAP,
818 839
819 on_connect => sub { 840 on_connect => sub {
820 if ($_[0]) { 841 if ($_[0]) {
821 DC::lowdelay fileno $CONN->{fh}; 842 DC::lowdelay fileno $CONN->{fh};
822 843
823 status "login successful"; 844 status "successfully connected to the server";
824 } else { 845 } else {
825 undef $CONN; 846 undef $CONN;
826 status "unable to connect: $!"; 847 status "unable to connect: $!";
827 stop_game(); 848 stop_game();
828 } 849 }
830 ; 851 ;
831} 852}
832 853
833sub start_game { 854sub start_game {
834 status "logging in..."; 855 status "logging in...";
856
857 my $server = $PROFILE->{host} || $DEFAULT_SERVER;
858 my ($host, $port) = AnyEvent::Socket::parse_hostport $server, "deliantra=13327"
859 or return status "$server: unable to parse server address, try an empty field.";
835 860
836 $LOGIN_BUTTON->set_text ("Logout"); 861 $LOGIN_BUTTON->set_text ("Logout");
837 $SETUP_DIALOG->hide; 862 $SETUP_DIALOG->hide;
838
839 my ($host, $port) = AnyEvent::Socket::parse_hostport $PROFILE->{host}, "deliantra=13327";
840 863
841 $MAP = new DC::Map; 864 $MAP = new DC::Map;
842 865
843 # hack to make SURE we find the IP address all right 866 # hack to make SURE we find the IP address all right
844 # can be removed once AnyEvent::DNS is proven stable. 867 # can be removed once AnyEvent::DNS is proven stable.
845 if ($host eq "gameserver.deliantra.net") { 868 if ($host eq "gameserver.deliantra.net") {
846 AnyEvent::DNS::a "dnstest.deliantra.net", sub { 869 AnyEvent::DNS::a "dnstest.deliantra.net", sub {
847 if ($_[0] ne "80.101.114.108") { # Perl 870 if ($_[0] ne "80.101.114.108") { # P-e-r-l
871 status "dns failure, trying differently";
872 $host = eval { Socket::inet_ntoa Socket::inet_aton "gameserver.deliantra.net" };
873 unless (defined $host) {
848 status "dns failure, using hardcoded address"; 874 status "dns failure, using hardcoded address";
849 $host = "129.13.162.95"; 875 $host = "194.126.175.154";
876 }
850 } 877 }
851 878
852 dc_connect $host, $port; 879 dc_connect $host, $port;
853 }; 880 };
854 } else { 881 } else {
1023 . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, " 1050 . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, "
1024 . "then disable this option. Changes take effect immdiately.", 1051 . "then disable this option. Changes take effect immdiately.",
1025 on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_movement} = $value; 0 } 1052 on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_movement} = $value; 0 }
1026 ); 1053 );
1027 1054
1055 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Smooth Transitions");
1056 $table->add_at (1, $row++, new DC::UI::CheckBox
1057 state => $CFG->{smooth_transitions},
1058 tooltip => "<b>Smooth Transitions</b> tries to blend the fog of war and lighting smoothly between updates. "
1059 . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, "
1060 . "then disable this option. Requires Smooth Movement and OpenGL Multitexturing. Changes take effect immdiately.",
1061 on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_transitions} = $value; 0 }
1062 );
1063
1064
1028 $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");
1029 $table->add_at (1, $row++, new DC::UI::Slider 1066 $table->add_at (1, $row++, new DC::UI::Slider
1030 range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], 1067 range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1],
1031 tooltip => "Enlarge or shrink the displayed map. Changes are instant.", 1068 tooltip => "Enlarge or shrink the displayed map. Changes are instant.",
1032 on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 } 1069 on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 }
1044 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fog of War"); 1081 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fog of War");
1045 $table->add_at (1, $row++, new DC::UI::CheckBox 1082 $table->add_at (1, $row++, new DC::UI::CheckBox
1046 state => $CFG->{fow_enable}, 1083 state => $CFG->{fow_enable},
1047 tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.", 1084 tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.",
1048 on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 } 1085 on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 }
1086 );
1087
1088 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Pattern");
1089 $table->add_at (1, $row++, new DC::UI::ImageButton
1090 tex => $DC::MapWidget::TEX_HIDDEN[$CFG->{fow_texture}],
1091 bg => [0.3, 0.3, 0.2],
1092 force_w => 64,
1093 force_h => 64,
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.",
1095 on_activate => sub {
1096 my ($self) = @_;
1097 $CFG->{fow_texture} = ($CFG->{fow_texture} + 1) % @DC::MapWidget::TEX_HIDDEN;
1098 $self->set_texture ($DC::MapWidget::TEX_HIDDEN[$CFG->{fow_texture}]);
1099 $MAPWIDGET->update;
1100 }
1049 ); 1101 );
1050 1102
1051 $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");
1052 $table->add_at (1, $row++, new DC::UI::Slider 1104 $table->add_at (1, $row++, new DC::UI::Slider
1053 range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256], 1105 range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256],
1104 ]); 1156 ]);
1105 1157
1106 my $text = !$freq 1158 my $text = !$freq
1107 ? "audio is off" 1159 ? "audio is off"
1108 : "audio is enabled\n" 1160 : "audio is enabled\n"
1161 . "driver: " . DC::SDL_AudioDriverName . "\n"
1109 . "frequency (Hz): $freq\n" 1162 . "frequency (Hz): $freq\n"
1110 . "channels: $chans"; 1163 . "channels: $chans\n"
1164 . "chunk decoders available: " . (join ", ", DC::MixChunk::decoders) . "\n"
1165 . "music decoders available: " . (join ", ", DC::MixMusic::decoders);
1111 1166
1112 $AUDIO_INFO->set_text ($text); 1167 $AUDIO_INFO->set_text ($text);
1113} 1168}
1114 1169
1115sub audio_setup { 1170sub audio_setup {
1118 $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]);
1119 1174
1120 my $row = 0; 1175 my $row = 0;
1121 1176
1122 $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");
1123 $table->add_at (1, $row++, new DC::UI::CheckBox 1178 $table->add_at (1, $row, new DC::UI::CheckBox
1124 state => $CFG->{audio_enable}, 1179 state => $CFG->{audio_enable},
1125 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.",
1126 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 }
1127 ); 1195 );
1128 1196
1129 $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");
1130 $table->add_at (1, $row, new DC::UI::CheckBox 1198 $table->add_at (1, $row, new DC::UI::CheckBox
1131 expand => 1, state => $CFG->{effects_enable}, 1199 expand => 1, state => $CFG->{effects_enable},
1144 ); 1212 );
1145 1213
1146 $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");
1147 $table->add_at (1, $row, new DC::UI::CheckBox 1215 $table->add_at (1, $row, new DC::UI::CheckBox
1148 expand => 1, state => $CFG->{bgm_enable}, 1216 expand => 1, state => $CFG->{bgm_enable},
1149 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.",
1150 on_changed => sub { 1218 on_changed => sub {
1151 $CFG->{bgm_enable} = $_[1]; 1219 $CFG->{bgm_enable} = $_[1];
1152 $CONN->update_fx_want if $CONN; 1220 $CONN->update_fx_want if $CONN;
1153 audio_music_push; 1221 audio_music_push;
1154 1 1222 1
1165 c_colspan => 2, expand => 1, 1233 c_colspan => 2, expand => 1,
1166 value => $CFG->{audio_hw_frequency}, 1234 value => $CFG->{audio_hw_frequency},
1167 options => [ 1235 options => [
1168 [ 0, "default" , "Use System Default"], 1236 [ 0, "default" , "Use System Default"],
1169 [11025, "11 kHz" , "11kHz (low quality)"], 1237 [11025, "11 kHz" , "11kHz (low quality)"],
1170 [22050, "22 kHz" , "22kHz (reduced quality)"], 1238 [22050, "22 kHz" , "22kHz (reduced quality, recommended)"],
1171 [44100, "44.1 kHz", "44.1kHz (cd quality)"], 1239 [44100, "44.1 kHz", "44.1kHz (cd quality)"],
1172 [48000, "48 kHz" , "48kHz (studio quality)"], 1240 [48000, "48 kHz" , "48kHz (studio quality, not recommended)"],
1173 ], 1241 ],
1174 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.",
1175 on_changed => sub { 1243 on_changed => sub {
1176 $CFG->{audio_hw_frequency} = $_[1]; 1244 $CFG->{audio_hw_frequency} = $_[1];
1177 audio_tab_update; 1245 audio_tab_update;
1201 $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");
1202 $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
1203 c_colspan => 2, expand => 1, 1271 c_colspan => 2, expand => 1,
1204 value => $CFG->{audio_hw_chunksize}, 1272 value => $CFG->{audio_hw_chunksize},
1205 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 "
1206 . "is stuttering, increase this value. Values of 50-100ms are optimal.", 1274 . "is stuttering, increase this value. Values of 50-150ms are optimal.",
1207 on_changed => sub { 1275 on_changed => sub {
1208 $CFG->{audio_hw_chunksize} = $_[1]; 1276 $CFG->{audio_hw_chunksize} = $_[1];
1209 audio_tab_update; 1277 audio_tab_update;
1210 1 1278 1
1211 } 1279 }
1291 &set_gauge_window_fontsize; 1359 &set_gauge_window_fontsize;
1292 1360
1293 $win 1361 $win
1294} 1362}
1295 1363
1364our $BW_WATCHER;
1365
1366sub 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
1296sub debug_setup { 1381sub debug_setup {
1297 my $table = new DC::UI::Table; 1382 my $table = new DC::UI::Table;
1298 1383
1299 $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");
1300 $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 });
1301 $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");
1302 $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 });
1303 $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");
1304 $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 });
1305 $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");
1306 $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
1307 $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() } );
1308
1309 $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#
1310 1397
1311 $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);
1312 $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);
1313 $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 );
1314 $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);
1635 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]),
1636 ); 1723 );
1637 1724
1638 $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");
1639 $table->add_at (1, 4, new DC::UI::Entry 1726 $table->add_at (1, 4, new DC::UI::Entry
1640 text => $CFG->{profile}{default}{user}, 1727 text => $PROFILE->{user},
1641 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!",
1642 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value; 1 } 1729 on_changed => sub { my ($self, $value) = @_; $PROFILE->{user} = $value; 1 }
1643 ); 1730 );
1644 1731
1645 $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");
1646 $table->add_at (1, 5, new DC::UI::Entry 1733 $table->add_at (1, 5, new DC::UI::Entry
1647 text => $CFG->{profile}{default}{password}, 1734 text => $PROFILE->{password},
1648 hidden => 1, 1735 hidden => 1,
1649 tooltip => "The password for your character.", 1736 tooltip => "The password for your character.",
1650 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value; 1 } 1737 on_changed => sub { my ($self, $value) = @_; $PROFILE->{password} = $value; 1 }
1651 ); 1738 );
1652 1739
1653 $table->add_at (1, 11, $LOGIN_BUTTON = new DC::UI::Button 1740 $table->add_at (1, 11, $LOGIN_BUTTON = new DC::UI::Button
1654 expand => 1, 1741 expand => 1,
1655 text => "Login / Register", 1742 text => "Login / Register",
1691 $table->add_at (1, $row, my $vbox = new DC::UI::VBox); 1778 $table->add_at (1, $row, my $vbox = new DC::UI::VBox);
1692 1779
1693 $vbox->add ( 1780 $vbox->add (
1694 $HOST_ENTRY = new DC::UI::Entry 1781 $HOST_ENTRY = new DC::UI::Entry
1695 expand => 1, 1782 expand => 1,
1696 text => $CFG->{profile}{default}{host}, 1783 text => $PROFILE->{host},
1697 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>)",
1698 on_changed => sub { 1785 on_changed => sub {
1699 my ($self, $value) = @_; 1786 my ($self, $value) = @_;
1700 $CFG->{profile}{default}{host} = $value; 1787 $PROFILE->{host} = $value;
1701 1 1788 1
1702 } 1789 }
1703 ); 1790 );
1704 1791
1705 if (0) { #d# disabled 1792 if (0) { #d# disabled
1904 $r 1991 $r
1905} 1992}
1906 1993
1907my %SORT_ORDER = ( 1994my %SORT_ORDER = (
1908 type => sub { 1995 type => sub {
1996 use sort 'stable';
1909 sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ 1997 sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_
1910 }, 1998 },
1911 mtime => sub { 1999 mtime => sub {
2000 use sort 'stable';
1912 my $NOW = time; 2001 my $NOW = time;
1913 sort { 2002 sort {
1914 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;
1915 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;
1916 2005
1917 ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED) 2006 ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED)
1918 or $btime <=> $atime 2007 or $btime <=> $atime
1919 or $a->{type} <=> $b->{type} 2008 or $a->{type} <=> $b->{type}
1920 } @_ 2009 } @_
1921 }, 2010 },
1922 weight => sub { sort { 2011 weight => sub {
2012 use sort 'stable';
2013 sort {
1923 $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) 2014 $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1)
1924 or $a->{type} <=> $b->{type} 2015 or $a->{type} <=> $b->{type}
1925 } @_ }, 2016 } @_
2017 },
1926); 2018);
1927 2019
1928sub inventory_widget { 2020sub inventory_widget {
1929 my $hb = new DC::UI::HBox homogeneous => 1; 2021 my $hb = new DC::UI::HBox homogeneous => 1;
1930 2022
2371 2463
2372 $dialog->show; 2464 $dialog->show;
2373 }; 2465 };
2374} 2466}
2375 2467
2376sub sdl_init {
2377 DC::SDL_Init DC::SDL_INIT_AUDIO #| DC::SDL_NOPARACHUTE
2378 and die "SDL::Init failed!\n";
2379}
2380
2381sub video_init { 2468sub video_init {
2382 DC::set_theme $CFG->{uitheme}; 2469 DC::set_theme $CFG->{uitheme};
2383 2470
2384 DC::SDL_InitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT; 2471 DC::SDL_InitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT;
2385 $SDL_REINIT = 0; 2472 $SDL_REINIT = 0;
2444 2531
2445 $DEBUG_STATUS = new DC::UI::Label 2532 $DEBUG_STATUS = new DC::UI::Label
2446 padding => 0, 2533 padding => 0,
2447 z => 100, 2534 z => 100,
2448 force_x => "max", 2535 force_x => "max",
2449 force_y => 0; 2536 force_y => 20;
2450 $DEBUG_STATUS->show; 2537 $DEBUG_STATUS->show;
2451 2538
2452 $STATUSBOX = new DC::UI::Statusbox; 2539 $STATUSBOX = new DC::UI::Statusbox;
2453 2540
2454 $MODBOX = new DC::UI::Label 2541 $MODBOX = new DC::UI::Label
2481 2568
2482 DC::UI::Toplevel->new ( 2569 DC::UI::Toplevel->new (
2483 title => "Minimap", 2570 title => "Minimap",
2484 name => "mapmap", 2571 name => "mapmap",
2485 x => 0, 2572 x => 0,
2486 y => $FONTSIZE + 8, 2573 y => $::FONTSIZE + 8,#d# hack to move messages window below the menubar
2487 border_bg => [1, 1, 1, 192/255], 2574 border_bg => [1, 1, 1, 192/255],
2488 bg => [1, 1, 1, 0], 2575 bg => [1, 1, 1, 0],
2489 child => ($MAPMAP = new DC::MapWidget::MapMap 2576 child => ($MAPMAP = new DC::MapWidget::MapMap
2490 tooltip => "<b>Minimap</b>. This will display an overview of the surrounding areas.", 2577 tooltip => "<b>Minimap</b>. This will display an overview of the surrounding areas.",
2491 ), 2578 ),
2520 $METASERVER = metaserver_dialog; 2607 $METASERVER = metaserver_dialog;
2521 # the name is changed to not conflict with the older name as users could have hidden it 2608 # the name is changed to not conflict with the older name as users could have hidden it
2522 $MESSAGE_WINDOW = new DC::UI::Dockbar 2609 $MESSAGE_WINDOW = new DC::UI::Dockbar
2523 name => "message_window2", 2610 name => "message_window2",
2524 title => 'Messages', 2611 title => 'Messages',
2612 y => $::FONTSIZE + 8,#d# hack to move messages window below the menubar
2525 force_w => $::WIDTH * 0.6, 2613 force_w => $::WIDTH * 0.6,
2526 force_h => $::HEIGHT * 0.25, 2614 force_h => $::HEIGHT * 0.25,
2527 ; 2615 ;
2528 2616
2529 $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; 2617 $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW;
2560 2648
2561 $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1, 1]); 2649 $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1, 1]);
2562 $MODE_SLIDER->emit (changed => $CFG->{sdl_mode}); 2650 $MODE_SLIDER->emit (changed => $CFG->{sdl_mode});
2563 2651
2564 $CAVEAT_LABEL->set_text ("None :)"); 2652 $CAVEAT_LABEL->set_text ("None :)");
2653 $CAVEAT_LABEL->set_text ("Apple/NVIDIA Texture bug (slow)")
2654 if $DC::OpenGL::APPLE_NVIDIA_BUG;
2565 $CAVEAT_LABEL->set_text ("Software Rendering (very slow)") 2655 $CAVEAT_LABEL->set_text ("Software Rendering (very slow)")
2566 unless DC::SDL_GL_GetAttribute DC::SDL_GL_ACCELERATED_VISUAL; 2656 unless DC::SDL_GL_GetAttribute DC::SDL_GL_ACCELERATED_VISUAL;
2567 2657
2568 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); 2658 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]);
2569} 2659}
2579my $animate_timer; 2669my $animate_timer;
2580 2670
2581my $fps = 9; 2671my $fps = 9;
2582 2672
2583sub force_refresh { 2673sub force_refresh {
2584 if ($ENV{CFPLUS_DEBUG} & 4) { 2674 if ($DELIANTRA_DEBUG & 4) {
2585 $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;
2586 debug sprintf "%3.2f", $fps; 2676 debug sprintf "%3.2f", $fps;
2587 } 2677 }
2588 2678
2589 undef $WANT_REFRESH; 2679 undef $WANT_REFRESH;
2702 fullscreen => 1, 2792 fullscreen => 1,
2703 fast => 0, 2793 fast => 0,
2704 force_opengl11 => undef, 2794 force_opengl11 => undef,
2705 disable_alpha => 0, 2795 disable_alpha => 0,
2706 smooth_movement => 1, 2796 smooth_movement => 1,
2797 smooth_transitions => 1,
2707 texture_compression => 1, 2798 texture_compression => 1,
2708 map_scale => 1, 2799 map_scale => 1,
2709 fow_enable => 1, 2800 fow_enable => 1,
2710 fow_intensity => 0, 2801 fow_intensity => 0,
2802 fow_texture => 0,
2711 map_smoothing => 1, 2803 map_smoothing => 1,
2712 gui_fontsize => 1, 2804 gui_fontsize => 1,
2713 log_fontsize => 0.7, 2805 log_fontsize => 0.7,
2714 gauge_fontsize => 1, 2806 gauge_fontsize => 1,
2715 gauge_size => 0.35, 2807 gauge_size => 0.35,
2730 default => "profile", # default profile 2822 default => "profile", # default profile
2731 show_tips => 1, 2823 show_tips => 1,
2732 logview_max_par => 1000, 2824 logview_max_par => 1000,
2733 shift_fire_stop => 0, 2825 shift_fire_stop => 0,
2734 uitheme => "wood", 2826 uitheme => "wood",
2735 ); 2827 map_shift_x => -24, # arbitrary
2828 map_shift_y => +24, # arbitrary
2736 2829 );
2830
2737 while (my ($k, $v) = each %DEF_CFG) { 2831 while (my ($k, $v) = each %DEF_CFG) {
2738 $CFG->{$k} = $v unless exists $CFG->{$k}; 2832 $CFG->{$k} = $v unless exists $CFG->{$k};
2739 } 2833 }
2740 2834
2741 $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} ||= {};
2742 $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;
2743 2862
2744 # convert old bindings (only default profile matters) 2863 # convert old bindings (only default profile matters)
2745 if (my $bindings = delete $PROFILE->{bindings}) { 2864 if (my $bindings = delete $PROFILE->{bindings}) {
2746 while (my ($mod, $syms) = each %$bindings) { 2865 while (my ($mod, $syms) = each %$bindings) {
2747 while (my ($sym, $cmds) = each %$syms) { 2866 while (my ($sym, $cmds) = each %$syms) {
2751 }; 2870 };
2752 } 2871 }
2753 } 2872 }
2754 } 2873 }
2755 2874
2756 sdl_init; 2875 $ENV{FONTCONFIG_FILE} = DC::find_rcfile "fonts/fonts.conf";
2876 $ENV{FONTCONFIG_DIR} = DC::find_rcfile "fonts";
2757 2877
2758 { 2878 {
2759 my @fonts = map DC::find_rcfile "fonts/$_", qw( 2879 my @fonts = map DC::find_rcfile "fonts/$_", qw(
2760 DejaVuSans.ttf 2880 DejaVuSans.ttf
2761 DejaVuSansMono.ttf 2881 DejaVuSansMono.ttf
2763 DejaVuSansMono-Bold.ttf 2883 DejaVuSansMono-Bold.ttf
2764 DejaVuSans-Oblique.ttf 2884 DejaVuSans-Oblique.ttf
2765 DejaVuSansMono-Oblique.ttf 2885 DejaVuSansMono-Oblique.ttf
2766 DejaVuSans-BoldOblique.ttf 2886 DejaVuSans-BoldOblique.ttf
2767 DejaVuSansMono-BoldOblique.ttf 2887 DejaVuSansMono-BoldOblique.ttf
2888 mona.ttf
2768 ); 2889 );
2769 2890
2770 DC::add_font $_ for @fonts; 2891 DC::add_font $_ for @fonts;
2771 2892
2772 $FONT_PROP = new_from_file DC::Font $fonts[0]; 2893 $FONT_PROP = new_from_file DC::Font $fonts[0];
2773 $FONT_FIXED = new_from_file DC::Font $fonts[1]; 2894 $FONT_FIXED = new_from_file DC::Font $fonts[1];
2774 2895
2775 $FONT_PROP->make_default; 2896 $FONT_PROP->make_default;
2776 2897
2799 our $STARTUP_CANCEL = EV::idle sub { 2920 our $STARTUP_CANCEL = EV::idle sub {
2800 undef $::STARTUP_CANCEL; 2921 undef $::STARTUP_CANCEL;
2801 $startup_done->(); 2922 $startup_done->();
2802 }; 2923 };
2803 2924
2925 debug_toggle 0;
2926
2804 delete $SIG{__DIE__}; 2927 delete $SIG{__DIE__};
2805 EV::loop; 2928 EV::loop;
2806 2929
2807 DC::write_cfg if $CFG->{config_autosave}; 2930 DC::write_cfg if $CFG->{config_autosave};
2808 2931
2820 2943
2821deliantra - A Deliantra MORPG game client 2944deliantra - A Deliantra MORPG game client
2822 2945
2823=head1 SYNOPSIS 2946=head1 SYNOPSIS
2824 2947
2825Just run it - no commandline arguments are supported. 2948 deliantra [--profile name] [host [user [password]]]
2949 deliantra --help
2826 2950
2827=head1 USAGE 2951=head1 USAGE
2828 2952
2829deliantra utilises OpenGL for all UI elements and the game. It is supposed to 2953The deliantra client utilises OpenGL for all UI elements and the game. It
2830be used in fullscreen mode and interactively. 2954is supposed to be used in fullscreen mode and interactively.
2831 2955
2832=head1 DEBUGGING 2956=head1 DEBUGGING
2833 2957
2834
2835CFPLUS_DEBUG - environment variable 2958DELIANTRA_DEBUG - environment variable
2836 2959
2837 1 draw borders around widgets 2960 1 draw borders around widgets
2838 2 add low-level widget info to tooltips 2961 2 add low-level widget info to tooltips
2839 4 show fps 2962 4 show fps
2840 8 suppress tooltips 2963 8 suppress tooltips
2964 16 show bandwidth downstream
2841 2965
2842=head1 AUTHOR 2966=head1 AUTHOR
2843 2967
2844Marc Lehmann <deliantra@schmorp.de>, Robin Redeker <elmex@ta-sa.org> 2968Marc Lehmann <deliantra@schmorp.de>, Robin Redeker <elmex@ta-sa.org>
2845 2969

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines