diff --git a/Yafc.UI/ImGui/ImGuiUtils.cs b/Yafc.UI/ImGui/ImGuiUtils.cs index 0e085721..fc0e92d9 100644 --- a/Yafc.UI/ImGui/ImGuiUtils.cs +++ b/Yafc.UI/ImGui/ImGuiUtils.cs @@ -225,6 +225,13 @@ public static bool WithTooltip(this ButtonEvent evt, ImGui gui, string tooltip, return evt; } + public static bool WithTooltipConditional(this ButtonEvent evt, bool condition, ImGui gui, string tooltip, Rect? rect = null) { + if (evt == ButtonEvent.MouseOver && condition) { + gui.ShowTooltip(rect ?? gui.lastRect, tooltip); + } + + return evt; + } public static bool BuildCheckBox(this ImGui gui, string text, bool value, out bool newValue, SchemeColor color = SchemeColor.None, RectAllocator allocator = RectAllocator.LeftRow, string? tooltip = null) { diff --git a/Yafc/Data/locale/en/yafc.cfg b/Yafc/Data/locale/en/yafc.cfg index 5bfbaaf9..dd2260e6 100644 --- a/Yafc/Data/locale/en/yafc.cfg +++ b/Yafc/Data/locale/en/yafc.cfg @@ -43,6 +43,7 @@ open-secondary-page=Open as secondary shortcut-ctrl-click=Ctrl+Click close-secondary-page=Close secondary duplicate-page=Duplicate page +tooltip-close-page=Click to close\nCtrl+Click to remove ; ObjectTooltip.cs name-with-type=__1__ (__2__) diff --git a/Yafc/Widgets/MainScreenTabBar.cs b/Yafc/Widgets/MainScreenTabBar.cs index 380d7421..0545cdc2 100644 --- a/Yafc/Widgets/MainScreenTabBar.cs +++ b/Yafc/Widgets/MainScreenTabBar.cs @@ -48,12 +48,19 @@ private void BuildContents(ImGui gui) { } gui.BuildText(page.name); - if (gui.BuildButton(Icon.Close, size: 0.8f)) { + if (gui.BuildButton(Icon.Close, size: 0.8f).WithTooltipConditional(page.canDelete, gui, LSs.TooltipClosePage)) { if (isActive || isSecondary) { changePageTo = prevPage; changePage = isActive ? 1 : 2; } - screen.ClosePage(pageGuid); + + if (InputSystem.Instance.control && page.canDelete) { + project.RemovePage(page); + } + else { + screen.ClosePage(pageGuid); + } + i--; } } diff --git a/changelog.txt b/changelog.txt index db6a0521..b40cd416 100644 --- a/changelog.txt +++ b/changelog.txt @@ -21,6 +21,8 @@ ---------------------------------------------------------------------------------------------------------------------- Version: Date: + Features: + - Add option to remove page with Right-click on the tab close button Fixes: - Fix rendering of multi-icon technologies (e.g. shooting speed techs) - Add simplified support for debug.getinfo(), only returns short_src. Fixes #455, #504.