aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/node/paintnode.cpp
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2022-04-29 10:48:09 +0200
committerRenaud G <renaud@rolisteam.org>2022-04-29 10:48:09 +0200
commit07c5f6ec23fcf9237a24e71adcfacabce677f818 (patch)
tree588e8c5f82b9163181fad3581f610e6f1d88cba4 /node/paintnode.cpp
parenta9153f1615a842cfb9e9bcda4d9071e202618569 (diff)
downloadOneRoll-07c5f6ec23fcf9237a24e71adcfacabce677f818.tar.gz
OneRoll-07c5f6ec23fcf9237a24e71adcfacabce677f818.zip
Change file organization.
Diffstat (limited to 'node/paintnode.cpp')
-rw-r--r--node/paintnode.cpp125
1 files changed, 0 insertions, 125 deletions
diff --git a/node/paintnode.cpp b/node/paintnode.cpp
deleted file mode 100644
index 22c020e..0000000
--- a/node/paintnode.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2015 by Renaud Guezennec *
- * http:://www.rolisteam.org/contact *
- * *
- * rolisteam is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-#include "paintnode.h"
-
-ColorItem::ColorItem(QString str, int val) : m_colorNumber(val), m_color(str) {}
-
-int ColorItem::colorNumber() const
-{
- return m_colorNumber;
-}
-
-void ColorItem::setColorNumber(int colorNumber)
-{
- m_colorNumber= colorNumber;
-}
-
-QString ColorItem::color() const
-{
- return m_color;
-}
-
-void ColorItem::setColor(const QString& color)
-{
- m_color= color;
-}
-
-///////////////////////////////////
-/// @brief PainterNode::PainterNode
-///////////////////////////////////
-
-PainterNode::PainterNode() : ExecutionNode()
-{
- m_nextNode= nullptr;
-}
-
-PainterNode::~PainterNode()
-{
- m_result= nullptr;
-}
-
-void PainterNode::run(ExecutionNode* previous)
-{
- m_previousNode= previous;
- if(nullptr == previous)
- {
- m_errors.insert(Dice::ERROR_CODE::NO_PREVIOUS_ERROR, QObject::tr("No previous node before Paint operator"));
- return;
- }
- Result* previousResult= previous->getResult();
- if(nullptr == previousResult)
- return;
-
- m_diceResult= dynamic_cast<DiceResult*>(previousResult->getCopy());
- if(nullptr != m_diceResult)
- {
- QList<Die*> diceList= m_diceResult->getResultList();
- int pastDice= 0;
- for(ColorItem& item : m_colors)
- {
- int current= item.colorNumber();
- QList<Die*>::iterator it;
- for(it= diceList.begin() + pastDice; it != diceList.end() && current > 0; ++it)
- {
- (*it)->setColor(item.color());
- --current;
- ++pastDice;
- }
- }
- m_diceResult->setPrevious(previousResult);
- m_result= m_diceResult;
- }
- if(nullptr != m_nextNode)
- {
- m_nextNode->run(this);
- }
-}
-
-QString PainterNode::toString(bool wl) const
-{
- if(wl)
- {
- return QString("%1 [label=\"PainterNode\"]").arg(m_id);
- }
- else
- {
- return m_id;
- }
-}
-
-qint64 PainterNode::getPriority() const
-{
- return 4;
-}
-
-void PainterNode::insertColorItem(QString color, int value)
-{
- ColorItem item(color, value);
- m_colors.append(item);
-}
-ExecutionNode* PainterNode::getCopy() const
-{
- PainterNode* node= new PainterNode();
- if(nullptr != m_nextNode)
- {
- node->setNextNode(m_nextNode->getCopy());
- }
- return node;
-}