From 4c7920778fa3ea4b9ea9fe3945eb57d250a0527f Mon Sep 17 00:00:00 2001
From: Maxim Nikolenko <maximnproductengine@lindenlab.com>
Date: Tue, 17 Oct 2023 18:12:13 +0300
Subject: [PATCH] SL-20457 allow creating new items from the right-click
 context menu

---
 indra/newview/llinventorybridge.cpp           |  18 +-
 .../skins/default/xui/en/menu_inventory.xml   | 236 +++++++++++++++++-
 2 files changed, 244 insertions(+), 10 deletions(-)

diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 22dd884b914..cb5316ddf4c 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -765,7 +765,7 @@ void hide_context_entries(LLMenuGL& menu,
 
 		// descend into split menus:
 		LLMenuItemBranchGL* branchp = dynamic_cast<LLMenuItemBranchGL*>(menu_item);
-		if ((name == "More") && branchp)
+        if (((name == "More") || (name == "create_new")) && branchp)
 		{
 			hide_context_entries(*branchp->getBranch(), entries_to_show, disabled_entries);
 		}
@@ -820,7 +820,7 @@ void hide_context_entries(LLMenuGL& menu,
 			// so that some other UI element from multi-select doesn't later set this invisible.
 			menu_item->pushVisible(TRUE);
 
-			bool enabled = (menu_item->getEnabled() == TRUE);
+			bool enabled = true;
 			for (itor2 = disabled_entries.begin(); enabled && (itor2 != disabled_entries.end()); ++itor2)
 			{
 				enabled &= (*itor2 != name);
@@ -4282,6 +4282,7 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t&   items
 
 		disabled_items.push_back(std::string("New Folder"));
 		disabled_items.push_back(std::string("upload_def"));
+        disabled_items.push_back(std::string("create_new"));
 	}
 	if (favorites == mUUID)
 	{
@@ -4304,6 +4305,7 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t&   items
     {
         disabled_items.push_back(std::string("New Folder"));
 		disabled_items.push_back(std::string("upload_def"));
+        disabled_items.push_back(std::string("create_new"));
     }
     if (marketplace_listings_id == mUUID)
     {
@@ -4367,6 +4369,18 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t&   items
                 if (!isMarketplaceListingsFolder())
                 {
                     items.push_back(std::string("upload_def"));
+                    items.push_back(std::string("create_new"));
+                    items.push_back(std::string("New Script"));
+                    items.push_back(std::string("New Note"));
+                    items.push_back(std::string("New Gesture"));
+                    items.push_back(std::string("New Material"));
+                    items.push_back(std::string("New Clothes"));
+                    items.push_back(std::string("New Body Parts"));
+                    items.push_back(std::string("New Settings"));
+                    if (!LLEnvironment::instance().isInventoryEnabled())
+                    {
+                        disabled_items.push_back("New Settings");
+                    }
                 }
                 if (menu_items_added)
                 {
diff --git a/indra/newview/skins/default/xui/en/menu_inventory.xml b/indra/newview/skins/default/xui/en/menu_inventory.xml
index 1907dc24383..3a8f360e2d1 100644
--- a/indra/newview/skins/default/xui/en/menu_inventory.xml
+++ b/indra/newview/skins/default/xui/en/menu_inventory.xml
@@ -143,14 +143,6 @@
          function="Inventory.EmptyLostAndFound"
          parameter="rename" />
     </menu_item_call>
-    <menu_item_call
-     label="New Folder"
-     layout="topleft"
-     name="New Folder">
-        <menu_item_call.on_click
-         function="Inventory.DoCreate"
-         parameter="category" />
-    </menu_item_call>
     <menu_item_call
      label="New Outfit"
      layout="topleft"
@@ -699,6 +691,234 @@
   <menu_item_separator
    layout="topleft"
    name="Subfolder Separator" />
+  <menu
+   label="Create new"
+   layout="topleft"
+   name="create_new">
+    <menu_item_call
+     label="New Folder"
+     layout="topleft"
+     name="New Folder">
+      <menu_item_call.on_click
+       function="Inventory.DoCreate"
+       parameter="category" />
+    </menu_item_call>
+    <menu_item_call
+     label="New Script"
+     layout="topleft"
+     name="New Script">
+      <menu_item_call.on_click
+       function="Inventory.DoCreate"
+       parameter="lsl" />
+    </menu_item_call>
+    <menu_item_call
+     label="New Notecard"
+     layout="topleft"
+     name="New Note">
+      <menu_item_call.on_click
+       function="Inventory.DoCreate"
+       parameter="notecard" />
+    </menu_item_call>
+    <menu_item_call
+     label="New Gesture"
+     layout="topleft"
+     name="New Gesture">
+      <menu_item_call.on_click
+       function="Inventory.DoCreate"
+       parameter="gesture" />
+    </menu_item_call>
+    <menu_item_call
+     label="New Material"
+     layout="topleft"
+     name="New Material">
+      <menu_item_call.on_click
+       function="Inventory.DoCreate"
+       parameter="material" />
+      <menu_item_call.on_enable
+       function="Inventory.MaterialsEnabled" />
+    </menu_item_call>
+    <menu
+     label="New Clothes"
+     layout="topleft"
+     name="New Clothes">
+      <menu_item_call
+       label="New Shirt"
+       layout="topleft"
+       name="New Shirt">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="shirt" />
+      </menu_item_call>
+      <menu_item_call
+       label="New Pants"
+       layout="topleft"
+       name="New Pants">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="pants" />
+      </menu_item_call>
+      <menu_item_call
+       label="New Shoes"
+       layout="topleft"
+       name="New Shoes">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="shoes" />
+      </menu_item_call>
+      <menu_item_call
+       label="New Socks"
+       layout="topleft"
+       name="New Socks">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="socks" />
+      </menu_item_call>
+      <menu_item_call
+       label="New Jacket"
+       layout="topleft"
+       name="New Jacket">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="jacket" />
+      </menu_item_call>
+      <menu_item_call
+       label="New Skirt"
+       layout="topleft"
+       name="New Skirt">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="skirt" />
+      </menu_item_call>
+      <menu_item_call
+       label="New Gloves"
+       layout="topleft"
+       name="New Gloves">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="gloves" />
+      </menu_item_call>
+      <menu_item_call
+       label="New Undershirt"
+       layout="topleft"
+       name="New Undershirt">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="undershirt" />
+      </menu_item_call>
+      <menu_item_call
+       label="New Underpants"
+       layout="topleft"
+       name="New Underpants">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="underpants" />
+      </menu_item_call>
+      <menu_item_call
+       label="New Alpha Mask"
+       layout="topleft"
+       name="New Alpha Mask">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="alpha" />
+      </menu_item_call>
+      <menu_item_call
+       label="New Tattoo"
+       layout="topleft"
+       name="New Tattoo">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="tattoo" />
+      </menu_item_call>
+      <menu_item_call
+       label="New Universal"
+       layout="topleft"
+       name="New Universal">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="universal" />
+      </menu_item_call>
+      <menu_item_call
+       label="New Physics"
+       layout="topleft"
+       name="New Physics">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="physics" />
+      </menu_item_call>
+    </menu>
+    <menu
+     label="New Body Parts"
+     layout="topleft"
+     name="New Body Parts">
+      <menu_item_call
+       label="New Shape"
+       layout="topleft"
+       name="New Shape">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="shape" />
+      </menu_item_call>
+      <menu_item_call
+       label="New Skin"
+       layout="topleft"
+       name="New Skin">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="skin" />
+      </menu_item_call>
+      <menu_item_call
+       label="New Hair"
+       layout="topleft"
+       name="New Hair">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="hair" />
+      </menu_item_call>
+      <menu_item_call
+       label="New Eyes"
+       layout="topleft"
+       name="New Eyes">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="eyes" />
+      </menu_item_call>
+    </menu>
+    <menu
+     label="New Settings"
+     layout="topleft"
+     name="New Settings">
+      <menu_item_call
+       label="New Sky"
+       layout="topleft"
+       name="New Sky">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="sky"/>
+        <menu_item_call.on_enable
+         function="Inventory.EnvironmentEnabled" />
+      </menu_item_call>
+      <menu_item_call
+       label="New Water"
+       layout="topleft"
+       name="New Water">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="water"/>
+        <menu_item_call.on_enable
+         function="Inventory.EnvironmentEnabled" />
+      </menu_item_call>
+      <menu_item_call
+       label="New Day Cycle"
+       layout="topleft"
+       name="New Day Cycle">
+        <menu_item_call.on_click
+         function="Inventory.DoCreate"
+         parameter="daycycle"/>
+        <menu_item_call.on_enable
+         function="Inventory.EnvironmentEnabled" />
+      </menu_item_call>
+    </menu>
+  </menu>  
   <menu_item_call
    label="Create folder from selected"
    layout="topleft"
-- 
GitLab