コード例 #1
0
ファイル: multilimit.cpp プロジェクト: muggenhor/warzone2100
static void displayStructureBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
{
	int x = xOffset + psWidget->x();
	int y = yOffset + psWidget->y();
	int w = psWidget->width();
	int h = psWidget->height();
	STRUCTURE_STATS	*stat = asStructureStats + psWidget->UserData;
	Position position;
	Vector3i rotation;
	char str[20];

	UDWORD scale,Radius;

	drawBlueBox(x,y,w,h);

	// draw image
	pie_SetGeometricOffset(x + 35, y + psWidget->height()/2 + 9);
	rotation.x = -15;
	rotation.y = ((realTime/45)%360) ; //45
	rotation.z = 0;
	position.x = 0;
	position.y = 0;
	position.z = BUTTON_DEPTH*2;//getStructureStatSize(stat)  * 38 * OBJECT_RADIUS;

	Radius = getStructureStatSizeMax(stat);
	if(Radius <= 128) {
		scale = SMALL_STRUCT_SCALE;
	} else if(Radius <= 256) {
		scale = MED_STRUCT_SCALE;
	} else {
		scale = LARGE_STRUCT_SCALE;
	}

	pie_SetDepthBufferStatus(DEPTH_CMP_LEQ_WRT_ON);
	displayStructureStatButton(stat, &rotation, &position, true, scale);
	pie_SetDepthBufferStatus(DEPTH_CMP_ALWAYS_WRT_ON);

	// draw name
	iV_SetFont(font_regular);											// font
	iV_SetTextColour(WZCOL_TEXT_BRIGHT);
	iV_DrawText(_(getName(stat->pName)), x + 80, y + psWidget->height()/2 + 3);

	// draw limit
	ssprintf(str, "%d", ((W_SLIDER *)widgGetFromID(psWScreen, psWidget->id + 1))->pos);
	iV_DrawText(str, x + 270, y + psWidget->height()/2 + 3);

	return;
}
コード例 #2
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();
}