void PositionTownMineInfoBox( void ) { // position town mine info box SGPRect pDimensions; SGPPoint pPosition; INT16 sX =0, sY = 0; INT16 sNewMargin = 0; // position the box based on x and y of the selected sector GetScreenXYFromMapXY( bCurrentTownMineSectorX, bCurrentTownMineSectorY, &sX, &sY); // set box position pPosition.iX = sX; pPosition.iY = sY; // set new position SetBoxPosition( ghTownMineBox, pPosition ); // get box size GetBoxSize( ghTownMineBox, &pDimensions ); // get position GetBoxPosition( ghTownMineBox, &pPosition); if( pDimensions.iRight < ( sTotalButtonWidth + 30 ) ) { SpecifyBoxMinWidth( ghTownMineBox, ( sTotalButtonWidth + 30 ) ); pDimensions.iRight = sTotalButtonWidth + 30; } // now position box - the x axis if( pPosition.iX < MapScreenRect.iLeft ) { pPosition.iX = MapScreenRect.iLeft + 5; } if( pPosition.iX + pDimensions.iRight > MapScreenRect.iRight ) { pPosition.iX = MapScreenRect.iRight - pDimensions.iRight - 5; } // position - the y axis if( pPosition.iY < MapScreenRect.iTop ) { pPosition.iY = MapScreenRect.iTop + 5; } if( pPosition.iY + pDimensions.iBottom > MapScreenRect.iBottom ) { pPosition.iY = MapScreenRect.iBottom - pDimensions.iBottom - 8; } // reset position SetBoxPosition( ghTownMineBox, pPosition ); return; }
void CheckBoxObject::SaveToXml(TiXmlElement * elem) { TiXmlElement * str = new TiXmlElement( "String" ); elem->LinkEndChild( str ); str->SetAttribute("value", GetString().c_str()); TiXmlElement * checked = new TiXmlElement( "Checked" ); elem->LinkEndChild( checked ); checked->SetAttribute("value", static_cast<bool>(IsChecked())); TiXmlElement * font = new TiXmlElement( "Font" ); elem->LinkEndChild( font ); font->SetAttribute("value", GetFont().c_str()); TiXmlElement * characterSize = new TiXmlElement( "CharacterSize" ); elem->LinkEndChild( characterSize ); characterSize->SetAttribute("value", GetCharacterSize()); TiXmlElement * backgroundColorElem = new TiXmlElement( "BackgroundColorScheme" ); elem->LinkEndChild( backgroundColorElem ); backgroundColor->SaveToXml(backgroundColorElem); TiXmlElement * borderColorElem = new TiXmlElement( "BorderColorScheme" ); elem->LinkEndChild( borderColorElem ); borderColor->SaveToXml(borderColorElem); TiXmlElement * textColorElem = new TiXmlElement( "TextColorScheme" ); elem->LinkEndChild( textColorElem ); textColor->SaveToXml(textColorElem); TiXmlElement * checkColorElem = new TiXmlElement( "CheckColorScheme" ); elem->LinkEndChild( checkColorElem ); checkColor->SaveToXml(checkColorElem); TiXmlElement * borderWidthElem = new TiXmlElement( "BorderWidth" ); elem->LinkEndChild( borderWidthElem ); borderWidthElem->SetAttribute("value", GetBorderWidth()); TiXmlElement * paddingElem = new TiXmlElement( "Padding" ); elem->LinkEndChild( paddingElem ); paddingElem->SetAttribute("value", GetPadding()); TiXmlElement * boxSizeElem = new TiXmlElement( "BoxSize" ); elem->LinkEndChild( boxSizeElem ); boxSizeElem->SetAttribute("value", GetBoxSize()); TiXmlElement * checkSignSizeElem = new TiXmlElement( "CheckSignSize" ); elem->LinkEndChild( checkSignSizeElem ); checkSignSizeElem->SetAttribute("value", GetCheckSignSize()); }
void CheckBoxObject::UpdateProperties() { //Update BackgroundColor sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId(), "BackgroundColor", backgroundColor->unfocusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":PRELIGHT", "BackgroundColor", backgroundColor->hoveredColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":ACTIVE", "BackgroundColor", backgroundColor->focusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":INSENSITIVE", "BackgroundColor", backgroundColor->disabledColor ); //Update BorderColor sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId(), "BorderColor", borderColor->unfocusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":PRELIGHT", "BorderColor", borderColor->hoveredColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":ACTIVE", "BorderColor", borderColor->focusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":INSENSITIVE", "BorderColor", borderColor->disabledColor ); //Update TextColor sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + "", "Color", textColor->unfocusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":PRELIGHT", "Color", textColor->hoveredColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":ACTIVE", "Color", textColor->focusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":INSENSITIVE", "Color", textColor->disabledColor ); //Update CheckColor sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + "", "CheckColor", checkColor->unfocusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":PRELIGHT", "CheckColor", checkColor->hoveredColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":ACTIVE", "CheckColor", checkColor->focusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":INSENSITIVE", "CheckColor", checkColor->disabledColor ); //Update font size sfg::Context::Get().GetEngine().SetProperty<unsigned int>("CheckButton#" + obj->GetId() + "", "FontSize", GetCharacterSize()); sfg::Context::Get().GetEngine().SetProperty<std::string>("CheckButton#" + obj->GetId(), "FontName", std::string("gdres:") + GetFont()); //Update border width and padding sfg::Context::Get().GetEngine().SetProperty<float>("CheckButton#" + obj->GetId(), "BorderWidth", static_cast<float>(GetBorderWidth())); sfg::Context::Get().GetEngine().SetProperty<float>("CheckButton#" + obj->GetId(), "Padding", static_cast<float>(GetPadding())); sfg::Context::Get().GetEngine().SetProperty<float>("CheckButton#" + obj->GetId(), "BoxSize", static_cast<float>(GetBoxSize())); sfg::Context::Get().GetEngine().SetProperty<float>("CheckButton#" + obj->GetId(), "CheckSize", static_cast<float>(GetCheckSignSize())); }
void AddInventoryButtonForMapPopUpBox( void ) { INT16 sX, sY; SGPRect pDimensions; SGPPoint pPosition; VOBJECT_DESC VObjectDesc; UINT32 uiObject; ETRLEObject *pTrav; INT16 sWidthA = 0, sWidthB = 0, sTotalBoxWidth = 0; HVOBJECT hHandle; // load the button VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE; FilenameForBPP("INTERFACE\\mapinvbtns.sti", VObjectDesc.ImageFile); AddVideoObject( &VObjectDesc, &uiObject ); // Calculate smily face positions... GetVideoObject( &hHandle, uiObject ); pTrav = &(hHandle->pETRLEObject[ 0 ] ); sWidthA = pTrav->usWidth; pTrav = &(hHandle->pETRLEObject[ 1 ] ); sWidthB = pTrav->usWidth; sTotalBoxWidth = sTotalButtonWidth; GetBoxSize( ghTownMineBox , &pDimensions ); GetBoxPosition( ghTownMineBox, &pPosition ); sX = pPosition.iX + ( pDimensions.iRight - sTotalBoxWidth ) / 3; sY = pPosition.iY + pDimensions.iBottom - ( ( BOX_BUTTON_HEIGHT + 5 ) ); guiMapButtonInventoryImage[0] = LoadButtonImage( "INTERFACE\\mapinvbtns.sti" ,-1,0,-1,2,-1 ); guiMapButtonInventory[0] = CreateIconAndTextButton( guiMapButtonInventoryImage[0], pMapPopUpInventoryText[ 0 ], BLOCKFONT2, FONT_WHITE, FONT_BLACK, FONT_WHITE, FONT_BLACK, TEXT_CJUSTIFIED, (INT16)(sX ), (INT16)( sY ), BUTTON_TOGGLE , MSYS_PRIORITY_HIGHEST - 1, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)MapTownMineInventoryButtonCallBack ); sX = sX + sWidthA + ( pDimensions.iRight - sTotalBoxWidth ) / 3; sY = pPosition.iY + pDimensions.iBottom - ( ( BOX_BUTTON_HEIGHT + 5) ); guiMapButtonInventoryImage[1] = LoadButtonImage( "INTERFACE\\mapinvbtns.sti" ,-1,1,-1,3,-1 ); guiMapButtonInventory[1] = CreateIconAndTextButton( guiMapButtonInventoryImage[1], pMapPopUpInventoryText[ 1 ], BLOCKFONT2, FONT_WHITE, FONT_BLACK, FONT_WHITE, FONT_BLACK, TEXT_CJUSTIFIED, (INT16)(sX ), (INT16)( sY ), BUTTON_TOGGLE , MSYS_PRIORITY_HIGHEST - 1, DEFAULT_MOVE_CALLBACK, (GUI_CALLBACK)MapTownMineExitButtonCallBack ); // delete video object DeleteVideoObjectFromIndex( uiObject ); /* // if below ground disable if( iCurrentMapSectorZ ) { DisableButton( guiMapButtonInventory[ 0 ] ); } */ return; }
void CreateDestroyTownInfoBox( void ) { // create destroy pop up box for town/mine info static BOOLEAN fCreated = FALSE; SGPRect pDimensions; SGPPoint pPosition; INT8 bTownId = 0; if( ( fCreated == FALSE ) && ( fShowTownInfo == TRUE ) ) { // create pop up box CreateTownInfoBox( ); // decide what kind of text to add to display if ( bCurrentTownMineSectorZ == 0 ) { // only show the mine info when mines button is selected, otherwise we need to see the sector's regular town info if ( ( IsThereAMineInThisSector( bCurrentTownMineSectorX, bCurrentTownMineSectorY ) == TRUE) && fShowMineFlag ) { AddTextToMineBox( ); } else { bTownId = GetTownIdForSector( bCurrentTownMineSectorX, bCurrentTownMineSectorY ); // do we add text for the town box? if( bTownId != BLANK_SECTOR ) { // add text for town box AddTextToTownBox( ); } else { // just a blank sector (handles SAM sites if visible) AddTextToBlankSectorBox( ); } } // add "militia", "militia training", "control" "enemy forces", etc. lines text to any popup box AddCommonInfoToBox(); } else // underground { // sector AddSectorToBox(); } AddItemsInSectorToBox(); // set font type SetBoxFont(ghTownMineBox, BLOCKFONT2); // set highlight color SetBoxHighLight(ghTownMineBox, FONT_WHITE); SetBoxSecondColumnForeground( ghTownMineBox, FONT_WHITE ); SetBoxSecondColumnBackground( ghTownMineBox, FONT_BLACK ); SetBoxSecondColumnHighLight( ghTownMineBox, FONT_WHITE ); SetBoxSecondColumnShade( ghTownMineBox, FONT_BLACK ); SetBoxSecondColumnFont( ghTownMineBox, BLOCKFONT2 ); SetBoxSecondColumnMinimumOffset( ghTownMineBox, 20 ); // unhighlighted color SetBoxForeground(ghTownMineBox, FONT_YELLOW); // background color SetBoxBackground(ghTownMineBox, FONT_BLACK); // shaded color..for darkened text SetBoxShade( ghTownMineBox, FONT_BLACK ); // give title line (0) different color from the rest SetBoxLineForeground( ghTownMineBox, 0, FONT_LTGREEN ); // ressize box to text ResizeBoxToText( ghTownMineBox ); // make box bigger to this size GetBoxSize( ghTownMineBox , &pDimensions ); if( pDimensions.iRight < BOX_BUTTON_WIDTH ) { // resize box to fit button pDimensions.iRight += BOX_BUTTON_WIDTH; } pDimensions.iBottom += BOX_BUTTON_HEIGHT; SetBoxSize( ghTownMineBox, pDimensions ); ShowBox( ghTownMineBox ); // now position box MinWidthOfTownMineInfoBox( ); PositionTownMineInfoBox( ); // now add the button AddInventoryButtonForMapPopUpBox( ); // now position box PositionTownMineInfoBox( ); fCreated = TRUE; } else if( ( fCreated == TRUE ) && ( fShowTownInfo == FALSE ) ) { // get box size GetBoxSize( ghTownMineBox, &pDimensions ); // get position GetBoxPosition( ghTownMineBox, &pPosition); // destroy pop up box RemoveBox( ghTownMineBox ); ghTownMineBox = -1; // remove inventory button RemoveInventoryButtonForMapPopUpBox( ); // restore background RestoreExternBackgroundRect( ( INT16 )pPosition.iX, ( INT16 )pPosition.iY, ( INT16 ) ( pDimensions.iRight - pDimensions.iLeft ), ( INT16 ) ( pDimensions.iBottom - pDimensions.iTop + 3 ) ); fCreated = FALSE; } return; }