Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Yafc/Data/locale/en/yafc.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 38 additions & 1 deletion Yafc/Workspace/ProductionTable/ProductionTableView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Yafc;

public class ProductionTableView : ProjectPageView<ProductionTable> {
private readonly FlatHierarchy<RecipeRow, ProductionTable> flatHierarchyBuilder;
private RecipeRow? hoveredRecipe;

public ProductionTableView() {
DataGrid<RecipeRow> grid = new DataGrid<RecipeRow>(new RecipePadColumn(this), new RecipeColumn(this), new EntityColumn(this),
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
}
}
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading