diff -r 89347b2b591f code/ryzom/client/src/interface_v3/view_radar.cpp --- a/code/ryzom/client/src/interface_v3/view_radar.cpp Sat Sep 29 12:51:15 2012 +0200 +++ b/code/ryzom/client/src/interface_v3/view_radar.cpp Sat Sep 29 13:53:02 2012 +0200 @@ -39,149 +39,182 @@ // ---------------------------------------------------------------------------- +CViewRadar::CViewRadar(const TCtorParam ¶m) + : CViewBase(param) +{ + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CCDBNodeLeaf *pUIMI = pIM->getDbProp( "UI:SAVE:INSCENE:FRIEND:MISSION_ICON" ); + if (pUIMI) + { + ICDBNode::CTextId textId; + pUIMI->addObserver( &_MissionIconsObs, textId); + } + + CCDBNodeLeaf *pUIMMI = pIM->getDbProp( "UI:SAVE:INSCENE:FRIEND:MINI_MISSION_ICON" ); + if (pUIMMI) + { + ICDBNode::CTextId textId; + pUIMMI->addObserver( &_MiniMissionSpotsObs, textId); + } +} + bool CViewRadar::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup) { - CXMLAutoPtr prop; + CXMLAutoPtr prop; - //try to get props that can be inherited from groups - //if a property is not defined, try to find it in the parent group. - //if it is undefined, set it to zero - if (! CViewBase::parse(cur,parentGroup) ) - { - string tmp = string("cannot parse view:")+getId()+", parent:"+parentGroup->getId(); - nlinfo (tmp.c_str()); - return false; - } + //try to get props that can be inherited from groups + //if a property is not defined, try to find it in the parent group. + //if it is undefined, set it to zero + if (! CViewBase::parse(cur,parentGroup) ) + { + string tmp = string("cannot parse view:")+getId()+", parent:"+parentGroup->getId(); + nlinfo (tmp.c_str()); + return false; + } - // World size - _WorldSize = 100.0; - prop = (char*) xmlGetProp( cur, (xmlChar*)"world_size" ); - if (prop) fromString((const char*)prop, _WorldSize); + // World size + _WorldSize = 100.0; + prop = (char*) xmlGetProp( cur, (xmlChar*)"world_size" ); + if (prop) fromString((const char*)prop, _WorldSize); - // Spot textures - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); - - // Large missions Icons - const char *spotTextureNames[NbRadarSpotIds] = { "texture_std", "texture_missionlist", "texture_missionauto", "texture_missionstep" }; + // Spot textures + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CViewRenderer &rVR = pIM->getViewRenderer(); - // Mini missions Icons - const char *spotMiniTextureNames[NbRadarSpotIds] = { "texture_std", "mini_texture_missionlist", "mini_texture_missionauto", "mini_texture_missionstep" }; + // Large missions Icons + const char *spotTextureNames[NbRadarSpotIds] = { "texture_std", "texture_missionlist", "texture_missionauto", "texture_missionstep" }; - for (uint i=0; i!=NbRadarSpotIds; ++i) - { - string txName; + // Mini missions Icons + const char *spotMiniTextureNames[NbRadarSpotIds] = { "texture_std", "mini_texture_missionlist", "mini_texture_missionauto", "mini_texture_missionstep" }; - // Large missions Icons - prop = (char*) xmlGetProp( cur, (xmlChar*)spotTextureNames[i] ); - if (prop) - { - txName = (const char *) prop; - txName = strlwr (txName); - } - _SpotDescriptions[i].TextureId.setTexture(txName.c_str()); - rVR.getTextureSizeFromId (_SpotDescriptions[i].TextureId, _SpotDescriptions[i].TxW, _SpotDescriptions[i].TxH); + for (uint i=0; i!=NbRadarSpotIds; ++i) + { + string txName; - // Mini missions Icons - prop = (char*) xmlGetProp( cur, (xmlChar*)spotMiniTextureNames[i] ); - if (prop) - { - txName = (const char *) prop; - txName = strlwr (txName); - } - _SpotDescriptions[i].MiniTextureId.setTexture(txName.c_str()); - rVR.getTextureSizeFromId (_SpotDescriptions[i].MiniTextureId, _SpotDescriptions[i].MTxW, _SpotDescriptions[i].MTxH); + // Large missions Icons + prop = (char*) xmlGetProp( cur, (xmlChar*)spotTextureNames[i] ); + if (prop) + { + txName = (const char *) prop; + txName = strlwr (txName); + } + _SpotDescriptions[i].TextureId.setTexture(txName.c_str()); + rVR.getTextureSizeFromId (_SpotDescriptions[i].TextureId, _SpotDescriptions[i].TxW, _SpotDescriptions[i].TxH); - if (i == 0) - _SpotDescriptions[i].isMissionSpot = false; - else - _SpotDescriptions[i].isMissionSpot = true; - } + // Mini missions Icons + prop = (char*) xmlGetProp( cur, (xmlChar*)spotMiniTextureNames[i] ); + if (prop) + { + txName = (const char *) prop; + txName = strlwr (txName); + } + _SpotDescriptions[i].MiniTextureId.setTexture(txName.c_str()); + rVR.getTextureSizeFromId (_SpotDescriptions[i].MiniTextureId, _SpotDescriptions[i].MTxW, _SpotDescriptions[i].MTxH); - return true; + if (i == 0) + _SpotDescriptions[i].isMissionSpot = false; + else + _SpotDescriptions[i].isMissionSpot = true; + } + + return true; } // ---------------------------------------------------------------------------- void CViewRadar::draw () { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = pIM->getViewRenderer(); - CEntityCL *user = EntitiesMngr.entity(0); - if (user == NULL) return; - CVectorD xyzRef = user->pos(); - CVector dir = user->front(); + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CViewRenderer &rVR = pIM->getViewRenderer(); - float angle = (float)(atan2(dir.y, dir.x) - (Pi / 2.0)); - CMatrix mat; - mat.identity(); - // Scale to transform from world to interface screen - mat.scale( CVector((float)(_WReal / _WorldSize), (float)(_HReal / _WorldSize), 1) ); - // local to user - mat.rotateZ(-angle); - xyzRef.z = 0; - mat.translate(-xyzRef); + CEntityCL *user = EntitiesMngr.entity(0); + if (__builtin_expect((user == NULL), true)) + return; - float maxSqrRadius= (float)sqr(_WorldSize/2); + CVectorD xyzRef = user->pos(); + const CVector dir = user->front(); - const bool displayMissionSpots = pIM->getDbProp("UI:SAVE:INSCENE:FRIEND:MISSION_ICON")->getValueBool(); - const bool displayMiniMissionSpots = pIM->getDbProp("UI:SAVE:INSCENE:FRIEND:MINI_MISSION_ICON")->getValueBool(); + float angle = (float)(atan2(dir.y, dir.x) - Pi / 2.0); + CMatrix mat; + mat.identity(); + // Scale to transform from world to interface screen + mat.scale( CVector((float)(_WReal / _WorldSize), (float)(_HReal / _WorldSize), 1) ); + // local to user + mat.rotateZ(-angle); + xyzRef.z = 0; + mat.translate(-xyzRef); - for (sint32 i = 1; i < 256; ++i) - { - CEntityCL *entity = EntitiesMngr.entity(i); - if (entity == NULL) continue; + float maxSqrRadius= (float)sqr(_WorldSize/2); - // if the entity must not be shown in radar - if(!entity->getDisplayInRadar()) - continue; + for (sint32 i = 1; i < 256; ++i) + { + CEntityCL *entity = EntitiesMngr.entity(i); + if (entity == NULL) continue; - // get entity pos - CVectorD xyz = entity->pos(); + // if the entity must not be shown in radar + if(!entity->getDisplayInRadar()) + continue; - xyz.z = 0; - // if the distance is too big so do not display the entity - if ((sqr(xyz.x - xyzRef.x)+sqr(xyz.y - xyzRef.y)) > maxSqrRadius) continue; + // get entity pos + CVectorD xyz = entity->pos(); - // Transform the dot - xyz = mat * xyz; + xyz.z = 0; + // if the distance is too big so do not display the entity + if ((sqr(xyz.x - xyzRef.x)+sqr(xyz.y - xyzRef.y)) > maxSqrRadius) continue; - // Convert to screen - sint32 x = OptFastFloor((float)xyz.x); - sint32 y = OptFastFloor((float)xyz.y); + // Transform the dot + xyz = mat * xyz; - CRGBA col = entity->getColor(); + // Convert to screen + sint32 x = OptFastFloor((float)xyz.x); + sint32 y = OptFastFloor((float)xyz.y); - if(getModulateGlobalColor()) - col.modulateFromColor (col, pIM->getGlobalColorForContent()); - else - col.A = (uint8)(((sint32)col.A*((sint32)pIM->getGlobalColorForContent().A+1))>>8); + CRGBA col = entity->getColor(); - // Select the icon to display and draw it - uint spotId = CNPCIconCache::getInstance().getNPCIcon(entity).getSpotId(); - CRadarSpotDesc spotDesc = _SpotDescriptions[spotId]; - - if (!displayMissionSpots) - spotDesc = _SpotDescriptions[0]; + if(getModulateGlobalColor()) + col.modulateFromColor (col, pIM->getGlobalColorForContent()); + else + col.A = (uint8)(((sint32)col.A*((sint32)pIM->getGlobalColorForContent().A+1))>>8); - if (spotDesc.isMissionSpot) - col = CRGBA(255, 255, 255, 255); + // Select the icon to display and draw it + uint spotId = CNPCIconCache::getInstance().getNPCIcon(entity).getSpotId(); + CRadarSpotDesc spotDesc = _SpotDescriptions[spotId]; - if (entity->isTarget()) - spotId = 4; // to make it over other spots + if (!_MissionIconsObs._displayMissionSpots) + spotDesc = _SpotDescriptions[0]; - // Draw it (and make sure mission icons are drawn over regular dot; caution: don't exceed the render layer range) - if (spotDesc.isMissionSpot && displayMiniMissionSpots) - rVR.drawRotFlipBitmap (_RenderLayer+spotId, _XReal+x-(spotDesc.MTxW/2)+(_WReal/2), _YReal+y-(spotDesc.MTxH/2)+(_HReal/2), - spotDesc.MTxW, spotDesc.MTxH, 0, false, spotDesc.MiniTextureId, col ); - else - rVR.drawRotFlipBitmap (_RenderLayer+spotId, _XReal+x-(spotDesc.TxW/2)+(_WReal/2), _YReal+y-(spotDesc.TxH/2)+(_HReal/2), - spotDesc.TxW, spotDesc.TxH, 0, false, spotDesc.TextureId, col ); - } + if (spotDesc.isMissionSpot) + col = CRGBA(255, 255, 255, 255); + + if (entity->isTarget()) + spotId = 4; // to make it over other spots + + // Draw it (and make sure mission icons are drawn over regular dot; caution: don't exceed the render layer range) + if (spotDesc.isMissionSpot && _MiniMissionSpotsObs._displayMiniMissionSpots) + rVR.drawRotFlipBitmap (_RenderLayer+spotId, _XReal+x-(spotDesc.MTxW/2)+(_WReal/2), _YReal+y-(spotDesc.MTxH/2)+(_HReal/2), + spotDesc.MTxW, spotDesc.MTxH, 0, false, spotDesc.MiniTextureId, col ); + else + rVR.drawRotFlipBitmap (_RenderLayer+spotId, _XReal+x-(spotDesc.TxW/2)+(_WReal/2), _YReal+y-(spotDesc.TxH/2)+(_HReal/2), + spotDesc.TxW, spotDesc.TxH, 0, false, spotDesc.TextureId, col ); + } } // ---------------------------------------------------------------------------- void CViewRadar::updateCoords() { - CViewBase::updateCoords(); + CViewBase::updateCoords(); } + +void CViewRadar::CDBMissionIconqObs::update(ICDBNode *node) +{ +// CInterfaceManager *pIM = CInterfaceManager::getInstance(); + _displayMissionSpots = ((CCDBNodeLeaf*)node)->getValueBool(); +// pIM->displaySystemInfo(ucstring("CDBMissionIconqObs: ") + toString(displayMissionSpots)); +} + +void CViewRadar::CDBMiniMissionSpotsObs::update(ICDBNode *node) +{ +// CInterfaceManager *pIM = CInterfaceManager::getInstance(); + _displayMiniMissionSpots = ((CCDBNodeLeaf*)node)->getValueBool(); +// pIM->displaySystemInfo(ucstring("CDBMiniMissionSpotsObs: ") + toString(displayMissionSpots)); +} diff -r 89347b2b591f code/ryzom/client/src/interface_v3/view_radar.h --- a/code/ryzom/client/src/interface_v3/view_radar.h Sat Sep 29 12:51:15 2012 +0200 +++ b/code/ryzom/client/src/interface_v3/view_radar.h Sat Sep 29 13:53:02 2012 +0200 @@ -23,6 +23,9 @@ #include "nel/3d/u_texture.h" #include "view_renderer.h" + + + /** * class implementing a radar view * \author Matthieu 'TrapII' Besson @@ -45,9 +48,7 @@ }; /// Constructor - CViewRadar(const TCtorParam ¶m) : CViewBase(param) - { - } + CViewRadar(const TCtorParam ¶m); bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup); @@ -64,8 +65,9 @@ void setWorldSize(float f) { _WorldSize = f; } float getWorldSize() const { return (float)_WorldSize; } + + protected: - double _WorldSize; struct CRadarSpotDesc @@ -79,7 +81,25 @@ sint32 MTxH; }; - CRadarSpotDesc _SpotDescriptions[NbRadarSpotIds]; +private: + CRadarSpotDesc _SpotDescriptions[NbRadarSpotIds]; + + class CDBMissionIconqObs : public ICDBNode::IPropertyObserver + { + public: + virtual void update(ICDBNode *node); + bool _displayMissionSpots; + }; + CDBMissionIconqObs _MissionIconsObs; + + class CDBMiniMissionSpotsObs : public ICDBNode::IPropertyObserver + { + public: + virtual void update(ICDBNode *node); + bool _displayMiniMissionSpots; + }; + CDBMiniMissionSpotsObs _MiniMissionSpotsObs; + }; #endif // RY_VIEW_RADAR_H