mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 13:24:02 +02:00
Add test mode to interface
This commit is contained in:
parent
06b7388930
commit
2a43f5fbef
6 changed files with 182 additions and 66 deletions
|
@ -131,6 +131,7 @@
|
||||||
#include "LODManager.h"
|
#include "LODManager.h"
|
||||||
#include "ModelPackager.h"
|
#include "ModelPackager.h"
|
||||||
#include "networking/HFWebEngineProfile.h"
|
#include "networking/HFWebEngineProfile.h"
|
||||||
|
#include "scripting/TestScriptingInterface.h"
|
||||||
#include "scripting/AccountScriptingInterface.h"
|
#include "scripting/AccountScriptingInterface.h"
|
||||||
#include "scripting/AssetMappingsScriptingInterface.h"
|
#include "scripting/AssetMappingsScriptingInterface.h"
|
||||||
#include "scripting/AudioDeviceScriptingInterface.h"
|
#include "scripting/AudioDeviceScriptingInterface.h"
|
||||||
|
@ -541,6 +542,20 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
setProperty(hifi::properties::STEAM, SteamClient::isRunning());
|
setProperty(hifi::properties::STEAM, SteamClient::isRunning());
|
||||||
setProperty(hifi::properties::CRASHED, _previousSessionCrashed);
|
setProperty(hifi::properties::CRASHED, _previousSessionCrashed);
|
||||||
|
|
||||||
|
{
|
||||||
|
const QString TEST_SCRIPT = "--testScript";
|
||||||
|
const QStringList args = arguments();
|
||||||
|
for (int i = 0; i < args.size() - 1; ++i) {
|
||||||
|
if (args.at(i) == TEST_SCRIPT) {
|
||||||
|
QString testScriptPath = args.at(i + 1);
|
||||||
|
if (QFileInfo(testScriptPath).exists()) {
|
||||||
|
setProperty(hifi::properties::TEST, QUrl::fromLocalFile(testScriptPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
_runningMarker.startRunningMarker();
|
_runningMarker.startRunningMarker();
|
||||||
|
|
||||||
PluginContainer* pluginContainer = dynamic_cast<PluginContainer*>(this); // set the container for any plugins that care
|
PluginContainer* pluginContainer = dynamic_cast<PluginContainer*>(this); // set the container for any plugins that care
|
||||||
|
@ -1329,90 +1344,96 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
return entityServerNode && !isPhysicsEnabled();
|
return entityServerNode && !isPhysicsEnabled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QVariant testProperty = property(hifi::properties::TEST);
|
||||||
|
qDebug() << testProperty;
|
||||||
|
if (testProperty.isValid()) {
|
||||||
|
auto scriptEngines = DependencyManager::get<ScriptEngines>();
|
||||||
|
const auto testScript = property(hifi::properties::TEST).toUrl();
|
||||||
|
scriptEngines->loadScript(testScript, false);
|
||||||
|
} else {
|
||||||
|
// Get sandbox content set version, if available
|
||||||
|
auto acDirPath = PathUtils::getRootDataDirectory() + BuildInfo::MODIFIED_ORGANIZATION + "/assignment-client/";
|
||||||
|
auto contentVersionPath = acDirPath + "content-version.txt";
|
||||||
|
qCDebug(interfaceapp) << "Checking " << contentVersionPath << " for content version";
|
||||||
|
auto contentVersion = 0;
|
||||||
|
QFile contentVersionFile(contentVersionPath);
|
||||||
|
if (contentVersionFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
QString line = contentVersionFile.readAll();
|
||||||
|
// toInt() returns 0 if the conversion fails, so we don't need to specifically check for failure
|
||||||
|
contentVersion = line.toInt();
|
||||||
|
}
|
||||||
|
qCDebug(interfaceapp) << "Server content version: " << contentVersion;
|
||||||
|
|
||||||
|
bool hasTutorialContent = contentVersion >= 1;
|
||||||
|
|
||||||
// Get sandbox content set version, if available
|
Setting::Handle<bool> firstRun { Settings::firstRun, true };
|
||||||
auto acDirPath = PathUtils::getRootDataDirectory() + BuildInfo::MODIFIED_ORGANIZATION + "/assignment-client/";
|
bool hasHMDAndHandControllers = PluginUtils::isHMDAvailable("OpenVR (Vive)") && PluginUtils::isHandControllerAvailable();
|
||||||
auto contentVersionPath = acDirPath + "content-version.txt";
|
Setting::Handle<bool> tutorialComplete { "tutorialComplete", false };
|
||||||
qCDebug(interfaceapp) << "Checking " << contentVersionPath << " for content version";
|
|
||||||
auto contentVersion = 0;
|
|
||||||
QFile contentVersionFile(contentVersionPath);
|
|
||||||
if (contentVersionFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
||||||
QString line = contentVersionFile.readAll();
|
|
||||||
// toInt() returns 0 if the conversion fails, so we don't need to specifically check for failure
|
|
||||||
contentVersion = line.toInt();
|
|
||||||
}
|
|
||||||
qCDebug(interfaceapp) << "Server content version: " << contentVersion;
|
|
||||||
|
|
||||||
bool hasTutorialContent = contentVersion >= 1;
|
bool shouldGoToTutorial = hasHMDAndHandControllers && hasTutorialContent && !tutorialComplete.get();
|
||||||
|
|
||||||
Setting::Handle<bool> firstRun { Settings::firstRun, true };
|
qCDebug(interfaceapp) << "Has HMD + Hand Controllers: " << hasHMDAndHandControllers << ", current plugin: " << _displayPlugin->getName();
|
||||||
bool hasHMDAndHandControllers = PluginUtils::isHMDAvailable("OpenVR (Vive)") && PluginUtils::isHandControllerAvailable();
|
qCDebug(interfaceapp) << "Has tutorial content: " << hasTutorialContent;
|
||||||
Setting::Handle<bool> tutorialComplete { "tutorialComplete", false };
|
qCDebug(interfaceapp) << "Tutorial complete: " << tutorialComplete.get();
|
||||||
|
qCDebug(interfaceapp) << "Should go to tutorial: " << shouldGoToTutorial;
|
||||||
|
|
||||||
bool shouldGoToTutorial = hasHMDAndHandControllers && hasTutorialContent && !tutorialComplete.get();
|
// when --url in command line, teleport to location
|
||||||
|
const QString HIFI_URL_COMMAND_LINE_KEY = "--url";
|
||||||
|
int urlIndex = arguments().indexOf(HIFI_URL_COMMAND_LINE_KEY);
|
||||||
|
QString addressLookupString;
|
||||||
|
if (urlIndex != -1) {
|
||||||
|
addressLookupString = arguments().value(urlIndex + 1);
|
||||||
|
}
|
||||||
|
|
||||||
qCDebug(interfaceapp) << "Has HMD + Hand Controllers: " << hasHMDAndHandControllers << ", current plugin: " << _displayPlugin->getName();
|
const QString TUTORIAL_PATH = "/tutorial_begin";
|
||||||
qCDebug(interfaceapp) << "Has tutorial content: " << hasTutorialContent;
|
|
||||||
qCDebug(interfaceapp) << "Tutorial complete: " << tutorialComplete.get();
|
|
||||||
qCDebug(interfaceapp) << "Should go to tutorial: " << shouldGoToTutorial;
|
|
||||||
|
|
||||||
// when --url in command line, teleport to location
|
if (shouldGoToTutorial) {
|
||||||
const QString HIFI_URL_COMMAND_LINE_KEY = "--url";
|
if (sandboxIsRunning) {
|
||||||
int urlIndex = arguments().indexOf(HIFI_URL_COMMAND_LINE_KEY);
|
qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home.";
|
||||||
QString addressLookupString;
|
DependencyManager::get<AddressManager>()->goToLocalSandbox(TUTORIAL_PATH);
|
||||||
if (urlIndex != -1) {
|
} else {
|
||||||
addressLookupString = arguments().value(urlIndex + 1);
|
qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry.";
|
||||||
}
|
if (firstRun.get()) {
|
||||||
|
showHelp();
|
||||||
const QString TUTORIAL_PATH = "/tutorial_begin";
|
}
|
||||||
|
if (addressLookupString.isEmpty()) {
|
||||||
if (shouldGoToTutorial) {
|
DependencyManager::get<AddressManager>()->goToEntry();
|
||||||
if(sandboxIsRunning) {
|
} else {
|
||||||
qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home.";
|
DependencyManager::get<AddressManager>()->loadSettings(addressLookupString);
|
||||||
DependencyManager::get<AddressManager>()->goToLocalSandbox(TUTORIAL_PATH);
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry.";
|
|
||||||
if (firstRun.get()) {
|
bool isFirstRun = firstRun.get();
|
||||||
|
|
||||||
|
if (isFirstRun) {
|
||||||
showHelp();
|
showHelp();
|
||||||
}
|
}
|
||||||
if (addressLookupString.isEmpty()) {
|
|
||||||
DependencyManager::get<AddressManager>()->goToEntry();
|
|
||||||
} else {
|
|
||||||
DependencyManager::get<AddressManager>()->loadSettings(addressLookupString);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
bool isFirstRun = firstRun.get();
|
// If this is a first run we short-circuit the address passed in
|
||||||
|
if (isFirstRun) {
|
||||||
if (isFirstRun) {
|
if (hasHMDAndHandControllers) {
|
||||||
showHelp();
|
if (sandboxIsRunning) {
|
||||||
}
|
qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home.";
|
||||||
|
DependencyManager::get<AddressManager>()->goToLocalSandbox();
|
||||||
// If this is a first run we short-circuit the address passed in
|
} else {
|
||||||
if (isFirstRun) {
|
qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry.";
|
||||||
if (hasHMDAndHandControllers) {
|
DependencyManager::get<AddressManager>()->goToEntry();
|
||||||
if(sandboxIsRunning) {
|
}
|
||||||
qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home.";
|
|
||||||
DependencyManager::get<AddressManager>()->goToLocalSandbox();
|
|
||||||
} else {
|
} else {
|
||||||
qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry.";
|
|
||||||
DependencyManager::get<AddressManager>()->goToEntry();
|
DependencyManager::get<AddressManager>()->goToEntry();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DependencyManager::get<AddressManager>()->goToEntry();
|
qCDebug(interfaceapp) << "Not first run... going to" << qPrintable(addressLookupString.isEmpty() ? QString("previous location") : addressLookupString);
|
||||||
|
DependencyManager::get<AddressManager>()->loadSettings(addressLookupString);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
qCDebug(interfaceapp) << "Not first run... going to" << qPrintable(addressLookupString.isEmpty() ? QString("previous location") : addressLookupString);
|
|
||||||
DependencyManager::get<AddressManager>()->loadSettings(addressLookupString);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_connectionMonitor.init();
|
||||||
|
|
||||||
|
// After all of the constructor is completed, then set firstRun to false.
|
||||||
|
firstRun.set(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
_connectionMonitor.init();
|
|
||||||
|
|
||||||
// After all of the constructor is completed, then set firstRun to false.
|
|
||||||
firstRun.set(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) {
|
void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) {
|
||||||
|
@ -5056,6 +5077,11 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
||||||
// AvatarManager has some custom types
|
// AvatarManager has some custom types
|
||||||
AvatarManager::registerMetaTypes(scriptEngine);
|
AvatarManager::registerMetaTypes(scriptEngine);
|
||||||
|
|
||||||
|
if (property(hifi::properties::TEST).isValid()) {
|
||||||
|
scriptEngine->registerGlobalObject("Test", TestScriptingInterface::getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptEngine->registerGlobalObject("Overlays", &_overlays);
|
||||||
scriptEngine->registerGlobalObject("Rates", new RatesScriptingInterface(this));
|
scriptEngine->registerGlobalObject("Rates", new RatesScriptingInterface(this));
|
||||||
|
|
||||||
// hook our avatar and avatar hash map object into this script engine
|
// hook our avatar and avatar hash map object into this script engine
|
||||||
|
|
30
interface/src/scripting/TestScriptingInterface.cpp
Normal file
30
interface/src/scripting/TestScriptingInterface.cpp
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2016/12/12
|
||||||
|
// Copyright 2013-2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#include "TestScriptingInterface.h"
|
||||||
|
|
||||||
|
#include <QtCore/QCoreApplication>
|
||||||
|
|
||||||
|
TestScriptingInterface* TestScriptingInterface::getInstance() {
|
||||||
|
static TestScriptingInterface sharedInstance;
|
||||||
|
return &sharedInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestScriptingInterface::quit() {
|
||||||
|
qApp->quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestScriptingInterface::waitForTextureIdle() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestScriptingInterface::waitForDownloadIdle() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestScriptingInterface::waitIdle() {
|
||||||
|
}
|
43
interface/src/scripting/TestScriptingInterface.h
Normal file
43
interface/src/scripting/TestScriptingInterface.h
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2016/12/12
|
||||||
|
// Copyright 2013-2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#ifndef hifi_TestScriptingInterface_h
|
||||||
|
#define hifi_TestScriptingInterface_h
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
|
class TestScriptingInterface : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
static TestScriptingInterface* getInstance();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Exits the application
|
||||||
|
*/
|
||||||
|
void quit();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Waits for all texture transfers to be complete
|
||||||
|
*/
|
||||||
|
void waitForTextureIdle();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Waits for all pending downloads to be complete
|
||||||
|
*/
|
||||||
|
void waitForDownloadIdle();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Waits for all pending downloads and texture transfers to be complete
|
||||||
|
*/
|
||||||
|
void waitIdle();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_TestScriptingInterface_h
|
|
@ -13,6 +13,7 @@ namespace hifi { namespace properties {
|
||||||
const char* CRASHED = "com.highfidelity.crashed";
|
const char* CRASHED = "com.highfidelity.crashed";
|
||||||
const char* STEAM = "com.highfidelity.launchedFromSteam";
|
const char* STEAM = "com.highfidelity.launchedFromSteam";
|
||||||
const char* LOGGER = "com.highfidelity.logger";
|
const char* LOGGER = "com.highfidelity.logger";
|
||||||
|
const char* TEST = "com.highfidelity.test";
|
||||||
|
|
||||||
namespace gl {
|
namespace gl {
|
||||||
const char* BACKEND = "com.highfidelity.gl.backend";
|
const char* BACKEND = "com.highfidelity.gl.backend";
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace hifi { namespace properties {
|
||||||
extern const char* CRASHED;
|
extern const char* CRASHED;
|
||||||
extern const char* STEAM;
|
extern const char* STEAM;
|
||||||
extern const char* LOGGER;
|
extern const char* LOGGER;
|
||||||
|
extern const char* TEST;
|
||||||
|
|
||||||
namespace gl {
|
namespace gl {
|
||||||
extern const char* BACKEND;
|
extern const char* BACKEND;
|
||||||
|
|
15
scripts/developer/tests/testTestMode.js
Normal file
15
scripts/developer/tests/testTestMode.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2016/12/12
|
||||||
|
// Copyright 2013-2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
print("Fooooo");
|
||||||
|
|
||||||
|
Script.setTimeout(function() {
|
||||||
|
Test.quit();
|
||||||
|
}, 10 * 1000);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue