public override void Render() { if (WinApi.IsKeyDown(Keys.Space)) { Settings.Enable.Value = false; } var drawPosX = Settings.WindowPosX; var drawPosY = Settings.WindowPosY; DrawRect = new RectangleF(drawPosX, drawPosY, WindowWidth + 10, WindowHeight + 55); UpdaterUtils.DrawFrameBox(DrawRect, 2, Color.Black, Color.White); #region Close Button var closeRect = DrawRect; closeRect.X += closeRect.Width - 25; closeRect.Y += 5; closeRect.Width = 20; closeRect.Height = 20; if (UpdaterUtils.DrawButton(closeRect, 1, new Color(20, 20, 20, 255), Color.White)) { Settings.Enable.Value = false; } Graphics.DrawText("X", 20, new Vector2(closeRect.X + 4, closeRect.Y - 2), Color.White); #endregion #region Tabs buttons var installedButtonRect = new RectangleF(DrawRect.X + 5, DrawRect.Y + 5, 120, 25); if (UpdaterUtils.DrawTextButton(installedButtonRect, "Installed Plugins", 15, 1, CurrentWindowTab == UWindowTab.InstalledPlugins ? Color.Gray : new Color(60, 60, 60, 255), Color.White, Color.White)) { CurrentWindowTab = UWindowTab.InstalledPlugins; } installedButtonRect.X += installedButtonRect.Width + 10; if (UpdaterUtils.DrawTextButton(installedButtonRect, "Available Plugins", 15, 1, CurrentWindowTab == UWindowTab.AvailablePlugins ? Color.Gray : new Color(60, 60, 60, 255), Color.White, Color.White)) { CurrentWindowTab = UWindowTab.AvailablePlugins; } #endregion var subWindowRect = new RectangleF(drawPosX + 5, drawPosY + 30, WindowWidth, WindowHeight); UpdaterUtils.DrawFrameBox(subWindowRect, 2, Color.Black, Color.White); if (CurrentWindowTab == UWindowTab.InstalledPlugins) { DrawWindow_InstalledPlugins(subWindowRect.X, subWindowRect.Y, subWindowRect.Width); } else if (CurrentWindowTab == UWindowTab.AvailablePlugins) { DrawWindow_AllPlugins(subWindowRect.X, subWindowRect.Y, subWindowRect.Width); } Graphics.DrawText("Notes: Move window by mouse drag. Close window key: Space", 15, new Vector2(subWindowRect.X + 10, subWindowRect.Y + subWindowRect.Height + 5), Color.Gray, FontDrawFlags.Left); bMouse_Click = false; }
public override void DrawSettingsMenu() { UniqIdCounter = 0; #region Tabs buttons ImGuiNative.igGetContentRegionAvail(out var newcontentRegionArea); ImGui.BeginChild($"{UniqId}", new ImGuiVector2(newcontentRegionArea.X, 40), true, WindowFlags.Default); if (ImGuiExtension.Button($"Installed Plugins{UniqId}")) { CurrentWindowTab = UWindowTab.InstalledPlugins; } ImGui.SameLine(); if (ImGuiExtension.Button($"Available Plugins{UniqId}")) { CurrentWindowTab = UWindowTab.AvailablePlugins; } ImGui.EndChild(); #endregion var style = ImGui.GetStyle(); var textColorBack = style.GetColor(ColorTarget.Text); if (CurrentWindowTab == UWindowTab.InstalledPlugins) { #region InstalledPlugins ImGuiNative.igGetContentRegionAvail(out newcontentRegionArea); ImGui.BeginChild($"{UniqId}", new ImGuiVector2(newcontentRegionArea.X, newcontentRegionArea.Y), true, WindowFlags.Default); ImGui.Columns(4, UniqId, true); ImGui.SetColumnWidth(0, 180); ImGui.SetColumnOffset(2, newcontentRegionArea.X - 400); ImGui.SetColumnOffset(3, newcontentRegionArea.X - 200); ImGui.Text($"Plugin name"); ImGui.NextColumn(); ImGui.Text($"Local version"); ImGui.NextColumn(); ImGui.Text($"Remote version"); ImGui.NextColumn(); ImGui.Text($"State"); ImGui.Separator(); ImGui.NextColumn(); foreach (var plug in AllPlugins.ToList()) { ImGui.Text(plug.PluginName); if (plug.IsPoeHUD) { var x64 = PoeHUDBranches[0]; if (ImGui.RadioButtonBool(x64, Settings.PoeHUDBranch == x64)) { if (Settings.PoeHUDBranch != x64) { Settings.PoeHUDBranch = x64; ForceInitialize(); } } var garena = PoeHUDBranches[1]; if (ImGui.RadioButtonBool(garena, Settings.PoeHUDBranch == garena)) { if (Settings.PoeHUDBranch != garena) { Settings.PoeHUDBranch = garena; ForceInitialize(); } } } ImGui.NextColumn(); style.SetColor(ColorTarget.Text, new ImGuiVector4(0.5f, 0.5f, 0.5f, 1)); ImGui.Text(plug.LocalVersion + (plug.LocalTag.Length > 0 ? $" ({plug.LocalTag})" : "")); ImGui.NextColumn(); if (plug.UpdateState == ePluginUpdateState.HasUpdate) { style.SetColor(ColorTarget.Text, new ImGuiVector4(0, 1, 0, 1)); } else if (plug.UpdateState == ePluginUpdateState.HasLowerUpdate) { style.SetColor(ColorTarget.Text, new ImGuiVector4(1, 0, 0, 1)); } if (plug.RemoteVersion == "No changes" || plug.RemoteVersion == "Undefined") { ImGui.Text(plug.RemoteVersion); } else if (ImGui.CollapsingHeader(plug.RemoteVersion + (plug.RemoteTag.Length > 0 ? $" ({plug.RemoteTag})" : "") + UniqId, UniqId, true, false)) { foreach (var file in plug.FilesToDownload) { ImGui.Text(file.Name); } } style.SetColor(ColorTarget.Text, textColorBack); ImGui.NextColumn(); if (!string.IsNullOrEmpty(plug.InstallProgress)) { ImGui.Text($"{plug.InstallProgress}"); } else if (!plug.bHasGitConfig) { ImGui.Text($"No git config"); } else if (plug.UpdateState == ePluginUpdateState.HasUpdate || plug.UpdateState == ePluginUpdateState.HasLowerUpdate || plug.UpdateState == ePluginUpdateState.UnknownUpdate) { string buttonLabel = ""; if (plug.UpdateState == ePluginUpdateState.UnknownUpdate) { buttonLabel = "Unknown update"; } else if (plug.UpdateState == ePluginUpdateState.HasLowerUpdate) { buttonLabel = "Update"; } else { buttonLabel = "Update"; } if (ImGui.SmallButton($"{buttonLabel}{UniqId}")) { plug.UpdatePlugin(); } } else if (plug.UpdateState == ePluginUpdateState.NoUpdate) { style.SetColor(ColorTarget.Text, new ImGuiVector4(0, 1, 0, 1)); ImGui.Text($"Updated"); } else if (plug.UpdateState == ePluginUpdateState.ReadyToInstal) { style.SetColor(ColorTarget.Text, new ImGuiVector4(1, 1, 0, 1)); ImGui.Text($"Restart PoeHUD"); } else { ImGui.Text($"Wrong git config"); } style.SetColor(ColorTarget.Text, textColorBack); ImGui.NextColumn(); ImGui.Separator(); if (plug.IsPoeHUD) { ImGui.NextColumn(); ImGui.Text($""); ImGui.NextColumn(); ImGui.NextColumn(); ImGui.NextColumn(); ImGui.Separator(); } } ImGui.EndChild(); #endregion } else if (CurrentWindowTab == UWindowTab.AvailablePlugins) { #region AvailablePlugins if (AllAvailablePlugins == null) { ImGui.Text($"File {AvailablePluginsConfigParser.AvailablePluginsConfigFile} is not found!{UniqId}"); WindowHeight = 40; return; } ImGuiNative.igGetContentRegionAvail(out newcontentRegionArea); ImGui.BeginChild($"{UniqId}", new ImGuiVector2(newcontentRegionArea.X, newcontentRegionArea.Y), true, WindowFlags.Default); ImGui.Columns(4, UniqId, true); ImGui.SetColumnWidth(0, 200); ImGui.SetColumnWidth(2, 80); ImGui.SetColumnOffset(2, newcontentRegionArea.X - 200); ImGui.Text($"Plugin name"); ImGui.NextColumn(); ImGui.Text($"Description"); ImGui.NextColumn(); ImGui.Text($"URL"); ImGui.NextColumn(); ImGui.Text($"State"); ImGui.Separator(); ImGui.NextColumn(); foreach (var availPlug in AllAvailablePlugins.ToList()) { ImGui.Text($"{availPlug.PluginName}"); ImGui.NextColumn(); ImGui.Text($"{availPlug.Description}"); ImGui.NextColumn(); if (ImGui.Button($"Open URL{UniqId}")) { System.Diagnostics.Process.Start($"https://github.com/{availPlug.GitOwner}/{availPlug.GitName}"); } ImGui.NextColumn(); if (availPlug.bOwned) { style.SetColor(ColorTarget.Text, new ImGuiVector4(0, 1, 0, 1)); ImGui.Text($"Owned"); } else if (availPlug.InstalledPlugin != null) { if (availPlug.InstalledPlugin.InstallProgress.Length > 0) { ImGui.Text($"{availPlug.InstalledPlugin.InstallProgress}"); } else if (availPlug.bInstaled) { style.SetColor(ColorTarget.Text, new ImGuiVector4(1, 1, 0, 1)); ImGui.Text($"Restart PoeHUD"); } else { ImGui.Text($"Downloading..."); } } else if (ImGui.Button($"Install{UniqId}")) { var newPluginDir = Path.Combine("plugins", availPlug.PluginName); Directory.CreateDirectory(newPluginDir); var newConfigPath = Path.Combine(newPluginDir, GitConfigParser.ConfigFileName); DownloadConfigForPlugin(availPlug, newConfigPath, newPluginDir); } style.SetColor(ColorTarget.Text, textColorBack); ImGui.NextColumn(); ImGui.Separator(); } ImGui.EndChild(); #endregion } }