protected override void Draw(double elapsed) { EnableTextInput(); RenderState.SetViewport(0, 0, Width, Height); RenderState.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f); RenderState.ClearAll(); guiHelper.NewFrame(elapsed); ImGui.PushFont(ImGuiHelper.Noto); ImGui.BeginMainMenuBar(); if (ImGui.BeginMenu("File")) { if (ImGui.MenuItem("Open", "Ctrl-O", false, true)) { var f = FileDialog.Open(); if (f != null && DetectFileType.Detect(f) == FileType.Utf) { tabs.Add(new UtfTab(this, new EditableUtf(f), System.IO.Path.GetFileName(f))); } } if (ImGui.MenuItem("Quit", "Ctrl-Q", false, true)) { Exit(); } ImGui.EndMenu(); } if (ImGui.BeginMenu("Help")) { if (ImGui.MenuItem("About")) { openAbout = true; } ImGui.EndMenu(); } if (openAbout) { ImGui.OpenPopup("About"); openAbout = false; } if (ImGui.BeginPopupModal("About")) { ImGui.Text("LancerEdit"); ImGui.Text("Callum McGing 2018"); if (ImGui.Button("OK")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } var menu_height = ImGui.GetWindowSize().Y; ImGui.EndMainMenuBar(); var size = (Vector2)ImGui.GetIO().DisplaySize; size.Y -= menu_height; ImGuiExt.RootDock(0, menu_height, size.X, size.Y - 25f); for (int i = 0; i < tabs.Count; i++) { if (!tabs[i].Draw()) //No longer open { tabs[i].Dispose(); tabs.RemoveAt(i); i--; } } //Status bar ImGui.SetNextWindowSize(new Vector2(size.X, 25f), Condition.Always); ImGui.SetNextWindowPos(new Vector2(0, size.Y - 6f), Condition.Always, Vector2.Zero); bool sbopened = true; ImGui.BeginWindow("statusbar", ref sbopened, WindowFlags.NoTitleBar | WindowFlags.NoSavedSettings | WindowFlags.NoBringToFrontOnFocus | WindowFlags.NoMove | WindowFlags.NoResize); if (updateTime > 9) { updateTime = 0; frequency = RenderFrequency; } else { updateTime++; } ImGui.Text(string.Format("FPS: {0}", (int)Math.Round(frequency))); ImGui.EndWindow(); ImGui.PopFont(); guiHelper.Render(RenderState); }
protected override void Draw(double elapsed) { EnableTextInput(); Viewport.Replace(0, 0, Width, Height); RenderState.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f); RenderState.ClearAll(); guiHelper.NewFrame(elapsed); ImGui.PushFont(ImGuiHelper.Noto); ImGui.BeginMainMenuBar(); if (ImGui.BeginMenu("File")) { if (ImGui.MenuItem("New", "Ctrl-N", false, true)) { var t = new UtfTab(this, new EditableUtf(), "Untitled"); ActiveTab = t; tabs.Add(t); } if (ImGui.MenuItem("Open", "Ctrl-O", false, true)) { var f = FileDialog.Open(); if (f != null && DetectFileType.Detect(f) == FileType.Utf) { var t = new UtfTab(this, new EditableUtf(f), System.IO.Path.GetFileName(f)); ActiveTab = t; tabs.Add(t); } } if (ActiveTab == null) { ImGui.MenuItem("Save", "Ctrl-S", false, false); } else { if (ImGui.MenuItem(string.Format("Save '{0}'", ActiveTab.Title), "Ctrl-S", false, true)) { var f = FileDialog.Save(); if (f != null) { ActiveTab.Title = System.IO.Path.GetFileName(f); ActiveTab.Utf.Save(f); } } } if (ImGui.MenuItem("Quit", "Ctrl-Q", false, true)) { Exit(); } ImGui.EndMenu(); } if (ImGui.BeginMenu("Tools")) { if (ImGui.MenuItem("Resources")) { tabs.Add(new ResourcesTab(Resources, MissingResources, ReferencedMaterials, ReferencedTextures)); } ImGui.EndMenu(); } if (ImGui.BeginMenu("Help")) { if (ImGui.MenuItem("About")) { openAbout = true; } ImGui.EndMenu(); } if (openAbout) { ImGui.OpenPopup("About"); openAbout = false; } if (ImGui.BeginPopupModal("About", WindowFlags.AlwaysAutoResize)) { ImGui.Text("LancerEdit"); ImGui.Text("Callum McGing 2018"); if (ImGui.Button("OK")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } var menu_height = ImGui.GetWindowSize().Y; ImGui.EndMainMenuBar(); var size = (Vector2)ImGui.GetIO().DisplaySize; size.Y -= menu_height; //Window ImGuiExt.RootDock(0, menu_height, size.X, size.Y - 25); MissingResources.Clear(); ReferencedMaterials.Clear(); ReferencedTextures.Clear(); foreach (var tab in tabs) { tab.DetectResources(MissingResources, ReferencedMaterials, ReferencedTextures); } for (int i = 0; i < tabs.Count; i++) { if (!tabs[i].Draw()) //No longer open { if (tabs[i] is UtfTab && ((UtfTab)tabs[i]) == ActiveTab) { ActiveTab = null; } tabs[i].Dispose(); tabs.RemoveAt(i); i--; } } //Status bar ImGui.SetNextWindowSize(new Vector2(size.X, 25f), Condition.Always); ImGui.SetNextWindowPos(new Vector2(0, size.Y - 6f), Condition.Always, Vector2.Zero); bool sbopened = true; ImGui.BeginWindow("statusbar", ref sbopened, WindowFlags.NoTitleBar | WindowFlags.NoSavedSettings | WindowFlags.NoBringToFrontOnFocus | WindowFlags.NoMove | WindowFlags.NoResize); if (updateTime > 9) { updateTime = 0; frequency = RenderFrequency; } else { updateTime++; } string activename = ActiveTab == null ? "None" : ActiveTab.Title; string utfpath = ActiveTab == null ? "None" : ActiveTab.GetUtfPath(); ImGui.Text(string.Format("FPS: {0} | {1} Materials | {2} Textures | Active: {3} - {4}", (int)Math.Round(frequency), Resources.MaterialDictionary.Count, Resources.TextureDictionary.Count, activename, utfpath)); ImGui.EndWindow(); ImGui.PopFont(); guiHelper.Render(RenderState); foreach (var tab in toAdd) { tabs.Add(tab); } toAdd.Clear(); }