Commits

Anonymous committed b772853

Fixed normal bug EXT-2791 - Upload Image / sound / animation missing cost.

  • Participants
  • Parent commits a5077a7
  • Branches product-engine

Comments (0)

Files changed (3)

indra/newview/app_settings/settings.xml

       <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>

indra/newview/llpanelmaininventory.cpp

 
 #include "llagent.h"
 #include "lldndbutton.h"
+#include "lleconomy.h"
 #include "llfilepicker.h"
 #include "llfloaterinventory.h"
 #include "llinventorybridge.h"
 	  mSavedFolderState(NULL),
 	  mFilterText(""),
 	  mMenuGearDefault(NULL),
-	  mMenuAdd(NULL)
+	  mMenuAdd(NULL),
+	  mNeedUploadCost(true)
 {
 	LLMemType mt(LLMemType::MTYPE_INVENTORY_VIEW_INIT);
 	// Menu Callbacks (non contex menus)
 
 void LLPanelMainInventory::onAddButtonClick()
 {
+	setUploadCostIfNeeded();
+
 	showActionMenu(mMenuAdd,"add_btn");
 }
 
 	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                                                              //
 ////////////////////////////////////////////////////////////////////////////////

indra/newview/llpanelmaininventory.h

 	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                                                              //
 	////////////////////////////////////////////////////////////////////////////////
 };