summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterregioninfo.h
blob: abf4789b6d808d614f03215fb5e93dd282de092b (plain)
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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
/** 
 * @file llfloaterregioninfo.h
 * @author Aaron Brashears
 * @brief Declaration of the region info and controls floater and panels.
 *
 * $LicenseInfo:firstyear=2004&license=viewergpl$
 * 
 * Copyright (c) 2004-2007, Linden Research, Inc.
 * 
 * Second Life Viewer Source Code
 * The source code in this file ("Source Code") is provided by Linden Lab
 * to you under the terms of the GNU General Public License, version 2.0
 * ("GPL"), unless you have obtained a separate licensing agreement
 * ("Other License"), formally executed by you and Linden Lab.  Terms of
 * the GPL can be found in doc/GPL-license.txt in this distribution, or
 * online at http://secondlife.com/developers/opensource/gplv2
 * 
 * There are special exceptions to the terms and conditions of the GPL as
 * it is applied to this Source Code. View the full text of the exception
 * in the file doc/FLOSS-exception.txt in this software distribution, or
 * online at http://secondlife.com/developers/opensource/flossexception
 * 
 * By copying, modifying or distributing this software, you acknowledge
 * that you have read and understood your obligations described above,
 * and agree to abide by those obligations.
 * 
 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
 * COMPLETENESS OR PERFORMANCE.
 * $/LicenseInfo$
 */

#ifndef LL_LLFLOATERREGIONINFO_H
#define LL_LLFLOATERREGIONINFO_H

#include <vector>
#include "llfloater.h"
#include "llpanel.h"

class LLLineEditor;
class LLMessageSystem;
class LLPanelRegionInfo;
class LLTabContainer;
class LLViewerRegion;
class LLViewerTextEditor;
class LLInventoryItem;
class LLCheckBoxCtrl;
class LLComboBox;
class LLNameListCtrl;
class LLSliderCtrl;
class LLSpinCtrl;
class LLTextBox;

class LLPanelRegionGeneralInfo;
class LLPanelRegionDebugInfo;
class LLPanelRegionTextureInfo;
class LLPanelRegionTerrainInfo;
class LLPanelEstateInfo;
class LLPanelEstateCovenant;

class LLFloaterRegionInfo : public LLFloater
{
public:
	~LLFloaterRegionInfo();

	static void show(LLViewerRegion* region);
	static void show(void*);
	static LLFloaterRegionInfo* getInstance();
	static void processEstateOwnerRequest(LLMessageSystem* msg, void**);

	// get and process region info if necessary.
	static void processRegionInfo(LLMessageSystem* msg);

	static const LLUUID& getLastInvoice() { return sRequestInvoice; }
	static void nextInvoice() { sRequestInvoice.generate(); }
	//static S32 getSerial() { return sRequestSerial; }
	//static void incrementSerial() { sRequestSerial++; }

	static LLPanelEstateInfo* getPanelEstate();
	static LLPanelEstateCovenant* getPanelCovenant();

	// from LLPanel
	virtual void refresh();
	
protected:
	LLFloaterRegionInfo(const LLRect& rect);
	void refreshFromRegion(LLViewerRegion* region);

	// static data
	static LLFloaterRegionInfo* sInstance;

	// member data
	LLTabContainer* mTab;
	typedef std::vector<LLPanelRegionInfo*> info_panels_t;
	info_panels_t mInfoPanels;
	//static S32 sRequestSerial;	// serial # of last EstateOwnerRequest
	static LLUUID sRequestInvoice;
};


// Base class for all region information panels.
class LLPanelRegionInfo : public LLPanel
{
public:
	LLPanelRegionInfo() : LLPanel("Region Info Panel") {}
	static void onBtnSet(void* user_data);
	static void onChangeChildCtrl(LLUICtrl* ctrl, void* user_data);
	static void onChangeAnything(LLUICtrl* ctrl, void* user_data);
	
	virtual bool refreshFromRegion(LLViewerRegion* region);
	virtual bool estateUpdate(LLMessageSystem* msg) { return true; }
	
	virtual BOOL postBuild();
	virtual void updateChild(LLUICtrl* child_ctrl);
	
	void enableButton(const char* btn_name, BOOL enable = TRUE);
	void disableButton(const char* btn_name);
	
protected:
	void initCtrl(const char* name);
	void initHelpBtn(const char* name, const char* xml_alert);

	// Callback for all help buttons, data is name of XML alert to show.
	static void onClickHelp(void* data);
	
	// Returns TRUE if update sent and apply button should be
	// disabled.
	virtual BOOL sendUpdate() { return TRUE; }
	
	typedef std::vector<std::string> strings_t;
	//typedef std::vector<U32> integers_t;
	void sendEstateOwnerMessage(
					 LLMessageSystem* msg,
					 const char* request,
					 const LLUUID& invoice,
					 const strings_t& strings);
	
