diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llpanelevent.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llpanelevent.cpp')
-rw-r--r-- | linden/indra/newview/llpanelevent.cpp | 339 |
1 files changed, 339 insertions, 0 deletions
diff --git a/linden/indra/newview/llpanelevent.cpp b/linden/indra/newview/llpanelevent.cpp new file mode 100644 index 0000000..498d4fc --- /dev/null +++ b/linden/indra/newview/llpanelevent.cpp | |||
@@ -0,0 +1,339 @@ | |||
1 | /** | ||
2 | * @file llpanelevent.cpp | ||
3 | * @brief Display for events in the finder | ||
4 | * | ||
5 | * Copyright (c) 2004-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #include "llviewerprecompiledheaders.h" | ||
29 | |||
30 | #include "llpanelevent.h" | ||
31 | #include "message.h" | ||
32 | #include "llui.h" | ||
33 | |||
34 | #include "llagent.h" | ||
35 | #include "llviewerwindow.h" | ||
36 | #include "llbutton.h" | ||
37 | #include "llcachename.h" | ||
38 | #include "lleventflags.h" | ||
39 | #include "lleventnotifier.h" | ||
40 | #include "llfloater.h" | ||
41 | #include "llfloaterworldmap.h" | ||
42 | #include "llinventorymodel.h" | ||
43 | #include "llsecondlifeurls.h" | ||
44 | #include "lltextbox.h" | ||
45 | #include "llviewertexteditor.h" | ||
46 | #include "lluiconstants.h" | ||
47 | #include "llviewercontrol.h" | ||
48 | #include "llweb.h" | ||
49 | #include "llworldmap.h" | ||
50 | #include "llvieweruictrlfactory.h" | ||
51 | |||
52 | //static | ||
53 | LLLinkedList<LLPanelEvent> LLPanelEvent::sAllPanels; | ||
54 | |||
55 | LLPanelEvent::LLPanelEvent() : LLPanel("Event Panel") | ||
56 | { | ||
57 | sAllPanels.addData(this); | ||
58 | } | ||
59 | |||
60 | |||
61 | LLPanelEvent::~LLPanelEvent() | ||
62 | { | ||
63 | sAllPanels.removeData(this); | ||
64 | } | ||
65 | |||
66 | |||
67 | BOOL LLPanelEvent::postBuild() | ||
68 | { | ||
69 | mTBName = LLViewerUICtrlFactory::getTextBoxByName(this, "event_name"); | ||
70 | mTBName->setColor(gColors.getColor( "LabelSelectedColor" )); | ||
71 | |||
72 | mTBCategory = LLViewerUICtrlFactory::getTextBoxByName(this, "event_category"); | ||
73 | mTBCategory->setColor(gColors.getColor( "LabelSelectedColor" )); | ||
74 | |||
75 | mMatureText = LLViewerUICtrlFactory::getTextBoxByName(this, "event_mature"); | ||
76 | mMatureText->setColor(gColors.getColor( "LabelSelectedColor" )); | ||
77 | |||
78 | mTBDate = LLViewerUICtrlFactory::getTextBoxByName(this, "event_date"); | ||
79 | mTBDate->setColor(gColors.getColor( "LabelSelectedColor" )); | ||
80 | |||
81 | mTBDuration = LLViewerUICtrlFactory::getTextBoxByName(this, "event_duration"); | ||
82 | mTBDuration->setColor(gColors.getColor( "LabelSelectedColor" )); | ||
83 | |||
84 | mTBDesc = LLUICtrlFactory::getTextEditorByName(this, "event_desc"); | ||
85 | mTBDesc->setWordWrap(TRUE); | ||
86 | mTBDesc->setEnabled(FALSE); | ||
87 | mTBDesc->setFgColor(gColors.getColor( "LabelSelectedColor" )); | ||
88 | mTBDesc->setReadOnlyFgColor(LLColor4(1.f, 1.f, 1.f, 1.f)); | ||
89 | |||
90 | mTBRunBy = LLViewerUICtrlFactory::getTextBoxByName(this, "event_runby"); | ||
91 | mTBRunBy->setColor(gColors.getColor( "LabelSelectedColor" )); | ||
92 | mTBLocation = LLViewerUICtrlFactory::getTextBoxByName(this, "event_location"); | ||
93 | mTBLocation->setColor(gColors.getColor( "LabelSelectedColor" )); | ||
94 | mTBCover = LLViewerUICtrlFactory::getTextBoxByName(this, "event_cover"); | ||
95 | mTBCover->setColor(gColors.getColor( "LabelSelectedColor" )); | ||
96 | |||
97 | mTeleportBtn = LLViewerUICtrlFactory::getButtonByName(this, "teleport_btn"); | ||
98 | mTeleportBtn->setClickedCallback(onClickTeleport); | ||
99 | mTeleportBtn->setCallbackUserData(this); | ||
100 | |||
101 | mMapBtn = LLViewerUICtrlFactory::getButtonByName(this, "map_btn"); | ||
102 | mMapBtn->setClickedCallback(onClickMap); | ||
103 | mMapBtn->setCallbackUserData(this); | ||
104 | |||
105 | //mLandmarkBtn = LLViewerUICtrlFactory::getButtonByName(this, "landmark_btn"); | ||
106 | //mLandmarkBtn->setClickedCallback(onClickLandmark); | ||
107 | //mLandmarkBtn->setCallbackUserData(this); | ||
108 | |||
109 | mNotifyBtn = LLViewerUICtrlFactory::getButtonByName(this, "notify_btn"); | ||
110 | mNotifyBtn->setClickedCallback(onClickNotify); | ||
111 | mNotifyBtn->setCallbackUserData(this); | ||
112 | |||
113 | mCreateEventBtn = LLViewerUICtrlFactory::getButtonByName(this, "create_event_btn"); | ||
114 | mCreateEventBtn->setClickedCallback(onClickCreateEvent); | ||
115 | mCreateEventBtn->setCallbackUserData(this); | ||
116 | |||
117 | return TRUE; | ||
118 | } | ||
119 | |||
120 | |||
121 | void LLPanelEvent::setEventID(const U32 event_id) | ||
122 | { | ||
123 | mEventID = event_id; | ||
124 | // Should reset all of the panel state here | ||
125 | resetInfo(); | ||
126 | |||
127 | if (event_id != 0) | ||
128 | { | ||
129 | sendEventInfoRequest(); | ||
130 | } | ||
131 | } | ||
132 | |||
133 | |||
134 | void LLPanelEvent::sendEventInfoRequest() | ||
135 | { | ||
136 | LLMessageSystem *msg = gMessageSystem; | ||
137 | |||
138 | msg->newMessageFast(_PREHASH_EventInfoRequest); | ||
139 | msg->nextBlockFast(_PREHASH_AgentData); | ||
140 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); | ||
141 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() ); | ||
142 | msg->nextBlockFast(_PREHASH_EventData); | ||
143 | msg->addU32Fast(_PREHASH_EventID, mEventID); | ||
144 | gAgent.sendReliableMessage(); | ||
145 | } | ||
146 | |||
147 | |||
148 | //static | ||
149 | void LLPanelEvent::processEventInfoReply(LLMessageSystem *msg, void **) | ||
150 | { | ||
151 | // extract the agent id | ||
152 | LLUUID agent_id; | ||
153 | msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id ); | ||
154 | |||
155 | U32 event_id; | ||
156 | msg->getU32("EventData", "EventID", event_id); | ||
157 | |||
158 | // look up all panels which have this avatar | ||
159 | LLPanelEvent *self = NULL; | ||
160 | |||
161 | |||
162 | for (self = sAllPanels.getFirstData(); self; self = sAllPanels.getNextData()) | ||
163 | { | ||
164 | // Skip updating panels which aren't for this event | ||
165 | if (self->mEventID != event_id) | ||
166 | { | ||
167 | continue; | ||
168 | } | ||
169 | char buffer[256]; | ||
170 | |||
171 | self->mEventInfo.unpack(msg); | ||
172 | self->mTBName->setText(self->mEventInfo.mName); | ||
173 | self->mTBCategory->setText(self->mEventInfo.mCategoryStr); | ||
174 | self->mTBDate->setText(self->mEventInfo.mTimeStr); | ||
175 | self->mTBDesc->setText(self->mEventInfo.mDesc); | ||
176 | |||
177 | sprintf(buffer, "%d:%.2d", self->mEventInfo.mDuration / 60, self->mEventInfo.mDuration % 60); | ||
178 | |||
179 | self->mTBDuration->setText(buffer); | ||
180 | |||
181 | if (!self->mEventInfo.mHasCover) | ||
182 | { | ||
183 | self->mTBCover->setText("none"); | ||
184 | } | ||
185 | else | ||
186 | { | ||
187 | sprintf(buffer, "%d", self->mEventInfo.mCover); | ||
188 | self->mTBCover->setText(buffer); | ||
189 | } | ||
190 | |||
191 | F32 global_x = (F32)self->mEventInfo.mPosGlobal.mdV[VX]; | ||
192 | F32 global_y = (F32)self->mEventInfo.mPosGlobal.mdV[VY]; | ||
193 | |||
194 | S32 region_x = llround(global_x) % REGION_WIDTH_UNITS; | ||
195 | S32 region_y = llround(global_y) % REGION_WIDTH_UNITS; | ||
196 | S32 region_z = llround((F32)self->mEventInfo.mPosGlobal.mdV[VZ]); | ||
197 | |||
198 | sprintf(buffer, "%s (%d, %d, %d)", self->mEventInfo.mSimName.c_str(), region_x, region_y, region_z); | ||
199 | self->mTBLocation->setText(buffer); | ||
200 | |||
201 | if (self->mEventInfo.mEventFlags & EVENT_FLAG_MATURE) | ||
202 | { | ||
203 | self->mMatureText->setText("Yes"); | ||
204 | } | ||
205 | else | ||
206 | { | ||
207 | self->mMatureText->setText("No"); | ||
208 | } | ||
209 | |||
210 | if (self->mEventInfo.mUnixTime < time_corrected()) | ||
211 | { | ||
212 | self->mNotifyBtn->setEnabled(FALSE); | ||
213 | } | ||
214 | else | ||
215 | { | ||
216 | self->mNotifyBtn->setEnabled(TRUE); | ||
217 | } | ||
218 | |||
219 | if (gEventNotifier.hasNotification(self->mEventInfo.mID)) | ||
220 | { | ||
221 | self->mNotifyBtn->setLabelSelected("Don't Notify"); | ||
222 | self->mNotifyBtn->setLabelUnselected("Don't Notify"); | ||
223 | } | ||
224 | else | ||
225 | { | ||
226 | self->mNotifyBtn->setLabelSelected("Notify"); | ||
227 | self->mNotifyBtn->setLabelUnselected("Notify"); | ||
228 | } | ||
229 | } | ||
230 | } | ||
231 | |||
232 | |||
233 | void LLPanelEvent::draw() | ||
234 | { | ||
235 | char firstname[DB_FIRST_NAME_BUF_SIZE]; | ||
236 | char lastname[DB_LAST_NAME_BUF_SIZE]; | ||
237 | gCacheName->getName(mEventInfo.mRunByID, firstname, lastname); | ||
238 | |||
239 | LLString name; | ||
240 | name = firstname; | ||
241 | name += " "; | ||
242 | name += lastname; | ||
243 | mTBRunBy->setText(name); | ||
244 | |||
245 | LLPanel::draw(); | ||
246 | } | ||
247 | |||
248 | void LLPanelEvent::resetInfo() | ||
249 | { | ||
250 | // Clear all of the text fields. | ||
251 | } | ||
252 | |||
253 | // static | ||
254 | void LLPanelEvent::onClickTeleport(void* data) | ||
255 | { | ||
256 | LLPanelEvent* self = (LLPanelEvent*)data; | ||
257 | |||
258 | if (!self->mEventInfo.mPosGlobal.isExactlyZero()) | ||
259 | { | ||
260 | gAgent.teleportViaLocation(self->mEventInfo.mPosGlobal); | ||
261 | gFloaterWorldMap->trackLocation(self->mEventInfo.mPosGlobal); | ||
262 | } | ||
263 | } | ||
264 | |||
265 | |||
266 | // static | ||
267 | void LLPanelEvent::onClickMap(void* data) | ||
268 | { | ||
269 | LLPanelEvent* self = (LLPanelEvent*)data; | ||
270 | |||
271 | if (!self->mEventInfo.mPosGlobal.isExactlyZero()) | ||
272 | { | ||
273 | gFloaterWorldMap->trackLocation(self->mEventInfo.mPosGlobal); | ||
274 | LLFloaterWorldMap::show(NULL, TRUE); | ||
275 | } | ||
276 | } | ||
277 | |||
278 | |||
279 | // static | ||
280 | /* | ||
281 | void LLPanelEvent::onClickLandmark(void* data) | ||
282 | { | ||
283 | LLPanelEvent* self = (LLPanelEvent*)data; | ||
284 | //create_landmark(self->mTBName->getText(), "", self->mEventInfo.mPosGlobal); | ||
285 | LLMessageSystem* msg = gMessageSystem; | ||
286 | msg->newMessage("CreateLandmarkForEvent"); | ||
287 | msg->nextBlockFast(_PREHASH_AgentData); | ||
288 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
289 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
290 | msg->nextBlockFast(_PREHASH_EventData); | ||
291 | msg->addU32Fast(_PREHASH_EventID, self->mEventID); | ||
292 | msg->nextBlockFast(_PREHASH_InventoryBlock); | ||
293 | LLUUID folder_id; | ||
294 | folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_LANDMARK); | ||
295 | msg->addUUIDFast(_PREHASH_FolderID, folder_id); | ||
296 | msg->addStringFast(_PREHASH_Name, self->mTBName->getText()); | ||
297 | gAgent.sendReliableMessage(); | ||
298 | } | ||
299 | */ | ||
300 | |||
301 | // static | ||
302 | void LLPanelEvent::onClickCreateEvent(void* data) | ||
303 | { | ||
304 | LLPanelEvent* self = (LLPanelEvent*)data; | ||
305 | |||
306 | gViewerWindow->alertXml("PromptGoToEventsPage", | ||
307 | callbackCreateEventWebPage, | ||
308 | self); | ||
309 | } | ||
310 | |||
311 | // static | ||
312 | void LLPanelEvent::onClickNotify(void *data) | ||
313 | { | ||
314 | LLPanelEvent* self = (LLPanelEvent*)data; | ||
315 | |||
316 | if (!gEventNotifier.hasNotification(self->mEventID)) | ||
317 | { | ||
318 | gEventNotifier.add(self->mEventInfo); | ||
319 | self->mNotifyBtn->setLabelSelected("Don't Notify"); | ||
320 | self->mNotifyBtn->setLabelUnselected("Don't Notify"); | ||
321 | } | ||
322 | else | ||
323 | { | ||
324 | gEventNotifier.remove(self->mEventInfo.mID); | ||
325 | self->mNotifyBtn->setLabelSelected("Notify"); | ||
326 | self->mNotifyBtn->setLabelUnselected("Notify"); | ||
327 | } | ||
328 | } | ||
329 | |||
330 | // static | ||
331 | void LLPanelEvent::callbackCreateEventWebPage(S32 option, void* data) | ||
332 | { | ||
333 | if (0 == option) | ||
334 | { | ||
335 | llinfos << "Loading events page " << EVENTS_URL << llendl; | ||
336 | |||
337 | LLWeb::loadURL(EVENTS_URL); | ||
338 | } | ||
339 | } | ||