Question on working with Check Boxes in the GUI

Kailric

Jack of All Trades
Joined
Mar 25, 2008
Messages
3,100
Location
Marooned, Y'isrumgone
I am working on a Mod for Colonization and having trouble figureing out Check Boxes. I added an extra check box to the Import/Export pop up from 2 to 3 using :

Code:
gDLL->getInterfaceIFace()->popupStartHLayout(pPopup, 0);
gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, L"", kYield.getButton(), -1, WIDGET_HELP_YIELD, iYield);
gDLL->getInterfaceIFace()->[COLOR="Red"]popupCreateCheckBoxes[/COLOR](pPopup, [COLOR="Red"]3[/COLOR], iYield, WIDGET_GENERAL, POPUP_LAYOUT_TOP);
gDLL->getInterfaceIFace()->popupSetCheckBoxText(pPopup, 0, gDLL->getText("TXT_KEY_POPUP_IMPORT"), iYield);
gDLL->getInterfaceIFace()->popupSetCheckBoxState(pPopup, 0, pCity->isImport(eYield), iYield);
gDLL->getInterfaceIFace()->popupSetCheckBoxText(pPopup, 1, gDLL->getText("TXT_KEY_POPUP_EXPORT"), iYield);
gDLL->getInterfaceIFace()->popupSetCheckBoxState(pPopup, 1, pCity->isExport(eYield), iYield);
gDLL->getInterfaceIFace()->popupSetCheckBoxText(pPopup, 2, gDLL->getText(szText), iYield);
gDLL->getInterfaceIFace()->popupSetCheckBoxState(pPopup, 2, pCity->isMarket(eYield), iYield);


Then I try to retrieve the input in the code:
Code:
bool bImport = (pPopupReturn->getCheckboxBitfield(iYield) & 0x01);
if (bImport != pCity->isImport(eYield))
{
gDLL->sendDoTask(info.getData1(), TASK_YIELD_IMPORT, iYield, bImport, false, false, false, false);
}
bool bExport = (pPopupReturn->getCheckboxBitfield(iYield) & 0x02);
if (bExport != pCity->isExport(eYield))
{
gDLL->sendDoTask(info.getData1(), TASK_YIELD_EXPORT, iYield, bExport, false, false, false, false);
}
bool bMarket = (pPopupReturn->getCheckboxBitfield(iYield) & [COLOR="Red"]0x03[/COLOR]);

But "0x03" never returns the proper varable. It returns true if either 0x01 or 0x02 is true and false if they are both false. I don't understand iterators much so can someone help me out?
 
"0x03" is a hex constant equivalent to the binary value 11. Do you understand binary? The behavior you describe is exactly right. What you want is 0x04, not 0x03. If you had four, the fourth one would be 0x08, then 0x10, etc.
 
Back
Top Bottom