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 19, 2025
2 parents 74b7458 + 84b8835 commit 41826ca
Show file tree
Hide file tree
Showing 12 changed files with 500 additions and 23 deletions.
48 changes: 35 additions & 13 deletions Editor/data_configs/selection_dialog/config_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ void ConfigManager::on_buttonBox_accepted()
on_configList_itemDoubleClicked(ui->configList->selectedItems().first());
}

bool ConfigManager::isConfigured()
bool ConfigManager::isConfigured(PGE_JsEngine *js)
{
QString settingsFile = DataConfig::buildLocalConfigPath(m_currentConfigPath);
if(!QFile::exists(settingsFile))
Expand All @@ -576,9 +576,20 @@ bool ConfigManager::isConfigured()
QString path = settings.value("application-path", QString()).toString();
settings.endGroup();

PGE_JsEngine loc_js;
bool js_valid = js != nullptr;
if(!js)
{
js = &loc_js;
js_valid = configure_loadScript(js);
}

// When directory got moved or deleted, config pack should be marked as not configured because got broken
ret &= !path.isEmpty() && QFileInfo(path).isDir() && QDir(path).exists();

if(js_valid && js->hasFunction("isValidIntegration"))
ret &= js->call<bool>("isValidIntegration", nullptr, path);

return ret;
}

Expand Down Expand Up @@ -715,18 +726,8 @@ bool ConfigManager::runConfigureTool()
if(ConfStatus::configIsIntegrational)
{
PGE_JsEngine js;
// QString cpDirName = QDir(m_currentConfigPath).dirName();
QString cpSetupFile = DataConfig::buildLocalConfigPath(m_currentConfigPath);

js.bindProxy(new PGE_JS_Common(parentW), "PGE");
js.bindProxy(new PGE_JS_File(m_currentConfigPath, cpSetupFile, parentW), "FileIO");
js.bindProxy(new PGE_JS_INI(parentW), "INI");
js.bindProxy(new PGE_JS_System(parentW), "System");

bool successfulLoaded = false;
js.loadFileByExpcetedResult<void>(ConfStatus::configConfigureTool, &successfulLoaded);

if(successfulLoaded)
if(configure_loadScript(&js))
{
setEnabled(false);
if(!js.call<bool>("onConfigure", nullptr))
Expand All @@ -735,7 +736,7 @@ bool ConfigManager::runConfigureTool()
return false;
}
setEnabled(true);
if(!isConfigured())
if(!isConfigured(&js))
return false;
return true;
}
Expand All @@ -761,3 +762,24 @@ bool ConfigManager::runConfigureTool()
return false;
}
}

bool ConfigManager::configure_loadScript(PGE_JsEngine *js)
{
QWidget *parentW = qobject_cast<QWidget *>(parent());
if(!parentW || isVisible())
parentW = this;

bool successfulLoaded = false;

// QString cpDirName = QDir(m_currentConfigPath).dirName();
QString cpSetupFile = DataConfig::buildLocalConfigPath(m_currentConfigPath);

js->bindProxy(new PGE_JS_Common(parentW), "PGE");
js->bindProxy(new PGE_JS_File(m_currentConfigPath, cpSetupFile, parentW), "FileIO");
js->bindProxy(new PGE_JS_INI(parentW), "INI");
js->bindProxy(new PGE_JS_System(parentW), "System");

js->loadFileByExpcetedResult<void>(ConfStatus::configConfigureTool, &successfulLoaded);

return successfulLoaded;
}
7 changes: 6 additions & 1 deletion Editor/data_configs/selection_dialog/config_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace Ui {
class ConfigManager;
}

class PGE_JsEngine;

class ConfigManager : public QDialog
{
Q_OBJECT
Expand Down Expand Up @@ -70,13 +72,16 @@ class ConfigManager : public QDialog
* @brief Checks is current config pack configured (or non-configurable)
* @return true if config pack is non-configurable or already configured
*/
bool isConfigured();
bool isConfigured(PGE_JsEngine *js = nullptr);
/**
* @brief Starts configure tool if available
* @return true on success configuring, false if no config tool found, rejected or script was been errored
*/
bool runConfigureTool();

private:
bool configure_loadScript(PGE_JsEngine *js);

private slots:

void on_configList_itemDoubleClicked(QListWidgetItem *item);
Expand Down
6 changes: 6 additions & 0 deletions Editor/js_engine/pge_jsengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ class PGE_JsEngine : public QObject
m_jsengine.globalObject().setProperty(regName, m_jsengine.newQObject(obj));
}

bool hasFunction(const QString &functionName, bool *ok = nullptr)
{
QJSValue function = m_jsengine.evaluate(functionName);
return checkForErrors(function, ok);
}

