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/llpanelcontents.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 '')
-rw-r--r-- | linden/indra/newview/llpanelcontents.cpp | 212 |
1 files changed, 212 insertions, 0 deletions
diff --git a/linden/indra/newview/llpanelcontents.cpp b/linden/indra/newview/llpanelcontents.cpp new file mode 100644 index 0000000..6fa34cf --- /dev/null +++ b/linden/indra/newview/llpanelcontents.cpp | |||
@@ -0,0 +1,212 @@ | |||
1 | /** | ||
2 | * @file llpanelcontents.cpp | ||
3 | * @brief Object contents panel in the tools floater. | ||
4 | * | ||
5 | * Copyright (c) 2001-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 | // file include | ||
31 | #include "llpanelcontents.h" | ||
32 | |||
33 | // linden library includes | ||
34 | #include "llerror.h" | ||
35 | #include "llrect.h" | ||
36 | #include "llstring.h" | ||
37 | #include "llmaterialtable.h" | ||
38 | #include "llfontgl.h" | ||
39 | #include "m3math.h" | ||
40 | #include "llpermissionsflags.h" | ||
41 | #include "lleconomy.h" | ||
42 | #include "material_codes.h" | ||
43 | |||
44 | // project includes | ||
45 | #include "llui.h" | ||
46 | #include "llspinctrl.h" | ||
47 | #include "llcheckboxctrl.h" | ||
48 | #include "lltextbox.h" | ||
49 | #include "llbutton.h" | ||
50 | #include "llcombobox.h" | ||
51 | |||
52 | #include "llagent.h" | ||
53 | #include "llviewerwindow.h" | ||
54 | #include "llworld.h" | ||
55 | #include "llviewerobject.h" | ||
56 | #include "llviewerregion.h" | ||
57 | #include "llresmgr.h" | ||
58 | #include "lltexturetable.h" | ||
59 | #include "llselectmgr.h" | ||
60 | #include "llpreviewscript.h" | ||
61 | #include "lltool.h" | ||
62 | #include "lltoolmgr.h" | ||
63 | #include "lltoolcomp.h" | ||
64 | #include "llpanelinventory.h" | ||
65 | #include "viewer.h" | ||
66 | |||
67 | // | ||
68 | // Imported globals | ||
69 | // | ||
70 | |||
71 | |||
72 | // | ||
73 | // Globals | ||
74 | // | ||
75 | |||
76 | BOOL LLPanelContents::postBuild() | ||
77 | { | ||
78 | LLRect rect = this->getRect(); | ||
79 | |||
80 | setMouseOpaque(FALSE); | ||
81 | |||
82 | childSetAction("button new script",&LLPanelContents::onClickNewScript, this); | ||
83 | |||
84 | return TRUE; | ||
85 | } | ||
86 | |||
87 | LLPanelContents::LLPanelContents(const std::string& name) | ||
88 | : LLPanel(name), | ||
89 | mPanelInventory(NULL) | ||
90 | { | ||
91 | } | ||
92 | |||
93 | |||
94 | LLPanelContents::~LLPanelContents() | ||
95 | { | ||
96 | // Children all cleaned up by default view destructor. | ||
97 | } | ||
98 | |||
99 | |||
100 | void LLPanelContents::getState(LLViewerObject *objectp ) | ||
101 | { | ||
102 | if( !objectp ) | ||
103 | { | ||
104 | childSetEnabled("button new script",FALSE); | ||
105 | //mBtnNewScript->setEnabled( FALSE ); | ||
106 | return; | ||
107 | } | ||
108 | |||
109 | // BUG? Check for all objects being editable? | ||
110 | BOOL editable = gAgent.isGodlike() | ||
111 | || (objectp->permModify() && objectp->permYouOwner()); | ||
112 | BOOL all_volume = gSelectMgr->selectionAllPCode( LL_PCODE_VOLUME ); | ||
113 | |||
114 | // Edit script button - ok if object is editable and there's an | ||
115 | // unambiguous destination for the object. | ||
116 | if( editable && | ||
117 | all_volume && | ||
118 | ((gSelectMgr->getRootObjectCount() == 1) | ||
119 | || (gSelectMgr->getObjectCount() == 1))) | ||
120 | { | ||
121 | //mBtnNewScript->setEnabled(TRUE); | ||
122 | childSetEnabled("button new script",TRUE); | ||
123 | } | ||
124 | else | ||
125 | { | ||
126 | //mBtnNewScript->setEnabled(FALSE); | ||
127 | childSetEnabled("button new script",FALSE); | ||
128 | } | ||
129 | } | ||
130 | |||
131 | |||
132 | void LLPanelContents::refresh() | ||
133 | { | ||
134 | LLViewerObject* object = gSelectMgr->getFirstRootObject(); | ||
135 | if(!object) | ||
136 | { | ||
137 | object = gSelectMgr->getFirstObject(); | ||
138 | } | ||
139 | |||
140 | getState(object); | ||
141 | if (mPanelInventory) | ||
142 | { | ||
143 | mPanelInventory->refresh(); | ||
144 | } | ||
145 | } | ||
146 | |||
147 | |||
148 | |||
149 | // | ||
150 | // Static functions | ||
151 | // | ||
152 | |||
153 | // static | ||
154 | void LLPanelContents::onClickNewScript(void *userdata) | ||
155 | { | ||
156 | LLViewerObject* object = gSelectMgr->getFirstRootObject(); | ||
157 | if(!object) | ||
158 | { | ||
159 | object = gSelectMgr->getFirstObject(); | ||
160 | } | ||
161 | if(object) | ||
162 | { | ||
163 | LLPermissions perm; | ||
164 | perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, LLUUID::null); | ||
165 | perm.initMasks( | ||
166 | PERM_ALL, | ||
167 | PERM_ALL, | ||
168 | PERM_NONE, | ||
169 | PERM_NONE, | ||
170 | PERM_MOVE | PERM_TRANSFER); | ||
171 | LLString desc; | ||
172 | LLAssetType::generateDescriptionFor(LLAssetType::AT_LSL_TEXT, desc); | ||
173 | LLPointer<LLViewerInventoryItem> new_item = | ||
174 | new LLViewerInventoryItem( | ||
175 | LLUUID::null, | ||
176 | LLUUID::null, | ||
177 | perm, | ||
178 | LLUUID::null, | ||
179 | LLAssetType::AT_LSL_TEXT, | ||
180 | LLInventoryType::IT_LSL, | ||
181 | LLString("New Script"), | ||
182 | desc, | ||
183 | LLSaleInfo::DEFAULT, | ||
184 | LLViewerInventoryItem::II_FLAGS_NONE, | ||
185 | time_corrected()); | ||
186 | object->saveScript(new_item, TRUE, true); | ||
187 | |||
188 | // *NOTE: In order to resolve SL-22177, we needed to create | ||
189 | // the script first, and then you have to click it in | ||
190 | // inventory to edit it. | ||
191 | // *TODO: The script creation should round-trip back to the | ||
192 | // viewer so the viewer can auto-open the script and start | ||
193 | // editing ASAP. | ||
194 | #if 0 | ||
195 | S32 left, top; | ||
196 | gFloaterView->getNewFloaterPosition(&left, &top); | ||
197 | LLRect rect = gSavedSettings.getRect("PreviewScriptRect"); | ||
198 | rect.translate( left - rect.mLeft, top - rect.mTop ); | ||
199 | |||
200 | LLLiveLSLEditor* editor; | ||
201 | editor = new LLLiveLSLEditor("script ed", | ||
202 | rect, | ||
203 | "Script: New Script", | ||
204 | object->mID, | ||
205 | LLUUID::null); | ||
206 | editor->open(); | ||
207 | |||
208 | // keep onscreen | ||
209 | gFloaterView->adjustToFitScreen(editor, FALSE); | ||
210 | #endif | ||
211 | } | ||
212 | } | ||