BWAPI
Public Member Functions | Private Member Functions | Private Attributes
EnhancedUI Class Reference

#include <EnhancedUI.h>

Collaboration diagram for EnhancedUI:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void update () const
void drawBoxAtTilePositionToSize (BWAPI::TilePosition tpos, int width, int height, BWAPI::Color color)
int getMinTileSize (int pixels)
int getMaxTileSize (int pixels)
BWAPI::Position getTilePositionCenter (BWAPI::TilePosition)
void drawRegionBoundingBox (const BWTA::Region *region)
void getRegionBoundingTilePositions (const BWTA::Region *region, BWAPI::TilePosition &topLeftTP, BWAPI::TilePosition &topRightTP, BWAPI::TilePosition &bottomRightTP, BWAPI::TilePosition &bottomLeftTP)
void drawPolygonFromRegion (BWTA::Region *region, BWAPI::Color color)
void drawTilePosition (BWAPI::TilePosition tPos, BWAPI::Color color)

Private Member Functions

void drawBases () const
void drawTerrain () const

Private Attributes

vector< BWAPI::TilePosition > foundSDTPos
vector< BWAPI::TilePosition > buildSDTPos

Detailed Description

Definition at line 9 of file EnhancedUI.h.


Member Function Documentation

void EnhancedUI::drawBases ( ) const [private]

Definition at line 23 of file EnhancedUI.cpp.

References BWAPI::Broodwar.

{
        //we will iterate through all the base locations, and draw their outlines.
        for(std::set<BWTA::BaseLocation*>::const_iterator i=BWTA::getBaseLocations().begin();i!=BWTA::getBaseLocations().end();i++)
        {
                BWAPI::TilePosition p=(*i)->getTilePosition();
                Position c=(*i)->getPosition();

                //draw outline of center location
                Broodwar->drawBox(CoordinateType::Map,p.x()*32,p.y()*32,p.x()*32+4*32,p.y()*32+3*32,Colors::Blue,false);

                //draw a circle at each mineral patch
                for(std::set<BWAPI::Unit*>::const_iterator j=(*i)->getMinerals().begin();j!=(*i)->getMinerals().end();j++)
                {
                        Position q=(*j)->getPosition();
                        Broodwar->drawCircle(CoordinateType::Map,q.x(),q.y(),30,Colors::Cyan,false);
                }

                //draw the outlines of vespene geysers
                for(std::set<BWAPI::Unit*>::const_iterator j=(*i)->getGeysers().begin();j!=(*i)->getGeysers().end();j++)
                {
                        BWAPI::TilePosition q=(*j)->getTilePosition();
                        Broodwar->drawBox(CoordinateType::Map,q.x()*32,q.y()*32,q.x()*32+4*32,q.y()*32+2*32,Colors::Orange,false);
                }

                //if this is an island expansion, draw a yellow circle around the base location
                if ((*i)->isIsland())
                {
                        Broodwar->drawCircle(CoordinateType::Map,c.x(),c.y(),80,Colors::Yellow,false);
                }
        }
}
void EnhancedUI::drawBoxAtTilePositionToSize ( BWAPI::TilePosition  tpos,
int  width,
int  height,
BWAPI::Color  color 
)

Definition at line 94 of file EnhancedUI.cpp.

References BWAPI::Broodwar.

Referenced by TacticalBuildingPlacer::draw(), and EnhancedChokepoint::drawBuildableSupplyDepotForRegion().

{
        Broodwar->drawBoxMap(tpos.x() * 32, tpos.y() * 32, ((tpos.x() + width) * 32) - 1, 
                ((tpos.y() + height) * 32) - 1, color);
}

Here is the caller graph for this function:

void EnhancedUI::drawPolygonFromRegion ( BWTA::Region *  region,
BWAPI::Color  color 
)

Definition at line 83 of file EnhancedUI.cpp.

References BWAPI::Broodwar.

{
                BWTA::Polygon p = region->getPolygon();
                for (int j = 0; j < (int)p.size(); j++) {
                        Position point1=p[j];
                        Position point2=p[(j+1) % p.size()];
                        Broodwar->drawLine(CoordinateType::Map,point1.x(),point1.y(),point2.x(),point2.y(),color);
                }
}
void EnhancedUI::drawRegionBoundingBox ( const BWTA::Region *  region)

Definition at line 242 of file EnhancedUI.cpp.

References BWAPI::Broodwar.

{
        BWTA::Polygon poly;
        BWAPI::Position pLeft, pRight, pTop, pBottom;

        poly = region->getPolygon();

        pLeft = pRight = pTop = pBottom = (Position) poly[0];

        /* get bounds for BWTA region, map top left is (0,0) */
        for(int j = 1; j < (int)poly.size(); j++)
        {
                if(poly[j].x() < pLeft.x()){
                        pLeft = poly[j];
                }
                if(poly[j].x() > pRight.x()){
                        pRight = poly[j];
                }
                if(poly[j].y() < pTop.y()){
                        pTop = poly[j];
                }
                if(poly[j].y() > pBottom.y()){
                        pBottom = poly[j];
                }
        }

        Broodwar->drawBoxMap(pLeft.x(), pTop.y(), pRight.x(), pBottom.y(), Colors::Purple, false);

}
void EnhancedUI::drawTerrain ( ) const [private]

