]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
make shift-a not always check classname, but check the current entity key if entity...
authorRudolf Polzer <divVerent@xonotic.org>
Wed, 22 Dec 2010 16:38:33 +0000 (17:38 +0100)
committerRudolf Polzer <divVerent@xonotic.org>
Wed, 22 Dec 2010 16:38:33 +0000 (17:38 +0100)
radiant/entityinspector.cpp
radiant/entityinspector.h
radiant/groupdialog.h
radiant/mainframe.h
radiant/select.cpp

index b5636780bfda49a39627ecb35ef0848185680d5a..95f03f7378326bd34f4cd01a204b1589fce58056 100644 (file)
@@ -76,6 +76,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "entity.h"
 #include "mainframe.h"
 #include "textureentry.h"
+#include "groupdialog.h"
 
 GtkEntry* numeric_entry_new()
 {
@@ -1760,3 +1761,11 @@ void EntityInspector_destroy()
   GlobalEntityClassManager().detach(g_EntityInspector);
 }
 
+const char *EntityInspector_getCurrentKey()
+{
+       if(!GroupDialog_isShown())
+               return 0;
+       if(GroupDialog_getPage() != g_page_entity)
+               return 0;
+       return gtk_entry_get_text(g_entityKeyEntry);
+}
index 62a69ab6644237c7213fde9b86dce5967ebc34c8..130c9657eceaa1f65def7e42bcede5381a118adb 100644 (file)
@@ -27,5 +27,6 @@ typedef struct _GtkWindow GtkWindow;
 GtkWidget* EntityInspector_constructWindow(GtkWindow* parent);
 void EntityInspector_construct();
 void EntityInspector_destroy();
+const char *EntityInspector_getCurrentKey();
 
 #endif
index 92caffabe2689be8af5d2f8114cc986a0a2875e6..38f399be01646299e47cc73eec3847267a7d1453 100644 (file)
@@ -44,5 +44,7 @@ GtkWidget* GroupDialog_addPage(const char* tabLabel, GtkWidget* widget, const St
 
 void GroupDialog_showPage(GtkWidget* page);
 void GroupDialog_updatePageTitle(GtkWidget* page);
+bool GroupDialog_isShown();
+GtkWidget* GroupDialog_getPage();
 
 #endif
index 5997abd34e286fc9d36c3c9fe2049e025c3f207a..d011f3198cc32c8ec8d3fc9ec44a5db97fb0d69d 100644 (file)
@@ -283,4 +283,6 @@ void XYWindowDestroyed_disconnect(SignalHandlerId id);
 MouseEventHandlerId XYWindowMouseDown_connect(const MouseEventHandler& handler);
 void XYWindowMouseDown_disconnect(MouseEventHandlerId id);
 
+extern GtkWidget* g_page_entity;
+
 #endif
index 5889fd5a1c69fb9d3753f18eb2e86c68d43a7ff4..c232da200caa8faff9a710e274ac8785580cf77b 100644 (file)
@@ -47,6 +47,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "mainframe.h"
 #include "grid.h"
 #include "map.h"
+#include "entityinspector.h"
 
 
 
@@ -658,13 +659,13 @@ void FindReplaceTextures(const char* pFind, const char* pReplace, bool bSelected
   }
 }
 
-typedef std::vector<const char*> Classnames;
+typedef std::vector<const char*> PropertyValues;
 
-bool classnames_match_entity(const Classnames& classnames, Entity* entity)
+bool propertyvalues_contain(const PropertyValues& propertyvalues, const char *str)
 {
-  for(Classnames::const_iterator i = classnames.begin(); i != classnames.end(); ++i)
+  for(PropertyValues::const_iterator i = propertyvalues.begin(); i != propertyvalues.end(); ++i)
   {
-    if(string_equal(entity->getKeyValue("classname"), *i))
+    if(string_equal(str, *i))
     {
       return true;
     }
@@ -672,19 +673,20 @@ bool classnames_match_entity(const Classnames& classnames, Entity* entity)
   return false;
 }
 
-class EntityFindByClassnameWalker : public scene::Graph::Walker
+class EntityFindByPropertyValueWalker : public scene::Graph::Walker
 {
-  const Classnames& m_classnames;
+  const PropertyValues& m_propertyvalues;
+  const char *m_prop;
 public:
-  EntityFindByClassnameWalker(const Classnames& classnames)
-    : m_classnames(classnames)
+  EntityFindByPropertyValueWalker(const char *prop, const PropertyValues& propertyvalues)
+    : m_propertyvalues(propertyvalues), m_prop(prop)
   {
   }
   bool pre(const scene::Path& path, scene::Instance& instance) const
   {
     Entity* entity = Node_getEntity(path.top());
     if(entity != 0
-      && classnames_match_entity(m_classnames, entity))
+      && propertyvalues_contain(m_propertyvalues, entity->getKeyValue(m_prop)))
     {
       Instance_getSelectable(instance)->setSelected(true);
     }
@@ -692,17 +694,18 @@ public:
   }
 };
 
-void Scene_EntitySelectByClassnames(scene::Graph& graph, const Classnames& classnames)
+void Scene_EntitySelectByPropertyValues(scene::Graph& graph, const char *prop, const PropertyValues& propertyvalues)
 {
-  graph.traverse(EntityFindByClassnameWalker(classnames));
+  graph.traverse(EntityFindByPropertyValueWalker(prop, propertyvalues));
 }
 
-class EntityGetSelectedClassnamesWalker : public scene::Graph::Walker
+class EntityGetSelectedPropertyValuesWalker : public scene::Graph::Walker
 {
-  Classnames& m_classnames;
+  PropertyValues& m_propertyvalues;
+  const char *m_prop;
 public:
-  EntityGetSelectedClassnamesWalker(Classnames& classnames)
-    : m_classnames(classnames)
+  EntityGetSelectedPropertyValuesWalker(const char *prop, PropertyValues& propertyvalues)
+    : m_propertyvalues(propertyvalues), m_prop(prop)
   {
   }
   bool pre(const scene::Path& path, scene::Instance& instance) const
@@ -714,16 +717,17 @@ public:
       Entity* entity = Node_getEntity(path.top());
       if(entity != 0)
       {
-        m_classnames.push_back(entity->getKeyValue("classname"));
+       if(!propertyvalues_contain(m_propertyvalues, entity->getKeyValue(m_prop)))
+          m_propertyvalues.push_back(entity->getKeyValue(m_prop));
       }
     }
     return true;
   }
 };
 
-void Scene_EntityGetClassnames(scene::Graph& graph, Classnames& classnames)
+void Scene_EntityGetPropertyValues(scene::Graph& graph, const char *prop, PropertyValues& propertyvalues)
 {
-  graph.traverse(EntityGetSelectedClassnamesWalker(classnames));
+  graph.traverse(EntityGetSelectedPropertyValuesWalker(prop, propertyvalues));
 }
 
 void Select_AllOfType()
@@ -738,12 +742,15 @@ void Select_AllOfType()
   }
   else
   {
-    Classnames classnames;
-    Scene_EntityGetClassnames(GlobalSceneGraph(), classnames);
+    PropertyValues propertyvalues;
+    const char *prop = EntityInspector_getCurrentKey();
+    if(!prop || !*prop)
+      prop = "classname";
+    Scene_EntityGetPropertyValues(GlobalSceneGraph(), prop, propertyvalues);
     GlobalSelectionSystem().setSelectedAll(false);
-    if(!classnames.empty())
+    if(!propertyvalues.empty())
     {
-      Scene_EntitySelectByClassnames(GlobalSceneGraph(), classnames);
+      Scene_EntitySelectByPropertyValues(GlobalSceneGraph(), prop, propertyvalues);
     }
     else
     {