mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-13 21:34:14 +02:00
Rework as script=only solution
This commit is contained in:
parent
72c4f5761a
commit
5e32298183
3 changed files with 14 additions and 18 deletions
|
@ -5781,7 +5781,6 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe
|
|||
ClipboardScriptingInterface* clipboardScriptable = new ClipboardScriptingInterface();
|
||||
scriptEngine->registerGlobalObject("Clipboard", clipboardScriptable);
|
||||
connect(scriptEngine.data(), &ScriptEngine::finished, clipboardScriptable, &ClipboardScriptingInterface::deleteLater);
|
||||
connect(scriptEngine.data(), &ScriptEngine::finished, this, &Application::cleanupRunningScripts);
|
||||
|
||||
scriptEngine->registerGlobalObject("Overlays", &_overlays);
|
||||
qScriptRegisterMetaType(scriptEngine.data(), OverlayPropertyResultToScriptValue, OverlayPropertyResultFromScriptValue);
|
||||
|
@ -6195,15 +6194,10 @@ void Application::showDialog(const QUrl& widgetUrl, const QUrl& tabletUrl, const
|
|||
}
|
||||
|
||||
void Application::showScriptLogs() {
|
||||
if (!_runningScripts.contains("debugWindow.js")) {
|
||||
auto scriptEngines = DependencyManager::get<ScriptEngines>();
|
||||
QUrl defaultScriptsLoc = PathUtils::defaultScriptsLocation();
|
||||
defaultScriptsLoc.setPath(defaultScriptsLoc.path() + "developer/debugging/debugWindow.js");
|
||||
ScriptEnginePointer sePointer = scriptEngines->loadScript(defaultScriptsLoc.toString());
|
||||
_runningScripts["debugWindow.js"] = sePointer;
|
||||
} else {
|
||||
qWarning() << "Scripts Log already running";
|
||||
}
|
||||
auto scriptEngines = DependencyManager::get<ScriptEngines>();
|
||||
QUrl defaultScriptsLoc = PathUtils::defaultScriptsLocation();
|
||||
defaultScriptsLoc.setPath(defaultScriptsLoc.path() + "developer/debugging/debugWindow.js");
|
||||
scriptEngines->loadScript(defaultScriptsLoc.toString());
|
||||
}
|
||||
|
||||
void Application::showAssetServerWidget(QString filePath) {
|
||||
|
@ -7302,10 +7296,6 @@ void Application::switchDisplayMode() {
|
|||
_previousHMDWornStatus = currentHMDWornStatus;
|
||||
}
|
||||
|
||||
void Application::cleanupRunningScripts(const QString& fileNameString, ScriptEnginePointer) {
|
||||
_runningScripts.remove(QUrl(fileNameString).fileName());
|
||||
}
|
||||
|
||||
void Application::startHMDStandBySession() {
|
||||
_autoSwitchDisplayModeSupportedHMDPlugin->startStandBySession();
|
||||
}
|
||||
|
|
|
@ -440,8 +440,6 @@ private slots:
|
|||
|
||||
void handleSandboxStatus(QNetworkReply* reply);
|
||||
void switchDisplayMode();
|
||||
|
||||
void cleanupRunningScripts(const QString& fileNameString, ScriptEnginePointer);
|
||||
private:
|
||||
static void initDisplay();
|
||||
void init();
|
||||
|
@ -712,7 +710,5 @@ private:
|
|||
|
||||
std::atomic<bool> _pendingIdleEvent { false };
|
||||
std::atomic<bool> _pendingRenderEvent { false };
|
||||
|
||||
QHash<QString, ScriptEnginePointer> _runningScripts;
|
||||
};
|
||||
#endif // hifi_Application_h
|
||||
|
|
|
@ -10,13 +10,23 @@
|
|||
|
||||
(function() { // BEGIN LOCAL_SCOPE
|
||||
|
||||
//check if script already running.
|
||||
var scriptData = ScriptDiscoveryService.getRunning();
|
||||
var scripts = scriptData.filter(function (datum) { return datum.name === 'debugWindow.js'; });
|
||||
if (scripts.length >= 2) {
|
||||
//2nd instance of the script is too much
|
||||
return;
|
||||
}
|
||||
|
||||
// Set up the qml ui
|
||||
var qml = Script.resolvePath('debugWindow.qml');
|
||||
|
||||
var window = new OverlayWindow({
|
||||
title: 'Debug Window',
|
||||
source: qml,
|
||||
width: 400, height: 900,
|
||||
});
|
||||
|
||||
window.setPosition(25, 50);
|
||||
window.closed.connect(function() { Script.stop(); });
|
||||
|
||||
|
|
Loading…
Reference in a new issue