From 187774c338c35864a2d3ad1c95ad06e9685c8427 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sat, 22 Jan 2022 00:11:13 +0100 Subject: Fix valueslist with variable values. --- node/valueslistnode.cpp | 2 +- node/variablenode.cpp | 53 +++++++++++++++++++++++++++++++------------------ node/variablenode.h | 2 ++ 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/node/valueslistnode.cpp b/node/valueslistnode.cpp index d378350..33a347d 100644 --- a/node/valueslistnode.cpp +++ b/node/valueslistnode.cpp @@ -20,7 +20,7 @@ void ValuesListNode::run(ExecutionNode* previous) Die* die= new Die(); auto dyna= dynamic_cast(node); if(nullptr != dyna) - die->displayed(); + dyna->setDisplayed(); die->insertRollValue(val); m_diceResult->insertResult(die); } diff --git a/node/variablenode.cpp b/node/variablenode.cpp index f48c254..416be86 100644 --- a/node/variablenode.cpp +++ b/node/variablenode.cpp @@ -9,26 +9,27 @@ void VariableNode::run(ExecutionNode* previous) { auto value= (*m_data)[m_index]; value= ParsingToolBox::getLeafNode(value); - if(nullptr != value) + if(nullptr == value) + return; + + auto result= value->getResult(); + if(!result) + return; + + auto copy= result->getCopy(); + auto diceResult= dynamic_cast(result); + if(nullptr == diceResult) + return; + + for(auto& die : diceResult->getResultList()) + { + die->setDisplayed(false); + } + + m_result= copy; + if(nullptr != m_nextNode) { - auto result= value->getResult(); - if(result) - { - auto copy= result->getCopy(); - auto diceResult= dynamic_cast(result); - if(nullptr != diceResult) - { - for(auto& die : diceResult->getResultList()) - { - die->setDisplayed(false); - } - } - m_result= copy; - if(nullptr != m_nextNode) - { - m_nextNode->run(this); - } - } + m_nextNode->run(this); } } else @@ -37,6 +38,20 @@ void VariableNode::run(ExecutionNode* previous) } } +void VariableNode::setDisplayed() +{ + if(!m_result) + return; + auto diceResult= dynamic_cast(m_result); + if(nullptr == diceResult) + return; + + for(auto& die : diceResult->getResultList()) + { + die->setDisplayed(true); + } +} + QString VariableNode::toString(bool withLabel) const { if(withLabel) diff --git a/node/variablenode.h b/node/variablenode.h index 5306ddb..8bf1cb1 100644 --- a/node/variablenode.h +++ b/node/variablenode.h @@ -25,6 +25,8 @@ public: std::vector* getData() const; void setData(std::vector* data); + void setDisplayed(); + private: quint64 m_index; std::vector* m_data= nullptr; -- cgit v1.2.3-70-g09d2