aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloaterbuildoptions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llfloaterbuildoptions.cpp')
-rw-r--r--linden/indra/newview/llfloaterbuildoptions.cpp292
1 files changed, 288 insertions, 4 deletions
diff --git a/linden/indra/newview/llfloaterbuildoptions.cpp b/linden/indra/newview/llfloaterbuildoptions.cpp
index 3cd35db..372b1df 100644
--- a/linden/indra/newview/llfloaterbuildoptions.cpp
+++ b/linden/indra/newview/llfloaterbuildoptions.cpp
@@ -4,7 +4,8 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2002&license=viewergpl$ 5 * $LicenseInfo:firstyear=2002&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2002-2009, Linden Research, Inc. 7 * Copyright (c) 2002-2009, Linden Research, Inc.,
8 * 2010, McCabe Maxsted
8 * 9 *
9 * Second Life Viewer Source Code 10 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 11 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -38,28 +39,38 @@
38#include "llviewerprecompiledheaders.h" 39#include "llviewerprecompiledheaders.h"
39 40
40#include "llfloaterbuildoptions.h" 41#include "llfloaterbuildoptions.h"
41#include "lluictrlfactory.h"
42 42
43// library includes 43// library includes
44#include "llfontgl.h" 44#include "llfontgl.h"
45#include "llcheckboxctrl.h" 45#include "llcheckboxctrl.h"
46#include "llcombobox.h"
46#include "llspinctrl.h" 47#include "llspinctrl.h"
47#include "llsliderctrl.h" 48#include "llsliderctrl.h"
49#include "lltexturectrl.h"
50#include "lluictrlfactory.h"
48 51
49// newview includes 52// newview includes
53#include "llcolorswatch.h"
54#include "llinventorymodel.h"
50#include "llresmgr.h" 55#include "llresmgr.h"
56#include "llstartup.h" // not really necessary here, but just in case
51#include "llviewercontrol.h" 57#include "llviewercontrol.h"
58#include "llviewerinventory.h"
59#include "floaterbusy.h" // class InvDropTarget
52 60
53// 61//
54// Globals 62// Globals
55// 63//
56LLFloaterBuildOptions *LLFloaterBuildOptions::sInstance = NULL; 64LLFloaterBuildOptions *LLFloaterBuildOptions::sInstance = NULL;
65InvDropTarget * LLFloaterBuildOptions::sBuildObjectDropTarget;
57 66
58// 67//
59// Methods 68// Methods
60// 69//
61LLFloaterBuildOptions::LLFloaterBuildOptions( ) 70LLFloaterBuildOptions::LLFloaterBuildOptions()
62: LLFloater(std::string("build options floater")) 71: LLFloater(std::string("build options floater")),
72mBuildItemUUID(NULL),
73mBuildTextureUUID(NULL)
63{ 74{
64 sInstance = this; 75 sInstance = this;
65} 76}
@@ -67,6 +78,74 @@ LLFloaterBuildOptions::LLFloaterBuildOptions( )
67LLFloaterBuildOptions::~LLFloaterBuildOptions() 78LLFloaterBuildOptions::~LLFloaterBuildOptions()
68{ 79{
69 sInstance = NULL; 80 sInstance = NULL;
81 delete sBuildObjectDropTarget;
82 sBuildObjectDropTarget = NULL;
83}
84
85BOOL LLFloaterBuildOptions::postBuild()
86{
87 childSetAction("btn_ok", onClickOK, this);
88 childSetAction("btn_apply", onClickApply, this);
89 childSetAction("btn_cancel", onClickCancel, this);
90 childSetAction("btn_clear", onClickClear, this);
91 childSetAction("btn_reset", onClickReset, this);
92
93 getChild<LLComboBox>("material")->setSimple(gSavedPerAccountSettings.getString("BuildPrefs_Material"));
94 getChild<LLComboBox>("combobox shininess")->setSimple(gSavedPerAccountSettings.getString("BuildPrefs_Shiny"));
95
96 childSetValue("BuildPrefsActualRoot_toggle", gSavedPerAccountSettings.getBOOL("BuildPrefs_ActualRoot") );
97 childSetValue("PivotPercToggle", gSavedPerAccountSettings.getBOOL("BuildPrefs_PivotIsPercent") );
98 childSetValue("FBToggle", gSavedPerAccountSettings.getBOOL("BuildPrefs_FullBright") );
99 childSetValue("BuildPrefsEmbedItem", gSavedPerAccountSettings.getBOOL("BuildPrefs_EmbedItem") );
100 childSetValue("PhysicalToggle", gSavedPerAccountSettings.getBOOL("BuildPrefs_Physical") );
101 childSetValue("TemporaryToggle", gSavedPerAccountSettings.getBOOL("BuildPrefs_Temporary") );
102 childSetValue("PhantomToggle", gSavedPerAccountSettings.getBOOL("BuildPrefs_Phantom") );
103
104 childSetValue("Z pos", gSavedPerAccountSettings.getF32("BuildPrefs_PivotZ") );
105 childSetValue("Y pos", gSavedPerAccountSettings.getF32("BuildPrefs_PivotY") );
106 childSetValue("X pos", gSavedPerAccountSettings.getF32("BuildPrefs_PivotX") );
107 childSetValue("glow", gSavedPerAccountSettings.getF32("BuildPrefs_Glow") );
108 childSetValue("alpha", gSavedPerAccountSettings.getF32("BuildPrefs_Alpha") );
109 childSetValue("Z size", gSavedPerAccountSettings.getF32("BuildPrefs_Zsize") );
110 childSetValue("Y size", gSavedPerAccountSettings.getF32("BuildPrefs_Ysize") );
111 childSetValue("X size", gSavedPerAccountSettings.getF32("BuildPrefs_Xsize") );
112
113 getChild<LLColorSwatchCtrl>("colorswatch")->set(gSavedPerAccountSettings.getColor4("BuildPrefs_Color"), TRUE );
114 getChild<LLTextureCtrl>("texture control")->setImageAssetID(LLUUID(gSavedPerAccountSettings.getString("BuildPrefs_Texture")));
115
116 childSetValue("BuildPrefsRenderHighlight_toggle", gSavedSettings.getBOOL("RenderHighlightSelections") );
117 childSetValue("grouplandrez", gSavedSettings.getBOOL("RezWithLandGroup") );
118 childSetValue("GridSubUnit", gSavedSettings.getBOOL("GridSubUnit") );
119 childSetValue("GridCrossSection", gSavedSettings.getBOOL("GridCrossSections") );
120
121 childSetValue("GridResolution", gSavedSettings.getF32("GridResolution") );
122 childSetValue("GridDrawSize", gSavedSettings.getF32("GridDrawSize") );
123 childSetValue("GridOpacity", gSavedSettings.getF32("GridOpacity") );
124
125 getChild<LLComboBox>("material")->setCommitCallback(onComboBoxCommit);
126 getChild<LLComboBox>("combobox shininess")->setCommitCallback(onComboBoxCommit);
127
128 getChild<LLTextureCtrl>("texture control")->setDefaultImageAssetID(LLUUID("89556747-24cb-43ed-920b-47caed15465f"));
129 getChild<LLTextureCtrl>("texture control")->setCommitCallback(onTexturePickerCommit);
130 getChild<LLTextureCtrl>("texture control")->setCallbackUserData(this);
131
132 LLView *target_view = getChild<LLView>("build_item_add_disp_rect");
133 if (target_view)
134 {
135 if (sBuildObjectDropTarget)
136 {
137 delete sBuildObjectDropTarget;
138 }
139 sBuildObjectDropTarget = new InvDropTarget("build drop target", target_view->getRect(),BuildAutoResponseItemDrop);
140 addChild(sBuildObjectDropTarget);
141 }
142
143 mBuildItemUUID = (LLUUID)gSavedPerAccountSettings.getString("BuildPrefs_Item");
144 mBuildTextureUUID = (LLUUID)gSavedPerAccountSettings.getString("BuildPrefs_Texture");
145
146 refreshItem(); // Refresh the item UI bits after everything's loaded -- MC
147
148 return TRUE;
70} 149}
71 150
72// static 151// static
@@ -95,3 +174,208 @@ BOOL LLFloaterBuildOptions::visible(void*)
95{ 174{
96 return (sInstance != NULL); 175 return (sInstance != NULL);
97} 176}
177
178// static
179void LLFloaterBuildOptions::BuildAutoResponseItemDrop(LLViewerInventoryItem* item)
180{
181 LLFloaterBuildOptions::getInstance()->setItem(item->getUUID());
182 LLFloaterBuildOptions::getInstance()->refreshItem();
183 /*LLFloaterBuildOptions::getInstance()->childSetValue("build_item_add_disp_rect_txt", "Currently set to: "+item->getName());
184 gSavedPerAccountSettings.setString("BuildPrefs_Item", item->getUUID().asString());*/
185}
186
187// static
188void LLFloaterBuildOptions::onComboBoxCommit(LLUICtrl* ctrl, void* userdata)
189{
190 LLComboBox* box = (LLComboBox*)ctrl;
191 if(box)
192 {
193 gSavedPerAccountSettings.setString(box->getControlName(), box->getValue().asString());
194 }
195}
196
197// static
198void LLFloaterBuildOptions::onTexturePickerCommit(LLUICtrl* ctrl, void* userdata)
199{
200 LLFloaterBuildOptions* self = (LLFloaterBuildOptions*)userdata;
201
202 LLTextureCtrl* image_ctrl = (LLTextureCtrl*)ctrl;
203 if(image_ctrl)
204 {
205 self->setTexture(image_ctrl->getImageAssetID());
206 /*gSavedPerAccountSettings.setString("BuildPrefs_Texture", image_ctrl->getImageAssetID().asString());*/
207 }
208}
209
210// static
211void LLFloaterBuildOptions::onClickOK(void* userdata)
212{
213 LLFloaterBuildOptions* self = (LLFloaterBuildOptions*)userdata;
214 self->apply();
215 self->close();
216}
217
218// static
219void LLFloaterBuildOptions::onClickApply(void* userdata)
220{
221 LLFloaterBuildOptions* self = (LLFloaterBuildOptions*)userdata;
222 self->apply();
223}
224
225// static
226void LLFloaterBuildOptions::onClickCancel(void* userdata)
227{
228 LLFloaterBuildOptions* self = (LLFloaterBuildOptions*)userdata;
229 self->cancel();
230}
231
232// static
233void LLFloaterBuildOptions::onClickClear(void* userdata)
234{
235 // Clear the inventory item
236 LLFloaterBuildOptions* self = (LLFloaterBuildOptions*)userdata;
237 //gSavedPerAccountSettings.setString("BuildPrefs_Item", LLUUID::null);
238 //gSavedPerAccountSettings.getControl("BuildPrefs_Item")->resetToDefault(false);
239
240 self->setItem(LLUUID::null);
241 self->refreshItem();
242}
243
244// static
245void LLFloaterBuildOptions::onClickReset(void* userdata)
246{
247 // Reset to defaults
248 LLFloaterBuildOptions* self = (LLFloaterBuildOptions*)userdata;
249 self->reset();
250 self->refresh();
251}
252
253void LLFloaterBuildOptions::apply()
254{
255 gSavedPerAccountSettings.setBOOL("BuildPrefs_ActualRoot", childGetValue("BuildPrefsActualRoot_toggle").asBoolean() );
256 gSavedPerAccountSettings.setBOOL("BuildPrefs_PivotIsPercent", childGetValue("PivotPercToggle").asBoolean() );
257 gSavedPerAccountSettings.setBOOL("BuildPrefs_FullBright", childGetValue("FBToggle").asBoolean() );
258 gSavedPerAccountSettings.setBOOL("BuildPrefs_EmbedItem", childGetValue("BuildPrefsEmbedItem").asBoolean() );
259 gSavedPerAccountSettings.setBOOL("BuildPrefs_Physical", childGetValue("PhysicalToggle").asBoolean() );
260 gSavedPerAccountSettings.setBOOL("BuildPrefs_Temporary", childGetValue("TemporaryToggle").asBoolean() );
261 gSavedPerAccountSettings.setBOOL("BuildPrefs_Phantom", childGetValue("PhantomToggle").asBoolean() );
262
263 gSavedPerAccountSettings.setF32("BuildPrefs_PivotZ", childGetValue("Z pos").asReal() );
264 gSavedPerAccountSettings.setF32("BuildPrefs_PivotY", childGetValue("Y pos").asReal() );
265 gSavedPerAccountSettings.setF32("BuildPrefs_PivotX", childGetValue("X pos").asReal() );
266 gSavedPerAccountSettings.setF32("BuildPrefs_Glow", childGetValue("glow").asReal() );
267 gSavedPerAccountSettings.setF32("BuildPrefs_Alpha", childGetValue("alpha").asReal() );
268 gSavedPerAccountSettings.setF32("BuildPrefs_Zsize", childGetValue("Z size").asReal() );
269 gSavedPerAccountSettings.setF32("BuildPrefs_Ysize", childGetValue("Y size").asReal() );
270 gSavedPerAccountSettings.setF32("BuildPrefs_Xsize", childGetValue("X size").asReal() );
271
272 gSavedPerAccountSettings.setString("BuildPrefs_Shiny", getChild<LLComboBox>("combobox shininess")->getValue().asString() );
273 gSavedPerAccountSettings.setString("BuildPrefs_Material", getChild<LLComboBox>("material")->getValue().asString() );
274
275 gSavedPerAccountSettings.setColor4("BuildPrefs_Color", getChild<LLColorSwatchCtrl>("colorswatch")->get());
276
277 if (mBuildItemUUID != LLSD(gSavedPerAccountSettings.getString("BuildPrefs_Item")) )
278 {
279 gSavedPerAccountSettings.setString("BuildPrefs_Item", mBuildItemUUID.asString() );
280 }
281
282 if (mBuildTextureUUID != LLSD(gSavedPerAccountSettings.getString("BuildPrefs_Texture")) )
283 {
284 gSavedPerAccountSettings.setString("BuildPrefs_Texture", mBuildTextureUUID.asString() );
285 }
286
287 gSavedSettings.setBOOL("RenderHighlightSelections", childGetValue("BuildPrefsRenderHighlight_toggle").asBoolean() );
288 gSavedSettings.setBOOL("RezWithLandGroup", childGetValue("grouplandrez").asBoolean() );
289 gSavedSettings.setBOOL("GridSubUnit", childGetValue("GridSubUnit").asBoolean() );
290 gSavedSettings.setBOOL("GridCrossSections", childGetValue("GridCrossSection").asBoolean() );
291
292 gSavedSettings.setF32("GridResolution", childGetValue("GridResolution").asReal() );
293 gSavedSettings.setF32("GridDrawSize", childGetValue("GridDrawSize").asReal() );
294 gSavedSettings.setF32("GridOpacity", childGetValue("GridOpacity").asReal() );
295}
296
297void LLFloaterBuildOptions::cancel()
298{
299 close();
300}
301
302void LLFloaterBuildOptions::reset()
303{
304 getChild<LLComboBox>("material")->setSimple(gSavedPerAccountSettings.getControl("BuildPrefs_Material")->getDefault().asString() );
305 getChild<LLComboBox>("combobox shininess")->setSimple(gSavedPerAccountSettings.getControl("BuildPrefs_Shiny")->getDefault().asString() );
306
307 childSetValue("BuildPrefsActualRoot_toggle", gSavedPerAccountSettings.getControl("BuildPrefs_ActualRoot")->getDefault() );
308 childSetValue("PivotPercToggle", gSavedPerAccountSettings.getControl("BuildPrefs_PivotIsPercent")->getDefault() );
309 childSetValue("FBToggle", gSavedPerAccountSettings.getControl("BuildPrefs_FullBright")->getDefault() );
310 childSetValue("BuildPrefsEmbedItem", gSavedPerAccountSettings.getControl("BuildPrefs_EmbedItem")->getDefault() );
311 childSetValue("PhysicalToggle", gSavedPerAccountSettings.getControl("BuildPrefs_Physical")->getDefault() );
312 childSetValue("TemporaryToggle", gSavedPerAccountSettings.getControl("BuildPrefs_Temporary")->getDefault() );
313 childSetValue("PhantomToggle", gSavedPerAccountSettings.getControl("BuildPrefs_Phantom")->getDefault() );
314
315 childSetValue("Z pos", gSavedPerAccountSettings.getControl("BuildPrefs_PivotZ")->getDefault() );
316 childSetValue("Y pos", gSavedPerAccountSettings.getControl("BuildPrefs_PivotY")->getDefault() );
317 childSetValue("X pos", gSavedPerAccountSettings.getControl("BuildPrefs_PivotX")->getDefault() );
318 childSetValue("glow", gSavedPerAccountSettings.getControl("BuildPrefs_Glow")->getDefault() );
319 childSetValue("alpha", gSavedPerAccountSettings.getControl("BuildPrefs_Alpha")->getDefault() );
320 childSetValue("Z size", gSavedPerAccountSettings.getControl("BuildPrefs_Zsize")->getDefault() );
321 childSetValue("Y size", gSavedPerAccountSettings.getControl("BuildPrefs_Ysize")->getDefault() );
322 childSetValue("X size", gSavedPerAccountSettings.getControl("BuildPrefs_Xsize")->getDefault() );
323
324 getChild<LLColorSwatchCtrl>("colorswatch")->set(gSavedPerAccountSettings.getControl("BuildPrefs_Color")->getDefault(), TRUE);
325 getChild<LLTextureCtrl>("texture control")->setImageAssetID(LLUUID(gSavedPerAccountSettings.getControl("BuildPrefs_Texture")->getDefault()) );
326
327 mBuildItemUUID = (LLUUID)gSavedPerAccountSettings.getControl("BuildPrefs_Item")->getDefault();
328 mBuildTextureUUID = (LLUUID)gSavedPerAccountSettings.getControl("BuildPrefs_Texture")->getDefault();
329
330 childSetValue("BuildPrefsRenderHighlight_toggle", gSavedSettings.getControl("RenderHighlightSelections")->getDefault() );
331 childSetValue("grouplandrez", gSavedSettings.getControl("RezWithLandGroup")->getDefault() );
332 childSetValue("GridSubUnit", gSavedSettings.getControl("GridSubUnit")->getDefault() );
333 childSetValue("GridCrossSection", gSavedSettings.getControl("GridCrossSections")->getDefault() );
334
335 childSetValue("GridResolution", gSavedSettings.getControl("GridResolution")->getDefault() );
336 childSetValue("GridDrawSize", gSavedSettings.getControl("GridDrawSize")->getDefault() );
337 childSetValue("GridOpacity", gSavedSettings.getControl("GridOpacity")->getDefault() );
338}
339
340void LLFloaterBuildOptions::refresh()
341{
342
343}
344
345void LLFloaterBuildOptions::setItem(const LLUUID& item)
346{
347 mBuildItemUUID = item;
348}
349
350void LLFloaterBuildOptions::setTexture(const LLUUID& texture)
351{
352 mBuildTextureUUID = texture;
353}
354
355void LLFloaterBuildOptions::refreshItem()
356{
357 if (LLStartUp::getStartupState() == STATE_STARTED)
358 {
359 if (mBuildItemUUID.isNull())
360 {
361 childSetValue("build_item_add_disp_rect_txt", "Currently not set");
362 }
363 else
364 {
365 LLViewerInventoryItem* item = gInventory.getItem(mBuildItemUUID);
366 if (item)
367 {
368 childSetValue("build_item_add_disp_rect_txt", "Currently set to: "+item->getName());
369 }
370
371 else
372 {
373 childSetValue("build_item_add_disp_rect_txt", "Currently set to a item not on this account");
374 }
375 }
376 }
377 else
378 {
379 childSetValue("build_item_add_disp_rect_txt", "Not logged in");
380 }
381}