Jump to content
XCOMUFO & Xenocide

Facility Construction Time


amessier

Recommended Posts

I have been working on displaying facility construction time aka days left until built.

 

I have the functions working for 1 square and im wondering what is the best way to approach multiple squares is .

 

void BaseviewRenderer::displayDaysRemainingforConstruction(bool windowStatus)

{

bool freeFacilitySquare;

Core::Player* player = Core::Player::getInstancePtr();

Core::HumanBase::SharedPtr base=getCurrentBase();

Core::HumanFacility::SharedPtr pickedFacility;

 

// Get number of facilites and loop that many times (Special case for landing docks due to there size 2x2)

freeFacilitySquare=base->isPlaceFree(0,5);

if(!freeFacilitySquare)

{

pickedFacility = base->getFacility(0,5);

CEGUI::WindowManager::getSingleton().getWindow("Baseview/FacilityDisplayWindow0x5")->setProperty("Text",pickedFacility->getDaysToComplete());

}

else

{

CEGUI::WindowManager::getSingleton().getWindow("Baseview/FacilityDisplayWindow0x5")->setProperty("Text","");

}

}

 

 

 

 

I really dont want to repeat this

"freeFacilitySquare=base->isPlaceFree(0,5);

if(!freeFacilitySquare)

{

pickedFacility = base->getFacility(0,5);

CEGUI::WindowManager::getSingleton().getWindow("Baseview/FacilityDisplayWindow0x5")->setProperty("Text",pickedFacility->getDaysToComplete());

}

else

{

CEGUI::WindowManager::getSingleton().getWindow("Baseview/FacilityDisplayWindow0x5")->setProperty("Text","");

}

}"

for every single square on the grid... I know if this was IBM REXX i could have variables in my getWindow() Baseview/FacilityDisplayWindowAxB declare A and B .

 

However in C++ to the best of my knowledge you are not able to use variables in this situation. :(

Edited by amessier
Link to comment
Share on other sites

You mean you want to generate strings like that:

"Baseview/FacilityDisplayWindow0x0"

"Baseview/FacilityDisplayWindow0x1"

...

"Baseview/FacilityDisplayWindow5x5"

...

 

Try

String windowName = boost::str( boost::format("Baseview/FacilityDisplayWindow%1%x%2%") % a % b);

(I'm not sure about syntaxis here, in worst case you probably can use sprintf :))

 

And then use windowName instead. (Put everything in a function or something)

 

BTW, why do you iterate through squares, and not through facilities themselves?

Edited by UnFleshed One
Link to comment
Share on other sites

Thats exactlly what I wanted to know.. So boost supports it...

 

Umm good point with the iterating thru facilities and not squares....

 

Thx!!!

 

 

 

You mean you want to generate strings like that:

"Baseview/FacilityDisplayWindow0x0"

"Baseview/FacilityDisplayWindow0x1"

...

"Baseview/FacilityDisplayWindow5x5"

...

 

Try

String windowName = boost::str( boost::format("Baseview/FacilityDisplayWindow%1%x%2%") % a % b);

(I'm not sure about syntaxis here, in worst case you probably can use sprintf :))

 

And then use windowName instead. (Put everything in a function or something)

 

BTW, why do you iterate through squares, and not through facilities themselves?

Edited by amessier
Link to comment
Share on other sites

×
×
  • Create New...