Example #1
0
    void PxPre.Tree.ITreeHandler.OnNodeSelected(PxPre.Tree.Tree tree, PxPre.Tree.Node node, bool selected)
    {
        if (this.showAllToggle.isOn == false)
        {
            return;
        }

        if (this.recurseGuard > 0)
        {
            return;
        }

        ++this.recurseGuard;

        for (PxPre.Tree.Node it = node; it != null; it = it.Parent)
        {
            if (nodeToActor.TryGetValue(it, out SceneActor actor) == true)
            {
                this.mgr.SelectActor(actor);
                --this.recurseGuard;
                return;
            }
        }

        this.mgr.SelectActor(null);

        --this.recurseGuard;
    }
Example #2
0
 /// <summary>
 /// Create an tree node for an actor and populate it with the correct
 /// contents.
 /// </summary>
 /// <param name="actor">The actor to add to the tree.</param>
 public void CreateActorTreeNode(SceneActor actor)
 {
     PxPre.Tree.Node actorNode = this.tree.AddNode("Actor", this.nodeShapes);
     RefreshActorNodeIcons(actor, actorNode);
     this.nodeToActor.Add(actorNode, actor);
     this.actorToNode.Add(actor, actorNode);
     this.actorToParams.Add(actor, new NodeWidgets());
     this.RefreshActorParams(actor);
 }
Example #3
0
    private void Start()
    {
        const int treeRecursionLimit = 0;

        this.treeScroll.onValueChanged.AddListener(
            (x) =>
        {
            if (this.treesSyncRecursionGuard > treeRecursionLimit)
            {
                return;
            }

            ++this.treesSyncRecursionGuard;

            this.optionScroll.verticalNormalizedPosition =
                this.treeScroll.verticalNormalizedPosition;
            this.StartCoroutine(_SetVertScroll(this.optionScroll, this.treeScroll.verticalNormalizedPosition));

            --this.treesSyncRecursionGuard;
        });

        this.optionScroll.onValueChanged.AddListener(
            (x) =>
        {
            if (this.treesSyncRecursionGuard > treeRecursionLimit)
            {
                return;
            }

            ++this.treesSyncRecursionGuard;

            this.treeScroll.verticalNormalizedPosition =
                this.optionScroll.verticalNormalizedPosition;
            this.StartCoroutine(_SetVertScroll(this.treeScroll, this.optionScroll.verticalNormalizedPosition));

            --this.treesSyncRecursionGuard;
        });

        this.tree.subscribers.Add(this);

        this.nodeWorld  = this.tree.AddNode("Environment", null);
        this.nodeDecay  = this.tree.AddNode("Decay", this.nodeWorld);
        this.nodeShapes = this.tree.AddNode("Shapes", null);

        GameObject goDecay = GameObject.Instantiate(this.prefabSpinnerReset);

        goDecay.transform.SetParent(this.optionScroll.content);
        this.decayEd = goDecay.GetComponent <ValueEditor_Base>();
        this.decayEd.Init(this.mgr, null, this.mgr.evDecay);
        this.decayEd.OnUpdateValue();
        this.environmentItems.Add(this.nodeDecay, this.decayEd);

        this.tree.LayoutTree();
    }
Example #4
0
    /// <summary>
    /// Rebuild the entire tree.
    /// </summary>
    public void RebuildActorTree()
    {
        this.nodeShapes.DestroyChildren();

        foreach (KeyValuePair <SceneActor, NodeWidgets> kvp in this.actorToParams)
        {
            kvp.Value.Destroy();
        }

        if (this.showAllToggle.isOn == true)
        {
            this.nodeShapes.Label = "Shapes";
        }
        else
        {
            this.nodeShapes.Label = "Selected";
        }

        this.actorToNode.Clear();
        this.nodeToActor.Clear();
        this.actorToParams.Clear();

        if (this.showAllToggle.isOn == true)
        {
            foreach (SceneActor actor in this.mgr.waveScene.Actors)
            {
                PxPre.Tree.Node actorNode = this.tree.AddNode("Actor", this.nodeShapes);
                RefreshActorNodeIcons(actor, actorNode);
                this.nodeToActor.Add(actorNode, actor);
                this.actorToNode.Add(actor, actorNode);
                this.actorToParams.Add(actor, new NodeWidgets());

                if (actor == this.mgr.Selected)
                {
                    ++this.recurseGuard;
                    actorNode.Selected = true;
                    --this.recurseGuard;
                }
            }

            foreach (SceneActor actor in this.mgr.waveScene.Actors)
            {
                this.RefreshActorParams(actor);
            }
        }
        else if (this.mgr.Selected != null)
        {
            CreateActorTreeNode(this.mgr.Selected);
        }
    }
