private async void _tabsOnTabChanged(int tab)
        {
            if (tab == TabClientComponents)
            {
                // Repopulate client components in case something changed.
                PopulateClientComponents();
            }

            if (_serverLoaded || tab != TabServerComponents && tab != TabServerVars)
            {
                return;
            }

            _serverLoaded = true;

            if (_entitySession == null)
            {
                try
                {
                    _entitySession =
                        await ViewVariablesManager.RequestSession(new ViewVariablesEntitySelector(_entity));
                }
                catch (SessionDenyException e)
                {
                    var text = $"Server denied VV request: {e.Reason}";
                    _serverVariables.AddChild(new Label {
                        Text = text
                    });
                    _serverComponents.AddChild(new Label {
                        Text = text
                    });
                    return;
                }
            }

            _membersBlob = await ViewVariablesManager.RequestData <ViewVariablesBlobMembers>(_entitySession, new ViewVariablesRequestMembers());

            var otherStyle = false;
            var first      = true;

            foreach (var(groupName, groupMembers) in _membersBlob !.MemberGroups)
            {
                ViewVariablesTraitMembers.CreateMemberGroupHeader(ref first, groupName, _serverVariables);

                foreach (var propertyData in groupMembers)
                {
                    var propertyEdit = new ViewVariablesPropertyControl(ViewVariablesManager, _robustSerializer);
                    propertyEdit.SetStyle(otherStyle = !otherStyle);
                    var editor        = propertyEdit.SetProperty(propertyData);
                    var selectorChain = new object[] { new ViewVariablesMemberSelector(propertyData.PropertyIndex) };
                    editor.OnValueChanged += (o, r) => ViewVariablesManager.ModifyRemote(_entitySession, selectorChain, o, r);
                    editor.WireNetworkSelector(_entitySession.SessionId, selectorChain);

                    _serverVariables.AddChild(propertyEdit);
                }
            }

            PopulateServerComponents();
        }
        public override async void Refresh()
        {
            _memberList.DisposeAllChildren();

            if (Instance.Object != null)
            {
                var first = true;
                foreach (var group in ViewVariablesInstance.LocalPropertyList(Instance.Object,
                                                                              Instance.ViewVariablesManager, _robustSerializer))
                {
                    CreateMemberGroupHeader(
                        ref first,
                        TypeAbbreviation.Abbreviate(group.Key),
                        _memberList);

                    foreach (var control in group)
                    {
                        _memberList.AddChild(control);
                    }
                }
            }
            else
            {
                DebugTools.AssertNotNull(Instance.Session);

                var blob = await Instance.ViewVariablesManager.RequestData <ViewVariablesBlobMembers>(
                    Instance.Session !, new ViewVariablesRequestMembers());

                var otherStyle = false;
                var first      = true;
                foreach (var(groupName, groupMembers) in blob.MemberGroups)
                {
                    CreateMemberGroupHeader(ref first, groupName, _memberList);

                    foreach (var propertyData in groupMembers)
                    {
                        var propertyEdit = new ViewVariablesPropertyControl(_vvm, _robustSerializer);
                        propertyEdit.SetStyle(otherStyle = !otherStyle);
                        var editor = propertyEdit.SetProperty(propertyData);

                        var selectorChain = new object[] { new ViewVariablesMemberSelector(propertyData.PropertyIndex) };
                        editor.WireNetworkSelector(Instance.Session !.SessionId, selectorChain);
                        editor.OnValueChanged += o =>
                        {
                            Instance.ViewVariablesManager.ModifyRemote(Instance.Session !,
                                                                       selectorChain, o);
                        };

                        _memberList.AddChild(propertyEdit);
                    }
                }
            }
        }
