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 Jan 3, 2025
2 parents cdbd53b + 02f54ba commit 1994e25
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 13 deletions.
14 changes: 7 additions & 7 deletions Editor/languages/editor_zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2451,15 +2451,15 @@ So, please break these words to avoid this.</li>
</message>
<message>
<source>Collision script function</source>
<translation type="unfinished"></translation>
<translation>判定触发脚本区域</translation>
</message>
<message>
<source>Mouse click Script function</source>
<translation type="unfinished"></translation>
<translation>鼠标点击触发脚本区域</translation>
</message>
<message>
<source>Sub-Area</source>
<translation type="unfinished"></translation>
<translation>子区域</translation>
</message>
</context>
<context>
Expand Down Expand Up @@ -4722,7 +4722,7 @@ number of existing and collected stars in the level will not be shown.</source>
</message>
<message>
<source>On-Enter event:</source>
<translation>进入事件:</translation>
<translation>传送点入口事件:</translation>
</message>
<message>
<source>Trigger event when he player enters this warp</source>
Expand Down Expand Up @@ -5034,11 +5034,11 @@ show the current playable character(s) and number of lives.</source>
</message>
<message>
<source>On-Exit event:</source>
<translation type="unfinished"></translation>
<translation>传送点出口事件:</translation>
</message>
<message>
<source>Trigger event when he player exists this warp from other side</source>
<translation type="unfinished"></translation>
<translation>当玩家从传送点出来时,触发事件</translation>
</message>
</context>
<context>
Expand Down Expand Up @@ -7507,7 +7507,7 @@ Reason: %1
</message>
<message>
<source>Event Warp Exit</source>
<translation type="unfinished"></translation>
<translation>传送点出口事件</translation>
</message>
</context>
<context>
Expand Down
102 changes: 96 additions & 6 deletions Editor/testing/ipc/pge_engine_ipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ PgeEngineIpcClient::PgeEngineIpcClient(QObject *parent) :
this, &PgeEngineIpcClient::showMainWindow, Qt::QueuedConnection);
QObject::connect(this, &PgeEngineIpcClient::signalSendLevelBuffer,
this, &PgeEngineIpcClient::sendLevelBuffer, Qt::QueuedConnection);
QObject::connect(this, &PgeEngineIpcClient::signalSendLevelBufferFull,
this, &PgeEngineIpcClient::sendLevelBufferFull, Qt::QueuedConnection);
QObject::connect(this, &PgeEngineIpcClient::signalSendLevelBufferNext,
this, &PgeEngineIpcClient::sendLevelBufferMultipartNext, Qt::QueuedConnection);
}

void PgeEngineIpcClient::setMainWindow(QWidget *mw)
Expand Down Expand Up @@ -83,6 +87,7 @@ void PgeEngineIpcClient::readInputStream(QByteArray &out)

if(c == '\n')
break; // complete

out.push_back(c);
}
}
Expand Down Expand Up @@ -181,6 +186,12 @@ void PgeEngineIpcClient::onInputData()
else if(std::strcmp(msgP, "ENGINE_CLOSED") == 0)
emit signalEngineClosed();
}
else if(std::strcmp(msg, "READY\n\n") == 0)
emit signalSendLevelBufferFull();
else if(std::strcmp(msg, "READY_PARTS\n\n") == 0)
emit signalSendLevelBufferNext();
else if(std::strcmp(msg, "LVLX_NEXT\n\n") == 0)
emit signalSendLevelBufferNext();
else
{
// Any unknown commands
Expand Down Expand Up @@ -354,9 +365,14 @@ void PgeEngineIpcClient::sendLevelBuffer()

sendNumStars(GlobalSettings::testing.xtra_starsNum);

LogDebug("Attempt to send LVLX buffer");
QString output;
FileFormats::WriteExtendedLvlFileRaw(m_levelTestBuffer, output);
if(m_levelTestAllowMultipart)
{
sendLevelBufferMultipart();
return;
}

LogDebug("Attempt to send LVLX buffer (full buffer)");
FileFormats::WriteExtendedLvlFileRaw(m_levelTestBuffer, m_levelTestBufferRaw);
QString sendLvlx;
QString x = (!m_levelTestBuffer.meta.smbx64strict ? "x" : "");

Expand All @@ -369,21 +385,90 @@ void PgeEngineIpcClient::sendLevelBuffer()
.arg(ApplicationPath)
.arg("_untitled.lvl").arg(x);

if(output.size() <= 0)
output = "HEAD\nEMPTY:1\nHEAD_END\n";
if(m_levelTestBufferRaw.size() <= 0)
m_levelTestBufferRaw = "HEAD\nEMPTY:1\nHEAD_END\n";

//#ifdef DEBUG_BUILD
// qDebug() << "Sent File data BEGIN >>>>>>>>>>>\n" << output << "\n<<<<<<<<<<<<Sent File data END";
//#endif
sendMessage(sendLvlx);
}

