llfloateravatarinfo.cpp

Go to the documentation of this file.
00001 
00034 #include "llviewerprecompiledheaders.h"
00035 
00036 #include "llfloateravatarinfo.h"
00037 
00038 // viewer project includes
00039 #include "llagentdata.h"
00040 //#include "llbutton.h"
00041 //#include "llcallingcard.h"
00042 //#include "llcheckboxctrl.h"
00043 //#include "llcommandhandler.h"
00044 //#include "llfloaterworldmap.h"
00045 //#include "llfloatermute.h"
00046 //#include "llinventoryview.h"
00047 //#include "lllineeditor.h"
00048 //#include "llmutelist.h"
00049 //#include "llscrolllistctrl.h"
00050 //#include "lltabcontainer.h"
00051 //#include "llimview.h"
00052 //#include "lluiconstants.h"
00053 //#include "llviewerobject.h"
00054 //#include "llviewerobjectlist.h"
00055 //#include "llviewerregion.h"
00056 //#include "llviewborder.h"
00057 //#include "llinventorymodel.h"
00058 //#include "lltextbox.h"
00059 //#include "lltexturectrl.h"
00060 //#include "llviewertexteditor.h"
00061 #include "llcommandhandler.h"
00062 #include "llpanelavatar.h"
00063 #include "llvieweruictrlfactory.h"
00064 
00065 // linden library includes
00066 #include "llinventory.h"
00067 #include "lluuid.h"
00068 #include "message.h"
00069 
00070 const char FLOATER_TITLE[] = "Profile";
00071 const LLRect FAI_RECT(0, 530, 420, 0);
00072 
00073 //-----------------------------------------------------------------------------
00074 // Globals
00075 //-----------------------------------------------------------------------------
00076 
00077 LLMap< const LLUUID, LLFloaterAvatarInfo* > gAvatarInfoInstances;
00078 
00079 class LLAgentHandler : public LLCommandHandler
00080 {
00081 public:
00082         LLAgentHandler() : LLCommandHandler("agent") { }
00083         bool handle(const std::vector<std::string>& params)
00084         {
00085                 if (params.size() < 2) return false;
00086                 LLUUID agent_id;
00087                 if (!agent_id.set(params[0], FALSE))
00088                 {
00089                         return false;
00090                 }
00091 
00092                 if (params[1] == "about")
00093                 {
00094                         LLFloaterAvatarInfo::show(agent_id);
00095                         return true;
00096                 }
00097                 return false;
00098         }
00099 };
00100 LLAgentHandler gAgentHandler;
00101 
00102 //-----------------------------------------------------------------------------
00103 // Member functions
00104 //-----------------------------------------------------------------------------
00105 
00106 //----------------------------------------------------------------------------
00107 
00108 void*   LLFloaterAvatarInfo::createPanelAvatar(void*    data)
00109 {
00110         LLFloaterAvatarInfo* self = (LLFloaterAvatarInfo*)data;
00111         self->mPanelAvatarp = new LLPanelAvatar("PanelAv", LLRect(), TRUE); // allow edit self
00112         return self->mPanelAvatarp;
00113 }
00114 
00115 //----------------------------------------------------------------------------
00116 
00117 
00118 BOOL    LLFloaterAvatarInfo::postBuild()
00119 {
00120         return TRUE;
00121 }
00122 
00123 LLFloaterAvatarInfo::LLFloaterAvatarInfo(const std::string& name, const LLRect &rect, const LLUUID &avatar_id)
00124 :       LLPreview(name, rect, FLOATER_TITLE, LLUUID::null, LLUUID::null),
00125         mAvatarID( avatar_id ),
00126         mSuggestedOnlineStatus(ONLINE_STATUS_NO)
00127 {
00128         mAutoFocus = TRUE;
00129 
00130         LLCallbackMap::map_t factory_map;
00131 
00132         factory_map["Panel Avatar"] = LLCallbackMap(createPanelAvatar, this);
00133         
00134         gUICtrlFactory->buildFloater(this, "floater_profile.xml", &factory_map);
00135 
00136 
00137         if(mPanelAvatarp)
00138         {
00139                 mPanelAvatarp->selectTab(0);
00140         }
00141 
00142         gAvatarInfoInstances.addData(avatar_id, this);
00143 
00144         
00145 }
00146 
00147 // virtual
00148 LLFloaterAvatarInfo::~LLFloaterAvatarInfo()
00149 {
00150         // child views automatically deleted
00151         gAvatarInfoInstances.removeData(mAvatarID);
00152 
00153 }
00154 
00155 void LLFloaterAvatarInfo::resetGroupList()
00156 {
00157         // only get these updates asynchronously via the group floater, which works on the agent only
00158         if (mAvatarID != gAgentID)
00159         {
00160                 return;
00161         }
00162 
00163         mPanelAvatarp->resetGroupList();
00164 }
00165 
00166 // static
00167 LLFloaterAvatarInfo* LLFloaterAvatarInfo::show(const LLUUID &avatar_id)
00168 {
00169         if (avatar_id.isNull())
00170         {
00171                 return NULL;
00172         }
00173 
00174         LLFloaterAvatarInfo *floater;
00175         if (gAvatarInfoInstances.checkData(avatar_id))
00176         {
00177                 // ...bring that window to front
00178                 floater = gAvatarInfoInstances.getData(avatar_id);
00179                 floater->open();        /*Flawfinder: ignore*/
00180         }
00181         else
00182         {
00183                 floater =  new LLFloaterAvatarInfo("avatarinfo", FAI_RECT, 
00184                         avatar_id );
00185                 floater->center();
00186                 floater->open();        /*Flawfinder: ignore*/
00187         }
00188         return floater;
00189 }
00190 
00191 // Open profile to a certain tab.
00192 // static
00193 void LLFloaterAvatarInfo::showFromObject(
00194         const LLUUID& avatar_id,
00195         std::string tab_name)
00196 {
00197         LLFloaterAvatarInfo *floater = show(avatar_id);
00198         if (floater)
00199         {
00200                 floater->mPanelAvatarp->setAvatarID(avatar_id, "", ONLINE_STATUS_NO);
00201                 floater->mPanelAvatarp->selectTabByName(tab_name);
00202         }
00203 }
00204 
00205 // static
00206 void LLFloaterAvatarInfo::showFromDirectory(const LLUUID &avatar_id)
00207 {
00208         LLFloaterAvatarInfo *floater = show(avatar_id);
00209         if (floater)
00210         {
00211                 floater->mPanelAvatarp->setAvatarID(avatar_id, "", ONLINE_STATUS_NO);
00212         }
00213 }
00214 
00215 
00216 // static
00217 void LLFloaterAvatarInfo::showFromFriend(const LLUUID& agent_id, BOOL online)
00218 {
00219         LLFloaterAvatarInfo *floater = show(agent_id);
00220         if (floater)
00221         {
00222                 floater->mSuggestedOnlineStatus = online ? ONLINE_STATUS_YES : ONLINE_STATUS_NO;
00223         }
00224 }
00225 
00226 
00227 void LLFloaterAvatarInfo::showProfileCallback(S32 option, void *userdata)
00228 {
00229         if (option == 0)
00230         {
00231                 showFromObject(gAgentID);
00232         }
00233 }
00234 
00235 
00237 void LLFloaterAvatarInfo::draw()
00238 {
00239         LLFloater::draw();
00240 }
00241 
00242 // virtual
00243 BOOL LLFloaterAvatarInfo::canClose()
00244 {
00245         return mPanelAvatarp && mPanelAvatarp->canClose();
00246 }
00247 
00248 LLFloaterAvatarInfo* LLFloaterAvatarInfo::getInstance(const LLUUID &id)
00249 {
00250         return gAvatarInfoInstances.getIfThere(gAgentID);
00251 }
00252 
00253 void LLFloaterAvatarInfo::loadAsset()
00254 {
00255         if (mPanelAvatarp) {
00256                 mPanelAvatarp->setAvatarID(mAvatarID, "", mSuggestedOnlineStatus);
00257                 mAssetStatus = PREVIEW_ASSET_LOADING;
00258         }
00259 }
00260 
00261 LLPreview::EAssetStatus LLFloaterAvatarInfo::getAssetStatus()
00262 {
00263         if (mPanelAvatarp && mPanelAvatarp->haveData())
00264         {
00265                 mAssetStatus = PREVIEW_ASSET_LOADED;
00266         }
00267         return mAssetStatus;
00268 }

Generated on Thu Jul 1 06:08:31 2010 for Second Life Viewer by  doxygen 1.4.7