llfloatereventlog.h

Go to the documentation of this file.
00001 //
00002 // C++ Interface: llfloatereventlog
00003 //
00004 // Description: 
00005 //
00006 //
00007 // Author: Dale Glass <dale@daleglass.net>, (C) 2007
00008 //
00009 // Copyright: See COPYING file that comes with this distribution
00010 //
00011 //
00012 
00013 #ifndef LL_LLFLOATERVENTLOG_H
00014 #define LL_LLFLOATERVENTLOG_H
00015 
00016 #include "llviewerprecompiledheaders.h"
00017 #include "llfloater.h"
00018 #include "viewer.h"
00019 #include "llviewerobject.h"
00020 #include "lltexturectrl.h"
00021 #include "llpartdata.h"
00022 
00023 #include <map>
00024 
00025 using std::map;
00026 
00027 class LLFloaterEventLog;
00028 class LLEventEmitter;
00029 
00030 /*************************************************************************
00031 * Events
00032 *************************************************************************/
00033 
00034 const S32 MAX_INTERESTING_TEXTURES = 3;
00035 
00036 
00040 class LLWorldEvent : public LLRefCount
00041 {
00042 public:
00043         LLWorldEvent(const LLUUID &id = LLUUID::null ) : mDuration(0), mCount(0) { mLastFrame = gFrameCount; mGlobalID.generate();}
00044 
00045         F32 getAge() const { return mAgeTimer.getElapsedTimeF32(); }
00046         F32 getDuration() const { return mDuration; }
00047         S32 getCount() const { return mCount; }
00048 
00053         virtual S32 getScore() const = 0;
00054 
00059         virtual LLUUID getID() const = 0;
00060 
00068         LLUUID getGlobalID() const { return mGlobalID; }
00069 
00076         void checkDuration() { if ( mLastFrame != gFrameCount ) mDurationTimer.reset(); }
00077 
00081         void incCount(S32 count = 1);
00082 
00083         bool operator+=(const LLWorldEvent &ev) { incCount(ev.mCount); return true; }
00084         bool operator<(const LLWorldEvent &ev) { return getScore() > ev.getScore(); }
00085 
00086         virtual LLString getIcon() = 0;
00087 
00088         void setParent(LLPointer<LLEventEmitter> parent) { mParent = parent; }
00089         LLPointer<LLEventEmitter> getParent() { return mParent; }
00090 private:
00091         F32 mDuration;
00092         S32 mCount;
00093         LLTimer mAgeTimer;
00094         LLTimer mDurationTimer;
00095         U32 mLastFrame;
00096 
00097         LLUUID mGlobalID;
00098         LLPointer<LLEventEmitter> mParent;
00099 };
00100 
00105 class LLParticleEvent : public LLWorldEvent
00106 {
00107 public:
00108         LLParticleEvent(const LLUUID &texture = LLUUID::null) : mTexture(texture) { }
00109         LLParticleEvent(const LLPartSysData &data);
00110 
00111         LLUUID getTexture() const { return mTexture; }
00112         virtual LLUUID getID() const { return mTexture; }
00113 
00114         virtual LLString getIcon() { return gViewerArt.getString("account_id_blue.tga"); }
00115 
00116         virtual S32 getScore() const;
00117 
00118         void setParticleData(const LLPartSysData &data) { mPartSysData = data; }
00119 private:
00120         friend class LLFloaterEventLog;
00121 
00122         LLUUID mTexture;
00123         LLPartSysData mPartSysData;
00124         
00125 };
00126 
00127 
00128 class LLSoundEvent : public LLWorldEvent
00129 {
00130 public:
00131         LLSoundEvent(const LLUUID &sound = LLUUID::null) : mSound(sound) {}
00132         
00133         LLUUID getSound() const { return mSound; }
00134         virtual LLUUID getID() const { return mSound; }
00135         virtual S32 getScore() const { return 0; }
00136         virtual LLString getIcon() { return gViewerArt.getString("inv_item_sound.tga"); }
00137 private:
00138         LLUUID mSound;
00139 };
00140 
00141 
00142 /*************************************************************************
00143 * Emitters
00144 *************************************************************************/
00145 
00151 class LLEventEmitter : public LLRefCount
00152 {
00153 public:
00154         LLEventEmitter() {}
00155 
00160         virtual LLString getName() const { return ""; }
00161 
00162         virtual void setName(const LLString &name) {}
00163 
00170         virtual LLUUID   getID() const { return LLUUID::null; }
00171 
00176         virtual void update() {}
00177 
00178 
00179         virtual LLString getOwnerName() const { return ""; }
00180         virtual LLUUID   getOwnerID() const { return LLUUID::null; }
00181 
00182         LLVector3d getPosition() const { return mPosition; }
00183         void setPosition(const LLVector3d &pos) { mPosition = pos; }
00184 
00185         void addEvent(LLPointer<LLWorldEvent> ev) { mEvents[ev->getID()] = ev; ev->setParent(this); }
00186         LLPointer<LLWorldEvent> getEvent(const LLUUID &id) { if ( mEvents.count( id ) > 0 )     { return mEvents[id]; } return NULL; }
00187 protected:
00188         friend class LLFloaterEventLog;
00189 
00190         LLVector3d mPosition;
00191         map <LLUUID, LLPointer<LLWorldEvent> > mEvents;
00192 };
00193 
00198 class LLAvatarOwnedEmitter: public LLEventEmitter
00199 {
00200 public:
00201         LLAvatarOwnedEmitter(const LLUUID& id = LLUUID::null, const LLString& name = "");
00202         ~LLAvatarOwnedEmitter();
00203 
00204         virtual LLString getOwnerName() const { return mOwnerName; }
00205         virtual LLUUID   getOwnerID() const { return mOwnerID; }
00206         virtual void update();
00207 
00208         void setOwner(const LLUUID &id, const LLString &name = "");
00209 
00210 protected:
00211         LLUUID mOwnerID;
00212         LLString mOwnerName;
00213 
00214 private:
00215         bool mNamePending;
00216         static void nameLookupCallback(const LLUUID&id, const char *first, const char *last, BOOL group, void *userdata);
00217 };
00218 
00219 
00224 class LLAvatarEmitter : public LLAvatarOwnedEmitter
00225 {
00226 public:
00227         LLAvatarEmitter(const LLUUID& id = LLUUID::null, const LLString& name = "") { setOwner(id, name); }
00228         
00229         virtual LLUUID   getID() const { return mOwnerID; }
00230         virtual LLString getName() const { return "<avatar>"; }
00231 private:
00232 };
00233 
00238 class LLObjectEmitter : public LLAvatarOwnedEmitter
00239 {
00240 public:
00241         LLObjectEmitter(const LLUUID& id = LLUUID::null, const LLUUID &owner = LLUUID::null);
00242         LLObjectEmitter(LLPointer <LLViewerObject> obj);
00243 
00244         virtual LLString getName() const { return mObjectName; }
00245         virtual void setName(const LLString &name) { mObjectName = name; }
00246 
00247         virtual LLUUID getID() const { return mObjectID; }
00248 
00249         LLUUID getObjectID() const { return mObjectID; }
00250         LLString getObjectName() const { return mObjectName; }
00251 
00261         void requestObjectInfo(const LLViewerRegion *reg);
00262 
00263         void setObject( const LLUUID& id, const LLString &name = "" );
00264 private:
00265         LLUUID mObjectID;
00266         LLString mObjectName;
00267         bool mRequestedProperties;
00268 };
00269 
00270 
00271 
00272 /*************************************************************************
00273 * Event Log
00274 *************************************************************************/
00275 
00276 class LLFloaterEventLog : public LLFloater
00277 {
00278 public:
00279         enum QUICK_BUTTON_FUNCTION
00280         {
00281                 QB_AVATAR_PROFILE,
00282                 QB_AVATAR_KEY,
00283                 QB_AVATAR_TRACK,
00284                 QB_AVATAR_MUTE,
00285                 QB_AVATAR_EJECT,
00286                 QB_AVATAR_LW_GOHOME,
00287                 QB_OBJECT_KEY,
00288                 QB_OBJECT_TRACK,
00289                 QB_OBJECT_MUTE,
00290                 QB_OBJECT_RETURN,
00291                 QB_UUID_BLACKLIST,
00292                 QB_UUID_WHITELIST,
00293                 QB_UUID_MUTELIST,
00294                 QB_COUNT /* must be the last one */
00295         } quick_button_function_t;
00296 
00297         enum QUICK_BUTTON_TYPE
00298         {
00299                 QBT_AVATAR,
00300                 QBT_OBJECT,
00301                 QBT_UUID
00302         } quick_button_type_t;
00303 
00304         LLFloaterEventLog();
00305         ~LLFloaterEventLog();
00306 
00307         void show();
00308         virtual void onClose(bool app_quitting) { setVisible(FALSE); }
00309         static void toggle(void*);
00310         static BOOL visible(void*);
00311 
00312         void logAvatarEvent( const LLUUID &avatar, const LLString &name = "", LLPointer <LLWorldEvent> ev = NULL);
00313         void logObjectEvent( const LLUUID &object, const LLUUID &owner = LLUUID::null, LLPointer <LLWorldEvent> ev = NULL);
00314 
00315         void logObject( LLPointer<LLViewerObject> vo);
00316 
00317         void logEvent( LLPointer<LLEventEmitter> em, LLPointer <LLWorldEvent> ev);
00318 
00319         void updateWindow();
00320 
00321         static void processObjectProperties(LLMessageSystem *msg, void **user_data);
00322         static void processObjectPropertiesFamily(LLMessageSystem *msg, void **user_data);
00323         static void onDoubleClick(void *userdata);
00324 private:
00325         enum EVENTS_COLUMN_ORDER
00326         {
00327                 LIST_EVENT_ICON,
00328                 LIST_OWNER_NAME,
00329                 LIST_OBJECT_NAME,
00330                 LIST_ID,
00331                 LIST_DISTANCE,
00332                 LIST_COUNT,
00333                 LIST_DURATION,
00334                 LIST_AGE,
00335                 LIST_SCORE
00336         } event_type_t;
00337 
00338         enum EVENT_TYPE
00339         {
00340                 EVENT_PARTICLE,
00341                 EVENT_SOUND
00342         };
00343 
00347         LLPointer<LLEventEmitter> getEmitter(const LLUUID &id) { if ( mEmitters.count( id ) > 0 )       { return mEmitters[id]; } return NULL; }
00348 
00349         LLPointer<LLEventEmitter> findEmitterBySelectedID(const LLUUID &id);
00350         LLPointer<LLWorldEvent> findEventBySelectedID(const LLUUID &id);
00351         
00352 
00353         void updateControlsState();
00354 
00355         LLScrollListCtrl *mEventList;
00356 
00357         LLTextureCtrl *mSelectedTexture;
00358 
00359         LLTextureCtrl*          mHiscoreTextures[MAX_INTERESTING_TEXTURES];
00360         LLTextBox*              mHiscoreNames[MAX_INTERESTING_TEXTURES];
00361         LLTextBox*              mHiscoreOwners[MAX_INTERESTING_TEXTURES];
00362         LLButton*               mHiscoreButtons[MAX_INTERESTING_TEXTURES];
00363         LLPointer<LLWorldEvent> mHiscoreEvents[MAX_INTERESTING_TEXTURES];
00364 
00365         LLButton*             mActionButtons[QB_COUNT]; 
00366         QUICK_BUTTON_TYPE   mActionButtonsType[QB_COUNT];
00367 
00368         map<LLUUID, LLPointer<LLEventEmitter> > mEmitters;
00369 
00370 
00371         void updateList();
00372         void updateSelectedEventInfo();
00373         void updateQuickButtons();
00374 
00375         typedef void (*avlist_command_t)(const LLUUID &avatar, const LLString &name);
00376 
00383         void LLFloaterEventLog::doCommand(avlist_command_t func, bool use_object_id, bool first_only = false);
00384 
00385         static void onClickAvatarGohomerSendHome(void *userdata);
00386         static void onClickAvatarGetKey(void *userdata);
00387         static void onClickAvatarEject(void *userdata);
00388         static void onClickAvatarMute(void *userdata);
00389         static void onClickAvatarProfile(void* userdata);
00390         static void onClickAvatarTrack(void* userdata);
00391 
00392         static void onClickObjectGetKey(void* userdata);
00393         static void onClickObjectTrack(void* userdata);
00394         static void onClickObjectMute(void* userdata);
00395         static void onClickObjectReturn(void* userdata);
00396 
00397         static void onClickUUIDBlacklist(void* userdata);
00398         static void onClickUUIDWhitelist(void* userdata);
00399         static void onClickUUIDMutelist(void* userdata);
00400 
00401         static void onClickQuickButton(void *userdata);
00402 };
00403 
00404 
00405 
00406 extern LLFloaterEventLog *gFloaterEventLog;
00407 
00408 #endif

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