Next branch fixes #3141 Fx key to reload scripts

This commit is contained in:
David S. Beach
2015-12-27 11:53:29 -05:00
parent b778c5e469
commit 3e409a0371
11 changed files with 40 additions and 0 deletions
@@ -60,6 +60,8 @@ class Er9xSimulator : public SimulatorInterface {
virtual void setTrainerInput(unsigned int inputNumber, int16_t value) {}; virtual void setTrainerInput(unsigned int inputNumber, int16_t value) {};
virtual void setLuaStateReloadPermanentScripts() {};
protected: protected:
Er9xInterface * er9xInterface; Er9xInterface * er9xInterface;
@@ -60,6 +60,8 @@ class Ersky9xSimulator : public SimulatorInterface {
virtual void setTrainerInput(unsigned int inputNumber, int16_t value) {}; virtual void setTrainerInput(unsigned int inputNumber, int16_t value) {};
virtual void setLuaStateReloadPermanentScripts() {};
protected: protected:
Ersky9xInterface * ersky9xInterface; Ersky9xInterface * ersky9xInterface;
@@ -644,6 +644,13 @@ void OpenTxSimulator::setTrainerInput(unsigned int inputNumber, ::int16_t value)
#include "simulatorimport.h" #include "simulatorimport.h"
} }
void OpenTxSimulator::setLuaStateReloadPermanentScripts()
{
#if defined(LUA)
luaState = INTERPRETER_RELOAD_PERMANENT_SCRIPTS;
#endif
}
void OpenTxSimulator::installTraceHook(void (*callback)(const char *)) void OpenTxSimulator::installTraceHook(void (*callback)(const char *))
{ {
traceCallback = callback; traceCallback = callback;
@@ -137,6 +137,8 @@ class DLLEXPORT OpenTxSimulator : public SimulatorInterface {
virtual void setTrainerInput(unsigned int inputNumber, int16_t value); virtual void setTrainerInput(unsigned int inputNumber, int16_t value);
virtual void installTraceHook(void (*callback)(const char *)); virtual void installTraceHook(void (*callback)(const char *));
virtual void setLuaStateReloadPermanentScripts();
}; };
} }
@@ -1461,6 +1461,13 @@ QPushButton:checked {
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="luaReload">
<property name="text">
<string>PF7 - Reload Lua Scripts</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item row="4" column="0"> <item row="4" column="0">
@@ -1754,6 +1754,13 @@ QPushButton:checked {
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="luaReload">
<property name="text">
<string>PF7 - Reload Lua Scripts</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@@ -73,6 +73,7 @@ SimulatorDialog::SimulatorDialog(QWidget * parent, SimulatorInterface *simulator
new QShortcut(QKeySequence(Qt::Key_F4), this, SLOT(openTelemetrySimulator())); new QShortcut(QKeySequence(Qt::Key_F4), this, SLOT(openTelemetrySimulator()));
new QShortcut(QKeySequence(Qt::Key_F5), this, SLOT(openTrainerSimulator())); new QShortcut(QKeySequence(Qt::Key_F5), this, SLOT(openTrainerSimulator()));
new QShortcut(QKeySequence(Qt::Key_F6), this, SLOT(openDebugOutput())); new QShortcut(QKeySequence(Qt::Key_F6), this, SLOT(openDebugOutput()));
new QShortcut(QKeySequence(Qt::Key_F7), this, SLOT(luaReload()));
traceCallbackInstance = this; traceCallbackInstance = this;
} }
@@ -166,11 +167,18 @@ void SimulatorDialog::openDebugOutput()
} }
} }
void SimulatorDialog::luaReload()
{
// force a reload of the lua environment (as if a standalone script were run)
simulator->setLuaStateReloadPermanentScripts();
}
void SimulatorDialog::onDebugOutputClose() void SimulatorDialog::onDebugOutputClose()
{ {
DebugOut = 0; DebugOut = 0;
} }
void SimulatorDialog::keyPressEvent (QKeyEvent *event) void SimulatorDialog::keyPressEvent (QKeyEvent *event)
{ {
switch (event->key()) { switch (event->key()) {
@@ -155,6 +155,7 @@ class SimulatorDialog : public QDialog
void openTrainerSimulator(); void openTrainerSimulator();
void openDebugOutput(); void openDebugOutput();
void onDebugOutputClose(); void onDebugOutputClose();
void luaReload();
#ifdef JOYSTICKS #ifdef JOYSTICKS
void onjoystickAxisValueChanged(int axis, int value); void onjoystickAxisValueChanged(int axis, int value);
@@ -73,6 +73,7 @@ SimulatorDialogHorus::SimulatorDialogHorus(QWidget * parent, SimulatorInterface
connect(ui->teleSim, SIGNAL(released()), this, SLOT(openTelemetrySimulator())); connect(ui->teleSim, SIGNAL(released()), this, SLOT(openTelemetrySimulator()));
connect(ui->trainerSim, SIGNAL(released()), this, SLOT(openTrainerSimulator())); connect(ui->trainerSim, SIGNAL(released()), this, SLOT(openTrainerSimulator()));
connect(ui->debugConsole, SIGNAL(released()), this, SLOT(openDebugOutput())); connect(ui->debugConsole, SIGNAL(released()), this, SLOT(openDebugOutput()));
connect(ui->luaReload, SIGNAL(released()), this, SLOT(luaReload()));
} }
SimulatorDialogHorus::~SimulatorDialogHorus() SimulatorDialogHorus::~SimulatorDialogHorus()
@@ -80,6 +80,7 @@ SimulatorDialogTaranis::SimulatorDialogTaranis(QWidget * parent, SimulatorInterf
connect(ui->teleSim, SIGNAL(released()), this, SLOT(openTelemetrySimulator())); connect(ui->teleSim, SIGNAL(released()), this, SLOT(openTelemetrySimulator()));
connect(ui->trainerSim, SIGNAL(released()), this, SLOT(openTrainerSimulator())); connect(ui->trainerSim, SIGNAL(released()), this, SLOT(openTrainerSimulator()));
connect(ui->debugConsole, SIGNAL(released()), this, SLOT(openDebugOutput())); connect(ui->debugConsole, SIGNAL(released()), this, SLOT(openDebugOutput()));
connect(ui->luaReload, SIGNAL(released()), this, SLOT(luaReload()));
} }
SimulatorDialogTaranis::~SimulatorDialogTaranis() SimulatorDialogTaranis::~SimulatorDialogTaranis()
@@ -106,6 +106,8 @@ class SimulatorInterface
virtual void setTrainerInput(unsigned int inputNumber, int16_t value) = 0; virtual void setTrainerInput(unsigned int inputNumber, int16_t value) = 0;
virtual void installTraceHook(void (*callback)(const char *)) = 0; virtual void installTraceHook(void (*callback)(const char *)) = 0;
virtual void setLuaStateReloadPermanentScripts() = 0;
}; };
class SimulatorFactory { class SimulatorFactory {