Compare commits
5 Commits
e0af318948
...
b1206b0fa2
Author | SHA1 | Date |
---|---|---|
Mr_Goldberg | b1206b0fa2 | |
Mr_Goldberg | 39d1d8dcdf | |
Mr_Goldberg | 92218b08c6 | |
Mr_Goldberg | eace15df47 | |
Mr_Goldberg | 6d96784af1 |
|
@ -270,8 +270,8 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
||||||
if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) { button = 1; }
|
if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) { button = 1; }
|
||||||
if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) { button = 2; }
|
if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) { button = 2; }
|
||||||
if (msg == WM_XBUTTONDOWN || msg == WM_XBUTTONDBLCLK) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; }
|
if (msg == WM_XBUTTONDOWN || msg == WM_XBUTTONDBLCLK) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; }
|
||||||
if (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL)
|
// if (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL)
|
||||||
::SetCapture(hwnd);
|
// ::SetCapture(hwnd);
|
||||||
io.MouseDown[button] = true;
|
io.MouseDown[button] = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -286,8 +286,8 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
||||||
if (msg == WM_MBUTTONUP) { button = 2; }
|
if (msg == WM_MBUTTONUP) { button = 2; }
|
||||||
if (msg == WM_XBUTTONUP) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; }
|
if (msg == WM_XBUTTONUP) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; }
|
||||||
io.MouseDown[button] = false;
|
io.MouseDown[button] = false;
|
||||||
if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd)
|
// if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd)
|
||||||
::ReleaseCapture();
|
// ::ReleaseCapture();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
|
|
|
@ -3,9 +3,9 @@ call build_set_protobuf_directories.bat
|
||||||
"%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
|
"%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
|
||||||
call build_env_x86.bat
|
call build_env_x86.bat
|
||||||
cl dll/rtlgenrandom.c dll/rtlgenrandom.def
|
cl dll/rtlgenrandom.c dll/rtlgenrandom.def
|
||||||
cl /LD /I%PROTOBUF_X86_DIRECTORY%\include\ /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DEMU_EXPERIMENTAL_BUILD dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c "%PROTOBUF_X86_LIBRARY%" Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib /EHsc /MP12 /link /OUT:steamclient.dll
|
cl /LD /IImGui /Iglew\include /I%PROTOBUF_X86_DIRECTORY%\include\ /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DEMU_EXPERIMENTAL_BUILD /DGLEW_STATIC /DEMU_OVERLAY dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X86_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /link /OUT:steamclient.dll
|
||||||
cl /LD steamnetworkingsockets.cpp /EHsc /MP12 /link /OUT:steamnetworkingsockets.dll
|
cl /LD steamnetworkingsockets.cpp /EHsc /MP12 /link /OUT:steamnetworkingsockets.dll
|
||||||
call build_env_x64.bat
|
call build_env_x64.bat
|
||||||
cl dll/rtlgenrandom.c dll/rtlgenrandom.def
|
cl dll/rtlgenrandom.c dll/rtlgenrandom.def
|
||||||
cl /LD /I%PROTOBUF_X64_DIRECTORY%\include\ /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DEMU_EXPERIMENTAL_BUILD dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c "%PROTOBUF_X64_LIBRARY%" Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib /EHsc /MP12 /link /OUT:steamclient64.dll
|
cl /LD /IImGui /Iglew\include /I%PROTOBUF_X64_DIRECTORY%\include\ /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DEMU_EXPERIMENTAL_BUILD /DGLEW_STATIC /DEMU_OVERLAY dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X64_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /link /OUT:steamclient64.dll
|
||||||
cl /LD steamnetworkingsockets.cpp /EHsc /MP12 /link /OUT:steamnetworkingsockets64.dll
|
cl /LD steamnetworkingsockets.cpp /EHsc /MP12 /link /OUT:steamnetworkingsockets64.dll
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
#define ORPHANED_PACKET_TIMEOUT (20)
|
#define ORPHANED_PACKET_TIMEOUT (20)
|
||||||
#define NEW_CONNECTION_TIMEOUT (20.0)
|
#define NEW_CONNECTION_TIMEOUT (20.0)
|
||||||
|
|
||||||
|
//kingdom 2 crowns doesn't work with a 0.3 delay or lower
|
||||||
|
#define NEW_CONNECTION_DELAY (0.4)
|
||||||
|
|
||||||
#define OLD_CHANNEL_NUMBER 1
|
#define OLD_CHANNEL_NUMBER 1
|
||||||
|
|
||||||
struct Steam_Networking_Connection {
|
struct Steam_Networking_Connection {
|
||||||
|
@ -78,6 +81,7 @@ public ISteamNetworking
|
||||||
std::vector<struct steam_connection_socket> connection_sockets;
|
std::vector<struct steam_connection_socket> connection_sockets;
|
||||||
|
|
||||||
std::map<CSteamID, std::chrono::high_resolution_clock::time_point> new_connection_times;
|
std::map<CSteamID, std::chrono::high_resolution_clock::time_point> new_connection_times;
|
||||||
|
std::queue<CSteamID> new_connections_to_call_cb;
|
||||||
|
|
||||||
bool connection_exists(CSteamID id)
|
bool connection_exists(CSteamID id)
|
||||||
{
|
{
|
||||||
|
@ -819,10 +823,7 @@ void RunCallbacks()
|
||||||
if (!msg.network().processed()) {
|
if (!msg.network().processed()) {
|
||||||
if (!connection_exists(source_id)) {
|
if (!connection_exists(source_id)) {
|
||||||
if (new_connection_times.find(source_id) == new_connection_times.end()) {
|
if (new_connection_times.find(source_id) == new_connection_times.end()) {
|
||||||
P2PSessionRequest_t data;
|
new_connections_to_call_cb.push(source_id);
|
||||||
memset(&data, 0, sizeof(data));
|
|
||||||
data.m_steamIDRemote = CSteamID(source_id);
|
|
||||||
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data), 0.1);
|
|
||||||
new_connection_times[source_id] = std::chrono::high_resolution_clock::now();
|
new_connection_times[source_id] = std::chrono::high_resolution_clock::now();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -855,6 +856,25 @@ void RunCallbacks()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (!new_connections_to_call_cb.empty()) {
|
||||||
|
CSteamID source_id = new_connections_to_call_cb.front();
|
||||||
|
auto t = new_connection_times.find(source_id);
|
||||||
|
if (t == new_connection_times.end()) {
|
||||||
|
new_connections_to_call_cb.pop();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!check_timedout(t->second, NEW_CONNECTION_DELAY)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
P2PSessionRequest_t data;
|
||||||
|
memset(&data, 0, sizeof(data));
|
||||||
|
data.m_steamIDRemote = source_id;
|
||||||
|
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
|
||||||
|
new_connections_to_call_cb.pop();
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: not sure if sockets should be wiped right away
|
//TODO: not sure if sockets should be wiped right away
|
||||||
remove_killed_connection_sockets();
|
remove_killed_connection_sockets();
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,8 @@ Steam_Overlay::Steam_Overlay(Settings* settings, SteamCallResults* callback_resu
|
||||||
notif_position(ENotificationPosition::k_EPositionBottomLeft),
|
notif_position(ENotificationPosition::k_EPositionBottomLeft),
|
||||||
h_inset(0),
|
h_inset(0),
|
||||||
v_inset(0),
|
v_inset(0),
|
||||||
overlay_state_changed(false)
|
overlay_state_changed(false),
|
||||||
|
i_have_lobby(false)
|
||||||
{
|
{
|
||||||
run_every_runcb->add(&Steam_Overlay::steam_overlay_run_every_runcb, this);
|
run_every_runcb->add(&Steam_Overlay::steam_overlay_run_every_runcb, this);
|
||||||
this->network->setCallback(CALLBACK_ID_STEAM_MESSAGES, settings->get_local_steam_id(), &Steam_Overlay::steam_overlay_callback, this);
|
this->network->setCallback(CALLBACK_ID_STEAM_MESSAGES, settings->get_local_steam_id(), &Steam_Overlay::steam_overlay_callback, this);
|
||||||
|
@ -283,6 +284,7 @@ void Steam_Overlay::FriendConnect(Friend _friend)
|
||||||
item.window_state = window_state_none;
|
item.window_state = window_state_none;
|
||||||
item.id = id;
|
item.id = id;
|
||||||
memset(item.chat_input, 0, max_chat_len);
|
memset(item.chat_input, 0, max_chat_len);
|
||||||
|
item.has_lobby = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
PRINT_DEBUG("No more free id to create a friend window\n");
|
PRINT_DEBUG("No more free id to create a friend window\n");
|
||||||
|
@ -298,7 +300,7 @@ void Steam_Overlay::FriendDisconnect(Friend _friend)
|
||||||
|
|
||||||
void Steam_Overlay::AddMessageNotification(std::string const& message)
|
void Steam_Overlay::AddMessageNotification(std::string const& message)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
std::lock_guard<std::recursive_mutex> lock(notifications_mutex);
|
||||||
int id = find_free_notification_id(notifications);
|
int id = find_free_notification_id(notifications);
|
||||||
if (id != 0)
|
if (id != 0)
|
||||||
{
|
{
|
||||||
|
@ -315,7 +317,7 @@ void Steam_Overlay::AddMessageNotification(std::string const& message)
|
||||||
|
|
||||||
void Steam_Overlay::AddAchievementNotification(nlohmann::json const& ach)
|
void Steam_Overlay::AddAchievementNotification(nlohmann::json const& ach)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
std::lock_guard<std::recursive_mutex> lock(notifications_mutex);
|
||||||
int id = find_free_notification_id(notifications);
|
int id = find_free_notification_id(notifications);
|
||||||
if (id != 0)
|
if (id != 0)
|
||||||
{
|
{
|
||||||
|
@ -333,7 +335,7 @@ void Steam_Overlay::AddAchievementNotification(nlohmann::json const& ach)
|
||||||
|
|
||||||
void Steam_Overlay::AddInviteNotification(std::pair<const Friend, friend_window_state>& wnd_state)
|
void Steam_Overlay::AddInviteNotification(std::pair<const Friend, friend_window_state>& wnd_state)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
std::lock_guard<std::recursive_mutex> lock(notifications_mutex);
|
||||||
int id = find_free_notification_id(notifications);
|
int id = find_free_notification_id(notifications);
|
||||||
if (id != 0)
|
if (id != 0)
|
||||||
{
|
{
|
||||||
|
@ -390,13 +392,13 @@ void Steam_Overlay::BuildContextMenu(Friend const& frd, friend_window_state& sta
|
||||||
// If we have the same appid, activate the invite/join buttons
|
// If we have the same appid, activate the invite/join buttons
|
||||||
if (settings->get_local_game_id().AppID() == frd.appid())
|
if (settings->get_local_game_id().AppID() == frd.appid())
|
||||||
{
|
{
|
||||||
if (IHaveLobby() && ImGui::Button("Invite###PopupInvite"))
|
if (i_have_lobby && ImGui::Button("Invite###PopupInvite"))
|
||||||
{
|
{
|
||||||
state.window_state |= window_state_invite;
|
state.window_state |= window_state_invite;
|
||||||
has_friend_action.push(frd);
|
has_friend_action.push(frd);
|
||||||
close_popup = true;
|
close_popup = true;
|
||||||
}
|
}
|
||||||
if (FriendHasLobby(frd.id()) && ImGui::Button("Join###PopupJoin"))
|
if (state.has_lobby && ImGui::Button("Join###PopupJoin"))
|
||||||
{
|
{
|
||||||
state.window_state |= window_state_join;
|
state.window_state |= window_state_join;
|
||||||
has_friend_action.push(frd);
|
has_friend_action.push(frd);
|
||||||
|
@ -520,6 +522,11 @@ void Steam_Overlay::BuildNotifications(int width, int height)
|
||||||
|
|
||||||
int font_size = ImGui::GetFontSize();
|
int font_size = ImGui::GetFontSize();
|
||||||
|
|
||||||
|
std::queue<Friend> friend_actions_temp;
|
||||||
|
|
||||||
|
{
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(notifications_mutex);
|
||||||
|
|
||||||
for (auto it = notifications.begin(); it != notifications.end(); ++it, ++i)
|
for (auto it = notifications.begin(); it != notifications.end(); ++it, ++i)
|
||||||
{
|
{
|
||||||
auto elapsed_notif = now - it->start_time;
|
auto elapsed_notif = now - it->start_time;
|
||||||
|
@ -560,7 +567,7 @@ void Steam_Overlay::BuildNotifications(int width, int height)
|
||||||
ImGui::TextWrapped("%s", it->message.c_str());
|
ImGui::TextWrapped("%s", it->message.c_str());
|
||||||
if (ImGui::Button("Join"))
|
if (ImGui::Button("Join"))
|
||||||
{
|
{
|
||||||
has_friend_action.push(it->frd->first);
|
friend_actions_temp.push(it->frd->first);
|
||||||
it->start_time = std::chrono::seconds(0);
|
it->start_time = std::chrono::seconds(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -576,6 +583,15 @@ void Steam_Overlay::BuildNotifications(int width, int height)
|
||||||
notifications.erase(std::remove_if(notifications.begin(), notifications.end(), [&now](Notification &item) {
|
notifications.erase(std::remove_if(notifications.begin(), notifications.end(), [&now](Notification &item) {
|
||||||
return (now - item.start_time) > Notification::show_time;
|
return (now - item.start_time) > Notification::show_time;
|
||||||
}), notifications.end());
|
}), notifications.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!friend_actions_temp.empty()) {
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||||
|
while (!friend_actions_temp.empty()) {
|
||||||
|
has_friend_action.push(friend_actions_temp.front());
|
||||||
|
friend_actions_temp.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Steam_Overlay::CreateFonts()
|
void Steam_Overlay::CreateFonts()
|
||||||
|
@ -606,16 +622,11 @@ void Steam_Overlay::OverlayProc()
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
ImGui::PushFont(font_notif);
|
ImGui::PushFont(font_notif);
|
||||||
overlay_mutex.lock();
|
|
||||||
BuildNotifications(io.DisplaySize.x, io.DisplaySize.y);
|
BuildNotifications(io.DisplaySize.x, io.DisplaySize.y);
|
||||||
overlay_mutex.unlock();
|
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
|
|
||||||
if (show_overlay)
|
if (show_overlay)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
|
||||||
int friend_size = friends.size();
|
|
||||||
|
|
||||||
// Set the overlay windows to the size of the game window
|
// Set the overlay windows to the size of the game window
|
||||||
ImGui::SetNextWindowPos({ 0,0 });
|
ImGui::SetNextWindowPos({ 0,0 });
|
||||||
ImGui::SetNextWindowSize({ static_cast<float>(io.DisplaySize.x),
|
ImGui::SetNextWindowSize({ static_cast<float>(io.DisplaySize.x),
|
||||||
|
@ -640,9 +651,11 @@ void Steam_Overlay::OverlayProc()
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
|
|
||||||
ImGui::LabelText("##label", "Friends");
|
ImGui::LabelText("##label", "Friends");
|
||||||
|
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||||
if (!friends.empty())
|
if (!friends.empty())
|
||||||
{
|
{
|
||||||
ImGui::ListBoxHeader("##label", friend_size);
|
ImGui::ListBoxHeader("##label", friends.size());
|
||||||
std::for_each(friends.begin(), friends.end(), [this](std::pair<Friend const, friend_window_state> &i)
|
std::for_each(friends.begin(), friends.end(), [this](std::pair<Friend const, friend_window_state> &i)
|
||||||
{
|
{
|
||||||
ImGui::PushID(i.second.id-base_friend_window_id+base_friend_item_id);
|
ImGui::PushID(i.second.id-base_friend_window_id+base_friend_item_id);
|
||||||
|
@ -707,7 +720,13 @@ void Steam_Overlay::RunCallbacks()
|
||||||
Steam_Friends* steamFriends = get_steam_client()->steam_friends;
|
Steam_Friends* steamFriends = get_steam_client()->steam_friends;
|
||||||
Steam_Matchmaking* steamMatchmaking = get_steam_client()->steam_matchmaking;
|
Steam_Matchmaking* steamMatchmaking = get_steam_client()->steam_matchmaking;
|
||||||
|
|
||||||
|
i_have_lobby = IHaveLobby();
|
||||||
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||||
|
std::for_each(friends.begin(), friends.end(), [this](std::pair<Friend const, friend_window_state> &i)
|
||||||
|
{
|
||||||
|
i.second.has_lobby = FriendHasLobby(i.first.id());
|
||||||
|
});
|
||||||
|
|
||||||
while (!has_friend_action.empty())
|
while (!has_friend_action.empty())
|
||||||
{
|
{
|
||||||
auto friend_info = friends.find(has_friend_action.front());
|
auto friend_info = friends.find(has_friend_action.front());
|
||||||
|
|
|
@ -31,6 +31,8 @@ struct friend_window_state
|
||||||
};
|
};
|
||||||
std::string chat_history;
|
std::string chat_history;
|
||||||
char chat_input[max_chat_len];
|
char chat_input[max_chat_len];
|
||||||
|
|
||||||
|
bool has_lobby;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Friend_Less
|
struct Friend_Less
|
||||||
|
@ -90,9 +92,12 @@ class Steam_Overlay
|
||||||
// Callback infos
|
// Callback infos
|
||||||
std::queue<Friend> has_friend_action;
|
std::queue<Friend> has_friend_action;
|
||||||
std::vector<Notification> notifications;
|
std::vector<Notification> notifications;
|
||||||
|
std::recursive_mutex notifications_mutex;
|
||||||
|
|
||||||
bool overlay_state_changed;
|
bool overlay_state_changed;
|
||||||
|
|
||||||
std::recursive_mutex overlay_mutex;
|
std::recursive_mutex overlay_mutex;
|
||||||
|
std::atomic<bool> i_have_lobby;
|
||||||
|
|
||||||
Steam_Overlay(Steam_Overlay const&) = delete;
|
Steam_Overlay(Steam_Overlay const&) = delete;
|
||||||
Steam_Overlay(Steam_Overlay&&) = delete;
|
Steam_Overlay(Steam_Overlay&&) = delete;
|
||||||
|
|
Loading…
Reference in New Issue