本文整理汇总了C++中CGroupMap::centerOnPlayer方法的典型用法代码示例。如果您正苦于以下问题:C++ CGroupMap::centerOnPlayer方法的具体用法?C++ CGroupMap::centerOnPlayer怎么用?C++ CGroupMap::centerOnPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGroupMap
的用法示例。
在下文中一共展示了CGroupMap::centerOnPlayer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
void execute (CCtrlBase * /* pCaller */, const std::string &sParams)
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CGroupMap *pMap = dynamic_cast<CGroupMap*>(CWidgetManager::getInstance()->getElementFromId(sParams));
if (pMap == NULL)
return;
// Get the spawn index (from selected squad)
uint8 nSpawnIndex = getOutpostSquadSpawnIndex();
// *** Get the BBox of the outpost
// init map with all xy that are in SERVER:GUILD:OUTPOST:O#x:SQUAD_SPAWN_ZONE (if 0,0 not present)
string sDBPathSZ = "SERVER:GUILD:OUTPOST:O" + toString(getOutpostSelection()) + ":SQUAD_SPAWN_ZONE:";
sint32 xMin = 0, xMax = 0, yMin = 0, yMax = 0;
bool bInit = false;
uint32 i;
for (i = 0; i < OUTPOSTENUMS::OUTPOST_MAX_SPAWN_ZONE; ++i)
{
sint32 x = NLGUI::CDBManager::getInstance()->getDbProp(sDBPathSZ + toString(i) + ":X")->getValue32();
sint32 y = NLGUI::CDBManager::getInstance()->getDbProp(sDBPathSZ + toString(i) + ":Y")->getValue32();
if ((x != 0) || (y != 0))
{
if (!bInit)
{
xMin = xMax = x;
yMin = yMax = y;
bInit = true;
}
else
{
if (x < xMin) xMin = x;
if (x > xMax) xMax = x;
if (y < yMin) yMin = y;
if (y > yMax) yMax = y;
}
}
}
// *** Find the finest map that contains the 2 points xMin,yMin and xMax,yMax
CWorldSheet *pWorldSheet = dynamic_cast<CWorldSheet*>(SheetMngr.get(CSheetId("ryzom.world")));
if (pWorldSheet == NULL)
return;
sint32 nMapFound = -1;
for (i = 0; i < pWorldSheet->Maps.size(); ++i)
{
SMap &rMap = pWorldSheet->Maps[i];
// Avoid 'world' map
if (!rMap.ContinentName.empty())
{
// Is bouding box contains the 2 points ?
if ((rMap.MinX < xMin) && (rMap.MinY < yMin) &&
(rMap.MaxX > xMax) && (rMap.MaxY > yMax))
{
// Is there a map already found ?
if (nMapFound == -1)
{
nMapFound = i; // No, first map found
}
else // Yes we have to compare with the previous map to keep the finest
{
SMap &rMapFound = pWorldSheet->Maps[nMapFound];
if ((rMap.MaxX - rMap.MinX) < (rMapFound.MaxX - rMapFound.MinX))
nMapFound = i;
}
}
}
}
// *** Setup the Map and zoom to outpost
if (nMapFound != -1)
{
SMap &rMapFound = pWorldSheet->Maps[nMapFound];
pMap->setMap(rMapFound.Name);
CVector2f centerWorldCoord((xMax + xMin)/2.0f, (yMin + yMax)/2.0f);
CVector2f centerMapCoord;
pMap->worldToMap(centerMapCoord, centerWorldCoord);
pMap->setScale((rMapFound.MaxX - rMapFound.MinX) / max(sint32(1), (xMax - xMin)) );
pMap->setPlayerPos(centerMapCoord);
pMap->centerOnPlayer();
CRespawnPointsMsg m;
m.NeedToReset = true;
for (i = 0; i < OUTPOSTENUMS::OUTPOST_MAX_SPAWN_ZONE; ++i)
{
sint32 x = NLGUI::CDBManager::getInstance()->getDbProp(sDBPathSZ + toString(i) + ":X")->getValue32();
sint32 y = NLGUI::CDBManager::getInstance()->getDbProp(sDBPathSZ + toString(i) + ":Y")->getValue32();
if ((x != 0) || (y != 0))
{
CRespawnPointsMsg::SRespawnPoint pt;
pt.x = x * 1000;
pt.y = y * 1000;
m.RespawnPoints.push_back(pt);
}
}
pMap->addRespawnPoints(m);
pMap->setRespawnSelected(nSpawnIndex);
}
}