forked from 0xcds4r/sampmodmobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
playerslist.cpp
107 lines (82 loc) · 2.57 KB
/
playerslist.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "main.h"
#include "game/game.h"
#include "net/netgame.h"
#include "game/common.h"
#include "gui/gui.h"
#include "playerslist.h"
#include "vendor/imgui/imgui_internal.h"
#include "timer.hpp"
#include <stdlib.h>
#include <string.h>
extern CGUI *pGUI;
extern CGame *pGame;
extern CNetGame *pNetGame;
CPlayersList::CPlayersList()
{
m_bIsActive = false;
szInfo = " ";
playersCount = 0;
out = false;
}
CPlayersList::~CPlayersList()
{
}
void CPlayersList::Show(bool bShow)
{
if(pGame)
pGame->FindPlayerPed()->TogglePlayerControllable(!bShow);
m_bIsActive = bShow;
if(bShow != false) out = false;
}
void CPlayersList::Clear()
{
m_bIsActive = false;
szInfo = " ";
playersCount = 0;
out = false;
}
int lastPlayerCount = 0;
void CPlayersList::Render()
{
if(!m_bIsActive) return;
CPlayerPool *pPlayerPool = pNetGame->GetPlayerPool();
ImGuiIO &io = ImGui::GetIO();
ImGui::StyleColorsClassic();
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8, 8));
char motd[256];
if(pNetGame) sprintf(motd, "> %.64s", pNetGame->m_szHostName);
ImGui::Begin(motd, nullptr,
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
ImGui::Text("Players: %i / 1000", playersCount);
ImGui::ItemSize( ImVec2(0, 1.2) );
if(ImGui::Button("Close", ImVec2(500, 50)))
{
Show(false);
}
ImGui::ItemSize( ImVec2(0, 5) );
ImGui::Text(" ID | Name");
ImGui::BeginChild("playersChild", ImVec2(500, 650), true,
ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
if(pPlayerPool)
{
ImGui::Text("[%d] %s", pPlayerPool->GetLocalPlayerID(), pPlayerPool->GetLocalPlayerName());
}
char szBuf[4096] = "";
for(PLAYERID playerId = 0; playerId < playersCount; playerId++)
{
if(pPlayerPool->GetSlotState(playerId) == true)
{
CRemotePlayer* pPlayer = pPlayerPool->GetAt(playerId);
uint32_t dwColor = pPlayer->GetPlayerColor();
char* pName = (char*)pPlayerPool->GetPlayerName(playerId);
sprintf(szBuf, "[%i] %s", playerId, pName);
ImGui::Text("%s", szBuf);
}
}
ImGui::EndChild();
ImGui::SetWindowSize(ImVec2(-1, -1));
ImVec2 size = ImGui::GetWindowSize();
ImGui::SetWindowPos( ImVec2( ((io.DisplaySize.x - size.x)/2), ((io.DisplaySize.y - size.y)/2) ) );
ImGui::End();
ImGui::PopStyleVar();
}