	// member data
	LLHost mHost;
};

/////////////////////////////////////////////////////////////////////////////
// Actual panels start here
/////////////////////////////////////////////////////////////////////////////

class LLPanelRegionGeneralInfo : public LLPanelRegionInfo
{
public:
	LLPanelRegionGeneralInfo()
		:	LLPanelRegionInfo()	{}
	~LLPanelRegionGeneralInfo() {}
	
	virtual bool refreshFromRegion(LLViewerRegion* region);
	
	// LLPanel
	virtual BOOL postBuild();
protected:
	virtual BOOL sendUpdate();
	
	static void onClickKick(void* userdata);
	static void onKickCommit(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* userdata);
	static void onClickKickAll(void* userdata);
	static void onKickAllCommit(S32 option, void* userdata);
	static void onClickMessage(void* userdata);
	static void onMessageCommit(S32 option, const LLString& text, void* userdata);
	static void onClickManageTelehub(void* data);
};

/////////////////////////////////////////////////////////////////////////////

class LLPanelRegionDebugInfo : public LLPanelRegionInfo
{
public:
	LLPanelRegionDebugInfo()
		:	LLPanelRegionInfo(), mTargetAvatar() {}
	~LLPanelRegionDebugInfo() {}
	// LLPanel
	virtual BOOL postBuild();
	
	virtual bool refreshFromRegion(LLViewerRegion* region);
	
protected:
	virtual BOOL sendUpdate();

	static void onClickChooseAvatar(void*);
	static void callbackAvatarID(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data);
	static void onClickReturnScriptedOtherLand(void*);
	static void callbackReturnScriptedOtherLand(S32 option, void*);
	static void onClickReturnScriptedAll(void*);
	static void callbackReturnScriptedAll(S32 option, void*);
	static void onClickTopColliders(void*);
	static void onClickTopScripts(void*);
	static void onClickRestart(void* data);
	static void callbackRestart(S32 option, void* data);
	static void onClickCancelRestart(void* data);
	
private:
	LLUUID mTargetAvatar;
};

/////////////////////////////////////////////////////////////////////////////

class LLPanelRegionTextureInfo : public LLPanelRegionInfo
{
public:
	LLPanelRegionTextureInfo();
	~LLPanelRegionTextureInfo() {}
	
	virtual bool refreshFromRegion(LLViewerRegion* region);
	
	// LLPanel && LLView
	virtual BOOL postBuild();
	virtual void draw();
	
protected:
	virtual BOOL sendUpdate();
	
	static void onClickDump(void* data);
	BOOL validateTextureSizes();
};

/////////////////////////////////////////////////////////////////////////////

class LLPanelRegionTerrainInfo : public LLPanelRegionInfo
{
public:
	LLPanelRegionTerrainInfo()
		:	LLPanelRegionInfo() {}
	~LLPanelRegionTerrainInfo() {}
	// LLPanel
	virtual BOOL postBuild();
	
	virtual bool refreshFromRegion(LLViewerRegion* region);
	
protected:
	virtual BOOL sendUpdate();

	static void onChangeUseEstateTime(LLUICtrl* ctrl, void* user_data);
	static void onChangeFixedSun(LLUICtrl* ctrl, void* user_data);
	static void onChangeSunHour(LLUICtrl* ctrl, void*);

	static void onClickDownloadRaw(void*);
	static void onClickUploadRaw(void*);
	static void onClickBakeTerrain(void*);
	static void callbackBakeTerrain(S32 option, void* data);
};

/////////////////////////////////////////////////////////////////////////////

class LLPanelEstateInfo : public LLPanelRegionInfo
{
public:
	static void initDispatch(LLDispatcher& dispatch);
	
	static void onChangeFixedSun(LLUICtrl* ctrl, void* user_data);
	static void onChangeUseGlobalTime(LLUICtrl* ctrl, void* user_data);
	
	static void onClickAddAllowedAgent(void* user_data);
	static void onClickRemoveAllowedAgent(void* user_data);
	static void onClickAddAllowedGroup(void* user_data);
	static void onClickRemoveAllowedGroup(void* user_data);
	static void onClickAddBannedAgent(void* user_data);
	static void onClickRemoveBannedAgent(void* user_data);
	static void onClickAddEstateManager(void* user_data);
	static void onClickRemoveEstateManager(void* user_data);
	static void onClickKickUser(void* userdata);

	// Group picker callback is different, can't use core methods below
	static void addAllowedGroup(S32 option, void* data);
	static void addAllowedGroup2(LLUUID id, void* data);

	// Core methods for all above add/remove button clicks
	static void accessAddCore(U32 operation_flag, const char* dialog_name);
	static void accessAddCore2(S32 option, void* data);
	static void accessAddCore3(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data);

