public void OpenFile(string f) { if (f != null && System.IO.File.Exists(f) && DetectFileType.Detect(f) == FileType.Utf) { var t = new UtfTab(this, new EditableUtf(f), System.IO.Path.GetFileName(f)); ActiveTab = t; AddTab(t); } }
protected override void OnDrop(string file) { if (DetectFileType.Detect(file) == FileType.Utf) { var t = new UtfTab(this, new EditableUtf(file), System.IO.Path.GetFileName(file)); ActiveTab = t; AddTab(t); } }
public void OpenFile(string f) { if (f != null && System.IO.File.Exists(f) && DetectFileType.Detect(f) == FileType.Utf) { var t = new UtfTab(this, new EditableUtf(f), System.IO.Path.GetFileName(f)); recentFiles.FileOpened(f); t.FilePath = f; ActiveTab = t; AddTab(t); guiHelper.ResetRenderTimer(); } }
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(); }
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 (Theme.IconMenuItem("New", "new", Color4.White, true)) { var t = new UtfTab(this, new EditableUtf(), "Untitled"); ActiveTab = t; AddTab(t); } if (Theme.IconMenuItem("Open", "open", Color4.White, 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; AddTab(t); } } if (ActiveTab == null) { Theme.IconMenuItem("Save", "save", Color4.LightGray, false); } else { if (Theme.IconMenuItem(string.Format("Save '{0}'", ActiveTab.Title), "save", Color4.White, true)) { var f = FileDialog.Save(); if (f != null) { ActiveTab.Title = System.IO.Path.GetFileName(f); ActiveTab.Utf.Save(f); } } } if (Theme.IconMenuItem("Quit", "quit", Color4.White, 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 (Theme.IconMenuItem("About", "about", Color4.White, true)) { 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"); ImGui.Separator(); ImGui.Text("Icons from Icons8: https://icons8.com/"); ImGui.Text("Icons from komorra: https://opengameart.org/content/kmr-editor-icon-set"); ImGui.Separator(); 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 MissingResources.Clear(); ReferencedMaterials.Clear(); ReferencedTextures.Clear(); foreach (var tab in tabs) { tab.DetectResources(MissingResources, ReferencedMaterials, ReferencedTextures); } ImGui.SetNextWindowSize(new Vector2(size.X, size.Y - 25), Condition.Always); ImGui.SetNextWindowPos(new Vector2(0, menu_height), Condition.Always, Vector2.Zero); bool childopened = true; ImGui.BeginWindow("tabwindow", ref childopened, WindowFlags.NoTitleBar | WindowFlags.NoSavedSettings | WindowFlags.NoBringToFrontOnFocus | WindowFlags.NoMove | WindowFlags.NoResize); TabHandler.TabLabels(tabs, ref selected); ImGui.BeginChild("###tabcontent"); if (selected != null) { selected.Draw(); selected.SetActiveTab(this); } else { ActiveTab = null; } ImGui.EndChild(); TabHandler.DrawTabDrag(tabs); ImGui.EndWindow(); //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); selected = tab; } toAdd.Clear(); }
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 (Theme.IconMenuItem("New", "new", Color4.White, true)) { var t = new UtfTab(this, new EditableUtf(), "Untitled"); ActiveTab = t; AddTab(t); } if (Theme.IconMenuItem("Open", "open", Color4.White, true)) { var f = FileDialog.Open(UtfFilters); if (f != null && DetectFileType.Detect(f) == FileType.Utf) { var t = new UtfTab(this, new EditableUtf(f), System.IO.Path.GetFileName(f)); ActiveTab = t; AddTab(t); } } if (ActiveTab == null) { Theme.IconMenuItem("Save", "save", Color4.LightGray, false); } else { if (Theme.IconMenuItem(string.Format("Save '{0}'", ActiveTab.DocumentName), "save", Color4.White, true)) { var f = FileDialog.Save(UtfFilters); if (f != null) { ActiveTab.DocumentName = System.IO.Path.GetFileName(f); ActiveTab.UpdateTitle(); ActiveTab.Utf.Save(f); } } } if (Theme.IconMenuItem("Quit", "quit", Color4.White, true)) { Exit(); } ImGui.EndMenu(); } bool openerror = false; if (ImGui.BeginMenu("Tools")) { if (ImGui.MenuItem("Options")) { showOptions = true; } if (ImGui.MenuItem("Log")) { showLog = true; } if (ImGui.MenuItem("Resources")) { AddTab(new ResourcesTab(Resources, MissingResources, ReferencedMaterials, ReferencedTextures)); } if (ImGui.MenuItem("Import Collada")) { string input; if ((input = FileDialog.Open(ColladaFilters)) != null) { List <ColladaObject> dae = null; try { dae = ColladaSupport.Parse(input); AddTab(new ColladaTab(dae, System.IO.Path.GetFileName(input), this)); } catch (Exception ex) { if (errorText != null) { errorText.Dispose(); } var str = "Import Error:\n" + ex.Message + "\n" + ex.StackTrace; errorText = new TextBuffer(); errorText.SetText(str); openerror = true; } } } ImGui.EndMenu(); } if (ImGui.BeginMenu("Help")) { if (Theme.IconMenuItem("About", "about", Color4.White, true)) { openAbout = true; } ImGui.EndMenu(); } if (openAbout) { ImGui.OpenPopup("About"); openAbout = false; } if (openerror) { ImGui.OpenPopup("Error"); } if (ImGui.BeginPopupModal("Error", WindowFlags.AlwaysAutoResize)) { ImGui.Text("Error:"); ImGui.InputTextMultiline("##etext", errorText.Pointer, (uint)errorText.Size, new Vector2(430, 200), InputTextFlags.ReadOnly, errorText.Callback); if (ImGui.Button("OK")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } if (ImGui.BeginPopupModal("About", WindowFlags.AlwaysAutoResize)) { ImGui.Text("LancerEdit"); ImGui.Text("Callum McGing 2018"); ImGui.Separator(); ImGui.Text("Icons from Icons8: https://icons8.com/"); ImGui.Text("Icons from komorra: https://opengameart.org/content/kmr-editor-icon-set"); ImGui.Separator(); 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 MissingResources.Clear(); ReferencedMaterials.Clear(); ReferencedTextures.Clear(); foreach (var tab in tabs) { tab.DetectResources(MissingResources, ReferencedMaterials, ReferencedTextures); } ImGui.SetNextWindowSize(new Vector2(size.X, size.Y - 25), Condition.Always); ImGui.SetNextWindowPos(new Vector2(0, menu_height), Condition.Always, Vector2.Zero); bool childopened = true; ImGui.BeginWindow("tabwindow", ref childopened, WindowFlags.NoTitleBar | WindowFlags.NoSavedSettings | WindowFlags.NoBringToFrontOnFocus | WindowFlags.NoMove | WindowFlags.NoResize); TabHandler.TabLabels(tabs, ref selected); var totalH = ImGui.GetWindowHeight(); if (showLog) { ImGuiExt.SplitterV(2f, ref h1, ref h2, 8, 8, -1); h1 = totalH - h2 - 24f; if (tabs.Count > 0) { h1 -= 20f; } ImGui.BeginChild("###tabcontent" + (selected != null ? selected.Title : ""), new Vector2(-1, h1), false, WindowFlags.Default); } else { ImGui.BeginChild("###tabcontent" + (selected != null ? selected.Title : "")); } if (selected != null) { selected.Draw(); selected.SetActiveTab(this); } else { ActiveTab = null; } ImGui.EndChild(); TabHandler.DrawTabDrag(tabs); if (showLog) { ImGui.BeginChild("###log", new Vector2(-1, h2), false, WindowFlags.Default); ImGui.Text("Log"); ImGui.SameLine(ImGui.GetWindowWidth() - 20); if (Theme.IconButton("closelog", "x", Color4.White)) { showLog = false; } ImGui.InputTextMultiline("##logtext", logBuffer.Pointer, 32768, new Vector2(-1, h2 - 24), InputTextFlags.ReadOnly, logBuffer.Callback); ImGui.EndChild(); } ImGui.EndWindow(); //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.DocumentName; 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(); if (showOptions) { ImGui.BeginWindow("Options", ref showOptions, WindowFlags.AlwaysAutoResize); var pastC = cFilter; ImGui.Combo("Texture Filter", ref cFilter, filters); if (cFilter != pastC) { switch (cFilter) { case 0: RenderState.PreferredFilterLevel = TextureFiltering.Linear; break; case 1: RenderState.PreferredFilterLevel = TextureFiltering.Bilinear; break; case 2: RenderState.PreferredFilterLevel = TextureFiltering.Trilinear; break; default: RenderState.AnisotropyLevel = anisotropyLevels[cFilter - 3]; RenderState.PreferredFilterLevel = TextureFiltering.Anisotropic; break; } } ImGui.EndWindow(); } ImGui.PopFont(); guiHelper.Render(RenderState); foreach (var tab in toAdd) { tabs.Add(tab); selected = tab; } toAdd.Clear(); }