00001
00033 #include "llviewerprecompiledheaders.h"
00034
00035 #include "llfloaterevent.h"
00036
00037
00038 #include "llcommandhandler.h"
00039 #include "llpanelevent.h"
00040
00041
00042 #include "lluuid.h"
00043 #include "lluictrlfactory.h"
00044
00046
00047
00048
00049
00050
00051
00052 LLMap< U32, LLFloaterEventInfo* > gEventInfoInstances;
00053
00054 class LLEventHandler : public LLCommandHandler
00055 {
00056 public:
00057
00058 LLEventHandler() : LLCommandHandler("event", false) { }
00059 bool handle(const LLSD& tokens, const LLSD& queryMap)
00060 {
00061 if (tokens.size() < 2)
00062 {
00063 return false;
00064 }
00065 U32 event_id = tokens[0].asInteger();
00066 if (tokens[1].asString() == "about")
00067 {
00068 LLFloaterEventInfo::show(event_id);
00069 return true;
00070 }
00071 return false;
00072 }
00073 };
00074 LLEventHandler gEventHandler;
00075
00076 LLFloaterEventInfo::LLFloaterEventInfo(const std::string& name, const U32 event_id)
00077 : LLFloater(name),
00078 mEventID( event_id )
00079 {
00080
00081 mFactoryMap["event_details_panel"] = LLCallbackMap(LLFloaterEventInfo::createEventDetail, this);
00082 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_preview_event.xml", &getFactoryMap());
00083 gEventInfoInstances.addData(event_id, this);
00084 }
00085
00086 LLFloaterEventInfo::~LLFloaterEventInfo()
00087 {
00088
00089 gEventInfoInstances.removeData(mEventID);
00090 }
00091
00092 void LLFloaterEventInfo::displayEventInfo(const U32 event_id)
00093 {
00094 mPanelEventp->setEventID(event_id);
00095 this->setFrontmost(true);
00096 }
00097
00098
00099 void* LLFloaterEventInfo::createEventDetail(void* userdata)
00100 {
00101 LLFloaterEventInfo *self = (LLFloaterEventInfo*)userdata;
00102 self->mPanelEventp = new LLPanelEvent();
00103 LLUICtrlFactory::getInstance()->buildPanel(self->mPanelEventp, "panel_event.xml");
00104
00105 return self->mPanelEventp;
00106 }
00107
00108
00109 LLFloaterEventInfo* LLFloaterEventInfo::show(const U32 event_id)
00110 {
00111 LLFloaterEventInfo *floater;
00112 if (gEventInfoInstances.checkData(event_id))
00113 {
00114
00115 floater = gEventInfoInstances.getData(event_id);
00116 floater->open();
00117 floater->setFrontmost(true);
00118 }
00119 else
00120 {
00121 floater = new LLFloaterEventInfo("eventinfo", event_id );
00122 floater->center();
00123 floater->open();
00124 floater->displayEventInfo(event_id);
00125 floater->setFrontmost(true);
00126 }
00127
00128 return floater;
00129 }