Ejemplo n.º 1
0
    private void InitElements()
    {
        var elements = Elements;

        //Init and add new elements to cache
        for (var i = 0; i < elements.Count; i++)
        {
            NetUIElement element = elements[i];
            if (!CachedElements.ContainsValue(element))
            {
                element.Init();
                CachedElements.Add(element.name, element);
            }
        }

        var toRemove = new List <string>();

        //Mark non-existent elements for removal
        foreach (var pair in CachedElements)
        {
            if (!elements.Contains(pair.Value))
            {
                toRemove.Add(pair.Key);
            }
        }
        //Remove obsolete elements from cache
        for (var i = 0; i < toRemove.Count; i++)
        {
            CachedElements.Remove(toRemove[i]);
        }
    }
Ejemplo n.º 2
0
 public override void OnEnable()
 {
     base.OnEnable();
     if (CustomNetworkManager.Instance._isServer)
     {
         infoNukeDisplay = this["NukeInfoDisplay"];
         codeDisplay     = this["NukeCodeDisplay"];
     }
 }
Ejemplo n.º 3
0
 public override void OnEnable()
 {
     base.OnEnable();
     if (CustomNetworkManager.IsServer)
     {
         infoNukeDisplay = (NetUIElement <string>) this["NukeInfoDisplay"];
         codeDisplay     = (NetUIElement <string>) this["NukeCodeDisplay"];
     }
 }
Ejemplo n.º 4
0
    public NetUIElement ImportValues(ElementValue[] values)
    {
        var  nonLists     = new List <ElementValue>();
        bool shouldRescan = false;

        //set DynamicList values first (so that corresponding subelements would get created)
        for (var i = 0; i < values.Length; i++)
        {
            var elementId = values[i].Id;
            if (CachedElements.ContainsKey(elementId) &&
                (this[elementId] is NetUIDynamicList || this[elementId] is NetPageSwitcher))
            {
                bool listContentsChanged = this[elementId].Value != values[i].Value;
                if (listContentsChanged)
                {
                    this[elementId].Value = values[i].Value;
                    shouldRescan          = true;
                }
            }
            else
            {
                nonLists.Add(values[i]);
            }
        }

        //rescan elements in case of dynamic list changes
        if (shouldRescan)
        {
            RescanElements();
        }

        NetUIElement firstTouchedElement = null;

        //set the rest of the values
        for (var i = 0; i < nonLists.Count; i++)
        {
            var elementId = nonLists[i].Id;
            if (CachedElements.ContainsKey(elementId))
            {
                var element = this[elementId];
                element.Value = nonLists[i].Value;

                if (firstTouchedElement == null)
                {
                    firstTouchedElement = element;
                }
            }
            else
            {
                Logger.LogWarning($"'{name}' wonky value import: can't find '{elementId}'.\n Expected: {string.Join("/",CachedElements.Keys)}", Category.NetUI);
            }
        }
        return(firstTouchedElement);
    }