llpanelevent.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "llpanelevent.h"
00035 #include "message.h"
00036 #include "llui.h"
00037 
00038 #include "llagent.h"
00039 #include "llviewerwindow.h"
00040 #include "llbutton.h"
00041 #include "llcachename.h"
00042 #include "lleventflags.h"
00043 #include "lleventnotifier.h"
00044 #include "llfloater.h"
00045 #include "llfloaterworldmap.h"
00046 #include "llinventorymodel.h"
00047 #include "llsecondlifeurls.h"
00048 #include "lltextbox.h"
00049 #include "llviewertexteditor.h"
00050 #include "lluiconstants.h"
00051 #include "llviewercontrol.h"
00052 #include "llweb.h"
00053 #include "llworldmap.h"
00054 #include "lluictrlfactory.h"
00055 
00056 //static
00057 std::list<LLPanelEvent*> LLPanelEvent::sAllPanels;
00058 
00059 LLPanelEvent::LLPanelEvent() : LLPanel("Event Panel")
00060 {
00061         sAllPanels.push_back(this);
00062 }
00063 
00064 
00065 LLPanelEvent::~LLPanelEvent()
00066 {
00067         sAllPanels.remove(this);
00068 }
00069 
00070 
00071 BOOL LLPanelEvent::postBuild()
00072 {
00073         mTBName = getChild<LLTextBox>("event_name");
00074 
00075         mTBCategory = getChild<LLTextBox>("event_category");
00076         
00077         mTBDate = getChild<LLTextBox>("event_date");
00078 
00079         mTBDuration = getChild<LLTextBox>("event_duration");
00080 
00081         mTBDesc = getChild<LLTextEditor>("event_desc");
00082         mTBDesc->setWordWrap(TRUE);
00083         mTBDesc->setEnabled(FALSE);
00084 
00085         mTBRunBy = getChild<LLTextBox>("event_runby");
00086         mTBLocation = getChild<LLTextBox>("event_location");
00087         mTBCover = getChild<LLTextBox>("event_cover");
00088 
00089         mTeleportBtn = getChild<LLButton>( "teleport_btn");
00090         mTeleportBtn->setClickedCallback(onClickTeleport);
00091         mTeleportBtn->setCallbackUserData(this);
00092 
00093         mMapBtn = getChild<LLButton>( "map_btn");
00094         mMapBtn->setClickedCallback(onClickMap);
00095         mMapBtn->setCallbackUserData(this);
00096 
00097         mNotifyBtn = getChild<LLButton>( "notify_btn");
00098         mNotifyBtn->setClickedCallback(onClickNotify);
00099         mNotifyBtn->setCallbackUserData(this);
00100 
00101         mCreateEventBtn = getChild<LLButton>( "create_event_btn");
00102         mCreateEventBtn->setClickedCallback(onClickCreateEvent);
00103         mCreateEventBtn->setCallbackUserData(this);
00104 
00105         return TRUE;
00106 }
00107 
00108 void LLPanelEvent::setEventID(const U32 event_id)
00109 {
00110         mEventID = event_id;
00111         // Should reset all of the panel state here
00112         resetInfo();
00113 
00114         if (event_id != 0)
00115         {
00116                 sendEventInfoRequest();
00117         }
00118 }
00119 
00120 
00121 void LLPanelEvent::sendEventInfoRequest()
00122 {
00123         LLMessageSystem *msg = gMessageSystem;
00124 
00125         msg->newMessageFast(_PREHASH_EventInfoRequest);
00126         msg->nextBlockFast(_PREHASH_AgentData);
00127         msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
00128         msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
00129         msg->nextBlockFast(_PREHASH_EventData);
00130         msg->addU32Fast(_PREHASH_EventID, mEventID);
00131         gAgent.sendReliableMessage();
00132 }
00133 
00134 
00135 //static 
00136 void LLPanelEvent::processEventInfoReply(LLMessageSystem *msg, void **)
00137 {
00138         // extract the agent id
00139         LLUUID agent_id;
00140         msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
00141 
00142         U32 event_id;
00143         msg->getU32("EventData", "EventID", event_id);
00144 
00145         // look up all panels which have this avatar
00146         for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter)
00147         {
00148                 LLPanelEvent* self = *iter;
00149                 // Skip updating panels which aren't for this event
00150                 if (self->mEventID != event_id)
00151                 {
00152                         continue;
00153                 }
00154                 self->mEventInfo.unpack(msg);
00155                 self->mTBName->setText(self->mEventInfo.mName);
00156                 self->mTBCategory->setText(self->mEventInfo.mCategoryStr);
00157                 self->mTBDate->setText(self->mEventInfo.mTimeStr);
00158                 self->mTBDesc->setText(self->mEventInfo.mDesc);
00159 
00160                 self->mTBDuration->setText(llformat("%d:%.2d", self->mEventInfo.mDuration / 60, self->mEventInfo.mDuration % 60));
00161 
00162                 if (!self->mEventInfo.mHasCover)
00163                 {
00164                         self->mTBCover->setText(self->getString("none"));
00165                 }
00166                 else
00167                 {
00168                         self->mTBCover->setText(llformat("%d", self->mEventInfo.mCover));
00169                 }
00170 
00171                 F32 global_x = (F32)self->mEventInfo.mPosGlobal.mdV[VX];
00172                 F32 global_y = (F32)self->mEventInfo.mPosGlobal.mdV[VY];
00173 
00174                 S32 region_x = llround(global_x) % REGION_WIDTH_UNITS;
00175                 S32 region_y = llround(global_y) % REGION_WIDTH_UNITS;
00176                 S32 region_z = llround((F32)self->mEventInfo.mPosGlobal.mdV[VZ]);
00177                 
00178                 LLString desc = self->mEventInfo.mSimName + llformat(" (%d, %d, %d)", region_x, region_y, region_z);
00179                 self->mTBLocation->setText(desc);
00180 
00181                 if (self->mEventInfo.mEventFlags & EVENT_FLAG_MATURE)
00182                 {
00183                         self->childSetVisible("event_mature_yes", TRUE);
00184                         self->childSetVisible("event_mature_no", FALSE);
00185                 }
00186                 else
00187                 {
00188                         self->childSetVisible("event_mature_yes", FALSE);
00189                         self->childSetVisible("event_mature_no", TRUE);
00190                 }
00191 
00192                 if (self->mEventInfo.mUnixTime < time_corrected())
00193                 {
00194                         self->mNotifyBtn->setEnabled(FALSE);
00195                 }
00196                 else
00197                 {
00198                         self->mNotifyBtn->setEnabled(TRUE);
00199                 }
00200                 
00201                 if (gEventNotifier.hasNotification(self->mEventInfo.mID))
00202                 {
00203                         self->mNotifyBtn->setLabel(self->getString("dont_notify"));
00204                 }
00205                 else
00206                 {
00207                         self->mNotifyBtn->setLabel(self->getString("notify"));
00208                 }
00209         }
00210 }
00211 
00212 
00213 void LLPanelEvent::draw()
00214 {
00215         std::string name;
00216         gCacheName->getFullName(mEventInfo.mRunByID, name);
00217 
00218         mTBRunBy->setText(name);
00219 
00220         LLPanel::draw();
00221 }
00222 
00223 void LLPanelEvent::resetInfo()
00224 {
00225         // Clear all of the text fields.
00226 }
00227 
00228 // static
00229 void LLPanelEvent::onClickTeleport(void* data)
00230 {
00231         LLPanelEvent* self = (LLPanelEvent*)data;
00232 
00233         if (!self->mEventInfo.mPosGlobal.isExactlyZero())
00234         {
00235                 gAgent.teleportViaLocation(self->mEventInfo.mPosGlobal);
00236                 gFloaterWorldMap->trackLocation(self->mEventInfo.mPosGlobal);
00237         }
00238 }
00239 
00240 
00241 // static
00242 void LLPanelEvent::onClickMap(void* data)
00243 {
00244         LLPanelEvent* self = (LLPanelEvent*)data;
00245 
00246         if (!self->mEventInfo.mPosGlobal.isExactlyZero())
00247         {
00248                 gFloaterWorldMap->trackLocation(self->mEventInfo.mPosGlobal);
00249                 LLFloaterWorldMap::show(NULL, TRUE);
00250         }
00251 }
00252 
00253 
00254 // static
00255 /*
00256 void LLPanelEvent::onClickLandmark(void* data)
00257 {
00258         LLPanelEvent* self = (LLPanelEvent*)data;
00259         //create_landmark(self->mTBName->getText(), "", self->mEventInfo.mPosGlobal);
00260         LLMessageSystem* msg = gMessageSystem;
00261         msg->newMessage("CreateLandmarkForEvent");
00262         msg->nextBlockFast(_PREHASH_AgentData);
00263         msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
00264         msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
00265         msg->nextBlockFast(_PREHASH_EventData);
00266         msg->addU32Fast(_PREHASH_EventID, self->mEventID);
00267         msg->nextBlockFast(_PREHASH_InventoryBlock);
00268         LLUUID folder_id;
00269         folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_LANDMARK);
00270         msg->addUUIDFast(_PREHASH_FolderID, folder_id);
00271         msg->addStringFast(_PREHASH_Name, self->mTBName->getText());
00272         gAgent.sendReliableMessage();
00273 }
00274 */
00275 
00276 // static
00277 void LLPanelEvent::onClickCreateEvent(void* data)
00278 {
00279         LLPanelEvent* self = (LLPanelEvent*)data;
00280         
00281         gViewerWindow->alertXml("PromptGoToEventsPage",
00282                 callbackCreateEventWebPage, 
00283                 self); 
00284 }
00285 
00286 // static
00287 void LLPanelEvent::onClickNotify(void *data)
00288 {
00289         LLPanelEvent* self = (LLPanelEvent*)data;
00290 
00291         if (!gEventNotifier.hasNotification(self->mEventID))
00292         {
00293                 gEventNotifier.add(self->mEventInfo);
00294                 self->mNotifyBtn->setLabel(self->getString("dont_notify"));
00295         }
00296         else
00297         {
00298                 gEventNotifier.remove(self->mEventInfo.mID);
00299                 self->mNotifyBtn->setLabel(self->getString("notify"));
00300         }
00301 }
00302 
00303 // static
00304 void LLPanelEvent::callbackCreateEventWebPage(S32 option, void* data)
00305 {
00306         if (0 == option)
00307         {
00308                 llinfos << "Loading events page " << EVENTS_URL << llendl;
00309 
00310                 LLWeb::loadURL(EVENTS_URL);
00311         }
00312 }

Generated on Fri May 16 08:33:50 2008 for SecondLife by  doxygen 1.5.5