… | |
… | |
105 | our $INVR; |
105 | our $INVR; |
106 | our $INVR_LBL; |
106 | our $INVR_LBL; |
107 | our $OPENCONT; |
107 | our $OPENCONT; |
108 | |
108 | |
109 | sub status { |
109 | sub status { |
110 | $STATUSBOX->add ($_[0], pri => -10, group => "status", timeout => 20, fg => [1, 1, 0, 1]); |
110 | $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 20, fg => [1, 1, 0, 1]); |
111 | } |
111 | } |
112 | |
112 | |
113 | sub debug { |
113 | sub debug { |
114 | $DEBUG_STATUS->set_text ($_[0]); |
114 | $DEBUG_STATUS->set_text ($_[0]); |
115 | my ($w, $h) = $DEBUG_STATUS->size_request; |
115 | my ($w, $h) = $DEBUG_STATUS->size_request; |
… | |
… | |
786 | bg => [0, 0, 0, 0.5], |
786 | bg => [0, 0, 0, 0.5], |
787 | user_w => int $::WIDTH / 3, |
787 | user_w => int $::WIDTH / 3, |
788 | user_h => int $::HEIGHT / 5, |
788 | user_h => int $::HEIGHT / 5, |
789 | child => (my $vbox = new CFClient::UI::VBox); |
789 | child => (my $vbox = new CFClient::UI::VBox); |
790 | |
790 | |
791 | $vbox->add ($LOGVIEW = new CFClient::UI::TextView |
791 | $vbox->add ($LOGVIEW); |
792 | expand => 1, |
|
|
793 | font => $FONT_FIXED, |
|
|
794 | fontsize => $::CFG->{log_fontsize}, |
|
|
795 | ); |
|
|
796 | |
792 | |
797 | $vbox->add (my $input = new CFClient::UI::Entry |
793 | $vbox->add (my $input = new CFClient::UI::Entry |
798 | connect_focus_in => sub { |
794 | connect_focus_in => sub { |
799 | my ($input, $prev_focus) = @_; |
795 | my ($input, $prev_focus) = @_; |
800 | |
796 | |
… | |
… | |
835 | |
831 | |
836 | sub make_inventory_window { |
832 | sub make_inventory_window { |
837 | my $invwin = new CFClient::UI::FancyFrame |
833 | my $invwin = new CFClient::UI::FancyFrame |
838 | user_w => $WIDTH * (4/5), user_h => $HEIGHT * (4/5), title => "Inventory"; |
834 | user_w => $WIDTH * (4/5), user_h => $HEIGHT * (4/5), title => "Inventory"; |
839 | |
835 | |
840 | $invwin->add (my $hb = new CFClient::UI::HBox); |
836 | $invwin->add (my $hb = new CFClient::UI::HBox expand => 1); |
841 | |
837 | |
842 | $hb->add (my $vb1 = new CFClient::UI::VBox expand => 1); |
838 | $hb->add (my $vb1 = new CFClient::UI::VBox expand => 1); |
843 | $vb1->add (my $lbl = new CFClient::UI::Label); |
839 | $vb1->add (my $lbl = new CFClient::UI::Label); |
844 | $lbl->set_text ("Player"); |
840 | $lbl->set_text ("Player"); |
845 | $vb1->add ($INV = new CFClient::UI::Inventory expand => 1); |
841 | $vb1->add ($INV = new CFClient::UI::Inventory expand => 1); |
… | |
… | |
865 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
861 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
866 | $FULLSCREEN = $CFG->{fullscreen}; |
862 | $FULLSCREEN = $CFG->{fullscreen}; |
867 | $FAST = $CFG->{fast}; |
863 | $FAST = $CFG->{fast}; |
868 | |
864 | |
869 | CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN |
865 | CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN |
870 | or die "SDL_SetVideoMode failed!\n"; |
866 | or die "SDL_SetVideoMode failed: " . (CFClient::SDL_GetError) . "\n"; |
871 | |
867 | |
872 | $SDL_ACTIVE = 1; |
868 | $SDL_ACTIVE = 1; |
873 | $LAST_REFRESH = time - 0.01; |
869 | $LAST_REFRESH = time - 0.01; |
874 | |
870 | |
875 | CFClient::gl_init; |
871 | CFClient::gl_init; |
… | |
… | |
914 | } |
910 | } |
915 | } |
911 | } |
916 | }); |
912 | }); |
917 | $MAPWIDGET->show; |
913 | $MAPWIDGET->show; |
918 | $MAPWIDGET->focus_in; |
914 | $MAPWIDGET->focus_in; |
|
|
915 | |
|
|
916 | $LOGVIEW = new CFClient::UI::TextView |
|
|
917 | expand => 1, |
|
|
918 | font => $FONT_FIXED, |
|
|
919 | fontsize => $::CFG->{log_fontsize}, |
|
|
920 | ; |
919 | |
921 | |
920 | $BUTTONBAR = new CFClient::UI::HBox; |
922 | $BUTTONBAR = new CFClient::UI::HBox; |
921 | |
923 | |
922 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); |
924 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); |
923 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); |
925 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); |
… | |
… | |
1009 | my %animate_object; |
1011 | my %animate_object; |
1010 | my $animate_timer; |
1012 | my $animate_timer; |
1011 | |
1013 | |
1012 | my $fps = 9; |
1014 | my $fps = 9; |
1013 | |
1015 | |
|
|
1016 | my %demo;#d# |
|
|
1017 | |
1014 | sub force_refresh { |
1018 | sub force_refresh { |
1015 | $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05; |
1019 | $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05; |
1016 | debug sprintf "%3.2f", $fps; |
1020 | debug sprintf "%3.2f", $fps; |
1017 | |
1021 | |
1018 | $CFClient::UI::ROOT->draw; |
1022 | $CFClient::UI::ROOT->draw; |
1019 | CFClient::SDL_GL_SwapBuffers; |
|
|
1020 | |
1023 | |
1021 | $WANT_REFRESH = 0; |
1024 | $WANT_REFRESH = 0; |
1022 | $CAN_REFRESH = 0; |
1025 | $CAN_REFRESH = 0; |
1023 | $LAST_REFRESH = $NOW; |
1026 | $LAST_REFRESH = $NOW; |
|
|
1027 | |
|
|
1028 | 0 && do { |
|
|
1029 | # some weird model-drawing code, just a joke right now |
|
|
1030 | use CFClient::OpenGL; |
|
|
1031 | |
|
|
1032 | $demo{t}{eye_auv} ||= new_from_file CFClient::Texture "eye2.png" or die; |
|
|
1033 | $demo{t}{body_auv} ||= new_from_file CFClient::Texture "body_auv3.png" or die; |
|
|
1034 | $demo{r} ||= do { |
|
|
1035 | my $mod = Compress::LZF::sthaw do { local $/; open my $fh, "<:raw:perlio", "dread.lz3"; <$fh> }; |
|
|
1036 | $mod->{v} = pack "f*", @{$mod->{v}}; |
|
|
1037 | $_ = [scalar @$_, pack "S!*", @$_] |
|
|
1038 | for values %{$mod->{g}}; |
|
|
1039 | $mod |
|
|
1040 | }; |
|
|
1041 | |
|
|
1042 | my $r = $demo{r} or die; |
|
|
1043 | |
|
|
1044 | glDepthMask 1; |
|
|
1045 | glClear GL_DEPTH_BUFFER_BIT; |
|
|
1046 | glEnable GL_TEXTURE_2D; |
|
|
1047 | glEnable GL_DEPTH_TEST; |
|
|
1048 | glEnable GL_CULL_FACE; |
|
|
1049 | glShadeModel $::FAST ? GL_FLAT : GL_SMOOTH; |
|
|
1050 | |
|
|
1051 | glMatrixMode GL_PROJECTION; |
|
|
1052 | glLoadIdentity; |
|
|
1053 | glFrustum -1 * ($::WIDTH / $::HEIGHT), 1 * ($::WIDTH / $::HEIGHT), 1, -1, 1, 10000; |
|
|
1054 | #glOrtho 0, $::WIDTH, 0, $::HEIGHT, -10000, 10000; |
|
|
1055 | glMatrixMode GL_MODELVIEW; |
|
|
1056 | glLoadIdentity; |
|
|
1057 | |
|
|
1058 | glPushMatrix; |
|
|
1059 | glTranslate 0, 0, -800; |
|
|
1060 | glScale 1, -1, 1; |
|
|
1061 | glRotate $NOW * 1000 % 36000 / 5, 0, 1, 0; |
|
|
1062 | glRotate $NOW * 1000 % 36000 / 6, 1, 0, 0; |
|
|
1063 | glRotate $NOW * 1000 % 36000 / 7, 0, 0, 1; |
|
|
1064 | glScale 50, 50, 50; |
|
|
1065 | |
|
|
1066 | glInterleavedArrays GL_T2F_N3F_V3F, 0, $r->{v}; |
|
|
1067 | while (my ($k, $v) = each %{$r->{g}}) { |
|
|
1068 | glBindTexture GL_TEXTURE_2D, ($demo{t}{$k}{name} or die); |
|
|
1069 | glDrawElements GL_TRIANGLES, $v->[0], GL_UNSIGNED_SHORT, $v->[1]; |
|
|
1070 | } |
|
|
1071 | |
|
|
1072 | glPopMatrix; |
|
|
1073 | |
|
|
1074 | glShadeModel GL_FLAT; |
|
|
1075 | glDisable GL_DEPTH_TEST; |
|
|
1076 | glDisable GL_TEXTURE_2D; |
|
|
1077 | glDepthMask 0; |
|
|
1078 | |
|
|
1079 | $WANT_REFRESH++; |
|
|
1080 | }; |
|
|
1081 | |
|
|
1082 | CFClient::SDL_GL_SwapBuffers; |
1024 | } |
1083 | } |
1025 | |
1084 | |
1026 | my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { |
1085 | my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { |
1027 | $NOW = time; |
1086 | $NOW = time; |
1028 | |
1087 | |
… | |
… | |
1154 | $self->set_texture ($id => $data); |
1213 | $self->set_texture ($id => $data); |
1155 | } |
1214 | } |
1156 | } |
1215 | } |
1157 | } |
1216 | } |
1158 | |
1217 | |
|
|
1218 | # hardcode /world/world_xxx_xxx map names, the savings are enourmous, |
|
|
1219 | # (server resource,s latency, bandwidth), so this hack is warranted. |
|
|
1220 | # the right fix is to make real tiled maps with an overview file |
|
|
1221 | sub conn::send_mapinfo { |
|
|
1222 | my ($self, $data, $cb) = @_; |
|
|
1223 | |
|
|
1224 | if ($self->{map_info}[0] =~ m%^/world/world_(\d\d\d)_(\d\d\d)$%) { |
|
|
1225 | my ($wx, $wy) = ($1, $2); |
|
|
1226 | |
|
|
1227 | if ($data =~ /^spatial ([1-4]+)$/) { |
|
|
1228 | my @dx = (0, 0, 1, 0, -1); |
|
|
1229 | my @dy = (0, -1, 0, 1, 0); |
|
|
1230 | my ($dx, $dy); |
|
|
1231 | |
|
|
1232 | for (split //, $1) { |
|
|
1233 | $dx += $dx[$_]; |
|
|
1234 | $dy += $dy[$_]; |
|
|
1235 | } |
|
|
1236 | |
|
|
1237 | $cb->(spatial => 15, |
|
|
1238 | $self->{map_info}[1] - $MAP->ox + $dx * 50, |
|
|
1239 | $self->{map_info}[2] - $MAP->oy + $dy * 50, |
|
|
1240 | 50, 50, |
|
|
1241 | sprintf "/world/world_%03d_%03d", $wx + $dx, $wy + $dy |
|
|
1242 | ); |
|
|
1243 | |
|
|
1244 | return; |
|
|
1245 | } |
|
|
1246 | } |
|
|
1247 | |
|
|
1248 | $self->SUPER::send_mapinfo ($data, $cb); |
|
|
1249 | } |
|
|
1250 | |
1159 | # this method does a "flood fill" into every tile direction |
1251 | # this method does a "flood fill" into every tile direction |
1160 | # it assumes that tiles are arranged in a rectangular grid, |
1252 | # it assumes that tiles are arranged in a rectangular grid, |
1161 | # i.e. a map is the same as the left of the right map etc. |
1253 | # i.e. a map is the same as the left of the right map etc. |
1162 | # failure to comply are harmless and result in display errors |
1254 | # failure to comply are harmless and result in display errors |
1163 | # at worst. |
1255 | # at worst. |
1164 | sub conn::flood_fill { |
1256 | sub conn::flood_fill { |
1165 | my ($self, $gx, $gy, $path, $hash, $flags) = @_; |
1257 | my ($self, $block, $gx, $gy, $path, $hash, $flags) = @_; |
1166 | |
1258 | |
1167 | # the server does not allow map paths > 6 |
1259 | # the server does not allow map paths > 6 |
1168 | return if 7 <= length $path; |
1260 | return if 7 <= length $path; |
1169 | |
1261 | |
1170 | my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}}; |
1262 | my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}}; |
1171 | |
1263 | |
1172 | for ( |
1264 | for ( |
1173 | [1, 0, -1], |
1265 | [1, 3, 0, -1], |
1174 | [2, 1, 0], |
1266 | [2, 4, 1, 0], |
1175 | [3, 0, 1], |
1267 | [3, 1, 0, 1], |
1176 | [4, -1, 0], |
1268 | [4, 2, -1, 0], |
1177 | ) { |
1269 | ) { |
1178 | my ($tile, $dx, $dy) = @$_; |
1270 | my ($tile, $tile2, $dx, $dy) = @$_; |
|
|
1271 | |
|
|
1272 | next if $block & (1 << $tile); |
|
|
1273 | my $block = $block | (1 << $tile2); |
1179 | |
1274 | |
1180 | my $gx = $gx + $dx; |
1275 | my $gx = $gx + $dx; |
1181 | my $gy = $gy + $dy; |
1276 | my $gy = $gy + $dy; |
1182 | |
1277 | |
1183 | next unless $flags & (1 << ($tile - 1)); |
1278 | next unless $flags & (1 << ($tile - 1)); |
… | |
… | |
1185 | |
1280 | |
1186 | my $neigh = $self->{neigh_map}{$hash} ||= []; |
1281 | my $neigh = $self->{neigh_map}{$hash} ||= []; |
1187 | if (my $info = $neigh->[$tile]) { |
1282 | if (my $info = $neigh->[$tile]) { |
1188 | my ($flags, $x, $y, $w, $h, $hash) = @$info; |
1283 | my ($flags, $x, $y, $w, $h, $hash) = @$info; |
1189 | |
1284 | |
1190 | $self->flood_fill ($gx, $gy, "$path$tile", $hash, $flags) |
1285 | $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) |
1191 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
1286 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
1192 | |
1287 | |
1193 | } else { |
1288 | } else { |
1194 | $self->send_mapinfo ("spatial $path$tile", sub { |
1289 | $self->send_mapinfo ("spatial $path$tile", sub { |
1195 | my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; |
1290 | my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; |
1196 | |
1291 | |
1197 | return if $mode ne "spatial"; |
1292 | return if $mode ne "spatial"; |
1198 | |
1293 | |
1199 | $x += $MAP->ox; |
1294 | $x += $MAP->ox; |
1200 | $y += $MAP->oy; |
1295 | $y += $MAP->oy; |
1201 | |
1296 | |
1202 | $self->load_map ($hash, $x, $y) |
1297 | $self->load_map ($hash, $x, $y) |
1203 | unless $self->{neigh_map}{$hash}[5]++;#d# |
1298 | unless $self->{neigh_map}{$hash}[5]++;#d# |
1204 | |
1299 | |
1205 | $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; |
1300 | $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; |
1206 | |
1301 | |
1207 | $self->flood_fill ($gx, $gy, "$path$tile", $hash, $flags) |
1302 | $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) |
1208 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
1303 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
1209 | }); |
1304 | }); |
1210 | } |
1305 | } |
1211 | } |
1306 | } |
1212 | } |
1307 | } |
… | |
… | |
1225 | $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, |
1320 | $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, |
1226 | $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h, |
1321 | $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h, |
1227 | ]; |
1322 | ]; |
1228 | |
1323 | |
1229 | delete $self->{neigh_grid}; |
1324 | delete $self->{neigh_grid}; |
1230 | $self->flood_fill (0, 0, "", $hash, $flags); |
|
|
1231 | |
1325 | |
1232 | $x += $ox; |
1326 | $x += $ox; |
1233 | $y += $oy; |
1327 | $y += $oy; |
1234 | |
1328 | |
1235 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
1329 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
1236 | |
1330 | |
1237 | my $map = $self->{map_info}[0]; |
|
|
1238 | $map =~ s/^.*?\/([^\/]+)$/\1/; |
1331 | (my $map = $hash) =~ s/^.*?\/([^\/]+)$/\1/; |
1239 | $STATWIDS->{map}->set_text ("Map: " . $map); |
1332 | $STATWIDS->{map}->set_text ("Map: " . $map); |
1240 | |
1333 | |
1241 | $self->load_map ($hash, $x, $y); |
1334 | $self->load_map ($hash, $x, $y); |
|
|
1335 | $self->flood_fill (0, 0, 0, "", $hash, $flags); |
1242 | } |
1336 | } |
1243 | |
1337 | |
1244 | sub conn::face_find { |
1338 | sub conn::face_find { |
1245 | my ($self, $facenum, $face) = @_; |
1339 | my ($self, $facenum, $face) = @_; |
1246 | |
1340 | |
… | |
… | |
1438 | my ($self) = @_; |
1532 | my ($self) = @_; |
1439 | |
1533 | |
1440 | $self->send ("command output-sync $CFG->{output_sync}"); |
1534 | $self->send ("command output-sync $CFG->{output_sync}"); |
1441 | $self->send ("command output-count $CFG->{output_count}"); |
1535 | $self->send ("command output-count $CFG->{output_count}"); |
1442 | |
1536 | |
|
|
1537 | my $parser = new Pod::POM; |
|
|
1538 | my $pod = $parser->parse_file (CFClient::find_rcfile "pod/skill_help.pod"); |
|
|
1539 | |
|
|
1540 | my %skill_tooltip; |
|
|
1541 | |
|
|
1542 | for my $head2 ($pod->head2) { |
|
|
1543 | $skill_tooltip{$head2->title} = CFClient::pod_to_pango $head2->content; |
|
|
1544 | } |
|
|
1545 | |
1443 | for my $skill (values %{$self->{skill_info}}) { |
1546 | for my $skill (values %{$self->{skill_info}}) { |
1444 | $MAPWIDGET->add_command ("ready_skill $skill", CFClient::UI::Label::escape "Ready the skill '$skill'"); |
1547 | $MAPWIDGET->add_command ("ready_skill $skill", |
1445 | $MAPWIDGET->add_command ("use_skill $skill", CFClient::UI::Label::escape "Immediately use the skill '$skill'"); |
1548 | (CFClient::UI::Label::escape "Ready the skill '$skill'\n\n") |
|
|
1549 | . $skill_tooltip{$skill}); |
|
|
1550 | $MAPWIDGET->add_command ("use_skill $skill", |
|
|
1551 | (CFClient::UI::Label::escape "Immediately use the skill '$skill'\n\n") |
|
|
1552 | . $skill_tooltip{$skill}); |
1446 | } |
1553 | } |
1447 | } |
1554 | } |
1448 | |
1555 | |
1449 | sub conn::eof { |
1556 | sub conn::eof { |
1450 | $MAPWIDGET->clr_commands; |
1557 | $MAPWIDGET->clr_commands; |
… | |
… | |
1615 | sdl_mode => 0, |
1722 | sdl_mode => 0, |
1616 | width => 640, |
1723 | width => 640, |
1617 | height => 480, |
1724 | height => 480, |
1618 | fullscreen => 0, |
1725 | fullscreen => 0, |
1619 | fast => 0, |
1726 | fast => 0, |
1620 | map_scale => 0.5, |
1727 | map_scale => 1, |
1621 | fow_enable => 1, |
1728 | fow_enable => 1, |
1622 | fow_intensity => 0.45, |
1729 | fow_intensity => 0.45, |
1623 | fow_smooth => 0, |
1730 | fow_smooth => 0, |
1624 | gui_fontsize => 1, |
1731 | gui_fontsize => 1, |
1625 | log_fontsize => 1, |
1732 | log_fontsize => 1, |
… | |
… | |
1746 | |
1853 | |
1747 | Typing B<climb> will display a list of commands with I<climb> in their |
1854 | Typing B<climb> will display a list of commands with I<climb> in their |
1748 | name, such as I<ready_skill climbing> and I<use_skill climbing>. |
1855 | name, such as I<ready_skill climbing> and I<use_skill climbing>. |
1749 | |
1856 | |
1750 | You can abbreviate commands by typing only the first character of every |
1857 | You can abbreviate commands by typing only the first character of every |
1751 | word. For example, typing I<iwor> will likely select I<invoke word of |
1858 | word (or even characters within the word - the client will try to make |
1752 | recall>, while I<ccfo> will select I<cast create food>. Likewise, I<rscli> |
1859 | a good guess, as long as the characters are in order). For example, |
1753 | will likely select I<ready_skill climbing> and I<usl> will give you |
1860 | typing I<iwor> will likely select I<invoke word of recall>, while I<ccfo> |
1754 | I<use_skill levitation>. |
1861 | will select I<cast create food>. Likewise, I<rscli> will likely select |
|
|
1862 | I<ready_skill climbing> and I<usl> will give you I<use_skill levitation>. |
|
|
1863 | |
|
|
1864 | You can enter space and other text as arguemnt to the command. For |
|
|
1865 | example, C<cfoo waybread> will expand to C<cast create food waybread>. |
1755 | |
1866 | |
1756 | =head2 The map overview |
1867 | =head2 The map overview |
1757 | |
1868 | |
1758 | #TODO# |
1869 | #TODO# |
1759 | |
1870 | |