private static bool DrawSettings(IUiManagerService ui) { var fontPtr = ui.Fonts["Roboto Regular 18px"]; ImGui.PushFont(fontPtr); ImGui.Text("Settings"); ImGui.SetWindowFontScale(14f / 18f); ImGui.Text("Appearance"); ImGui.SetWindowFontScale(1f); ImGui.PopFont(); var themeOptions = Enum.GetNames(typeof(UiStyle)); var selectedStyle = (int)CurrentStyle; if (ImGui.Combo("Style", ref selectedStyle, themeOptions, themeOptions.Length)) { ui.SetUiStyle((UiStyle)selectedStyle); CurrentStyle = (UiStyle)selectedStyle; } if (ImGui.Button("Done##Settings")) { State = WindowState.AgentIndex; } return(true); }
private static bool DrawAgentIndex(IUiManagerService ui, IAgentManagerService agentMan, HttpClient http) { var fontPtr = ui.Fonts["Roboto Regular 18px"]; ImGui.BeginChild("##MainWindowColumnHolder2", new Vector2(800, 330)); { ImGui.Columns(2, "##MainWindowColumns2", border: false); { ImGui.Text(agentMan.Count == 1 ? "1 agent" : $"{agentMan.Count} agents"); ImGui.BeginChild("##AgentIndex", new Vector2(600, 310)); { for (var i = 0; i < agentMan.Count; i++) { DrawCard(agentMan[i], i); if ((i + 1) % 5 != 0) { ImGui.SameLine(); } } DrawNewAgentCard(agentMan, http); } ImGui.EndChild(); } ImGui.GetWindowDrawList().AddLine( ImGui.GetWindowPos() + new Vector2(392, 42), ImGui.GetWindowPos() + new Vector2(392, 322), ImGui.GetColorU32(ImGuiCol.Border)); ImGui.NextColumn(); { ImGui.PushFont(fontPtr); ImGui.SetWindowFontScale(14f / 18f); ImGui.PushStyleColor(ImGuiCol.Button, 0); ImGui.PushStyleColor(ImGuiCol.ButtonActive, ImGui.GetColorU32(new Vector4(1, 1, 1, 0.3f))); ImGui.PushStyleColor(ImGuiCol.ButtonHovered, ImGui.GetColorU32(new Vector4(1, 1, 1, 0.1f))); ImGui.PushStyleVar(ImGuiStyleVar.ButtonTextAlign, new Vector2()); ImGui.NewLine(); ImGui.NewLine(); ImGui.Spacing(); if (ImGui.Button("Back", new Vector2(160, 22))) { State = WindowState.Index; } ImGui.PopStyleVar(); ImGui.PopStyleColor(3); ImGui.SetWindowFontScale(1f); ImGui.PopFont(); } } ImGui.EndChild(); return(true); }
public static void Draw(IUiManagerService ui, IAgentManagerService agentMan, IPluginManagerService pluginMan, HttpClient http) { ImGui.SetNextWindowSize(new Vector2(600, 400)); ImGui.Begin("Island Universe", ImGuiWindowFlags.NoResize); _ = State switch { WindowState.Index => DrawIndex(ui), WindowState.AgentIndex => DrawAgentIndex(ui, agentMan, http), WindowState.AgentSetup => DrawAgentSetup(pluginMan), WindowState.Settings => DrawSettings(ui), _ => throw new NotImplementedException(), }; ImGui.End(); }
private static bool DrawIndex(IUiManagerService ui) { var textColor = ImGui.GetColorU32(ImGuiCol.Text); var fontPtr = ui.Fonts["Roboto Regular 18px"]; ImGui.PushFont(fontPtr); ImGui.Text("Welcome to Island Universe!"); ImGui.PopFont(); ImGui.PushStyleColor(ImGuiCol.Button, 0); ImGui.PushStyleColor(ImGuiCol.ButtonActive, ImGui.GetColorU32(new Vector4(1, 1, 1, 0.3f))); ImGui.PushStyleColor(ImGuiCol.ButtonHovered, ImGui.GetColorU32(new Vector4(1, 1, 1, 0.1f))); ImGui.BeginChild("##MainWindowColumnHolder1", new Vector2(800, 300)); { ImGui.Columns(2, "##MainWindowColumns1", border: false); { ImGui.Text("Recent Procedure Executions:"); if (ImGui.Button("", new Vector2(360, 18))) { } ImGui.GetWindowDrawList().AddText(ImGui.GetWindowPos() + new Vector2(18, 19), textColor, "Timestamp 1"); ImGui.GetWindowDrawList().AddText(ImGui.GetWindowPos() + new Vector2(178, 19), textColor, "Procedure 1"); } ImGui.GetWindowDrawList().AddLine( ImGui.GetWindowPos() + new Vector2(392, 20), ImGui.GetWindowPos() + new Vector2(392, 350), ImGui.GetColorU32(ImGuiCol.Border)); ImGui.NextColumn(); { ImGui.PushFont(fontPtr); ImGui.SetWindowFontScale(14f / 18f); ImGui.PushStyleVar(ImGuiStyleVar.ButtonTextAlign, new Vector2()); ImGui.NewLine(); if (ImGui.Button("Agents", new Vector2(160, 22))) { State = WindowState.AgentIndex; } if (ImGui.Button("Procedures", new Vector2(160, 22))) { State = WindowState.ProcedureIndex; } if (ImGui.Button("Settings", new Vector2(160, 22))) { State = WindowState.Settings; } ImGui.PopStyleVar(); ImGui.SetWindowFontScale(1f); ImGui.PopFont(); } } ImGui.EndChild(); ImGui.PopStyleColor(3); return(true); }
public UiBuilder(IUiManagerService uiManager) { this.uiManager = uiManager; this.uiManager.OnBuildUi += Draw; }