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
9090 #include <PerfStat.h>
9191 #include <PhysicsEngine.h>
9292 #include <PhysicsHelpers.h>
93+#include <plugins/CodecPlugin.h>
9394 #include <plugins/PluginManager.h>
9495 #include <plugins/PluginUtils.h>
95−#include <plugins/CodecPlugin.h>
96+#include <plugins/SteamClientPlugin.h>
9697 #include <RecordingScriptingInterface.h>
9798 #include <RenderableWebEntityItem.h>
9899 #include <RenderShadowTask.h>
@@ -103,7 +104,6 @@ · 4 unmodified lines
103104 #include <ScriptEngines.h>
104105 #include <ScriptCache.h>
105106 #include <SoundCache.h>
106−#include <steamworks-wrapper/SteamClient.h>
107107 #include <Tooltip.h>
108108 #include <udt/PacketHeaders.h>
109109 #include <UserActivityLogger.h>
@@ -421,6 +421,10 @@ bool setupEssentials(int& argc, char** argv) { · 311 unmodified lines
421421
422422 Setting::preInit();
423423
424+ if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
425+ steamClient->init();
426+ }
427+
424428 #if defined(Q_OS_WIN)
425429 // Select appropriate audio DLL
426430 QString audioDLLPath = QCoreApplication::applicationDirPath();
@@ -551,7 +555,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 124 unmodified lines
551555 _maxOctreePPS(maxOctreePacketsPerSecond.get()),
552556 _lastFaceTrackerUpdate(0)
553557 {
554− setProperty(hifi::properties::STEAM, SteamClient::isRunning());
558+ auto steamClient = PluginManager::getInstance()->getSteamClientPlugin();
559+ setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning()));
555560 setProperty(hifi::properties::CRASHED, _previousSessionCrashed);
556561
557562 {
@@ -606,7 +611,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 48 unmodified lines
606611 _deadlockWatchdogThread = new DeadlockWatchdogThread();
607612 _deadlockWatchdogThread->start();
608613
609− qCDebug(interfaceapp) << "[VERSION] SteamVR buildID:" << SteamClient::getSteamVRBuildID();
614+ if (steamClient) {
615+ qCDebug(interfaceapp) << "[VERSION] SteamVR buildID:" << steamClient->getSteamVRBuildID();
616+ }
610617 qCDebug(interfaceapp) << "[VERSION] Build sequence:" << qPrintable(applicationVersion());
611618 qCDebug(interfaceapp) << "[VERSION] MODIFIED_ORGANIZATION:" << BuildInfo::MODIFIED_ORGANIZATION;
612619 qCDebug(interfaceapp) << "[VERSION] VERSION:" << BuildInfo::VERSION;
@@ -1695,6 +1702,10 @@ Application::~Application() { · 1082 unmodified lines
16951702
16961703 Leapmotion::destroy();
16971704
1705+ if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
1706+ steamClient->shutdown();
1707+ }
1708+
16981709 #if 0
16991710 ConnexionClient::getInstance().destroy();
17001711 #endif
@@ -1874,8 +1885,10 @@ void Application::initializeUi() { · 173 unmodified lines
18741885
18751886 rootContext->setContextProperty("ApplicationCompositor", &getApplicationCompositor());
18761887
1877− rootContext->setContextProperty("Steam", new SteamScriptingInterface(engine));
1878−
1888+ if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
1889+ rootContext->setContextProperty("Steam", new SteamScriptingInterface(engine, steamClient.get()));
1890+ }
1891+
18791892
18801893 _glWidget->installEventFilter(offscreenUi.data());
18811894 offscreenUi->setMouseTranslator([=](const QPointF& pt) {
@@ -3201,7 +3214,9 @@ void Application::idle(float nsecsElapsed) { · 1319 unmodified lines
32013214
32023215 PROFILE_RANGE(__FUNCTION__);
32033216
3204− SteamClient::runCallbacks();
3217+ if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
3218+ steamClient->runCallbacks();
3219+ }
32053220
32063221 float secondsSinceLastUpdate = nsecsElapsed / NSECS_PER_MSEC / MSECS_PER_SECOND;
32073222
@@ -3533,12 +3548,16 @@ void Application::init() { · 325 unmodified lines
35333548
35343549 _timerStart.start();
35353550 _lastTimeUpdated.start();
3536− // when +connect_lobby in command line, join steam lobby
3537− const QString STEAM_LOBBY_COMMAND_LINE_KEY = "+connect_lobby";
3538− int lobbyIndex = arguments().indexOf(STEAM_LOBBY_COMMAND_LINE_KEY);
3539− if (lobbyIndex != -1) {
3540− QString lobbyId = arguments().value(lobbyIndex + 1);
3541− SteamClient::joinLobby(lobbyId);
3551+
3552+
3553+ if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
3554+ // when +connect_lobby in command line, join steam lobby
3555+ const QString STEAM_LOBBY_COMMAND_LINE_KEY = "+connect_lobby";
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+ }
35423561 }
35433562
35443563
@@ -5193,8 +5212,9 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 1648 unmodified lines
51935212 scriptEngine->registerGlobalObject("UserActivityLogger", DependencyManager::get<UserActivityLoggerScriptingInterface>().data());
51945213 scriptEngine->registerGlobalObject("Users", DependencyManager::get<UsersScriptingInterface>().data());
51955214
5196− scriptEngine->registerGlobalObject("Steam", new SteamScriptingInterface(scriptEngine));
5197−
5215+ if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
5216+ scriptEngine->registerGlobalObject("Steam", new SteamScriptingInterface(scriptEngine, steamClient.get()));
5217+ }
51985218 auto scriptingInterface = DependencyManager::get<controller::ScriptingInterface>();
51995219 scriptEngine->registerGlobalObject("Controller", scriptingInterface.data());
52005220 UserInputMapper::registerControllerTypes(scriptEngine);