Choice cards now cycle colours on every new question.
This commit is contained in:
@@ -18,12 +18,21 @@ public class PermissionsPanel : UdonSharpBehaviour
|
||||
[SerializeField] private RectTransform _ListContainer;
|
||||
[SerializeField] private GameObject _PlayerItemTemplate;
|
||||
|
||||
private const int MAX_PLAYERS_IN_LIST = 85;
|
||||
private const int MAX_PLAYERS_IN_LIST = 100;
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
for (int i = 0; i < PlayerData_Name.Length; i++)
|
||||
{
|
||||
GameObject NewListItem = Instantiate<GameObject>(_PlayerItemTemplate, _ListContainer, false);
|
||||
NewListItem.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnPlayerJoined(VRCPlayerApi Player)
|
||||
{
|
||||
for (int i = 0; i < MAX_PLAYERS_IN_LIST; i++)
|
||||
for (int i = 0; i < PlayerData_Name.Length; i++)
|
||||
{
|
||||
if (PlayerData_Name[i] == null)
|
||||
{
|
||||
@@ -38,6 +47,7 @@ public class PermissionsPanel : UdonSharpBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
RebuildPlayerList();
|
||||
RequestSerialization();
|
||||
|
||||
base.OnPlayerJoined(Player);
|
||||
@@ -45,44 +55,18 @@ public class PermissionsPanel : UdonSharpBehaviour
|
||||
|
||||
public override void OnPlayerLeft(VRCPlayerApi Player)
|
||||
{
|
||||
for (int i = 0; i < MAX_PLAYERS_IN_LIST; i++)
|
||||
for (int i = 0; i < PlayerData_Name.Length; i++)
|
||||
{
|
||||
if (PlayerData_Name[i] == Player.displayName)
|
||||
{
|
||||
Debug.Log("[PermissionsPanel] Found exiting player " + PlayerData_Name[i] + "on the list. Removing...");
|
||||
PlayerData_Name[i] = null;
|
||||
Debug.Log("[PermissionsPanel] PlayerData_Name[" + i + "] now equals " + PlayerData_Name[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
string[] NewPlayerData_Name = new string[MAX_PLAYERS_IN_LIST];
|
||||
int[] NewPlayerData_ID = new int[MAX_PLAYERS_IN_LIST];
|
||||
bool[] NewPlayerData_Admin = new bool[MAX_PLAYERS_IN_LIST];
|
||||
bool[] NewPlayerData_Host = new bool[MAX_PLAYERS_IN_LIST];
|
||||
bool[] NewPlayerData_Camera = new bool[MAX_PLAYERS_IN_LIST];
|
||||
|
||||
for (int i = 0; i < MAX_PLAYERS_IN_LIST; i++)
|
||||
{
|
||||
for (int j = i; j < MAX_PLAYERS_IN_LIST; j++)
|
||||
{
|
||||
if (PlayerData_Name[j] != null)
|
||||
{
|
||||
NewPlayerData_Name[i] = PlayerData_Name[j];
|
||||
NewPlayerData_ID[i] = PlayerData_ID[j];
|
||||
NewPlayerData_Admin[i] = PlayerData_Admin[j];
|
||||
NewPlayerData_Host[i] = PlayerData_Host[j];
|
||||
NewPlayerData_Camera[i] = PlayerData_Camera[j];
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlayerData_Name = NewPlayerData_Name;
|
||||
PlayerData_ID = NewPlayerData_ID;
|
||||
PlayerData_Admin = NewPlayerData_Admin;
|
||||
PlayerData_Host = NewPlayerData_Host;
|
||||
PlayerData_Camera = NewPlayerData_Camera;
|
||||
|
||||
RebuildPlayerList();
|
||||
RequestSerialization();
|
||||
|
||||
base.OnPlayerLeft(Player);
|
||||
@@ -90,13 +74,15 @@ public class PermissionsPanel : UdonSharpBehaviour
|
||||
|
||||
public override void OnDeserialization(DeserializationResult Result)
|
||||
{
|
||||
RebuildPlayerList();
|
||||
|
||||
base.OnDeserialization(Result);
|
||||
}
|
||||
|
||||
|
||||
public void PermissionsChanged()
|
||||
{
|
||||
for (int i = 0; i < _ListContainer.childCount; i++)
|
||||
for (int i = 0; i < PlayerData_Name.Length; i++)
|
||||
{
|
||||
GameObject Entry = _ListContainer.GetChild(i).gameObject;
|
||||
PermissionsPanelPlayerEntry PlayerEntry = Entry.GetComponent<PermissionsPanelPlayerEntry>();
|
||||
@@ -110,26 +96,32 @@ public class PermissionsPanel : UdonSharpBehaviour
|
||||
|
||||
private void RebuildPlayerList()
|
||||
{
|
||||
int CurrentListCount = _ListContainer.childCount;
|
||||
for (int i = 0; i < CurrentListCount; i++)
|
||||
Debug.Log("[PermissionsPanel] Rebuilding the player list...");
|
||||
|
||||
for (int i = 0; i < PlayerData_Name.Length; i++)
|
||||
{
|
||||
Destroy(_ListContainer.GetChild(CurrentListCount - i - 1).gameObject);
|
||||
}
|
||||
Debug.Log("[PermissionsPanel] PlayerData_Name[" + i + "] is " + PlayerData_Name[i]);
|
||||
|
||||
for (int i = 0; i < VRCPlayerApi.GetPlayerCount(); i++)
|
||||
{
|
||||
GameObject NewListItem = Instantiate<GameObject>(_PlayerItemTemplate, _ListContainer, false);
|
||||
NewListItem.SetActive(true);
|
||||
PermissionsPanelPlayerEntry PlayerListItem = NewListItem.GetComponent<PermissionsPanelPlayerEntry>();
|
||||
PlayerListItem.PlayerNameUI.text = PlayerData_Name[i];
|
||||
PermissionsPanelPlayerEntry PlayerListItem = _ListContainer.GetChild(i).GetComponent<PermissionsPanelPlayerEntry>();
|
||||
|
||||
PlayerListItem.AdminToggle.SetIsOnWithoutNotify(PlayerData_Admin[i]);
|
||||
PlayerListItem.HostToggle.SetIsOnWithoutNotify(PlayerData_Host[i]);
|
||||
PlayerListItem.CameraToggle.SetIsOnWithoutNotify(PlayerData_Camera[i]);
|
||||
if (PlayerData_Name[i] != null)
|
||||
{
|
||||
PlayerListItem.PlayerNameUI.text = PlayerData_Name[i];
|
||||
|
||||
PlayerListItem.AdminToggle.interactable = false;
|
||||
PlayerListItem.HostToggle.interactable = false;
|
||||
PlayerListItem.CameraToggle.interactable = false;
|
||||
PlayerListItem.AdminToggle.SetIsOnWithoutNotify(PlayerData_Admin[i]);
|
||||
PlayerListItem.HostToggle.SetIsOnWithoutNotify(PlayerData_Host[i]);
|
||||
PlayerListItem.CameraToggle.SetIsOnWithoutNotify(PlayerData_Camera[i]);
|
||||
|
||||
PlayerListItem.AdminToggle.interactable = (Networking.LocalPlayer.isInstanceOwner || Networking.LocalPlayer.isMaster);
|
||||
PlayerListItem.HostToggle.interactable = (Networking.LocalPlayer.isInstanceOwner || Networking.LocalPlayer.isMaster);
|
||||
PlayerListItem.CameraToggle.interactable = (Networking.LocalPlayer.isInstanceOwner || Networking.LocalPlayer.isMaster);
|
||||
|
||||
PlayerListItem.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerListItem.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user