Changed: Set icon background from land speciality sbrick

--HG--
branch : develop
This commit is contained in:
Nimetu 2018-05-02 17:05:35 +03:00
parent aa612e3799
commit b48b1dc0cc
3 changed files with 89 additions and 1 deletions

View file

@ -1548,12 +1548,48 @@ void CDBCtrlSheet::setupDisplayAsPhrase(const std::vector<NLMISC::CSheetId> &bri
// Get the best SBrick to display.
CSheetId rootBrickSheetId= bricks[0];
{
CSheetId bestBrickSheetId= pBM->getSabrinaCom().getPhraseBestDisplayBrick(bricks);
setupDisplayAsSBrick (rootBrickSheetId.asInt(), bestBrickSheetId.asInt() );
}
// Override background if type is forace extraction/prospection and ecosystem brick is used
{
BRICK_FAMILIES::TBrickFamily family = pBM->getSabrinaCom().getPhraseForageFamily(bricks);
std::string icon;
switch(family)
{
case BRICK_FAMILIES::BHFEMA:
case BRICK_FAMILIES::BHFPMA:
icon = "bk_matis_brick.tga";
break;
case BRICK_FAMILIES::BHFEMB:
case BRICK_FAMILIES::BHFPMB:
icon = "bk_fyros_brick.tga";
break;
case BRICK_FAMILIES::BHFEMC:
case BRICK_FAMILIES::BHFPMC:
icon = "bk_zorai_brick.tga";
break;
case BRICK_FAMILIES::BHFEMD:
case BRICK_FAMILIES::BHFPMD:
icon = "bk_tryker_brick.tga";
break;
case BRICK_FAMILIES::BHFEME:
case BRICK_FAMILIES::BHFPME:
icon = "bk_generic_brick.tga";
break;
default:
icon = "";
break;
}
if (!icon.empty())
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
_DispBackBmpId = rVR.getTextureIdFromName(icon);
}
}
// not so beautiful to display .sphrase name in progression, and in botchat
if(_ActualType==SheetType_SPhraseId)
{

View file

@ -140,6 +140,55 @@ TOOL_TYPE::TCraftingToolType CSabrinaCom::getPhraseFaberPlanToolType(const std:
return TOOL_TYPE::Unknown;
}
// ***************************************************************************
BRICK_FAMILIES::TBrickFamily CSabrinaCom::getPhraseForageFamily(const std::vector<NLMISC::CSheetId> &phraseBricks) const
{
if(phraseBricks.empty())
return BRICK_FAMILIES::Unknown;
BRICK_TYPE::EBrickType bType= _BC->getBrickType(phraseBricks[0]);
if ( (bType == BRICK_TYPE::FORAGE_PROSPECTION) || (bType == BRICK_TYPE::FORAGE_EXTRACTION) )
{
for ( uint i=1; i<phraseBricks.size(); ++i ) // skip the root brick (index 0)
{
const CSheetId& brickId = phraseBricks[i];
uint indexInFamily;
BRICK_FAMILIES::TBrickFamily brickFamily = _BC->getBrickFamily( brickId, indexInFamily );
// FPMA=prospection, FEMA=extraction
if ((brickFamily == BRICK_FAMILIES::BHFPMA || brickFamily == BRICK_FAMILIES::BHFEMA))
{
// remapping need to be used because prospection ecosystem families
// have resource speciality inserted right in the middle
// luckily indexInFamily and TBrickFamily is defined in the same order
BRICK_FAMILIES::TBrickFamily bf = (BRICK_FAMILIES::TBrickFamily)(brickFamily + indexInFamily - 1);
// A:matis, B:fyros, C:zorai, D:tryker, E:prime roots
switch (bf) {
case BRICK_FAMILIES::BHFPMA:
case BRICK_FAMILIES::BHFPMB:
return bf;
case BRICK_FAMILIES::BHFPRMFMA:
return BRICK_FAMILIES::BHFPMC;
case BRICK_FAMILIES::BHFPRMFMB:
return BRICK_FAMILIES::BHFPMD;
case BRICK_FAMILIES::BHFPRMFMC:
return BRICK_FAMILIES::BHFPME;
case BRICK_FAMILIES::BHFEMA:
case BRICK_FAMILIES::BHFEMB:
case BRICK_FAMILIES::BHFEMC:
case BRICK_FAMILIES::BHFEMD:
case BRICK_FAMILIES::BHFEME:
return bf;
default:
break;
}
}
}
}
return BRICK_FAMILIES::Unknown;
}
// ***************************************************************************
NLMISC::CSheetId CSabrinaCom::getPhraseBestDisplayBrick(const std::vector<NLMISC::CSheetId> &phraseBricks) const
{

View file

@ -91,6 +91,9 @@ public:
/// For Faber.
TOOL_TYPE::TCraftingToolType getPhraseFaberPlanToolType(const std::vector<NLMISC::CSheetId> &phraseBricks) const;
//// For Display, if ecosystem is in use, then return it
BRICK_FAMILIES::TBrickFamily getPhraseForageFamily(const std::vector<NLMISC::CSheetId> &phraseBricks) const;
/// For Display. Return the brick (should be in phrase) used to display the phrase as icon
NLMISC::CSheetId getPhraseBestDisplayBrick(const std::vector<NLMISC::CSheetId> &phraseBricks) const;