From a6e45f15b8634db39facc852501c53ab36e2ed3f Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Tue, 13 Apr 2010 23:15:19 -0700 Subject: Changed advanced build options to per-account settings, added OK, Apply, Cancel, Clear Item, and Reset to Default buttons --- .../newview/app_settings/settings_per_account.xml | 1 - linden/indra/newview/llfloaterbuildoptions.cpp | 279 ++++++++++++++++++--- linden/indra/newview/llfloaterbuildoptions.h | 23 +- .../default/xui/en-us/floater_build_options.xml | 78 +++--- 4 files changed, 308 insertions(+), 73 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/app_settings/settings_per_account.xml b/linden/indra/newview/app_settings/settings_per_account.xml index 83852d3..7465af2 100644 --- a/linden/indra/newview/app_settings/settings_per_account.xml +++ b/linden/indra/newview/app_settings/settings_per_account.xml @@ -231,7 +231,6 @@ - BuildPrefs_Xsize Comment diff --git a/linden/indra/newview/llfloaterbuildoptions.cpp b/linden/indra/newview/llfloaterbuildoptions.cpp index 6c59a4e..372b1df 100644 --- a/linden/indra/newview/llfloaterbuildoptions.cpp +++ b/linden/indra/newview/llfloaterbuildoptions.cpp @@ -4,7 +4,8 @@ * * $LicenseInfo:firstyear=2002&license=viewergpl$ * - * Copyright (c) 2002-2009, Linden Research, Inc. + * Copyright (c) 2002-2009, Linden Research, Inc., + * 2010, McCabe Maxsted * * Second Life Viewer Source Code * The source code in this file ("Source Code") is provided by Linden Lab @@ -38,7 +39,6 @@ #include "llviewerprecompiledheaders.h" #include "llfloaterbuildoptions.h" -#include "lluictrlfactory.h" // library includes #include "llfontgl.h" @@ -47,8 +47,10 @@ #include "llspinctrl.h" #include "llsliderctrl.h" #include "lltexturectrl.h" +#include "lluictrlfactory.h" // newview includes +#include "llcolorswatch.h" #include "llinventorymodel.h" #include "llresmgr.h" #include "llstartup.h" // not really necessary here, but just in case @@ -60,13 +62,15 @@ // Globals // LLFloaterBuildOptions *LLFloaterBuildOptions::sInstance = NULL; -InvDropTarget * LLFloaterBuildOptions::mBuildObjectDropTarget; +InvDropTarget * LLFloaterBuildOptions::sBuildObjectDropTarget; // // Methods // -LLFloaterBuildOptions::LLFloaterBuildOptions( ) -: LLFloater(std::string("build options floater")) +LLFloaterBuildOptions::LLFloaterBuildOptions() +: LLFloater(std::string("build options floater")), +mBuildItemUUID(NULL), +mBuildTextureUUID(NULL) { sInstance = this; } @@ -74,53 +78,72 @@ LLFloaterBuildOptions::LLFloaterBuildOptions( ) LLFloaterBuildOptions::~LLFloaterBuildOptions() { sInstance = NULL; - delete mBuildObjectDropTarget; - mBuildObjectDropTarget = NULL; + delete sBuildObjectDropTarget; + sBuildObjectDropTarget = NULL; } BOOL LLFloaterBuildOptions::postBuild() { + childSetAction("btn_ok", onClickOK, this); + childSetAction("btn_apply", onClickApply, this); + childSetAction("btn_cancel", onClickCancel, this); + childSetAction("btn_clear", onClickClear, this); + childSetAction("btn_reset", onClickReset, this); + getChild("material")->setSimple(gSavedPerAccountSettings.getString("BuildPrefs_Material")); getChild("combobox shininess")->setSimple(gSavedPerAccountSettings.getString("BuildPrefs_Shiny")); + childSetValue("BuildPrefsActualRoot_toggle", gSavedPerAccountSettings.getBOOL("BuildPrefs_ActualRoot") ); + childSetValue("PivotPercToggle", gSavedPerAccountSettings.getBOOL("BuildPrefs_PivotIsPercent") ); + childSetValue("FBToggle", gSavedPerAccountSettings.getBOOL("BuildPrefs_FullBright") ); + childSetValue("BuildPrefsEmbedItem", gSavedPerAccountSettings.getBOOL("BuildPrefs_EmbedItem") ); + childSetValue("PhysicalToggle", gSavedPerAccountSettings.getBOOL("BuildPrefs_Physical") ); + childSetValue("TemporaryToggle", gSavedPerAccountSettings.getBOOL("BuildPrefs_Temporary") ); + childSetValue("PhantomToggle", gSavedPerAccountSettings.getBOOL("BuildPrefs_Phantom") ); + + childSetValue("Z pos", gSavedPerAccountSettings.getF32("BuildPrefs_PivotZ") ); + childSetValue("Y pos", gSavedPerAccountSettings.getF32("BuildPrefs_PivotY") ); + childSetValue("X pos", gSavedPerAccountSettings.getF32("BuildPrefs_PivotX") ); + childSetValue("glow", gSavedPerAccountSettings.getF32("BuildPrefs_Glow") ); + childSetValue("alpha", gSavedPerAccountSettings.getF32("BuildPrefs_Alpha") ); + childSetValue("Z size", gSavedPerAccountSettings.getF32("BuildPrefs_Zsize") ); + childSetValue("Y size", gSavedPerAccountSettings.getF32("BuildPrefs_Ysize") ); + childSetValue("X size", gSavedPerAccountSettings.getF32("BuildPrefs_Xsize") ); + + getChild("colorswatch")->set(gSavedPerAccountSettings.getColor4("BuildPrefs_Color"), TRUE ); + getChild("texture control")->setImageAssetID(LLUUID(gSavedPerAccountSettings.getString("BuildPrefs_Texture"))); + + childSetValue("BuildPrefsRenderHighlight_toggle", gSavedSettings.getBOOL("RenderHighlightSelections") ); + childSetValue("grouplandrez", gSavedSettings.getBOOL("RezWithLandGroup") ); + childSetValue("GridSubUnit", gSavedSettings.getBOOL("GridSubUnit") ); + childSetValue("GridCrossSection", gSavedSettings.getBOOL("GridCrossSections") ); + + childSetValue("GridResolution", gSavedSettings.getF32("GridResolution") ); + childSetValue("GridDrawSize", gSavedSettings.getF32("GridDrawSize") ); + childSetValue("GridOpacity", gSavedSettings.getF32("GridOpacity") ); + getChild("material")->setCommitCallback(onComboBoxCommit); getChild("combobox shininess")->setCommitCallback(onComboBoxCommit); getChild("texture control")->setDefaultImageAssetID(LLUUID("89556747-24cb-43ed-920b-47caed15465f")); getChild("texture control")->setCommitCallback(onTexturePickerCommit); + getChild("texture control")->setCallbackUserData(this); LLView *target_view = getChild("build_item_add_disp_rect"); if (target_view) { - if (mBuildObjectDropTarget) + if (sBuildObjectDropTarget) { - delete mBuildObjectDropTarget; + delete sBuildObjectDropTarget; } - mBuildObjectDropTarget = new InvDropTarget("build drop target", target_view->getRect(),BuildAutoResponseItemDrop); - addChild(mBuildObjectDropTarget); + sBuildObjectDropTarget = new InvDropTarget("build drop target", target_view->getRect(),BuildAutoResponseItemDrop); + addChild(sBuildObjectDropTarget); } - if (LLStartUp::getStartupState() == STATE_STARTED) - { - LLUUID itemid = (LLUUID)gSavedPerAccountSettings.getString("BuildPrefs_Item"); - LLViewerInventoryItem* item = gInventory.getItem(itemid); - if (item) - { - childSetValue("build_item_add_disp_rect_txt", "Currently set to: "+item->getName()); - } - else if (itemid.isNull()) - { - childSetValue("build_item_add_disp_rect_txt", "Currently not set"); - } - else - { - childSetValue("build_item_add_disp_rect_txt", "Currently set to a item not on this account"); - } - } - else - { - childSetValue("build_item_add_disp_rect_txt", "Not logged in"); - } + mBuildItemUUID = (LLUUID)gSavedPerAccountSettings.getString("BuildPrefs_Item"); + mBuildTextureUUID = (LLUUID)gSavedPerAccountSettings.getString("BuildPrefs_Texture"); + + refreshItem(); // Refresh the item UI bits after everything's loaded -- MC return TRUE; } @@ -152,27 +175,207 @@ BOOL LLFloaterBuildOptions::visible(void*) return (sInstance != NULL); } +// static void LLFloaterBuildOptions::BuildAutoResponseItemDrop(LLViewerInventoryItem* item) { - gSavedPerAccountSettings.setString("BuildPrefs_Item", item->getUUID().asString()); - LLFloaterBuildOptions::getInstance()->childSetValue("build_item_add_disp_rect_txt", "Currently set to: "+item->getName()); + LLFloaterBuildOptions::getInstance()->setItem(item->getUUID()); + LLFloaterBuildOptions::getInstance()->refreshItem(); + /*LLFloaterBuildOptions::getInstance()->childSetValue("build_item_add_disp_rect_txt", "Currently set to: "+item->getName()); + gSavedPerAccountSettings.setString("BuildPrefs_Item", item->getUUID().asString());*/ } +// static void LLFloaterBuildOptions::onComboBoxCommit(LLUICtrl* ctrl, void* userdata) { - LLComboBox* box = (LLComboBox*)ctrl; if(box) { - gSavedSettings.setString(box->getControlName(), box->getValue().asString()); - } + gSavedPerAccountSettings.setString(box->getControlName(), box->getValue().asString()); + } } +// static void LLFloaterBuildOptions::onTexturePickerCommit(LLUICtrl* ctrl, void* userdata) { + LLFloaterBuildOptions* self = (LLFloaterBuildOptions*)userdata; + LLTextureCtrl* image_ctrl = (LLTextureCtrl*)ctrl; if(image_ctrl) { - gSavedPerAccountSettings.setString("BuildPrefs_Texture", image_ctrl->getImageAssetID().asString()); + self->setTexture(image_ctrl->getImageAssetID()); + /*gSavedPerAccountSettings.setString("BuildPrefs_Texture", image_ctrl->getImageAssetID().asString());*/ + } +} + +// static +void LLFloaterBuildOptions::onClickOK(void* userdata) +{ + LLFloaterBuildOptions* self = (LLFloaterBuildOptions*)userdata; + self->apply(); + self->close(); +} + +// static +void LLFloaterBuildOptions::onClickApply(void* userdata) +{ + LLFloaterBuildOptions* self = (LLFloaterBuildOptions*)userdata; + self->apply(); +} + +// static +void LLFloaterBuildOptions::onClickCancel(void* userdata) +{ + LLFloaterBuildOptions* self = (LLFloaterBuildOptions*)userdata; + self->cancel(); +} + +// static +void LLFloaterBuildOptions::onClickClear(void* userdata) +{ + // Clear the inventory item + LLFloaterBuildOptions* self = (LLFloaterBuildOptions*)userdata; + //gSavedPerAccountSettings.setString("BuildPrefs_Item", LLUUID::null); + //gSavedPerAccountSettings.getControl("BuildPrefs_Item")->resetToDefault(false); + + self->setItem(LLUUID::null); + self->refreshItem(); +} + +// static +void LLFloaterBuildOptions::onClickReset(void* userdata) +{ + // Reset to defaults + LLFloaterBuildOptions* self = (LLFloaterBuildOptions*)userdata; + self->reset(); + self->refresh(); +} + +void LLFloaterBuildOptions::apply() +{ + gSavedPerAccountSettings.setBOOL("BuildPrefs_ActualRoot", childGetValue("BuildPrefsActualRoot_toggle").asBoolean() ); + gSavedPerAccountSettings.setBOOL("BuildPrefs_PivotIsPercent", childGetValue("PivotPercToggle").asBoolean() ); + gSavedPerAccountSettings.setBOOL("BuildPrefs_FullBright", childGetValue("FBToggle").asBoolean() ); + gSavedPerAccountSettings.setBOOL("BuildPrefs_EmbedItem", childGetValue("BuildPrefsEmbedItem").asBoolean() ); + gSavedPerAccountSettings.setBOOL("BuildPrefs_Physical", childGetValue("PhysicalToggle").asBoolean() ); + gSavedPerAccountSettings.setBOOL("BuildPrefs_Temporary", childGetValue("TemporaryToggle").asBoolean() ); + gSavedPerAccountSettings.setBOOL("BuildPrefs_Phantom", childGetValue("PhantomToggle").asBoolean() ); + + gSavedPerAccountSettings.setF32("BuildPrefs_PivotZ", childGetValue("Z pos").asReal() ); + gSavedPerAccountSettings.setF32("BuildPrefs_PivotY", childGetValue("Y pos").asReal() ); + gSavedPerAccountSettings.setF32("BuildPrefs_PivotX", childGetValue("X pos").asReal() ); + gSavedPerAccountSettings.setF32("BuildPrefs_Glow", childGetValue("glow").asReal() ); + gSavedPerAccountSettings.setF32("BuildPrefs_Alpha", childGetValue("alpha").asReal() ); + gSavedPerAccountSettings.setF32("BuildPrefs_Zsize", childGetValue("Z size").asReal() ); + gSavedPerAccountSettings.setF32("BuildPrefs_Ysize", childGetValue("Y size").asReal() ); + gSavedPerAccountSettings.setF32("BuildPrefs_Xsize", childGetValue("X size").asReal() ); + + gSavedPerAccountSettings.setString("BuildPrefs_Shiny", getChild("combobox shininess")->getValue().asString() ); + gSavedPerAccountSettings.setString("BuildPrefs_Material", getChild("material")->getValue().asString() ); + + gSavedPerAccountSettings.setColor4("BuildPrefs_Color", getChild("colorswatch")->get()); + + if (mBuildItemUUID != LLSD(gSavedPerAccountSettings.getString("BuildPrefs_Item")) ) + { + gSavedPerAccountSettings.setString("BuildPrefs_Item", mBuildItemUUID.asString() ); + } + + if (mBuildTextureUUID != LLSD(gSavedPerAccountSettings.getString("BuildPrefs_Texture")) ) + { + gSavedPerAccountSettings.setString("BuildPrefs_Texture", mBuildTextureUUID.asString() ); + } + + gSavedSettings.setBOOL("RenderHighlightSelections", childGetValue("BuildPrefsRenderHighlight_toggle").asBoolean() ); + gSavedSettings.setBOOL("RezWithLandGroup", childGetValue("grouplandrez").asBoolean() ); + gSavedSettings.setBOOL("GridSubUnit", childGetValue("GridSubUnit").asBoolean() ); + gSavedSettings.setBOOL("GridCrossSections", childGetValue("GridCrossSection").asBoolean() ); + + gSavedSettings.setF32("GridResolution", childGetValue("GridResolution").asReal() ); + gSavedSettings.setF32("GridDrawSize", childGetValue("GridDrawSize").asReal() ); + gSavedSettings.setF32("GridOpacity", childGetValue("GridOpacity").asReal() ); +} + +void LLFloaterBuildOptions::cancel() +{ + close(); +} + +void LLFloaterBuildOptions::reset() +{ + getChild("material")->setSimple(gSavedPerAccountSettings.getControl("BuildPrefs_Material")->getDefault().asString() ); + getChild("combobox shininess")->setSimple(gSavedPerAccountSettings.getControl("BuildPrefs_Shiny")->getDefault().asString() ); + + childSetValue("BuildPrefsActualRoot_toggle", gSavedPerAccountSettings.getControl("BuildPrefs_ActualRoot")->getDefault() ); + childSetValue("PivotPercToggle", gSavedPerAccountSettings.getControl("BuildPrefs_PivotIsPercent")->getDefault() ); + childSetValue("FBToggle", gSavedPerAccountSettings.getControl("BuildPrefs_FullBright")->getDefault() ); + childSetValue("BuildPrefsEmbedItem", gSavedPerAccountSettings.getControl("BuildPrefs_EmbedItem")->getDefault() ); + childSetValue("PhysicalToggle", gSavedPerAccountSettings.getControl("BuildPrefs_Physical")->getDefault() ); + childSetValue("TemporaryToggle", gSavedPerAccountSettings.getControl("BuildPrefs_Temporary")->getDefault() ); + childSetValue("PhantomToggle", gSavedPerAccountSettings.getControl("BuildPrefs_Phantom")->getDefault() ); + + childSetValue("Z pos", gSavedPerAccountSettings.getControl("BuildPrefs_PivotZ")->getDefault() ); + childSetValue("Y pos", gSavedPerAccountSettings.getControl("BuildPrefs_PivotY")->getDefault() ); + childSetValue("X pos", gSavedPerAccountSettings.getControl("BuildPrefs_PivotX")->getDefault() ); + childSetValue("glow", gSavedPerAccountSettings.getControl("BuildPrefs_Glow")->getDefault() ); + childSetValue("alpha", gSavedPerAccountSettings.getControl("BuildPrefs_Alpha")->getDefault() ); + childSetValue("Z size", gSavedPerAccountSettings.getControl("BuildPrefs_Zsize")->getDefault() ); + childSetValue("Y size", gSavedPerAccountSettings.getControl("BuildPrefs_Ysize")->getDefault() ); + childSetValue("X size", gSavedPerAccountSettings.getControl("BuildPrefs_Xsize")->getDefault() ); + + getChild("colorswatch")->set(gSavedPerAccountSettings.getControl("BuildPrefs_Color")->getDefault(), TRUE); + getChild("texture control")->setImageAssetID(LLUUID(gSavedPerAccountSettings.getControl("BuildPrefs_Texture")->getDefault()) ); + + mBuildItemUUID = (LLUUID)gSavedPerAccountSettings.getControl("BuildPrefs_Item")->getDefault(); + mBuildTextureUUID = (LLUUID)gSavedPerAccountSettings.getControl("BuildPrefs_Texture")->getDefault(); + + childSetValue("BuildPrefsRenderHighlight_toggle", gSavedSettings.getControl("RenderHighlightSelections")->getDefault() ); + childSetValue("grouplandrez", gSavedSettings.getControl("RezWithLandGroup")->getDefault() ); + childSetValue("GridSubUnit", gSavedSettings.getControl("GridSubUnit")->getDefault() ); + childSetValue("GridCrossSection", gSavedSettings.getControl("GridCrossSections")->getDefault() ); + + childSetValue("GridResolution", gSavedSettings.getControl("GridResolution")->getDefault() ); + childSetValue("GridDrawSize", gSavedSettings.getControl("GridDrawSize")->getDefault() ); + childSetValue("GridOpacity", gSavedSettings.getControl("GridOpacity")->getDefault() ); +} + +void LLFloaterBuildOptions::refresh() +{ + +} + +void LLFloaterBuildOptions::setItem(const LLUUID& item) +{ + mBuildItemUUID = item; +} + +void LLFloaterBuildOptions::setTexture(const LLUUID& texture) +{ + mBuildTextureUUID = texture; +} + +void LLFloaterBuildOptions::refreshItem() +{ + if (LLStartUp::getStartupState() == STATE_STARTED) + { + if (mBuildItemUUID.isNull()) + { + childSetValue("build_item_add_disp_rect_txt", "Currently not set"); + } + else + { + LLViewerInventoryItem* item = gInventory.getItem(mBuildItemUUID); + if (item) + { + childSetValue("build_item_add_disp_rect_txt", "Currently set to: "+item->getName()); + } + + else + { + childSetValue("build_item_add_disp_rect_txt", "Currently set to a item not on this account"); + } + } + } + else + { + childSetValue("build_item_add_disp_rect_txt", "Not logged in"); } } diff --git a/linden/indra/newview/llfloaterbuildoptions.h b/linden/indra/newview/llfloaterbuildoptions.h index 50599dd..c776055 100644 --- a/linden/indra/newview/llfloaterbuildoptions.h +++ b/linden/indra/newview/llfloaterbuildoptions.h @@ -5,6 +5,7 @@ * $LicenseInfo:firstyear=2002&license=viewergpl$ * * Copyright (c) 2002-2009, Linden Research, Inc. + * 2010, McCabe Maxsted * * Second Life Viewer Source Code * The source code in this file ("Source Code") is provided by Linden Lab @@ -40,8 +41,8 @@ #include "llfloater.h" -class LLViewerInventoryItem; class InvDropTarget; +class LLViewerInventoryItem; class LLFloaterBuildOptions : public LLFloater @@ -57,15 +58,33 @@ public: static LLFloaterBuildOptions* getInstance(); static BOOL visible(void*); + void apply(); + void cancel(); + void refresh(); + void reset(); + + void setItem(const LLUUID& item); + void setTexture(const LLUUID& texture); + protected: static LLFloaterBuildOptions* sInstance; private: - static InvDropTarget* mBuildObjectDropTarget; + static InvDropTarget* sBuildObjectDropTarget; + LLUUID mBuildItemUUID; + LLUUID mBuildTextureUUID; static void onTexturePickerCommit(LLUICtrl* ctrl, void* userdata); static void onComboBoxCommit(LLUICtrl* ctrl, void* userdata); static void BuildAutoResponseItemDrop(LLViewerInventoryItem* item); + + static void onClickOK(void* userdata); + static void onClickApply(void* userdata); + static void onClickCancel(void* userdata); + static void onClickClear(void* userdata); + static void onClickReset(void* userdata); + + void refreshItem(); }; #endif diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_build_options.xml b/linden/indra/newview/skins/default/xui/en-us/floater_build_options.xml index cdd5dc1..298805d 100644 --- a/linden/indra/newview/skins/default/xui/en-us/floater_build_options.xml +++ b/linden/indra/newview/skins/default/xui/en-us/floater_build_options.xml @@ -1,6 +1,6 @@ @@ -10,23 +10,23 @@ bottom_delta="110" drop_shadow_visible="true" enabled="true" follows="left|top" font="SansSerifSmall" h_pad="0" halign="left" height="10" left_delta="53" mouse_opaque="false" name="text_box7" v_pad="0" width="150"> Grid Options - - - + - - + mouse_opaque="true" name="X size" width="110" /> + mouse_opaque="true" name="Y size" width="110" /> + mouse_opaque="true" name="Z size" width="110" /> + width="100" /> + width="100" /> + width="100" /> + left="10" max_chars="20" mouse_opaque="true" name="material" width="87"> Stone Metal Glass @@ -84,25 +83,24 @@ + mouse_opaque="true" name="colorswatch" tool_tip="Click to open Color Picker" width="64" /> + mouse_opaque="true" name="alpha" width="90" /> + min_val="0" mouse_opaque="true" name="glow" width="90" /> + width="100" /> + width="90"> None Low Medium @@ -117,14 +115,17 @@ v_pad="2" width="400"> Drop an inventory item here to have it added to the prim contents. +