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 Initialize(DefaultWindow window, ViewVariablesBlobMetadata blob, ViewVariablesRemoteSession session) { // TODO: this is pretty poorly implemented right now. // For example, it assumes a client-side entity exists, // so it also means client bubbling won't work in this context. _entitySession = session; _membersBlob = await ViewVariablesManager.RequestData <ViewVariablesBlobMembers>(session, new ViewVariablesRequestMembers()); var uid = (EntityUid)_membersBlob.MemberGroups.SelectMany(p => p.Item2).Single(p => p.Name == "Uid").Value; Initialize(window, uid); }
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); 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(); componentsBlob.ComponentTypes.Sort(); foreach (var componentType in componentsBlob.ComponentTypes.OrderBy(t => t.Stringified)) { 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); } }
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); } }