mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-06-23 01:02:23 +08:00
feat(Players): Made list alphabetical
This commit is contained in:
@ -11,6 +11,9 @@ namespace big
|
|||||||
if (busy) return;
|
if (busy) return;
|
||||||
busy = true;
|
busy = true;
|
||||||
|
|
||||||
|
int friend_count = 0;
|
||||||
|
int player_count = 0;
|
||||||
|
|
||||||
for (Player i = 0; i < 32; i++)
|
for (Player i = 0; i < 32; i++)
|
||||||
{
|
{
|
||||||
if (NETWORK::NETWORK_IS_PLAYER_CONNECTED(i) && i != PLAYER::PLAYER_ID())
|
if (NETWORK::NETWORK_IS_PLAYER_CONNECTED(i) && i != PLAYER::PLAYER_ID())
|
||||||
@ -24,7 +27,13 @@ namespace big
|
|||||||
NETWORK::NETWORK_HANDLE_FROM_PLAYER(i, &iNetworkHandle[0], 13);
|
NETWORK::NETWORK_HANDLE_FROM_PLAYER(i, &iNetworkHandle[0], 13);
|
||||||
NETWORK::NETWORK_IS_HANDLE_VALID(&iNetworkHandle[0], 13) && NETWORK::NETWORK_IS_FRIEND(&iNetworkHandle[0]);
|
NETWORK::NETWORK_IS_HANDLE_VALID(&iNetworkHandle[0], 13) && NETWORK::NETWORK_IS_FRIEND(&iNetworkHandle[0]);
|
||||||
|
|
||||||
g.players[i].is_friend = NETWORK::NETWORK_IS_HANDLE_VALID(iNetworkHandle, 13) && NETWORK::NETWORK_IS_FRIEND(iNetworkHandle);
|
if (NETWORK::NETWORK_IS_HANDLE_VALID(iNetworkHandle, 13) && NETWORK::NETWORK_IS_FRIEND(iNetworkHandle))
|
||||||
|
{
|
||||||
|
g.players[i].is_friend = true;
|
||||||
|
|
||||||
|
friend_count++;
|
||||||
|
}
|
||||||
|
else player_count++;
|
||||||
|
|
||||||
strcpy(g.players[i].name, PLAYER::GET_PLAYER_NAME(i));
|
strcpy(g.players[i].name, PLAYER::GET_PLAYER_NAME(i));
|
||||||
}
|
}
|
||||||
@ -37,6 +46,9 @@ namespace big
|
|||||||
script::get_current()->yield();
|
script::get_current()->yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g.friend_count = friend_count;
|
||||||
|
g.player_count = player_count;
|
||||||
|
|
||||||
busy = false;
|
busy = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -43,6 +43,8 @@ struct globals {
|
|||||||
int y;
|
int y;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int friend_count = 0;
|
||||||
|
int player_count = 0;
|
||||||
CPlayer players[32];
|
CPlayer players[32];
|
||||||
CPlayer selected_player;
|
CPlayer selected_player;
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#include <algorithm>
|
||||||
|
#include <iterator>
|
||||||
#include "gui/window.hpp"
|
#include "gui/window.hpp"
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
|
||||||
@ -12,7 +14,7 @@ namespace big
|
|||||||
ImGui::SetNextWindowPos({ g.window.x - width, height_correction }, ImGuiCond_Always);
|
ImGui::SetNextWindowPos({ g.window.x - width, height_correction }, ImGuiCond_Always);
|
||||||
if (ImGui::Begin("###player_menu", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoNav))
|
if (ImGui::Begin("###player_menu", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoNav))
|
||||||
{
|
{
|
||||||
auto vecButtonWidth = ImVec2(ImGui::GetWindowSize().x - 30.f, 0.0f);
|
auto vecButtonWidth = ImVec2(ImGui::GetWindowSize().x - 15.f, 0.0f);
|
||||||
|
|
||||||
//ImGui::TextColored({ 255,255,255,255 }, "YOU:");
|
//ImGui::TextColored({ 255,255,255,255 }, "YOU:");
|
||||||
|
|
||||||
@ -24,15 +26,19 @@ namespace big
|
|||||||
|
|
||||||
//ImGui::Separator();
|
//ImGui::Separator();
|
||||||
|
|
||||||
|
CPlayer players[32];
|
||||||
|
std::copy(std::begin(g.players), std::end(g.players), std::begin(players));
|
||||||
|
std::sort(std::begin(players), std::end(players));
|
||||||
|
|
||||||
char title[64];
|
char title[64];
|
||||||
sprintf(title, "Friends (%d)###friend_lists", 0);
|
sprintf(title, "Friends (%d)###friend_lists", g.friend_count);
|
||||||
if (ImGui::TreeNode(title))
|
if (ImGui::TreeNode(title))
|
||||||
{
|
{
|
||||||
ImGui::Unindent();
|
ImGui::Unindent();
|
||||||
|
|
||||||
bool friendInLobby = false;
|
bool friendInLobby = false;
|
||||||
|
|
||||||
for (auto& player : g.players)
|
for (auto& player : players)
|
||||||
{
|
{
|
||||||
if (player.is_friend && player.is_online)
|
if (player.is_friend && player.is_online)
|
||||||
{
|
{
|
||||||
@ -56,12 +62,12 @@ namespace big
|
|||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(title, "Players (%d)###player_lists", 0);
|
sprintf(title, "Players (%d)###player_lists", g.player_count);
|
||||||
if (ImGui::TreeNode(title))
|
if (ImGui::TreeNode(title))
|
||||||
{
|
{
|
||||||
ImGui::Unindent();
|
ImGui::Unindent();
|
||||||
|
|
||||||
for (auto& player : g.players)
|
for (auto& player : players)
|
||||||
{
|
{
|
||||||
if (!player.is_friend && player.is_online)
|
if (!player.is_friend && player.is_online)
|
||||||
{
|
{
|
||||||
@ -79,6 +85,5 @@ namespace big
|
|||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user