Compare commits

..

No commits in common. "b1206b0fa24a17e1a9c50714c9b8688f0bb93e82" and "e0af31894851ffb39cba1ee8aa9fb8d37cca0ac7" have entirely different histories.

5 changed files with 68 additions and 112 deletions

View File

@ -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_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) { button = 2; }
if (msg == WM_XBUTTONDOWN || msg == WM_XBUTTONDBLCLK) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; }
// if (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL)
// ::SetCapture(hwnd);
if (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL)
::SetCapture(hwnd);
io.MouseDown[button] = true;
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_XBUTTONUP) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; }
io.MouseDown[button] = false;
// if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd)
// ::ReleaseCapture();
if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd)
::ReleaseCapture();
return 0;
}
case WM_MOUSEWHEEL:

View File

@ -3,9 +3,9 @@ call build_set_protobuf_directories.bat
"%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
call build_env_x86.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def
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 /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 steamnetworkingsockets.cpp /EHsc /MP12 /link /OUT:steamnetworkingsockets.dll
call build_env_x64.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def
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 /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 steamnetworkingsockets.cpp /EHsc /MP12 /link /OUT:steamnetworkingsockets64.dll

View File

@ -21,9 +21,6 @@
#define ORPHANED_PACKET_TIMEOUT (20)
#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
struct Steam_Networking_Connection {
@ -81,7 +78,6 @@ public ISteamNetworking
std::vector<struct steam_connection_socket> connection_sockets;
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)
{
@ -823,7 +819,10 @@ void RunCallbacks()
if (!msg.network().processed()) {
if (!connection_exists(source_id)) {
if (new_connection_times.find(source_id) == new_connection_times.end()) {
new_connections_to_call_cb.push(source_id);
P2PSessionRequest_t data;
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();
}
} else {
@ -856,25 +855,6 @@ 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
remove_killed_connection_sockets();

View File

@ -89,8 +89,7 @@ Steam_Overlay::Steam_Overlay(Settings* settings, SteamCallResults* callback_resu
notif_position(ENotificationPosition::k_EPositionBottomLeft),
h_inset(0),
v_inset(0),
overlay_state_changed(false),
i_have_lobby(false)
overlay_state_changed(false)
{
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);
@ -284,7 +283,6 @@ void Steam_Overlay::FriendConnect(Friend _friend)
item.window_state = window_state_none;
item.id = id;
memset(item.chat_input, 0, max_chat_len);
item.has_lobby = false;
}
else
PRINT_DEBUG("No more free id to create a friend window\n");
@ -300,7 +298,7 @@ void Steam_Overlay::FriendDisconnect(Friend _friend)
void Steam_Overlay::AddMessageNotification(std::string const& message)
{
std::lock_guard<std::recursive_mutex> lock(notifications_mutex);
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
int id = find_free_notification_id(notifications);
if (id != 0)
{
@ -317,7 +315,7 @@ void Steam_Overlay::AddMessageNotification(std::string const& message)
void Steam_Overlay::AddAchievementNotification(nlohmann::json const& ach)
{
std::lock_guard<std::recursive_mutex> lock(notifications_mutex);
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
int id = find_free_notification_id(notifications);
if (id != 0)
{
@ -335,7 +333,7 @@ void Steam_Overlay::AddAchievementNotification(nlohmann::json const& ach)
void Steam_Overlay::AddInviteNotification(std::pair<const Friend, friend_window_state>& wnd_state)
{
std::lock_guard<std::recursive_mutex> lock(notifications_mutex);
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
int id = find_free_notification_id(notifications);
if (id != 0)
{
@ -392,13 +390,13 @@ void Steam_Overlay::BuildContextMenu(Friend const& frd, friend_window_state& sta
// If we have the same appid, activate the invite/join buttons
if (settings->get_local_game_id().AppID() == frd.appid())
{
if (i_have_lobby && ImGui::Button("Invite###PopupInvite"))
if (IHaveLobby() && ImGui::Button("Invite###PopupInvite"))
{
state.window_state |= window_state_invite;
has_friend_action.push(frd);
close_popup = true;
}
if (state.has_lobby && ImGui::Button("Join###PopupJoin"))
if (FriendHasLobby(frd.id()) && ImGui::Button("Join###PopupJoin"))
{
state.window_state |= window_state_join;
has_friend_action.push(frd);
@ -522,11 +520,6 @@ void Steam_Overlay::BuildNotifications(int width, int height)
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)
{
auto elapsed_notif = now - it->start_time;
@ -567,7 +560,7 @@ void Steam_Overlay::BuildNotifications(int width, int height)
ImGui::TextWrapped("%s", it->message.c_str());
if (ImGui::Button("Join"))
{
friend_actions_temp.push(it->frd->first);
has_friend_action.push(it->frd->first);
it->start_time = std::chrono::seconds(0);
}
}
@ -585,15 +578,6 @@ void Steam_Overlay::BuildNotifications(int width, int height)
}), 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()
{
ImGuiIO& io = ImGui::GetIO();
@ -622,11 +606,16 @@ void Steam_Overlay::OverlayProc()
ImGuiIO& io = ImGui::GetIO();
ImGui::PushFont(font_notif);
overlay_mutex.lock();
BuildNotifications(io.DisplaySize.x, io.DisplaySize.y);
overlay_mutex.unlock();
ImGui::PopFont();
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
ImGui::SetNextWindowPos({ 0,0 });
ImGui::SetNextWindowSize({ static_cast<float>(io.DisplaySize.x),
@ -651,11 +640,9 @@ void Steam_Overlay::OverlayProc()
ImGui::Spacing();
ImGui::LabelText("##label", "Friends");
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
if (!friends.empty())
{
ImGui::ListBoxHeader("##label", friends.size());
ImGui::ListBoxHeader("##label", friend_size);
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);
@ -720,13 +707,7 @@ void Steam_Overlay::RunCallbacks()
Steam_Friends* steamFriends = get_steam_client()->steam_friends;
Steam_Matchmaking* steamMatchmaking = get_steam_client()->steam_matchmaking;
i_have_lobby = IHaveLobby();
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())
{
auto friend_info = friends.find(has_friend_action.front());

View File

@ -31,8 +31,6 @@ struct friend_window_state
};
std::string chat_history;
char chat_input[max_chat_len];
bool has_lobby;
};
struct Friend_Less
@ -92,12 +90,9 @@ class Steam_Overlay
// Callback infos
std::queue<Friend> has_friend_action;
std::vector<Notification> notifications;
std::recursive_mutex notifications_mutex;
bool overlay_state_changed;
std::recursive_mutex overlay_mutex;
std::atomic<bool> i_have_lobby;
Steam_Overlay(Steam_Overlay const&) = delete;
Steam_Overlay(Steam_Overlay&&) = delete;