mirror of
https://git.aaro.dev/VRCBoard/vrcboard-udon.git
synced 2026-03-17 02:49:46 +00:00
Add meta files for new materials and update serialized Udon program assets
This commit is contained in:
@@ -42,6 +42,7 @@ namespace VRCBoard
|
||||
private float[] _atlasDownloadTimes;
|
||||
|
||||
public VRCUrl[] customModuleUrls;
|
||||
public bool[] customModuleEnabled;
|
||||
|
||||
public VRCUrl atlasInfoUrl;
|
||||
private DataDictionary _atlasInfo;
|
||||
@@ -56,28 +57,34 @@ namespace VRCBoard
|
||||
[UdonSynced, FieldChangeCallback(nameof(instanceOwnerOverride))]
|
||||
private string _instanceOwnerOverride = "";
|
||||
|
||||
public string instanceOwnerOverride
|
||||
private string instanceOwnerOverride
|
||||
{
|
||||
get => _instanceOwnerOverride;
|
||||
set
|
||||
{
|
||||
_instanceOwnerOverride = value;
|
||||
Networking.SetOwner(Networking.LocalPlayer, gameObject);
|
||||
RequestSerialization();
|
||||
Debug.Log("Instance owner override set to " + value);
|
||||
}
|
||||
}
|
||||
|
||||
[UdonSynced, FieldChangeCallback(nameof(instanceOwner))] private string _instanceOwner;
|
||||
[UdonSynced, FieldChangeCallback(nameof(InstanceOwner))] private string _instanceOwner;
|
||||
public string[] imageIdDownloadQueue = new string[0];
|
||||
|
||||
[PublicAPI]
|
||||
public void SetInstanceOwner(string owner)
|
||||
{
|
||||
instanceOwnerOverride = owner;
|
||||
Networking.SetOwner(Networking.LocalPlayer, gameObject);
|
||||
}
|
||||
|
||||
public string instanceOwner
|
||||
public string InstanceOwner
|
||||
{
|
||||
get {
|
||||
if (!string.IsNullOrWhiteSpace(instanceOwnerOverride)) return instanceOwnerOverride;
|
||||
return _instanceOwner;
|
||||
}
|
||||
set
|
||||
private set
|
||||
{
|
||||
_instanceOwner = value;
|
||||
Networking.SetOwner(Networking.LocalPlayer, gameObject);
|
||||
@@ -132,7 +139,7 @@ namespace VRCBoard
|
||||
public void _PeriodicUpdate()
|
||||
{
|
||||
//Debug.Log("Periodic update");
|
||||
if (Networking.LocalPlayer.isInstanceOwner) { instanceOwner = Networking.LocalPlayer.displayName; }
|
||||
if (Networking.LocalPlayer.isInstanceOwner) { InstanceOwner = Networking.LocalPlayer.displayName; }
|
||||
_RequestAtlasInfoUpdate();
|
||||
_RequestSupporterInfoUpdate();
|
||||
SendCustomEventDelayedSeconds(nameof(_PeriodicUpdate), periodicUpdateInterval);
|
||||
@@ -142,12 +149,14 @@ namespace VRCBoard
|
||||
//Debug.Log("Task loop");
|
||||
_TryUpdateAtlasInfo();
|
||||
_TryUpdateSupporterInfo();
|
||||
_TryUpdateCustomModules();
|
||||
SendCustomEventDelayedSeconds(nameof(_TaskLoop), 1f);
|
||||
}
|
||||
|
||||
|
||||
private bool _shouldUpdateAtlasInfo = true;
|
||||
private bool _shouldUpdateSupporterInfo = true;
|
||||
private bool _shouldUpdateCustomModules = false;
|
||||
private void _TryUpdateAtlasInfo()
|
||||
{
|
||||
if (!_shouldUpdateAtlasInfo) return;
|
||||
@@ -163,6 +172,19 @@ namespace VRCBoard
|
||||
_shouldUpdateSupporterInfo = false;
|
||||
}
|
||||
|
||||
private void _TryUpdateCustomModules()
|
||||
{
|
||||
if (!_shouldUpdateCustomModules) return;
|
||||
Debug.Log("Trying to update custom modules");
|
||||
for (int i = 0; i < customModuleUrls.Length; i++)
|
||||
{
|
||||
if (!customModuleEnabled[i]) continue;
|
||||
VRCUrl url = customModuleUrls[i];
|
||||
RequestUrlLoad(url);
|
||||
}
|
||||
_shouldUpdateCustomModules = false;
|
||||
}
|
||||
|
||||
[PublicAPI] public void _RequestAtlasInfoUpdate()
|
||||
{
|
||||
_shouldUpdateAtlasInfo = true;
|
||||
@@ -222,6 +244,14 @@ namespace VRCBoard
|
||||
{
|
||||
OnSupporterInfoDownload(download.Result);
|
||||
}
|
||||
|
||||
for (int i = 0; i < customModuleUrls.Length; i++)
|
||||
{
|
||||
if (customModuleUrls[i].Get() == url)
|
||||
{
|
||||
OnCustomModuleDownload(i, download.Result);
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void OnStringLoadError(IVRCStringDownload result)
|
||||
{
|
||||
@@ -380,25 +410,58 @@ namespace VRCBoard
|
||||
Debug.Log("Set supporter info "+vrcsuccess+" "+supporterSuccess+" "+perkSuccess);
|
||||
}
|
||||
|
||||
private void OnCustomModuleDownload(int moduleIndex, string data)
|
||||
{
|
||||
Debug.Log("Custom module download success " + moduleIndex);
|
||||
if (VRCJson.TryDeserializeFromJson(data, out DataToken result))
|
||||
{
|
||||
if (result.TokenType != TokenType.DataDictionary) return;
|
||||
OnCustomModuleUpdate(moduleIndex, result.DataDictionary);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Failed to deserialize custom module " + moduleIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCustomModuleUpdate(int moduleIndex, DataDictionary data)
|
||||
{
|
||||
Debug.Log("Custom module update " + moduleIndex);
|
||||
foreach (var component in vrcBoardComponents)
|
||||
component._OnCustomModuleUpdate(moduleIndex, data);
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public bool PlayerHasTag(VRCPlayerApi player, string tag)
|
||||
{
|
||||
return PlayerHasTag(player.displayName, tag);
|
||||
}
|
||||
|
||||
|
||||
[PublicAPI]
|
||||
public bool PlayerHasTag(string displayName, string tag)
|
||||
public String[] GetPlayerTags(string displayName)
|
||||
{
|
||||
DataDictionary supporterData = GetSupporterDataFromPlayer(displayName);
|
||||
if (supporterData == null) return false;
|
||||
if (supporterData == null) return new string[0];
|
||||
bool perkNodesSuccess = supporterData.TryGetValue("pn", out DataToken perkNodesToken);
|
||||
if (!perkNodesSuccess || perkNodesToken.TokenType != TokenType.DataList) return false;
|
||||
if (!perkNodesSuccess || perkNodesToken.TokenType != TokenType.DataList) return new string[0];
|
||||
DataList perkNodes = perkNodesToken.DataList;
|
||||
string[] tags = new string[perkNodes.Count];
|
||||
for (int i = 0; i < perkNodes.Count; i++)
|
||||
{
|
||||
DataToken perkNode = perkNodes[i];
|
||||
if (perkNode.TokenType != TokenType.String) continue;
|
||||
if (perkNode.String == tag) return true;
|
||||
tags[i] = perkNode.String;
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public bool PlayerHasTag(string displayName, string tag)
|
||||
{
|
||||
string[] tags = GetPlayerTags(displayName);
|
||||
for (int i = 0; i < tags.Length; i++)
|
||||
{
|
||||
if (tags[i] == tag) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -636,8 +699,14 @@ namespace VRCBoard
|
||||
[CustomEditor(typeof(VRCBoardManager))]
|
||||
public class VrcBoardManagerEditor : Editor
|
||||
{
|
||||
bool shouldRefreshUrls = true;
|
||||
private void OnEnable()
|
||||
{
|
||||
shouldRefreshUrls = true;
|
||||
}
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
// is first render
|
||||
//base.OnInspectorGUI();
|
||||
VRCBoardManager manager = target as VRCBoardManager;
|
||||
if (manager == null)
|
||||
@@ -646,9 +715,6 @@ namespace VRCBoard
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// draw a header
|
||||
EditorGUILayout.HelpBox("VRCBoard Manager", MessageType.Info);
|
||||
string domainInput = EditorGUILayout.TextField("Your VRCBoard Domain", manager.vrcBoardDomain);
|
||||
bool changed = domainInput != manager.vrcBoardDomain;
|
||||
@@ -658,7 +724,7 @@ namespace VRCBoard
|
||||
manager.atlasUrlCount = Math.Clamp(urlCount, 10, 1000);
|
||||
|
||||
|
||||
if (changed || urlCountChanged)
|
||||
if (changed || urlCountChanged || shouldRefreshUrls)
|
||||
{
|
||||
domainInput = domainInput.Trim();
|
||||
domainInput = domainInput.Replace("http://", "");
|
||||
@@ -675,6 +741,16 @@ namespace VRCBoard
|
||||
}
|
||||
|
||||
const string apiPath = "api/data/v1/";
|
||||
|
||||
bool[] oldEnabled = manager.customModuleEnabled;
|
||||
manager.customModuleUrls = new VRCUrl[3];
|
||||
manager.customModuleEnabled = new bool[3];
|
||||
manager.customModuleUrls[0] = new VRCUrl(baseUrl + apiPath + "barmanager");
|
||||
|
||||
for (int i = 0; i < oldEnabled.Length; i++)
|
||||
{
|
||||
if (i < manager.customModuleEnabled.Length) manager.customModuleEnabled[i] = oldEnabled[i];
|
||||
}
|
||||
|
||||
manager.atlasInfoUrl = new VRCUrl(baseUrl + apiPath + "atlas");
|
||||
manager.supporterInfoUrl = new VRCUrl(baseUrl + apiPath + "supporters");
|
||||
@@ -684,7 +760,17 @@ namespace VRCBoard
|
||||
|
||||
float selectedInterval = EditorGUILayout.FloatField("Periodic Update Interval", manager.periodicUpdateInterval);
|
||||
manager.periodicUpdateInterval = Mathf.Clamp(selectedInterval, 5f, 600f);
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Separator();
|
||||
|
||||
SerializedProperty customModuleEnabled = serializedObject.FindProperty("customModuleEnabled");
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField("[Module] Group Manager");
|
||||
// dropdown with enabled/disabled
|
||||
customModuleEnabled.GetArrayElementAtIndex(0).boolValue = EditorGUILayout.Popup(customModuleEnabled.GetArrayElementAtIndex(0).boolValue ? 1 : 0, new[] {"Disabled", "Enabled"}) == 1;
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
|
||||
SerializedProperty vrcBoardComponents = serializedObject.FindProperty("vrcBoardComponents");
|
||||
EditorGUILayout.PropertyField(vrcBoardComponents);
|
||||
@@ -701,8 +787,7 @@ namespace VRCBoard
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
//DrawDefaultInspector();
|
||||
|
||||
|
||||
shouldRefreshUrls = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user