Skip to content

Commit

Permalink
Merge pull request #1586 from OutpostUniverse/refactorFactoryProduction
Browse files Browse the repository at this point in the history
Refactor `FactoryProduction`
  • Loading branch information
DanRStevens authored Feb 16, 2025
2 parents 8a5ac8e + 6033866 commit 8c8de9d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
25 changes: 16 additions & 9 deletions appOPHD/UI/FactoryProduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "StringTable.h"

#include "../Constants/UiConstants.h"
#include "../Resources.h"
#include "../ProductCatalogue.h"
#include "../Constants/Strings.h"
Expand All @@ -15,32 +16,38 @@ using namespace NAS2D;


FactoryProduction::FactoryProduction() :
Window{constants::WindowFactoryProduction}
Window{constants::WindowFactoryProduction},
mFactory{nullptr},
mProduct{ProductType::PRODUCT_NONE},
mProductGrid{"ui/factory.png", 32, constants::MarginTight},
btnOkay{"Okay", {this, &FactoryProduction::onOkay}},
btnCancel{"Cancel", {this, &FactoryProduction::onCancel}},
btnClearSelection{"Clear Selection", {this, &FactoryProduction::onClearSelection}},
btnApply{"Apply", {this, &FactoryProduction::onApply}},
chkIdle{"Idle", {this, &FactoryProduction::onCheckBoxIdleChange}}
{
size({320, 162});

// Set up GUI Layout
add(mProductGrid, {constants::Margin, 25});
mProductGrid.size({140, 110});
mProductGrid.showTooltip(true);
mProductGrid.hide();
mProductGrid.selectionChanged().connect({this, &FactoryProduction::onProductSelectionChange});
add(mProductGrid, {constants::Margin, 25});

add(btnOkay, {233, 138});
btnOkay.size({40, 20});
add(btnOkay, {233, 138});

add(btnCancel, {276, 138});
btnCancel.size({40, 20});
add(btnCancel, {276, 138});

add(btnClearSelection, {5, 138});
btnClearSelection.size({mProductGrid.size().x, 20});
add(btnClearSelection, {5, 138});

add(btnApply, {mProductGrid.size().x + 12, btnClearSelection.positionY()});
btnApply.size({40, 20});
add(btnApply, {mProductGrid.size().x + 12, btnClearSelection.positionY()});

add(chkIdle, {mProductGrid.size().x + 12, 115});
chkIdle.size({50, 20});
chkIdle.click().connect({this, &FactoryProduction::onCheckBoxIdleChange});
add(chkIdle, {mProductGrid.size().x + 12, 115});
}


Expand Down
20 changes: 10 additions & 10 deletions appOPHD/UI/FactoryProduction.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "IconGrid.h"

#include "../Constants/UiConstants.h"
#include "../ProductionCost.h"

#include <libOPHD/EnumProductType.h>
Expand Down Expand Up @@ -30,7 +29,7 @@ class FactoryProduction : public Window

void update() override;

private:
protected:
void onOkay();
void onCancel();
void onClearSelection();
Expand All @@ -41,17 +40,18 @@ class FactoryProduction : public Window

void onProductSelectionChange(const IconGrid::Item*);

Factory* mFactory = nullptr;
private:
Factory* mFactory;

ProductType mProduct = ProductType::PRODUCT_NONE;
ProductType mProduct;
ProductionCost mProductCost;

IconGrid mProductGrid{"ui/factory.png", 32, constants::MarginTight};
IconGrid mProductGrid;

Button btnOkay{"Okay", {this, &FactoryProduction::onOkay}};
Button btnCancel{"Cancel", {this, &FactoryProduction::onCancel}};
Button btnClearSelection{"Clear Selection", {this, &FactoryProduction::onClearSelection}};
Button btnApply{"Apply", {this, &FactoryProduction::onApply}};
Button btnOkay;
Button btnCancel;
Button btnClearSelection;
Button btnApply;

CheckBox chkIdle{"Idle"};
CheckBox chkIdle;
};

0 comments on commit 8c8de9d

Please sign in to comment.