Example #3
0
        public override async void Refresh()
        {
            _memberList.DisposeAllChildren();

            if (Instance.Object != null)
            {
                foreach (var control in ViewVariablesInstance.LocalPropertyList(Instance.Object,
                                                                                Instance.ViewVariablesManager, _resourceCache))
                {
                    _memberList.AddChild(control);
                }
            }
            else
            {
                DebugTools.AssertNotNull(Instance.Session);

                var blob = await Instance.ViewVariablesManager.RequestData <ViewVariablesBlobMembers>(
                    Instance.Session !, new ViewVariablesRequestMembers());

                var otherStyle = false;
                foreach (var propertyData in blob.Members)
                {
                    var propertyEdit = new ViewVariablesPropertyControl(_vvm, _resourceCache);
                    propertyEdit.SetStyle(otherStyle = !otherStyle);
                    var editor = propertyEdit.SetProperty(propertyData);
                    // TODO: should this maybe not be hardcoded?
                    if (editor is ViewVariablesPropertyEditorReference refEditor)
                    {
                        refEditor.OnPressed += () =>
                                               Instance.ViewVariablesManager.OpenVV(
                            new ViewVariablesSessionRelativeSelector(Instance.Session !.SessionId,
                                                                     new object[] { new ViewVariablesMemberSelector(propertyData.PropertyIndex) }));
                    }

                    editor.OnValueChanged += o =>
                    {
                        Instance.ViewVariablesManager.ModifyRemote(Instance.Session !,
                                                                   new object[] { new ViewVariablesMemberSelector(propertyData.PropertyIndex) }, o);
                    };

                    _memberList.AddChild(propertyEdit);
                }
            }
        }
Example #4
0
        public override async void Refresh()
        {
            _memberList.DisposeAllChildren();

            if (Instance.Object != null)
            {
                foreach (var control in ViewVariablesInstance.LocalPropertyList(Instance.Object,
                                                                                Instance.ViewVariablesManager, _resourceCache))
                {
                    _memberList.AddChild(control);
                }
            }
            else
            {
                DebugTools.AssertNotNull(Instance.Session);

                var blob = await Instance.ViewVariablesManager.RequestData <ViewVariablesBlobMembers>(
                    Instance.Session !, new ViewVariablesRequestMembers());

                var otherStyle = false;
                foreach (var propertyData in blob.Members)
                {
                    var propertyEdit = new ViewVariablesPropertyControl(_vvm, _resourceCache);
                    propertyEdit.SetStyle(otherStyle = !otherStyle);
                    var editor = propertyEdit.SetProperty(propertyData);

                    var selectorChain = new object[] { new ViewVariablesMemberSelector(propertyData.PropertyIndex) };
                    editor.WireNetworkSelector(Instance.Session !.SessionId, selectorChain);
                    editor.OnValueChanged += o =>
                    {
                        Instance.ViewVariablesManager.ModifyRemote(Instance.Session !,
                                                                   selectorChain, o);
                    };

                    _memberList.AddChild(propertyEdit);
                }
            }
        }
        private async void _tabsOnTabChanged(int tab)
        {
            if (_serverLoaded || tab != TabServerComponents && tab != TabServerVars)
            {
                return;
            }

            _serverLoaded = true;

            if (_entitySession == null)
            {
                try
                {
                    _entitySession =
                        await ViewVariablesManager.RequestSession(new ViewVariablesEntitySelector(_entity.Uid));
                }
                catch (SessionDenyException e)
                {
                    var text = $"Server denied VV request: {e.Reason}";
                    _serverVariables.AddChild(new Label {
                        Text = text
                    });
                    _serverComponents.AddChild(new Label {
                        Text = text
                    });
                    return;
                }

                _membersBlob = await ViewVariablesManager.RequestData <ViewVariablesBlobMembers>(_entitySession, new ViewVariablesRequestMembers());
            }

            var otherStyle = false;

            foreach (var propertyData in _membersBlob.Members)
            {
                var propertyEdit = new ViewVariablesPropertyControl(ViewVariablesManager, _resourceCache);
                propertyEdit.SetStyle(otherStyle = !otherStyle);
                var editor = propertyEdit.SetProperty(propertyData);
                editor.OnValueChanged += o =>
                                         ViewVariablesManager.ModifyRemote(_entitySession, new object[] { new ViewVariablesMemberSelector(propertyData.PropertyIndex) }, o);
                if (editor is ViewVariablesPropertyEditorReference refEditor)
                {
                    refEditor.OnPressed += () =>
                                           ViewVariablesManager.OpenVV(
                        new ViewVariablesSessionRelativeSelector(_entitySession.SessionId,
                                                                 new object[] { new ViewVariablesMemberSelector(propertyData.PropertyIndex) }));
                }

                _serverVariables.AddChild(propertyEdit);
            }

            var componentsBlob = await ViewVariablesManager.RequestData <ViewVariablesBlobEntityComponents>(_entitySession, new ViewVariablesRequestEntityComponents());

            _serverComponents.DisposeAllChildren();
            componentsBlob.ComponentTypes.Sort();
            foreach (var componentType in componentsBlob.ComponentTypes.OrderBy(t => t.Stringified))
            {
                var button = new Button {
                    Text = componentType.Stringified, TextAlign = Button.AlignMode.Left
                };
                button.OnPressed += args =>
                {
                    ViewVariablesManager.OpenVV(
                        new ViewVariablesComponentSelector(_entity.Uid, componentType.Qualified));
                };
                _serverComponents.AddChild(button);
            }
        }
