From b165492945d4a9b13a594ec626e49482da9635b1 Mon Sep 17 00:00:00 2001
From: Dmitry Zaporozhan <dzaporozhan@productengine.com>
Date: Mon, 28 Dec 2009 13:19:15 +0200
Subject: Fixed normal bug EXT-2791 - Upload Image / sound / animation missing
 cost.

--HG--
branch : product-engine
---
 indra/newview/app_settings/settings.xml | 11 +++++++++
 indra/newview/llpanelmaininventory.cpp  | 40 ++++++++++++++++++++++++++++++++-
 indra/newview/llpanelmaininventory.h    |  6 +++++
 3 files changed, 56 insertions(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index ba78d80ad1..bf69986094 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -2344,6 +2344,17 @@
       <key>Value</key>
       <string>89556747-24cb-43ed-920b-47caed15465f</string>
     </map>
+    <key>DefaultUploadCost</key>
+    <map>
+      <key>Comment</key>
+      <string>Default sound/image/file upload cost(in case economy data is not available).</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>U32</string>
+      <key>Value</key>
+      <integer>10</integer>
+    </map>
     <key>DisableCameraConstraints</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp
index 961d3dec8b..e74a39c85c 100644
--- a/indra/newview/llpanelmaininventory.cpp
+++ b/indra/newview/llpanelmaininventory.cpp
@@ -35,6 +35,7 @@
 
 #include "llagent.h"
 #include "lldndbutton.h"
+#include "lleconomy.h"
 #include "llfilepicker.h"
 #include "llfloaterinventory.h"
 #include "llinventorybridge.h"
@@ -97,7 +98,8 @@ LLPanelMainInventory::LLPanelMainInventory()
 	  mSavedFolderState(NULL),
 	  mFilterText(""),
 	  mMenuGearDefault(NULL),
-	  mMenuAdd(NULL)
+	  mMenuAdd(NULL),
+	  mNeedUploadCost(true)
 {
 	LLMemType mt(LLMemType::MTYPE_INVENTORY_VIEW_INIT);
 	// Menu Callbacks (non contex menus)
@@ -895,6 +897,8 @@ void LLPanelMainInventory::onGearButtonClick()
 
 void LLPanelMainInventory::onAddButtonClick()
 {
+	setUploadCostIfNeeded();
+
 	showActionMenu(mMenuAdd,"add_btn");
 }
 
@@ -1131,5 +1135,39 @@ bool LLPanelMainInventory::handleDragAndDropToTrash(BOOL drop, EDragAndDropType
 	return true;
 }
 
+void LLPanelMainInventory::setUploadCostIfNeeded()
+{
+	// *NOTE dzaporozhan
+	// Upload cost is set in process_economy_data() (llviewermessage.cpp). But since we
+	// have two instances of Inventory panel at the moment(and two instances of context menu),
+	// call to gMenuHolder->childSetLabelArg() sets upload cost only for one of the instances.
+
+	if(mNeedUploadCost && mMenuAdd)
+	{
+		LLMenuItemBranchGL* upload_menu = mMenuAdd->findChild<LLMenuItemBranchGL>("upload");
+		if(upload_menu)
+		{
+			S32 upload_cost = -1;//LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
+			std::string cost_str;
+
+			// getPriceUpload() returns -1 if no data available yet.
+			if(upload_cost >= 0)
+			{
+				mNeedUploadCost = false;
+				cost_str = llformat("%d", upload_cost);
+			}
+			else
+			{
+				cost_str = llformat("%d", gSavedSettings.getU32("DefaultUploadCost"));
+			}
+
+			upload_menu->getChild<LLView>("Upload Image")->setLabelArg("[COST]", cost_str);
+			upload_menu->getChild<LLView>("Upload Sound")->setLabelArg("[COST]", cost_str);
+			upload_menu->getChild<LLView>("Upload Animation")->setLabelArg("[COST]", cost_str);
+			upload_menu->getChild<LLView>("Bulk Upload")->setLabelArg("[COST]", cost_str);
+		}
+	}
+}
+
 // List Commands                                                              //
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/indra/newview/llpanelmaininventory.h b/indra/newview/llpanelmaininventory.h
index 69f8a14583..d9ea0da2da 100644
--- a/indra/newview/llpanelmaininventory.h
+++ b/indra/newview/llpanelmaininventory.h
@@ -139,10 +139,16 @@ protected:
 	BOOL isActionEnabled(const LLSD& command_name);
 	void onCustomAction(const LLSD& command_name);
 	bool handleDragAndDropToTrash(BOOL drop, EDragAndDropType cargo_type, EAcceptance* accept);
+	/**
+	 * Set upload cost in "Upload" sub menu.
+	 */
+	void setUploadCostIfNeeded();
 private:
 	LLPanel*					mListCommands;
 	LLMenuGL*					mMenuGearDefault;
 	LLMenuGL*					mMenuAdd;
+
+	bool						mNeedUploadCost;
 	// List Commands                                                              //
 	////////////////////////////////////////////////////////////////////////////////
 };
-- 
cgit v1.2.3