From 79441906f249690ad99d4a0e94b807c42fb264a6 Mon Sep 17 00:00:00 2001 From: kubiix Date: Tue, 23 Sep 2025 22:29:13 +0200 Subject: [PATCH 1/2] Remove page with Ctrl+right click on close button --- Yafc.UI/ImGui/ImGuiUtils.cs | 7 +++++++ Yafc/Data/locale/en/yafc.cfg | 1 + Yafc/Widgets/MainScreenTabBar.cs | 11 +++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) 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--; } } From 088e602b6fa6681bf33f710057681e4d045541b8 Mon Sep 17 00:00:00 2001 From: kubiix Date: Tue, 23 Sep 2025 23:55:16 +0200 Subject: [PATCH 2/2] Remove page with Ctrl+right click on close button (changelog) --- changelog.txt | 2 ++ 1 file changed, 2 insertions(+) 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.