Example #6
0
        private async void _tabsOnTabChanged(int tab)
        {
            if (_serverLoaded || tab != TabServerComponents && tab != TabServerVars)
            {
                return;
            }

            _serverLoaded = true;

            if (_entitySession == null)
            {
                try
                {
                    _entitySession =
                        await ViewVariablesManager.RequestSession(new ViewVariablesEntitySelector(_entity.Uid));
                }
                catch (SessionDenyException e)
                {
                    var text = $"Server denied VV request: {e.Reason}";
                    _serverVariables.AddChild(new Label {
                        Text = text
                    });
                    _serverComponents.AddChild(new Label {
                        Text = text
                    });
                    return;
                }

                _membersBlob = await ViewVariablesManager.RequestData <ViewVariablesBlobMembers>(_entitySession, new ViewVariablesRequestMembers());
            }

            var otherStyle = false;
            var first      = true;

            foreach (var(groupName, groupMembers) in _membersBlob !.MemberGroups)
            {
                ViewVariablesTraitMembers.CreateMemberGroupHeader(ref first, groupName, _serverVariables);

                foreach (var propertyData in groupMembers)
                {
                    var propertyEdit = new ViewVariablesPropertyControl(ViewVariablesManager, _resourceCache);
                    propertyEdit.SetStyle(otherStyle = !otherStyle);
                    var editor        = propertyEdit.SetProperty(propertyData);
                    var selectorChain = new object[] { new ViewVariablesMemberSelector(propertyData.PropertyIndex) };
                    editor.OnValueChanged += o => ViewVariablesManager.ModifyRemote(_entitySession, selectorChain, o);
                    editor.WireNetworkSelector(_entitySession.SessionId, selectorChain);

                    _serverVariables.AddChild(propertyEdit);
                }
            }

            var componentsBlob = await ViewVariablesManager.RequestData <ViewVariablesBlobEntityComponents>(_entitySession, new ViewVariablesRequestEntityComponents());

            _serverComponents.DisposeAllChildren();

            _serverComponents.AddChild(_serverComponentsSearchBar = new LineEdit
            {
                PlaceHolder         = Loc.GetString("Search"),
                SizeFlagsHorizontal = SizeFlags.FillExpand
            });

            _serverComponentsSearchBar.OnTextChanged += OnServerComponentsSearchBarChanged;

            componentsBlob.ComponentTypes.Sort();

            var componentTypes = componentsBlob.ComponentTypes.AsEnumerable();

            if (!string.IsNullOrEmpty(_serverComponentsSearchBar.Text))
            {
                componentTypes = componentTypes
                                 .Where(t => t.Stringified.Contains(_serverComponentsSearchBar.Text,
                                                                    StringComparison.InvariantCultureIgnoreCase));
            }

            componentTypes = componentTypes.OrderBy(t => t.Stringified);

            foreach (var componentType in componentTypes)
            {
                var button = new Button {
                    Text = componentType.Stringified, TextAlign = Label.AlignMode.Left
                };
                button.OnPressed += args =>
                {
                    ViewVariablesManager.OpenVV(
                        new ViewVariablesComponentSelector(_entity.Uid, componentType.FullName));
                };
                _serverComponents.AddChild(button);
            }
        }