Browse Source

Editor: info about selected model (thanks MonkeyFirst for idea)

1vanK 9 years ago
parent
commit
65b639af13

+ 46 - 0
bin/Data/Scripts/Editor/EditorHierarchyWindow.as

@@ -615,6 +615,50 @@ void SelectUIElement(UIElement@ element, bool multiselect)
         hierarchyList.ClearSelection();
         hierarchyList.ClearSelection();
 }
 }
 
 
+// Find the first selected StaticModel/AtimatedModel component or node with it
+Model@ FindFirstSelectedModel()
+{
+    for (uint i = 0; i < selectedComponents.length; ++i)
+    {
+        // Get SM, but also works well for AnimatedModel
+        StaticModel@ sm = cast<StaticModel>(selectedComponents[i]);
+        if (sm !is null && sm.model !is null)
+            return sm.model;
+    }
+
+    for (uint i = 0; i < selectedNodes.length; ++i)
+    {
+        for (uint j = 0; j < selectedNodes[i].numComponents; ++j)
+        {
+            StaticModel@ sm = cast<StaticModel>(selectedNodes[i].components[j]);
+            if (sm !is null && sm.model !is null)
+                return sm.model;
+        }
+    }
+    
+    return null;
+}
+
+void UpdateModelInfo(Model@ model)
+{
+    if (model is null)
+    {
+        modelInfoText.text = "";
+        return;
+    }
+    
+    String infoStr = "Model: " + model.name;
+
+    infoStr += "\n  Morphs: " + model.numMorphs;
+    
+    for (uint g = 0; g < model.numGeometries; ++g)
+    {
+        infoStr += "\n  Geometry " + g + "\n    Lods: " + model.numGeometryLodLevels[g];
+    }
+    
+    modelInfoText.text = infoStr;
+}
+
 void HandleHierarchyListSelectionChange()
 void HandleHierarchyListSelectionChange()
 {
 {
     if (inSelectionModify)
     if (inSelectionModify)
@@ -675,6 +719,8 @@ void HandleHierarchyListSelectionChange()
         }
         }
         editNode = commonNode;
         editNode = commonNode;
     }
     }
+    
+    UpdateModelInfo(FindFirstSelectedModel());
 
 
     // Now check if the component(s) can be edited. If many selected, must have same type or have same edit node
     // Now check if the component(s) can be edited. If many selected, must have same type or have same edit node
     if (!selectedComponents.empty)
     if (!selectedComponents.empty)

+ 5 - 0
bin/Data/Scripts/Editor/EditorView.as

@@ -346,6 +346,7 @@ ViewportContext@ activeViewport;
 
 
 Text@ editorModeText;
 Text@ editorModeText;
 Text@ renderStatsText;
 Text@ renderStatsText;
+Text@ modelInfoText;
 
 
 EditMode editMode = EDIT_MOVE;
 EditMode editMode = EDIT_MOVE;
 AxisMode axisMode = AXIS_WORLD;
 AxisMode axisMode = AXIS_WORLD;
@@ -1110,6 +1111,8 @@ void CreateStatsBar()
     ui.root.AddChild(editorModeText);
     ui.root.AddChild(editorModeText);
     renderStatsText = Text();
     renderStatsText = Text();
     ui.root.AddChild(renderStatsText);
     ui.root.AddChild(renderStatsText);
+    modelInfoText = Text();
+    ui.root.AddChild(modelInfoText);
 }
 }
 
 
 void SetupStatsBarText(Text@ text, Font@ font, int x, int y, HorizontalAlignment hAlign, VerticalAlignment vAlign)
 void SetupStatsBarText(Text@ text, Font@ font, int x, int y, HorizontalAlignment hAlign, VerticalAlignment vAlign)
@@ -1153,11 +1156,13 @@ void UpdateStats(float timeStep)
     {
     {
         SetupStatsBarText(editorModeText, font, 35, 64, HA_LEFT, VA_TOP);
         SetupStatsBarText(editorModeText, font, 35, 64, HA_LEFT, VA_TOP);
         SetupStatsBarText(renderStatsText, font, -4, 64, HA_RIGHT, VA_TOP);
         SetupStatsBarText(renderStatsText, font, -4, 64, HA_RIGHT, VA_TOP);
+        SetupStatsBarText(modelInfoText, font, 35, 88, HA_LEFT, VA_TOP);
     }
     }
     else
     else
     {
     {
         SetupStatsBarText(editorModeText, font, 35, 64, HA_LEFT, VA_TOP);
         SetupStatsBarText(editorModeText, font, 35, 64, HA_LEFT, VA_TOP);
         SetupStatsBarText(renderStatsText, font, 35, 78, HA_LEFT, VA_TOP);
         SetupStatsBarText(renderStatsText, font, 35, 78, HA_LEFT, VA_TOP);
+        SetupStatsBarText(modelInfoText, font, 35, 102, HA_LEFT, VA_TOP);
     }
     }
 }
 }