Skip to content

Commit

Permalink
Merge branch 'master' into wip-translator
Browse files Browse the repository at this point in the history
  • Loading branch information
Wohlstand committed Oct 7, 2023
2 parents 9145edf + 3f82267 commit 335dbe0
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 25 deletions.
86 changes: 70 additions & 16 deletions Editor/testing/ipc/thextech_capabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,35 @@ static QString s_getExecRawOutput(const QString &exec, const QStringList &args)
return ret;
}

static void fillCapsLegacy(TheXTechCapabilities &caps)
static void fillCapsNoIPC(TheXTechCapabilities &caps)
{
caps.type = "Legacy No-IPC build";
caps.version = "legacy-no-ipc";

caps.ipcProtocols << "no-ipc" << "--END--";
caps.arguments << "frameskip"
<< "no-sound"
<< "never-pause"
<< "render"
<< "leveltest"
<< "num-players"
<< "battle"
<< "player1"
<< "player2"
<< "god-mode"
<< "grab-all"
<< "show-fps"
<< "max-fps"
<< "levelpath"
<< "--END--";

caps.renders << "sw" << "hw" << "vsync" << "--END--";
caps.features << "test-level-file" << "leveltest-arg-required" << "--END--";

caps.isCompatible = true;
}

static void fillCapsLegacy(TheXTechCapabilities &caps, const QString &input)
{
caps.type = "legacy fallback";
caps.version = "legacy";
Expand All @@ -61,7 +89,6 @@ static void fillCapsLegacy(TheXTechCapabilities &caps)
<< "no-frameskip"
<< "no-sound"
<< "never-pause"
<< "bg-input"
<< "render"
<< "leveltest"
<< "num-players"
Expand All @@ -72,21 +99,46 @@ static void fillCapsLegacy(TheXTechCapabilities &caps)
<< "grab-all"
<< "show-fps"
<< "max-fps"
<< "magic-hand"
<< "editor"
<< "interprocessing"
<< "compat-level"
<< "speed-run-mode"
<< "speed-run-semitransparent"
<< "speed-run-blink-mode"
<< "show-controls"
<< "show-battery-status"
<< "verbose"
<< "levelpath"
<< "--END--";
<< "levelpath";

if(input.contains("--bg-input"))
caps.arguments << "bg-input";

if(input.contains("--magic-hand"))
caps.arguments << "magic-hand";

if(input.contains("--editor"))
{
caps.arguments << "editor";
caps.features << "stars-number" << "editor";
}

if(input.contains("--compat-level"))
caps.arguments << "compat-level";

if(input.contains("--speed-run-mode"))
caps.arguments << "speed-run-mode";

if(input.contains("--speed-run-semitransparent"))
caps.arguments << "speed-run-semitransparent";

if(input.contains("--speed-run-blink-mode"))
caps.arguments << "speed-run-blink-mode";

if(input.contains("--show-controls"))
caps.arguments << "show-controls";

if(input.contains("--show-battery-status"))
caps.arguments << "show-battery-status";

if(input.contains("--verbose"))
caps.arguments << "verbose";

caps.arguments << "--END--";

caps.renders << "sw" << "hw" << "vsync" << "--END--";
caps.features << "stars-number" << "editor" << "test-level-file" << "test-level-ipc" << "--END--";
caps.features << "test-level-file" << "test-level-ipc" << "--END--";

caps.isCompatible = true;
}
Expand Down Expand Up @@ -149,8 +201,10 @@ bool getTheXTechCapabilities(TheXTechCapabilities &caps, const QString &path)

input = s_getExecRawOutput(path, {"--help"});

if(!input.contains("--capabilities")) // Fill with legacy preset
fillCapsLegacy(caps);
if(!input.contains("--interprocessing")) // Version of engine is too old
fillCapsNoIPC(caps);
else if(!input.contains("--capabilities")) // Fill with legacy preset
fillCapsLegacy(caps, input);
else // Parse from JSON
{
input = s_getExecRawOutput(path, {"--capabilities"});
Expand Down
38 changes: 29 additions & 9 deletions Editor/testing/thextech_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ void TheXTechEngine::updateMenuCapabilities()
{
Q_ASSERT(m_w);

if(m_menuRunLevelTestIPC)
m_menuRunLevelTestIPC->setEnabled(m_caps.features.contains("test-level-ipc"));

if(m_menuRunWorldTestFile)
m_menuRunWorldTestFile->setEnabled(m_caps.features.contains("test-world-file"));

Expand Down Expand Up @@ -231,7 +234,18 @@ void TheXTechEngine::startBattleTestAction()
return;

m_battleMode = true;
doTestLevelIPC(edit->LvlData);
if(!m_caps.ipcProtocols.contains("no-ipc"))
doTestLevelIPC(edit->LvlData);
else
{
if(edit->isUntitled())
{
AbstractRuntimeEngine::rejectUntitled(m_w);
return;
}

doTestLevelFile(edit->curFile);
}
}
}

