public override void drawMutable() { ImGui.Indent(); if (ImGui.CollapsingHeader($"{_name} [{_list.Count}]###{_name}", ImGuiTreeNodeFlags.FramePadding)) { ImGui.Indent(); if (!_isArray) { if (ImGui.Button("Add Element")) { if (_elementType == typeof(string)) { _list.Add(""); } else { _list.Add(Activator.CreateInstance(_elementType)); } } ImGui.SameLine(ImGui.GetWindowWidth() - ImGui.GetItemRectSize().X - ImGui.GetStyle().ItemInnerSpacing.X); // ImGui.SameLine( 0, ImGui.GetWindowWidth() * 0.65f - ImGui.GetItemRectSize().X + ImGui.GetStyle().ItemInnerSpacing.X - ImGui.GetStyle().IndentSpacing ); if (ImGui.Button("Clear")) { ImGui.OpenPopup("Clear Data"); } if (NezImGui.SimpleDialog("Clear Data", "Are you sure you want to clear the data?")) { _list.Clear(); Debug.log($"list count: {_list.Count}"); } } ImGui.PushItemWidth(-ImGui.GetStyle().IndentSpacing); for (var i = 0; i < _list.Count; i++) { if (_elementType == typeof(int)) { drawWidget((int)Convert.ChangeType(_list[i], _elementType), i); } else if (_elementType == typeof(float)) { drawWidget((float)Convert.ChangeType(_list[i], _elementType), i); } else if (_elementType == typeof(string)) { drawWidget((string)Convert.ChangeType(_list[i], _elementType), i); } else if (_elementType == typeof(Vector2)) { drawWidget((Vector2)Convert.ChangeType(_list[i], _elementType), i); } } ImGui.PopItemWidth(); ImGui.Unindent(); } ImGui.Unindent(); }
public void draw() { updatePostProcessorInspectorList(); ImGui.Indent(); for (var i = 0; i < _postProcessorInspectors.Count; i++) { if (_postProcessorInspectors[i].postProcessor._scene != null) { _postProcessorInspectors[i].draw(); NezImGui.SmallVerticalSpace(); } } if (_postProcessorInspectors.Count == 0) { NezImGui.SmallVerticalSpace(); } if (NezImGui.CenteredButton("Add PostProcessor", 0.6f)) { ImGui.OpenPopup("postprocessor-selector"); } ImGui.Unindent(); NezImGui.MediumVerticalSpace(); drawPostProcessorSelectorPopup(); }
public void Draw() { ImGui.PushID(_scopeId); var isOpen = ImGui.CollapsingHeader(_postProcessor.GetType().Name.Replace("PostProcessor", string.Empty)); NezImGui.ShowContextMenuTooltip(); if (ImGui.BeginPopupContextItem()) { if (ImGui.Selectable("Remove PostProcessor")) { isOpen = false; Core.Scene.RemovePostProcessor(_postProcessor); ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } if (isOpen) { ImGui.Indent(); foreach (var inspector in _inspectors) { inspector.Draw(); } ImGui.Unindent(); } ImGui.PopID(); }
public override void DrawMutable() { bool isOpen = ImGui.CollapsingHeader($"{_name}", ImGuiTreeNodeFlags.FramePadding); if (AllowsEffectRemoval) { NezImGui.ShowContextMenuTooltip(); } if (AllowsEffectRemoval && ImGui.BeginPopupContextItem()) { if (ImGui.Selectable("Remove Effect")) { SetValue(null); _isTargetDestroyed = true; } ImGui.EndPopup(); } if (isOpen && !_isTargetDestroyed) { foreach (AbstractTypeInspector i in _inspectors) { i.Draw(); } } }
public unsafe void Draw() { if (Core.Scene.Entities.Count > MIN_ENTITIES_FOR_CLIPPER) { ImGuiListClipper * clipperPtr = ImGuiNative.ImGuiListClipper_ImGuiListClipper(Core.Scene.Entities.Count, -1); ImGuiListClipperPtr clipper = new ImGuiListClipperPtr(clipperPtr); while (clipper.Step()) { for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) { DrawEntity(Core.Scene.Entities[i]); } } ImGuiNative.ImGuiListClipper_destroy(clipperPtr); } else { for (int i = 0; i < Core.Scene.Entities.Count; i++) { DrawEntity(Core.Scene.Entities[i]); } } NezImGui.MediumVerticalSpace(); if (NezImGui.CenteredButton("Create Entity", 0.6f)) { ImGui.OpenPopup("create-entity"); } DrawCreateEntityPopup(); }
public void Draw() { ImGui.PushID(_scopeId); var isOpen = ImGui.CollapsingHeader(_name); NezImGui.ShowContextMenuTooltip(); if (ImGui.BeginPopupContextItem()) { if (ImGui.Selectable("Remove Renderer")) { if (Core.Scene is ECScene s) { isOpen = false; s.RemoveRenderer(_renderer); ImGui.CloseCurrentPopup(); } } ImGui.EndPopup(); } if (isOpen) { ImGui.Indent(); _materialInspector.Draw(); ImGui.Checkbox("shouldDebugRender", ref Renderer.ShouldDebugRender); var value = Renderer.RenderTargetClearColor.ToNumerics(); if (ImGui.ColorEdit4("renderTargetClearColor", ref value)) { Renderer.RenderTargetClearColor = value.ToXNAColor(); } if (Renderer.Camera != null) { if (NezImGui.LabelButton("Camera", Renderer.Camera.Entity.Name)) { Core.GetGlobalManager <ImGuiManager>().StartInspectingEntity(Renderer.Camera.Entity); } } ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); NezImGui.DisableNextWidget(); var tempBool = Renderer.WantsToRenderToSceneRenderTarget; ImGui.Checkbox("wantsToRenderToSceneRenderTarget", ref tempBool); NezImGui.DisableNextWidget(); tempBool = Renderer.WantsToRenderAfterPostProcessors; ImGui.Checkbox("wantsToRenderAfterPostProcessors", ref tempBool); ImGui.PopStyleVar(); ImGui.Unindent(); } ImGui.PopID(); }
private void DrawNullMaterial() { if (NezImGui.CenteredButton("Create Material", 0.5f, ImGui.GetStyle().IndentSpacing * 0.5f)) { Material material = new Material(); SetValue(material); _inspectors = TypeInspectorUtils.GetInspectableProperties(material); } }
public override void draw() { NezImGui.beginBorderedGroup(); ImGui.Text(_name); foreach (var i in _inspectors) { i.draw(); } NezImGui.endBorderedGroup(); }
public override void DrawMutable() { var entity = GetValue <Entity>(); if (NezImGui.LabelButton(_name, entity.Name)) { Core.GetGlobalManager <ImGuiManager>().StartInspectingEntity(entity); } HandleTooltip(); }
public void Draw() { if (ImGui.CollapsingHeader("Transform", ImGuiTreeNodeFlags.DefaultOpen)) { ImGui.LabelText("Children", _transform.ChildCount.ToString()); if (_transform.Parent == null) { ImGui.LabelText("Parent", "none"); } else { if (NezImGui.LabelButton("Parent", _transform.Parent.Entity.Name)) { Core.GetGlobalManager <ImGuiManager>().StartInspectingEntity(_transform.Parent.Entity); } if (ImGui.Button("Detach From Parent")) { _transform.Parent = null; } } NezImGui.SmallVerticalSpace(); var pos = _transform.LocalPosition.ToNumerics(); if (ImGui.DragFloat2("Local Position", ref pos)) { _transform.SetLocalPosition(pos.ToXNA()); } var rot = _transform.LocalRotationDegrees; if (ImGui.DragFloat("Local Rotation", ref rot, 1, -360, 360)) { _transform.SetLocalRotationDegrees(rot); } var scale = _transform.LocalScale.ToNumerics(); if (ImGui.DragFloat2("Local Scale", ref scale, 0.05f)) { _transform.SetLocalScale(scale.ToXNA()); } scale = _transform.Scale.ToNumerics(); if (ImGui.DragFloat2("Scale", ref scale, 0.05f)) { _transform.SetScale(scale.ToXNA()); } } }
public void Draw() { for (var i = 0; i < Core.Scene.Entities.Count; i++) { DrawEntity(Core.Scene.Entities[i]); } NezImGui.MediumVerticalSpace(); if (NezImGui.CenteredButton("Create Entity", 0.6f)) { ImGui.OpenPopup("create-entity"); } DrawCreateEntityPopup(); }
void IComponentInspector.draw() { if (ImGui.CollapsingHeader("Transform", ImGuiTreeNodeFlags.DefaultOpen)) { ImGui.Indent(); ImGui.Text($"Children: {_transform.childCount}"); ImGui.Text("Parent: "); ImGui.SameLine(); if (_transform.parent == null) { ImGui.Text("none"); } else { if (ImGui.SmallButton(_transform.parent.entity.name)) { Core.getGlobalManager <ImGuiManager>().startInspectingEntity(_transform.parent.entity); } } ImGui.Unindent(); NezImGui.smallVerticalSpace(); var pos = _transform.localPosition.toNumerics(); if (ImGui.DragFloat2("Local Position", ref pos)) { _transform.setLocalPosition(pos.toXNA()); } var rot = _transform.localRotationDegrees; if (ImGui.DragFloat("Local Rotation", ref rot, 1, -360, 360)) { _transform.setLocalRotationDegrees(rot); } var scale = _transform.localScale.toNumerics(); if (ImGui.DragFloat2("Local Scale", ref scale, 0.05f)) { _transform.setLocalScale(scale.toXNA()); } scale = _transform.scale.toNumerics(); if (ImGui.DragFloat2("Scale", ref scale, 0.05f)) { _transform.setScale(scale.toXNA()); } } }
public override void drawMutable() { ImGui.Indent(); NezImGui.BeginBorderedGroup(); _isHeaderOpen = ImGui.CollapsingHeader($"{_name}"); if (_isHeaderOpen) { foreach (var i in _inspectors) { i.draw(); } } NezImGui.EndBorderedGroup(new System.Numerics.Vector2(4, 1), new System.Numerics.Vector2(4, 2)); ImGui.Unindent(); }
void DrawEntity(Entity entity, bool onlyDrawRoots = true) { if (onlyDrawRoots && entity.Transform.Parent != null) { return; } ImGui.PushID((int)entity.Id); bool treeNodeOpened; if (entity.Transform.ChildCount > 0) { treeNodeOpened = ImGui.TreeNodeEx($"{entity.Name} ({entity.Transform.ChildCount})###{entity.Id}", ImGuiTreeNodeFlags.OpenOnArrow); } else { treeNodeOpened = ImGui.TreeNodeEx($"{entity.Name} ({entity.Transform.ChildCount})###{entity.Id}", ImGuiTreeNodeFlags.Leaf | ImGuiTreeNodeFlags.OpenOnArrow); } NezImGui.ShowContextMenuTooltip(); // context menu for entity commands //ImGui.OpenPopupOnItemClick("entityContextMenu", 1); ImGui.OpenPopup("entityContextMenu", ImGuiPopupFlags.MouseButtonDefault); DrawEntityContextMenuPopup(entity); // we are looking for a double-click that is not on the arrow if (ImGui.IsMouseDoubleClicked(0) && ImGui.IsItemClicked() && (ImGui.GetMousePos().X - ImGui.GetItemRectMin().X) > ImGui.GetTreeNodeToLabelSpacing()) { Core.GetGlobalManager <ImGuiManager>().StartInspectingEntity(entity); } if (treeNodeOpened) { for (var i = 0; i < entity.Transform.ChildCount; i++) { DrawEntity(entity.Transform.GetChild(i).Entity, false); } ImGui.TreePop(); } ImGui.PopID(); }
public void Draw() { UpdateRenderersPaneList(); ImGui.Indent(); for (var i = 0; i < _renderers.Count; i++) { _renderers[i].Draw(); NezImGui.SmallVerticalSpace(); } if (_renderers.Count == 0) { NezImGui.SmallVerticalSpace(); } ImGui.Unindent(); }
public override void Initialize() { base.Initialize(); _scopeId = NezImGui.GetScopeId(); // we could have zero or 1 param ParameterInfo[] parameters = (_memberInfo as MethodInfo).GetParameters(); if (parameters.Length == 0) { return; } ParameterInfo parameter = parameters[0]; _parameterType = parameter.ParameterType; _parameterName = parameter.Name; }
protected Spawn() { this.imGuiId = baseId() + " #" + NezImGui.GetScopeId().ToString(); }
/// <summary> /// default implementation disables the next widget and calls through to drawMutable. If specialy drawing needs to /// be done (such as a multi-widget setup) this can be overridden. /// </summary> public virtual void drawReadOnly() { NezImGui.DisableNextWidget(); drawMutable(); }
public override void DrawMutable() { bool isOpen = ImGui.CollapsingHeader($"{_name}", ImGuiTreeNodeFlags.FramePadding); if (GetValue() == null) { if (isOpen) { DrawNullMaterial(); } return; } NezImGui.ShowContextMenuTooltip(); if (ImGui.BeginPopupContextItem()) { if (AllowsMaterialRemoval && ImGui.Selectable("Remove Material")) { SetValue(null); _inspectors.Clear(); ImGui.CloseCurrentPopup(); } if (ImGui.Selectable("Set Effect", false, ImGuiSelectableFlags.DontClosePopups)) { ImGui.OpenPopup("effect-chooser"); } ImGui.EndPopup(); } if (isOpen) { ImGui.Indent(); if (_inspectors.Count == 0) { if (NezImGui.CenteredButton("Set Effect", 0.6f)) { ImGui.OpenPopup("effect-chooser"); } } for (int i = _inspectors.Count - 1; i >= 0; i--) { if (_inspectors[i].IsTargetDestroyed) { _inspectors.RemoveAt(i); continue; } _inspectors[i].Draw(); } ImGui.Unindent(); } if (DrawEffectChooserPopup()) { ImGui.CloseCurrentPopup(); } }