Example #1
0
static void DrawNodeDescription( string text,
                                 float x_,
                                 float y_,
                                 float size_x,
                                 float size_y,
                                 bool ignore_occupied_areas,
                                 const GFXColor &col,
                                 navscreenoccupied *screenoccupation )
{
    //take the head and stick it in the back
    if (text.size() == 0)
        return;
    TextPlane    displayname;   //will be used to display shits names
    displayname.col = col;
    static float background_alpha =
        XMLSupport::parse_float( vs_config->getVariable( "graphics", "hud", "text_background_alpha", "0.0625" ) );
    int   length = text.size();
    float offset = (float(length)*0.005);
    if (ignore_occupied_areas) {
        displayname.SetPos( (x_-offset), y_ );
        displayname.SetText( text );
        displayname.SetCharSize( size_x, size_y );

        GFXColor tpbg = displayname.bgcol;
        bool     automatte = (0 == tpbg.a);
        if (automatte) displayname.bgcol = GFXColor( 0, 0, 0, background_alpha );
        displayname.Draw( text, 0, true, false, automatte );
        displayname.bgcol = tpbg;
    } else {
        float new_y = screenoccupation->findfreesector( x_, y_ );
        displayname.SetPos( (x_-offset), new_y );
        displayname.SetText( text );
        displayname.SetCharSize( size_x, size_y );
        GFXColor tpbg = displayname.bgcol;
        bool     automatte = (0 == tpbg.a);
        if (automatte) displayname.bgcol = GFXColor( 0, 0, 0, background_alpha );
        displayname.Draw( text, 0, true, false, automatte );
        displayname.bgcol = tpbg;
    }
}
Example #2
0
void NavigationSystem::DrawGalaxy()
{
//systemdrawlist mainlist;//(0, screenoccupation, factioncolours);	//	lists of items to draw that are in mouse range

    systemdrawlist mouselist;     //(1, screenoccupation, factioncolours);	//	lists of items to draw that are in mouse range

    string csector, csystem;

    Beautify( getCurrentSystem(), csector, csystem );
    //what's my name
    //***************************
    TextPlane systemname;       //will be used to display shits names
    string    systemnamestring = "Current System : "+csystem+" in the "+csector+" Sector.";

//int length = systemnamestring.size();
//float offset = (float(length)*0.005);
    systemname.col = GFXColor( 1, 1, .7, 1 );
    systemname.SetPos( screenskipby4[0], screenskipby4[3] );     //Looks ugly when name is too long and goes off the edge.
//systemname.SetPos( (((screenskipby4[0]+screenskipby4[1])/2)-offset) , screenskipby4[3]);
    systemname.SetText( systemnamestring );
//systemname.SetCharSize(1, 1);
    systemname.Draw();
    //***************************

    QVector pos;        //item position
    QVector pos_flat;           //item position flat on plane

    float   zdistance = 0.0;
    float   zscale    = 1.0;
    int     l;

    Adjust3dTransformation( galaxy_view == VIEW_3D, 0 );

    float center_nav_x = ( (screenskipby4[0]+screenskipby4[1])/2 );
    float center_nav_y = ( (screenskipby4[2]+screenskipby4[3])/2 );
    //**********************************

    glEnable( GL_ALPHA );
    GFXDisable( LIGHTING );
    GFXBlendMode( SRCALPHA, INVSRCALPHA );
    if (!camera_z) {
        float max_x = 0.0;
        float min_x = 0.0;
        float max_y = 0.0;
        float min_y = 0.0;
        float max_z = 0.0;
        float min_z = 0.0;

//themaxvalue = fabs(pos.i);
        themaxvalue = 0.0;

        {
            {
                systemIter.seek( focusedsystemindex );
                pos = systemIter->Position();
                ReplaceAxes( pos );
//if(galaxy_view==VIEW_3D){pos = dxyz(pos, 0, ry, 0);pos = dxyz(pos, rx, 0, 0);}

                max_x = (float) pos.i;
                min_x = (float) pos.i;
                max_y = (float) pos.j;
                min_y = (float) pos.j;
                max_z = (float) pos.k;
                min_z = (float) pos.k;

                //Find Centers
                //**********************************
                //This will use the current system as the center
                center_x = pos.i;
                center_y = pos.j;
                center_z = pos.k;
                //**********************************

                unsigned destsize = systemIter->GetDestinationSize();
                if (destsize != 0) {
                    for (unsigned i = 0; i < destsize; ++i) {
                        QVector posoth = systemIter[systemIter->GetDestinationIndex( i )].Position();
                        ReplaceAxes( posoth );
//if(galaxy_view==VIEW_3D){posoth = dxyz(pos, 0, ry, 0);posoth = dxyz(pos, rx, 0, 0);}

                        RecordMinAndMax( posoth, min_x, max_x, min_y, max_y, min_z, max_z, themaxvalue );
                    }
                }
            }
        }

        //Find Centers
        //**********************************
        //this will make the center be the center of the displayable area.
//center_x = (min_x + max_x)/2;
//center_y = (min_y + max_y)/2;
//center_z = (min_z + max_z)/2;
        //**********************************

        /*	        min_x = (min_x+center_x)/2;
         *               min_y = (min_y+center_y)/2;
         *               min_z = (min_z+center_z)/2;
         *               max_x = (max_x+center_x)/2;
         *               max_y = (max_y+center_y)/2;
         *               max_z = (max_z+center_z)/2;
         */
        //Set Camera Distance
        //**********************************

#define SQRT3 1.7320508
//themaxvalue = sqrt(themaxvalue*themaxvalue + themaxvalue*themaxvalue + themaxvalue*themaxvalue);
//themaxvalue = SQRT3*themaxvalue;

        themaxvalue *= 3;

        {
            float half_x = vsmax( max_x-center_x, center_x-min_x );
            float half_y = vsmax( max_y-center_y, center_y-min_y );
            float half_z = vsmax( max_z-center_z, center_z-min_z );

//float half_x =(0.5*(max_x - min_x));
//float half_y =(0.5*(max_y - min_y));
//float half_z =(0.5*(max_z - min_z));

            camera_z = sqrt( (half_x*half_x)+(half_y*half_y)+(half_z*half_z) );

//float halfmax = 0.5*themaxvalue;
//camera_z = sqrt( (halfmax*halfmax) + (halfmax*halfmax) + (halfmax*halfmax) );
//camera_z = 4.0*themaxvalue;
//camera_z = tihemaxvalue;
        }

        //**********************************
    }
    DrawOriginOrientationTri( center_nav_x, center_nav_y, 0 );

    //Enlist the items and attributes
    //**********************************
    systemIter.seek();
    while ( !systemIter.done() ) {
        //this draws the points
        //IGNORE UNDRAWABLE SYSTEMS
        //**********************************
        if ( !systemIter->isDrawable() ) {
            ++systemIter;
            continue;
        }
        //**********************************

        //Retrieve unit data
        //**********************************
        unsigned temp = systemIter.getIndex();

        pos = systemIter->Position();

        ReplaceAxes( pos );             //poop

        //Modify by old rotation amount
        //*************************
//if(galaxy_view==VIEW_3D){pos = dxyz(pos, 0, ry, 0);pos = dxyz(pos, rx, 0, 0);}
        //*************************
        //*************************

        GFXColor col    = systemIter->GetColor();
        Vector   oldpos = pos;
        float    the_x, the_y, the_x_flat, the_y_flat, system_item_scale_temp;
        TranslateCoordinates( pos,
                              pos_flat,
                              center_nav_x,
                              center_nav_y,
                              themaxvalue,
                              zscale,
                              zdistance,
                              the_x,
                              the_y,
                              the_x_flat,
                              the_y_flat,
                              system_item_scale_temp,
                              0 );
        float alphaadd;
        {
            float tmp = ( 1-(zoom/MAXZOOM) );
            alphaadd = (tmp*tmp)-.5;
//if (alphaadd<=0)
//alphaadd=0;
//else
            alphaadd *= 4;
        }
        col.a = (system_item_scale_temp-minimumitemscaledown)/(maximumitemscaleup-minimumitemscaledown)+alphaadd;
//col.a=GetAlpha(oldpos,center_x,center_y,center_z,zdistance);
        //IGNORE DIM AND OFF SCREEN SYETEMS
        //**********************************
        if ( (col.a < .05)
                || ( !TestIfInRange( screenskipby4[0], screenskipby4[1], screenskipby4[2], screenskipby4[3], the_x, the_y ) ) ) {
            ++systemIter;
            continue;
        }
        //**********************************

        //FIND OUT IF SYSTEM IS PART OF A VISIBLE PATH
        //**********************************
        bool isPath = false;
        if (path_view != PATH_OFF) {
            if (systemIter->part_of_path) {
                for (std::set< NavPath* >::iterator paths = systemIter->paths.begin();
                        paths != systemIter->paths.end();
                        ++paths)
                    if ( (*paths)->getVisible() ) {
                        isPath = true;
                        break;
                    }
            }
        }
        //**********************************
        //IGNORE NON-PATH SYSTEMS IN PATH_ONLY MODE
        //**********************************
        if (!isPath && path_view == PATH_ONLY) {
            ++systemIter;
            continue;
        }
        //**********************************

        int   insert_type = systemambiguous;
        float insert_size = SYSTEM_DEFAULT_SIZE;
        if ( system_item_scale_temp > (system_item_scale*3) )
            system_item_scale_temp = (system_item_scale*3);
        insert_size *= system_item_scale_temp/3;
        if (currentsystemindex == temp)
            DrawTargetCorners( the_x, the_y, (insert_size), currentcol );
        if (destinationsystemindex == temp)
            DrawTargetCorners( the_x, the_y, (insert_size)*1.2, destinationcol );
        if (systemselectionindex == temp)
            DrawTargetCorners( the_x, the_y, (insert_size)*1.4, selectcol );
        bool moused = false;
        DrawNode( insert_type, insert_size, the_x, the_y,
                  (*systemIter).GetName(), screenoccupation, moused, isPath ? pathcol : col, false, false,
                  isPath ? "" : csector );
        if (std::fabs(zdistance) < 2.0f * camera_z)
        {
            DisplayOrientationLines( the_x, the_y, the_x_flat, the_y_flat, 0 );
        }
        if ( TestIfInRangeRad( the_x, the_y, insert_size, mouse_x_current, mouse_y_current ) ) {
            mouselist.push_back( systemdrawnode( insert_type, insert_size, the_x, the_y, (*systemIter).GetName(),
                                                 systemIter.getIndex(), screenoccupation, false, isPath ? pathcol : col ) );
            moused = true;
        }
        unsigned destsize = systemIter->GetDestinationSize();
        if (destsize != 0) {
            GFXDisable( LIGHTING );
            GFXDisable( TEXTURE0 );
            GFXBegin( GFXLINE );
            for (unsigned i = 0; i < destsize; ++i) {
                CachedSystemIterator::SystemInfo &oth = systemIter[systemIter->GetDestinationIndex( i )];
                if ( oth.isDrawable() ) {
                    QVector posoth    = oth.Position();
                    ReplaceAxes( posoth );
                    Vector  oldposoth = posoth;
                    float   the_new_x, the_new_y, new_system_item_scale_temp, the_new_x_flat, the_new_y_flat;
                    //WARNING: SOME VARIABLES FOR ORIGINAL SYSTEM MAY BE MODIFIED HERE!!!
                    TranslateCoordinates( posoth,
                                          pos_flat,
                                          center_nav_x,
                                          center_nav_y,
                                          themaxvalue,
                                          zscale,
                                          zdistance,
                                          the_new_x,
                                          the_new_y,
                                          the_new_x_flat,
                                          the_new_y_flat,
                                          new_system_item_scale_temp,
                                          0 );
                    GFXColor othcol = oth.GetColor();
                    othcol.a =
                        (new_system_item_scale_temp
                         -minimumitemscaledown)/(maximumitemscaleup-minimumitemscaledown)+alphaadd;
                    //GetAlpha(oldposoth,center_x,center_y,center_z,zdistance);
                    IntersectBorder( the_new_x, the_new_y, the_x, the_y );

                    bool isConnectionPath = false;
                    if (path_view != PATH_OFF) {
                        if (systemIter->part_of_path && oth.part_of_path) {
                            for (std::set< NavPath* >::iterator paths = systemIter->paths.begin();
                                    paths != systemIter->paths.end();
                                    ++paths)
                                if ( (*paths)->getVisible() ) {
                                    if ( (*paths)->isNeighborPath( temp, systemIter->GetDestinationIndex( i ) ) ) {
                                        isConnectionPath = true;
                                        GFXColorf( pathcol );
                                        GFXVertex3f( the_x, the_y, 0 );
                                        GFXColorf( pathcol );
                                        GFXVertex3f( the_new_x, the_new_y, 0 );
                                        break;
                                    }
                                }
                        }
                    }
                    if (!isConnectionPath && path_view != PATH_ONLY) {
                        GFXColorf( col );
                        GFXVertex3f( the_x, the_y, 0 );
                        GFXColorf( othcol );
                        GFXVertex3f( the_new_x, the_new_y, 0 );
                    }
                }
            }
            GFXEnd();
        }
        ++systemIter;
    }
    //**********************************
    //Adjust mouse list for 'n' kliks
    //**********************************
    //STANDARD	: (1 3 2) ~ [0] [2] [1]
    //VS			: (1 2 3) ~ [0] [1] [2]	<-- use this
    if (mouselist.size() > 0) {
        //mouse is over a target when this is > 0
        if (mouse_wentdown[2] == 1)             //mouse button went down for mouse button 2(standard)
            rotations += 1;
    }
    if ( rotations >= static_cast<int>(mouselist.size()) )        //dont rotate more than there is
        rotations = 0;
    systemdrawlist tmpv;
    int siz = mouselist.size();
    for (l = 0; l < siz; ++l)
        tmpv.push_back( mouselist[( (unsigned int) (l+rotations) )%( (unsigned int) siz )] );
    mouselist.swap( tmpv );
    //**********************************
    //Give back the selected tail IF there is one
    //**********************************
    if (mouselist.size() > 0) {
        //mouse is over a target when this is > 0
        if (mouse_wentdown[0] == 1) {
            //mouse button went down for mouse button 1
            unsigned oldselection = systemselectionindex;
            systemselectionindex = mouselist.back().getIndex();
            //JUST FOR NOW, target == current selection. later it'll be used for other shit, that will then set target.
            if (systemselectionindex == oldselection)
                setFocusedSystemIndex( systemselectionindex );
        }
    }
    //**********************************

    //Clear the lists
    //**********************************
    {
        for (systemdrawlist::iterator it = mouselist.begin(); it != mouselist.end(); ++it)
            (*it).draw( true, &(*it) == &mouselist.back() );
    }

    mouselist.clear();          //whipe mouse over'd list
    //**********************************
}
void NavigationSystem::DrawSystem()
{
    UniverseUtil::PythonUnitIter bleh = UniverseUtil::getUnitList();
    if ( !(*bleh) )
        return;
//string mystr ("3d "+XMLSupport::tostring (system_view));
//UniverseUtil::IOmessage (0,"game","all",mystr);

    //what's my name
    //***************************
    TextPlane systemname;       //will be used to display shits names
    int faction = FactionUtil::GetFactionIndex( UniverseUtil::GetGalaxyFaction( _Universe->activeStarSystem()->getFileName() ) );
    //GFXColor factioncolor = factioncolours[faction];
    string    systemnamestring = "#ff0000Sector: #ffff00"+getStarSystemSector( _Universe->activeStarSystem()->getFileName() )
                                 +"  #ff0000Current System: #ffff00"+_Universe->activeStarSystem()->getName()+" ("
                                 +FactionUtil::GetFactionName( faction )
                                 +"#ffff00)";
    //int length = systemnamestring.size();
    //float offset = (float(length)*0.001);
    //systemname.SetPos( (((screenskipby4[0]+screenskipby4[1])/2)-offset) , screenskipby4[3]); // middle position
    systemname.SetPos( screenskipby4[0]+0.03, screenskipby4[3]+0.02 );     //left position
    systemname.col = GFXColor( 1, 1, .7, 1 );
    systemname.SetText( systemnamestring );
//systemname.SetCharSize(1, 1);
    static float background_alpha =
        XMLSupport::parse_float( vs_config->getVariable( "graphics", "hud", "text_background_alpha", "0.0625" ) );
    GFXColor     tpbg = systemname.bgcol;
    bool automatte    = (0 == tpbg.a);
    if (automatte) systemname.bgcol = GFXColor( 0, 0, 0, background_alpha );
    systemname.Draw( systemnamestring, 0, true, false, automatte );
    systemname.bgcol = tpbg;
    //***************************

//navdrawlist mainlist(0, screenoccupation, factioncolours);		//	lists of items to draw
//mainlist.unselectedalpha = unselectedalpha;
    navdrawlist mouselist( 1, screenoccupation, factioncolours );       //lists of items to draw that are in mouse range

    QVector     pos;    //item position
    QVector     pos_flat;       //item position flat on plane

    float zdistance = 0.0;
    float zscale    = 0.0;

    Adjust3dTransformation( system_view == VIEW_3D, 1 );
    //Set up first item to compare to + centres
    //**********************************
    while ( (*bleh) && ( _Universe->AccessCockpit()->GetParent() != (*bleh) )
           && ( UnitUtil::isSun( *bleh ) || !UnitUtil::isSignificant( *bleh ) ) )                                                                       //no sun's in initial setup
        ++bleh;
    if ( !(*bleh) )      //nothing there that's significant, just do it all
        bleh = UniverseUtil::getUnitList();
    //GET THE POSITION
    //*************************
    pos = (*bleh)->Position();
    ReplaceAxes( pos );
    //*************************

    //Modify by old rotation amount
    //*************************
//if(system_view==VIEW_3D)
//{
//pos = dxyz(pos, 0, ry_s, 0);
//pos = dxyz(pos, rx_s, 0, 0);
//}
    //*************************

    float max_x = (float) pos.i;
    float min_x = (float) pos.i;
    float max_y = (float) pos.j;
    float min_y = (float) pos.j;
    float max_z = (float) pos.k;
    float min_z = (float) pos.k;

//float themaxvalue = fabs(pos.i);
    themaxvalue = 0.0;

    float center_nav_x = ( (screenskipby4[0]+screenskipby4[1])/2 );
    float center_nav_y = ( (screenskipby4[2]+screenskipby4[3])/2 );
    //**********************************
    //Retrieve unit data min/max
    //**********************************
    while (*bleh) {
        //this goes through one time to get the major components locations, and scales its output appropriately
        if ( UnitUtil::isSun( *bleh ) ) {
            ++bleh;
            continue;
        }
        string temp = (*bleh)->name;
        pos = (*bleh)->Position();
        ReplaceAxes( pos );
        //Modify by old rotation amount
        //*************************
//if(system_view==VIEW_3D)
//{
//pos = dxyz(pos, 0, ry_s, 0);
//pos = dxyz(pos, rx_s, 0, 0);
//}
        //*************************
        //*************************
        if ( ( UnitUtil::isSignificant( *bleh ) ) || ( _Universe->AccessCockpit()->GetParent() == (*bleh) ) )
            RecordMinAndMax( pos, min_x, max_x, min_y, max_y, min_z, max_z, themaxvalue );
        ++bleh;
    }
    //**********************************

    //Find Centers
    //**********************************
    center_x     = (min_x+max_x)/2;
    center_y     = (min_y+max_y)/2;
    center_z     = (min_z+max_z)/2;
    //**********************************

    max_x        = 2*max_x-center_x;
    max_y        = 2*max_y-center_y;
    max_z        = 2*max_z-center_z;
    min_x        = 2*min_x-center_x;
    min_y        = 2*min_y-center_y;
    min_z        = 2*min_z-center_z;

    themaxvalue *= 2;

//#define SQRT3 1.7320508
//themaxvalue = sqrt(themaxvalue*themaxvalue + themaxvalue*themaxvalue + themaxvalue*themaxvalue);
//themaxvalue = SQRT3*themaxvalue;

    //Set Camera Distance
    //**********************************
//{
    float half_x = (max_x-min_x);
    float half_y = (max_y-min_y);
    float half_z = (max_z-min_z);

    camera_z = sqrt( (half_x*half_x)+(half_y*half_y)+(half_z*half_z) );

//float halfmax = 0.5*themaxvalue;
//camera_z = sqrt( (halfmax*halfmax) + (halfmax*halfmax) + (halfmax*halfmax) );
//camera_z = 4.0*themaxvalue;
//}

    //**********************************

    DrawOriginOrientationTri( center_nav_x, center_nav_y, 1 );

/*
 *       string mystr ("max x "+XMLSupport::tostring (max_x));
 *       UniverseUtil::IOmessage (0,"game","all",mystr);
 *
 *       string mystr2 ("min x "+XMLSupport::tostring (min_x));
 *       UniverseUtil::IOmessage (0,"game","all",mystr2);
 *
 *       string mystr3 ("max y "+XMLSupport::tostring (max_y));
 *       UniverseUtil::IOmessage (0,"game","all",mystr3);
 *
 *       string mystr4 ("min y "+XMLSupport::tostring (min_y));
 *       UniverseUtil::IOmessage (0,"game","all",mystr4);
 *
 *       string mystrcx ("center x "+XMLSupport::tostring (center_x));
 *       UniverseUtil::IOmessage (0,"game","all",mystrcx);
 *
 *       string mystrcy ("center y "+XMLSupport::tostring (center_y));
 *       UniverseUtil::IOmessage (0,"game","all",mystrcy);
 */

    Unit *ThePlayer = ( UniverseUtil::getPlayerX( UniverseUtil::getCurrentPlayer() ) );

    //Enlist the items and attributes
    //**********************************
    un_iter blah = UniverseUtil::getUnitList();
    while (*blah) {
        //this draws the points

        //Retrieve unit data
        //**********************************
        string temp = (*blah)->name;

        pos = (*blah)->Position();
        ReplaceAxes( pos );

        float the_x, the_y, the_x_flat, the_y_flat, system_item_scale_temp;
        TranslateCoordinates( pos,
                              pos_flat,
                              center_nav_x,
                              center_nav_y,
                              themaxvalue,
                              zscale,
                              zdistance,
                              the_x,
                              the_y,
                              the_x_flat,
                              the_y_flat,
                              system_item_scale_temp,
                              1 );
        //IGNORE OFF SCREEN
        //**********************************
        if ( !TestIfInRange( screenskipby4[0], screenskipby4[1], screenskipby4[2], screenskipby4[3], the_x, the_y ) ) {
            ++blah;
            continue;
        }
        //**********************************

        //Now starts the test that determines the type of things and inserts
        //|
        //|
        //\/

        float insert_size = 0.0;
        int   insert_type = navambiguous;
        if ( (*blah)->isUnit() == UNITPTR ) {
            //unit
            /*if(UnitUtil::isPlayerStarship(*blah) > -1)	//	is a PLAYER SHIP
             *  {
             *       if (UnitUtil::isPlayerStarship (*blah)==UniverseUtil::getCurrentPlayer()) //	is THE PLAYER
             *       {
             *               insert_type = navcurrentplayer;
             *               insert_size = navcurrentplayersize;
             *       }
             *       else	//	is A PLAYER
             *       {
             *               insert_type = navplayer;
             *               insert_size = navplayersize;
             *       }
             *  }
             *  else	//	is a non player ship
             *  {*/
            if ( UnitUtil::isSignificant( *blah ) ) {
                //capship or station
                if ( (*blah)->GetComputerData().max_speed() == 0 ) {
                    //is this item STATIONARY?
                    insert_type = navstation;
                    insert_size = navstationsize;
                } else {
                    //it moves = capship
                    if ( ThePlayer->InRange( (*blah), false, false ) ) {
                        //only insert if in range
                        insert_type = navcapship;
                        insert_size = navcapshipsize;
                    } else {
                        //skip unit completely if not in range
                        ++blah;
                        continue;
                    }
                }
            } else {
                //fighter
                /*if(ThePlayer->InRange((*blah),false,false))	//	only insert if in range
                 *  {
                 *       insert_type = navfighter;
                 *       insert_size = navfightersize;
                 *  }
                 *  else	// skip unit completely if not in range
                 *  {
                 * ++blah;
                 *       continue;
                 *  }*/
                if (UnitUtil::isPlayerStarship( *blah ) > -1) {
                    //is THE PLAYER
                    insert_type = navfighter;
                    insert_size = navfightersize;
                } else {
                    //skip unit completely if not in range
                    ++blah;
                    continue;
                }
            }
            //}
        } else if ( (*blah)->isUnit() == PLANETPTR ) {
            //is it a PLANET?
            if ( UnitUtil::isSun( *blah ) ) {
                //is this a SUN?
                insert_type = navsun;
                insert_size = navsunsize;
            } else if ( !( (*blah)->GetDestinations().empty() ) ) {
                //is a jump point (has destinations)
                insert_type = navjump;
                insert_size = navjumpsize;
            } else {
                //its a planet
                insert_type = navplanet;
                insert_size = navplanetsize;
            }
        } else if ( (*blah)->isUnit() == MISSILEPTR ) {
            //a missile
            insert_type = navmissile;
            insert_size = navmissilesize;
        } else if ( (*blah)->isUnit() == ASTEROIDPTR ) {
            //an asteroid
            insert_type = navasteroid;
            insert_size = navasteroidsize;
        } else if ( (*blah)->isUnit() == NEBULAPTR ) {
            //a nebula
            insert_type = navnebula;
            insert_size = navnebulasize;
        } else {
            //undefined non unit
            insert_type = navambiguous;
            insert_size = navambiguoussize;
        }
        if ( system_item_scale_temp > (system_item_scale*3) )
            system_item_scale_temp = (system_item_scale*3);
        insert_size *= system_item_scale_temp;
        if ( _Universe->AccessCockpit()->GetParent()->Target() == (*blah) ) {
            //Get a color from the config
            static GFXColor col = vs_config->getColor( "nav", "targetted_unit", GFXColor(1, 0.3, 0.3, 0.8) );
            DrawTargetCorners( the_x, the_y, insert_size, col );
            }
        bool tests_in_range = 0;
        if (insert_type == navstation)
            tests_in_range = TestIfInRangeBlk( the_x, the_y, insert_size, mouse_x_current, mouse_y_current );
        else
            tests_in_range = TestIfInRangeRad( the_x, the_y, insert_size, mouse_x_current, mouse_y_current );
        Unit *myunit = (*blah);

        ++blah;
        DisplayOrientationLines( the_x, the_y, the_x_flat, the_y_flat, 1 );
        if (tests_in_range) {
            mouselist.insert( insert_type, insert_size, the_x, the_y, myunit );
        } else {
            drawlistitem( insert_type,
                          insert_size,
                          the_x,
                          the_y,
                          myunit,
                          screenoccupation,
                          false,
                          (*blah) ? true : false,
                          unselectedalpha,
                          factioncolours );
        }
    }
    //**********************************	//	done enlisting items and attributes
    //Adjust mouse list for 'n' kliks
    //**********************************
    //STANDARD	: (1 3 2) ~ [0] [2] [1]
    //VS			: (1 2 3) ~ [0] [1] [2]	<-- use this
    if (mouselist.get_n_contents() > 0) {
        //mouse is over a target when this is > 0
        if (mouse_wentdown[2] == 1)             //mouse button went down for mouse button 2(standard)
            rotations += 1;
    }
    if ( rotations >= mouselist.get_n_contents() )      //dont rotate more than there is
        rotations = 0;
    int r = 0;
    while (r < rotations) {
        //rotate whatver rotations, leaving n rotated items, tail on top
        mouselist.rotate();
        r += 1;
    }
    //**********************************
    //Draw the damn shit
    //**********************************
//mainlist.draw();	//	draw the items
//mainlist.wipe();	//	whipe the list
    //**********************************
    //Check for selection query
    //give back the selected tail IF there is one
    //IF given back, undo the selection state
    //**********************************
    if ( 1 || checkbit( buttonstates, 1 ) ) {
        //button #2 is down, wanting a (selection)
        if (mouselist.get_n_contents() > 0) {
            //mouse is over a target when this is > 0
            if (mouse_wentdown[0] == 1) {
                //mouse button went down for mouse button 1
                currentselection = mouselist.gettailunit();
                unsetbit( buttonstates, 1 );
                //JUST FOR NOW, target == current selection. later it'll be used for other shit, that will then set target.
                if ( currentselection.GetUnit() ) {
                    ( UniverseUtil::getPlayerX( UniverseUtil::getCurrentPlayer() ) )->Target( currentselection.GetUnit() );
                    ( UniverseUtil::getPlayerX( UniverseUtil::getCurrentPlayer() ) )->LockTarget( currentselection.GetUnit() );
                }
            }
        }
    }
    //**********************************

    //Clear the lists
    //**********************************
    mouselist.draw();           //draw mouse over'd items
    mouselist.wipe();           //whipe mouse over'd list
    //**********************************
}