Expand Down Expand Up @@ -395,6 +409,7 @@ void TheXTechEngine::initMenu(QMenu *destmenu)
QObject::connect(RunLevelTest, &QAction::triggered,
this, &TheXTechEngine::startTestAction,
Qt::QueuedConnection);
m_menuRunLevelTestIPC = RunLevelTest;
m_menuItems[menuItemId++] = RunLevelTest;
QObject::connect(m_w, &MainWindow::windowActiveWorld, [this, menuItemId](bool wld)
{
Expand Down Expand Up @@ -447,13 +462,13 @@ void TheXTechEngine::initMenu(QMenu *destmenu)
{
auto *m = m_menuItems[menuItemId - 1];
if(wld)
m->setEnabled(hasCapability(AbstractRuntimeEngine::CAP_WORLD_IPC));
m->setEnabled(false);
});
QObject::connect(m_w, &MainWindow::windowActiveLevel, [this, menuItemId](bool lvl)
{
auto *m = m_menuItems[menuItemId - 1];
if(lvl)
m->setEnabled(hasCapability(AbstractRuntimeEngine::CAP_LEVEL_IPC));
m->setEnabled(hasCapability(AbstractRuntimeEngine::CAP_LEVEL_IPC | AbstractRuntimeEngine::CAP_LEVEL_FILE));
});
}

Expand Down Expand Up @@ -1157,6 +1172,9 @@ bool TheXTechEngine::doTestLevelIPC(const LevelData &d)

m_errorString.clear();

if((capabilities() & CAP_LEVEL_IPC) == 0)
return false;

QString command = getEnginePath();

if(!QFile::exists(command))
Expand Down Expand Up @@ -1240,7 +1258,7 @@ bool TheXTechEngine::doTestLevelIPC(const LevelData &d)
if(m_caps.arguments.contains("start-warp") && m_startWarp > 0)
args << "--start-warp" << QString::number(m_startWarp);

if(m_speedRunMode >= 0)
if(m_speedRunMode >= 0 && m_caps.arguments.contains("speed-run-mode"))
{
switch(m_speedRunMode)
{
Expand All @@ -1258,7 +1276,7 @@ bool TheXTechEngine::doTestLevelIPC(const LevelData &d)
if(m_speedRunTimerST)
args << "--speed-run-semitransparent";
}
else if(m_compatLevel >= 0)
else if(m_compatLevel >= 0 && m_caps.arguments.contains("compat-level"))
{
switch(m_compatLevel)
{
Expand Down Expand Up @@ -1315,6 +1333,8 @@ bool TheXTechEngine::doTestLevelFile(const QString &levelFile)
// args << "--debug";
// args << "--config=\"" + m_w->configs.config_dir + "\"";

if(m_battleMode) args << "--battle";

SETTINGS_TestSettings t = GlobalSettings::testing;
args << "--num-players" << QString::number(t.numOfPlayers);
args << "--player1" << QString("c%1;s%2;m%3;t%4")
Expand Down Expand Up @@ -1371,7 +1391,7 @@ bool TheXTechEngine::doTestLevelFile(const QString &levelFile)
if(m_caps.arguments.contains("start-warp") && m_startWarp > 0)
args << "--start-warp" << QString::number(m_startWarp);

if(m_speedRunMode >= 0)
if(m_speedRunMode >= 0 && m_caps.arguments.contains("speed-run-mode"))
{
switch(m_speedRunMode)
{
Expand All @@ -1386,10 +1406,10 @@ bool TheXTechEngine::doTestLevelFile(const QString &levelFile)
break;
}

if(m_speedRunTimerST)
if(m_speedRunTimerST && m_caps.arguments.contains("speed-run-semitransparent"))
args << "--speed-run-semitransparent";
}
else if(m_compatLevel >= 0)
else if(m_compatLevel >= 0 && m_caps.arguments.contains("compat-level"))
{
switch(m_compatLevel)
{
Expand Down Expand Up @@ -1554,7 +1574,7 @@ bool TheXTechEngine::isRunning()

int TheXTechEngine::capabilities()
{
return CAP_LEVEL_IPC |
return (m_caps.features.contains("test-level-ipc") ? CAP_LEVEL_IPC : 0) |
CAP_LEVEL_FILE |
CAP_RUN_GAME |
CAP_HAS_MENU |
Expand Down
1 change: 1 addition & 0 deletions Editor/testing/thextech_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class TheXTechEngine : public AbstractRuntimeEngine
static const size_t m_menuItemsSize = 40;
//! List of registered menu items
QAction *m_menuItems[m_menuItemsSize];
QAction *m_menuRunLevelTestIPC = nullptr;
QAction *m_menuRunWorldTestFile = nullptr;
QAction *m_menuRunWorldTestIPC = nullptr;

Expand Down

0 comments on commit 335dbe0

Please sign in to comment.