From 86fe86702e582e43be8e9fa0338a2fb8a8056771 Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Thu, 30 Aug 2012 19:46:21 -0700 Subject: Adding results from the Get method to a scroll list table. --- indra/newview/llfloaterstinson.cpp | 123 ++++++++++++++++++++- indra/newview/llfloaterstinson.h | 7 +- .../skins/default/xui/en/floater_stinson.xml | 87 +++++++++++++-- 3 files changed, 202 insertions(+), 15 deletions(-) diff --git a/indra/newview/llfloaterstinson.cpp b/indra/newview/llfloaterstinson.cpp index ff8fc18112..5da1d9b242 100644 --- a/indra/newview/llfloaterstinson.cpp +++ b/indra/newview/llfloaterstinson.cpp @@ -39,7 +39,11 @@ #include "llbutton.h" #include "llenvmanager.h" #include "llfloater.h" +#include "llfontgl.h" #include "llhttpclient.h" +#include "llscrolllistcell.h" +#include "llscrolllistctrl.h" +#include "llscrolllistitem.h" #include "llsd.h" #include "llselectmgr.h" #include "llstring.h" @@ -116,6 +120,9 @@ BOOL LLFloaterStinson::postBuild() llassert(mPutButton != NULL); mPutButton->setCommitCallback(boost::bind(&LLFloaterStinson::onPutClicked, this)); + mMaterialsScrollList = findChild("materials_scroll_list"); + llassert(mMaterialsScrollList != NULL); + mWarningColor = LLUIColorTable::instance().getColor("MaterialWarningColor"); mErrorColor = LLUIColorTable::instance().getColor("MaterialErrorColor"); @@ -144,10 +151,13 @@ void LLFloaterStinson::onOpen(const LLSD& pKey) } checkRegionMaterialStatus(); + clearMaterialsList(); } void LLFloaterStinson::onClose(bool pIsAppQuitting) { + clearMaterialsList(); + if (mSelectionUpdateConnection.connected()) { mSelectionUpdateConnection.disconnect(); @@ -224,7 +234,7 @@ void LLFloaterStinson::onGetResponse(bool pRequestStatus, const LLSD& pContent) if (pRequestStatus) { setState(kRequestCompleted); - parseResponse("GET", pContent); + parseGetResponse(pContent); } else { @@ -237,7 +247,7 @@ void LLFloaterStinson::onPutResponse(bool pRequestStatus, const LLSD& pContent) if (pRequestStatus) { setState(kRequestCompleted); - parseResponse("PUT", pContent); + printResponse("PUT", pContent); } else { @@ -445,7 +455,109 @@ void LLFloaterStinson::requestPutMaterials(const LLUUID& regionId) } } -void LLFloaterStinson::parseResponse(const std::string& pRequestType, const LLSD& pContent) const +void LLFloaterStinson::parseGetResponse(const LLSD& pContent) +{ + printResponse("GET", pContent); + clearMaterialsList(); + + LLScrollListCell::Params cellParams; + LLScrollListItem::Params rowParams; + + llassert(pContent.isArray()); + for (LLSD::array_const_iterator materialIter = pContent.beginArray(); materialIter != pContent.endArray(); + ++materialIter) + { + const LLSD &material = *materialIter; + llassert(material.isMap()); + llassert(material.has(MATERIALS_CAP_OBJECT_ID_FIELD)); + llassert(material.get(MATERIALS_CAP_OBJECT_ID_FIELD).isBinary()); + + const LLSD::Binary &materialIDValue = material.get(MATERIALS_CAP_OBJECT_ID_FIELD).asBinary(); + unsigned int valueSize = materialIDValue.size(); + + std::string materialID(reinterpret_cast(&materialIDValue[0]), valueSize); + std::string materialIDString; + for (unsigned int i = 0; i < valueSize; ++i) + { + materialIDString += llformat("%02x", materialID.c_str()[i]); + } + + llassert(material.has(MATERIALS_CAP_MATERIAL_FIELD)); + const LLSD &materialData = material.get(MATERIALS_CAP_MATERIAL_FIELD); + llassert(materialData.isMap()); + + llassert(materialData.has(MATERIALS_CAP_NORMAL_MAP_FIELD)); + llassert(materialData.get(MATERIALS_CAP_NORMAL_MAP_FIELD).isUUID()); + const LLUUID &normalMapID = materialData.get(MATERIALS_CAP_NORMAL_MAP_FIELD).asUUID(); + + llassert(materialData.has(MATERIALS_CAP_SPECULAR_MAP_FIELD)); + llassert(materialData.get(MATERIALS_CAP_SPECULAR_MAP_FIELD).isUUID()); + const LLUUID &specularMapID = materialData.get(MATERIALS_CAP_SPECULAR_MAP_FIELD).asUUID(); + + llassert(materialData.has(MATERIALS_CAP_SPECULAR_COLOR_FIELD)); + llassert(materialData.get(MATERIALS_CAP_SPECULAR_COLOR_FIELD).isArray()); + LLColor4U specularColor; + specularColor.setValue(materialData.get(MATERIALS_CAP_SPECULAR_COLOR_FIELD)); + + llassert(materialData.has(MATERIALS_CAP_SPECULAR_EXP_FIELD)); + llassert(materialData.get(MATERIALS_CAP_SPECULAR_EXP_FIELD).isInteger()); + S32 specularExp = materialData.get(MATERIALS_CAP_SPECULAR_EXP_FIELD).asInteger(); + + llassert(materialData.has(MATERIALS_CAP_ENV_INTENSITY_FIELD)); + llassert(materialData.get(MATERIALS_CAP_ENV_INTENSITY_FIELD).isInteger()); + S32 envIntensity = materialData.get(MATERIALS_CAP_ENV_INTENSITY_FIELD).asInteger(); + + llassert(materialData.has(MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD)); + llassert(materialData.get(MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD).isInteger()); + S32 alphaMaskCutoff = materialData.get(MATERIALS_CAP_ALPHA_MASK_CUTOFF_FIELD).asInteger(); + + llassert(materialData.has(MATERIALS_CAP_DIFFUSE_ALPHA_IS_MASK_FIELD)); + llassert(materialData.get(MATERIALS_CAP_DIFFUSE_ALPHA_IS_MASK_FIELD).isInteger()); + BOOL isDiffuseAlphaMask = static_cast(materialData.get(MATERIALS_CAP_DIFFUSE_ALPHA_IS_MASK_FIELD).asInteger()); + + + cellParams.font = LLFontGL::getFontMonospace(); + + cellParams.column = "id"; + cellParams.value = materialIDString; + rowParams.columns.add(cellParams); + + cellParams.column = "normal_map"; + cellParams.value = normalMapID.asString(); + rowParams.columns.add(cellParams); + + cellParams.column = "specular_map"; + cellParams.value = specularMapID.asString(); + rowParams.columns.add(cellParams); + + cellParams.font = LLFontGL::getFontSansSerif(); + + cellParams.column = "specular_color"; + cellParams.value = llformat("(%d, %d, %d, %d)", specularColor.mV[0], + specularColor.mV[1], specularColor.mV[2], specularColor.mV[3]); + rowParams.columns.add(cellParams); + + cellParams.column = "specular_exponent"; + cellParams.value = llformat("%d", specularExp); + rowParams.columns.add(cellParams); + + cellParams.column = "env_intensity"; + cellParams.value = llformat("%d", envIntensity); + rowParams.columns.add(cellParams); + + cellParams.column = "alpha_mask_cutoff"; + cellParams.value = llformat("%d", alphaMaskCutoff); + rowParams.columns.add(cellParams); + + cellParams.column = "is_diffuse_alpha_mask"; + cellParams.value = (isDiffuseAlphaMask ? "True" : "False"); + rowParams.columns.add(cellParams); + + mMaterialsScrollList->addRow(rowParams); + } +} + +void LLFloaterStinson::printResponse(const std::string& pRequestType, const LLSD& pContent) const { llinfos << "--------------------------------------------------------------------------" << llendl; llinfos << pRequestType << " Response: '" << pContent << "'" << llendl; @@ -459,6 +571,11 @@ void LLFloaterStinson::setState(EState pState) updateControls(); } +void LLFloaterStinson::clearMaterialsList() +{ + mMaterialsScrollList->deleteAllItems(); +} + void LLFloaterStinson::updateStatusMessage() { std::string statusText; diff --git a/indra/newview/llfloaterstinson.h b/indra/newview/llfloaterstinson.h index 1a4c511deb..5b8f157cd0 100644 --- a/indra/newview/llfloaterstinson.h +++ b/indra/newview/llfloaterstinson.h @@ -34,6 +34,7 @@ #include "v4color.h" class LLButton; +class LLScrollListCtrl; class LLSD; class LLTextBase; @@ -82,17 +83,21 @@ private: void requestPutMaterials(); void requestPutMaterials(const LLUUID& regionId); - void parseResponse(const std::string& pRequestType, const LLSD& pContent) const; + void parseGetResponse(const LLSD& pContent); + void printResponse(const std::string& pRequestType, const LLSD& pContent) const; void setState(EState pState); inline EState getState() const; + void clearMaterialsList(); + void updateStatusMessage(); void updateControls(); LLTextBase* mStatusText; LLButton* mGetButton; LLButton* mPutButton; + LLScrollListCtrl* mMaterialsScrollList; EState mState; LLColor4 mWarningColor; diff --git a/indra/newview/skins/default/xui/en/floater_stinson.xml b/indra/newview/skins/default/xui/en/floater_stinson.xml index 0ec6b281cf..559e6eb48f 100644 --- a/indra/newview/skins/default/xui/en/floater_stinson.xml +++ b/indra/newview/skins/default/xui/en/floater_stinson.xml @@ -2,15 +2,18 @@ + title="Stinson Test"> No current region available. Region capabilities are loading. Materials are enabled for this region. @@ -57,22 +60,21 @@ + width="1170"/> + width="1170">