55 factioncolours = NULL;
62 delete screenoccupation;
71 delete factioncolours;
101 minimumitemscaledown = 0.2;
102 maximumitemscaleup = 3.0;
126 system_view = start_sys_ortho ? VIEW_ORTHO : VIEW_2D;
127 galaxy_view = start_sec_ortho ? VIEW_ORTHO : VIEW_2D;
128 system_multi_dimensional = 1;
129 galaxy_multi_dimensional = 1;
131 zshiftmultiplier = 2.5;
132 item_zscalefactor = 1.0;
133 system_item_scale = 1.0;
134 mouse_previous_state[0] = 0;
135 mouse_previous_state[1] = 0;
136 mouse_previous_state[2] = 0;
137 mouse_previous_state[3] = 0;
138 mouse_previous_state[4] = 0;
144 mouse_wentdown[0] = 0;
145 mouse_wentdown[1] = 0;
146 mouse_wentdown[2] = 0;
147 mouse_wentdown[3] = 0;
148 mouse_wentdown[4] = 0;
154 sectorIter.
init( systemIter );
155 systemselectionindex = 0;
156 sectorselectionindex = 0;
157 destinationsystemindex = 0;
158 currentsystemindex = 0;
159 setFocusedSystemIndex( 0 );
163 if (
getSaveData( 0,
"436457r1K3574r7uP71m35", 0 ) <= time_to_helpscreen)
167 currentselection = NULL;
169 unselectedalpha = 1.0;
171 sectorOffset = systemOffset = 0;
175 factioncolours[p].
r = 1;
176 factioncolours[p].
g = 1;
177 factioncolours[p].
b = 1;
178 factioncolours[p].
a = 1;
181 meshcoordinate_x[p] = 0.0;
183 meshcoordinate_y[p] = 0.0;
185 meshcoordinate_z[p] = 0.0;
187 meshcoordinate_z_delta[p] = 0.0;
195 screenskipby4[0] = .3;
196 screenskipby4[1] = .7;
197 screenskipby4[2] = .3;
198 screenskipby4[3] = .7;
200 buttonskipby4_1[0] = .75;
201 buttonskipby4_1[1] = .95;
202 buttonskipby4_1[2] = .85;
203 buttonskipby4_1[3] = .90;
205 buttonskipby4_2[0] = .75;
206 buttonskipby4_2[1] = .95;
207 buttonskipby4_2[2] = .75;
208 buttonskipby4_2[3] = .80;
210 buttonskipby4_3[0] = .75;
211 buttonskipby4_3[1] = .95;
212 buttonskipby4_3[2] = .65;
213 buttonskipby4_3[3] = .70;
215 buttonskipby4_4[0] = .75;
216 buttonskipby4_4[1] = .95;
217 buttonskipby4_4[2] = .55;
218 buttonskipby4_4[3] = .60;
220 buttonskipby4_5[0] = .75;
221 buttonskipby4_5[1] = .95;
222 buttonskipby4_5[2] = .45;
223 buttonskipby4_5[3] = .50;
225 buttonskipby4_6[0] = .75;
226 buttonskipby4_6[1] = .95;
227 buttonskipby4_6[2] = .35;
228 buttonskipby4_6[3] = .40;
230 buttonskipby4_7[0] = .75;
231 buttonskipby4_7[1] = .95;
232 buttonskipby4_7[2] = .25;
233 buttonskipby4_7[3] = .30;
236 screenskipby4[0] = .3;
237 screenskipby4[1] = .7;
238 screenskipby4[2] = .3;
239 screenskipby4[3] = .7;
241 buttonskipby4_1[0] = .75;
242 buttonskipby4_1[1] = .95;
243 buttonskipby4_1[2] = .85;
244 buttonskipby4_1[3] = .90;
246 buttonskipby4_2[0] = .75;
247 buttonskipby4_2[1] = .95;
248 buttonskipby4_2[2] = .75;
249 buttonskipby4_2[3] = .80;
251 buttonskipby4_3[0] = .75;
252 buttonskipby4_3[1] = .95;
253 buttonskipby4_3[2] = .65;
254 buttonskipby4_3[3] = .70;
256 buttonskipby4_4[0] = .75;
257 buttonskipby4_4[1] = .95;
258 buttonskipby4_4[2] = .55;
259 buttonskipby4_4[3] = .60;
261 buttonskipby4_5[0] = .75;
262 buttonskipby4_5[1] = .95;
263 buttonskipby4_5[2] = .45;
264 buttonskipby4_5[3] = .50;
266 buttonskipby4_6[0] = .75;
267 buttonskipby4_6[1] = .95;
268 buttonskipby4_6[2] = .35;
269 buttonskipby4_6[3] = .40;
271 buttonskipby4_7[0] = .75;
272 buttonskipby4_7[1] = .95;
273 buttonskipby4_7[2] = .25;
274 buttonskipby4_7[3] = .30;
279 vs_fprintf( stderr,
"ERROR: Map mesh file not found!!! Using default: blank mesh.\n" );
325 if ( (screenskipby4[1]-screenskipby4[0]) < (screenskipby4[3]-screenskipby4[2]) )
326 system_item_scale *= (screenskipby4[1]-screenskipby4[0]);
328 system_item_scale *= (screenskipby4[3]-screenskipby4[2]);
329 screenoccupation =
new navscreenoccupied( screenskipby4[0], screenskipby4[1], screenskipby4[2], screenskipby4[3], 1 );
332 float tempcol1[4] = {1, 0.3, 0.3, 1.0};
334 currentcol =
GFXColor( tempcol1[0], tempcol1[1], tempcol1[2], tempcol1[3] );
335 float tempcol2[4] = {1, 0.77, 0.3, 1.0};
337 destinationcol =
GFXColor( tempcol2[0], tempcol2[1], tempcol2[2], tempcol2[3] );
338 float tempcol3[4] = {0.3, 1, 0.3, 1.0};
340 selectcol =
GFXColor( tempcol3[0], tempcol3[1], tempcol3[2], tempcol3[3] );
341 float tempcol4[4] = {1, 0.3, 0.3, 1.0};
343 pathcol =
GFXColor( tempcol4[0], tempcol4[1], tempcol4[2], tempcol4[3] );
362 static float zrange =
364 static float zfloor =
376 float screen_x = 0.0;
377 float screen_y = 0.0;
378 float screen_z = 0.0;
380 screen_x = meshcoordinate_x[
i];
381 screen_y = meshcoordinate_y[
i];
382 screen_z = meshcoordinate_z[
i];
384 screen_z += meshcoordinate_z_delta[
i];
389 pos = (p.Cast()*screen_x)+pos;
394 pos = (q.Cast()*screen_y)+pos;
399 pos = (r.Cast()*screen_z)+pos;
402 Matrix mat( p, q, r, pos );
422 screenoccupation->
reset();
438 if (galaxy_view == VIEW_3D) {
439 DrawNavCircle( ( (screenskipby4[0]+screenskipby4[1])/2.0 ), ( (screenskipby4[2]+screenskipby4[3])/2.0 ),
444 DrawGrid( screenskipby4[0], screenskipby4[1], screenskipby4[2], screenskipby4[3],
GFXColor( 1, 1, 1, 0.2 ) );
448 if (system_view == VIEW_3D) {
449 DrawNavCircle( ( (screenskipby4[0]+screenskipby4[1])/2.0 ), ( (screenskipby4[2]+screenskipby4[3])/2.0 ),
454 DrawGrid( screenskipby4[0], screenskipby4[1], screenskipby4[2], screenskipby4[3],
GFXColor( 1, 1, 1, 0.2 ) );
461 else if (
checkbit( whattodraw, 2 ) )
472 bool outlinebuttons = 0;
475 DrawButton( buttonskipby4_1[0], buttonskipby4_1[1], buttonskipby4_1[2], buttonskipby4_1[3], 1, outlinebuttons );
476 DrawButton( buttonskipby4_2[0], buttonskipby4_2[1], buttonskipby4_2[2], buttonskipby4_2[3], 2, outlinebuttons );
477 DrawButton( buttonskipby4_3[0], buttonskipby4_3[1], buttonskipby4_3[2], buttonskipby4_3[3], 3, outlinebuttons );
478 DrawButton( buttonskipby4_4[0], buttonskipby4_4[1], buttonskipby4_4[2], buttonskipby4_4[3], 4, outlinebuttons );
479 DrawButton( buttonskipby4_5[0], buttonskipby4_5[1], buttonskipby4_5[2], buttonskipby4_5[3], 5, outlinebuttons );
480 DrawButton( buttonskipby4_6[0], buttonskipby4_6[1], buttonskipby4_6[2], buttonskipby4_6[3], 6, outlinebuttons );
481 DrawButton( buttonskipby4_7[0], buttonskipby4_7[1], buttonskipby4_7[2], buttonskipby4_7[3], 7, outlinebuttons );
508 navdrawlist factionlist( 0, screenoccupation, factioncolours );
510 float deltax = screenskipby4[1]-screenskipby4[0];
511 float deltay = screenskipby4[3]-screenskipby4[2];
512 float originx = screenskipby4[0];
513 float originy = screenskipby4[3];
515 string relationskills =
"Relations";
516 if (killlist->size() > 0)
517 relationskills +=
" | Kills";
518 drawdescription( relationskills, ( originx+(0.1*deltax) ), (originy), 1, 1, 0, screenoccupation,
GFXColor( .3, 1, .3, 1 ) );
519 drawdescription(
" ", ( originx+(0.1*deltax) ), (originy), 1, 1, 0, screenoccupation,
GFXColor( .3, 1, .3, 1 ) );
521 drawdescription(
" ", ( originx+(0.3*deltax) ), (originy), 1, 1, 0, screenoccupation,
GFXColor( .3, 1, .3, 1 ) );
522 drawdescription(
" ", ( originx+(0.3*deltax) ), (originy), 1, 1, 0, screenoccupation,
GFXColor( .3, 1, .3, 1 ) );
526 string factionname =
"factionname";
527 float relation = 0.0;
528 static string disallowedFactions =
vs_config->
getVariable(
"graphics",
"unprintable_factions",
"" );
529 static string disallowedExtension =
vs_config->
getVariable(
"graphics",
"unprintable_faction_extension",
"citizen" );
531 size_t fac_loc_before = 0, fac_loc = 0, fac_loc_after = 0;
532 for (; i < numfactions; ++i) {
534 if (factionname !=
"neutral" && factionname !=
"privateer" && factionname !=
"planets" && factionname !=
"upgrades") {
535 if ( i < killlist->
size() )
536 totkills += (
int) (*killlist)[i];
537 if (factionname.find( disallowedExtension ) != string::npos)
540 fac_loc = disallowedFactions.find( factionname, fac_loc_after );
541 while (fac_loc != string::npos) {
542 fac_loc_before = fac_loc-1;
543 if (fac_loc_before < 0)
545 fac_loc_after = fac_loc+factionname.size();
546 if ( (fac_loc == 0 || disallowedFactions[fac_loc_before] ==
' ' || disallowedFactions[fac_loc_before]
548 && (disallowedFactions[fac_loc_after] ==
' ' || disallowedFactions[fac_loc_after] ==
'\t'
549 || disallowedFactions[fac_loc_after] ==
'\0') )
551 fac_loc = disallowedFactions.find( factionname, fac_loc_after );
553 if (fac_loc != string::npos)
560 i ), ( originx+(0.1*deltax) ), (originy), 1, 1, 0, screenoccupation,
561 GFXColor( colors[0], colors[1], colors[2], 1. ) );
563 float relation01 = relation*0.5+0.5;
564 relation = ( (relation > 1 ? 1 : relation) < -1 ? -1 : relation );
565 int percent = (
int) (relation*100.0);
567 if ( i < killlist->
size() ) {
568 relationtext +=
" | ";
571 drawdescription( relationtext, ( originx+(0.3*deltax) ), (originy), 1, 1, 0, screenoccupation,
572 GFXColor( (1.0-relation01), (relation01), ( 1.0-( 2.0*
Delta( relation01, 0.5 ) ) ), 1 ) );
575 string relationtext(
"Total Kills: " );
579 drawdescription( relationtext, ( originx+(0.2*deltax) ), ( originy-(0.95*deltay) ), 1, 1, 0, screenoccupation,
580 GFXColor( (1.0-relation), relation, ( 1.0-( 2.0*
Delta( relation, 0.5 ) ) ), 1 ) );
592 displayname.
SetSize( .42, -.7 );
593 displayname.
SetPos( originx+(.1*deltax)+.37, originy );
605 "#FFA000 PRESS SHIFT-M TO TOGGLE THIS MENU \n\n\n\n#000000*******#00a6FFVega Strike 0.5#000000*********\nWelcome to VS. Your ship undocks stopped; #8080FFArrow keys/mouse/joystick#000000 steer your ship. Use #8080FF+#000000 & #8080FF-#000000 to adjust cruise control, or #8080FF/#000000 & #8080FF[backspace]#000000 to go to max governor setting or full-stop, respectively. Use #8080FFy#000000 to toggle between maneuver and travel settings for your relative velocity governors. Use #8080ff[home]#000000 & #8080FF[end]#000000 to set and unset velocity reference point to the current target (non-hostile targets only). Use #8080FFTab#000000 to activate Overdrive(if present).\n\nPress #8080FFn#000000 to cycle nav points, #8080FFt#000000 to cycle targets, and #8080FFp#000000 to target objects in front of you.\n\n#8080FF[space]#000000 fires guns, and #8080ff[Enter]#000000 fires missiles.\n\nThe #8080FFa#000000 key activates SPEC drive for insystem FTL.\nInterstellar Travel requires a #FFBB11 jump drive#000000 and #FFBB11FTL Capacitors#000000 to be installed. To jump, fly into the green wireframe nav-marker; hit #8080FFj#000000 to jump to the linked system.\n\nTo dock, target a base, planet or large vessel and hail with #8080FF0#000000 to request docking clearance. When you get close, a green box will appear. Fly to the box. When inside the box, #8080FFd#000000 will dock.\n\n#FF0000If Vega Strike halts or acts oddly,#000000\n#FFFF00immediately#000000 post stderr.txt & stdout.txt\nto http://vegastrike.sourceforge.net/forums\nbefore you restart Vega Strike.\n";
630 navdrawlist factionlist( 0, screenoccupation, factioncolours );
632 float deltax = screenskipby4[1]-screenskipby4[0];
633 float deltay = screenskipby4[3]-screenskipby4[2];
634 float originx = screenskipby4[0];
635 float originy = screenskipby4[3];
643 displayname.SetSize( .7, -.8 );
644 displayname.SetPos( originx-(.1*deltax), originy );
645 displayname.SetText( writethis );
646 displayname.SetCharSize( 1, 1 );
647 static float background_alpha =
650 bool automatte = (0 == tpbg.a);
651 if (automatte) displayname.bgcol =
GFXColor( 0, 0, 0, background_alpha );
652 displayname.Draw( writethis, 0,
true,
false, automatte );
653 displayname.bgcol = tpbg;
666 float deltax = screenskipby4[1]-screenskipby4[0];
667 float deltay = screenskipby4[3]-screenskipby4[2];
668 float originx = screenskipby4[0];
669 float originy = screenskipby4[3];
670 float width = (deltax/6);
671 float height = (0.031*deltay);
672 const unsigned numRows = 26;
673 float the_x, the_y, the_x1, the_y1, the_x2, the_y2;
675 unsigned count,
index, row;
678 drawdescription(
"Sectors", originx+(0.5*width), originy-(0.0*deltay), 1, 1, 1, screenoccupation,
682 color =
GFXColor( 0.7, 0.3, 0.3, 1.0 );
684 the_x = width*(0.5)+originx;
685 the_y = originy-(0.05*deltay);
686 the_x1 = the_x-width/2;
688 the_x2 = the_x+width/2;
690 if (
TestIfInRange( the_x1, the_x2, the_y1, the_y2, mouse_x_current, mouse_y_current ) ) {
691 if (mouse_wentdown[0] == 1)
692 if (sectorOffset > 0)
695 drawdescription(
"Up", the_x, the_y, 1, 1, 1, screenoccupation, color );
697 the_x = width*(0.5)+originx;
698 the_y = originy-(0.05*deltay)-height*(29);
699 the_x1 = the_x-width/2;
701 the_x2 = the_x+width/2;
703 if (
TestIfInRange( the_x1, the_x2, the_y1, the_y2, mouse_x_current, mouse_y_current ) ) {
704 if (mouse_wentdown[0] == 1)
705 if ( sectorOffset < (sectorIter.
size()-numRows) )
708 drawdescription(
"Down", the_x, the_y, 1, 1, 1, screenoccupation, color );
711 for (sectorIter.
seek(); !sectorIter.
done(); ++sectorIter) {
712 bool drawable =
false;
720 if ( ( (count-sectorOffset) < 0 ) || ( (count-sectorOffset) >= numRows ) ) {
724 row = (count-sectorOffset)%numRows;
725 the_x = width*(0.5)+originx;
726 the_y = originy-(0.05*deltay)-height*(row+2);
727 the_x1 = the_x-width/2;
729 the_x2 = the_x+width/2;
731 if (
TestIfInRange( the_x1, the_x2, the_y1, the_y2, mouse_x_current, mouse_y_current ) ) {
732 if (mouse_wentdown[0] == 1) {
734 sectorselectionindex = sectorIter.
getIndex();
738 if (sectorIter.
getIndex() == sectorselectionindex)
741 color =
GFXColor( 0.7, 0.3, 0.3, 1.0 );
745 drawdescription(
"Systems", originx+(1.5)*width, originy-(0.0*deltay), 1, 1, 1, screenoccupation,
749 color =
GFXColor( 0.7, 0.3, 0.3, 1.0 );
751 the_x = width*(1.5)+originx;
752 the_y = originy-(0.05*deltay);
753 the_x1 = the_x-width/2;
755 the_x2 = the_x+width/2;
757 if (
TestIfInRange( the_x1, the_x2, the_y1, the_y2, mouse_x_current, mouse_y_current ) ) {
758 if (mouse_wentdown[0] == 1)
759 if (systemOffset > 0)
762 drawdescription(
"Up", the_x, the_y, 1, 1, 1, screenoccupation, color );
764 the_x = width*(1.5)+originx;
765 the_y = originy-(0.05*deltay)-height*(29);
766 the_x1 = the_x-width/2;
768 the_x2 = the_x+width/2;
770 if (
TestIfInRange( the_x1, the_x2, the_y1, the_y2, mouse_x_current, mouse_y_current ) ) {
771 if (mouse_wentdown[0] == 1)
772 if ( systemOffset < (sectorIter[sectorselectionindex].GetSubsystemSize()-numRows) )
775 drawdescription(
"Down", the_x, the_y, 1, 1, 1, screenoccupation, color );
778 sectorIter.
seek( sectorselectionindex );
781 if ( !systemIter[index].isDrawable() )
783 if ( ( (count-systemOffset) < 0 ) || ( (count-systemOffset) >= numRows ) ) {
787 row = (count-systemOffset)%numRows;
788 the_x = width*(1.5)+originx;
789 the_y = originy-(0.05*deltay)-height*(row+2);
790 the_x1 = the_x-width/2;
792 the_x2 = the_x+width/2;
794 if (
TestIfInRange( the_x1, the_x2, the_y1, the_y2, mouse_x_current, mouse_y_current ) ) {
795 if (mouse_wentdown[0] == 1) {
797 unsigned oldselection = systemselectionindex;
798 systemselectionindex =
index;
799 if (systemselectionindex == oldselection)
800 setFocusedSystemIndex( systemselectionindex );
803 if (index == destinationsystemindex)
804 color = destinationcol;
805 else if (index == focusedsystemindex)
807 else if (index == systemselectionindex)
810 color =
GFXColor( 0.7, 0.3, 0.3, 1.0 );
811 string csector, csystem;
812 Beautify( systemIter[index].GetName(), csector, csystem );
814 drawdescription( csystem, the_x, the_y, 1, 1, 1, screenoccupation, color );
834 if ( n != (draw == 1) ) {
847 currentselection = NULL;
874 for (i = 0; i < 5; i++) {
876 if ( (status == 1) && (mouse_previous_state[i] == 0) ) {
877 mouse_wentdown[i] = 1;
879 }
else if ( (status == 0) && (mouse_previous_state[i] == 1) ) {
881 mouse_wentdown[i] = 0;
884 mouse_wentdown[i] = 0;
885 if (i == 3 || i == 4)
889 for (i = 0; i < 5; i++)
908 float distance_yz =
sqrt( (vector.j*vector.j)+(vector.k*vector.k) );
909 float current_angle = atan2( vector.k, vector.j );
911 vector.j =
cos( current_angle )*distance_yz;
912 vector.k =
sin( current_angle )*distance_yz;
915 float distance_xz =
sqrt( (vector.i*vector.i)+(vector.k*vector.k) );
916 float current_angle = atan2( vector.k, vector.i );
918 vector.i =
cos( current_angle )*distance_xz;
919 vector.k =
sin( current_angle )*distance_xz;
922 float distance_xy =
sqrt( (vector.i*vector.i)+(vector.j*vector.j) );
923 float current_angle = atan2( vector.j, vector.i );
925 vector.i =
cos( current_angle )*distance_xy;
926 vector.j =
sin( current_angle )*distance_xy;
935 for (
unsigned i = 0;
i < systemIter.
size(); ++
i)
936 if (systemIter[
i].GetName() == newSystem) {
937 setCurrentSystemIndex(
i );
942 void NavigationSystem::setFocusedSystemIndex(
unsigned newSystemIndex )
944 focusedsystemindex = newSystemIndex;
946 if (galaxy_view != VIEW_3D) {
956 void NavigationSystem::setCurrentSystemIndex(
unsigned newSystemIndex )
958 currentsystemindex = newSystemIndex;
959 static bool AlwaysUpdateNavMap =
961 if (AlwaysUpdateNavMap)
965 void NavigationSystem::setDestinationSystemIndex(
unsigned newSystemIndex )
967 destinationsystemindex = newSystemIndex;
973 if ( factioncolours == NULL || focusedsystemindex >= systemIter.
size() )
975 return systemIter[currentsystemindex].GetName();
979 if ( factioncolours == NULL || focusedsystemindex >= systemIter.
size() )
981 return systemIter[systemselectionindex].GetName();
985 if ( factioncolours == NULL || focusedsystemindex >= systemIter.
size() )
987 return systemIter[destinationsystemindex].GetName();
991 if ( factioncolours == NULL || focusedsystemindex >= systemIter.
size() )
993 return systemIter[focusedsystemindex].GetName();
1011 float mx = mouse_x_current;
1012 float my = mouse_y_current;
1016 if (button_number == 1) {
1018 }
else if (button_number == 3) {
1019 label =
"Target Selected";
1020 }
else if (button_number == 7) {
1021 label =
"2D/Ortho/3D";
1022 }
else if (
checkbit( whattodraw, 1 ) ) {
1023 if (button_number == 2)
1024 label =
"Path On/Off/Only";
1025 else if (button_number == 4)
1027 else if (button_number == 5)
1029 else if (button_number == 6)
1030 label =
"Axis Swap";
1032 if (button_number == 2)
1034 else if (button_number == 4)
1036 else if (button_number == 5)
1038 else if (button_number == 6)
1043 int length = label.size();
1044 float offset = (
float(length)*0.0065);
1045 float xl = (x1+x2)/2.0;
1046 float yl = (y1+y2)/2.0;
1047 a_label.
SetPos( (xl-offset)-(
checkbit( buttonstates, button_number-1 ) ? 0.006 : 0), (yl+0.025) );
1049 static bool nav_button_labels =
1051 if (nav_button_labels) {
1052 static float background_alpha =
1055 bool automatte = (0 == tpbg.a);
1056 if (automatte) a_label.
bgcol =
GFXColor( 0, 0, 0, background_alpha );
1057 a_label.
Draw( label, 0,
true,
false, automatte );
1058 a_label.
bgcol = tpbg;
1061 if ( (inrange == 1) && (mouse_wentdown[0] == 1) ) {
1062 currentselection = NULL;
1068 dosetbit( buttonstates, (button_number-1) );
1073 if ( (inrange == 1) && (
checkbit( buttonstates, (button_number-1) ) ) && (mouse_wentup[0]) ) {
1078 unsetbit( buttonstates, (button_number-1) );
1080 unsetbit( buttonstates, (button_number-1) );
1085 if (button_number == 1)
1091 if (button_number == 2) {
1094 path_view = (path_view+1)%PATH_MAXIMUM;
1095 else if ( !
checkbit( whattodraw, 1 ) )
1102 if (button_number == 3) {
1106 setDestinationSystemIndex( systemselectionindex );
1112 if (button_number == 4) {
1117 setFocusedSystemIndex( currentsystemindex );
1118 systemselectionindex = currentsystemindex;
1129 if (button_number == 5) {
1145 if (button_number == 6) {
1166 if (button_number == 7) {
1167 if ( (
checkbit( whattodraw, 1 ) ) && (
checkbit( whattodraw, 2 ) ) && galaxy_multi_dimensional ) {
1168 galaxy_view = (galaxy_view+1)%VIEW_MAX;
1173 if ( (
checkbit( whattodraw, 1 ) ) && ( !
checkbit( whattodraw, 2 ) ) && system_multi_dimensional ) {
1174 system_view = (system_view+1)%VIEW_MAX;
1188 unsetbit( buttonstates, (button_number-1) );
1195 if (
checkbit( buttonstates, (button_number-1) ) )
1201 if (
checkbit( buttonstates, (button_number-1) ) )
1235 template <
class T >
1236 static inline bool intersect( T x0, T y0, T x1, T y1, T sx0, T sy0, T sx1, T sy1, T &ansx, T &ansy )
1239 if ( ( (x1 == x0) && (sx1 == sx0) ) || ( (x1 == x0) && (y1 == y0) ) || ( (sx1 == sx0) && (sy1 == sy0) ) ) {
1244 if ( (x1 == x0) && (sy1 == sy0) ) {
1249 && x1 <= sx1) || (sx1 <= x1 && x1 <= sx0) ) && ( (y0 <= sy1 && sy1 <= y1) || (y1 <= sy1 && sy1 <= y0) );
1251 if ( (sx1 == sx0) && (y1 == y0) ) {
1256 && sx1 <= x1) || (x1 <= sx1 && sx1 <= x0) ) && ( (sy0 <= y1 && y1 <= sy1) || (sy1 <= y1 && y1 <= sy0) );
1259 if ( (x1 == x0) || (sx1 == sx0) ) {
1277 T m = (y1-y0)/(x1-x0);
1278 T sm = (sy1-sy0)/(sx1-sx0);
1282 ansx = (m*x1-sm*sx1-y1+sy1)/(m-sm);
1283 ansy = (y1-m*x1+m*ansx);
1286 || (x1 <= ansx && ansx <= x0) ) && ( (sx0 <= ansx && ansx <= sx1) || (sx1 <= ansx && ansx <= sx0) ) ) {
1304 if (
intersect( x, y, x1, y1, screenskipby4[1], screenskipby4[3], screenskipby4[0], screenskipby4[3], ansx, ansy )
1305 ||
intersect( x, y, x1, y1, screenskipby4[0], screenskipby4[2], screenskipby4[0], screenskipby4[3], ansx, ansy )
1306 ||
intersect( x, y, x1, y1, screenskipby4[0], screenskipby4[2], screenskipby4[1], screenskipby4[2], ansx, ansy )
1307 ||
intersect( x, y, x1, y1, screenskipby4[1], screenskipby4[3], screenskipby4[1], screenskipby4[2], ansx, ansy ) ) {
1317 if ( ( (tx < x2) && (tx > x1) ) && ( (ty < y2) && (ty > y1) ) )
1328 if ( ( ( (x-tx)*(x-tx) )+( (y-ty)*(y-ty) ) ) < ( (0.5*size)*(0.5*size) ) )
1340 if ( (
Delta( tx, x ) < (0.5*size) ) && (
Delta( ty, y ) < (0.5*size) ) )
1379 void NavigationSystem::Adjust3dTransformation(
bool three_d,
bool system_vs_galaxy )
1383 if ( (mouse_previous_state[0] == 1)
1384 &&
TestIfInRange( screenskipby4[0], screenskipby4[1], screenskipby4[2], screenskipby4[3], mouse_x_current,
1385 mouse_y_current ) ) {
1386 if (system_vs_galaxy) {
1388 float ndx = -1.0*(mouse_y_current-mouse_y_previous);
1389 float ndy = -4.0*(mouse_x_current-mouse_x_previous);
1395 if (rx_s > 0.0/2) rx_s = 0.0/2;
1396 if (rx_s < -6.28/2) rx_s = -6.28/2;
1397 if (ry_s >= 6.28) ry_s -= 6.28;
1398 if (ry_s <= -6.28) ry_s += 6.28;
1399 if (rz_s >= 6.28) rz_s -= 6.28;
1400 if (rz_s <= -6.28) rz_s += 6.28;
1403 float ndy = -1.0*(mouse_y_current-mouse_y_previous);
1404 float ndx = -1.0*(mouse_x_current-mouse_x_previous);
1410 float zoom_modifier = 1.;
1412 rx_s = rx_s -= ( (ndx*camera_z)/zoom_modifier );
1413 ry_s = ry_s -= ( (ndy*camera_z)/zoom_modifier );
1414 rz_s = rz_s -= ( (ndz*camera_z)/zoom_modifier );
1419 float ndx = -1.0*(mouse_y_current-mouse_y_previous);
1420 float ndy = -4.0*(mouse_x_current-mouse_x_previous);
1426 if (rx > 0.0/2) rx = 0.0/2;
1427 if (rx < -6.28/2) rx = -6.28/2;
1428 if (ry >= 6.28) ry -= 6.28;
1429 if (ry <= -6.28) ry += 6.28;
1430 if (rz >= 6.28) rz -= 6.28;
1431 if (rz <= -6.28) rz += 6.28;
1434 float ndy = -1.0*(mouse_y_current-mouse_y_previous);
1435 float ndx = -1.0*(mouse_x_current-mouse_x_previous);
1441 float zoom_modifier = 1.;
1443 rx = rx -= ( (ndx*camera_z)/zoom_modifier );
1444 ry = ry -= ( (ndy*camera_z)/zoom_modifier );
1445 rz = rz -= ( (ndz*camera_z)/zoom_modifier );
1452 if ( ( (mouse_previous_state[1] == 1)
1453 &&
TestIfInRange( screenskipby4[0], screenskipby4[1], screenskipby4[2], screenskipby4[3], mouse_x_current,
1454 mouse_y_current ) ) || (mouse_wentdown[3] || mouse_wentdown[4]) ) {
1456 if (system_vs_galaxy) {
1457 if (mouse_wentdown[3])
1458 zoom_s += wheel_zoom_level;
1459 else if (mouse_wentdown[4])
1460 zoom_s -= wheel_zoom_level;
1462 zoom_s = zoom_s+( 8*(mouse_y_current-mouse_y_previous) );
1471 if (mouse_wentdown[3])
1472 zoom += wheel_zoom_level;
1473 else if (mouse_wentdown[4])
1474 zoom -= wheel_zoom_level;
1476 zoom = zoom+( 8*(mouse_y_current-mouse_y_previous) );
1489 void NavigationSystem::ReplaceAxes(
QVector &pos )
1496 float old_i = pos.i;
1497 float old_j = pos.j;
1498 float old_k = pos.k;
1504 float old_i = pos.i;
1505 float old_j = pos.j;
1506 float old_k = pos.k;
1515 void NavigationSystem::RecordMinAndMax(
const QVector &pos,
1526 if ( (
float) pos.i > max_x )
1527 max_x = (
float) pos.i;
1528 if ( (
float) pos.i < min_x )
1529 min_x = (
float) pos.i;
1532 if ( ( fabs( max_x-min_x ) ) > max_all )
1533 max_all = 0.5*( fabs( max_x-min_x ) );
1534 if ( (
float) pos.j > max_y )
1535 max_y = (
float) pos.j;
1536 if ( (
float) pos.j < min_y )
1537 min_y = (
float) pos.j;
1540 if ( ( fabs( max_y-min_y ) ) > max_all )
1541 max_all = 0.5*( fabs( max_y-min_y ) );
1542 if ( (
float) pos.k > max_z )
1543 max_z = (
float) pos.k;
1544 if ( (
float) pos.k < min_z )
1545 min_z = (
float) pos.k;
1548 if ( ( fabs( max_z-min_z ) ) > max_all )
1549 max_all = 0.5*( fabs( max_z-min_z ) );
1553 void NavigationSystem::DrawOriginOrientationTri(
float center_nav_x,
float center_nav_y,
bool system_not_galaxy )
1572 }
else if (axis == 1) {
1598 if (system_not_galaxy) {
1599 if (system_view == VIEW_3D) {
1600 directionx =
dxyz( directionx, 0, 0, ry_s );
1601 directionx =
dxyz( directionx, rx_s, 0, 0 );
1603 directiony =
dxyz( directiony, 0, 0, ry_s );
1604 directiony =
dxyz( directiony, rx_s, 0, 0 );
1606 directionz =
dxyz( directionz, 0, 0, ry_s );
1607 directionz =
dxyz( directionz, rx_s, 0, 0 );
1609 }
else if (galaxy_view == VIEW_3D) {
1610 directionx =
dxyz( directionx, 0, 0, ry );
1611 directionx =
dxyz( directionx, rx, 0, 0 );
1613 directiony =
dxyz( directiony, 0, 0, ry );
1614 directiony =
dxyz( directiony, rx, 0, 0 );
1616 directionz =
dxyz( directionz, 0, 0, ry );
1617 directionz =
dxyz( directionz, rx, 0, 0 );
1623 float where_x = center_nav_x-0.8*( (screenskipby4[1]-screenskipby4[0])/2 );
1624 float where_y = center_nav_y-0.8*( (screenskipby4[3]-screenskipby4[2])/2 );
1630 GFXVertex3f( where_x+( directionx.i*( 0.3/(0.3-directionx.k) ) ),
1631 where_y+( directionx.j*( 0.3/(0.3-directionx.k) ) ),
1636 GFXVertex3f( where_x+( directiony.i*( 0.3/(0.3-directiony.k) ) ),
1637 where_y+( directiony.j*( 0.3/(0.3-directiony.k) ) ),
1642 GFXVertex3f( where_x+( directionz.i*( 0.3/(0.3-directionz.k) ) ),
1643 where_y+( directionz.j*( 0.3/(0.3-directionz.k) ) ),
1651 float NavigationSystem::CalculatePerspectiveAdjustment(
float &zscale,
1655 float &system_item_scale_temp,
1656 bool system_not_galaxy )
1660 pos_flat.k = center_z;
1669 pos_flat.i -= center_x;
1670 pos_flat.j -= center_y;
1671 pos_flat.k -= center_z;
1672 if (system_not_galaxy) {
1673 if (system_view == VIEW_3D) {
1675 pos =
dxyz( pos, 0, 0, ry_s );
1676 pos =
dxyz( pos, rx_s, 0, 0 );
1678 pos_flat =
dxyz( pos_flat, 0, 0, ry_s );
1679 pos_flat =
dxyz( pos_flat, rx_s, 0, 0 );
1689 if (galaxy_view == VIEW_3D) {
1691 pos =
dxyz( pos, 0, 0, ry );
1692 pos =
dxyz( pos, rx, 0, 0 );
1694 pos_flat =
dxyz( pos_flat, 0, 0, ry );
1695 pos_flat =
dxyz( pos_flat, rx, 0, 0 );
1710 float standard_unit = 0.25*camera_z;
1712 zdistance = (camera_z-pos.k);
1713 double zdistance_flat = (camera_z-pos_flat.k);
1715 zscale = standard_unit/zdistance;
1716 double zscale_flat = standard_unit/zdistance_flat;
1718 double real_zoom = 0.0;
1719 double real_zoom_flat = 0.0;
1721 if (system_not_galaxy) {
1722 real_zoom = zoom_s*zoom_s*zscale;
1723 real_zoom_flat = zoom_s*zoom_s*zscale_flat;
1729 real_zoom = zoom*zoom*zscale;
1730 real_zoom_flat = zoom*zoom*zscale_flat;
1738 pos_flat.i *= real_zoom_flat;
1739 pos_flat.j *= real_zoom_flat;
1740 pos_flat.k *= real_zoom_flat;
1742 float itemscale = real_zoom*item_zscalefactor;
1743 if (itemscale < minimumitemscaledown)
1744 itemscale = minimumitemscaledown;
1745 if (itemscale > maximumitemscaleup)
1746 itemscale = maximumitemscaleup;
1747 system_item_scale_temp = system_item_scale*itemscale;
1752 void NavigationSystem::TranslateCoordinates(
QVector &pos,
1763 float &system_item_scale_temp,
1764 bool system_not_galaxy )
1766 float itemscale = CalculatePerspectiveAdjustment( zscale,
1770 system_item_scale_temp,
1771 system_not_galaxy );
1775 the_x = (
float) pos.i;
1776 the_y = (
float) pos.j;
1777 the_x_flat = (
float) pos_flat.i;
1778 the_y_flat = (
float) pos_flat.j;
1780 the_x = ( the_x/(themaxvalue) );
1781 the_y = ( the_y/(themaxvalue) );
1783 the_x_flat = ( the_x_flat/(themaxvalue) );
1784 the_y_flat = ( the_y_flat/(themaxvalue) );
1786 float navscreen_width_delta = (screenskipby4[1]-screenskipby4[0]);
1787 float navscreen_height_delta = (screenskipby4[3]-screenskipby4[2]);
1788 float navscreen_small_delta =
std::min( navscreen_width_delta, navscreen_height_delta );
1790 the_x = (the_x*navscreen_small_delta);
1791 the_x = the_x+center_nav_x;
1792 the_y = (the_y*navscreen_small_delta);
1793 the_y = the_y+center_nav_y;
1795 the_x_flat = (the_x_flat*navscreen_small_delta);
1796 the_x_flat = the_x_flat+center_nav_x;
1797 the_y_flat = (the_y_flat*navscreen_small_delta);
1798 the_y_flat = the_y_flat+center_nav_y;
1800 if ( (system_not_galaxy ? system_view : galaxy_view) == VIEW_ORTHO ) {
1807 void NavigationSystem::TranslateAndDisplay(
QVector &pos,
1816 float &system_item_scale_temp,
1817 bool system_not_galaxy )
1821 if ( (system_not_galaxy ? system_view : galaxy_view) == VIEW_ORTHO ) {
1822 TranslateCoordinates( pos, pos_flat, center_nav_x, center_nav_y, themaxvalue, zscale, zdistance,
1823 the_x, the_y, the_x_flat, the_y_flat, system_item_scale_temp, system_not_galaxy );
1826 TranslateCoordinates( pos, pos_flat, center_nav_x, center_nav_y, themaxvalue, zscale, zdistance,
1827 the_x, the_y, the_x_flat, the_y_flat, system_item_scale_temp, system_not_galaxy );
1829 DisplayOrientationLines( the_x, the_y, the_x_flat, the_y_flat, system_not_galaxy );
1832 void NavigationSystem::DisplayOrientationLines(
float the_x,
1836 bool system_not_galaxy )
1838 if ( (system_not_galaxy ? system_view : galaxy_view) == VIEW_ORTHO )
1850 bool display_flat_circle =
true;
1851 if ( (the_y_flat > screenskipby4[3])
1852 || (the_y_flat < screenskipby4[2])
1853 || (the_x_flat > screenskipby4[1])
1854 || (the_x_flat < screenskipby4[0]) ) {
1856 display_flat_circle =
false;
1858 bool display_flat =
true;
1859 if ( (the_x > screenskipby4[1])
1860 || (the_x < screenskipby4[0])
1861 || (the_y > screenskipby4[3])
1862 || (the_y < screenskipby4[2]) ) {
1864 display_flat =
false;
1870 if (display_flat_circle)
1871 DrawCircle( the_x_flat, the_y_flat, (.005*system_item_scale),
GFXColor( 1, 1, 1, .2 ) );
1878 void Beautify(
string systemfile,
string §or,
string &system )
1880 string::size_type slash = systemfile.find(
"/" );
1881 if (slash == string::npos) {
1883 system = systemfile;
1885 sector = systemfile.substr( 0, slash );
1886 system = systemfile.substr( slash+1 );
1888 if ( sector.size() )
1889 sector[0] = toupper( sector[0] );
1890 if ( system.size() )
1891 system[0] = toupper( system[0] );