change input/output buffer item count display
This commit is contained in:
@@ -194,7 +194,7 @@ The screen is divided into three vertical sections:
|
|||||||
### Selected Building Panel
|
### Selected Building Panel
|
||||||
|
|
||||||
- REQ-UI-EMPTY-SELECTION: When no building is selected, the panel is empty.
|
- REQ-UI-EMPTY-SELECTION: When no building is selected, the panel is empty.
|
||||||
- REQ-UI-SINGLE-SELECTION: When one building is selected, the panel shows: building name, current recipe or blueprint selection, input buffer contents, and output buffer contents.
|
- REQ-UI-SINGLE-SELECTION: When one building is selected, the panel shows: building name, current recipe or blueprint selection, input buffer contents, and output buffer contents. Buffer counts are displayed as `a/b` where `a` is the current item count and `b` is the per-cycle amount (items consumed per run for inputs; items produced per run for outputs).
|
||||||
- REQ-UI-MULTI-SELECT: The player selects multiple buildings by box-drag or by Ctrl+clicking individual buildings to add or remove them from the selection.
|
- REQ-UI-MULTI-SELECT: The player selects multiple buildings by box-drag or by Ctrl+clicking individual buildings to add or remove them from the selection.
|
||||||
- REQ-UI-MULTI-SELECTION: When multiple buildings are selected, the panel shows how many of each building type are selected. No per-building detail is shown.
|
- REQ-UI-MULTI-SELECTION: When multiple buildings are selected, the panel shows how many of each building type are selected. No per-building detail is shown.
|
||||||
- REQ-UI-CONFIG-INLINE: Recipe, blueprint, ship stance, and target priority configuration for a selected building is shown and changed inline within this panel.
|
- REQ-UI-CONFIG-INLINE: Recipe, blueprint, ship stance, and target priority configuration for a selected building is shown and changed inline within this panel.
|
||||||
|
|||||||
@@ -193,21 +193,44 @@ void SelectedBuildingPanel::buildSingle(EntityId id)
|
|||||||
|
|
||||||
void SelectedBuildingPanel::refreshBuffers(const Building* b)
|
void SelectedBuildingPanel::refreshBuffers(const Building* b)
|
||||||
{
|
{
|
||||||
|
const RecipeDef* recipe = findRecipe(b);
|
||||||
|
const ShipDef* shipDef = (b->type == BuildingType::Shipyard)
|
||||||
|
? findShipDef(b->recipeId)
|
||||||
|
: nullptr;
|
||||||
|
|
||||||
QString bufText;
|
QString bufText;
|
||||||
|
|
||||||
if (!b->inputBuffer.counts.empty())
|
if (!b->inputBuffer.counts.empty())
|
||||||
{
|
{
|
||||||
bufText += "Input: ";
|
bufText += "Input: ";
|
||||||
for (const std::pair<const ItemType, int>& entry : b->inputBuffer.counts)
|
for (const std::pair<const ItemType, int>& entry : b->inputBuffer.counts)
|
||||||
{
|
{
|
||||||
const std::map<ItemType, int>::const_iterator cap =
|
int perCycle = 0;
|
||||||
b->inputBuffer.caps.find(entry.first);
|
if (recipe)
|
||||||
const int capVal = (cap != b->inputBuffer.caps.end()) ? cap->second : 0;
|
{
|
||||||
|
for (const RecipeIngredient& ing : recipe->inputs)
|
||||||
|
{
|
||||||
|
if (ing.item == entry.first.id) { perCycle = ing.amount; break; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (shipDef)
|
||||||
|
{
|
||||||
|
for (const RecipeIngredient& mat : shipDef->blueprint.materials)
|
||||||
|
{
|
||||||
|
if (mat.item == entry.first.id) { perCycle = mat.amount; break; }
|
||||||
|
}
|
||||||
|
}
|
||||||
bufText += QString::fromStdString(entry.first.id)
|
bufText += QString::fromStdString(entry.first.id)
|
||||||
+ ": " + QString::number(entry.second)
|
+ ": " + QString::number(entry.second);
|
||||||
+ "/" + QString::number(capVal) + " ";
|
if (perCycle > 0)
|
||||||
|
{
|
||||||
|
bufText += "/" + QString::number(perCycle);
|
||||||
|
}
|
||||||
|
bufText += " ";
|
||||||
}
|
}
|
||||||
bufText += "\n";
|
bufText += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!b->outputBuffer.items.empty())
|
if (!b->outputBuffer.items.empty())
|
||||||
{
|
{
|
||||||
std::map<std::string, int> outCounts;
|
std::map<std::string, int> outCounts;
|
||||||
@@ -215,17 +238,50 @@ void SelectedBuildingPanel::refreshBuffers(const Building* b)
|
|||||||
{
|
{
|
||||||
outCounts[item.type.id]++;
|
outCounts[item.type.id]++;
|
||||||
}
|
}
|
||||||
bufText += "Output(" + QString::number(static_cast<int>(b->outputBuffer.items.size()))
|
bufText += "Output: ";
|
||||||
+ "/" + QString::number(b->outputBuffer.capacity) + "): ";
|
|
||||||
for (const std::pair<const std::string, int>& entry : outCounts)
|
for (const std::pair<const std::string, int>& 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)
|
bufText += QString::fromStdString(entry.first)
|
||||||
+ ":" + QString::number(entry.second) + " ";
|
+ ": " + QString::number(entry.second);
|
||||||
|
if (perCycle > 0)
|
||||||
|
{
|
||||||
|
bufText += "/" + QString::number(perCycle);
|
||||||
|
}
|
||||||
|
bufText += " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_buffersLabel->setText(bufText);
|
m_buffersLabel->setText(bufText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const RecipeDef* SelectedBuildingPanel::findRecipe(const Building* b) const
|
||||||
|
{
|
||||||
|
if (b->recipeId.empty()) { return nullptr; }
|
||||||
|
for (const RecipeDef& r : m_config->recipes.recipes)
|
||||||
|
{
|
||||||
|
if (r.id == b->recipeId && r.building == b->type) { return &r; }
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ShipDef* SelectedBuildingPanel::findShipDef(const std::string& id) const
|
||||||
|
{
|
||||||
|
if (id.empty()) { return nullptr; }
|
||||||
|
for (const ShipDef& s : m_config->ships.ships)
|
||||||
|
{
|
||||||
|
if (s.id == id) { return &s; }
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void SelectedBuildingPanel::onStateUpdated(Tick /*tick*/, int /*blocks*/, double /*speed*/)
|
void SelectedBuildingPanel::onStateUpdated(Tick /*tick*/, int /*blocks*/, double /*speed*/)
|
||||||
{
|
{
|
||||||
if (m_singleId == kInvalidEntityId) { return; }
|
if (m_singleId == kInvalidEntityId) { return; }
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#include "Building.h"
|
#include "Building.h"
|
||||||
#include "EntityId.h"
|
#include "EntityId.h"
|
||||||
#include "GameConfig.h"
|
#include "GameConfig.h"
|
||||||
|
#include "RecipesConfig.h"
|
||||||
|
#include "ShipsConfig.h"
|
||||||
#include "Tick.h"
|
#include "Tick.h"
|
||||||
|
|
||||||
class Simulation;
|
class Simulation;
|
||||||
@@ -39,6 +41,8 @@ private:
|
|||||||
void buildSingle(EntityId id);
|
void buildSingle(EntityId id);
|
||||||
void buildMulti(const std::vector<EntityId>& ids);
|
void buildMulti(const std::vector<EntityId>& ids);
|
||||||
void refreshBuffers(const Building* b);
|
void refreshBuffers(const Building* b);
|
||||||
|
const RecipeDef* findRecipe(const Building* b) const;
|
||||||
|
const ShipDef* findShipDef(const std::string& id) const;
|
||||||
|
|
||||||
Simulation* m_sim;
|
Simulation* m_sim;
|
||||||
const GameConfig* m_config;
|
const GameConfig* m_config;
|
||||||
|
|||||||
Reference in New Issue
Block a user