diff --git a/Yafc/Data/locale/en/yafc.cfg b/Yafc/Data/locale/en/yafc.cfg index fa1dbf04..7e2cf443 100644 --- a/Yafc/Data/locale/en/yafc.cfg +++ b/Yafc/Data/locale/en/yafc.cfg @@ -136,6 +136,8 @@ tooltip-entity-absorbs-pollution=Absorption: __1__ __2__ per minute tooltip-entity-emits-pollution=Emission: __1__ __2__ per minute tooltip-entity-requires-heat=Requires __1__ heat on cold planets. tooltip-item-spoils=After __1__, spoils into +tooltip-copy-building-blueprint=Press Ctrl+C to copy building blueprint +button-copy-blueprint=Copy blueprint ; AboutScreen.cs about-yafc=About YAFC-CE diff --git a/Yafc/Workspace/ProductionTable/ProductionTableView.cs b/Yafc/Workspace/ProductionTable/ProductionTableView.cs index e93a2bda..3e81a10e 100644 --- a/Yafc/Workspace/ProductionTable/ProductionTableView.cs +++ b/Yafc/Workspace/ProductionTable/ProductionTableView.cs @@ -12,6 +12,7 @@ namespace Yafc; public class ProductionTableView : ProjectPageView { private readonly FlatHierarchy flatHierarchyBuilder; + private RecipeRow? hoveredRecipe; public ProductionTableView() { DataGrid grid = new DataGrid(new RecipePadColumn(this), new RecipeColumn(this), new EntityColumn(this), @@ -120,7 +121,22 @@ private static void BuildRowMarker(ImGui gui, RecipeRow row) { private class RecipeColumn(ProductionTableView view) : ProductionTableDataColumn(view, LSs.ProductionTableHeaderRecipe, 13f, 13f, 30f, widthStorage: nameof(Preferences.recipeColumnWidth)) { public override void BuildElement(ImGui gui, RecipeRow recipe) { gui.spacing = 0.5f; - switch (gui.BuildFactorioObjectButton(recipe.recipe, ButtonDisplayStyle.ProductionTableUnscaled)) { + var buttonEvent = gui.BuildFactorioObjectButton(recipe.recipe, ButtonDisplayStyle.ProductionTableUnscaled); + + // Track hovered recipe for Ctrl+C functionality and show tooltip + if (gui.IsMouseOver(gui.lastRect)) { + view.hoveredRecipe = recipe; + + // Show tooltip with Ctrl+C hint if the recipe has an entity (can generate blueprint) + if (recipe.entity != null) { + gui.ShowTooltip(gui.lastRect, tooltip => { + tooltip.BuildText(recipe.recipe.target.locName, Font.subheader); + tooltip.BuildText(LSs.TooltipCopyBuildingBlueprint, TextBlockDisplayStyle.WrappedText); + }); + } + } + + switch (buttonEvent) { case Click.Left: gui.ShowDropDown(delegate (ImGui imgui) { DrawRecipeTagSelect(imgui, recipe); @@ -145,6 +161,11 @@ public override void BuildElement(ImGui gui, RecipeRow recipe) { view.BuildShoppingList(recipe); } + // Add "Copy blueprint" button if recipe has an entity + if (recipe.entity != null && imgui.BuildButton(LSs.ButtonCopyBlueprint) && imgui.CloseDropdown()) { + view.CopyRecipeBlueprint(recipe); + } + if (imgui.BuildCheckBox(LSs.ProductionTableShowTotalIo, recipe.showTotalIO, out bool newShowTotalIO)) { recipe.RecordUndo().showTotalIO = newShowTotalIO; } @@ -1675,4 +1696,20 @@ void initializeGrid(ImGui gui) { } } } + + public override bool ControlKey(SDL.SDL_Scancode code) { + // Handle Ctrl+C to copy blueprint for hovered recipe + if (code == SDL.SDL_Scancode.SDL_SCANCODE_C && hoveredRecipe?.entity != null) { + CopyRecipeBlueprint(hoveredRecipe); + return true; + } + + return base.ControlKey(code); + } + + private void CopyRecipeBlueprint(RecipeRow recipe) { + if (recipe.entity == null) return; + + BlueprintUtilities.ExportRecipiesAsBlueprint(recipe.recipe.target.locName, [recipe], Preferences.Instance.exportEntitiesWithFuelFilter); + } } diff --git a/changelog.txt b/changelog.txt index a0584d19..9bbce36e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -21,6 +21,10 @@ ---------------------------------------------------------------------------------------------------------------------- Version: Date: + Features: + - Add Ctrl+C shortcut to copy building blueprint for hovered recipe in production table. + - Add "Copy blueprint" button to recipe dropdown menu in production table. + - Add tooltip showing Ctrl+C hint when hovering over recipes with buildings. 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.