History

Make Steamworks a plugin

Atlante45 committed 9 years ago

Commit 0dec97f1 parent 1829f5418 files · +299 −160Browse files

Showing the changes to interface/src/Application.cpp (1 of 18 files). Show all

Unified · Split

interface/src/Application.cpp+35−15
@@ -90,9 +90,10 @@ · 89 unmodified lines
90#include <PerfStat.h>90#include <PerfStat.h>
91#include <PhysicsEngine.h>91#include <PhysicsEngine.h>
92#include <PhysicsHelpers.h>92#include <PhysicsHelpers.h>
93#include <plugins/CodecPlugin.h>
93#include <plugins/PluginManager.h>94#include <plugins/PluginManager.h>
94#include <plugins/PluginUtils.h>95#include <plugins/PluginUtils.h>
95#include <plugins/CodecPlugin.h>96#include <plugins/SteamClientPlugin.h>
96#include <RecordingScriptingInterface.h>97#include <RecordingScriptingInterface.h>
97#include <RenderableWebEntityItem.h>98#include <RenderableWebEntityItem.h>
98#include <RenderShadowTask.h>99#include <RenderShadowTask.h>
@@ -103,7 +104,6 @@ · 4 unmodified lines
103#include <ScriptEngines.h>104#include <ScriptEngines.h>
104#include <ScriptCache.h>105#include <ScriptCache.h>
105#include <SoundCache.h>106#include <SoundCache.h>
106#include <steamworks-wrapper/SteamClient.h>
107#include <Tooltip.h>107#include <Tooltip.h>
108#include <udt/PacketHeaders.h>108#include <udt/PacketHeaders.h>
109#include <UserActivityLogger.h>109#include <UserActivityLogger.h>
@@ -421,6 +421,10 @@ bool setupEssentials(int& argc, char** argv) { · 311 unmodified lines
421 421
422 Setting::preInit();422 Setting::preInit();
423 423
424 if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
425 steamClient->init();
426 }
427
424#if defined(Q_OS_WIN)428#if defined(Q_OS_WIN)
425 // Select appropriate audio DLL429 // Select appropriate audio DLL
426 QString audioDLLPath = QCoreApplication::applicationDirPath();430 QString audioDLLPath = QCoreApplication::applicationDirPath();
@@ -551,7 +555,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 124 unmodified lines
551 _maxOctreePPS(maxOctreePacketsPerSecond.get()),555 _maxOctreePPS(maxOctreePacketsPerSecond.get()),
552 _lastFaceTrackerUpdate(0)556 _lastFaceTrackerUpdate(0)
553{557{
554 setProperty(hifi::properties::STEAM, SteamClient::isRunning());558 auto steamClient = PluginManager::getInstance()->getSteamClientPlugin();
559 setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning()));
555 setProperty(hifi::properties::CRASHED, _previousSessionCrashed);560 setProperty(hifi::properties::CRASHED, _previousSessionCrashed);
556 561
557 {562 {
@@ -606,7 +611,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 48 unmodified lines
606 _deadlockWatchdogThread = new DeadlockWatchdogThread();611 _deadlockWatchdogThread = new DeadlockWatchdogThread();
607 _deadlockWatchdogThread->start();612 _deadlockWatchdogThread->start();
608 613
609 qCDebug(interfaceapp) << "[VERSION] SteamVR buildID:" << SteamClient::getSteamVRBuildID();614 if (steamClient) {
615 qCDebug(interfaceapp) << "[VERSION] SteamVR buildID:" << steamClient->getSteamVRBuildID();
616 }
610 qCDebug(interfaceapp) << "[VERSION] Build sequence:" << qPrintable(applicationVersion());617 qCDebug(interfaceapp) << "[VERSION] Build sequence:" << qPrintable(applicationVersion());
611 qCDebug(interfaceapp) << "[VERSION] MODIFIED_ORGANIZATION:" << BuildInfo::MODIFIED_ORGANIZATION;618 qCDebug(interfaceapp) << "[VERSION] MODIFIED_ORGANIZATION:" << BuildInfo::MODIFIED_ORGANIZATION;
612 qCDebug(interfaceapp) << "[VERSION] VERSION:" << BuildInfo::VERSION;619 qCDebug(interfaceapp) << "[VERSION] VERSION:" << BuildInfo::VERSION;
@@ -1695,6 +1702,10 @@ Application::~Application() { · 1082 unmodified lines
1695 1702
1696 Leapmotion::destroy();1703 Leapmotion::destroy();
1697 1704
1705 if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
1706 steamClient->shutdown();
1707 }
1708
1698#if 01709#if 0
1699 ConnexionClient::getInstance().destroy();1710 ConnexionClient::getInstance().destroy();
1700#endif1711#endif
@@ -1874,8 +1885,10 @@ void Application::initializeUi() { · 173 unmodified lines
1874 1885
1875 rootContext->setContextProperty("ApplicationCompositor", &getApplicationCompositor());1886 rootContext->setContextProperty("ApplicationCompositor", &getApplicationCompositor());
1876 1887
1877 rootContext->setContextProperty("Steam", new SteamScriptingInterface(engine));1888 if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
1878 1889 rootContext->setContextProperty("Steam", new SteamScriptingInterface(engine, steamClient.get()));
1890 }
1891
1879 1892
1880 _glWidget->installEventFilter(offscreenUi.data());1893 _glWidget->installEventFilter(offscreenUi.data());
1881 offscreenUi->setMouseTranslator([=](const QPointF& pt) {1894 offscreenUi->setMouseTranslator([=](const QPointF& pt) {
@@ -3201,7 +3214,9 @@ void Application::idle(float nsecsElapsed) { · 1319 unmodified lines
3201 3214
3202 PROFILE_RANGE(__FUNCTION__);3215 PROFILE_RANGE(__FUNCTION__);
3203 3216
3204 SteamClient::runCallbacks();3217 if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
3218 steamClient->runCallbacks();
3219 }
3205 3220
3206 float secondsSinceLastUpdate = nsecsElapsed / NSECS_PER_MSEC / MSECS_PER_SECOND;3221 float secondsSinceLastUpdate = nsecsElapsed / NSECS_PER_MSEC / MSECS_PER_SECOND;
3207 3222
@@ -3533,12 +3548,16 @@ void Application::init() { · 325 unmodified lines
3533 3548
3534 _timerStart.start();3549 _timerStart.start();
3535 _lastTimeUpdated.start();3550 _lastTimeUpdated.start();
3536 // when +connect_lobby in command line, join steam lobby3551
3537 const QString STEAM_LOBBY_COMMAND_LINE_KEY = "+connect_lobby";3552
3538 int lobbyIndex = arguments().indexOf(STEAM_LOBBY_COMMAND_LINE_KEY);3553 if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
3539 if (lobbyIndex != -1) {3554 // when +connect_lobby in command line, join steam lobby
3540 QString lobbyId = arguments().value(lobbyIndex + 1);3555 const QString STEAM_LOBBY_COMMAND_LINE_KEY = "+connect_lobby";
3541 SteamClient::joinLobby(lobbyId);3556 int lobbyIndex = arguments().indexOf(STEAM_LOBBY_COMMAND_LINE_KEY);
3557 if (lobbyIndex != -1) {
3558 QString lobbyId = arguments().value(lobbyIndex + 1);
3559 steamClient->joinLobby(lobbyId);
3560 }
3542 }3561 }
3543 3562
3544 3563
@@ -5193,8 +5212,9 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 1648 unmodified lines
5193 scriptEngine->registerGlobalObject("UserActivityLogger", DependencyManager::get<UserActivityLoggerScriptingInterface>().data());5212 scriptEngine->registerGlobalObject("UserActivityLogger", DependencyManager::get<UserActivityLoggerScriptingInterface>().data());
5194 scriptEngine->registerGlobalObject("Users", DependencyManager::get<UsersScriptingInterface>().data());5213 scriptEngine->registerGlobalObject("Users", DependencyManager::get<UsersScriptingInterface>().data());
5195 5214
5196 scriptEngine->registerGlobalObject("Steam", new SteamScriptingInterface(scriptEngine));5215 if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
5197 5216 scriptEngine->registerGlobalObject("Steam", new SteamScriptingInterface(scriptEngine, steamClient.get()));
5217 }
5198 auto scriptingInterface = DependencyManager::get<controller::ScriptingInterface>();5218 auto scriptingInterface = DependencyManager::get<controller::ScriptingInterface>();
5199 scriptEngine->registerGlobalObject("Controller", scriptingInterface.data());5219 scriptEngine->registerGlobalObject("Controller", scriptingInterface.data());
5200 UserInputMapper::registerControllerTypes(scriptEngine);5220 UserInputMapper::registerControllerTypes(scriptEngine);