mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 23:33:48 +02:00
Invite friends in HMD
This commit is contained in:
parent
a13950752b
commit
42c9a695ff
5 changed files with 58 additions and 3 deletions
|
@ -1599,6 +1599,8 @@ void Application::initializeUi() {
|
|||
rootContext->setContextProperty("Reticle", getApplicationCompositor().getReticleInterface());
|
||||
|
||||
rootContext->setContextProperty("ApplicationCompositor", &getApplicationCompositor());
|
||||
|
||||
rootContext->setContextProperty("Steam", new SteamScriptingInterface(engine));
|
||||
|
||||
|
||||
_glWidget->installEventFilter(offscreenUi.data());
|
||||
|
@ -4799,6 +4801,8 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
|||
|
||||
scriptEngine->registerGlobalObject("UserActivityLogger", DependencyManager::get<UserActivityLoggerScriptingInterface>().data());
|
||||
scriptEngine->registerGlobalObject("Users", DependencyManager::get<UsersScriptingInterface>().data());
|
||||
|
||||
scriptEngine->registerGlobalObject("Steam", new SteamScriptingInterface(scriptEngine));
|
||||
}
|
||||
|
||||
bool Application::canAcceptURL(const QString& urlString) const {
|
||||
|
|
|
@ -149,7 +149,7 @@ private:
|
|||
};
|
||||
|
||||
SteamCallbackManager::SteamCallbackManager() :
|
||||
_gameRichPresenceJoinRequestedResponse(this, &SteamCallbackManager::onGameRichPresenceJoinRequested)
|
||||
_gameRichPresenceJoinRequestedResponse(this, &SteamCallbackManager::onGameRichPresenceJoinRequested)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ void SteamCallbackManager::onGameRichPresenceJoinRequested(GameRichPresenceJoinR
|
|||
url.remove(-CONNECT_SUFFIX.size(), CONNECT_SUFFIX.size());
|
||||
}
|
||||
|
||||
qDebug() << "Joining Steam Friends at:" << url;
|
||||
qDebug() << "Joining Steam Friend at:" << url;
|
||||
auto mimeData = new QMimeData();
|
||||
mimeData->setUrls(QList<QUrl>() << QUrl(url));
|
||||
auto event = new QDropEvent(QPointF(0,0), Qt::MoveAction, mimeData, Qt::LeftButton, Qt::NoModifier);
|
||||
|
@ -169,7 +169,6 @@ void SteamCallbackManager::onGameRichPresenceJoinRequested(GameRichPresenceJoinR
|
|||
QCoreApplication::postEvent(qApp, event);
|
||||
}
|
||||
|
||||
|
||||
static std::atomic_bool initialized { false };
|
||||
static SteamCallbackManager steamCallbackManager;
|
||||
|
||||
|
@ -239,3 +238,12 @@ void SteamClient::updateLocation(QString status, QUrl locationUrl) {
|
|||
SteamFriends()->SetRichPresence("status", status.toLocal8Bit().data());
|
||||
SteamFriends()->SetRichPresence("connect", connectStr.toLocal8Bit().data());
|
||||
}
|
||||
|
||||
void SteamClient::openInviteOverlay() {
|
||||
if (!initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "Inviting steam friends";
|
||||
SteamFriends()->ActivateGameOverlayInviteDialog(CSteamID());
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <functional>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QByteArray>
|
||||
|
||||
using Ticket = QByteArray;
|
||||
|
@ -33,6 +34,21 @@ public:
|
|||
|
||||
static void requestTicket(TicketRequestCallback callback);
|
||||
static void updateLocation(QString status, QUrl locationUrl);
|
||||
static void openInviteOverlay();
|
||||
|
||||
};
|
||||
|
||||
class SteamScriptingInterface : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(bool isRunning READ isRunning)
|
||||
|
||||
public:
|
||||
SteamScriptingInterface(QObject* parent) : QObject(parent) {}
|
||||
|
||||
public slots:
|
||||
bool isRunning() const { return SteamClient::isRunning(); }
|
||||
void openInviteOverlay() const { SteamClient::openInviteOverlay(); }
|
||||
|
||||
};
|
||||
|
||||
|
|
BIN
scripts/system/assets/images/tools/steam.jpeg
Normal file
BIN
scripts/system/assets/images/tools/steam.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 979 B |
27
scripts/system/steam.js
Normal file
27
scripts/system/steam.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
//
|
||||
// steam.js
|
||||
// scripts/system/
|
||||
//
|
||||
// Created by Clement on 7/28/16
|
||||
// Copyright 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
|
||||
//
|
||||
|
||||
var toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system");
|
||||
|
||||
|
||||
var steamInviteButton = toolBar.addButton({
|
||||
objectName: "steamInvite",
|
||||
imageURL: Script.resolvePath("assets/images/tools/steam.jpeg"),
|
||||
visible: Steam.isRunning,
|
||||
});
|
||||
|
||||
steamInviteButton.clicked.connect(function(){
|
||||
Steam.openInviteOverlay();
|
||||
});
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
toolBar.removeButton("steamInvite");
|
||||
});
|
Loading…
Reference in a new issue