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

Comparing deliantra/Deliantra-Client/bin/pclient (file contents):
Revision 1.236 by root, Mon May 22 03:28:55 2006 UTC vs.
Revision 1.240 by root, Tue May 23 21:14:42 2006 UTC

82our $BUTTONBAR; 82our $BUTTONBAR;
83our $LOGVIEW; 83our $LOGVIEW;
84our $CONSOLE; 84our $CONSOLE;
85our $METASERVER; 85our $METASERVER;
86our $LOGIN_BUTTON; 86our $LOGIN_BUTTON;
87our $QUIT_DIALOG;
87 88
88our $FLOORBOX; 89our $FLOORBOX;
89our $GAUGES; 90our $GAUGES;
90our $STATWIDS; 91our $STATWIDS;
91 92
209 } 210 }
210 ); 211 );
211 212
212 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Map Scale"); 213 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Map Scale");
213 $table->add (1, $row++, new CFClient::UI::Slider 214 $table->add (1, $row++, new CFClient::UI::Slider
214 range => [$CFG->{map_scale}, 0.25, 2, 0.05, 0.05], 215 range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1],
215 tooltip => "Enlarge or shrink the displayed map", 216 tooltip => "Enlarge or shrink the displayed map",
216 connect_changed => sub { 217 connect_changed => sub {
217 my ($self, $value) = @_; 218 my ($self, $value) = @_;
218 $CFG->{map_scale} = $value; 219 $CFG->{map_scale} = 2 ** $value;
219 } 220 }
220 ); 221 );
221 222
222 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War"); 223 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War");
223 $table->add (1, $row++, new CFClient::UI::CheckBox 224 $table->add (1, $row++, new CFClient::UI::CheckBox
834 }; 835 };
835 836
836 $window 837 $window
837} 838}
838 839
840sub open_quit_dialog {
841 unless ($QUIT_DIALOG) {
842
843 $QUIT_DIALOG = new CFClient::UI::FancyFrame title => "Really Quit?";
844
845 $QUIT_DIALOG->add (my $vb = new CFClient::UI::VBox expand => 1);
846
847 $vb->add (new CFClient::UI::Label
848 text => "You should find a savebed and apply it first!",
849 max_w => $WIDTH * 0.25
850 );
851 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
852 $hb->add (new CFClient::UI::Button
853 text => "Ok",
854 connect_activate => sub { $QUIT_DIALOG->hide },
855 expand => 1
856 );
857 $hb->add (new CFClient::UI::Button
858 text => "Quit anyway",
859 connect_activate => sub { exit 1 },
860 expand => 1
861 );
862 $hb->add (new CFClient::UI::Label "You should find a savebed and apply it first!");
863
864 $QUIT_DIALOG->show_centered;
865 } else {
866 $QUIT_DIALOG->show_centered;
867 }
868}
869
839sub make_inventory_window { 870sub make_inventory_window {
840 my $invwin = new CFClient::UI::FancyFrame 871 my $invwin = new CFClient::UI::FancyFrame
841 user_w => $WIDTH * (4/5), user_h => $HEIGHT * (4/5), title => "Inventory"; 872 user_w => $WIDTH * (7/8), user_h => $HEIGHT * (7/8), title => "Inventory";
842 873
843 $invwin->add (my $hb = new CFClient::UI::HBox expand => 1); 874 $invwin->add (my $hb = new CFClient::UI::HBox expand => 1);
844 875
845 $hb->add (my $vb1 = new CFClient::UI::VBox expand => 1); 876 $hb->add (my $vb1 = new CFClient::UI::VBox expand => 1);
846 $vb1->add (my $lbl = new CFClient::UI::Label); 877 $vb1->add (my $lbl = new CFClient::UI::Label);
954 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 985 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
955 status "Configuration Saved"; 986 status "Configuration Saved";
956 }, 987 },
957 ); 988 );
958 989
990 $BUTTONBAR->add (new CFClient::UI::Button
991 text => "Quit",
992 tooltip => "Terminates the program",
993 connect_activate => sub {
994 if ($CONN) {
995 open_quit_dialog
996 } else {
997 exit 1
998 }
999 },
1000 );
1001
959 $BUTTONBAR->show; 1002 $BUTTONBAR->show;
960 1003
961 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); 1004 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]);
962 1005
963 # delay till geometry is constant 1006 # delay till geometry is constant
995 1038
996sub audio_init { 1039sub audio_init {
997 if ($CFG->{audio_enable}) { 1040 if ($CFG->{audio_enable}) {
998 if (open my $fh, "<", CFClient::find_rcfile "sounds/config") { 1041 if (open my $fh, "<", CFClient::find_rcfile "sounds/config") {
999 $SDL_MIXER = !CFClient::Mix_OpenAudio; 1042 $SDL_MIXER = !CFClient::Mix_OpenAudio;
1043
1044 unless ($SDL_MIXER) {
1045 status "Unable to open sound device: there will be no sound";
1046 return;
1047 }
1048
1000 CFClient::Mix_AllocateChannels 8; 1049 CFClient::Mix_AllocateChannels 8;
1001 CFClient::MixMusic::volume $CFG->{bgm_volume} * 128; 1050 CFClient::MixMusic::volume $CFG->{bgm_volume} * 128;
1002 1051
1003 audio_music_finished; 1052 audio_music_finished;
1004 1053
1158 1207
1159 $MAPWIDGET->add_command ("$cmd$arg", $text); 1208 $MAPWIDGET->add_command ("$cmd$arg", $text);
1160 } 1209 }
1161 } 1210 }
1162 1211
1212 $self->{noface} = new_from_file CFClient::Texture
1213 CFClient::find_rcfile "noface.png", minify => 1, mipmap => 1;
1214
1163 $self 1215 $self
1164} 1216}
1165 1217
1166sub conn::stats_update { 1218sub conn::stats_update {
1167 my ($self, $stats) = @_; 1219 my ($self, $stats) = @_;
1363 1415
1364 my $id = $FACEMAP->get ($hash); 1416 my $id = $FACEMAP->get ($hash);
1365 1417
1366 unless ($id) { 1418 unless ($id) {
1367 # create new id for face 1419 # create new id for face
1368 # i love transactions 1420 # I love transactions
1369 for (1..100) { 1421 for (1..100) {
1370 my $txn = $CFClient::DB_ENV->txn_begin; 1422 my $txn = $CFClient::DB_ENV->txn_begin;
1371 my $status = $FACEMAP->db_get (id => $id, BerkeleyDB::DB_RMW); 1423 my $status = $FACEMAP->db_get (id => $id, BerkeleyDB::DB_RMW);
1372 if ($status == 0 || $status == BerkeleyDB::DB_NOTFOUND) { 1424 if ($status == 0 || $status == BerkeleyDB::DB_NOTFOUND) {
1373 $id++; 1425 $id = ($id || 16) + 1;
1374 if ($FACEMAP->put (id => $id) == 0 1426 if ($FACEMAP->put (id => $id) == 0
1375 && $FACEMAP->put ($hash => $id) == 0) { 1427 && $FACEMAP->put ($hash => $id) == 0) {
1376 $txn->txn_commit; 1428 $txn->txn_commit;
1377 1429
1378 goto gotid; 1430 goto gotid;
1386 1438
1387gotid: 1439gotid:
1388 $face->{id} = $id; 1440 $face->{id} = $id;
1389 $MAP->set_face ($facenum => $id); 1441 $MAP->set_face ($facenum => $id);
1390 $self->{faceid}[$facenum] = $id;#d# 1442 $self->{faceid}[$facenum] = $id;#d#
1443
1391 $TILECACHE->get ($id) 1444 $TILECACHE->get ($id) || do {
1445 my $tex = $self->{noface};
1446 $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}});
1447 undef
1448 };
1392} 1449}
1393 1450
1394sub conn::face_update { 1451sub conn::face_update {
1395 my ($self, $facenum, $face) = @_; 1452 my ($self, $facenum, $face) = @_;
1396 1453
1489 ); 1546 );
1490 1547
1491 $entry->focus_in; 1548 $entry->focus_in;
1492 } 1549 }
1493 1550
1494 $dialog->show; 1551 $dialog->show_centered;
1495} 1552}
1496 1553
1497sub conn::drawinfo { 1554sub conn::drawinfo {
1498 my ($self, $color, $text) = @_; 1555 my ($self, $color, $text) = @_;
1499 1556

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines