mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-01-09 02:43:38 +08:00
feat(Players): Added friends again
This commit is contained in:
parent
accabcdfa1
commit
b9f61c522b
@ -13,10 +13,23 @@ namespace big
|
||||
ImGui::SetNextWindowPos({ g.window.x - width, height_correction }, ImGuiCond_Always);
|
||||
if (g.window.users && ImGui::Begin("###player_menu", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoNav))
|
||||
{
|
||||
ImGui::Text("Friends:");
|
||||
for (auto& item : g_player_service->m_players)
|
||||
{
|
||||
std::unique_ptr<player>& plyr = item.second;
|
||||
if (ImGui::Button(plyr->get_name(), { ImGui::GetWindowSize().x - 15.f, 0.f }))
|
||||
if (plyr->is_friend() && ImGui::Button(plyr->get_name(), { ImGui::GetWindowSize().x - 15.f, 0.f }))
|
||||
{
|
||||
g_player_service->set_selected(plyr.get());
|
||||
|
||||
g.window.player = true;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Text("Players:");
|
||||
for (auto& item : g_player_service->m_players)
|
||||
{
|
||||
std::unique_ptr<player>& plyr = item.second;
|
||||
if (!plyr->is_friend() && ImGui::Button(plyr->get_name(), { ImGui::GetWindowSize().x - 15.f, 0.f }))
|
||||
{
|
||||
g_player_service->set_selected(plyr.get());
|
||||
|
||||
|
25
BigBaseV2/src/services/friends_service.cpp
Normal file
25
BigBaseV2/src/services/friends_service.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include "friends_service.hpp"
|
||||
#include "pointers.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
friends_service::friends_service()
|
||||
{
|
||||
g_friends_service = this;
|
||||
}
|
||||
|
||||
friends_service::~friends_service()
|
||||
{
|
||||
g_friends_service = nullptr;
|
||||
}
|
||||
|
||||
bool friends_service::is_friend(const std::unique_ptr<player>& plyr)
|
||||
{
|
||||
const std::uint64_t rockstar_id = plyr->get_net_data()->m_rockstar_id2;
|
||||
for (std::uint32_t i = 0; i < g_pointers->m_friend_registry->m_friend_count; i++)
|
||||
if (rockstar_id == g_pointers->m_friend_registry->m_friends_list->m_data[i].m_rockstar_id)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
16
BigBaseV2/src/services/friends_service.hpp
Normal file
16
BigBaseV2/src/services/friends_service.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include "player_service.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
class friends_service final
|
||||
{
|
||||
public:
|
||||
friends_service();
|
||||
virtual ~friends_service();
|
||||
|
||||
static bool is_friend(const std::unique_ptr<player>& plyr);
|
||||
};
|
||||
|
||||
inline friends_service* g_friends_service{};
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
#include "gta_util.hpp"
|
||||
#include "friends_service.hpp"
|
||||
#include "player_service.hpp"
|
||||
#include "util/notify.hpp"
|
||||
|
||||
@ -58,6 +59,12 @@ namespace big
|
||||
return m_net_game_player == nullptr ? false : m_net_game_player->is_host();
|
||||
}
|
||||
|
||||
bool player::is_friend()
|
||||
{
|
||||
return m_is_friend;
|
||||
}
|
||||
|
||||
|
||||
bool player::is_valid()
|
||||
{
|
||||
return m_net_game_player == nullptr ? false : m_net_game_player->is_valid();
|
||||
@ -85,6 +92,7 @@ namespace big
|
||||
if (CNetGamePlayer* net_game_player = network_player_mgr->m_player_list[i]; net_game_player != nullptr)
|
||||
{
|
||||
std::unique_ptr<player> plyr = std::make_unique<player>(net_game_player);
|
||||
plyr->m_is_friend = friends_service::is_friend(plyr);
|
||||
|
||||
m_players.emplace(
|
||||
plyr->to_lowercase_identifier(),
|
||||
@ -132,6 +140,7 @@ namespace big
|
||||
notify::player_joined(net_game_player);
|
||||
|
||||
std::unique_ptr<player> plyr = std::make_unique<player>(net_game_player);
|
||||
plyr->m_is_friend = friends_service::is_friend(plyr);
|
||||
|
||||
m_players.emplace(
|
||||
plyr->to_lowercase_identifier(),
|
||||
|
@ -9,6 +9,7 @@ namespace big
|
||||
|
||||
CNetGamePlayer* m_net_game_player = nullptr;
|
||||
std::string m_identifier;
|
||||
bool m_is_friend;
|
||||
|
||||
public:
|
||||
player(CNetGamePlayer* net_game_player);
|
||||
@ -23,6 +24,7 @@ namespace big
|
||||
|
||||
uint8_t id();
|
||||
|
||||
bool is_friend();
|
||||
bool is_host();
|
||||
bool is_valid();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user