internal override void DrawSettingsMenu() { #region var newSelectedTheme = ImGuiExtension.ComboBox("Select Theme", "Themes", SelectedThemeName, MainMenuWindow.Settings.Theme.Values); if (SelectedThemeName != newSelectedTheme) { SelectedThemeName = newSelectedTheme; LoadedTheme = LoadTheme(newSelectedTheme, false); ApplyTheme(LoadedTheme); } if (ImGuiExtension.Button("Save current theme settings to selected")) { var currentThemeNew = ReadThemeFromCurrent(); SaveTheme(currentThemeNew, SelectedThemeName); } ImGui.Text(""); NewThemeName = ImGuiExtension.InputText("New theme name", NewThemeName, 200, InputTextFlags.Default); if (ImGuiExtension.Button("Create new theme from current")) { if (!string.IsNullOrEmpty(NewThemeName)) { string regexSearch = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars()); Regex r = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch))); NewThemeName = r.Replace(NewThemeName, ""); var currentThemeNew = ReadThemeFromCurrent(); SaveTheme(currentThemeNew, NewThemeName); SelectedThemeName = NewThemeName; LoadThemeFilesList(); } } #endregion ImGui.Text(""); var style = ImGui.GetStyle(); if (ImGui.TreeNode("Theme settings")) { style.AntiAliasedFill = DrawBoolSetting("AntiAliasedFill", style.AntiAliasedFill); style.AntiAliasedLines = DrawBoolSetting("AntiAliasedLines", style.AntiAliasedLines); style.Alpha = DrawFloatSetting("Alpha", style.Alpha * 100, 0, 100) / 100f; style.DisplayWindowPadding = DrawVectorSetting("DisplayWindowPadding", style.DisplayWindowPadding, 0, 20); style.TouchExtraPadding = DrawVectorSetting("TouchExtraPadding", style.TouchExtraPadding, 0, 10); style.WindowPadding = DrawVectorSetting("WindowPadding", style.WindowPadding, 0, 20); style.FramePadding = DrawVectorSetting("FramePadding", style.FramePadding, 0, 20); style.DisplaySafeAreaPadding = DrawVectorSetting("DisplaySafeAreaPadding", style.DisplaySafeAreaPadding, 0, 20); style.ItemInnerSpacing = DrawVectorSetting("ItemInnerSpacing", style.ItemInnerSpacing, 0, 20); style.ItemSpacing = DrawVectorSetting("ItemSpacing", style.ItemSpacing, 0, 20); style.GrabMinSize = DrawFloatSetting("GrabMinSize", style.GrabMinSize, 0, 20); style.GrabRounding = DrawFloatSetting("GrabRounding", style.GrabRounding, 0, 12); style.IndentSpacing = DrawFloatSetting("IndentSpacing", style.IndentSpacing, 0, 30); style.ScrollbarRounding = DrawFloatSetting("ScrollbarRounding", style.ScrollbarRounding, 0, 19); style.ScrollbarSize = DrawFloatSetting("ScrollbarSize", style.ScrollbarSize, 0, 20); style.WindowTitleAlign = DrawVectorSetting("WindowTitleAlign", style.WindowTitleAlign, 0, 1, 0.1f); style.WindowRounding = DrawFloatSetting("WindowRounding", style.WindowRounding, 0, 14); style.ChildWindowRounding = DrawFloatSetting("ChildWindowRounding", style.ChildWindowRounding, 0, 16); style.FrameRounding = DrawFloatSetting("FrameRounding", style.FrameRounding, 0, 12); style.ColumnsMinSpacing = DrawFloatSetting("ColumnsMinSpacing", style.ColumnsMinSpacing, 0, 30); style.CurveTessellationTolerance = DrawFloatSetting("CurveTessellationTolerance", style.CurveTessellationTolerance * 100, 0, 100) / 100; } ImGui.Text(""); #region ColorsDraw ImGui.Text("Colors:"); ImGui.Columns(2, "Columns", true); var colorTypes = Enum.GetValues(typeof(ColorTarget)).Cast <ColorTarget>(); var count = colorTypes.Count() / 2; foreach (var type in colorTypes) { var nameFixed = Regex.Replace(type.ToString(), "(\\B[A-Z])", " $1"); var colorValue = style.GetColor(type); if (ImGui.ColorEdit4(nameFixed, ref colorValue, ColorEditFlags.AlphaBar | ColorEditFlags.NoInputs | ColorEditFlags.AlphaPreviewHalf)) { style.SetColor(type, colorValue); } if (count-- == -1) { ImGui.NextColumn(); } } #endregion }
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 } }
public void Render() { if (!Settings.Enable.Value) { return; } var opened = Settings.Enable.Value; Settings.IsCollapsed = !DrawInfoWindow("PoeHUD " + PoeHUDVersion, ref opened, Settings.MenuWindowPos.X, Settings.MenuWindowPos.Y, Settings.MenuWindowSize.X, Settings.MenuWindowSize.Y, WindowFlags.Default, Condition.Appearing); Settings.Enable.Value = opened; if (!Settings.IsCollapsed) { ImGuiNative.igGetContentRegionAvail(out newcontentRegionArea); if (ImGui.BeginChild("PluginsList", new Vector2(PluginNameWidth + 60, newcontentRegionArea.Y), true, WindowFlags.Default)) { PluginNameWidth = 120; var coreOpened = ImGui.TreeNodeEx("", Settings.CorePluginsTreeState); ImGui.SameLine(); if (ImGui.Selectable(CoreMenu.Plugin.PluginName, SelectedPlugin == CoreMenu.Plugin)) { SelectedPlugin = CoreMenu.Plugin; } if (coreOpened) { foreach (var defPlugin in CoreMenu.Childs) { if (defPlugin.Childs.Count == 0) { DrawPlugin(defPlugin.Plugin, 20); } else { defPlugin.Plugin.Settings.Enable = ImGuiExtension.Checkbox($"##{defPlugin.Plugin.PluginName}Enabled", defPlugin.Plugin.Settings.Enable.Value); ImGui.SameLine(); var pluginOpened = ImGui.TreeNodeEx($"##{defPlugin.Plugin.PluginName}", TreeNodeFlags.OpenOnArrow); ImGui.SameLine(); var labelSize = ImGui.GetTextSize(defPlugin.Plugin.PluginName).X + 30; if (PluginNameWidth < labelSize) { PluginNameWidth = labelSize; } if (ImGui.Selectable(defPlugin.Plugin.PluginName, SelectedPlugin == defPlugin.Plugin)) { SelectedPlugin = defPlugin.Plugin; } if (pluginOpened) { foreach (var plugin in defPlugin.Childs) { DrawPlugin(plugin.Plugin, 30); } ImGuiNative.igUnindent(); } } } ImGui.TreePop(); Settings.CorePluginsTreeState = TreeNodeFlags.DefaultOpen | TreeNodeFlags.OpenOnArrow; ImGui.Text(""); } else { Settings.CorePluginsTreeState = TreeNodeFlags.OpenOnArrow; } if (ImGui.TreeNodeEx("Installed Plugins", Settings.InstalledPluginsTreeNode)) { foreach (var plugin in PluginExtensionPlugin.Plugins) { if (Settings.DeveloperMode.Value && Settings.ShowPluginsMS.Value) { var extPlugin = (plugin as ExternalPluginHolder).BPlugin; if (extPlugin == null) //This can happen while plugin update (using plugin updator) or recompile { continue; } ImGuiExtension.Label(extPlugin.AwerageMs.ToString()); ImGui.SameLine(); } DrawPlugin(plugin, 20); } ImGui.TreePop(); Settings.InstalledPluginsTreeNode = TreeNodeFlags.DefaultOpen; } else { Settings.InstalledPluginsTreeNode = (TreeNodeFlags)0; } } ImGui.EndChild(); ImGui.SameLine(); if (SelectedPlugin != null) { ImGuiNative.igGetContentRegionAvail(out newcontentRegionArea); ImGui.BeginChild("PluginOptions", new Vector2(newcontentRegionArea.X, newcontentRegionArea.Y), true, WindowFlags.Default); var extPlugin = SelectedPlugin as ExternalPluginHolder; if (Settings.DeveloperMode.Value && extPlugin != null) { if (ImGuiExtension.Button("Reload Plugin")) { extPlugin.ReloadPlugin(); } if (extPlugin.BPlugin != null) { ImGui.SameLine(); ImGuiExtension.Label("CurrentMS: " + extPlugin.BPlugin.CurrentMs); ImGui.SameLine(); ImGuiExtension.Label("AwerageMS: " + extPlugin.BPlugin.AwerageMs); ImGui.SameLine(); ImGuiExtension.Label("TopMS: " + extPlugin.BPlugin.TopMs); } } SelectedPlugin.DrawSettingsMenu(); ImGui.EndChild(); } Settings.MenuWindowSize = ImGui.GetWindowSize(); } Settings.MenuWindowPos = ImGui.GetWindowPosition(); ImGui.EndWindow(); if (Settings.ShowImguiDemo.Value) { bool tmp = Settings.ShowImguiDemo.Value; ImGuiNative.igShowDemoWindow(ref tmp); Settings.ShowImguiDemo.Value = tmp; } }