void DoNode(LUtfNode node, LUtfNode parent, int idx) { string id = ImGuiExt.IDWithExtra(node.Name, parent.Name + idx); if (node.Children != null) { var flags = selectedNode == node ? ImGuiTreeNodeFlags.Selected | tflags : tflags; var isOpen = ImGui.TreeNodeEx(id, flags); if (ImGui.IsItemClicked(0)) { selectedNode = node; } if (node.ResolvedName != null) { ImGui.SameLine(); ImGui.TextDisabled("(" + ImGuiExt.IDSafe(node.ResolvedName) + ")"); } ImGui.PushID(id); DoNodeMenu(id, node, parent); ImGui.PopID(); //int i = 0; if (isOpen) { for (int i = 0; i < node.Children.Count; i++) { DoNode(node.Children[i], node, (idx * 1024) + i); } ImGui.TreePop(); } } else { if (node.Data != null) { ImGui.Bullet(); } else { ImGui.Text($" {Icons.BulletEmpty}"); ImGui.SameLine(); } bool selected = selectedNode == node; if (ImGui.Selectable(id, ref selected)) { selectedNode = node; } if (node.ResolvedName != null) { ImGui.SameLine(); ImGui.TextDisabled("(" + ImGuiExt.IDSafe(node.ResolvedName) + ")"); } DoNodeMenu(id, node, parent); } }
public static void DropdownButton(string id, ref int selected, IReadOnlyList <DropdownOption> options) { ImGui.PushID(id); bool clicked = false; const string PADDING = " "; string text = PADDING + ImGuiExt.IDSafe(options[selected].Name) + " "; var w = ImGui.CalcTextSize(text).X; clicked = ImGui.Button(text); ImGui.SameLine(); var cpos = ImGuiNative.igGetCursorPosX(); var cposY = ImGuiNative.igGetCursorPosY(); Theme.TinyTriangle(cpos - 15, cposY + 15); ImGuiNative.igSetCursorPosX(cpos - w - 13); ImGuiNative.igSetCursorPosY(cposY + 2); Theme.Icon(options[selected].Icon, Color4.White); ImGui.SameLine(); ImGuiNative.igSetCursorPosY(cposY); ImGui.SetCursorPosX(cpos - 6); ImGui.Dummy(Vector2.Zero); if (clicked) { ImGui.OpenPopup(id + "#popup"); } if (ImGui.BeginPopup(id + "#popup")) { ImGui.MenuItem(id, false); for (int i = 0; i < options.Count; i++) { var opt = options[i]; if (Theme.IconMenuItem(opt.Name, opt.Icon, Color4.White, true)) { selected = i; } } ImGui.EndPopup(); } ImGui.PopID(); }
void SearchWindow() { ImGui.Text(isSearchInfocards ? "Search Infocards" : "Search Strings"); searchBuffer.InputText("##searchtext", ImGuiInputTextFlags.None, 200); ImGui.Checkbox("Case Sensitive", ref searchCaseSensitive); ImGui.Checkbox("Match Whole World", ref searchWholeWord); if (ImGui.Button("Go")) { var str = searchBuffer.GetText(); if (!string.IsNullOrWhiteSpace(str)) { resultTitle = ImGuiExt.IDSafe($"Results for '{str}'"); dialogState = 1; Regex r; var regOptions = searchCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase; if (searchWholeWord) { r = new Regex($"\\b{Regex.Escape(str)}\\b", regOptions); } else { r = new Regex(Regex.Escape(str), regOptions); } if (isSearchInfocards) { AsyncManager.RunTask(() => { var results = new List <int>(); var resStrings = new List <string>(); foreach (var kv in manager.AllXml) { if (r.IsMatch(kv.Value)) { results.Add(kv.Key); resStrings.Add(kv.Value); } } searchResults = results.ToArray(); searchStrings = resStrings.ToArray(); searchStringPreviews = new string[searchStrings.Length]; dialogState = 2; }); } else { AsyncManager.RunTask(() => { var results = new List <int>(); var resStrings = new List <string>(); foreach (var kv in manager.AllStrings) { if (r.IsMatch(kv.Value)) { results.Add(kv.Key); resStrings.Add(kv.Value); } } searchResults = results.ToArray(); searchStrings = resStrings.ToArray(); dialogState = 2; }); } } } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } }
void DoModel(RigidModelPart part) { //Hardpoints bool open = ImGui.TreeNode(ImGuiExt.Pad("Hardpoints")); var act = NewHpMenu(part.Path); switch (act) { case ContextActions.NewFixed: case ContextActions.NewRevolute: newIsFixed = act == ContextActions.NewFixed; addTo = part; newHpBuffer.Clear(); popups.OpenPopup("New Hardpoint"); break; } Theme.RenderTreeIcon("Hardpoints", "hardpoint", Color4.CornflowerBlue); if (open) { List <Action> addActions = new List <Action>(); foreach (var hp in part.Hardpoints) { if (doFilter) { if (hp.Name.IndexOf(currentFilter, StringComparison.OrdinalIgnoreCase) == -1) { continue; } } HardpointGizmo gz = null; foreach (var gizmo in gizmos) { if (gizmo.Hardpoint == hp) { gz = gizmo; break; } } if (hp.Definition is RevoluteHardpointDefinition) { Theme.Icon("rev", Color4.LightSeaGreen); } else { Theme.Icon("fix", Color4.Purple); } ImGui.SameLine(); if (Theme.IconButton("visible$" + hp.Name, "eye", gz.Enabled ? Color4.White : Color4.Gray)) { gz.Enabled = !gz.Enabled; } ImGui.SameLine(); ImGui.Selectable(ImGuiExt.IDSafe(hp.Name)); var action = EditDeleteHpMenu(part.Path + hp.Name); if (action == ContextActions.Delete) { hpDelete = hp; hpDeleteFrom = part.Hardpoints; popups.OpenPopup("Confirm Delete"); } if (action == ContextActions.Edit) { hpEditing = hp; } if (action == ContextActions.MirrorX) { var newHp = MakeDuplicate(GetDupName(hp.Name), hp); //do mirroring newHp.Definition.Position.X = -newHp.Definition.Position.X; newHp.Definition.Orientation *= new Matrix4x4( -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ); //add addActions.Add(() => { part.Hardpoints.Add(newHp); gizmos.Add(new HardpointGizmo(newHp, gz.Parent)); OnDirtyHp(); }); } if (action == ContextActions.MirrorY) { var newHp = MakeDuplicate(GetDupName(hp.Name), hp); //do mirroring newHp.Definition.Position.Y = -newHp.Definition.Position.Y; newHp.Definition.Orientation *= new Matrix4x4( 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ); //add addActions.Add(() => { part.Hardpoints.Add(newHp); gizmos.Add(new HardpointGizmo(newHp, gz.Parent)); OnDirtyHp(); }); } if (action == ContextActions.MirrorZ) { var newHp = MakeDuplicate(GetDupName(hp.Name), hp); //do mirroring newHp.Definition.Position.Z = -newHp.Definition.Position.Z; newHp.Definition.Orientation *= new Matrix4x4( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1 ); //add addActions.Add(() => { part.Hardpoints.Add(newHp); gizmos.Add(new HardpointGizmo(newHp, gz.Parent)); OnDirtyHp(); }); } } foreach (var action in addActions) { action(); } ImGui.TreePop(); } }
void DoConstructNode(RigidModelPart cn) { var n = ImGuiExt.IDSafe(string.Format("{0} ({1})", cn.Construct.ChildName, ConType(cn.Construct))); var tflags = ImGuiTreeNodeFlags.OpenOnArrow | ImGuiTreeNodeFlags.OpenOnDoubleClick; if (selectedNode == cn) { tflags |= ImGuiTreeNodeFlags.Selected; } var icon = "fix"; var color = Color4.LightYellow; if (cn.Construct is PrisConstruct) { icon = "pris"; color = Color4.LightPink; } if (cn.Construct is SphereConstruct) { icon = "sphere"; color = Color4.LightGreen; } if (cn.Construct is RevConstruct) { icon = "rev"; color = Color4.LightCoral; } bool mdlVisible = cn.Active; if (!mdlVisible) { var disabledColor = ImGui.GetStyle().Colors[(int)ImGuiCol.TextDisabled]; ImGui.PushStyleColor(ImGuiCol.Text, disabledColor); } if (ImGui.TreeNodeEx(ImGuiExt.Pad(n), tflags)) { if (!mdlVisible) { ImGui.PopStyleColor(); } if (ImGui.IsItemClicked(0)) { selectedNode = cn; } ConstructContext(cn, mdlVisible); Theme.RenderTreeIcon(n, icon, color); if (cn.Children != null) { foreach (var child in cn.Children) { DoConstructNode(child); } } DoModel(cn); ImGui.TreePop(); } else { if (!mdlVisible) { ImGui.PopStyleColor(); } if (ImGui.IsItemClicked(0)) { selectedNode = cn; } ConstructContext(cn, mdlVisible); Theme.RenderTreeIcon(n, icon, color); } }
void DoModel(RigidModelPart part) { //Hardpoints bool open = Theme.IconTreeNode(Icons.Hardpoints, "Hardpoints"); var act = NewHpMenu(part.Path); switch (act) { case ContextActions.NewFixed: case ContextActions.NewRevolute: newIsFixed = act == ContextActions.NewFixed; addTo = part; newHpBuffer.Clear(); popups.OpenPopup("New Hardpoint"); break; } if (open) { List <Action> addActions = new List <Action>(); foreach (var hp in part.Hardpoints) { if (doFilter) { if (hp.Name.IndexOf(currentFilter, StringComparison.OrdinalIgnoreCase) == -1) { continue; } } HardpointGizmo gz = null; foreach (var gizmo in gizmos) { if (gizmo.Hardpoint == hp) { gz = gizmo; break; } } if (gz == null) { throw new Exception("gizmo for hp not exist"); } if (hp.Definition is RevoluteHardpointDefinition) { ImGui.Text(Icons.Rev_LightSeaGreen.ToString()); } else { ImGui.Text(Icons.Cube_Purple.ToString()); } ImGui.SameLine(); ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(0)); ImGui.PushID("visible$" + hp.Name); var push = !gz.Enabled; if (push) { ImGui.PushStyleColor(ImGuiCol.Text, (uint)Color4.Gray.ToAbgr()); } if (ImGui.Button(Icons.Eye.ToString())) { gz.Enabled = !gz.Enabled; } if (push) { ImGui.PopStyleColor(); } ImGui.PopID(); ImGui.PopStyleVar(1); ImGui.SameLine(); ImGui.Selectable(ImGuiExt.IDSafe(hp.Name)); var action = EditDeleteHpMenu(part.Path + hp.Name); if (action == ContextActions.Delete) { hpDelete = hp; hpDeleteFrom = part.Hardpoints; popups.OpenPopup("Confirm Delete"); } if (action == ContextActions.Edit) { hpEditing = hp; } if (action == ContextActions.MirrorX) { var newHp = MakeDuplicate(GetDupName(hp.Name), hp); //do mirroring newHp.Definition.Position.X = -newHp.Definition.Position.X; newHp.Definition.Orientation *= new Matrix4x4( -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ); //add addActions.Add(() => { part.Hardpoints.Add(newHp); gizmos.Add(new HardpointGizmo(newHp, gz.Parent)); OnDirtyHp(); }); } if (action == ContextActions.MirrorY) { var newHp = MakeDuplicate(GetDupName(hp.Name), hp); //do mirroring newHp.Definition.Position.Y = -newHp.Definition.Position.Y; newHp.Definition.Orientation *= new Matrix4x4( 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ); //add addActions.Add(() => { part.Hardpoints.Add(newHp); gizmos.Add(new HardpointGizmo(newHp, gz.Parent)); OnDirtyHp(); }); } if (action == ContextActions.MirrorZ) { var newHp = MakeDuplicate(GetDupName(hp.Name), hp); //do mirroring newHp.Definition.Position.Z = -newHp.Definition.Position.Z; newHp.Definition.Orientation *= new Matrix4x4( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1 ); //add addActions.Add(() => { part.Hardpoints.Add(newHp); gizmos.Add(new HardpointGizmo(newHp, gz.Parent)); OnDirtyHp(); }); } } foreach (var action in addActions) { action(); } ImGui.TreePop(); } }
public override void Draw() { ImGui.Columns(2, "cols", true); ImGui.Text("Type"); ImGui.NextColumn(); ImGui.Text("Reference"); ImGui.Separator(); ImGui.NextColumn(); var tcolor = ImGui.GetStyle().Colors[(int)ImGuiCol.Text]; foreach (var t in res.TextureDictionary) { var col = new Vector4(0.6f, 0.6f, 0.6f, 1f); foreach (var tex in referencedTex) { if (t.Key.Equals(tex, StringComparison.InvariantCultureIgnoreCase)) { col = tcolor; break; } } ImGui.TextColored(col, "Texture"); ImGui.NextColumn(); SelectableColored(col, ImGuiExt.IDSafe(t.Key)); ContextView(t.Key, () => { if (t.Value is Texture2D) { var title = string.Format("{0} (Texture)", t.Key); win.AddTab(new TextureViewer(title, (Texture2D)t.Value, null, false)); } else { FLLog.Error("Texture", "Tried to view non-2D texture"); } }); ImGui.NextColumn(); } foreach (var m in res.MaterialDictionary) { var col = referencedMats.Contains(m.Key) ? tcolor : new Vector4(0.6f, 0.6f, 0.6f, 1f); ImGui.TextColored(col, "Material"); ImGui.NextColumn(); ImGui.TextColored(col, ImGuiExt.IDSafe(string.Format("{0} (0x{1:X})", m.Value.Name, m.Key))); ImGui.NextColumn(); } foreach (var m in res.AnimationDictionary) { var col = referencedTex.Contains(m.Key) ? tcolor : new Vector4(0.6f, 0.6f, 0.6f, 1f); ImGui.TextColored(col, "Animated Texture"); ImGui.NextColumn(); SelectableColored(col, ImGuiExt.IDSafe(m.Key)); ContextView(m.Key, () => { var title = string.Format("{0} (Animation)", m.Key); win.AddTab(new TextureViewer(title, (Texture2D)res.FindTexture(m.Key + "_0"), m.Value, false)); }); ImGui.NextColumn(); } foreach (var ln in missing) { ImGui.TextColored(Color4.Red, "Missing"); ImGui.NextColumn(); ImGui.TextColored(Color4.Red, string.Format("{0} (Ref {1})", ln.Missing, ln.Reference)); ImGui.NextColumn(); } ImGui.Columns(1, null, false); }