2022-03-28 14:49:26 +02:00
|
|
|
|
using System.Collections.Generic;
|
2021-07-07 13:36:25 +02:00
|
|
|
|
|
2021-12-27 10:15:52 +01:00
|
|
|
|
using CoopClient.Entities.Player;
|
2021-07-07 13:36:25 +02:00
|
|
|
|
|
|
|
|
|
using GTA;
|
|
|
|
|
using GTA.Native;
|
|
|
|
|
|
|
|
|
|
namespace CoopClient
|
|
|
|
|
{
|
2022-03-28 14:49:26 +02:00
|
|
|
|
internal class PlayerList
|
2021-07-07 13:36:25 +02:00
|
|
|
|
{
|
2022-02-24 21:29:04 -07:00
|
|
|
|
private const float LEFT_POSITION = 0.122f;
|
|
|
|
|
private const float RIGHT_POSITION = 0.9f;
|
2021-07-07 13:36:25 +02:00
|
|
|
|
private readonly Scaleform MainScaleform = new Scaleform("mp_mm_card_freemode");
|
2021-11-19 22:08:15 +01:00
|
|
|
|
private ulong LastUpdate = Util.GetTickCount64();
|
2022-03-28 14:49:26 +02:00
|
|
|
|
internal ulong Pressed { get; set; }
|
2021-07-07 13:36:25 +02:00
|
|
|
|
|
2022-03-28 14:49:26 +02:00
|
|
|
|
internal bool LeftAlign = true;
|
2022-02-24 21:29:04 -07:00
|
|
|
|
|
2022-03-28 14:49:26 +02:00
|
|
|
|
public void Tick()
|
2021-08-13 15:20:26 +02:00
|
|
|
|
{
|
2021-08-17 15:04:50 +02:00
|
|
|
|
if (!Main.MainNetworking.IsOnServer())
|
2021-08-13 15:20:26 +02:00
|
|
|
|
{
|
2021-08-17 15:04:50 +02:00
|
|
|
|
return;
|
2021-08-13 15:20:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-19 22:08:15 +01:00
|
|
|
|
if ((Util.GetTickCount64() - LastUpdate) >= 1000)
|
2021-08-13 15:20:26 +02:00
|
|
|
|
{
|
2021-08-17 15:04:50 +02:00
|
|
|
|
Update(Main.Players, Main.MainSettings.Username);
|
2021-08-13 15:20:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-19 22:08:15 +01:00
|
|
|
|
if ((Util.GetTickCount64() - Pressed) < 5000 && !Main.MainChat.Focused
|
2021-09-26 20:52:23 -06:00
|
|
|
|
#if !NON_INTERACTIVE
|
|
|
|
|
&& !Main.MainMenu.MenuPool.AreAnyVisible
|
|
|
|
|
#endif
|
|
|
|
|
)
|
2021-08-13 15:20:26 +02:00
|
|
|
|
{
|
2022-02-24 21:29:04 -07:00
|
|
|
|
Function.Call(Hash.DRAW_SCALEFORM_MOVIE, MainScaleform.Handle,
|
2022-03-20 09:21:41 +01:00
|
|
|
|
LeftAlign ? LEFT_POSITION : RIGHT_POSITION, 0.3f,
|
2022-02-24 21:29:04 -07:00
|
|
|
|
0.28f, 0.6f,
|
|
|
|
|
255, 255, 255, 255, 0);
|
2021-08-13 15:20:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-16 14:03:05 +02:00
|
|
|
|
private void Update(Dictionary<long, EntitiesPlayer> players, string localUsername)
|
2021-07-07 13:36:25 +02:00
|
|
|
|
{
|
2021-11-19 22:08:15 +01:00
|
|
|
|
LastUpdate = Util.GetTickCount64();
|
2021-08-13 15:20:26 +02:00
|
|
|
|
|
2021-07-07 13:36:25 +02:00
|
|
|
|
MainScaleform.CallFunction("SET_DATA_SLOT_EMPTY", 0);
|
2021-08-16 12:43:52 +02:00
|
|
|
|
MainScaleform.CallFunction("SET_DATA_SLOT", 0, $"{Main.MainNetworking.Latency * 1000:N0}ms", localUsername, 116, 0, 0, "", "", 2, "", "", ' ');
|
2021-07-07 13:36:25 +02:00
|
|
|
|
|
|
|
|
|
int i = 1;
|
2021-08-13 15:20:26 +02:00
|
|
|
|
|
2021-08-16 14:03:05 +02:00
|
|
|
|
foreach (KeyValuePair<long, EntitiesPlayer> player in players)
|
2021-07-07 13:36:25 +02:00
|
|
|
|
{
|
2021-08-16 12:43:52 +02:00
|
|
|
|
MainScaleform.CallFunction("SET_DATA_SLOT", i++, $"{player.Value.Latency * 1000:N0}ms", player.Value.Username, 116, 0, i - 1, "", "", 2, "", "", ' ');
|
2021-07-07 13:36:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MainScaleform.CallFunction("SET_TITLE", "Player list", (players.Count + 1) + " players");
|
|
|
|
|
MainScaleform.CallFunction("DISPLAY_VIEW");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|