71 , system(0), zoom(1.1), offset_x(0), offset_y(0), ship(0), campaign(0)
72 , captured(false), dragging(false), adding_navpt(false)
73 , moving_navpt(false), moving_elem(false)
75 , current_star(0), current_planet(0), current_region(0)
76 , current_ship(0), current_elem(0), current_navpt(0), mission(0)
77 , scrolling(0), scroll_x(0), scroll_y(0), click_x(0), click_y(0)
78 , active_menu(0), map_menu(0), map_system_menu(0), map_sector_menu(0)
79 , ship_menu(0), editor(false)
80 , nav_menu(0), action_menu(0), objective_menu(0), formation_menu(0), speed_menu(0)
81 , hold_menu(0), farcast_menu(0), menu_view(0)
83 for (
int i = 0; i < 3; i++) {
155 switch (star->
Type()) {
205 if (rgn && rgn->
System()) {
408 bool send_nav_data =
false;
409 bool can_command =
true;
428 send_nav_data =
true;
435 send_nav_data =
true;
443 case MAP_HOLD + 0: hold_time = 0;
break;
444 case MAP_HOLD + 1: hold_time = 60;
break;
445 case MAP_HOLD + 2: hold_time = 300;
break;
446 case MAP_HOLD + 3: hold_time = 600;
break;
447 case MAP_HOLD + 4: hold_time = 900;
break;
452 send_nav_data =
true;
459 send_nav_data =
true;
466 send_nav_data =
true;
474 send_nav_data =
true;
492 n =
new(__FILE__,__LINE__)
Instruction(rgn, init_pt);
495 n =
new(__FILE__,__LINE__)
Instruction(rgn_name, init_pt);
516 n =
new(__FILE__,__LINE__)
Instruction(rgn_name, init_pt);
586 if (send_nav_data && sim) {
628 if (mode >= 0 && mode < 3) {
740 FindShips(
true,
true,
true,
false, ships);
744 FindShips(
true,
true,
true,
false, ships);
748 FindShips(
true,
false,
true,
true, ships);
752 FindShips(
false,
false,
false,
true, ships);
756 FindShips(
false,
false,
true,
false, ships);
760 FindShips(
false,
true,
false,
false, ships);
764 for (
int i = 0; i < ships.
size(); i++)
787 if (!station && elem->
IsStatic())
continue;
788 if (!starship && elem->
IsStarship())
continue;
789 if (!dropship && elem->
IsDropship())
continue;
808 for (
int i = 0; i < rgn->
Ships().
size(); i++) {
811 if (!station && s->
IsStatic())
continue;
884 selected_elem = elem.
value();
895 if (!_stricmp(selected_elem->
Region(), rgn->
Name())) {
940 selected_elem = elem.
value();
951 if (!_stricmp(selected_elem->
Region(), rgn->
Name())) {
996 selected_elem = elem.
value();
1007 if (!_stricmp(selected_elem->
Region(), rgn->
Name())) {
1025 selship = s.
value();
1069 if (simrgn && simrgn->
NumShips()) {
1182 double sx = loc.
x * scale;
1183 double sy = loc.
y * scale;
1184 double cx =
rect.
w/2;
1185 double cy =
rect.
h/2;
1187 int test_x = (int) (cx + sx + ox);
1188 int test_y = (int) (cy + sy + oy);
1190 bool visible = test_x >= 0 && test_x <
rect.
w &&
1191 test_y >= 0 && test_y <
rect.
h;
1208 if (index < 0 || index == current_region || index >=
regions.
size())
1242 if (!strcmp(rgn_name, r->
Name())) {
1263 double cx =
rect.
w/2;
1264 double cy =
rect.
h/2;
1267 double dist = 1.0e20;
1271 c = (cx>cy) ? cx : cy;
1287 double d = sqrt(dx*dx + dy*dy);
1306 double dx = (star->
Location().
x - test_x);
1307 double dy = (star->
Location().
y - test_y);
1308 double d = sqrt(dx*dx + dy*dy);
1328 double dx = (planet->
Location().
x - test_x);
1329 double dy = (planet->
Location().
y - test_y);
1330 double d = sqrt(dx*dx + dy*dy);
1351 double dx = (region->
Location().
x - test_x);
1352 double dy = (region->
Location().
y - test_y);
1353 double d = sqrt(dx*dx + dy*dy);
1392 double dx = nloc.
x - test_x;
1393 double dy = nloc.
y - test_y;
1394 double d = sqrt(dx*dx + dy*dy);
1419 double dx = sloc.
x - test_x;
1420 double dy = sloc.
y - test_y;
1421 double d = sqrt(dx*dx + dy*dy);
1451 for (
int i = 0; i < simrgn->
Ships().
size(); i++) {
1461 double dx = nloc.
x - test_x;
1462 double dy = nloc.
y - test_y;
1463 double d = sqrt(dx*dx + dy*dy);
1490 double dx = sloc.
x - test_x;
1491 double dy = sloc.
y - test_y;
1492 double d = sqrt(dx*dx + dy*dy);
1599 if (font && text && *text) {
1605 label_rect.
Inset(8,8,8,8);
1607 DWORD text_flags = DT_WORDBREAK | DT_LEFT;
1701 double cx =
rect.
w/2;
1702 double cy =
rect.
h/2;
1704 c = (cx>cy) ? cx : cy;
1739 int sx = (int) (cx + ox + s->
Location().
x * scale);
1740 int sy = (int) (cy + oy + s->
Location().
y * scale);
1742 if (sx < 4 || sx >
rect.
w-4 || sy < 4 || sy >
rect.
h-4)
1760 int bx = (int) (cx + ox + s2->
Location().
x * scale);
1761 int by = (int) (cy + oy + s2->
Location().
y * scale);
1772 else if (ay == by) {
1785 ax += (int) (8 * d.
x);
1786 ay += (int) (8 * d.
y);
1788 bx -= (int) (8 * d.
x);
1789 by -= (int) (8 * d.
y);
1803 int sx = (int) (cx + ox + s->
Location().
x * scale);
1804 int sy = (int) (cy + oy + s->
Location().
y * scale);
1807 if (sx < 4 || sx >
rect.
w-4 || sy < 4 || sy >
rect.
h-4)
1812 if (!strncmp(s->
Name(),
"GSC", 3))
1817 Rect name_rect(sx-60, sy+8, 120, 20);
1886 char resolution[64];
1887 sprintf_s(resolution,
"%s: %s",
Game::GetText(
"MapView.info.Resolution").data(), r_txt);
1902 caption += rgn->
Name();
1919 double cx =
rect.
w/2;
1920 double cy =
rect.
h/2;
1922 int size = (int) rgn->
Radius();
1925 c = (cx<cy) ? cx : cy;
1932 int left = (int) (-size * scale + ox + cx);
1933 int right = (int) ( size * scale + ox + cx);
1934 int top = (int) (-size * scale + oy + cy);
1935 int bottom = (int) ( size * scale + oy + cy);
1937 Color major(48,48,48);
1938 Color minor(24,24,24);
1943 for (x = 0; x <= size; x += step) {
1944 int lx = (int) (x * scale + ox + cx);
1950 lx = (int) (-x * scale + ox + cx);
1956 if (++tick > 3) tick = 0;
1961 for (y = 0; y <= size; y += step) {
1962 int ly = (int) (y * scale + oy + cy);
1968 ly = (int) (-y * scale + oy + cy);
1974 if (++tick > 3) tick = 0;
1978 if (
r > 70e3) rep = 2;
1979 if (
r > 250e3) rep = 1;
2059 char resolution[64];
2060 sprintf_s(resolution,
"%s: %s",
Game::GetText(
"MapView.info.Resolution").data(), r_txt);
2071 int grid_step =
rect.
w/8;
2080 for (
int i = 1; i < 4; i++) {
2093 int type = body.
Type();
2103 double cx =
rect.
w/2;
2104 double cy =
rect.
h/2;
2106 c = (cx<cy) ? cx : cy;
2112 double xscale = cx /
r;
2113 double yscale = cy /
r * 0.75;
2118 double bo_x = body.
Orbit() * xscale;
2119 double bo_y = body.
Orbit() * yscale;
2120 double br = body.
Radius() * yscale;
2134 min_pr *= (index+1);
2137 double min_x = min_pr * xscale / yscale;
2138 double min_y = min_pr;
2153 int ipx = (int) (cx + px + ox);
2154 int ipy = (int) (cy + py + oy);
2155 int ibo_x = (int) bo_x;
2156 int ibo_y = (int) bo_y;
2165 double b =
rect.
w*32;
2172 bx = px + bo_x * cos(body.
Phase());
2173 by = py + bo_y * sin(body.
Phase());
2176 if (br < min_br) br = min_br;
2188 int icx = (int) (cx + bx + ox);
2189 int icy = (int) (cy + by + oy);
2218 if (ibr >= 4 || combatant->
GetIFF() == 1)
2225 label_rect.
x = x1 - label_w + (int) br;
2226 label_rect.
y = y1 - label_h;
2227 label_rect.
w = label_w * 2;
2228 label_rect.
h = label_h;
2255 int w = img.
Width();
2258 for (
int y = 0; y < h; y++) {
2259 for (
int x = 0; x < w; x++) {
2271 static POINT shipshape1[] = { {6,0}, {-6,4}, {-6,-4} };
2272 static POINT shipshape2[] = { {8,0}, { 4,4}, {-8,4}, {-8,-4}, {4,-4} };
2273 static POINT shipshape3[] = { {8,8}, {-8,8}, {-8,-8}, {8,-8} };
2285 double cx =
rect.
w/2;
2286 double cy =
rect.
h/2;
2288 c = (cx<cy) ? cx : cy;
2299 int sprite_width = 10;
2305 double sx = (sloc.
x + rlx) * scale;
2306 double sy = (sloc.
y + rly) * scale;
2308 shiploc.x = (int) (cx + sx + ox);
2309 shiploc.y = (int) (cy + sy + oy);
2311 bool ship_visible = shiploc.x >= 0 && shiploc.x <
rect.
w &&
2312 shiploc.y >= 0 && shiploc.y <
rect.
h;
2320 window->
Print(shiploc.x-sprite_width, shiploc.y+sprite_width+2, s.
Name());
2330 theta = acos(heading.
x);
2332 theta = -acos(heading.
x);
2334 const double THETA_SLICE = 4 /
PI;
2335 const double THETA_OFFSET =
PI + THETA_SLICE/2;
2337 int sprite_index = (int) ((theta + THETA_OFFSET) * THETA_SLICE);
2341 if (sprite_index < 0 || sprite_index >= nsprites)
2342 sprite_index = sprite_index % nsprites;
2349 sprite_width = bmp.
Width()/2;
2354 shiploc.x+sprite_width,
2377 window->
Print(shiploc.x-sprite_width, shiploc.y+sprite_width+2, s.
Name());
2385 x1 = (int) (shiploc.x - sprite_width - 1);
2386 x2 = (int) (shiploc.x + sprite_width + 1);
2387 y1 = (int) (shiploc.y - sprite_width - 1);
2388 y2 = (int) (shiploc.y + sprite_width + 1);
2409 if (!visible)
return;
2418 double cx =
rect.
w/2;
2419 double cy =
rect.
h/2;
2421 c = (cx<cy) ? cx : cy;
2432 int sprite_width = 10;
2438 double sx = (s.
Location().
x + rlx) * scale;
2439 double sy = (s.
Location().
y + rly) * scale;
2441 shiploc.x = (int) (cx + sx + ox);
2442 shiploc.y = (int) (cy + sy + oy);
2444 bool ship_visible = shiploc.x >= 0 && shiploc.x <
rect.
w &&
2445 shiploc.y >= 0 && shiploc.y <
rect.
h;
2453 window->
Print(shiploc.x-sprite_width, shiploc.y+sprite_width+2, s.
Name());
2458 const double THETA_SLICE = 4 /
PI;
2459 const double THETA_OFFSET =
PI / 2;
2461 int sprite_index = (int) ((theta + THETA_OFFSET) * THETA_SLICE);
2468 if (sprite_index < 0 || sprite_index >= nsprites)
2469 sprite_index = sprite_index % nsprites;
2476 sprite_width = bmp.
Width()/2;
2481 shiploc.x+sprite_width,
2507 sprintf_s(label,
"%s x %d", (
const char*) s.
Name(), s.
Count());
2509 strcpy_s(label, (
const char*) s.
Name());
2511 window->
Print(shiploc.x-sprite_width, shiploc.y+sprite_width+2, label);
2519 x1 = (int) (shiploc.x - sprite_width - 1);
2520 x2 = (int) (shiploc.x + sprite_width + 1);
2521 y1 = (int) (shiploc.y - sprite_width - 1);
2522 y2 = (int) (shiploc.y + sprite_width + 1);
2541 double cx =
rect.
w/2;
2542 double cy =
rect.
h/2;
2544 c = (cx<cy) ? cx : cy;
2559 bool old_in =
false;
2564 bool first_in =
false;
2566 bool draw_route =
true;
2567 bool draw_bold =
false;
2573 s_marker = s_marker * 1.5;
2578 s_marker = s_marker * 1.5;
2582 for (
int i = 0; i < s_route.
size(); i++) {
2586 double nav_x = navpt->
Location().
x * scale;
2587 double nav_y = navpt->
Location().
y * scale;
2589 int isx = (int) (cx + nav_x + ox);
2590 int isy = (int) (cy + nav_y + oy);
2592 if (old_in && draw_route) {
2593 int iox = (int) (cx + old_x + ox);
2594 int ioy = (int) (cy + old_y + oy);
2609 if ((x1*x1 + y1*y1) > 2000) {
2612 int imx = (int) (cx + (old_x+nav_x)/2 + ox);
2613 int imy = (int) (cy + (old_y+nav_y)/2 + oy);
2633 else if (!first_in) {
2648 sprintf_s(buf,
"%d", i+1);
2665 sprintf_s(buf,
"%d", navpt->
Speed());
2672 sprintf_s(buf,
"%s %s",
Game::GetText(
"MapView.item.Hold").data(), hold_time);
2703 old_x = old_loc.
x * scale;
2704 old_y = old_loc.
y * scale;
2709 old_in = (elem->
Region() == rgn->
Name()) ?
true :
false;
2713 old_x = old_loc.
x * scale;
2714 old_y = old_loc.
y * scale;
2719 int iox = (int) (cx + old_x + ox);
2720 int ioy = (int) (cy + old_y + oy);
2723 int x1 = (iox-first_x);
2724 int y1 = (ioy-first_y);
2735 if ((x1*x1 + y1*y1) > 2000) {
2736 double dist =
Point(first_loc - old_loc).
length();
2737 double nav_x = first_loc.
x * scale;
2738 double nav_y = first_loc.
y * scale;
2740 int imx = (int) (cx + (old_x+nav_x)/2 + ox);
2741 int imy = (int) (cy + (old_y+nav_y)/2 + oy);
2766 case 0: x1 = x - 64;
2772 case 1: x1 = x - 200;
2777 default: x1 = x + r + 4;
2797 switch (group->
Type()) {
2860 double cx =
rect.
w/2;
2861 double cy =
rect.
h/2;
2863 c = (cx<cy) ? cx : cy;
2874 int sprite_width = 10;
2888 double sx = (unit->
Location().
x + rlx) * scale;
2889 double sy = (unit->
Location().
y + rly) * scale;
2891 shiploc.x = (int) (cx + sx + ox);
2892 shiploc.y = (int) (cy + sy + oy);
2894 bool ship_visible = shiploc.x >= 0 && shiploc.x <
rect.
w &&
2895 shiploc.y >= 0 && shiploc.y <
rect.
h;
2903 sprintf_s(buf,
"%s", unit->
Name().
data());
2905 window->
Print(shiploc.x-sprite_width, shiploc.y+sprite_width+2, buf);
2908 int sprite_index = 2;
2915 if (sprite_index < 0 || sprite_index >= nsprites)
2916 sprite_index = sprite_index % nsprites;
2923 sprite_width = bmp.
Width()/2;
2928 shiploc.x+sprite_width,
2952 window->
Print(shiploc.x-sprite_width, shiploc.y+sprite_width+2, label);
2979 POINT testloc, leadloc;
2984 double dx = testloc.x - leadloc.x;
2985 double dy = testloc.y - leadloc.y;
2986 double d = dx*dx + dy*dy;
3000 POINT testloc, refloc;
3013 if (ref && ref != &test) {
3016 double dx = testloc.x - refloc.x;
3017 double dy = testloc.y - refloc.y;
3018 double d = dx*dx + dy*dy;
3032 double cx =
rect.
w/2;
3033 double cy =
rect.
h/2;
3035 c = (cx<cy) ? cx : cy;
3064 double sx = (s.
Location().
x + rlx) * scale;
3065 double sy = (s.
Location().
y + rly) * scale;
3067 shiploc.x = (int) (cx + sx + ox);
3068 shiploc.y = (int) (cy + sy + oy);
3081 POINT testloc, refloc;
3092 if (ref && ref != &test && !_stricmp(ref->
Region(), rgn->
Name())) {
3095 double dx = testloc.x - refloc.x;
3096 double dy = testloc.y - refloc.y;
3097 double d = dx*dx + dy*dy;
3111 double cx =
rect.
w/2;
3112 double cy =
rect.
h/2;
3114 c = (cx<cy) ? cx : cy;
3143 double sx = (s.
Location().
x + rlx) * scale;
3144 double sy = (s.
Location().
y + rly) * scale;
3146 shiploc.x = (int) (cx + sx + ox);
3147 shiploc.y = (int) (cy + sy + oy);
3382 double d = sqrt(dx*dx + dy*dy);
3404 double d = sqrt(dx*dx + dy*dy);
3422 bool process_event =
false;
3425 process_event =
true;