Definition at line 56 of file EnhancedUI.cpp.

References BWAPI::Broodwar.

{
        //we will iterate through all the regions and draw the polygon outline of it in green.
        for(std::set<BWTA::Region*>::const_iterator r=BWTA::getRegions().begin();r!=BWTA::getRegions().end();r++)
        {
                BWTA::Polygon p=(*r)->getPolygon();
                for(int j=0;j<(int)p.size();j++)
                {
                        Position point1=p[j];
                        Position point2=p[(j+1) % p.size()];
                        Broodwar->drawLine(CoordinateType::Map,point1.x(),point1.y(),point2.x(),point2.y(),Colors::Green);
                }
        }

        //we will visualize the chokepoints with yellow lines
        for(std::set<BWTA::Region*>::const_iterator r=BWTA::getRegions().begin();r!=BWTA::getRegions().end();r++)
        {
                for(std::set<BWTA::Chokepoint*>::const_iterator c=(*r)->getChokepoints().begin();c!=(*r)->getChokepoints().end();c++)
                {
                        Position point1=(*c)->getSides().first;
                        Position point2=(*c)->getSides().second;
                        Broodwar->drawLine(CoordinateType::Map,point1.x(),point1.y(),point2.x(),point2.y(),Colors::Yellow);
                }
        }
}
void EnhancedUI::drawTilePosition ( BWAPI::TilePosition  tPos,
BWAPI::Color  color 
)

Definition at line 17 of file EnhancedUI.cpp.

References BWAPI::Broodwar.

Referenced by EnhancedChokepoint::drawBuildableTilesForRegion(), EnhancedChokepoint::drawTilePositions(), and EnhancedSide::drawTiles().

{
        Broodwar->drawBoxMap(tPos.x() * 32, tPos.y() * 32, tPos.x() * 32 + 31, 
                tPos.y() * 32 + 31, color, false);
}

Here is the caller graph for this function:

int EnhancedUI::getMaxTileSize ( int  pixels)

Definition at line 106 of file EnhancedUI.cpp.

                                        {

        if(pixels % TILE_SIZE){
                return  pixels / TILE_SIZE + 1; 
        }
        return  pixels / TILE_SIZE;
}
int EnhancedUI::getMinTileSize ( int  pixels)

Definition at line 101 of file EnhancedUI.cpp.

                                        {

        return  pixels / TILE_SIZE;
}
void EnhancedUI::getRegionBoundingTilePositions ( const BWTA::Region *  region,
BWAPI::TilePosition &  topLeftTP,
BWAPI::TilePosition &  topRightTP,
BWAPI::TilePosition &  bottomRightTP,
BWAPI::TilePosition &  bottomLeftTP 
)

Definition at line 125 of file EnhancedUI.cpp.

{

        BWTA::Polygon poly;
        BWAPI::Position pLeft, pRight, pTop, pBottom;
        /* tile sizes */
        int tsLeft, tsTop, tsRight, tsBottom;
        poly = region->getPolygon();

        pLeft = pRight = pTop = pBottom = (Position) poly[0];

        /* get bounds for BWTA region, map top left is (0,0) */
        for(int j = 1; j < (int)poly.size(); j++)
        {
                if(poly[j].x() < pLeft.x()){
                        pLeft = poly[j];
                }
                if(poly[j].x() > pRight.x()){
                        pRight = poly[j];
                }
                if(poly[j].y() < pTop.y()){
                        pTop = poly[j];
                }
                if(poly[j].y() > pBottom.y()){
                        pBottom = poly[j];
                }
        }
        /* align to tile sizes */
        tsLeft = this->getMaxTileSize(pLeft.x());
        tsTop = this->getMaxTileSize(pTop.y());

        tsRight = this->getMinTileSize(pRight.x());
        tsBottom = this->getMinTileSize(pBottom.y());

        /* set tile positions */
        topLeftTP.x() = tsLeft;
        topLeftTP.y() = tsTop;

        topRightTP.x() = tsRight;
        topRightTP.y() = tsTop;

        bottomRightTP.x() = tsRight;
        bottomRightTP.y() = tsBottom;

        bottomLeftTP.x() = tsLeft;
        bottomLeftTP.y() = tsBottom;

}
BWAPI::Position EnhancedUI::getTilePositionCenter ( BWAPI::TilePosition  tPos)

Definition at line 114 of file EnhancedUI.cpp.

Referenced by EnhancedChokepoint::radialSweepSearch().

{
        BWAPI::Position pos;

        pos.x() = tPos.x() * 32 + 15;
        pos.y() = tPos.y() * 32 + 15;

        return pos;
}

Here is the caller graph for this function:

void EnhancedUI::update ( ) const

Definition at line 10 of file EnhancedUI.cpp.

{
        drawTerrain();
        drawBases();
        //  drawProgress();
}

Member Data Documentation

vector<BWAPI::TilePosition> EnhancedUI::buildSDTPos [private]

Definition at line 46 of file EnhancedUI.h.

vector<BWAPI::TilePosition> EnhancedUI::foundSDTPos [private]

Definition at line 45 of file EnhancedUI.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines