BGE patch: add Debug button next to object state. The object state mask will be print...
[blender-staging.git] / source / gameengine / Ketsji / KX_KetsjiEngine.cpp
index c7b0d7b3ea34c7177c56493d8391076a6bf23450..b1ab8e3e7def86b45319bf697404dc7394b2ba5e 100644 (file)
@@ -1243,19 +1243,49 @@ void KX_KetsjiEngine::RenderDebugProperties()
                                CValue* propobj = (*it)->m_obj;
                                STR_String objname = propobj->GetName();
                                STR_String propname = (*it)->m_name;
                                CValue* propobj = (*it)->m_obj;
                                STR_String objname = propobj->GetName();
                                STR_String propname = (*it)->m_name;
-                               CValue* propval = propobj->GetProperty(propname);
-                               if (propval)
+                               if (propname == "__state__")
                                {
                                {
-                                       STR_String text = propval->GetText();
-                                       debugtxt = objname + "." + propname + " = " + text;
+                                       // reserve name for object state
+                                       KX_GameObject* gameobj = static_cast<KX_GameObject*>(propobj);
+                                       unsigned int state = gameobj->GetState();
+                                       debugtxt = objname + "." + propname + " = ";
+                                       bool first = true;
+                                       for (int statenum=1;state;state >>= 1, statenum++)
+                                       {
+                                               if (state & 1)
+                                               {
+                                                       if (!first)
+                                                       {
+                                                               debugtxt += ",";
+                                                       }
+                                                       debugtxt += STR_String(statenum);
+                                                       first = false;
+                                               }
+                                       }
                                        m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, 
                                        m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, 
-                                                                                               debugtxt.Ptr(),
-                                                                                               xcoord,
-                                                                                               ycoord,
-                                                                                               m_canvas->GetWidth(),
-                                                                                               m_canvas->GetHeight());
+                                                                                                       debugtxt.Ptr(),
+                                                                                                       xcoord,
+                                                                                                       ycoord,
+                                                                                                       m_canvas->GetWidth(),
+                                                                                                       m_canvas->GetHeight());
                                        ycoord += 14;
                                }
                                        ycoord += 14;
                                }
+                               else
+                               {
+                                       CValue* propval = propobj->GetProperty(propname);
+                                       if (propval)
+                                       {
+                                               STR_String text = propval->GetText();
+                                               debugtxt = objname + "." + propname + " = " + text;
+                                               m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, 
+                                                                                                       debugtxt.Ptr(),
+                                                                                                       xcoord,
+                                                                                                       ycoord,
+                                                                                                       m_canvas->GetWidth(),
+                                                                                                       m_canvas->GetHeight());
+                                               ycoord += 14;
+                                       }
+                               }
                        }
                }
        }
                        }
                }
        }