Overte C++ Documentation
SteamClientPlugin.h
1 //
2 // SteamClientPlugin.h
3 // libraries/plugins/src/plugins
4 //
5 // Created by Clement Brisset on 12/14/16.
6 // Copyright 2016 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 
13 #ifndef hifi_SteamClientPlugin_h
14 #define hifi_SteamClientPlugin_h
15 
16 #include <functional>
17 
18 #include <QtCore/QObject>
19 #include <QtCore/QByteArray>
20 
21 using Ticket = QByteArray;
22 using TicketRequestCallback = std::function<void(Ticket)>;
23 
24 class SteamClientPlugin {
25 public:
26  virtual ~SteamClientPlugin() {};
27 
28  virtual bool init() = 0;
29  virtual void shutdown() = 0;
30 
31  virtual bool isRunning() = 0;
32 
33  virtual void runCallbacks() = 0;
34 
35  virtual void requestTicket(TicketRequestCallback callback) = 0;
36  virtual void updateLocation(QString status, QUrl locationUrl) = 0;
37  virtual void openInviteOverlay() = 0;
38  virtual void joinLobby(QString lobbyId) = 0;
39 
40  virtual int getSteamVRBuildID() = 0;
41 };
42 
43 /*@jsdoc
44  * The <code>Steam</code> API provides facilities for working with the Steam version of Interface.
45  *
46  * @namespace Steam
47  *
48  * @hifi-interface
49  * @hifi-client-entity
50  * @hifi-avatar
51  *
52  * @property {boolean} running - <code>true</code> if Interface is running under Steam, <code>false</code> if it isn't.
53  * <em>Read-only.</em>
54  */
55 
56 class SteamScriptingInterface : public QObject {
57  Q_OBJECT
58 
59  Q_PROPERTY(bool running READ isRunning)
60 
61 public:
62  SteamScriptingInterface(QObject* parent, SteamClientPlugin* plugin) : QObject(parent), _plugin(plugin) {}
63 
64 public slots:
65 
66  /*@jsdoc
67  * Gets whether Interface is running under Steam.
68  * @function Steam.isRunning
69  * @returns {boolean} <code>true</code> if Interface is running under Steam, <code>false</code> if it isn't.
70  */
71  bool isRunning() const { return _plugin && _plugin->isRunning(); }
72 
73  /*@jsdoc
74  * Opens Steam's "Choose Friends to invite" dialog if Interface is running under Steam.
75  * @function Steam.openInviteOverlay
76  * @example <caption>Invite Steam friends to join you in Overte.</caption>
77  * if (Steam.running) {
78  * print("Invite Steam friends to joint you...");
79  * Steam.openInviteOverlay();
80  * } else {
81  * print("Interface isn't running under Steam.");
82  * }
83  */
84  void openInviteOverlay() const { if (_plugin) { _plugin->openInviteOverlay(); } }
85 
86 private:
87  SteamClientPlugin* _plugin;
88 };
89 
90 #endif /* hifi_SteamClientPlugin_h */