2019-07-31 20:21:02 +00:00
|
|
|
#ifndef __INCLUDED_STEAM_OVERLAY_H__
|
|
|
|
#define __INCLUDED_STEAM_OVERLAY_H__
|
2019-07-25 21:33:07 +00:00
|
|
|
|
2019-07-31 20:21:02 +00:00
|
|
|
#include "../dll/base.h"
|
2019-08-02 09:16:30 +00:00
|
|
|
#include <map>
|
2019-08-02 11:02:20 +00:00
|
|
|
#include <queue>
|
2019-07-25 21:33:07 +00:00
|
|
|
|
2019-08-03 10:58:48 +00:00
|
|
|
static constexpr size_t max_chat_len = 768;
|
|
|
|
|
2019-08-02 11:02:20 +00:00
|
|
|
enum window_state
|
2019-07-31 20:21:02 +00:00
|
|
|
{
|
2019-08-16 16:31:56 +00:00
|
|
|
window_state_none = 0,
|
|
|
|
window_state_show = 1<<0,
|
|
|
|
window_state_invite = 1<<1,
|
|
|
|
window_state_join = 1<<2,
|
|
|
|
window_state_lobby_invite = 1<<3,
|
|
|
|
window_state_rich_invite = 1<<4,
|
|
|
|
window_state_send_message = 1<<5,
|
|
|
|
window_state_need_attention = 1<<6,
|
2019-07-31 20:21:02 +00:00
|
|
|
};
|
2019-07-25 21:33:07 +00:00
|
|
|
|
2019-08-02 11:02:20 +00:00
|
|
|
struct friend_window_state
|
2019-08-02 09:16:30 +00:00
|
|
|
{
|
2019-10-11 11:10:48 +00:00
|
|
|
int id;
|
2019-08-02 11:02:20 +00:00
|
|
|
uint8 window_state;
|
2019-10-14 14:35:36 +00:00
|
|
|
std::string window_title;
|
2019-08-03 10:58:48 +00:00
|
|
|
union // The invitation (if any)
|
2019-08-02 09:16:30 +00:00
|
|
|
{
|
|
|
|
uint64 lobbyId;
|
|
|
|
char connect[k_cchMaxRichPresenceValueLength];
|
|
|
|
};
|
2019-08-03 10:58:48 +00:00
|
|
|
std::string chat_history;
|
|
|
|
char chat_input[max_chat_len];
|
2019-08-02 09:16:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Friend_Less
|
|
|
|
{
|
|
|
|
bool operator()(const Friend& lhs, const Friend& rhs) const
|
|
|
|
{
|
|
|
|
return lhs.id() < rhs.id();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-09-04 17:31:31 +00:00
|
|
|
struct Notification
|
|
|
|
{
|
2019-09-05 07:00:02 +00:00
|
|
|
static constexpr float width = 0.25;
|
|
|
|
static constexpr float height = 4.0;
|
2019-09-04 17:31:31 +00:00
|
|
|
static constexpr std::chrono::milliseconds fade_in = std::chrono::milliseconds(2000);
|
|
|
|
static constexpr std::chrono::milliseconds fade_out = std::chrono::milliseconds(2000);
|
|
|
|
static constexpr std::chrono::milliseconds show_time = std::chrono::milliseconds(6000) + fade_in + fade_out;
|
|
|
|
static constexpr std::chrono::milliseconds fade_out_start = show_time - fade_out;
|
|
|
|
static constexpr float r = 0.16;
|
|
|
|
static constexpr float g = 0.29;
|
|
|
|
static constexpr float b = 0.48;
|
|
|
|
static constexpr float max_alpha = 0.5f;
|
2019-10-11 11:10:48 +00:00
|
|
|
|
|
|
|
int id;
|
2019-09-04 17:31:31 +00:00
|
|
|
std::chrono::seconds start_time;
|
|
|
|
std::string message;
|
|
|
|
};
|
|
|
|
|
2019-08-14 13:09:57 +00:00
|
|
|
#ifndef NO_OVERLAY
|
2019-08-14 12:55:31 +00:00
|
|
|
|
2019-07-25 21:33:07 +00:00
|
|
|
class Steam_Overlay
|
|
|
|
{
|
|
|
|
Settings* settings;
|
|
|
|
SteamCallResults* callback_results;
|
|
|
|
SteamCallBacks* callbacks;
|
|
|
|
RunEveryRunCB* run_every_runcb;
|
2019-07-31 20:21:02 +00:00
|
|
|
Networking* network;
|
|
|
|
|
2019-08-02 09:16:30 +00:00
|
|
|
// friend id, show client window (to chat and accept invite maybe)
|
2019-08-02 11:02:20 +00:00
|
|
|
std::map<Friend, friend_window_state, Friend_Less> friends;
|
2019-07-25 21:33:07 +00:00
|
|
|
|
2019-08-26 14:38:01 +00:00
|
|
|
bool setup_overlay_called;
|
2019-07-25 21:33:07 +00:00
|
|
|
bool is_ready;
|
|
|
|
bool show_overlay;
|
|
|
|
ENotificationPosition notif_position;
|
|
|
|
int h_inset, v_inset;
|
|
|
|
|
2019-07-31 20:21:02 +00:00
|
|
|
// Callback infos
|
2019-08-02 11:02:20 +00:00
|
|
|
std::queue<Friend> has_friend_action;
|
2019-09-04 17:31:31 +00:00
|
|
|
std::vector<Notification> notifications;
|
2019-07-31 20:21:02 +00:00
|
|
|
bool overlay_state_changed;
|
|
|
|
|
2019-07-25 21:33:07 +00:00
|
|
|
Steam_Overlay(Steam_Overlay const&) = delete;
|
|
|
|
Steam_Overlay(Steam_Overlay&&) = delete;
|
|
|
|
Steam_Overlay& operator=(Steam_Overlay const&) = delete;
|
|
|
|
Steam_Overlay& operator=(Steam_Overlay&&) = delete;
|
|
|
|
|
2019-07-31 20:21:02 +00:00
|
|
|
static void steam_overlay_run_every_runcb(void* object);
|
2019-08-03 10:58:48 +00:00
|
|
|
static void steam_overlay_callback(void* object, Common_Message* msg);
|
|
|
|
|
|
|
|
void Callback(Common_Message* msg);
|
2019-07-31 20:21:02 +00:00
|
|
|
void RunCallbacks();
|
2019-07-25 21:33:07 +00:00
|
|
|
|
2019-08-06 11:46:43 +00:00
|
|
|
bool FriendHasLobby(uint64 friend_id);
|
|
|
|
bool IHaveLobby();
|
|
|
|
|
2019-09-04 17:31:31 +00:00
|
|
|
void NotifyUser(friend_window_state& friend_state, std::string const& message);
|
|
|
|
|
2019-08-02 13:26:16 +00:00
|
|
|
// Right click on friend
|
|
|
|
void BuildContextMenu(Friend const& frd, friend_window_state &state);
|
|
|
|
// Double click on friend
|
|
|
|
void BuildFriendWindow(Friend const& frd, friend_window_state &state);
|
2019-08-26 17:36:07 +00:00
|
|
|
// Notifications like achievements, chat and invitations
|
2019-09-04 17:31:31 +00:00
|
|
|
void BuildNotifications(int width, int height);
|
2019-07-25 21:33:07 +00:00
|
|
|
public:
|
2019-07-31 20:21:02 +00:00
|
|
|
Steam_Overlay(Settings* settings, SteamCallResults* callback_results, SteamCallBacks* callbacks, RunEveryRunCB* run_every_runcb, Networking *network);
|
2019-07-25 21:33:07 +00:00
|
|
|
|
2019-07-31 20:21:02 +00:00
|
|
|
~Steam_Overlay();
|
2019-07-25 21:33:07 +00:00
|
|
|
|
2019-07-31 20:21:02 +00:00
|
|
|
bool Ready() const;
|
2019-07-25 21:33:07 +00:00
|
|
|
|
2019-07-31 20:21:02 +00:00
|
|
|
bool NeedPresent() const;
|
2019-07-25 21:33:07 +00:00
|
|
|
|
2019-07-31 20:21:02 +00:00
|
|
|
void SetNotificationPosition(ENotificationPosition eNotificationPosition);
|
2019-07-25 21:33:07 +00:00
|
|
|
|
2019-07-31 20:21:02 +00:00
|
|
|
void SetNotificationInset(int nHorizontalInset, int nVerticalInset);
|
|
|
|
void SetupOverlay();
|
2019-07-25 21:33:07 +00:00
|
|
|
|
2019-08-18 14:22:07 +00:00
|
|
|
void HookReady();
|
2019-07-25 21:33:07 +00:00
|
|
|
|
2019-09-05 07:00:02 +00:00
|
|
|
void CreateFonts();
|
|
|
|
void OverlayProc();
|
2019-07-25 21:33:07 +00:00
|
|
|
|
2019-07-31 20:21:02 +00:00
|
|
|
void OpenOverlayInvite(CSteamID lobbyId);
|
|
|
|
void OpenOverlay(const char* pchDialog);
|
2019-07-25 21:33:07 +00:00
|
|
|
|
2019-08-18 14:22:07 +00:00
|
|
|
bool ShowOverlay() const;
|
2019-07-31 20:21:02 +00:00
|
|
|
void ShowOverlay(bool state);
|
2019-08-02 09:16:30 +00:00
|
|
|
|
2019-08-02 21:01:24 +00:00
|
|
|
void SetLobbyInvite(Friend friendId, uint64 lobbyId);
|
|
|
|
void SetRichInvite(Friend friendId, const char* connect_str);
|
2019-08-02 09:16:30 +00:00
|
|
|
|
|
|
|
void FriendConnect(Friend _friend);
|
|
|
|
void FriendDisconnect(Friend _friend);
|
2019-09-04 17:31:31 +00:00
|
|
|
|
|
|
|
void AddNotification(std::string const& message);
|
2019-07-31 20:21:02 +00:00
|
|
|
};
|
2019-07-25 21:33:07 +00:00
|
|
|
|
2019-08-14 12:55:31 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
class Steam_Overlay
|
|
|
|
{
|
|
|
|
public:
|
2019-09-05 07:00:02 +00:00
|
|
|
Steam_Overlay(Settings* settings, SteamCallResults* callback_results, SteamCallBacks* callbacks, RunEveryRunCB* run_every_runcb, Networking* network) {}
|
2019-08-14 16:11:00 +00:00
|
|
|
~Steam_Overlay() {}
|
2019-08-14 12:55:31 +00:00
|
|
|
|
2019-08-14 16:11:00 +00:00
|
|
|
bool Ready() const { return false; }
|
2019-08-14 12:55:31 +00:00
|
|
|
|
|
|
|
bool NeedPresent() const { return false; }
|
|
|
|
|
|
|
|
void SetNotificationPosition(ENotificationPosition eNotificationPosition) {}
|
|
|
|
|
|
|
|
void SetNotificationInset(int nHorizontalInset, int nVerticalInset) {}
|
|
|
|
void SetupOverlay() {}
|
|
|
|
|
2019-09-05 07:00:02 +00:00
|
|
|
void HookReady() {}
|
2019-08-14 12:55:31 +00:00
|
|
|
|
2019-09-05 07:00:02 +00:00
|
|
|
void CreateFonts() {}
|
|
|
|
void OverlayProc() {}
|
2019-08-14 12:55:31 +00:00
|
|
|
|
|
|
|
void OpenOverlayInvite(CSteamID lobbyId) {}
|
|
|
|
void OpenOverlay(const char* pchDialog) {}
|
|
|
|
|
2019-09-05 07:00:02 +00:00
|
|
|
bool ShowOverlay() const {}
|
2019-08-14 12:55:31 +00:00
|
|
|
void ShowOverlay(bool state) {}
|
|
|
|
|
|
|
|
void SetLobbyInvite(Friend friendId, uint64 lobbyId) {}
|
|
|
|
void SetRichInvite(Friend friendId, const char* connect_str) {}
|
|
|
|
|
|
|
|
void FriendConnect(Friend _friend) {}
|
|
|
|
void FriendDisconnect(Friend _friend) {}
|
2019-09-04 17:40:22 +00:00
|
|
|
|
|
|
|
void AddNotification(std::string const& message) {}
|
2019-08-14 12:55:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2019-07-31 20:21:02 +00:00
|
|
|
#endif//__INCLUDED_STEAM_OVERLAY_H__
|