58 static BYTE* sensor_fov_shade;
59 static BYTE* sensor_fwd_shade;
60 static BYTE* sensor_hsd_shade;
61 static BYTE* sensor_3d_shade;
69 : window(c), rect(0,0,0,0), index(n), mode(MFD_MODE_OFF), sprite(0),
70 ship(0), hidden(true), camview(0), lines(0), mouse_latch(0), mouse_in(false),
71 cockpit_hud_texture(0)
98 static int initialized = 0;
99 if (initialized)
return;
122 delete [] sensor_fov_shade;
123 delete [] sensor_fwd_shade;
124 delete [] sensor_hsd_shade;
125 delete [] sensor_3d_shade;
324 char mode_buf[8] =
" ";
339 Rect mode_rect(scan_x+2, scan_y+2, 40, 12);
344 if (beam_range >= 1e6)
345 sprintf_s(range_txt,
"-%dM+", (
int) (beam_range / 1e6));
347 sprintf_s(range_txt,
"-%3d+", (
int) (beam_range / 1e3));
349 Rect range_rect(scan_x+2, scan_y+scan_r-12, 40, 12);
352 Rect disp_rect(scan_x+scan_r-41, scan_y+2, 40, 12);
355 Rect probe_rect(scan_x+scan_r-41, scan_y+scan_r-12, 40, 12);
371 int sensor_mode = sensor->
GetMode() + 1;
410 double xctr = (scan_r / 2.0) - 0.5;
411 double yctr = (scan_r / 2.0) + 0.5;
422 if (w < sprite->Frame()->Width())
425 if (h < sprite->Frame()->Height())
431 if (h < sprite->Frame()->Height())
434 double sweep_scale = r / (
PI/2);
437 sweep_scale = (
double) r / (90*
DEGREES);
441 int xc = (int) (scan_x + xctr);
442 int yc = (int) (scan_y + yctr);
456 Rect az_rect(scan_x+2, scan_y+scan_r-12, 32, 12);
459 az_rect.
x = scan_x + (scan_r/2) - (az_rect.
w/2);
462 az_rect.
x = scan_x + scan_r - az_rect.
w - 2;
475 double tx = pt * cam->
vrt();
476 double ty = pt * cam->
vup();
477 double tz = pt * cam->
vpn();
482 double az = asin(fabs(tx) / rng);
483 double el = asin(fabs(ty) / rng);
485 if (tx < 0) az = -az;
486 if (ty < 0) el = -el;
492 int x = (int) (r + az);
493 int y = (int) (r - el);
496 if (x > 0 && x < scan_r &&
497 y > 0 && y < scan_r) {
525 if (c_ship ==
ship)
continue;
537 double len = sqrt(az*az + el*el);
551 int x = (int) (r + az);
552 int y = (int) (r - el);
555 if (x < 0 || x > scan_r)
continue;
556 if (y < 0 || y > scan_r)
continue;
613 int r = scan_r / 2 - 4;
615 double xctr = (scan_r / 2.0) - 0.5;
616 double yctr = (scan_r / 2.0) + 0.5;
618 int xc = (int) xctr + scan_x;
619 int yc = (int) yctr + scan_y;
630 if (w < sprite->Frame()->Width())
633 if (h < sprite->Frame()->Height())
639 if (h < sprite->Frame()->Height())
646 int x0 = (int) (0.1*r*s);
647 int y0 = (int) (0.1*r*c);
648 int x1 = (int) (1.0*r*s);
649 int y1 = (int) (1.0*r*c);
670 for (
int dir = 0; dir < 4; dir++) {
674 case 0: tick =
Point( 0, 0, 1000);
break;
675 case 1: tick =
Point( 1000, 0, 0);
break;
676 case 2: tick =
Point( 0, 0, -1000);
break;
677 case 3: tick =
Point(-1000, 0, 0);
break;
680 double tx = tick * hsd_cam.
vrt();
681 double tz = tick * hsd_cam.
vpn();
682 double az = asin(fabs(tx) / 1000);
684 if (tx < 0) az = -az;
687 if (az < 0) az = -
PI - az;
690 for (
double range = 0.3; range < 1; range += 0.3) {
691 int x0 = (int) (sin(az) * r * range);
692 int y0 = (int) (cos(az) * r * range);
693 int x1 = (int) (sin(az) * r * (range + 0.1));
694 int y1 = (int) (cos(az) * r * (range + 0.1));
708 const Camera* cam = &hsd_cam;
714 double tx = pt * cam->
vrt();
715 double ty = pt * cam->
vup();
716 double tz = pt * cam->
vpn();
720 double az = asin(fabs(tx) / rng);
735 int x = (int) (xc + sin(az) * rng * rscale);
736 int y = (int) (yc - cos(az) * rng * rscale);
754 if (c_ship ==
ship)
continue;
760 double tx = targ_pt * hsd_cam.
vrt();
762 double true_range = targ_pt.
length();
763 double az = asin(fabs(tx) / true_range);
766 if (rg > limit || rg <= 0)
779 int x = (int) (xc + sin(az) * rg * rscale);
780 int y = (int) (yc - cos(az) * rg * rscale);
784 if (x < scan_x || y < scan_y)
837 int r = scan_r / 2 - 4;
839 double xctr = (scan_r / 2.0) - 0.5;
840 double yctr = (scan_r / 2.0) + 0.5;
842 int xc = (int) xctr + scan_x;
843 int yc = (int) yctr + scan_y;
854 if (w < sprite->Frame()->Width())
857 if (h < sprite->Frame()->Height())
863 if (h < sprite->Frame()->Height())
881 const Camera* cam = &hsd_cam;
887 double tx = pt * cam->
vrt();
888 double ty = pt * cam->
vup();
889 double tz = pt * cam->
vpn();
893 double az = asin(fabs(tx) / rng);
910 ty = log10(ty-9) * r/8;
913 ty = -log10(9-ty) * r/8;
919 int x = (int) (sin(az) * rng * rscale);
920 int y = (int) (cos(az) * rng * rscale/2);
956 if (c_ship ==
ship)
continue;
962 double tx = targ_pt * hsd_cam.
vrt();
963 double ty = targ_pt * hsd_cam.
vup();
965 double true_range = targ_pt.
length();
966 double az = asin(fabs(tx) / true_range);
969 if (rg > limit || rg <= 0)
985 int x = (int) (sin(az) * rg * rscale);
986 int y = (int) (cos(az) * rg * rscale/2);
987 int z = (int) (ty * rscale/2);
1060 y += 256 - this->
rect.
y;
1067 if (percent < 3)
return;
1068 if (percent > 100) percent = 100;
1093 if (
lines <= 1)
return;
1106 if (
lines <= 2)
return;
1115 hours = (clock / 3600000) ;
1116 minutes = (clock / 60000) % 60;
1117 seconds = (clock / 1000) % 60;
1123 sprintf_s(txt,
"%02d:%02d:%02d", hours, minutes, seconds);
1133 if (
lines <= 4)
return;
1161 status_rect.
y += 32;
1167 status_rect.
y += 10;
1170 if (
lines <= 1)
return;
1177 status_rect.
y += 10;
1181 if (
lines <= 2)
return;
1184 if (quantum_drive) {
1187 status_rect.
y += 10;
1190 if (
lines <= 3)
return;
1201 DrawGauge(status_rect.
x+70, status_rect.
y, (
int) hull);
1202 status_rect.
y += 10;
1204 if (
lines <= 4)
return;
1210 status_rect.
y += 10;
1213 if (
lines <= 5)
return;
1219 status_rect.
y += 10;
1222 if (
lines <= 6)
return;
1232 sprintf_s(ammo,
"%d *", w->
Ammo());
1234 sprintf_s(ammo,
"%d", w->
Ammo());
1237 status_rect.
x += 70;
1239 status_rect.
x -= 70;
1240 status_rect.
y += 10;
1248 status_rect.
x += 70;
1250 status_rect.
x -= 70;
1251 status_rect.
y += 10;
1258 status_rect.
x += 70;
1260 status_rect.
x -= 70;
1261 status_rect.
y += 10;
1271 status_rect.
x += 70;
1273 status_rect.
x -= 70;
1274 status_rect.
y += 10;
1279 status_rect.
x += 70;
1285 strcpy_s(txt,
Game::GetText(
"MFD.status.SENSOR-OFF").data());
1289 status_rect.
x -= 70;
1290 status_rect.
y += 10;
1294 if (
lines <= 7)
return;
1297 status_rect.
x += 70;
1303 status_rect.
x -= 70;
1304 status_rect.
y += 10;
1306 status_rect.
x += 70;
1340 Print(
"MFD DrawMFDText() invalid mfd_text index %d '%s'\n", index, txt);
1355 int n = strlen(txt);
1357 if (n > 250) n = 250;
1360 for (i = 0; i < n; i++) {
1361 if (islower(txt[i]))
1362 txt_buf[i] = toupper(txt[i]);
1364 txt_buf[i] = txt[i];
1371 Rect hud_rect(txt_rect);
1373 hud_rect.
x = txt_rect.
x + this->index * 128 - this->
rect.
x;
1374 hud_rect.
y = txt_rect.
y + 256 - this->
rect.
y;
1386 mt.
font->
DrawText(txt_buf, 0, txt_rect, align | DT_SINGLELINE);
1397 Print(
"MFD HideMFDText() invalid mfd_text index %d\n", index);