wip for getting hmd overlay

This commit is contained in:
Wayne Chen 2018-10-29 11:33:28 -07:00
parent 6e0b89f0a6
commit ed847203ea
7 changed files with 133 additions and 138 deletions

View file

@ -1025,6 +1025,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
auto steamClient = PluginManager::getInstance()->getSteamClientPlugin();
setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning()));
setProperty(hifi::properties::CRASHED, _previousSessionCrashed);
{
const QStringList args = arguments();
@ -1223,7 +1224,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
connect(&domainHandler, &DomainHandler::domainConnectionRefused, this, &Application::domainConnectionRefused);
nodeList->getDomainHandler().setErrorDomainURL(QUrl(REDIRECT_HIFI_ADDRESS));
nodeList->getDomainHandler().setLoginScreenDomainURL(QUrl(LOGIN_SCREEN_HIFI_ADDRESS));
// We could clear ATP assets only when changing domains, but it's possible that the domain you are connected
// to has gone down and switched to a new content set, so when you reconnect the cached ATP assets will no longer be valid.
@ -1745,27 +1745,30 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
userInputMapper->registerDevice(_touchscreenVirtualPadDevice->getInputDevice());
}
{
auto scriptEngines = DependencyManager::get<ScriptEngines>().data();
// this will force the model the look at the correct directory (weird order of operations issue)
scriptEngines->reloadLocalFiles();
QString scriptsSwitch = QString("--").append(SCRIPTS_SWITCH);
_defaultScriptsLocation = getCmdOption(argc, constArgv, scriptsSwitch.toStdString().c_str());
// do this as late as possible so that all required subsystems are initialized
// If we've overridden the default scripts location, just load default scripts
// otherwise, load 'em all
//{
// auto scriptEngines = DependencyManager::get<ScriptEngines>().data();
// // this will force the model the look at the correct directory (weird order of operations issue)
// scriptEngines->reloadLocalFiles();
// we just want to see if --scripts was set, we've already parsed it and done
// the change in PathUtils. Rather than pass that in the constructor, lets just
// look (this could be debated)
QString scriptsSwitch = QString("--").append(SCRIPTS_SWITCH);
QDir defaultScriptsLocation(getCmdOption(argc, constArgv, scriptsSwitch.toStdString().c_str()));
if (!defaultScriptsLocation.exists()) {
scriptEngines->loadDefaultScripts();
scriptEngines->defaultScriptsLocationOverridden(true);
} else {
scriptEngines->loadScripts();
}
}
// // do this as late as possible so that all required subsystems are initialized
// // If we've overridden the default scripts location, just load default scripts
// // otherwise, load 'em all
// // we just want to see if --scripts was set, we've already parsed it and done
// // the change in PathUtils. Rather than pass that in the constructor, lets just
// // look (this could be debated)
// QString scriptsSwitch = QString("--").append(SCRIPTS_SWITCH);
// QDir defaultScriptsLocation(getCmdOption(argc, constArgv, scriptsSwitch.toStdString().c_str()));
// if (!defaultScriptsLocation.exists()) {
// scriptEngines->loadDefaultScripts();
// scriptEngines->defaultScriptsLocationOverridden(true);
// } else {
// scriptEngines->loadScripts();
// }
//}
// Make sure we don't time out during slow operations at startup
updateHeartbeat();
@ -2247,28 +2250,28 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
_snapshotSound = DependencyManager::get<SoundCache>()->getSound(PathUtils::resourcesUrl("sounds/snapshot/snap.wav"));
QVariant testProperty = property(hifi::properties::TEST);
qDebug() << testProperty;
if (testProperty.isValid()) {
const auto testScript = property(hifi::properties::TEST).toUrl();
//QVariant testProperty = property(hifi::properties::TEST);
//qDebug() << testProperty;
//if (testProperty.isValid()) {
// const auto testScript = property(hifi::properties::TEST).toUrl();
// Set last parameter to exit interface when the test script finishes, if so requested
DependencyManager::get<ScriptEngines>()->loadScript(testScript, false, false, false, false, quitWhenFinished);
// // Set last parameter to exit interface when the test script finishes, if so requested
// DependencyManager::get<ScriptEngines>()->loadScript(testScript, false, false, false, false, quitWhenFinished);
// This is done so we don't get a "connection time-out" message when we haven't passed in a URL.
if (arguments().contains("--url")) {
auto reply = SandboxUtils::getStatus();
connect(reply, &QNetworkReply::finished, this, [this, reply] {
handleSandboxStatus(reply);
});
}
} else {
PROFILE_RANGE(render, "GetSandboxStatus");
auto reply = SandboxUtils::getStatus();
connect(reply, &QNetworkReply::finished, this, [this, reply] {
handleSandboxStatus(reply);
});
}
// // This is done so we don't get a "connection time-out" message when we haven't passed in a URL.
// if (arguments().contains("--url")) {
// auto reply = SandboxUtils::getStatus();
// connect(reply, &QNetworkReply::finished, this, [this, reply] {
// handleSandboxStatus(reply);
// });
// }
//} else {
// PROFILE_RANGE(render, "GetSandboxStatus");
// auto reply = SandboxUtils::getStatus();
// connect(reply, &QNetworkReply::finished, this, [this, reply] {
// handleSandboxStatus(reply);
// });
//}
// Monitor model assets (e.g., from Clara.io) added to the world that may need resizing.
static const int ADD_ASSET_TO_WORLD_TIMER_INTERVAL_MS = 1000;
@ -2288,7 +2291,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
connect(this, &QCoreApplication::aboutToQuit, this, &Application::addAssetToWorldMessageClose);
connect(&domainHandler, &DomainHandler::domainURLChanged, this, &Application::addAssetToWorldMessageClose);
connect(&domainHandler, &DomainHandler::redirectToErrorDomainURL, this, &Application::addAssetToWorldMessageClose);
connect(&domainHandler, &DomainHandler::redirectToLoginScreenDomainURL, this, &Application::addAssetToWorldMessageClose);
updateSystemTabletMode();
@ -2344,6 +2346,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
connect(&AndroidHelper::instance(), &AndroidHelper::enterForeground, this, &Application::enterForeground);
AndroidHelper::instance().notifyLoadComplete();
#endif
pauseUntilLoginDetermined();
}
void Application::updateVerboseLogging() {
@ -2914,18 +2917,14 @@ void Application::showLoginScreen() {
auto accountManager = DependencyManager::get<AccountManager>();
auto dialogsManager = DependencyManager::get<DialogsManager>();
if (!accountManager->isLoggedIn()) {
// dialogsManager->showLoginScreenDialog();
_loginDialogPoppedUp = true;
dialogsManager->showLoginDialog();
QJsonObject loginData = {};
loginData["action"] = "login dialog shown";
UserActivityLogger::getInstance().logAction("encourageLoginDialog", loginData);
if (qApp->isHMDMode()) {
// create web overlay.
auto nodeList = DependencyManager::get<NodeList>();
auto loginScreenDomainURL = nodeList->getDomainHandler().getLoginScreenDomainURL();
goToLoginScreenDomainURL(loginScreenDomainURL);
}
_window->setWindowTitle("High Fidelity Interface");
} else {
resumeAfterLoginDialogActionTaken();
}
_loginDialogPoppedUp = !accountManager->isLoggedIn();
loginDialogPoppedUp.set(_loginDialogPoppedUp);
@ -3066,14 +3065,12 @@ void Application::initializeUi() {
offscreenSurfaceCache->reserve(Web3DOverlay::QML, 2);
flushMenuUpdates();
// Now that the menu is instantiated, ensure the display plugin menu is properly updated
{
auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins();
// first sort the plugins into groupings: standard, advanced, developer
std::stable_sort(displayPlugins.begin(), displayPlugins.end(),
[](const DisplayPluginPointer& a, const DisplayPluginPointer& b)->bool { return a->getGrouping() < b->getGrouping(); });
[](const DisplayPluginPointer& a, const DisplayPluginPointer& b) -> bool { return a->getGrouping() < b->getGrouping(); });
int dpIndex = 1;
// concatenate the groupings into a single list in the order: standard, advanced, developer
for(const auto& displayPlugin : displayPlugins) {
@ -3086,6 +3083,7 @@ void Application::initializeUi() {
parent->addSeparator();
}
// The display plugins are created before the menu now, so we need to do this here to hide the menu bar
// now that it exists
if (_window && _window->isFullScreen()) {
@ -3661,24 +3659,6 @@ void Application::loadErrorDomain(QUrl domainURL) {
_fullSceneReceivedCounter++;
}
void Application::loadLoginScreenDomain(QUrl domainURL) {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "loadLoginScreenDomain", Q_ARG(QUrl, domainURL));
return;
}
if (domainURL.isEmpty()) {
return;
}
auto namedPaths = prepareServerlessDomainContents(domainURL);
auto nodeList = DependencyManager::get<NodeList>();
nodeList->getDomainHandler().loadedLoginScreenDomain(namedPaths);
_fullSceneReceivedCounter++;
}
bool Application::importImage(const QString& urlString) {
qCDebug(interfaceapp) << "An image file has been dropped in";
QString filepath(urlString);
@ -3913,7 +3893,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
return;
}
if (hasFocus()) {
if (hasFocus() && !_loginDialogPoppedUp) {
if (_keyboardMouseDevice->isActive()) {
_keyboardMouseDevice->keyPressEvent(event);
}
@ -5205,9 +5185,83 @@ void Application::init() {
}
void Application::pauseUntilLoginDetermined() {
if (QThread::currentThread() != qApp->thread()) {
QMetaObject::invokeMethod(this, "pauseUntilLoginDetermined");
return;
}
auto myAvatar = qApp->getMyAvatar();
myAvatar->setEnableMeshVisible(false);
const auto& nodeList = DependencyManager::get<NodeList>();
// disconnect domain handler.
nodeList->getDomainHandler().disconnect();
Menu::getInstance()->setVisible(false);
{
auto scriptEngines = DependencyManager::get<ScriptEngines>().data();
scriptEngines->reloadLocalFiles();
scriptEngines->loadControllerScripts();
}
}
void Application::resumeAfterLoginDialogActionTaken() {
if (QThread::currentThread() != qApp->thread()) {
QMetaObject::invokeMethod(this, "resumeAfterLoginDialogActionTaken");
return;
}
auto myAvatar = qApp->getMyAvatar();
myAvatar->setEnableMeshVisible(true);
{
auto scriptEngines = DependencyManager::get<ScriptEngines>().data();
// this will force the model the look at the correct directory (weird order of operations issue)
scriptEngines->reloadLocalFiles();
// do this as late as possible so that all required subsystems are initialized
// If we've overridden the default scripts location, just load default scripts
// otherwise, load 'em all
// we just want to see if --scripts was set, we've already parsed it and done
// the change in PathUtils. Rather than pass that in the constructor, lets just
// look (this could be debated)
if (!_defaultScriptsLocation.exists()) {
scriptEngines->loadDefaultScripts();
scriptEngines->defaultScriptsLocationOverridden(true);
} else {
scriptEngines->loadScripts();
}
}
QVariant testProperty = property(hifi::properties::TEST);
qDebug() << testProperty;
if (testProperty.isValid()) {
const auto testScript = property(hifi::properties::TEST).toUrl();
// Set last parameter to exit interface when the test script finishes, if so requested
DependencyManager::get<ScriptEngines>()->loadScript(testScript, false, false, false, false, quitWhenFinished);
// This is done so we don't get a "connection time-out" message when we haven't passed in a URL.
if (arguments().contains("--url")) {
auto reply = SandboxUtils::getStatus();
connect(reply, &QNetworkReply::finished, this, [this, reply] {
handleSandboxStatus(reply);
});
}
} else {
PROFILE_RANGE(render, "GetSandboxStatus");
auto reply = SandboxUtils::getStatus();
connect(reply, &QNetworkReply::finished, this, [this, reply] {
handleSandboxStatus(reply);
});
}
const auto& nodeList = DependencyManager::get<NodeList>();
// disconnect domain handler.
nodeList->getDomainHandler().resetting();
Menu::getInstance()->setVisible(true);
}
void Application::loadAvatarScripts(const QVector<QString>& urls) {
@ -6545,7 +6599,6 @@ void Application::updateWindowTitle() const {
auto nodeList = DependencyManager::get<NodeList>();
auto accountManager = DependencyManager::get<AccountManager>();
auto isInErrorState = nodeList->getDomainHandler().isInErrorState();
auto isInLoginScreenState = nodeList->getDomainHandler().isInLoginScreenState();
QString buildVersion = " - "
+ (BuildInfo::BUILD_TYPE == BuildInfo::BuildType::Stable ? QString("Version") : QString("Build"))
@ -6555,8 +6608,6 @@ void Application::updateWindowTitle() const {
QString connectionStatus = isInErrorState ? " (ERROR CONNECTING)" :
nodeList->getDomainHandler().isConnected() ? "" : " (NOT CONNECTED)";
// check for login state - login state needs empty connection status
connectionStatus = isInLoginScreenState ? "" : connectionStatus;
QString username = accountManager->getAccountInfo().getUsername();
setCrashAnnotation("username", username.toStdString());
@ -6565,8 +6616,6 @@ void Application::updateWindowTitle() const {
if (isServerlessMode()) {
if (isInErrorState) {
currentPlaceName = "serverless: " + nodeList->getDomainHandler().getErrorDomainURL().toString();
} else if (isInLoginScreenState) {
currentPlaceName = "High Fidelity Interface";
} else {
currentPlaceName = "serverless: " + DependencyManager::get<AddressManager>()->getDomainURL().toString();
}
@ -6645,23 +6694,6 @@ void Application::goToErrorDomainURL(QUrl errorDomainURL) {
updateWindowTitle();
}
void Application::goToLoginScreenDomainURL(QUrl loginScreenDomainURL) {
// disable physics until we have enough information about our new location to not cause craziness.
resetPhysicsReadyInformation();
setIsServerlessMode(loginScreenDomainURL.scheme() != URL_SCHEME_HIFI);
// show avatar as a mesh and show hand controllers.
qApp->getMyAvatar()->setEnableMeshVisible(false);
DependencyManager::get<HMDScriptingInterface>()->requestShowHandControllers();
// set into login screen state.
emit loginScreenStateChanged(true);
if (isServerlessMode()) {
loadLoginScreenDomain(loginScreenDomainURL);
}
updateWindowTitle();
}
void Application::resettingDomain() {
_notifiedPacketVersionMismatchThisDomain = false;
@ -8459,8 +8491,6 @@ void Application::setShowBulletConstraintLimits(bool value) {
}
void Application::onDismissedLoginDialog() {
// TODO something with login dialog.
qDebug() << "dismissed login dialog";
_loginDialogPoppedUp = false;
loginDialogPoppedUp.set(false);
resumeAfterLoginDialogActionTaken();

View file

@ -339,8 +339,6 @@ signals:
void interstitialModeChanged(bool isInInterstitialMode);
void loginScreenStateChanged(bool isInLoginScreenState);
public slots:
QVector<EntityItemID> pasteEntities(float x, float y, float z);
bool exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs, const glm::vec3* givenOffset = nullptr);
@ -349,7 +347,6 @@ public slots:
void updateThreadPoolCount() const;
void updateSystemTabletMode();
void goToErrorDomainURL(QUrl errorDomainURL);
void goToLoginScreenDomainURL(QUrl loginScreenDomainURL);
Q_INVOKABLE void loadDialog();
Q_INVOKABLE void loadScriptURLDialog() const;
@ -444,7 +441,6 @@ public slots:
void loadServerlessDomain(QUrl domainURL);
void loadErrorDomain(QUrl domainURL);
void loadLoginScreenDomain(QUrl domainURL);
void setIsInterstitialMode(bool interstitialMode);
void updateVerboseLogging();
@ -664,6 +660,8 @@ private:
QPointer<LogDialog> _logDialog;
QPointer<EntityScriptServerLogDialog> _entityScriptServerLogDialog;
QDir _defaultScriptsLocation{""};
FileLogger* _logger;
TouchEvent _lastTouchEvent;

View file

@ -33,7 +33,6 @@ void ConnectionMonitor::init() {
connect(&domainHandler, &DomainHandler::connectedToDomain, this, &ConnectionMonitor::stopTimer);
connect(&domainHandler, &DomainHandler::domainConnectionRefused, this, &ConnectionMonitor::stopTimer);
connect(&domainHandler, &DomainHandler::redirectToErrorDomainURL, this, &ConnectionMonitor::stopTimer);
connect(&domainHandler, &DomainHandler::redirectToLoginScreenDomainURL, this, &ConnectionMonitor::stopTimer);
connect(this, &ConnectionMonitor::setRedirectErrorState, &domainHandler, &DomainHandler::setRedirectErrorState);
_timer.setSingleShot(true);

View file

@ -62,16 +62,6 @@ DomainHandler::DomainHandler(QObject* parent) :
// stop the refresh timer if redirected to the error domain
connect(this, &DomainHandler::redirectToErrorDomainURL, &_apiRefreshTimer, &QTimer::stop);
// stop the refresh timer if redirected to the login screen domain
connect(this, &DomainHandler::redirectToLoginScreenDomainURL, &_apiRefreshTimer, &QTimer::stop);
// stop the refresh timer if redirected to the login screen domain
connect(this, &DomainHandler::redirectToLoginScreenDomainURL, [this]() {
_isInLoginScreenState = true;
qCDebug(networking) << "Redirecting user to " << _loginScreenDomainURL;
});
}
void DomainHandler::disconnect() {
@ -123,7 +113,7 @@ void DomainHandler::softReset() {
QMetaObject::invokeMethod(&_settingsTimer, "stop");
// restart the API refresh timer in case we fail to connect and need to refresh information
if (!_isInErrorState || !_isInLoginScreenState) {
if (!_isInErrorState) {
QMetaObject::invokeMethod(&_apiRefreshTimer, "start");
}
}
@ -135,9 +125,6 @@ void DomainHandler::hardReset() {
_isInErrorState = false;
emit redirectErrorStateChanged(_isInErrorState);
_isInLoginScreenState = false;
emit loginScreenStateChanged(_isInLoginScreenState);
qCDebug(networking) << "Hard reset in NodeList DomainHandler.";
_pendingDomainID = QUuid();
_iceServerSockAddr = HifiSockAddr();
@ -176,11 +163,6 @@ void DomainHandler::setErrorDomainURL(const QUrl& url) {
return;
}
void DomainHandler::setLoginScreenDomainURL(const QUrl& url) {
_loginScreenDomainURL = url;
return;
}
void DomainHandler::setSockAddr(const HifiSockAddr& sockAddr, const QString& hostname) {
if (_sockAddr != sockAddr) {
// we should reset on a sockAddr change
@ -383,17 +365,6 @@ void DomainHandler::loadedErrorDomain(std::map<QString, QString> namedPaths) {
DependencyManager::get<AddressManager>()->goToViewpointForPath(viewpoint, QString());
}
void DomainHandler::loadedLoginScreenDomain(std::map<QString, QString> namedPaths) {
auto lookup = namedPaths.find("/");
QString viewpoint;
if (lookup != namedPaths.end()) {
viewpoint = lookup->second;
} else {
viewpoint = DOMAIN_SPAWNING_POINT;
}
DependencyManager::get<AddressManager>()->goToViewpointForPath(viewpoint, QString());
}
void DomainHandler::setRedirectErrorState(QUrl errorUrl, QString reasonMessage, int reasonCode, const QString& extraInfo) {
_lastDomainConnectionError = reasonCode;
if (getInterstitialModeEnabled() && isHardRefusal(reasonCode)) {

View file

@ -58,9 +58,6 @@ public:
int getLastDomainConnectionError() { return _lastDomainConnectionError; }
QUrl getLoginScreenDomainURL(){ return _loginScreenDomainURL; }
void setLoginScreenDomainURL(const QUrl& url);
const QHostAddress& getIP() const { return _sockAddr.getAddress(); }
void setIPToLocalhost() { _sockAddr.setAddress(QHostAddress(QHostAddress::LocalHost)); }
@ -96,8 +93,6 @@ public:
void loadedErrorDomain(std::map<QString, QString> namedPaths);
void loadedLoginScreenDomain(std::map<QString, QString> namedPaths);
QString getViewPointFromNamedPath(QString namedPath);
bool hasSettings() const { return !_settingsObject.isEmpty(); }
@ -211,9 +206,6 @@ signals:
void redirectToErrorDomainURL(QUrl errorDomainURL);
void redirectErrorStateChanged(bool isInErrorState);
void redirectToLoginScreenDomainURL();
void loginScreenStateChanged(bool isInLoginScreenState);
void limitOfSilentDomainCheckInsReached();
private:
@ -227,7 +219,6 @@ private:
Node::LocalID _localID;
QUrl _domainURL;
QUrl _errorDomainURL;
QUrl _loginScreenDomainURL;
HifiSockAddr _sockAddr;
QUuid _assignmentUUID;
QUuid _connectionToken;

View file

@ -28,6 +28,7 @@ static const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStanda
static const bool HIFI_SCRIPT_DEBUGGABLES { true };
static const QString SETTINGS_KEY { "RunningScripts" };
static const QUrl DEFAULT_SCRIPTS_LOCATION { "file:///~//defaultScripts.js" };
static const QUrl CONTROLLER_SCRIPTS_LOCATION { "file:///~//system//controllers//controllerScripts.js" };
// Using a QVariantList so this is human-readable in the settings file
static Setting::Handle<QVariantList> runningScriptsHandle(SETTINGS_KEY, { QVariant(DEFAULT_SCRIPTS_LOCATION) });
@ -287,6 +288,10 @@ void ScriptEngines::loadDefaultScripts() {
loadScript(DEFAULT_SCRIPTS_LOCATION);
}
void ScriptEngines::loadControllerScripts() {
loadScript(CONTROLLER_SCRIPTS_LOCATION);
}
void ScriptEngines::loadOneScript(const QString& scriptFilename) {
loadScript(scriptFilename);
}

View file

@ -65,6 +65,7 @@ public:
void setDebugScriptUrl(const QString& url) { _debugScriptUrl = url; };
void loadDefaultScripts();
void loadControllerScripts();
void reloadLocalFiles();
QStringList getRunningScripts();