From 6a1ecee57b66b4ace4766d75fad2f9a7c4e85dd1 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Mon, 7 Jun 2021 11:30:54 +0200 Subject: [PATCH] Show hidden objects in the status bar --- libs/scenelib.h | 7 +++++++ src/map.cpp | 36 ++++++++++++++++++++++++++++++++++++ src/qe3.cpp | 10 +++++++++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/libs/scenelib.h b/libs/scenelib.h index e1c05d4..da422d3 100644 --- a/libs/scenelib.h +++ b/libs/scenelib.h @@ -184,6 +184,9 @@ bool m_isRoot; bool isRoot(){ return m_isRoot; } +bool isHidden(){ + return (m_state == eHidden) ? 1 : 0; +} Node( Symbiot* symbiot, void* node, NodeTypeCastTable& casts ) : m_state( eVisible ), @@ -381,6 +384,10 @@ inline bool Node_isPrimitive( scene::Node& node ){ #endif } +inline bool Node_isHidden( scene::Node& node ){ + return node.isHidden(); +} + class ParentBrushes : public scene::Traversable::Walker { scene::Node& m_parent; diff --git a/src/map.cpp b/src/map.cpp index 5ffa854..5af35a3 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1799,6 +1799,42 @@ std::size_t Scene_countSelectedBrushes(scene::Graph &graph) return count; } + + +class CountHiddenBrushes : public scene::Graph::Walker { + std::size_t &m_count; + mutable std::size_t m_depth; +public: + CountHiddenBrushes(std::size_t &count) : m_count(count), m_depth(0) + { + m_count = 0; + } + + bool pre(const scene::Path &path, scene::Instance &instance) const + { + if (++m_depth != 1 && path.top().get().isRoot()) { + return false; + } + + if (Node_isHidden(path.top())) { + ++m_count; + } + return true; + } + + void post(const scene::Path &path, scene::Instance &instance) const + { + --m_depth; + } +}; + +std::size_t Scene_countHiddenBrushes(scene::Graph &graph) +{ + std::size_t count; + graph.traverse(CountHiddenBrushes(count)); + return count; +} + enum ENodeType { eNodeUnknown, eNodeMap, diff --git a/src/qe3.cpp b/src/qe3.cpp index b972e89..aee9733 100644 --- a/src/qe3.cpp +++ b/src/qe3.cpp @@ -98,11 +98,12 @@ void QE_InitVFS() int g_numbrushes = 0; int g_numentities = 0; +int g_numhidden = 0; void QE_UpdateStatusBar() { char buffer[128]; - sprintf(buffer, "Brushes: %d Entities: %d", g_numbrushes, g_numentities); + sprintf(buffer, "Brushes: %d Entities: %d Hidden: %d", g_numbrushes, g_numentities, g_numhidden); g_pParentWnd->SetStatusText(g_pParentWnd->m_brushcount_status, buffer); } @@ -122,6 +123,13 @@ void QE_entityCountChanged() QE_UpdateStatusBar(); } +std::size_t Scene_countHiddenBrushes(scene::Graph &graph); +void QE_hiddenCountChanged() +{ + g_numhidden = Scene_countHiddenBrushes(GlobalSceneGraph()); + QE_UpdateStatusBar(); +} + bool ConfirmModified(const char *title) { if (!Map_Modified(g_map)) {