protected override void Draw(double elapsed) { 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("Open", "open", Color4.White, true)) { string f; if ((f = FileDialog.ChooseFolder()) != null) { NewGui(f); } } if (selected is SaveableTab saveable) { if (Theme.IconMenuItem($"Save '{saveable.Title}'", "save", Color4.White, true)) { saveable.Save(); } } else { Theme.IconMenuItem("Save", "save", Color4.LightGray, false); } if (Theme.IconMenuItem("Quit", "quit", Color4.White, true)) { Exit(); } ImGui.EndMenu(); } if (ImGui.BeginMenu("Lua")) { if (ImGui.BeginMenu("Base Icons")) { ImGui.MenuItem("Bar", "", ref TestApi.HasBar); ImGui.MenuItem("Trader", "", ref TestApi.HasTrader); ImGui.MenuItem("Equipment", "", ref TestApi.HasEquip); ImGui.MenuItem("Ship Dealer", "", ref TestApi.HasShipDealer); ImGui.EndMenu(); } if (ImGui.BeginMenu("Active Room")) { var rooms = TestApi.GetNavbarButtons(); for (int i = 0; i < rooms.Length; i++) { if (ImGui.MenuItem(rooms[i].IconName + "##" + i, "", TestApi.ActiveHotspotIndex == i)) { TestApi.ActiveHotspotIndex = i; } } ImGui.EndMenu(); } if (ImGui.BeginMenu("Room Actions")) { ImGui.MenuItem("Launch", "", ref TestApi.HasLaunchAction); ImGui.MenuItem("Repair", "", ref TestApi.HasRepairAction); ImGui.MenuItem("Missions", "", ref TestApi.HasMissionVendor); ImGui.MenuItem("News", "", ref TestApi.HasNewsAction); ImGui.EndMenu(); } ImGui.EndMenu(); } if (UiData != null && ImGui.BeginMenu("View")) { ImGui.MenuItem("Project", "", ref projectWindow.IsOpen); ImGui.MenuItem("Resources", "", ref resourceEditor.IsOpen); ImGui.EndMenu(); } var menu_height = ImGui.GetWindowSize().Y; ImGui.EndMainMenuBar(); var size = (Vector2)ImGui.GetIO().DisplaySize; size.Y -= menu_height; ImGui.SetNextWindowSize(new Vector2(size.X, size.Y - 25), ImGuiCond.Always); ImGui.SetNextWindowPos(new Vector2(0, menu_height), ImGuiCond.Always, Vector2.Zero); bool childopened = true; ImGui.Begin("tabwindow", ref childopened, ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoBringToFrontOnFocus | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize); var prevSel = selected; TabHandler.TabLabels(tabs, ref selected); ImGui.BeginChild("##tabcontent"); if (selected != null) { selected.Draw(); } ImGui.EndChild(); ImGui.End(); if (resourceEditor != null) { resourceEditor.Draw(); } if (projectWindow != null) { projectWindow.Draw(); } //Status Bar ImGui.SetNextWindowSize(new Vector2(size.X, 25f), ImGuiCond.Always); ImGui.SetNextWindowPos(new Vector2(0, size.Y - 6f), ImGuiCond.Always, Vector2.Zero); bool sbopened = true; ImGui.Begin("statusbar", ref sbopened, ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoBringToFrontOnFocus | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize); ImGui.Text($"InterfaceEdit{(XmlFolder != null ? " - Editing: " : "")}{(XmlFolder ?? "")}"); ImGui.End(); //Finish Render ImGui.PopFont(); guiHelper.Render(RenderState); }
protected override void Draw(double elapsed) { var delta = elapsed; RenderDelta = delta; RenderContext.ReplaceViewport(0, 0, Width, Height); RenderContext.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f); RenderContext.ClearAll(); guiHelper.NewFrame(elapsed); ImGui.PushFont(ImGuiHelper.Noto); ImGui.BeginMainMenuBar(); if (ImGui.BeginMenu("File")) { if (Theme.IconMenuItem(Icons.File, "New", true)) { string folder; string outpath; if ((folder = FileDialog.ChooseFolder()) != null) { if ((outpath = FileDialog.Save(projectFilters)) != null) { var proj = new Project(this); proj.Create(folder, outpath); OpenGui(outpath); } } } if (Theme.IconMenuItem(Icons.Open, "Open", true)) { string f; if ((f = FileDialog.Open(projectFilters)) != null) { OpenGui(f); } } recentFiles.Menu(); if (!playing && selected is SaveableTab saveable) { if (Theme.IconMenuItem(Icons.Save, $"Save '{saveable.Title}'", true)) { saveable.Save(); } } else { Theme.IconMenuItem(Icons.Save, "Save", false); } if (ImGui.MenuItem("Compile", Project != null && !playing)) { CompileProject(); } if (Theme.IconMenuItem(Icons.Quit, "Quit", true)) { Exit(); } ImGui.EndMenu(); } if (ImGui.BeginMenu("Lua")) { if (ImGui.BeginMenu("Base Icons")) { ImGui.MenuItem("Bar", "", ref TestApi.HasBar); ImGui.MenuItem("Trader", "", ref TestApi.HasTrader); ImGui.MenuItem("Equipment", "", ref TestApi.HasEquip); ImGui.MenuItem("Ship Dealer", "", ref TestApi.HasShipDealer); ImGui.EndMenu(); } if (ImGui.BeginMenu("Active Room")) { var rooms = TestApi.GetNavbarButtons(); for (int i = 0; i < rooms.Length; i++) { if (ImGui.MenuItem(rooms[i].IconName + "##" + i, "", TestApi.ActiveHotspotIndex == i)) { TestApi.ActiveHotspotIndex = i; } } ImGui.EndMenu(); } if (ImGui.BeginMenu("Room Actions")) { ImGui.MenuItem("Launch", "", ref TestApi.HasLaunchAction); ImGui.MenuItem("Repair", "", ref TestApi.HasRepairAction); ImGui.MenuItem("Missions", "", ref TestApi.HasMissionVendor); ImGui.MenuItem("News", "", ref TestApi.HasNewsAction); ImGui.MenuItem("Commodity Trader", "", ref TestApi.HasCommodityTraderAction); ImGui.MenuItem("Ship Dealer", "", ref TestApi.HasShipDealerAction); ImGui.EndMenu(); } ImGui.EndMenu(); } if (Project != null && ImGui.BeginMenu("View")) { ImGui.MenuItem("Project", "", ref projectWindow.IsOpen); ImGui.MenuItem("Resources", "", ref resourceEditor.IsOpen); ImGui.EndMenu(); } if (Project != null && !playing && ImGui.BeginMenu("Play")) { foreach (var file in projectWindow.GetClasses()) { if (ImGui.MenuItem(file)) { StartPlay(Path.GetFileNameWithoutExtension(file)); } } ImGui.EndMenu(); } if (Project != null && playing && ImGui.MenuItem("Stop")) { playing = false; _playContext = null; _playData = null; } var menu_height = ImGui.GetWindowSize().Y; ImGui.EndMainMenuBar(); var size = (Vector2)ImGui.GetIO().DisplaySize; size.Y -= menu_height; ImGui.SetNextWindowSize(new Vector2(size.X, size.Y - 25 * ImGuiHelper.Scale), ImGuiCond.Always); ImGui.SetNextWindowPos(new Vector2(0, menu_height), ImGuiCond.Always, Vector2.Zero); if (playing) { try { Player(delta); } catch (Exception e) { var detail = new StringBuilder(); BuildExceptionString(e, detail); CrashWindow.Run("Interface Edit", "Runtime Error", detail.ToString()); playing = false; _playContext = null; _playData = null; } } else { Tabs(); } //Status Bar ImGui.SetNextWindowSize(new Vector2(size.X, 25f * ImGuiHelper.Scale), ImGuiCond.Always); ImGui.SetNextWindowPos(new Vector2(0, size.Y - 6f), ImGuiCond.Always, Vector2.Zero); bool sbopened = true; ImGui.Begin("statusbar", ref sbopened, ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoBringToFrontOnFocus | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize); ImGui.Text($"InterfaceEdit{(Project != null ? " - Editing: " : "")}{(Project?.ProjectFile ?? "")}"); if (playing) { ImGui.SameLine(); ImGui.Text($"Mouse Wanted: {mouseWanted}"); } ImGui.End(); recentFiles.DrawErrors(); //Finish Render ImGui.PopFont(); guiHelper.Render(RenderContext); }