Example #5
0
    /// <summary>
    /// Refresh the icons for an actor's tree node.
    /// </summary>
    /// <param name="actor">The actor to refresh for.</param>
    /// <param name="actorNode">The actor's tree node.</param>
    protected void RefreshActorNodeIcons(SceneActor actor, PxPre.Tree.Node actorNode)
    {
        actorNode.SetIcon(
            "enabled",
            true,
            actor.enabled.BoolVal ? this.icotogOn : this.icotogOff,
            (x, y, z) =>
        {
            actor.enabled.BoolVal = !actor.enabled.BoolVal;
            this.mgr.NotifyActorModified(actor, actor.enabled);
        });

        int fill = actor.fillMode.IntVal;

        switch (actor.shape.IntVal)
        {
        case (int)SceneActor.Shape.Ellipse:
            if (fill == (int)SceneActor.Fill.Filled)
            {
                actorNode.SetIcon("icon", true, this.tyicoEllipseFilled, (x, y, z) => { });
            }
            else
            {
                actorNode.SetIcon("icon", true, this.tyicoEllipseHollow, (x, y, z) => { });
            }
            break;

        case (int)SceneActor.Shape.Square:
            if (fill == (int)SceneActor.Fill.Filled)
            {
                actorNode.SetIcon("icon", true, this.tyicoRectFilled, (x, y, z) => { });
            }
            else
            {
                actorNode.SetIcon("icon", true, this.tyicoRectHollow, (x, y, z) => { });
            }
            break;
        }
    }
Example #6
0
 void PxPre.Tree.ITreeHandler.OnNodeClicked(PxPre.Tree.Tree tree, PxPre.Tree.Node node)
 {
 }
Example #7
0
 void PxPre.Tree.ITreeHandler.OnNodeExpanded(PxPre.Tree.Tree tree, PxPre.Tree.Node node, bool expanded)
 {
 }
Example #8
0
 void PxPre.Tree.ITreeHandler.OnNodeAdd(PxPre.Tree.Tree tree, PxPre.Tree.Node node)
 {
 }
Example #9
0
    ////////////////////////////////////////////////////////////////////////////////
    //
    //      INTERFACE : ITreeHandler
    //
    ////////////////////////////////////////////////////////////////////////////////

    void PxPre.Tree.ITreeHandler.OnNodeDelete(PxPre.Tree.Tree tree, PxPre.Tree.Node node)
    {
    }
Example #10
0
    /// <summary>
    /// For a specified actor, rebuild its tree of parameters to make sure
    /// they are up to date.
    /// </summary>
    /// <param name="actor">The actor to rebuilt the subtree for.</param>
    void RefreshActorParams(SceneActor actor)
    {
        PxPre.Tree.Node n;
        if (this.actorToNode.TryGetValue(actor, out n) == false)
        {
            return;
        }

        // We are going to re-add items from scratch
        n.DestroyChildren();

        NodeWidgets nw;

        this.actorToParams.TryGetValue(actor, out nw);
        HashSet <string> foundParams = new HashSet <string>(nw.widgets.Keys);

        foreach (EditValue ev in actor.EnumerateRelevantParams())
        {
            PxPre.Tree.Node np = this.tree.AddNode(ev.name, n);
            foundParams.Remove(ev.name);

            NodeWidgets.ParamNodePair pnp;
            if (nw.widgets.TryGetValue(ev.name, out pnp) == true)
            {
                pnp.node            = np;
                np.MinHeight        = pnp.param.rectTransform.sizeDelta.y;
                nw.widgets[ev.name] = pnp;
            }
            else
            {
                pnp      = new NodeWidgets.ParamNodePair();
                pnp.node = np;

                GameObject goPrefab = null;
                if (ev.name == "Rotation")
                {
                    // Rotation is an edge case where the parameter gets its
                    // own specific widget.
                    goPrefab = GameObject.Instantiate(this.prefabWRotation);
                }
                else if (ev.val.ty == Val.Type.Float)
                {
                    goPrefab = GameObject.Instantiate(this.prefabWSpinner);
                }
                else if (ev.val.ty == Val.Type.Int)
                {
                    goPrefab = GameObject.Instantiate(this.prefabWSpinner);
                }
                else if (ev.val.ty == Val.Type.Bool)
                {
                    goPrefab = GameObject.Instantiate(this.prefabWCheckbox);
                }
                else if (ev.val.ty == Val.Type.Enum)
                {
                    goPrefab = GameObject.Instantiate(this.prefabWPulldown);
                }

                if (goPrefab != null)
                {
                    ValueEditor_Base veb = goPrefab.GetComponent <ValueEditor_Base>();
                    veb.transform.SetParent(this.optionScroll.content, false);
                    veb.Init(this.mgr, actor, ev);

                    np.MinHeight = goPrefab.GetComponent <RectTransform>().sizeDelta.y;

                    pnp.param = veb;
                    nw.widgets.Add(ev.name, pnp);
                }
            }
        }

        // Remove anything we originally had that's no longer needed.
        foreach (string str in foundParams)
        {
            GameObject.Destroy(nw.widgets[str].param.gameObject);
            nw.widgets.Remove(str);
        }
    }