From 5e4d0aacc87348e41bc6083cc39c6a70a3a86120 Mon Sep 17 00:00:00 2001 From: mlangkabel Date: Tue, 21 Apr 2026 20:27:27 +0200 Subject: [PATCH] fix output display --- src/ui/SelectedBuildingPanel.cpp | 35 ++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/ui/SelectedBuildingPanel.cpp b/src/ui/SelectedBuildingPanel.cpp index fdb454f..8e6748a 100644 --- a/src/ui/SelectedBuildingPanel.cpp +++ b/src/ui/SelectedBuildingPanel.cpp @@ -231,7 +231,25 @@ void SelectedBuildingPanel::refreshBuffers(const Building* b) bufText += "\n"; } - if (!b->outputBuffer.items.empty()) + if (recipe && !recipe->outputs.empty()) + { + std::map outCounts; + for (const Item& item : b->outputBuffer.items) + { + outCounts[item.type.id]++; + } + bufText += "Output: "; + for (const RecipeOutput& out : recipe->outputs) + { + const std::map::const_iterator it = + outCounts.find(out.item); + const int count = (it != outCounts.end()) ? it->second : 0; + bufText += QString::fromStdString(out.item) + + ": " + QString::number(count) + + "/" + QString::number(out.amount) + " "; + } + } + else if (!b->outputBuffer.items.empty()) { std::map outCounts; for (const Item& item : b->outputBuffer.items) @@ -241,21 +259,8 @@ void SelectedBuildingPanel::refreshBuffers(const Building* b) bufText += "Output: "; for (const std::pair& entry : outCounts) { - int perCycle = 0; - if (recipe) - { - for (const RecipeOutput& out : recipe->outputs) - { - if (out.item == entry.first) { perCycle = out.amount; break; } - } - } bufText += QString::fromStdString(entry.first) - + ": " + QString::number(entry.second); - if (perCycle > 0) - { - bufText += "/" + QString::number(perCycle); - } - bufText += " "; + + ": " + QString::number(entry.second) + " "; } }