	static void accessRemoveCore(U32 operation_flag, const char* dialog_name, const char* list_ctrl_name);
	static void accessRemoveCore2(S32 option, void* data);

	// used for both add and remove operations
	static void accessCoreConfirm(S32 option, void* data);
	static void kickUserConfirm(S32 option, void* userdata);

	// Send the actual EstateOwnerRequest "estateaccessdelta" message
	static void sendEstateAccessDelta(U32 flags, const LLUUID& agent_id);

	static void onKickUserCommit(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* userdata);
	static void onClickMessageEstate(void* data);
	static void onMessageCommit(S32 option, const LLString& text, void* data);
	
	LLPanelEstateInfo();
	~LLPanelEstateInfo() {}
	
	virtual bool refreshFromRegion(LLViewerRegion* region);
	virtual bool estateUpdate(LLMessageSystem* msg);
	
	// LLPanel
	virtual BOOL postBuild();
	virtual void updateChild(LLUICtrl* child_ctrl);
	virtual void refresh();
	
	U32 computeEstateFlags();
	void setEstateFlags(U32 flags);
	
	BOOL getGlobalTime();
	void setGlobalTime(bool b);

	BOOL getFixedSun();

	F32 getSunHour();
	void setSunHour(F32 sun_hour);
	
	const std::string getEstateName() const;
	void setEstateName(const std::string& name);

	U32 getEstateID() const { return mEstateID; }
	void setEstateID(U32 estate_id) { mEstateID = estate_id; }
	static bool isLindenEstate();
	
	const std::string getOwnerName() const;
	void setOwnerName(const std::string& name);

	// If visible from mainland, allowed agent and allowed groups
	// are ignored, so must disable UI.
	void setAccessAllowedEnabled(bool enable_agent, bool enable_group, bool enable_ban);

	// this must have the same function signature as
	// llmessage/llcachename.h:LLCacheNameCallback
	static void callbackCacheName(
		const LLUUID& id,
		const char* first,
		const char* last,
		BOOL is_group,
		void*);

protected:
	virtual BOOL sendUpdate();
	// confirmation dialog callback
	static void callbackChangeLindenEstate(S32 opt, void* data);

	void commitEstateInfo();
	void commitEstateAccess();
	void commitEstateManagers();
	
	void clearAccessLists();
	BOOL checkRemovalButton(std::string name);
	BOOL checkSunHourSlider(LLUICtrl* child_ctrl);

	U32 mEstateID;
};

/////////////////////////////////////////////////////////////////////////////

class LLPanelEstateCovenant : public LLPanelRegionInfo
{
public:
	LLPanelEstateCovenant();
	~LLPanelEstateCovenant() {}
	
	// LLPanel
	virtual BOOL postBuild();
	virtual void updateChild(LLUICtrl* child_ctrl);
	virtual bool refreshFromRegion(LLViewerRegion* region);
	virtual bool estateUpdate(LLMessageSystem* msg);

	// LLView overrides
	BOOL handleDragAndDrop(S32 x, S32 y, MASK mask,
						   BOOL drop, EDragAndDropType cargo_type,
						   void *cargo_data, EAcceptance *accept,
						   LLString& tooltip_msg);
	static void confirmChangeCovenantCallback(S32 option, void* userdata);
	static void resetCovenantID(void* userdata);
	static void confirmResetCovenantCallback(S32 option, void* userdata);
	void sendChangeCovenantID(const LLUUID &asset_id);
	void loadInvItem(LLInventoryItem *itemp);
	static void onLoadComplete(LLVFS *vfs,
							   const LLUUID& asset_uuid,
							   LLAssetType::EType type,
							   void* user_data, S32 status, LLExtStat ext_status);

	// Accessor functions
	static void updateCovenantText(const std::string& string, const LLUUID& asset_id);
	static void updateEstateName(const std::string& name);
	static void updateLastModified(const std::string& text);
	static void updateEstateOwnerName(const std::string& name);

	const LLUUID& getCovenantID() const { return mCovenantID; }
	void setCovenantID(const LLUUID& id) { mCovenantID = id; }
	const std::string& getEstateName() const;
	void setEstateName(const std::string& name);
	const std::string& getOwnerName() const;
	void setOwnerName(const std::string& name);
	void setCovenantTextEditor(const std::string& text);

	typedef enum e_asset_status
	{
		ASSET_ERROR,
		ASSET_UNLOADED,
		ASSET_LOADING,
		ASSET_LOADED
	} EAssetStatus;

protected:
	virtual BOOL sendUpdate();
	LLTextBox*				mEstateNameText;
	LLTextBox*				mEstateOwnerText;
	LLTextBox*				mLastModifiedText;
	// CovenantID from sim
	LLUUID					mCovenantID;
	LLViewerTextEditor*		mEditor;
	EAssetStatus			mAssetStatus;
};

#endif