Пример #1
0
// doDraw
//---------------------------------------------------------------------------
void SoundView::doDraw(Surface &viewArea, Surface &clientArea)
{
    MenuTemplateView::doDraw(viewArea, clientArea);

    char strBuf[256];
    
    const int arrowButtonWidth = 16;
    
    iRect visualMeter;
    int   x               = optionsMeterStartX + arrowButtonWidth;
    int   y               = bodyTextRect.min.y + 15;
    int   yOffset         = 15;
    
    Surface tempSurface(optionsMeterWidth, 14, 1);
    
    // Sound Volume
    y += yOffset;
    tempSurface.fill(meterColor);
    tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);
    sprintf(strBuf, "%d %%", getSoundVolume());
    tempSurface.bltStringCenter(strBuf, meterTextColor);
    tempSurface.blt(clientArea, x, y);

    // Music Volume
    y += yOffset*3;
    tempSurface.fill(meterColor);
    tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);
    sprintf(strBuf, "%d %%", getMusicVolume());
    tempSurface.bltStringCenter(strBuf, meterTextColor);
    tempSurface.blt(clientArea, x, y);

    //clientArea.bltStringCenter("Not available for preview", Color::white);

} // end SoundView::doDraw
// doDraw
//---------------------------------------------------------------------------
void OptionsTemplateView::doDraw(Surface &viewArea, Surface &clientArea)
{
    checkBoxFullscreen->setState(GameConfig::video_fullscreen);
    checkBoxBlendSmoke->setState(GameConfig::video_blendsmoke);
    checkBoxDrawAllShadows->setState(GameConfig::video_shadows);

    MenuTemplateView::doDraw(viewArea, clientArea);

    Surface tempSurface(optionsMeterWidth, 14, 1);

    // Scroll Rate
    tempSurface.fill(meterColor);
    tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);

    char strBuf[256];
    const int arrowButtonWidth = 16;
    int   x               = bodyTextRect.min.x + optionsMeterStartX + arrowButtonWidth;
    int   y               = bodyTextRect.min.y ;
    int yOffset          =  17;

    y += yOffset*7;

    sprintf(strBuf, "%d %%", int((float(getScrollRate()) / 
                    float(gameconfig->scrollrate.getMax())) * 100.0f));
    tempSurface.bltStringCenter(strBuf, meterTextColor);
    tempSurface.blt(clientArea, x, y);
    y += yOffset*2;
    
    // Sound Volume
    y += yOffset*3;
    tempSurface.fill(meterColor);
    tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);
    sprintf(strBuf, "%d %%", getSoundVolume());
    tempSurface.bltStringCenter(strBuf, meterTextColor);
    tempSurface.blt(clientArea, x, y);

    // Music Volume
    y += yOffset*3;
    tempSurface.fill(meterColor);
    tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);
    sprintf(strBuf, "%d %%", getMusicVolume());
    tempSurface.bltStringCenter(strBuf, meterTextColor);
    tempSurface.blt(clientArea, x, y);
} // end VisualsView::doDraw
// doDraw
//---------------------------------------------------------------------------
void InterfaceView::doDraw(Surface &viewArea, Surface &clientArea)
{
    MenuTemplateView::doDraw(viewArea, clientArea);

    char strBuf[256];

    const int arrowButtonWidth = 16;
    int   x               = optionsMeterStartX + arrowButtonWidth;
    int   y               = bodyTextRect.min.y + 15;

    Surface tempSurface(optionsMeterWidth, 14, optionsMeterWidth, 1);

    // Scroll Rate
    tempSurface.fill(meterColor);
    tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);
    sprintf(strBuf, "%d %%", int((float(getScrollRate()) / 
                    float(gameconfig->scrollrate.getMax())) * 100.0f));
    tempSurface.bltStringCenter(strBuf, meterTextColor);
    tempSurface.blt(clientArea, x, y);
} // end InterfaceView::doDraw
// createUnitBodyGreenChunks
//---------------------------------------------------------------------------
void ChunkTrajectoryParticle2D::createUnitBodyGreenChunks()
{

    // Blt the green titan body onto a surface to pull colors from.
    Surface tempUnitBodyGray;
    tempUnitBodyGray.create(gAbramsBody.getPixX(), gAbramsBody.getPixY(), gAbramsBody.getPixX(), 1);
    tempUnitBodyGray.fill(0);
    gAbramsBody.blt(tempUnitBodyGray, 0, 0);

    // Build a table of the green unit colors.
    Surface tempSurface(2, 2, 2, 64);

    int x = 0;
    int y = 0;

    for (int i = 0; i < tempSurface.getFrameCount(); i++) {
        tempSurface.setFrame(i);

        while (tempUnitBodyGray.getPixel(x, y) == 0) {
            x++;

            if (x > tempUnitBodyGray.getPixX() - 1) {
                x = 0;
                y++;
            } else if (y > tempUnitBodyGray.getPixY() - 1) {
                assert(false);
            }
        }

        tempSurface.fill(tempUnitBodyGray.getPixel(x, y));
    }

    PackedSurface tempPackedSurface;
    tempPackedSurface.pack(tempSurface);

    char chunkPathPAK[] = "pics/particles/chunks/pak/";
    char strBuf[256];
    sprintf(strBuf, "%sgreenUnitChunks.pak", chunkPathPAK);
    tempPackedSurface.save(strBuf);

} // end ChunkTrajectoryParticle2D::createUnitBodyGreenChunks
Пример #5
0
// drawMeterInfo
//---------------------------------------------------------------------------
void HostOptionsView::drawMeterInfo(Surface &dest, const iXY &pos)
{
    char strBuf[256];

    const int arrowButtonWidth = 16;
    const int yOffset          = 15;

    int x = pos.x + 270 + arrowButtonWidth;
    int y = pos.y;

    Surface tempSurface(meterWidth, 14, 1);
    tempSurface.fill(meterColor);

    // Game Max Player Count
    tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);
    sprintf(strBuf, "%d", getCurMaxPlayersCount());
    tempSurface.bltStringCenter(strBuf, meterTextColor);
    tempSurface.blt(dest, x, y);

    // Game Max Unit Count
    y += yOffset;
    tempSurface.fill(meterColor);
    tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);
    sprintf(strBuf, "%d - %d max per player", getCurMaxUnitCount(), getCurMaxUnitCount() / getCurMaxPlayersCount());
    tempSurface.bltStringCenter(strBuf, meterTextColor);
    tempSurface.blt(dest, x, y);
    /*
    	// Respawn Unit Count
    	y += yOffset;
    	tempSurface.fill(meterColor);
    	tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);
    	sprintf(strBuf, "%d", getRespawnUnitCount());
    	tempSurface.bltStringCenter(strBuf, meterTextColor);
    	tempSurface.blt(dest, x, y);
    */
    // Allow Allies
    //y += yOffset;
    //tempSurface.fill(meterColor);
    //tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);
    //sprintf(strBuf, "%s", getAllowAllies());
    //tempSurface.bltStringCenter(strBuf, meterTextColor);
    //tempSurface.blt(dest, x, y);
    //
    //// Spawn Placement
    //y += yOffset;
    //tempSurface.fill(meterColor);
    //tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);
    //sprintf(strBuf, "%s", getSpawnPlacement());
    //tempSurface.bltStringCenter(strBuf, meterTextColor);
    //tempSurface.blt(dest, x, y);

    // Objective Capture Percent
    y += yOffset;
    tempSurface.fill(meterColor);
    tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);
    if (MapSelectionView::curMap >= 0 && MapSelectionView::mapList.size() > 0) {
        int objectiveCount =
            MapSelectionView::mapList[MapSelectionView::curMap]->objectiveCount;
        sprintf(strBuf, "%d%% - %d of %d", getObjectiveCapturePercent(),
                int(float(objectiveCount) * (float(getObjectiveCapturePercent()
                            ) / 100.0f) + 0.999), objectiveCount);
    } else {
        sprintf(strBuf, "Map Data Needed");
    }
    tempSurface.bltStringCenter(strBuf, meterTextColor);
    tempSurface.blt(dest, x, y);

    y += yOffset;
    tempSurface.fill(meterColor);
    tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);
    sprintf(strBuf, "%d:%d", getTimeLimitHours(), getTimeLimitMinutes() );
    tempSurface.bltStringCenter(strBuf, meterTextColor);
    tempSurface.blt(dest, x, y);

    y += yOffset;
    tempSurface.fill(meterColor);
    tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);
    sprintf(strBuf, "%d Frags", getFragLimit() );
    tempSurface.bltStringCenter(strBuf, meterTextColor);
    tempSurface.blt(dest, x, y);


    /*
    	// Fog of War
    	y += yOffset;
    	tempSurface.fill(meterColor);
    	tempSurface.drawButtonBorder(meterTopLeftBorderColor, meterBottomRightBorderColor);
    	sprintf(strBuf, "%s", getAllowFogOfWar());
    	tempSurface.bltStringCenter(strBuf, meterTextColor);
    	tempSurface.blt(dest, x, y);
    */

} // end HostOptionsView::drawMeterInfo
// drawHostList
//---------------------------------------------------------------------------
void GetSessionHostView::drawHostList(const Surface &dest)
{
	char host_info_str[256];
	int curIndex = 0;
	int color;

	Surface tempSurface( getClientRect().getSizeX() - 2, (TEXT_GAP_SPACE + CHAR_YPIX), getClientRect().getSizeX() - 2, 1 );

    tempSurface.fill(Color::darkGreen);
	sprintf( host_info_str, "%-24s %-24s %-12s %10s", "Host",
                                                      "Map",
                                                      "Game Type",
                                                      "Players"   );
	
    tempSurface.bltString( 4, 1, host_info_str, Color::white );
	tempSurface.blt(dest, 0, 1 );
    
    curIndex++;

	for (int i = 0; i < hosts.getCount(); i++)
	{
		sprintf( host_info_str, "%-24s %-24s %-15s %4d/%-4d", hosts[i].name,
                                                              hosts[i].map,
                                                              hosts[i].game_type,
                                                              hosts[i].current_players,
                                                              hosts[i].max_players  );
                                               
        
        color = Color::white;

		if (i == highlightedItem)
		{
			color = Color::red;
		}
		else if (i == selectedItem)
		{
			color = Color::green;
		}

		dest.bltString(4, 6 + curIndex * (TEXT_GAP_SPACE + CHAR_YPIX), host_info_str, color);

		curIndex++;
	}
	//for (int i = topViewableItem; i < topViewableItem + maxViewableItems; i++)

/*	
	int i;

	int shit = 0;
	int color;
	for (i = scrollBar.getValue(); i < scrollBar.getValue() + viewableItemCount; i++)
	{
		iXY offset;
		offset.x = 2;
		offset.y = 2 + shit * (CHAR_YPIX + ITEM_GAP_SPACE);
		
		// Get a color for the item.
		if (i == selectedItem)
		{
			color = Color::green;
		} else
		if (i == highlightedItem)
		{
			color = Color::red;
		} else
		{
			color = Color::white;
		}
		
		// Display the name of this shape.
		dest.bltString(offset.x, offset.y, hosts[i].getName(), color);

		shit++;
	}
*/
} // end GetSessionHostView::drawHostList