1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
/**
* @file llpanelplaceinfo.cpp
* @brief Base class for place information in Side Tray.
*
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llpanelplaceinfo.h"
#include "llsdutil.h"
#include "llsdutil_math.h"
#include "llregionhandle.h"
#include "lliconctrl.h"
#include "lltextbox.h"
#include "lltrans.h"
#include "llagent.h"
#include "llexpandabletextbox.h"
#include "llpanelpick.h"
#include "lltexturectrl.h"
#include "llviewerregion.h"
LLPanelPlaceInfo::LLPanelPlaceInfo()
: LLPanel(),
mParcelID(),
mRequestedID(),
mPosRegion(),
mScrollingPanelMinHeight(0),
mScrollingPanelWidth(0),
mInfoType(UNKNOWN),
mScrollingPanel(NULL),
mScrollContainer(NULL),
mDescEditor(NULL)
{}
//virtual
LLPanelPlaceInfo::~LLPanelPlaceInfo()
{
if (mParcelID.notNull())
{
LLRemoteParcelInfoProcessor::getInstance()->removeObserver(mParcelID, this);
}
}
//virtual
BOOL LLPanelPlaceInfo::postBuild()
{
mTitle = getChild<LLTextBox>("title");
mCurrentTitle = mTitle->getText();
mSnapshotCtrl = getChild<LLTextureCtrl>("logo");
mRegionName = getChild<LLTextBox>("region_title");
mParcelName = getChild<LLTextBox>("parcel_title");
mDescEditor = getChild<LLExpandableTextBox>("description");
mMaturityRatingIcon = getChild<LLIconCtrl>("maturity_icon");
mMaturityRatingText = getChild<LLTextBox>("maturity_value");
mScrollingPanel = getChild<LLPanel>("scrolling_panel");
mScrollContainer = getChild<LLScrollContainer>("place_scroll");
mScrollingPanelMinHeight = mScrollContainer->getScrolledViewRect().getHeight();
mScrollingPanelWidth = mScrollingPanel->getRect().getWidth();
return TRUE;
}
//virtual
void LLPanelPlaceInfo::resetLocation()
{
mParcelID.setNull();
mRequestedID.setNull();
mPosRegion.clearVec();
std::string loading = LLTrans::getString("LoadingData");
mMaturityRatingText->setValue(loading);
mRegionName->setText(loading);
mParcelName->setText(loading);
mDescEditor->setText(loading);
mMaturityRatingIcon->setValue(LLUUID::null);
mSnapshotCtrl->setImageAssetID(LLUUID::null);
}
//virtual
void LLPanelPlaceInfo::setParcelID(const LLUUID& parcel_id)
{
mParcelID = parcel_id;
sendParcelInfoRequest();
}
//virtual
void LLPanelPlaceInfo::setInfoType(EInfoType type)
{
mTitle->setText(mCurrentTitle);
mTitle->setToolTip(mCurrentTitle);
mInfoType = type;
}
void LLPanelPlaceInfo::sendParcelInfoRequest()
{
if (mParcelID != mRequestedID)
{
//ext-4655, defensive. remove now incase this gets called twice without a remove
//as panel never closes its ok atm (but wrong :)
LLRemoteParcelInfoProcessor::getInstance()->removeObserver(mRequestedID, this);
LLRemoteParcelInfoProcessor::getInstance()->addObserver(mParcelID, this);
LLRemoteParcelInfoProcessor::getInstance()->sendParcelInfoRequest(mParcelID);
mRequestedID = mParcelID;
}
}
void LLPanelPlaceInfo::displayParcelInfo(const LLUUID& region_id,
const LLVector3d& pos_global)
{
LLViewerRegion* region = gAgent.getRegion();
if (!region)
return;
mPosRegion.setVec((F32)fmod(pos_global.mdV[VX], (F64)REGION_WIDTH_METERS),
(F32)fmod(pos_global.mdV[VY], (F64)REGION_WIDTH_METERS),
(F32)pos_global.mdV[VZ]);
LLSD body;
std::string url = region->getCapability("RemoteParcelRequest");
if (!url.empty())
{
body["location"] = ll_sd_from_vector3(mPosRegion);
if (!region_id.isNull())
{
body["region_id"] = region_id;
}
if (!pos_global.isExactlyZero())
{
U64 region_handle = to_region_handle(pos_global);
body["region_handle"] = ll_sd_from_U64(region_handle);
}
LLHTTPClient::post(url, body, new LLRemoteParcelRequestResponder(getObserverHandle()));
}
else
{
mDescEditor->setText(getString("server_update_text"));
}
}
// virtual
void LLPanelPlaceInfo::setErrorStatus(U32 status, const std::string& reason)
{
// We only really handle 404 and 499 errors
std::string error_text;
if(status == 404)
{
error_text = getString("server_error_text");
}
else if(status == 499)
{
error_text = getString("server_forbidden_text");
}
else
{
error_text = getString("server_error_text");
}
mDescEditor->setText(error_text);
std::string not_available = getString("not_available");
mMaturityRatingText->setValue(not_available);
mRegionName->setText(not_available);
mParcelName->setText(not_available);
mMaturityRatingIcon->setValue(LLUUID::null);
// Enable "Back" button that was disabled when parcel request was sent.
getChild<LLButton>("back_btn")->setEnabled(TRUE);
}
// virtual
void LLPanelPlaceInfo::processParcelInfo(const LLParcelData& parcel_data)
{
if(parcel_data.snapshot_id.notNull())
{
mSnapshotCtrl->setImageAssetID(parcel_data.snapshot_id);
}
if(!parcel_data.sim_name.empty())
{
mRegionName->setText(parcel_data.sim_name);
}
else
{
mRegionName->setText(LLStringUtil::null);
}
if(!parcel_data.desc.empty())
{
mDescEditor->setText(parcel_data.desc);
}
else
{
mDescEditor->setText(getString("not_available"));
}
S32 region_x;
S32 region_y;
S32 region_z;
// If the region position is zero, grab position from the global
if(mPosRegion.isExactlyZero())
{
region_x = llround(parcel_data.global_x) % REGION_WIDTH_UNITS;
region_y = llround(parcel_data.global_y) % REGION_WIDTH_UNITS;
region_z = llround(parcel_data.global_z);
}
else
{
region_x = llround(mPosRegion.mV[VX]);
region_y = llround(mPosRegion.mV[VY]);
region_z = llround(mPosRegion.mV[VZ]);
}
if (!parcel_data.name.empty())
{
mParcelTitle = parcel_data.name;
mParcelName->setText(llformat("%s (%d, %d, %d)",
mParcelTitle.c_str(), region_x, region_y, region_z));
}
else
{
mParcelName->setText(getString("not_available"));
}
}
// virtual
void LLPanelPlaceInfo::reshape(S32 width, S32 height, BOOL called_from_parent)
{
// This if was added to force collapsing description textbox on Windows at the beginning of reshape
// (the only case when reshape is skipped here is when it's caused by this textbox, so called_from_parent is FALSE)
// This way it is consistent with Linux where topLost collapses textbox at the beginning of reshape.
// On windows it collapsed only after reshape which caused EXT-8342.
if(called_from_parent)
{
if(mDescEditor) mDescEditor->onTopLost();
}
LLPanel::reshape(width, height, called_from_parent);
if (!mScrollContainer || !mScrollingPanel)
return;
static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);
S32 scroll_height = mScrollContainer->getRect().getHeight();
if (mScrollingPanelMinHeight > scroll_height)
{
mScrollingPanel->reshape(mScrollingPanelWidth, mScrollingPanelMinHeight);
}
else
{
mScrollingPanel->reshape(mScrollingPanelWidth + scrollbar_size, scroll_height);
}
}
void LLPanelPlaceInfo::createPick(const LLVector3d& pos_global, LLPanelPickEdit* pick_panel)
{
std::string region_name = mRegionName->getText();
LLPickData data;
data.pos_global = pos_global;
data.name = mParcelTitle.empty() ? region_name : mParcelTitle;
data.sim_name = region_name;
data.desc = mDescEditor->getText();
data.snapshot_id = mSnapshotCtrl->getImageAssetID();
data.parcel_id = mParcelID;
pick_panel->setPickData(&data);
}
// static
void LLPanelPlaceInfo::nameUpdatedCallback(LLTextBox* text,
const std::string& first,
const std::string& last)
{
text->setText(first + " " + last);
}
|