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 "llvieweruictrlfactory.h"
00055
00056
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 = LLViewerUICtrlFactory::getTextBoxByName(this, "event_name");
00074 mTBName->setColor(gColors.getColor( "LabelSelectedColor" ));
00075
00076 mTBCategory = LLViewerUICtrlFactory::getTextBoxByName(this, "event_category");
00077 mTBCategory->setColor(gColors.getColor( "LabelSelectedColor" ));
00078
00079 childSetColor("event_mature_yes", gColors.getColor( "LabelSelectedColor" ));
00080 childSetColor("event_mature_no", gColors.getColor( "LabelSelectedColor" ));
00081
00082 mTBDate = LLViewerUICtrlFactory::getTextBoxByName(this, "event_date");
00083 mTBDate->setColor(gColors.getColor( "LabelSelectedColor" ));
00084
00085 mTBDuration = LLViewerUICtrlFactory::getTextBoxByName(this, "event_duration");
00086 mTBDuration->setColor(gColors.getColor( "LabelSelectedColor" ));
00087
00088 mTBDesc = LLUICtrlFactory::getTextEditorByName(this, "event_desc");
00089 mTBDesc->setWordWrap(TRUE);
00090 mTBDesc->setEnabled(FALSE);
00091 mTBDesc->setFgColor(gColors.getColor( "LabelSelectedColor" ));
00092 mTBDesc->setReadOnlyFgColor(LLColor4(1.f, 1.f, 1.f, 1.f));
00093
00094 mTBRunBy = LLViewerUICtrlFactory::getTextBoxByName(this, "event_runby");
00095 mTBRunBy->setColor(gColors.getColor( "LabelSelectedColor" ));
00096 mTBLocation = LLViewerUICtrlFactory::getTextBoxByName(this, "event_location");
00097 mTBLocation->setColor(gColors.getColor( "LabelSelectedColor" ));
00098 mTBCover = LLViewerUICtrlFactory::getTextBoxByName(this, "event_cover");
00099 mTBCover->setColor(gColors.getColor( "LabelSelectedColor" ));
00100
00101 mTeleportBtn = LLViewerUICtrlFactory::getButtonByName(this, "teleport_btn");
00102 mTeleportBtn->setClickedCallback(onClickTeleport);
00103 mTeleportBtn->setCallbackUserData(this);
00104
00105 mMapBtn = LLViewerUICtrlFactory::getButtonByName(this, "map_btn");
00106 mMapBtn->setClickedCallback(onClickMap);
00107 mMapBtn->setCallbackUserData(this);
00108
00109
00110
00111
00112
00113 mNotifyBtn = LLViewerUICtrlFactory::getButtonByName(this, "notify_btn");
00114 mNotifyBtn->setClickedCallback(onClickNotify);
00115 mNotifyBtn->setCallbackUserData(this);
00116
00117 mCreateEventBtn = LLViewerUICtrlFactory::getButtonByName(this, "create_event_btn");
00118 mCreateEventBtn->setClickedCallback(onClickCreateEvent);
00119 mCreateEventBtn->setCallbackUserData(this);
00120
00121 return TRUE;
00122 }
00123
00124 void LLPanelEvent::setEventID(const U32 event_id)
00125 {
00126 mEventID = event_id;
00127
00128 resetInfo();
00129
00130 if (event_id != 0)
00131 {
00132 sendEventInfoRequest();
00133 }
00134 }
00135
00136
00137 void LLPanelEvent::sendEventInfoRequest()
00138 {
00139 LLMessageSystem *msg = gMessageSystem;
00140
00141 msg->newMessageFast(_PREHASH_EventInfoRequest);
00142 msg->nextBlockFast(_PREHASH_AgentData);
00143 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
00144 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
00145 msg->nextBlockFast(_PREHASH_EventData);
00146 msg->addU32Fast(_PREHASH_EventID, mEventID);
00147 gAgent.sendReliableMessage();
00148 }
00149
00150
00151
00152 void LLPanelEvent::processEventInfoReply(LLMessageSystem *msg, void **)
00153 {
00154
00155 LLUUID agent_id;
00156 msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
00157
00158 U32 event_id;
00159 msg->getU32("EventData", "EventID", event_id);
00160
00161
00162 for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter)
00163 {
00164 LLPanelEvent* self = *iter;
00165
00166 if (self->mEventID != event_id)
00167 {
00168 continue;
00169 }
00170 self->mEventInfo.unpack(msg);
00171 self->mTBName->setText(self->mEventInfo.mName);
00172 self->mTBCategory->setText(self->mEventInfo.mCategoryStr);
00173 self->mTBDate->setText(self->mEventInfo.mTimeStr);
00174 self->mTBDesc->setText(self->mEventInfo.mDesc);
00175
00176 self->mTBDuration->setText(llformat("%d:%.2d", self->mEventInfo.mDuration / 60, self->mEventInfo.mDuration % 60));
00177
00178 if (!self->mEventInfo.mHasCover)
00179 {
00180 self->mTBCover->setText(self->childGetText("none"));
00181 }
00182 else
00183 {
00184 self->mTBCover->setText(llformat("%d", self->mEventInfo.mCover));
00185 }
00186
00187 F32 global_x = (F32)self->mEventInfo.mPosGlobal.mdV[VX];
00188 F32 global_y = (F32)self->mEventInfo.mPosGlobal.mdV[VY];
00189
00190 S32 region_x = llround(global_x) % REGION_WIDTH_UNITS;
00191 S32 region_y = llround(global_y) % REGION_WIDTH_UNITS;
00192 S32 region_z = llround((F32)self->mEventInfo.mPosGlobal.mdV[VZ]);
00193
00194 LLString desc = self->mEventInfo.mSimName + llformat(" (%d, %d, %d)", region_x, region_y, region_z);
00195 self->mTBLocation->setText(desc);
00196
00197 if (self->mEventInfo.mEventFlags & EVENT_FLAG_MATURE)
00198 {
00199 self->childSetVisible("event_mature_yes", TRUE);
00200 self->childSetVisible("event_mature_no", FALSE);
00201 }
00202 else
00203 {
00204 self->childSetVisible("event_mature_yes", FALSE);
00205 self->childSetVisible("event_mature_no", TRUE);
00206 }
00207
00208 if (self->mEventInfo.mUnixTime < time_corrected())
00209 {
00210 self->mNotifyBtn->setEnabled(FALSE);
00211 }
00212 else
00213 {
00214 self->mNotifyBtn->setEnabled(TRUE);
00215 }
00216
00217 if (gEventNotifier.hasNotification(self->mEventInfo.mID))
00218 {
00219 self->mNotifyBtn->setLabel(self->childGetText("dont_notify"));
00220 }
00221 else
00222 {
00223 self->mNotifyBtn->setLabel(self->childGetText("notify"));
00224 }
00225 }
00226 }
00227
00228
00229 void LLPanelEvent::draw()
00230 {
00231 char firstname[DB_FIRST_NAME_BUF_SIZE];
00232 char lastname[DB_LAST_NAME_BUF_SIZE];
00233 gCacheName->getName(mEventInfo.mRunByID, firstname, lastname);
00234
00235 LLString name;
00236 name = firstname;
00237 name += " ";
00238 name += lastname;
00239 mTBRunBy->setText(name);
00240
00241 LLPanel::draw();
00242 }
00243
00244 void LLPanelEvent::resetInfo()
00245 {
00246
00247 }
00248
00249
00250 void LLPanelEvent::onClickTeleport(void* data)
00251 {
00252 LLPanelEvent* self = (LLPanelEvent*)data;
00253
00254 if (!self->mEventInfo.mPosGlobal.isExactlyZero())
00255 {
00256 gAgent.teleportViaLocation(self->mEventInfo.mPosGlobal);
00257 gFloaterWorldMap->trackLocation(self->mEventInfo.mPosGlobal);
00258 }
00259 }
00260
00261
00262
00263 void LLPanelEvent::onClickMap(void* data)
00264 {
00265 LLPanelEvent* self = (LLPanelEvent*)data;
00266
00267 if (!self->mEventInfo.mPosGlobal.isExactlyZero())
00268 {
00269 gFloaterWorldMap->trackLocation(self->mEventInfo.mPosGlobal);
00270 LLFloaterWorldMap::show(NULL, TRUE);
00271 }
00272 }
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298 void LLPanelEvent::onClickCreateEvent(void* data)
00299 {
00300 LLPanelEvent* self = (LLPanelEvent*)data;
00301
00302 gViewerWindow->alertXml("PromptGoToEventsPage",
00303 callbackCreateEventWebPage,
00304 self);
00305 }
00306
00307
00308 void LLPanelEvent::onClickNotify(void *data)
00309 {
00310 LLPanelEvent* self = (LLPanelEvent*)data;
00311
00312 if (!gEventNotifier.hasNotification(self->mEventID))
00313 {
00314 gEventNotifier.add(self->mEventInfo);
00315 self->mNotifyBtn->setLabel(self->childGetText("dont_notify"));
00316 }
00317 else
00318 {
00319 gEventNotifier.remove(self->mEventInfo.mID);
00320 self->mNotifyBtn->setLabel(self->childGetText("notify"));
00321 }
00322 }
00323
00324
00325 void LLPanelEvent::callbackCreateEventWebPage(S32 option, void* data)
00326 {
00327 if (0 == option)
00328 {
00329 llinfos << "Loading events page " << EVENTS_URL << llendl;
00330
00331 LLWeb::loadURL(EVENTS_URL);
00332 }
00333 }