Skip to content

Commit

Permalink
Let's also display assigned group number on UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Monsterovich committed Feb 14, 2024
1 parent 6dbcfc2 commit a9f5574
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/hci/manufacture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,10 @@ class ManufactureObjectButton : public ObjectButton
void initialize()
{
attach(factoryNumberLabel = std::make_shared<W_LABEL>());
attach(factoryAssignGroupLabel = std::make_shared<W_LABEL>());
factoryNumberLabel->setGeometry(OBJ_TEXTX, OBJ_B1TEXTY, 16, 16);
factoryAssignGroupLabel->setGeometry(OBJ_TEXTX + 48, OBJ_B1TEXTY, 16, 16);
factoryAssignGroupLabel->setFontColour(pal_RGBA(255, 220, 115, 255) /* gold */);
}

void display(int xOffset, int yOffset) override
Expand All @@ -262,14 +265,23 @@ class ManufactureObjectButton : public ObjectButton
void updateLayout() override
{
BaseWidget::updateLayout();
auto factory = getFactoryOrNullptr(controller->getObjectAt(objectIndex));
auto psStruct = controller->getObjectAt(objectIndex);
auto factory = getFactoryOrNullptr(psStruct);
ASSERT_NOT_NULLPTR_OR_RETURN(, factory);
if (factory->psAssemblyPoint == nullptr)
{
factoryNumberLabel->setString("");
return;
}
factoryNumberLabel->setString(WzString::fromUtf8(astringf("%u", factory->psAssemblyPoint->factoryInc + 1)));
if (psStruct->productToGroup != UBYTE_MAX)
{
factoryAssignGroupLabel->setString(WzString::fromUtf8(astringf("%u", psStruct->productToGroup)));
}
else
{
factoryAssignGroupLabel->setString("");
}
}

std::string getTip() override
Expand All @@ -287,6 +299,7 @@ class ManufactureObjectButton : public ObjectButton
private:
std::shared_ptr<ManufactureController> controller;
std::shared_ptr<W_LABEL> factoryNumberLabel;
std::shared_ptr<W_LABEL> factoryAssignGroupLabel;
};

class ManufactureStatsButton: public StatsButton
Expand Down

0 comments on commit a9f5574

Please sign in to comment.