Skip to content

Commit

Permalink
Merge pull request #1616 from OutpostUniverse/refactorFactoryReportLa…
Browse files Browse the repository at this point in the history
…youtCode

Refactor `FactoryReport` layout code
  • Loading branch information
DanRStevens authored Feb 20, 2025
2 parents 9985267 + 7dbc776 commit 8ec9961
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions appOPHD/UI/Reports/FactoryReport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ using namespace NAS2D;

namespace
{
constexpr auto viewFilterButtonSize = NAS2D::Vector{75, 20};
constexpr auto mainButtonSize = NAS2D::Vector{140, 30};

bool productTypeInRange(ProductType productType)
{
return ProductType::PRODUCT_NONE < productType && productType < ProductType::PRODUCT_COUNT;
Expand Down Expand Up @@ -58,58 +61,48 @@ FactoryReport::FactoryReport() :
factorySeed{imageCache.load("ui/interface/factory_seed.png")},
factoryAboveGround{imageCache.load("ui/interface/factory_ag.png")},
factoryUnderGround{imageCache.load("ui/interface/factory_ug.png")},
btnShowAll{"All", {this, &FactoryReport::onShowAll}},
btnShowSurface{"Surface", {this, &FactoryReport::onShowSurface}},
btnShowUnderground{"Underground", {this, &FactoryReport::onShowUnderground}},
btnShowActive{"Active", {this, &FactoryReport::onShowActive}},
btnShowIdle{"Idle", {this, &FactoryReport::onShowIdle}},
btnShowDisabled{"Disabled", {this, &FactoryReport::onShowDisabled}},
btnIdle{"Idle", {this, &FactoryReport::onIdle}},
btnClearProduction{"Clear Production", {this, &FactoryReport::onClearProduction}},
btnTakeMeThere{constants::TakeMeThere, {this, &FactoryReport::onTakeMeThere}},
btnApply{"Apply", {this, &FactoryReport::onApply}}
btnShowAll{"All", viewFilterButtonSize, {this, &FactoryReport::onShowAll}},
btnShowSurface{"Surface", viewFilterButtonSize, {this, &FactoryReport::onShowSurface}},
btnShowUnderground{"Underground", viewFilterButtonSize, {this, &FactoryReport::onShowUnderground}},
btnShowActive{"Active", viewFilterButtonSize, {this, &FactoryReport::onShowActive}},
btnShowIdle{"Idle", viewFilterButtonSize, {this, &FactoryReport::onShowIdle}},
btnShowDisabled{"Disabled", viewFilterButtonSize, {this, &FactoryReport::onShowDisabled}},
btnIdle{"Idle", mainButtonSize, {this, &FactoryReport::onIdle}},
btnClearProduction{"Clear Production", mainButtonSize, {this, &FactoryReport::onClearProduction}},
btnTakeMeThere{constants::TakeMeThere, mainButtonSize, {this, &FactoryReport::onTakeMeThere}},
btnApply{"Apply", mainButtonSize, {this, &FactoryReport::onApply}}
{
add(lstFactoryList, {10, 63});
lstFactoryList.selectionChanged().connect({this, &FactoryReport::onListSelectionChange});

add(btnShowAll, {10, 10});
btnShowAll.size({75, 20});
btnShowAll.type(Button::Type::Toggle);
btnShowAll.toggle(true);

add(btnShowSurface, {87, 10});
btnShowSurface.size({75, 20});
btnShowSurface.type(Button::Type::Toggle);

add(btnShowUnderground, {164, 10});
btnShowUnderground.size({75, 20});
btnShowUnderground.type(Button::Type::Toggle);

add(btnShowActive, {10, 33});
btnShowActive.size({75, 20});
btnShowActive.type(Button::Type::Toggle);

add(btnShowIdle, {87, 33});
btnShowIdle.size({75, 20});
btnShowIdle.type(Button::Type::Toggle);

add(btnShowDisabled, {164, 33});
btnShowDisabled.size({75, 20});
btnShowDisabled.type(Button::Type::Toggle);

int position_x = Utility<Renderer>::get().size().x - 110;
add(btnIdle, {position_x, 35});
btnIdle.type(Button::Type::Toggle);
btnIdle.size({140, 30});

add(btnClearProduction, {position_x, 75});
btnClearProduction.size({140, 30});

add(btnTakeMeThere, {position_x, 115});
btnTakeMeThere.size({140, 30});

add(btnApply, {0, 0});
btnApply.size({140, 30});

add(cboFilterByProduct, {250, 33});
cboFilterByProduct.size({200, 20});
Expand Down

0 comments on commit 8ec9961

Please sign in to comment.