diff options
| author | 2015-03-03 23:00:11 +0100 | |
|---|---|---|
| committer | 2015-03-03 23:00:11 +0100 | |
| commit | 30aaf7a35bc6e8224ad683148af28cedf81f03fd (patch) | |
| tree | 4ef6e1451a62d852d4b83f2bb2a89e7940a33c6d | |
| parent | 343f0d6b839d3f9a4740733cf2148b136ef8e00d (diff) | |
| download | OneRoll-30aaf7a35bc6e8224ad683148af28cedf81f03fd.tar.gz OneRoll-30aaf7a35bc6e8224ad683148af28cedf81f03fd.zip | |
Add gui and new node.
| -rw-r--r-- | gui/gui.pri | 10 | ||||
| -rw-r--r-- | gui/mainwindow.cpp | 31 | ||||
| -rw-r--r-- | gui/mainwindow.h | 26 | ||||
| -rw-r--r-- | gui/mainwindow.ui | 75 | ||||
| -rw-r--r-- | node/jumpbackwardnode.cpp | 38 | ||||
| -rw-r--r-- | node/jumpbackwardnode.h | 27 |
6 files changed, 207 insertions, 0 deletions
diff --git a/gui/gui.pri b/gui/gui.pri new file mode 100644 index 0000000..c31fd79 --- /dev/null +++ b/gui/gui.pri @@ -0,0 +1,10 @@ +QT += gui + +FORMS += \ + $$PWD/mainwindow.ui + +HEADERS += \ + $$PWD/mainwindow.h + +SOURCES += \ + $$PWD/mainwindow.cpp diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp new file mode 100644 index 0000000..5ec6e87 --- /dev/null +++ b/gui/mainwindow.cpp @@ -0,0 +1,31 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + + +#include "diceparser.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + connect(ui->m_rollButton,SIGNAL(pressed()),this,SLOT(rollDiceCommand())); + m_dieParser = new DiceParser(); +} + +MainWindow::~MainWindow() +{ + delete ui; +} +void MainWindow::rollDiceCommand() +{ + QString cmd = ui->m_cmdEdit->text(); + + if(m_dieParser->parseLine(cmd)) + { + m_dieParser->Start(); + m_dieParser->displayResult(); + } + +} diff --git a/gui/mainwindow.h b/gui/mainwindow.h new file mode 100644 index 0000000..d910ad6 --- /dev/null +++ b/gui/mainwindow.h @@ -0,0 +1,26 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QMainWindow> + +class DiceParser; +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +protected slots: + void rollDiceCommand(); +private: + Ui::MainWindow *ui; + DiceParser* m_dieParser; +}; + +#endif // MAINWINDOW_H diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui new file mode 100644 index 0000000..d09f866 --- /dev/null +++ b/gui/mainwindow.ui @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>600</height> + </rect> + </property> + <property name="windowTitle"> + <string>MainWindow</string> + </property> + <widget class="QWidget" name="centralwidget"> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLineEdit" name="m_cmdEdit"/> + </item> + <item> + <widget class="QPushButton" name="m_rollButton"> + <property name="text"> + <string>Roll</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1"> + <item> + <widget class="QListView" name="m_historicView"/> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QWidget" name="m_display" native="true"/> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>29</height> + </rect> + </property> + </widget> + <widget class="QStatusBar" name="statusbar"/> + </widget> + <resources/> + <connections/> +</ui> diff --git a/node/jumpbackwardnode.cpp b/node/jumpbackwardnode.cpp new file mode 100644 index 0000000..c311ed2 --- /dev/null +++ b/node/jumpbackwardnode.cpp @@ -0,0 +1,38 @@ +#include "jumpbackwardnode.h" + +JumpBackwardNode::JumpBackwardNode() +{ +} + + + +qint64 JumpBackwardNode::getPriority() const +{ + return 1; +} +QString JumpBackwardNode::toString() const +{ + return QString(); +} +void JumpBackwardNode::run(ExecutionNode* previous) +{ + ExecutionNode* parent = previous; + bool found=false; + int i = 1; + Result* result=NULL; + while((NULL!=parent)&&(found)) + { + result = parent->getResult(); + if(NULL!=result) + { + --i; + if(i==0) + { + found =true; + } + } + parent = parent->getPreviousNode(); + + } + m_result = result; +} diff --git a/node/jumpbackwardnode.h b/node/jumpbackwardnode.h new file mode 100644 index 0000000..d211385 --- /dev/null +++ b/node/jumpbackwardnode.h @@ -0,0 +1,27 @@ +#ifndef JUMPBACKWARDNODE_H +#define JUMPBACKWARDNODE_H + +#include "executionnode.h" + +class JumpBackwardNode : public ExecutionNode +{ +public: + JumpBackwardNode(); + + virtual void run(ExecutionNode* previous = NULL); + + /** + * @brief toString + * @return + */ + virtual QString toString() const; + /** + * @brief getPriority + * @return + */ + virtual qint64 getPriority() const; + + +}; + +#endif // JUMPBACKWARDNODE_H |