void PgeEngineIpcClient::sendLevelBufferFull()
{
if(!isWorking())
return;

QByteArray output_e;
base64_encode(output_e, output);
base64_encode(output_e, m_levelTestBufferRaw);
output_e.append('\n');
m_engine->write(output_e);
sendMessage("PARSE_LVLX");
LogDebug("LVLX buffer sent");
}

void PgeEngineIpcClient::sendLevelBufferMultipart()
{
if(!isWorking())
return;

LogDebug("Attempt to send LVLX buffer (multipart method)");
FileFormats::WriteExtendedLvlFileRaw(m_levelTestBuffer, m_levelTestBufferRaw);
QString sendLvlx;
QString x = (!m_levelTestBuffer.meta.smbx64strict ? "x" : "");

if(!m_levelTestBuffer.meta.path.isEmpty())
sendLvlx = QString("SEND_LVLX_PARTS: %1/%2\n")
.arg(m_levelTestBuffer.meta.path)
.arg(m_levelTestBuffer.meta.filename + ".lvl" + x);
else
sendLvlx = QString("SEND_LVLX_PARTS: %1/%2%3\n")
.arg(ApplicationPath)
.arg("_untitled.lvl").arg(x);

if(m_levelTestBufferRaw.size() <= 0)
m_levelTestBufferRaw = "HEAD\nEMPTY:1\nHEAD_END\n";

m_levelTestBufferRawOffset = 0;
m_levelTestBufferRawAtEnd = false;

sendMessage(sendLvlx);
}

void PgeEngineIpcClient::sendLevelBufferMultipartNext()
{
if(!isWorking())
return;

if(m_levelTestBufferRawAtEnd)
{
sendMessage("PARSE_LVLX");
LogDebug("LVLX buffer sent");
return;
}

qDebug() << "LVLX-Multipart: Sending next part, offset" << m_levelTestBufferRawOffset << "of" << m_levelTestBufferRaw.size();

const int buffSize = 102400;
QString buff;

if(m_levelTestBufferRaw.size() - m_levelTestBufferRawOffset > buffSize)
{
buff = m_levelTestBufferRaw.mid(m_levelTestBufferRawOffset, buffSize);
m_levelTestBufferRawOffset += buffSize;
}
else
{
buff = m_levelTestBufferRaw.mid(m_levelTestBufferRawOffset, -1);
m_levelTestBufferRawAtEnd = true;
}

QByteArray output_e;
base64_encode(output_e, buff);
output_e.append('\n');
m_engine->write(output_e);
}

void PgeEngineIpcClient::showMainWindow()
{
if(!m_mainWindow)
Expand All @@ -405,6 +490,11 @@ void PgeEngineIpcClient::sendNumStars(int numStars)
sendMessage(out);
}

void PgeEngineIpcClient::setMultipartMode(bool mp)
{
m_levelTestAllowMultipart = mp;
}

bool PgeEngineIpcClient::sendMessage(const char *msg)
{
if(!isWorking())
Expand Down
17 changes: 17 additions & 0 deletions Editor/testing/ipc/pge_engine_ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ class PgeEngineIpcClient: public QObject
*/
void sendNumStars(int numStars);

void setMultipartMode(bool mp);

private:
/**
* @brief Read all input data before last delimeter character
Expand Down Expand Up @@ -166,6 +168,8 @@ private slots:
void engineCloseProperties();

void signalSendLevelBuffer();
void signalSendLevelBufferFull();
void signalSendLevelBufferNext();
void signalEngineClosed();

private:
Expand All @@ -186,6 +190,13 @@ private slots:
* @brief When engine is ready, submit a level data from a cache
*/
void sendLevelBuffer();
void sendLevelBufferFull();

/**
* @brief When engine is ready, submit a level data from a cache as multipart
*/
void sendLevelBufferMultipart();
void sendLevelBufferMultipartNext();

void showMainWindow();

Expand All @@ -198,6 +209,12 @@ private slots:

//! Cached level data buffer
LevelData m_levelTestBuffer;

bool m_levelTestAllowMultipart = false;
QString m_levelTestBufferRaw;
int m_levelTestBufferRawOffset = 0;
bool m_levelTestBufferRawAtEnd = false;

//! Main window instance pointer
QWidget *m_mainWindow = nullptr;
//! Engine server QProcess instance
Expand Down
2 changes: 2 additions & 0 deletions Editor/testing/thextech_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,8 @@ bool TheXTechEngine::doTestLevelIPC(const LevelData &d)
}
}

m_interface.setMultipartMode(m_caps.features.contains("ipc-lvlx-multipart"));

edit->prepareLevelFile(data);
m_interface.setTestLvlBuffer(data);

Expand Down

0 comments on commit 1994e25

Please sign in to comment.