diff --git a/software/chip32/chip32_vm.c b/software/chip32/chip32_vm.c index ef2aabc..4d08d68 100644 --- a/software/chip32/chip32_vm.c +++ b/software/chip32/chip32_vm.c @@ -193,22 +193,22 @@ chip32_result_t chip32_step(chip32_ctx_t *ctx) const uint8_t reg = _NEXT_BYTE; _CHECK_REGISTER_VALID(reg) ctx->registers[PC] = ctx->registers[reg] - 1; - // save all temporary registers on stack - ctx->registers[SP] -= 4*10; // reserve memory - // fill memory - for (int i = 0; i < 10; i++) { - leu32_put(&ctx->ram.mem[ctx->registers[SP] + i*4], ctx->registers[T0 + i]); - } +// // save all temporary registers on stack +// ctx->registers[SP] -= 4*10; // reserve memory +// // fill memory +// for (int i = 0; i < 10; i++) { +// leu32_put(&ctx->ram.mem[ctx->registers[SP] + i*4], ctx->registers[T0 + i]); +// } break; } case OP_RET: { ctx->registers[PC] = ctx->registers[RA] - 1; // restore all temporary registers on stack - for (int i = 0; i < 10; i++) { - ctx->registers[T0 + i] = leu32_get(&ctx->ram.mem[ctx->registers[SP] + i*4]); - } - ctx->registers[SP] += 4*10; // free memory +// for (int i = 0; i < 10; i++) { +// ctx->registers[T0 + i] = leu32_get(&ctx->ram.mem[ctx->registers[SP] + i*4]); +// } +// ctx->registers[SP] += 4*10; // free memory break; } case OP_STORE: diff --git a/software/chip32/chip32_vm.h b/software/chip32/chip32_vm.h index cc97d77..54e6abc 100644 --- a/software/chip32/chip32_vm.h +++ b/software/chip32/chip32_vm.h @@ -108,7 +108,7 @@ typedef enum R7, R8, R9, - // Temporaties are automatically saved on stack across a call + // Temporaries are automatically saved on stack across a call T0, T1, T2, diff --git a/story-editor/assets/check-mark.png b/story-editor/assets/check-mark.png new file mode 100644 index 0000000..9a25900 Binary files /dev/null and b/story-editor/assets/check-mark.png differ diff --git a/story-editor/assets/home.png b/story-editor/assets/home.png new file mode 100644 index 0000000..f7698bf Binary files /dev/null and b/story-editor/assets/home.png differ diff --git a/story-editor/assets/left.png b/story-editor/assets/left.png new file mode 100644 index 0000000..7fd799b Binary files /dev/null and b/story-editor/assets/left.png differ diff --git a/story-editor/assets/pause-button.png b/story-editor/assets/pause-button.png new file mode 100644 index 0000000..9aa3e3c Binary files /dev/null and b/story-editor/assets/pause-button.png differ diff --git a/story-editor/assets/right.png b/story-editor/assets/right.png new file mode 100644 index 0000000..e274d8b Binary files /dev/null and b/story-editor/assets/right.png differ diff --git a/story-editor/nodeeditor b/story-editor/nodeeditor index e1c9ee8..d5250cd 160000 --- a/story-editor/nodeeditor +++ b/story-editor/nodeeditor @@ -1 +1 @@ -Subproject commit e1c9ee891129e24c5703d5044509faabd8725923 +Subproject commit d5250cd445a6fa2177075603f1ca5580c3498c8e diff --git a/story-editor/scripts/media.asm b/story-editor/scripts/media.asm index 112e139..0dff347 100644 --- a/story-editor/scripts/media.asm +++ b/story-editor/scripts/media.asm @@ -9,25 +9,24 @@ ; t2: increment 4 ; t3: current media address ; t4: where to jump when OK button is pressed + ; t5: address of the "choice" array + mov t5, r0 ; we save R0 .media_loop_start: - load t0, @r0, 4 ; Le premier élément est le nombre de choix possibles, t0 = 3 (exemple) + load t0, @t5, 4 ; Le premier élément est le nombre de choix possibles, t0 = 3 (exemple) lcons t1, 1 lcons t2, 4 - mov t3, r0 + mov t3, t5 .media_loop: add t3, t2 ; @++ - ; --------- We call a media transition node - push r0 ; save r0 - load r0, @t3, 4 ; r0 = content in ram at address in T4 + load r0, @t3, 4 ; r0 = content in ram at address in T3 call r0 ; call subroutine ; Return argument in R0: the address of the node to call whe OK is pressed ; save it in t4 mov t4, r0 - pop r0 ; wait for event (OK or wheel) syscall 2 diff --git a/story-editor/src/code_editor.cpp b/story-editor/src/code_editor.cpp index 77c45c6..e83ecbe 100644 --- a/story-editor/src/code_editor.cpp +++ b/story-editor/src/code_editor.cpp @@ -4,8 +4,6 @@ #include #include -//![constructor] - CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent) { lineNumberArea = new LineNumberArea(this); @@ -14,6 +12,8 @@ CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent) connect(this, &CodeEditor::updateRequest, this, &CodeEditor::updateLineNumberArea); connect(this, &CodeEditor::cursorPositionChanged, this, &CodeEditor::highlightCurrentLine); + connect(lineNumberArea, &LineNumberArea::sigLineNumberAreaClicked, this, &CodeEditor::sigLineNumberAreaClicked); + setTabStopDistance(QFontMetricsF(font()).horizontalAdvance(' ') * 4); updateLineNumberAreaWidth(0); @@ -100,6 +100,14 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) painter.setPen(Qt::black); painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(), Qt::AlignRight, number); + + if (m_breakpoints.contains(blockNumber +1)) + { + QRectF rectangle(0, top, fontMetrics().height(), fontMetrics().height()); + painter.setPen(Qt::red); + painter.setBrush(QBrush(Qt::red)); + painter.drawEllipse(rectangle); + } } block = block.next(); @@ -109,4 +117,46 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) } } -//![extraAreaPaintEvent_2] + +int CodeEditor::ComputeLine(const QPointF &p) +{ + int line = -1; + + QTextBlock block = firstVisibleBlock(); + + while (block.isValid()) + { + int top = qRound(blockBoundingGeometry(block).top()); + int bottom = top + qRound(blockBoundingRect(block).height()); + + if ((p.y() >= top) && (p.y() <= bottom)) + { + line = block.blockNumber() + 1; + break; + } + + block = block.next(); + } + + return line; +} + +void CodeEditor::SetBreakPoints(const std::set &bkp) +{ + m_breakpoints = bkp; + update(); +} + + +void LineNumberArea::mouseReleaseEvent(QMouseEvent *event) { + if (event->button() == Qt::LeftButton) + { + QPointF p = event->position(); + int line = codeEditor->ComputeLine(p); +// qDebug() << "Clicked line: " << line; + if (line >= 0) + { + emit sigLineNumberAreaClicked(line); + } + } +} diff --git a/story-editor/src/code_editor.h b/story-editor/src/code_editor.h index e851b85..d3a920d 100644 --- a/story-editor/src/code_editor.h +++ b/story-editor/src/code_editor.h @@ -2,6 +2,7 @@ #define CODEEDITOR_H #include +#include QT_BEGIN_NAMESPACE class QPaintEvent; @@ -12,7 +13,6 @@ QT_END_NAMESPACE class LineNumberArea; -//![codeeditordefinition] class CodeEditor : public QPlainTextEdit { @@ -24,6 +24,12 @@ public: void lineNumberAreaPaintEvent(QPaintEvent *event); int lineNumberAreaWidth(); + int ComputeLine(const QPointF &p); + void SetBreakPoints(const std::set & bkp); + +signals: + void sigLineNumberAreaClicked(int line); + protected: void resizeEvent(QResizeEvent *event) override; @@ -33,14 +39,15 @@ private slots: void updateLineNumberArea(const QRect &rect, int dy); private: - QWidget *lineNumberArea; + LineNumberArea *lineNumberArea; + std::set m_breakpoints; }; -//![codeeditordefinition] -//![extraarea] class LineNumberArea : public QWidget { + Q_OBJECT + public: LineNumberArea(CodeEditor *editor) : QWidget(editor), codeEditor(editor) {} @@ -50,6 +57,11 @@ public: return QSize(codeEditor->lineNumberAreaWidth(), 0); } + void mouseReleaseEvent(QMouseEvent *event) override; + +signals: + void sigLineNumberAreaClicked(int line); + protected: void paintEvent(QPaintEvent *event) override { diff --git a/story-editor/src/main_window.cpp b/story-editor/src/main_window.cpp index 7e53a8d..d164da1 100644 --- a/story-editor/src/main_window.cpp +++ b/story-editor/src/main_window.cpp @@ -70,8 +70,6 @@ MainWindow::MainWindow() addToolBar(Qt::LeftToolBarArea, m_toolbar); m_toolbar->setVisible(true); - connect(m_toolbar, &ToolBar::sigDefaultDocksPosition, this, &MainWindow::slotDefaultDocksPosition); - createStatusBar(); m_logDock = new LogDock(); @@ -82,10 +80,6 @@ MainWindow::MainWindow() addDockWidget(Qt::DockWidgetArea::RightDockWidgetArea, m_ostHmiDock); m_toolbar->AddDockToMenu(m_ostHmiDock->toggleViewAction(), m_ostHmiDock); - connect(m_ostHmiDock, &OstHmiDock::sigOkButton, [&]() { - QCoreApplication::postEvent(this, new VmEvent(VmEvent::evOkButton)); - }); - m_resourcesDock = new ResourcesDock(m_project, m_resourceModel); addDockWidget(Qt::DockWidgetArea::RightDockWidgetArea, m_resourcesDock); m_toolbar->AddDockToMenu(m_resourcesDock->toggleViewAction(), m_resourcesDock); @@ -98,18 +92,6 @@ MainWindow::MainWindow() addDockWidget(Qt::DockWidgetArea::RightDockWidgetArea, m_vmDock); m_toolbar->AddDockToMenu(m_vmDock->toggleViewAction(), m_vmDock); - connect(m_vmDock, &VmDock::sigCompile, [&]() { - // m_scriptEditorDock->setScript(m_project.BuildResources()); - }); - - connect(m_vmDock, &VmDock::sigStepInstruction, [&]() { - QCoreApplication::postEvent(this, new VmEvent(VmEvent::evStep)); - }); - - connect(m_vmDock, &VmDock::sigBuild, [&]() { - BuildScript(); - }); - m_ramView = new MemoryViewDock("RamViewDock", "RAM"); addDockWidget(Qt::DockWidgetArea::RightDockWidgetArea, m_ramView); m_toolbar->AddDockToMenu(m_ramView->toggleViewAction(), m_ramView); @@ -125,6 +107,71 @@ MainWindow::MainWindow() m_chooseFileUi.setupUi(m_chooseFileDialog); m_chooseFileDialog->close(); + m_newProjectDialog = new NewProjectDialog(this); + m_newProjectDialog->hide(); + + // TODO: merge both + m_model.registerNode("MediaNode"); + m_model.addModel("MediaNode", "Story Teller"); + + // Prepare run timer + m_runTimer = new QTimer(this); + m_runTimer->setSingleShot(true); + + // VM Initialize + m_chip32_ctx.stack_size = 512; + + m_chip32_ctx.rom.mem = m_rom_data; + m_chip32_ctx.rom.addr = 0; + m_chip32_ctx.rom.size = sizeof(m_rom_data); + + m_chip32_ctx.ram.mem = m_ram_data; + m_chip32_ctx.ram.addr = sizeof(m_rom_data); + m_chip32_ctx.ram.size = sizeof(m_ram_data); + + Callback::func = std::bind(&MainWindow::Syscall, this, std::placeholders::_1); + m_chip32_ctx.syscall = static_cast(Callback::callback); + + // Install event handler now that everything is initialized + Callback::func = std::bind(&MainWindow::MessageOutput, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); + auto cb = static_cast(Callback::callback); + + qInstallMessageHandler(cb); + + readSettings(); // restore all windows preferences + qDebug() << "Settings location: " << m_settings.fileName(); + qDebug() << "Welcome to StoryTeller Editor"; + + CloseProject(); + RefreshProjectInformation(); + + // =================================== CONNECTIONS =================================== + connect(m_toolbar, &ToolBar::sigDefaultDocksPosition, this, &MainWindow::slotDefaultDocksPosition); + + connect(m_ostHmiDock, &OstHmiDock::sigOkButton, [&]() { + QCoreApplication::postEvent(this, new VmEvent(VmEvent::evOkButton)); + }); + + connect(m_ostHmiDock, &OstHmiDock::sigLeftButton, [&]() { + QCoreApplication::postEvent(this, new VmEvent(VmEvent::evLeftButton)); + }); + + connect(m_ostHmiDock, &OstHmiDock::sigRightButton, [&]() { + QCoreApplication::postEvent(this, new VmEvent(VmEvent::evRightButton)); + }); + + connect(m_vmDock, &VmDock::sigCompile, [&]() { + // m_scriptEditorDock->setScript(m_project.BuildResources()); + }); + + connect(m_vmDock, &VmDock::sigStepInstruction, [&]() { + QCoreApplication::postEvent(this, new VmEvent(VmEvent::evStep)); + }); + + connect(m_vmDock, &VmDock::sigBuild, [&]() { + BuildScript(); + }); + connect(&m_model, &StoryGraphModel::sigChooseFile, [&](NodeId id, const QString &type) { m_chooseFileUi.tableView->setModel(&m_resourcesDock->getModel()); m_chooseFileDialog->exec(); @@ -145,33 +192,6 @@ MainWindow::MainWindow() } }); - m_newProjectDialog = new NewProjectDialog(this); - m_newProjectDialog->hide(); - - // TODO: merge both - m_model.registerNode("MediaNode"); - m_model.addModel("MediaNode", "Story Teller"); - -// m_project.Load("packs/BE8949F60D854F54828419A1BDAED36A/pack.json"); - -// DisplayNode(m_project.m_tree, QtNodes::InvalidNodeId); - - // VM Initialize - - m_chip32_ctx.stack_size = 512; - - m_chip32_ctx.rom.mem = m_rom_data; - m_chip32_ctx.rom.addr = 0; - m_chip32_ctx.rom.size = sizeof(m_rom_data); - - m_chip32_ctx.ram.mem = m_ram_data; - m_chip32_ctx.ram.addr = sizeof(m_rom_data); - m_chip32_ctx.ram.size = sizeof(m_ram_data); - - - Callback::func = std::bind(&MainWindow::Syscall, this, std::placeholders::_1); - m_chip32_ctx.syscall = static_cast(Callback::callback); - connect(m_toolbar, &ToolBar::sigNew, this, [&]() { NewProject(); }); @@ -181,7 +201,7 @@ MainWindow::MainWindow() }); connect(m_toolbar, &ToolBar::sigOpen, this, [&]() { - OpenProjectDialog(); + OpenProjectDialog(); }); connect(m_toolbar, &ToolBar::sigClose, this, [&]() { @@ -201,26 +221,15 @@ MainWindow::MainWindow() BuildAndRun(); }); - // Install event handler now that everythin is initialized - Callback::func = std::bind(&MainWindow::MessageOutput, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); - auto cb = static_cast(Callback::callback); - - - qInstallMessageHandler(cb); - - readSettings(); // restore all windows preferences - qDebug() << "Settings location: " << m_settings.fileName(); - qDebug() << "Welcome to StoryTeller Editor"; - - CloseProject(); - RefreshProjectInformation(); - - // Prepare run timer - m_runTimer = new QTimer(this); - m_runTimer->setSingleShot(true); connect(m_runTimer, &QTimer::timeout, this, [&]() { if (m_dbg.run_result == VM_OK) { + if (m_dbg.m_breakpoints.contains(m_dbg.line + 1)) + { + qDebug() << "Breakpoint on line: " << (m_dbg.line + 1); + m_dbg.free_run = false; + return; + } stepInstruction(); } @@ -231,7 +240,7 @@ MainWindow::MainWindow() } else if (m_dbg.run_result == VM_FINISHED) { - m_dbg.running = false; + m_dbg.free_run = false; } else if (m_dbg.run_result == VM_WAIT_EVENT) { @@ -240,12 +249,29 @@ MainWindow::MainWindow() }); connect(&m_model, &StoryGraphModel::sigAudioStopped, this, [&]() { + QCoreApplication::postEvent(this, new VmEvent(VmEvent::evAudioFinished)); + }); - if ((m_dbg.run_result == VM_WAIT_EVENT) && (m_dbg.running)) + connect(m_scriptEditorDock, &ScriptEditorDock::sigLineNumberAreaClicked, this, [&](int line) { + + // On cherche si une instruction existe à cette ligne + std::vector::const_iterator ptr = m_assembler.Begin(); + for (; ptr != m_assembler.End(); ++ptr) { - m_dbg.run_result = VM_OK; - // Continue execution of node - m_runTimer->start(100); + if ((ptr->line == line) && ptr->isRomCode()) + { + if (m_dbg.m_breakpoints.contains(line)) + { + m_dbg.m_breakpoints.erase(line); + } + else + { + m_dbg.m_breakpoints.insert(line); + } + + m_scriptEditorDock->SetBreakPoints(m_dbg.m_breakpoints); + break; + } } }); @@ -273,7 +299,7 @@ void MainWindow::BuildAndRun() // 4. Run the VM code! if (m_dbg.run_result == VM_OK) { - m_dbg.running = true; + m_dbg.free_run = true; m_runTimer->start(100); } } @@ -433,7 +459,7 @@ void MainWindow::highlightNextLine() else { // Not found - qDebug() << "Reached end or instruction not found: " << m_dbg.line; + qDebug() << "Reached end or instruction not found line: " << m_dbg.line; } } @@ -458,6 +484,25 @@ QString MainWindow::GetFileNameFromMemory(uint32_t addr) return QString(strBuf); } +void MainWindow::EventFinished(uint32_t replyEvent) +{ + if (m_dbg.run_result == VM_WAIT_EVENT) + { + // Result event is in R0 + m_chip32_ctx.registers[R0] = replyEvent; + m_dbg.run_result = VM_OK; + + if (m_dbg.free_run) + { + m_runTimer->start(100); + } + else + { + stepInstruction(); + } + } +} + bool MainWindow::event(QEvent *event) { if (event->type() == VmEvent::evStep) @@ -473,16 +518,19 @@ bool MainWindow::event(QEvent *event) } else if (event->type() == VmEvent::evOkButton) { - VmEvent *myEvent = static_cast(event); - - if (m_dbg.run_result == VM_WAIT_EVENT) - { - // Result event is in R1 - m_chip32_ctx.registers[R1] = 0x01; - m_dbg.run_result = VM_OK; - m_runTimer->start(100); - } - + EventFinished(0x01); + } + else if (event->type() == VmEvent::evLeftButton) + { + EventFinished(0x02); + } + else if (event->type() == VmEvent::evRightButton) + { + EventFinished(0x04); + } + else if (event->type() == VmEvent::evAudioFinished) + { + EventFinished(0x08); } // false means it should be send to target also. as in , we dont remove it. @@ -547,7 +595,7 @@ void MainWindow::stepInstruction() void MainWindow::BuildScript() { m_dbg.run_result = VM_FINISHED; - m_dbg.running = false; + m_dbg.free_run = false; if (m_assembler.Parse(m_scriptEditorDock->getScript().toStdString()) == true ) { diff --git a/story-editor/src/main_window.h b/story-editor/src/main_window.h index 8fb09f0..7e4adfe 100644 --- a/story-editor/src/main_window.h +++ b/story-editor/src/main_window.h @@ -54,10 +54,12 @@ struct DebugContext { uint32_t event_mask{0}; bool wait_event{0}; - bool running{false}; + bool free_run{false}; int line{-1}; chip32_result_t run_result{VM_FINISHED}; + std::set m_breakpoints; + static void DumpCodeAssembler(Chip32::Assembler & assembler) { for (std::vector::const_iterator iter = assembler.Begin(); @@ -109,6 +111,9 @@ public: {} static const QEvent::Type evStep = static_cast(QEvent::User + 1); static const QEvent::Type evOkButton = static_cast(QEvent::User + 2); + static const QEvent::Type evLeftButton = static_cast(QEvent::User + 3); + static const QEvent::Type evRightButton = static_cast(QEvent::User + 4); + static const QEvent::Type evAudioFinished = static_cast(QEvent::User + 5); uint8_t ev{0}; }; @@ -186,6 +191,7 @@ private: void EnableProject(); void OpenProject(const QString &filePath); QString ReadResourceFile(const QString &fileName); + void EventFinished(uint32_t replyEvent); }; #endif // MAIN_WINDOW_H diff --git a/story-editor/src/media_node_model.cpp b/story-editor/src/media_node_model.cpp index 9c6d30e..84a8578 100644 --- a/story-editor/src/media_node_model.cpp +++ b/story-editor/src/media_node_model.cpp @@ -12,7 +12,7 @@ MediaNodeModel::MediaNodeModel(StoryGraphModel &model) : m_model(model) - , m_widget(new QWidget()) + , m_widget(new StoryNodeWidgetBase()) { m_ui.setupUi(m_widget); m_ui.image->setText("Image will appear here"); @@ -73,12 +73,18 @@ MediaNodeModel::MediaNodeModel(StoryGraphModel &model) _nodeStyle.GradientColor2 = bgColor; _nodeStyle.GradientColor3 = bgColor; _nodeStyle.NormalBoundaryColor = bgColor; - _nodeStyle.FontColor = QColor(206, 206, 206); + _nodeStyle.FontColor = Qt::white; _nodeStyle.FontColorFaded = QColor(125, 125, 125); _nodeStyle.ShadowColor = QColor(20, 20, 20); _nodeStyle.ConnectionPointColor = QColor(125, 125, 125); _nodeStyle.FilledConnectionPointColor = QColor(206, 206, 206); + _nodeStyle.SelectedBoundaryColor = QColor(20, 146, 202); + _nodeStyle.Opacity = 1.0; + _nodeStyle.PenWidth = 0; + _nodeStyle.HoveredPenWidth = 2.0; + _nodeStyle.ConnectionPointDiameter = 3.5; + setNodeStyle(_nodeStyle); } @@ -239,12 +245,18 @@ std::string MediaNodeModel::Build() { std::unordered_set conns = m_model.allConnectionIds(getNodeId()); - auto it = conns.begin(); - ++it; - // On place dans R0 le prochain noeud à exécuter en cas de OK - ss << "lcons r0, " - << m_model.GetNodeEntryLabel(it->inNodeId) << "\n" - << "ret\n"; + + for (auto c : conns) + { + if (c.outNodeId == getNodeId()) + { + // On place dans R0 le prochain noeud à exécuter en cas de OK + ss << "lcons r0, " + << m_model.GetNodeEntryLabel(c.inNodeId) << "\n" + << "ret\n"; + } + } + } else // Choice node { @@ -346,3 +358,15 @@ std::string MediaNodeModel::EntryLabel() const ss << ".mediaEntry" << std::setw(4) << std::setfill('0') << getNodeId(); return ss.str(); } + +StoryNodeWidgetBase::StoryNodeWidgetBase() { + // setWindowFlags(Qt::Window | Qt::FramelessWindowHint); + + // setAttribute(Qt::WA_NoSystemBackground); + setAttribute(Qt::WA_TranslucentBackground); + // setAttribute(Qt::WA_PaintOnScreen); + + // setAttribute(Qt::WA_TransparentForMouseEvents); + + setStyleSheet("QLabel { background-color: rgba(0,0,0,0) }; QWidget { background-color: rgba(0,0,0,0) };"); +} diff --git a/story-editor/src/media_node_model.h b/story-editor/src/media_node_model.h index 6c9eab4..e1c235e 100644 --- a/story-editor/src/media_node_model.h +++ b/story-editor/src/media_node_model.h @@ -22,6 +22,13 @@ using QtNodes::PortType; #include "story_graph_model.h" #include "story_node_base.h" +class StoryNodeWidgetBase : public QWidget +{ +public: + StoryNodeWidgetBase(); +private: +}; + /// The model dictates the number of inputs and outputs for the Node. /// In this example it has no logic. class MediaNodeModel : public StoryNodeBase @@ -72,7 +79,7 @@ private: StoryGraphModel &m_model; unsigned int m_ports{1}; - QWidget *m_widget; + StoryNodeWidgetBase *m_widget; QString m_soundFilePath; diff --git a/story-editor/src/ost-editor.qrc b/story-editor/src/ost-editor.qrc index c4f9c51..b8b5ff6 100644 --- a/story-editor/src/ost-editor.qrc +++ b/story-editor/src/ost-editor.qrc @@ -11,5 +11,10 @@ ../assets/welcome.png ../assets/play-circle-green.png ../scripts/media.asm + ../assets/home.png + ../assets/left.png + ../assets/pause-button.png + ../assets/right.png + ../assets/check-mark.png diff --git a/story-editor/src/ost-hmi.ui b/story-editor/src/ost-hmi.ui index 089d5e1..632ecad 100644 --- a/story-editor/src/ost-hmi.ui +++ b/story-editor/src/ost-hmi.ui @@ -7,15 +7,21 @@ 0 0 338 - 443 + 326 + + + 0 + 0 + + Story Teller Emulator - - + + @@ -46,63 +52,140 @@ - - - - Commands - - - - - - - - - - - - - Ok - - - - - - - Home - - - - - - - Pause - - - - - - - - - - - Qt::Vertical - - - - 20 - 129 - - - - - - + + + + + + + 0 + 0 + + + + + + + + :/assets/left.png:/assets/left.png + + + + 45 + 35 + + + + + + + + + + + + :/assets/check-mark.png:/assets/check-mark.png + + + + 35 + 35 + + + + false + + + + + + + + 0 + 0 + + + + + + + + :/assets/right.png:/assets/right.png + + + + 45 + 35 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + + + + :/assets/pause-button.png:/assets/pause-button.png + + + + 30 + 30 + + + + + + + + + 0 + 0 + + + + + + + + :/assets/home.png:/assets/home.png + + + + 30 + 30 + + + + + - + + + diff --git a/story-editor/src/osthmi_dock.cpp b/story-editor/src/osthmi_dock.cpp index 9680954..b5ef77b 100644 --- a/story-editor/src/osthmi_dock.cpp +++ b/story-editor/src/osthmi_dock.cpp @@ -9,6 +9,8 @@ OstHmiDock::OstHmiDock() m_uiOstDisplay.setupUi(this); connect(m_uiOstDisplay.okButton, &QPushButton::clicked, this, &OstHmiDock::sigOkButton); + connect(m_uiOstDisplay.leftButton, &QPushButton::clicked, this, &OstHmiDock::sigLeftButton); + connect(m_uiOstDisplay.rightButton, &QPushButton::clicked, this, &OstHmiDock::sigRightButton); } void OstHmiDock::SetImage(const QString &fileName) diff --git a/story-editor/src/osthmi_dock.h b/story-editor/src/osthmi_dock.h index 74238ce..a610e3a 100644 --- a/story-editor/src/osthmi_dock.h +++ b/story-editor/src/osthmi_dock.h @@ -15,6 +15,8 @@ public: signals: void sigOkButton(); + void sigLeftButton(); + void sigRightButton(); private: Ui::ostDisplay m_uiOstDisplay; diff --git a/story-editor/src/script_editor_dock.cpp b/story-editor/src/script_editor_dock.cpp index 989822e..6912117 100644 --- a/story-editor/src/script_editor_dock.cpp +++ b/story-editor/src/script_editor_dock.cpp @@ -9,6 +9,8 @@ ScriptEditorDock::ScriptEditorDock() m_editor = new CodeEditor(this); m_highlighter = new Highlighter(m_editor->document()); setWidget(m_editor); + + connect(m_editor, &CodeEditor::sigLineNumberAreaClicked, this, &ScriptEditorDock::sigLineNumberAreaClicked); } void ScriptEditorDock::HighlightLine(int line) @@ -25,3 +27,8 @@ QString ScriptEditorDock::getScript() const { return m_editor->toPlainText(); } + +void ScriptEditorDock::SetBreakPoints(const std::set &bkp) +{ + m_editor->SetBreakPoints(bkp); +} diff --git a/story-editor/src/script_editor_dock.h b/story-editor/src/script_editor_dock.h index 7e01f17..2b459f6 100644 --- a/story-editor/src/script_editor_dock.h +++ b/story-editor/src/script_editor_dock.h @@ -17,6 +17,11 @@ public: void setScript(const std::string &script); QString getScript() const; + void SetBreakPoints(const std::set & bkp); + +signals: + void sigLineNumberAreaClicked(int line); + private: CodeEditor *m_editor{nullptr}; Highlighter *m_highlighter; diff --git a/story-editor/src/story_graph_model.cpp b/story-editor/src/story_graph_model.cpp index 0d2600c..c2790d0 100644 --- a/story-editor/src/story_graph_model.cpp +++ b/story-editor/src/story_graph_model.cpp @@ -186,8 +186,7 @@ QVariant StoryGraphModel::nodeData(NodeId nodeId, NodeRole role) const break; case NodeRole::Style: { - auto style = StyleCollection::nodeStyle(); - result = style.toJson().toVariantMap(); + result = model->nodeStyle().toJson().toVariantMap(); } break; case NodeRole::InternalData: