]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/entity.cpp
Merge commit '48410b113dd2036e69dbf723a39ec9af02fc9b12'
[xonotic/netradiant.git] / radiant / entity.cpp
index 52be82feed93405b0189f86754661886690b72cd..9478bda27ea00fbc84f39cc281b95a6ab50b751e 100644 (file)
@@ -184,11 +184,11 @@ public:
 
 class EntityGroupSelected : public scene::Graph::Walker
 {
-       NodeSmartReference group;
+       NodeSmartReference group, worldspawn;
        //typedef std::pair<NodeSmartReference, NodeSmartReference> DeletionPair;
        //Stack<DeletionPair> deleteme;
        public:
-       EntityGroupSelected(const scene::Path &p): group(p.top().get())
+       EntityGroupSelected(const scene::Path &p): group(p.top().get()), worldspawn(Map_FindOrInsertWorldspawn(g_map))
        {
        }
        bool pre(const scene::Path& path, scene::Instance& instance) const
@@ -206,7 +206,7 @@ class EntityGroupSelected : public scene::Graph::Walker
                                NodeSmartReference child(path.top().get());
                                NodeSmartReference parent(path.parent().get());
 
-                               if(path.size() >= 3 && parent != Map_FindOrInsertWorldspawn(g_map))
+                               if(path.size() >= 3 && parent != worldspawn)
                                {
                                        NodeSmartReference parentparent(path[path.size() - 3].get());
 
@@ -258,7 +258,8 @@ void Entity_connectSelected()
   {
     GlobalEntityCreator().connectEntities(
       GlobalSelectionSystem().penultimateSelected().path(),
-      GlobalSelectionSystem().ultimateSelected().path()
+      GlobalSelectionSystem().ultimateSelected().path(),
+      0
     );
   }
   else
@@ -267,6 +268,22 @@ void Entity_connectSelected()
   }
 }
 
+void Entity_killconnectSelected()
+{
+  if(GlobalSelectionSystem().countSelected() == 2)
+  {
+    GlobalEntityCreator().connectEntities(
+      GlobalSelectionSystem().penultimateSelected().path(),
+      GlobalSelectionSystem().ultimateSelected().path(),
+      1
+    );
+  }
+  else
+  {
+    globalErrorStream() << "entityKillConnectSelected: exactly two instances must be selected\n";
+  }
+}
+
 AABB Doom3Light_getBounds(const AABB& workzone)
 {
   AABB aabb(workzone);
@@ -311,8 +328,7 @@ void Entity_createFromSelection(const char* name, const Vector3& origin)
 
   EntityClass* entityClass = GlobalEntityClassManager().findOrInsert(name, true);
 
-  bool isModel = string_equal_nocase(name, "misc_model")
-    || string_equal_nocase(name, "misc_gamemodel")
+  bool isModel = (string_compare_nocase_n(name, "misc_", 5) == 0 && string_equal_nocase(name + string_length(name) - 5, "model")) // misc_*model (also misc_model)
     || string_equal_nocase(name, "model_static")
     || (GlobalSelectionSystem().countSelected() == 0 && string_equal_nocase(name, "func_static"));
 
@@ -618,6 +634,7 @@ void Entity_constructMenu(GtkMenu* menu)
   create_menu_item_with_mnemonic(menu, "_Regroup", "GroupSelection");
   create_menu_item_with_mnemonic(menu, "_Ungroup", "UngroupSelection");
   create_menu_item_with_mnemonic(menu, "_Connect", "ConnectSelection");
+  create_menu_item_with_mnemonic(menu, "_KillConnect", "KillConnectSelection");
   create_menu_item_with_mnemonic(menu, "_Select Color...", "EntityColor");
   create_menu_item_with_mnemonic(menu, "_Normalize Color...", "NormalizeColor");
 }
@@ -632,6 +649,7 @@ void Entity_Construct()
   GlobalCommands_insert("EntityColor", FreeCaller<Entity_setColour>(), Accelerator('K'));
   GlobalCommands_insert("NormalizeColor", FreeCaller<Entity_normalizeColor>());
   GlobalCommands_insert("ConnectSelection", FreeCaller<Entity_connectSelected>(), Accelerator('K', (GdkModifierType)GDK_CONTROL_MASK));
+  GlobalCommands_insert("KillConnectSelection", FreeCaller<Entity_killconnectSelected>(), Accelerator('K', (GdkModifierType)(GDK_SHIFT_MASK)));
   GlobalCommands_insert("GroupSelection", FreeCaller<Entity_groupSelected>());
   GlobalCommands_insert("UngroupSelection", FreeCaller<Entity_ungroupSelected>());