File indexing completed on 2024-05-12 05:39:27
0001 /*************************************************************************** 0002 * Copyright (C) 2015 by Renaud Guezennec * 0003 * https://rolisteam.org/contact * 0004 * * 0005 * rolisteam is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 #include "helpnode.h" 0021 0022 HelpNode::HelpNode() : m_path("https://invent.kde.org/rolisteam/rolisteam-diceparser/-/blob/master/HelpMe.md") 0023 { 0024 m_result= new StringResult(); 0025 } 0026 void HelpNode::run(ExecutionNode* previous) 0027 { 0028 m_previousNode= previous; 0029 StringResult* txtResult= dynamic_cast<StringResult*>(m_result); 0030 txtResult->setHighLight(false); 0031 0032 if((nullptr == previous) && (txtResult != nullptr)) 0033 { 0034 txtResult->addText(QObject::tr("Rolisteam Dice Parser:\n" 0035 "\n" 0036 "Example (with ! as prefix):\n" 0037 "!2d6\n" 0038 "!1d20\n" 0039 "!6d10e10k3 (L5R)\n" 0040 "\n" 0041 "Full documentation at: %1") 0042 .arg(m_path)); 0043 m_result->setPrevious(nullptr); 0044 } 0045 else if(nullptr != previous) 0046 { 0047 txtResult->addText(previous->getHelp()); 0048 m_result->setPrevious(previous->getResult()); 0049 } 0050 txtResult->finished(); 0051 0052 if(nullptr != m_nextNode) 0053 { 0054 m_nextNode->run(this); 0055 } 0056 } 0057 QString HelpNode::toString(bool wl) const 0058 { 0059 if(wl) 0060 { 0061 return QString("%1 [label=\"%3 : %2\"]").arg(m_id, m_path, tr("Rolisteam Dice Parser:\nFull documentation at")); 0062 } 0063 else 0064 { 0065 return m_id; 0066 } 0067 } 0068 0069 qint64 HelpNode::getPriority() const 0070 { 0071 return 0; 0072 } 0073 void HelpNode::setHelpPath(QString path) 0074 { 0075 m_path= path; 0076 } 0077 0078 ExecutionNode* HelpNode::getCopy() const 0079 { 0080 HelpNode* node= new HelpNode(); 0081 if(nullptr != m_nextNode) 0082 { 0083 node->setNextNode(m_nextNode->getCopy()); 0084 } 0085 return node; 0086 }