private void DrawEntryHoverMenu(Rect entryRect, SettingHandle handle)
        {
            var topRight = new Vector2(
                entryRect.x + entryRect.width / 2f - HandleEntryPadding,
                entryRect.y + entryRect.height / 2f - ModSettingsWidgets.HoverMenuHeight / 2f
                );
            var includeResetEntry   = handle.CanBeReset && !handle.Unsaved;
            var menuHasExtraOptions = handle.ContextMenuEntries != null;
            var menuEnabled         = includeResetEntry || menuHasExtraOptions;
            var menuButtonClicked   = ModSettingsWidgets.DrawHandleHoverMenu(
                topRight, handle.Description, menuEnabled, menuHasExtraOptions);

            if (menuButtonClicked)
            {
                OpenHandleContextMenu();
            }

            void OpenHandleContextMenu()
            {
                var resetOptionLabel = handle.CanBeReset ? "HugsLib_settings_resetValue".Translate() : null;

                ModSettingsWidgets.OpenExtensibleContextMenu(resetOptionLabel,
                                                             () => ResetSettingHandles(handle), delegate {}, handle.ContextMenuEntries);
            }
        }
        // draws the input control for Enum settings
        private bool DrawHandleInputEnum(SettingHandle handle, Rect controlRect, HandleControlInfo info)
        {
            if (info.enumNames == null)
            {
                return(false);
            }
            var readableValue = (handle.EnumStringPrefix + info.inputValue).Translate();

            if (Widgets.ButtonText(controlRect, readableValue))
            {
                var floatOptions = new List <FloatMenuOption>();
                foreach (var valueName in info.enumNames)
                {
                    var name           = valueName;
                    var readableOption = (handle.EnumStringPrefix + name).Translate();
                    floatOptions.Add(new FloatMenuOption(readableOption, () => {
                        handle.StringValue       = info.inputValue = name;
                        info.validationScheduled = true;
                    }));
                }
                ModSettingsWidgets.OpenFloatMenu(floatOptions);
            }
            if (info.validationScheduled)
            {
                info.validationScheduled = false;
                return(true);
            }
            return(false);
        }
        // draws the header with the name of the mod
        private void DrawModEntryHeader(ModEntry entry, float width, ref float curY)
        {
            if (entry.ModName.NullOrEmpty())
            {
                return;
            }
            var entryTitleRect = new Rect(0f, curY, width, ModEntryLabelHeight);
            var mouseOverTitle = Mouse.IsOver(entryTitleRect);

            if (mouseOverTitle)
            {
                Widgets.DrawHighlight(entryTitleRect);
            }
            var labelRect = entryTitleRect.ContractedBy(ModEntryLabelPadding);

            Text.Font = GameFont.Medium;
            Widgets.Label(labelRect, entry.ModName);
            Text.Font = GameFont.Small;

            var entryButtonsTopRight = new Vector2(width, curY);
            var activateButtonWidth  = DrawActivateEntryButton(entryButtonsTopRight);

            DrawFloatMenuButton(new Vector2(entryButtonsTopRight.x - activateButtonWidth, entryButtonsTopRight.y));

            curY += ModEntryLabelHeight;
            var color = GUI.color;

            GUI.color = ModEntryLineColor;
            Widgets.DrawLineHorizontal(0f, curY, width);
            GUI.color = color;
            curY     += ModEntryLabelPadding;

            float DrawActivateEntryButton(Vector2 topRight)
            {
                if (entry.SettingsPack == null || !entry.SettingsPack.AlwaysExpandEntry)
                {
                    var         isExpanded = expandedModEntries.Contains(entry);
                    CachedLabel buttonLabel;
                    var         isVanillaEntry = entry.SettingsPack == null;
                    float       toggleButtonWidth;
                    if (isVanillaEntry)
                    {
                        buttonLabel       = labelShowVanillaSettings;
                        toggleButtonWidth = labelShowVanillaSettings.Size.x + ModEntryExpandButtonPadding;
                    }
                    else
                    {
                        buttonLabel       = isExpanded ? labelCollapseModEntry : labelExpandModEntry;
                        toggleButtonWidth = expandableToggleButtonWidth;
                    }
                    var buttonRect = new Rect(topRight.x - (toggleButtonWidth + ModEntryLabelPadding),
                                              topRight.y + (ModEntryLabelHeight - ModEntryShowSettingsButtonHeight) / 2f,
                                              toggleButtonWidth, ModEntryShowSettingsButtonHeight);
                    if (Widgets.ButtonText(buttonRect, buttonLabel))
                    {
                        if (isVanillaEntry)
                        {
                            Find.WindowStack.Add(new Dialog_VanillaModSettings(entry.VanillaMod));
                        }
                        else
                        {
                            if (isExpanded)
                            {
                                expandedModEntries.Remove(entry);
                            }
                            else
                            {
                                expandedModEntries.Add(entry);
                            }
                        }
                    }
                    return(topRight.x - buttonRect.x);
                }
                return(0f);
            }

            void DrawFloatMenuButton(Vector2 topRight)
            {
                if (!mouseOverTitle)
                {
                    return;
                }
                var buttonTopRight = new Vector2(topRight.x - ModEntryLabelPadding,
                                                 topRight.y + (ModEntryLabelHeight - ModSettingsWidgets.HoverMenuHeight) / 2f);
                var hasExtraMenuEntries = entry.SettingsPack?.ContextMenuEntries != null;

                if (ModSettingsWidgets.DrawHoverMenuButton(
                        buttonTopRight, entry.HasContextMenuEntries, hasExtraMenuEntries))
                {
                    OpenModEntryContextMenu();
                }

                void OpenModEntryContextMenu()
                {
                    var resetOptionLabel =
                        entry.SettingsPack.CanBeReset ? "HugsLib_settings_resetMod".Translate(entry.ModName) : null;

                    ModSettingsWidgets.OpenExtensibleContextMenu(resetOptionLabel,
                                                                 OnResetOptionSelected, delegate {}, entry.SettingsPack.ContextMenuEntries);
                }

                void OnResetOptionSelected()
                {
                    ShowResetPrompt("HugsLib_settings_resetMod_prompt".Translate(entry.ModName),
                                    entry.SettingsPack.Handles);
                }
            }
        }