mirror of
https://github.com/arabine/open-story-teller.git
synced 2025-12-06 17:09:06 +01:00
Working pack! fix VM, new icons...
This commit is contained in:
parent
0112c935d2
commit
b619eaefe6
22 changed files with 424 additions and 175 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
BIN
story-editor/assets/check-mark.png
Normal file
BIN
story-editor/assets/check-mark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
BIN
story-editor/assets/home.png
Normal file
BIN
story-editor/assets/home.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
BIN
story-editor/assets/left.png
Normal file
BIN
story-editor/assets/left.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7 KiB |
BIN
story-editor/assets/pause-button.png
Normal file
BIN
story-editor/assets/pause-button.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
BIN
story-editor/assets/right.png
Normal file
BIN
story-editor/assets/right.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7 KiB |
|
|
@ -1 +1 @@
|
|||
Subproject commit e1c9ee891129e24c5703d5044509faabd8725923
|
||||
Subproject commit d5250cd445a6fa2177075603f1ca5580c3498c8e
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
#include <QTextBlock>
|
||||
#include <QFontMetrics>
|
||||
|
||||
//![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<int> &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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define CODEEDITOR_H
|
||||
|
||||
#include <QPlainTextEdit>
|
||||
#include <set>
|
||||
|
||||
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<int> & 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<int> 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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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<MediaNodeModel>("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<uint8_t(uint8_t)>::func = std::bind(&MainWindow::Syscall, this, std::placeholders::_1);
|
||||
m_chip32_ctx.syscall = static_cast<syscall_t>(Callback<uint8_t(uint8_t)>::callback);
|
||||
|
||||
// Install event handler now that everything is initialized
|
||||
Callback<void(QtMsgType , const QMessageLogContext &, const QString &)>::func = std::bind(&MainWindow::MessageOutput, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||
auto cb = static_cast<message_output_t>(Callback<void(QtMsgType , const QMessageLogContext &, const QString &)>::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<MediaNodeModel>("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<uint8_t(uint8_t)>::func = std::bind(&MainWindow::Syscall, this, std::placeholders::_1);
|
||||
m_chip32_ctx.syscall = static_cast<syscall_t>(Callback<uint8_t(uint8_t)>::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<void(QtMsgType , const QMessageLogContext &, const QString &)>::func = std::bind(&MainWindow::MessageOutput, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||
auto cb = static_cast<message_output_t>(Callback<void(QtMsgType , const QMessageLogContext &, const QString &)>::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<Chip32::Instr>::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<VmEvent *>(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 )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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<int> m_breakpoints;
|
||||
|
||||
static void DumpCodeAssembler(Chip32::Assembler & assembler) {
|
||||
|
||||
for (std::vector<Chip32::Instr>::const_iterator iter = assembler.Begin();
|
||||
|
|
@ -109,6 +111,9 @@ public:
|
|||
{}
|
||||
static const QEvent::Type evStep = static_cast<QEvent::Type>(QEvent::User + 1);
|
||||
static const QEvent::Type evOkButton = static_cast<QEvent::Type>(QEvent::User + 2);
|
||||
static const QEvent::Type evLeftButton = static_cast<QEvent::Type>(QEvent::User + 3);
|
||||
static const QEvent::Type evRightButton = static_cast<QEvent::Type>(QEvent::User + 4);
|
||||
static const QEvent::Type evAudioFinished = static_cast<QEvent::Type>(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
|
||||
|
|
|
|||
|
|
@ -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<ConnectionId> 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) };");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,5 +11,10 @@
|
|||
<file>../assets/welcome.png</file>
|
||||
<file>../assets/play-circle-green.png</file>
|
||||
<file>../scripts/media.asm</file>
|
||||
<file>../assets/home.png</file>
|
||||
<file>../assets/left.png</file>
|
||||
<file>../assets/pause-button.png</file>
|
||||
<file>../assets/right.png</file>
|
||||
<file>../assets/check-mark.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
|||
|
|
@ -7,15 +7,21 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>338</width>
|
||||
<height>443</height>
|
||||
<height>326</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Story Teller Emulator</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="display">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
|
|
@ -46,63 +52,140 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Commands</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QDial" name="rotary"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="okButton">
|
||||
<property name="text">
|
||||
<string>Ok</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="homeButton">
|
||||
<property name="text">
|
||||
<string>Home</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pauseButton">
|
||||
<property name="text">
|
||||
<string>Pause</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>129</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="leftButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="ost-editor.qrc">
|
||||
<normaloff>:/assets/left.png</normaloff>:/assets/left.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="okButton">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="ost-editor.qrc">
|
||||
<normaloff>:/assets/check-mark.png</normaloff>:/assets/check-mark.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>35</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="rightButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="ost-editor.qrc">
|
||||
<normaloff>:/assets/right.png</normaloff>:/assets/right.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>45</width>
|
||||
<height>35</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pauseButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="ost-editor.qrc">
|
||||
<normaloff>:/assets/pause-button.png</normaloff>:/assets/pause-button.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="homeButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="ost-editor.qrc">
|
||||
<normaloff>:/assets/home.png</normaloff>:/assets/home.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="ost-editor.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ public:
|
|||
|
||||
signals:
|
||||
void sigOkButton();
|
||||
void sigLeftButton();
|
||||
void sigRightButton();
|
||||
|
||||
private:
|
||||
Ui::ostDisplay m_uiOstDisplay;
|
||||
|
|
|
|||
|
|
@ -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<int> &bkp)
|
||||
{
|
||||
m_editor->SetBreakPoints(bkp);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,11 @@ public:
|
|||
void setScript(const std::string &script);
|
||||
QString getScript() const;
|
||||
|
||||
void SetBreakPoints(const std::set<int> & bkp);
|
||||
|
||||
signals:
|
||||
void sigLineNumberAreaClicked(int line);
|
||||
|
||||
private:
|
||||
CodeEditor *m_editor{nullptr};
|
||||
Highlighter *m_highlighter;
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue