… | |
… | |
210 | } |
210 | } |
211 | ); |
211 | ); |
212 | |
212 | |
213 | $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"); |
214 | $table->add (1, $row++, new CFClient::UI::Slider |
214 | $table->add (1, $row++, new CFClient::UI::Slider |
215 | range => [$CFG->{map_scale}, 0.25, 2, 0.05, 0.05], |
215 | range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], |
216 | tooltip => "Enlarge or shrink the displayed map", |
216 | tooltip => "Enlarge or shrink the displayed map", |
217 | connect_changed => sub { |
217 | connect_changed => sub { |
218 | my ($self, $value) = @_; |
218 | my ($self, $value) = @_; |
219 | $CFG->{map_scale} = $value; |
219 | $CFG->{map_scale} = 2 ** $value; |
220 | } |
220 | } |
221 | ); |
221 | ); |
222 | |
222 | |
223 | $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"); |
224 | $table->add (1, $row++, new CFClient::UI::CheckBox |
224 | $table->add (1, $row++, new CFClient::UI::CheckBox |
… | |
… | |
1038 | |
1038 | |
1039 | sub audio_init { |
1039 | sub audio_init { |
1040 | if ($CFG->{audio_enable}) { |
1040 | if ($CFG->{audio_enable}) { |
1041 | if (open my $fh, "<", CFClient::find_rcfile "sounds/config") { |
1041 | if (open my $fh, "<", CFClient::find_rcfile "sounds/config") { |
1042 | $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 | |
1043 | CFClient::Mix_AllocateChannels 8; |
1049 | CFClient::Mix_AllocateChannels 8; |
1044 | CFClient::MixMusic::volume $CFG->{bgm_volume} * 128; |
1050 | CFClient::MixMusic::volume $CFG->{bgm_volume} * 128; |
1045 | |
1051 | |
1046 | audio_music_finished; |
1052 | audio_music_finished; |
1047 | |
1053 | |
… | |
… | |
1201 | |
1207 | |
1202 | $MAPWIDGET->add_command ("$cmd$arg", $text); |
1208 | $MAPWIDGET->add_command ("$cmd$arg", $text); |
1203 | } |
1209 | } |
1204 | } |
1210 | } |
1205 | |
1211 | |
|
|
1212 | $self->{noface} = new_from_file CFClient::Texture |
|
|
1213 | CFClient::find_rcfile "noface.png", minify => 1, mipmap => 1; |
|
|
1214 | |
1206 | $self |
1215 | $self |
1207 | } |
1216 | } |
1208 | |
1217 | |
1209 | sub conn::stats_update { |
1218 | sub conn::stats_update { |
1210 | my ($self, $stats) = @_; |
1219 | my ($self, $stats) = @_; |
… | |
… | |
1406 | |
1415 | |
1407 | my $id = $FACEMAP->get ($hash); |
1416 | my $id = $FACEMAP->get ($hash); |
1408 | |
1417 | |
1409 | unless ($id) { |
1418 | unless ($id) { |
1410 | # create new id for face |
1419 | # create new id for face |
1411 | # i love transactions |
1420 | # I love transactions |
1412 | for (1..100) { |
1421 | for (1..100) { |
1413 | my $txn = $CFClient::DB_ENV->txn_begin; |
1422 | my $txn = $CFClient::DB_ENV->txn_begin; |
1414 | my $status = $FACEMAP->db_get (id => $id, BerkeleyDB::DB_RMW); |
1423 | my $status = $FACEMAP->db_get (id => $id, BerkeleyDB::DB_RMW); |
1415 | if ($status == 0 || $status == BerkeleyDB::DB_NOTFOUND) { |
1424 | if ($status == 0 || $status == BerkeleyDB::DB_NOTFOUND) { |
1416 | $id++; |
1425 | $id = ($id || 16) + 1; |
1417 | if ($FACEMAP->put (id => $id) == 0 |
1426 | if ($FACEMAP->put (id => $id) == 0 |
1418 | && $FACEMAP->put ($hash => $id) == 0) { |
1427 | && $FACEMAP->put ($hash => $id) == 0) { |
1419 | $txn->txn_commit; |
1428 | $txn->txn_commit; |
1420 | |
1429 | |
1421 | goto gotid; |
1430 | goto gotid; |
… | |
… | |
1429 | |
1438 | |
1430 | gotid: |
1439 | gotid: |
1431 | $face->{id} = $id; |
1440 | $face->{id} = $id; |
1432 | $MAP->set_face ($facenum => $id); |
1441 | $MAP->set_face ($facenum => $id); |
1433 | $self->{faceid}[$facenum] = $id;#d# |
1442 | $self->{faceid}[$facenum] = $id;#d# |
|
|
1443 | |
1434 | $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 | }; |
1435 | } |
1449 | } |
1436 | |
1450 | |
1437 | sub conn::face_update { |
1451 | sub conn::face_update { |
1438 | my ($self, $facenum, $face) = @_; |
1452 | my ($self, $facenum, $face) = @_; |
1439 | |
1453 | |