public void Load() { float center = _editor.ToEditorResolution(_editor.Game.Settings.VirtualResolution.Width / 2f, 0f, null).x; var factory = _editor.Editor.Factory; _parent = factory.UI.GetPanel($"MethodWizardPanel_{_method.Name}", 600f, 400f, -1000f, 100f, addToUi: false); _parent.RenderLayer = _layer; _parent.Tint = GameViewColors.Panel; _parent.Border = factory.Graphics.Borders.SolidColor(GameViewColors.Border, 3f); var host = new AGSComponentHost(_editor.GameResolver); host.Init(_parent, typeof(AGSComponentHost)); _modal = host.AddComponent <IModalWindowComponent>(); _modal.GrabFocus(); var box = _parent.AddComponent <IBoundingBoxWithChildrenComponent>(); box.IncludeSelf = false; _parent.Visible = false; _editor.Editor.State.UI.Add(_parent); var inspectorParent = factory.UI.GetPanel("WizardInspectorParentPanel", WIDTH, 300f, MARGIN_HORIZONTAL, 0f, _parent); inspectorParent.Tint = Colors.Transparent; inspectorParent.Pivot = (0f, 1f); _inspector = new InspectorPanel(_editor, _layer, new ActionManager(), "Wizard"); _inspector.Load(inspectorParent); _inspector.Inspector.SortValues = false; var methodDescriptor = new MethodTypeDescriptor(_method, _hideProperties, _overrideDefaults); _inspector.Show(methodDescriptor); _addUiExternal?.Invoke(_parent); addButtons(); var layout = _parent.AddComponent <IStackLayoutComponent>(); layout.AbsoluteSpacing = -30f; layout.LayoutAfterCrop = true; box.OnBoundingBoxWithChildrenChanged.Subscribe(() => { layout.StartLocation = box.BoundingBoxWithChildren.Height + MARGIN_VERTICAL; _parent.BaseSize = (box.BoundingBoxWithChildren.Width + MARGIN_HORIZONTAL * 2f, box.BoundingBoxWithChildren.Height + MARGIN_VERTICAL * 2f); _parent.X = center - _parent.BaseSize.Width / 2f; }); layout.StartLayout(); }
public void Load() { const float headerHeight = 50f; const float borderWidth = 3f; IGameFactory factory = _editor.Editor.Factory; _panel = factory.UI.GetPanel(_panelId, _layer.IndependentResolution.Value.Width / 4f, _layer.IndependentResolution.Value.Height, 1f, _layer.IndependentResolution.Value.Height / 2f); _panel.Pivot = new PointF(0f, 0.5f); _panel.Visible = false; _panel.Tint = GameViewColors.Panel; _panel.Border = factory.Graphics.Borders.SolidColor(GameViewColors.Border, borderWidth, hasRoundCorners: true); _panel.RenderLayer = _layer; _panel.ClickThrough = false; _editor.Editor.State.FocusedUI.CannotLoseFocus.Add(_panelId); var headerLabel = factory.UI.GetLabel("GameDebugTreeLabel", "Game Debug", _panel.Width, headerHeight, 0f, _panel.Height - headerHeight, _panel, new AGSTextConfig(alignment: Alignment.MiddleCenter, autoFit: AutoFit.TextShouldFitLabel)); headerLabel.Tint = Colors.Transparent; headerLabel.Border = factory.Graphics.Borders.SolidColor(GameViewColors.Border, borderWidth, hasRoundCorners: true); headerLabel.RenderLayer = _layer; var xButton = factory.UI.GetButton("GameDebugTreeCloseButton", (IAnimation)null, null, null, 0f, _panel.Height - headerHeight + 5f, _panel, "X", new AGSTextConfig(factory.Graphics.Brushes.LoadSolidBrush(Colors.Red), autoFit: AutoFit.TextShouldFitLabel, alignment: Alignment.MiddleCenter), width: 40f, height: 40f); xButton.Pivot = new PointF(); xButton.RenderLayer = _layer; xButton.Tint = Colors.Transparent; xButton.MouseEnter.Subscribe(_ => xButton.TextConfig = AGSTextConfig.ChangeColor(xButton.TextConfig, GameViewColors.HoveredText, GameViewColors.HoveredText, 0.3f)); xButton.MouseLeave.Subscribe(_ => xButton.TextConfig = AGSTextConfig.ChangeColor(xButton.TextConfig, Colors.Red, Colors.Transparent, 0f)); xButton.MouseClicked.Subscribe(_ => Hide()); _panesButton = factory.UI.GetButton("GameDebugViewPanesButton", (IAnimation)null, null, null, _panel.Width, xButton.Y, _panel, "Display List", new AGSTextConfig(autoFit: AutoFit.TextShouldFitLabel, alignment: Alignment.MiddleRight), width: 120f, height: 40f); _panesButton.Pivot = new PointF(1f, 0f); _panesButton.RenderLayer = _layer; _panesButton.Tint = GameViewColors.Button; _panesButton.MouseEnter.Subscribe(_ => _panesButton.TextConfig = AGSTextConfig.ChangeColor(xButton.TextConfig, GameViewColors.HoveredText, GameViewColors.HoveredText, 0.3f)); _panesButton.MouseLeave.Subscribe(_ => _panesButton.TextConfig = AGSTextConfig.ChangeColor(xButton.TextConfig, GameViewColors.Text, Colors.Transparent, 0f)); _panesButton.MouseClicked.SubscribeToAsync(onPaneSwitch); var parentPanelHeight = _panel.Height - headerHeight; var parentPanel = factory.UI.GetPanel("GameDebugParentPanel", _panel.Width, parentPanelHeight, 0f, parentPanelHeight, _panel); parentPanel.Pivot = new PointF(0f, 1f); parentPanel.Tint = Colors.Transparent; parentPanel.RenderLayer = _layer; var topPanel = factory.UI.GetPanel("GameDebugTopPanel", _panel.Width, parentPanelHeight / 2f, 0f, parentPanelHeight / 2f, parentPanel); topPanel.Pivot = new PointF(0f, 0f); topPanel.Tint = Colors.Transparent; topPanel.RenderLayer = _layer; var bottomPanel = factory.UI.GetPanel("GameDebugBottomPanel", _panel.Width, parentPanelHeight / 2f, 0f, parentPanelHeight / 2f, parentPanel); bottomPanel.Pivot = new PointF(0f, 1f); bottomPanel.Tint = Colors.Transparent; bottomPanel.RenderLayer = _layer; Tree.Load(topPanel); _displayList.Load(topPanel); _inspector.Load(bottomPanel); _currentTab = Tree; _splitPanel = parentPanel.AddComponent <ISplitPanelComponent>(); _splitPanel.TopPanel = topPanel; _splitPanel.BottomPanel = bottomPanel; var horizSplit = _panel.AddComponent <ISplitPanelComponent>(); horizSplit.IsHorizontal = true; horizSplit.TopPanel = _panel; _panel.GetComponent <IScaleComponent>().PropertyChanged += (_, args) => { if (args.PropertyName != nameof(IScaleComponent.Width)) { return; } _panesButton.X = _panel.Width; headerLabel.LabelRenderSize = new SizeF(_panel.Width, headerLabel.LabelRenderSize.Height); parentPanel.BaseSize = new SizeF(_panel.Width, parentPanel.Height); topPanel.BaseSize = new SizeF(_panel.Width, topPanel.Height); bottomPanel.BaseSize = new SizeF(_panel.Width, bottomPanel.Height); _currentTab.Resize(); _inspector.Resize(); resizeGameWindow(); }; }
public void Load() { float center = _editor.ToEditorResolution(_editor.Game.Settings.VirtualResolution.Width / 2f, 0f, null).x; var factory = _editor.Editor.Factory; var title = _parentForm == null ? _title : $"{_parentForm.Header.Text}->{_title}"; _form = factory.UI.GetForm($"MethodWizardPanel{_idSuffix}", title, 600f, 30f, 400f, -1000f, 100f, addToUi: false); _form.Visible = false; var host = new AGSComponentHost(_editor.GameResolver); host.Init(_form.Contents, typeof(AGSComponentHost)); _modal = host.AddComponent <IModalWindowComponent>(); _modal.GrabFocus(); var box = _form.Contents.AddComponent <IBoundingBoxWithChildrenComponent>(); box.IncludeSelf = false; setupForm(_form.Contents, factory); setupForm(_form.Header, factory); var layoutPanel = factory.UI.GetPanel($"WizardLayoutPanel{_idSuffix}", 1f, 1f, 0f, 0f, _form.Contents); layoutPanel.Tint = Colors.Transparent; var inspectorParent = factory.UI.GetPanel($"WizardInspectorParentPanel{_idSuffix}", WIDTH, 300f, MARGIN_HORIZONTAL, 0f, layoutPanel); inspectorParent.Tint = Colors.Transparent; inspectorParent.Pivot = (0f, 1f); _inspector = new InspectorPanel(_editor, _layer, new ActionManager(), $"Wizard{_idSuffix}"); _inspector.Load(inspectorParent, _form); _inspector.Inspector.SortValues = false; var methodDescriptor = new MethodTypeDescriptor(_method, _hideProperties, _overrideDefaults); if (!_inspector.Show(methodDescriptor) && _addUiExternal == null) { closeForm(new Dictionary <string, ValueModel>()); return; } _addUiExternal?.Invoke(layoutPanel); addButtons(layoutPanel); var layout = layoutPanel.AddComponent <IStackLayoutComponent>(); layout.AbsoluteSpacing = -30f; layout.LayoutAfterCrop = true; box.OnBoundingBoxWithChildrenChanged.Subscribe(() => { layoutPanel.Y = box.BoundingBoxWithChildren.Height + MARGIN_VERTICAL; _form.Contents.BaseSize = (_form.Contents.BaseSize.Width, box.BoundingBoxWithChildren.Height + MARGIN_VERTICAL * 2f); _form.Width = box.BoundingBoxWithChildren.Width + MARGIN_HORIZONTAL * 2f; _form.X = center - _form.Contents.BaseSize.Width / 2f; }); layout.StartLayout(); layout.ForceRefreshLayout(); }