示例#1
0
Vector2i getStatsSize(BASE_STATS const *pType, uint16_t direction)
{
	if (StatIsStructure(pType))
	{
		return static_cast<STRUCTURE_STATS const *>(pType)->size(direction);
	}
	else if (StatIsFeature(pType))
	{
		return static_cast<FEATURE_STATS const *>(pType)->size();
	}
	return Vector2i(1, 1);
}
示例#2
0
StructureBounds getStructureBounds(BASE_STATS const *stats, Vector2i pos, uint16_t direction)
{
	if (StatIsStructure(stats))
	{
		return getStructureBounds(static_cast<STRUCTURE_STATS const *>(stats), pos, direction);
	}
	else if (StatIsFeature(stats))
	{
		return getStructureBounds(static_cast<FEATURE_STATS const *>(stats), pos);
	}

	return StructureBounds(map_coord(pos), Vector2i(1, 1));  // Default to a 1×1 tile.
}
示例#3
0
/* renders the Research IMDs into the surface - used by message display in
Intelligence Map */
void renderResearchToBuffer(RESEARCH *psResearch, UDWORD OriginX, UDWORD OriginY)
{
    UDWORD   angle = 0;

    BASE_STATS      *psResGraphic;
    UDWORD          compID, IMDType;
    Vector3i Rotation,Position;
    UDWORD          basePlateSize, Radius;
    SDWORD          scale = 0;

    // Set identity (present) context
    pie_MatBegin();

    pie_SetGeometricOffset(OriginX+10, OriginY+10);

    // Pitch down a bit
    //pie_MatRotX(-65536/12);

    // Rotate round
    // full rotation once every 2 seconds..
    angle = (realTime % ROTATE_TIME) * 360 / ROTATE_TIME;

    Position.x = 0;
    Position.y = 0;
    Position.z = BUTTON_DEPTH;

    // Rotate round
    Rotation.x = -30;
    Rotation.y = angle;
    Rotation.z = 0;

    //draw the IMD for the research
    if (psResearch->psStat)
    {
        //we have a Stat associated with this research topic
        if  (StatIsStructure(psResearch->psStat))
        {
            //this defines how the button is drawn
            IMDType = IMDTYPE_STRUCTURESTAT;
            psResGraphic = psResearch->psStat;
            //set up the scale
            basePlateSize= getStructureStatSizeMax((STRUCTURE_STATS*)psResearch->psStat);
            if(basePlateSize == 1)
            {
                scale = RESEARCH_COMPONENT_SCALE / 2;
                /*HACK HACK HACK!
                if its a 'tall thin (ie tower)' structure stat with something on
                the top - offset the position to show the object on top*/
                if (((STRUCTURE_STATS*)psResearch->psStat)->pIMD[0]->nconnectors &&
                        getStructureStatHeight((STRUCTURE_STATS*)psResearch->psStat) > TOWER_HEIGHT)
                {
                    Position.y -= 30;
                }
            }
            else if(basePlateSize == 2)
            {
                scale = RESEARCH_COMPONENT_SCALE / 4;
            }
            else
            {
                scale = RESEARCH_COMPONENT_SCALE / 5;
            }
        }
        else
        {
            compID = StatIsComponent(psResearch->psStat);
            if (compID != COMP_UNKNOWN)
            {
                //this defines how the button is drawn
                IMDType = IMDTYPE_COMPONENT;
                psResGraphic = psResearch->psStat;
                // NOTE: Another kludge to deal with the superTransport to make it "fit" the display.
                // Using pName, should be safe to compare, pName doesn't get translated.
                if (!strcmp("SuperTransport", psResearch->pName))
                {
                    scale = RESEARCH_COMPONENT_SCALE / 3;
                }
                else
                {
                    scale = RESEARCH_COMPONENT_SCALE;
                }
            }
            else
            {
                ASSERT( false, "intDisplayMessageButton: invalid stat" );
                IMDType = IMDTYPE_RESEARCH;
                psResGraphic = (BASE_STATS *)psResearch;
            }
        }
    }
    else
    {
        //no Stat for this research topic so use the research topic to define what is drawn
        psResGraphic = (BASE_STATS *)psResearch;
        IMDType = IMDTYPE_RESEARCH;
    }

    //scale the research according to size of IMD
    if (IMDType == IMDTYPE_RESEARCH)
    {
        Radius = getResearchRadius((BASE_STATS*)psResGraphic);
        if(Radius <= 100)
        {
            scale = RESEARCH_COMPONENT_SCALE / 2;
        }
        else if(Radius <= 128)
        {
            scale = RESEARCH_COMPONENT_SCALE / 3;
        }
        else if(Radius <= 256)
        {
            scale = RESEARCH_COMPONENT_SCALE / 4;
        }
        else
        {
            scale = RESEARCH_COMPONENT_SCALE / 5;
        }
    }

    /* display the IMDs */
    if(IMDType == IMDTYPE_COMPONENT)
    {
        displayComponentButton(psResGraphic, &Rotation, &Position, true, scale);
    }
    else if(IMDType == IMDTYPE_RESEARCH)
    {
        displayResearchButton(psResGraphic, &Rotation, &Position, true, scale);
    }
    else if(IMDType == IMDTYPE_STRUCTURESTAT)
    {
        displayStructureStatButton((STRUCTURE_STATS *)psResGraphic, &Rotation, &Position, true, scale);
    }
    else
    {
        ASSERT( false, "Unknown PIEType" );
    }

    // close matrix context
    pie_MatEnd();
}
示例#4
0
/*Displays the buttons used on the intelligence map */
void intDisplayMessageButton(WIDGET *psWidget, UDWORD xOffset,
							  UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
{
	W_CLICKFORM		*psButton = (W_CLICKFORM*)psWidget;
	RENDERED_BUTTON *psBuffer = (RENDERED_BUTTON*)psButton->pUserData;
	MESSAGE			*psMsg;
	BOOL			Hilight = false;
	UDWORD			Down = 0, IMDType = 0, compID;
	SDWORD			image = -1;
	RESEARCH		*pResearch = NULL;
    BASE_STATS      *psResGraphic = NULL;
	BOOL MovieButton = false;

	OpenButtonRender((UWORD)(xOffset+psButton->x), (UWORD)(yOffset+psButton->y),
		psButton->width, psButton->height);

	Down = psButton->state & (WBUTS_DOWN | WBUTS_CLICKLOCK);
	Hilight = psButton->state & WBUTS_HILITE;

	// Get the object associated with this widget.
	psMsg = (MESSAGE *)psBuffer->Data;
	ASSERT_OR_RETURN( , psMsg != NULL, "psBuffer->Data empty. Why?" );
	//shouldn't have any proximity messages here...
	if (psMsg->type == MSG_PROXIMITY)
	{
		return;
	}
	//set the graphic for the button
	switch (psMsg->type)
	{
	case MSG_RESEARCH:
		pResearch = getResearchForMsg((VIEWDATA *)psMsg->pViewData);
		//IMDType = IMDTYPE_RESEARCH;
        	//set the IMDType depending on what stat is associated with the research
		if (pResearch && pResearch->psStat)
        	{
			//we have a Stat associated with this research topic
			if  (StatIsStructure(pResearch->psStat))
			{
				//this defines how the button is drawn
				IMDType = IMDTYPE_STRUCTURESTAT;
				psResGraphic = pResearch->psStat;
			}
			else
			{
				compID = StatIsComponent(pResearch->psStat);
				if (compID != COMP_UNKNOWN)
				{
					//this defines how the button is drawn
					IMDType = IMDTYPE_COMPONENT;
					psResGraphic = pResearch->psStat;
				}
				else
				{
					ASSERT( false, "intDisplayMessageButton: invalid stat" );
					IMDType = IMDTYPE_RESEARCH;
					psResGraphic = (BASE_STATS *)pResearch;
				}
			}
		}
		else
		{
			//no Stat for this research topic so use the research topic to define what is drawn
			psResGraphic = (BASE_STATS *)pResearch;
			IMDType = IMDTYPE_RESEARCH;
		}
		break;
	case MSG_CAMPAIGN:
		image = IMAGE_INTEL_CAMPAIGN;
		MovieButton = true;
		break;
	case MSG_MISSION:
		image = IMAGE_INTEL_MISSION;
		MovieButton = true;
		break;
	default:
		debug( LOG_ERROR, "Unknown message type: %i", psMsg->type );
		return;
	}

	//if research message
	if (pResearch)
	{
		if (pResearch->iconID != NO_RESEARCH_ICON)
		{
			image = pResearch->iconID;
		}

		//do we have the same icon for the top right hand corner?
		if (image > 0)
		{
			RenderToButton(IntImages, (UWORD)image, psResGraphic, selectedPlayer, psBuffer,Down, IMDType, TOPBUTTON);
		}
		else
		{
			RenderToButton(NULL,0,pResearch,selectedPlayer,psBuffer,Down,IMDType,TOPBUTTON); //ajl, changed from 0 to selectedPlayer
		}
	}
	else
	//draw buttons for mission and general messages
	{
		if (image > 0)
		{

			if(MovieButton) {
				// draw the button with the relevant image, don't add Down to the image ID if it's
				// a movie button.
				RenderImageToButton(IntImages,(UWORD)(image),psBuffer,Down,TOPBUTTON);
			} else {
				//draw the button with the relevant image
				RenderImageToButton(IntImages,(UWORD)(image+Down),psBuffer,Down,TOPBUTTON);
			}

		}
	}

	CloseButtonRender();

	if (Hilight)
	{

		iV_DrawImage(IntImages,IMAGE_BUT_HILITE,xOffset+psButton->x,
			yOffset+psButton->y);
	}
}