aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpreviewlandmark.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llpreviewlandmark.cpp
parentREADME.txt (diff)
downloadmeta-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/llpreviewlandmark.cpp')
-rw-r--r--linden/indra/newview/llpreviewlandmark.cpp267
1 files changed, 267 insertions, 0 deletions
diff --git a/linden/indra/newview/llpreviewlandmark.cpp b/linden/indra/newview/llpreviewlandmark.cpp
new file mode 100644
index 0000000..b56e7a5
--- /dev/null
+++ b/linden/indra/newview/llpreviewlandmark.cpp
@@ -0,0 +1,267 @@
1/**
2 * @file llpreviewlandmark.cpp
3 * @brief LLPreviewLandmark class implementation
4 *
5 * Copyright (c) 2002-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 "llpreviewlandmark.h"
31
32#include "llassetstorage.h"
33#include "llfocusmgr.h"
34#include "llfontgl.h"
35#include "llgl.h"
36#include "llinventory.h"
37#include "message.h"
38
39#include "llagent.h"
40#include "llbutton.h"
41#include "lleconomy.h"
42#include "llfloaterworldmap.h"
43#include "llinventoryview.h"
44#include "lliconctrl.h"
45#include "lllandmarklist.h"
46#include "lllineeditor.h"
47#include "llresmgr.h"
48#include "llstatusbar.h"
49#include "lltextbox.h"
50#include "llui.h"
51#include "llviewercontrol.h"
52#include "llviewerregion.h"
53#include "llviewerstats.h"
54#include "viewer.h"
55#include "llvieweruictrlfactory.h"
56
57
58
59
60////////////////////////////////////////////////////////////////////////////
61// LLPreviewLandmark
62
63// static
64//LLDoubleLinkedList<LLPreviewLandmark> LLPreviewLandmark::sOrderedInstances;
65LLPreviewLandmarkList LLPreviewLandmark::sOrderedInstances;
66
67
68LLPreviewLandmark::LLPreviewLandmark(const std::string& name,
69 const LLRect& rect,
70 const std::string& title,
71 const LLUUID& item_uuid,
72 BOOL show_keep_discard)
73: LLPreview(name,
74 LLRect(rect.mLeft,
75 rect.mTop,
76 (show_keep_discard ? rect.mRight+70 : rect.mRight),
77 rect.mBottom),
78 title,
79 item_uuid,
80 LLUUID::null),
81 mLandmark( NULL )
82{
83
84 if (show_keep_discard)
85 {
86 gUICtrlFactory->buildFloater(this,"floater_preview_new_landmark.xml");
87 childSetAction("Discard btn",onDiscardBtn,this);
88 }
89 else
90 {
91 gUICtrlFactory->buildFloater(this,"floater_preview_existing_landmark.xml");
92 childSetVisible("desc txt", FALSE);
93 childSetEnabled("desc", FALSE);
94 }
95
96 childSetAction("Teleport btn", onTeleportBtn,this);
97 childSetAction("Show on Map btn", onMapBtn,this);
98
99 LLInventoryItem* item = getItem();
100
101 childSetCommitCallback("desc", LLPreview::onText, this);
102 childSetText("desc", item->getDescription());
103 childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe);
104
105 setTitle(title);
106
107 if (!getHost())
108 {
109 LLRect curRect = getRect();
110 translate(rect.mLeft - curRect.mLeft, rect.mTop - curRect.mTop);
111 }
112
113 LLPreviewLandmark::sOrderedInstances.push_back( this );
114}
115
116// static
117void LLPreviewLandmark::onMapBtn( void* userdata )
118{
119 LLPreviewLandmark* self = (LLPreviewLandmark*) userdata;
120 gFocusMgr.setKeyboardFocus(NULL, NULL);
121
122 if( gFloaterWorldMap )
123 {
124 gFloaterWorldMap->trackLandmark( self->mItemUUID );
125 LLFloaterWorldMap::show(NULL, TRUE);
126
127 self->close();
128 }
129}
130
131// static
132void LLPreviewLandmark::onTeleportBtn( void* userdata )
133{
134 LLPreviewLandmark* self = (LLPreviewLandmark*) userdata;
135 gFocusMgr.setKeyboardFocus(NULL, NULL);
136
137 LLInventoryItem *item = self->getItem();
138 if(item)
139 {
140 gAgent.teleportViaLandmark(item->getAssetUUID());
141
142 // we now automatically track the landmark you're teleporting to
143 // because you'll probably arrive at a telehub instead
144 if( gFloaterWorldMap )
145 {
146 gFloaterWorldMap->trackLandmark( self->mItemUUID );
147 }
148 }
149 self->close();
150}
151
152LLPreviewLandmark::~LLPreviewLandmark()
153{
154 LLPreviewLandmarkList::iterator this_itr;
155 this_itr = std::find(LLPreviewLandmark::sOrderedInstances.begin(),
156 LLPreviewLandmark::sOrderedInstances.end(), this);
157 if (this_itr != LLPreviewLandmark::sOrderedInstances.end())
158 {
159 LLPreviewLandmark::sOrderedInstances.erase(this_itr);
160 }
161}
162
163
164// Distance and direction from avatar to landmark.
165// Distance is in meters; degrees is angle from east (north = 90)
166void LLPreviewLandmark::getDegreesAndDist( F32* degrees, F64* horiz_dist, F64* vert_dist) const
167{
168 if( mLandmark )
169 {
170 LLVector3d pos;
171 if(mLandmark->getGlobalPos(pos))
172 {
173 LLVector3d to_vec = pos - gAgent.getPositionGlobal();
174 *horiz_dist = sqrt(to_vec.mdV[VX] * to_vec.mdV[VX] + to_vec.mdV[VY] * to_vec.mdV[VY]);
175 *vert_dist = to_vec.mdV[VZ];
176 *degrees = F32( RAD_TO_DEG * atan2( to_vec.mdV[VY], to_vec.mdV[VX] ) );
177 }
178 }
179}
180
181const LLString& LLPreviewLandmark::getName() const
182{
183 LLInventoryItem *item = getItem();
184 if (item)
185 {
186 return item->getName();
187 }
188 return LLString::null;
189}
190
191LLVector3d LLPreviewLandmark::getPositionGlobal() const
192{
193 LLVector3d pos;
194 if( mLandmark )
195 {
196 // we can safely ignore the return value here.
197 (void)mLandmark->getGlobalPos(pos);
198 }
199 return pos;
200}
201
202
203const LLColor4& LLPreviewLandmark::getMarkerColor() const
204{
205 return mMarkerColor;
206}
207
208void LLPreviewLandmark::draw()
209{
210 if( getVisible() )
211 {
212 LLInventoryItem *item = getItem();
213
214 if( item && !mLandmark )
215 {
216 mLandmark = gLandmarkList.getAsset( item->getAssetUUID() );
217 }
218
219 if(mLandmark)
220 {
221 F32 degrees = 0;
222 F64 horiz_dist = 0;
223 F64 vert_dist = 0;
224 getDegreesAndDist( &degrees, &horiz_dist, &vert_dist);
225 S32 offset = 180 + (360/16);
226 if( S32(degrees) + offset >= 360 )
227 {
228 offset -= 360;
229 }
230#if _DEBUG
231 S32 dir_index = (S32(degrees) + offset) / (360/8);
232 llassert( 0 <= dir_index && dir_index <= 7 );
233#endif
234 // See also llfloatermap.cpp -> onLandmarkGo
235
236 childSetEnabled("Teleport btn", TRUE);
237 LLButton* teleportBtn = LLUICtrlFactory::getButtonByName(this, "Teleport btn");
238 teleportBtn->setLabelUnselected("Teleport");
239 }
240
241 BOOL in_prelude = gAgent.inPrelude();
242 childSetEnabled("Show on Map btn", !in_prelude);
243
244 LLFloater::draw();
245 }
246}
247
248void LLPreviewLandmark::loadAsset()
249{
250 LLInventoryItem *item = getItem();
251
252 if( item && !mLandmark )
253 {
254 mLandmark = gLandmarkList.getAsset( item->getAssetUUID() );
255 }
256 mAssetStatus = PREVIEW_ASSET_LOADING;
257}
258
259LLPreview::EAssetStatus LLPreviewLandmark::getAssetStatus()
260{
261 LLInventoryItem *item = getItem();
262 if (item && gLandmarkList.assetExists(item->getAssetUUID()))
263 {
264 mAssetStatus = PREVIEW_ASSET_LOADED;
265 }
266 return mAssetStatus;
267}