template<typename RetVal, typename... Args>
RetVal call(const QString &functionName, bool *ok, Args &&... args)
{
Expand Down
8 changes: 4 additions & 4 deletions Editor/languages/editor_zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7860,21 +7860,21 @@ Reason: %1
</message>
<message>
<source>Set custom health level</source>
<translation type="unfinished"></translation>
<translation>设置初始体力</translation>
</message>
<message>
<source>Reserved item</source>
<translation type="unfinished"></translation>
<translation>道具存储</translation>
</message>
<message>
<source>&lt;Unknown&gt;</source>
<comment>Unknown NPC from the list</comment>
<translation type="unfinished"></translation>
<translation>&amp;lt;未知道具&amp;gt;</translation>
</message>
<message>
<source>[No item]</source>
<comment>Reserve box of player contains no item</comment>
<translation type="unfinished"></translation>
<translation>[无道具]</translation>
</message>
</context>
<context>
Expand Down
2 changes: 1 addition & 1 deletion Editor/testing/luna_tester_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,14 +1064,14 @@ void LunaTesterEngine::killProcess()
#else // anything but _WIN32

# ifdef __APPLE__
Q_UNUSED(lunaExecPath)
LogDebugNC(QString("LunaEngineWorker: Killing %1 by 'kill'...").arg(smbxExeName));
QProcess ps;
ps.start("/bin/ps", {"-A"});
ps.waitForFinished();
QString psAll = ps.readAllStandardOutput();

QStringList psAllList = psAll.split('\n');
QString smbxExeName = smbxExeName;

QRegExp psReg(QString("(\\d+) .*(wine-preloader).*(%1)").arg(smbxExeName));
for(QString &psOne : psAllList)
Expand Down
30 changes: 30 additions & 0 deletions Editor/testing/thextech_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,16 @@ bool TheXTechEngine::doTestLevelIPC(const LevelData &d)
}
}

if(m_caps.arguments.contains("c"))
{
#if __APPLE__
if(!ConfStatus::configDataPath.endsWith(".app/Content/Resources/assets/", Qt::CaseInsensitive))
args << "-c" << ConfStatus::configDataPath;
#else
args << "-c" << ConfStatus::configDataPath;
#endif
}

if(m_caps.features.contains("vsync-flag") && m_vsyncEnable)
args << "--vsync";

Expand Down Expand Up @@ -1407,6 +1417,16 @@ bool TheXTechEngine::doTestLevelFile(const QString &levelFile)
}
}

if(m_caps.arguments.contains("c"))
{
#if __APPLE__
if(!ConfStatus::configDataPath.endsWith(".app/Content/Resources/assets/", Qt::CaseInsensitive))
args << "-c" << ConfStatus::configDataPath;
#else
args << "-c" << ConfStatus::configDataPath;
#endif
}

if(m_caps.features.contains("vsync-flag") && m_vsyncEnable)
args << "--vsync";

Expand Down Expand Up @@ -1537,6 +1557,16 @@ bool TheXTechEngine::doTestWorldFile(const QString &worldFile)
}
}

if(m_caps.arguments.contains("c"))
{
#if __APPLE__
if(!ConfStatus::configDataPath.endsWith(".app/Contents/Resources/assets/", Qt::CaseInsensitive))
args << "-c" << ConfStatus::configDataPath;
#else
args << "-c" << ConfStatus::configDataPath;
#endif
}

if(m_caps.features.contains("vsync-flag") && m_vsyncEnable)
args << "--vsync";

Expand Down
2 changes: 1 addition & 1 deletion GIFs2PNG/gifs2png.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ int main(int argc, char *argv[])
setup.removeSource = switchRemove.getValue();
setup.skipBackground2 = switchSkipBG.getValue();
setup.skipNonBW = switchSkipNonBW.getValue();
setup.walkSubDirs = switchDigRecursive.getValue() | switchDigRecursiveDEP.getValue();
setup.walkSubDirs = switchDigRecursive.getValue() || switchDigRecursiveDEP.getValue();

setup.pathOut = outputDirectory.getValue();
setup.configPath = configDirectory.getValue();
Expand Down
19 changes: 19 additions & 0 deletions _Misc/glossary/ta.tbx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE martif PUBLIC "ISO 12200:1999A//DTD MARTIF core (DXFcdV04)//EN" "TBXcdv04.dtd">
<martif type="TBX" xml:lang="en">
<martifHeader>
<fileDesc>
<sourceDesc>
<p>Translate Toolkit</p>
</sourceDesc>
</fileDesc>
</martifHeader>
<text>
<body>
<termEntry>
<langSet xml:lang="en"><tig><term>Moondust</term></tig></langSet>
<langSet xml:lang="ta"><tig><term>நிலவொளி</term></tig></langSet>
</termEntry>
</body>
</text>
</martif>
2 changes: 1 addition & 1 deletion _common/Graphics/bitmask2rgba.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void bitmask_set_bitblit_bg(uint8_t red, uint8_t green, uint8_t blue)
s_bitblitBG.rgbBlue = blue;
}

void bitmask_reset_bitblit_bg()
void bitmask_reset_bitblit_bg(void)
{
s_bitblitBG.rgbRed = 0;
s_bitblitBG.rgbGreen = 0;
Expand Down
2 changes: 1 addition & 1 deletion _common/Graphics/bitmask2rgba.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern void bitmask_set_bitblit_bg(uint8_t red, uint8_t green, uint8_t blue);
/**
* @brief Restore the default pseudo-background colour
*/
extern void bitmask_reset_bitblit_bg();
extern void bitmask_reset_bitblit_bg(void);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion _common/PGE_File_Formats
Submodule PGE_File_Formats updated 0 files
Loading

0 comments on commit 41826ca

Please sign in to comment.