tech buttons are only clickable when they should be

This commit is contained in:
devZoGok
2024-03-30 09:48:54 +02:00
parent 541cc7ff25
commit 055ea5d97a
2 changed files with 6 additions and 0 deletions
+5
View File
@@ -39,6 +39,8 @@ namespace battleship{
}
void ResearchButton::onClick(){
if(!active) return;
vector<Unit*> labs = getUnits(unitId);
for(Unit *lab : labs)
@@ -54,6 +56,7 @@ namespace battleship{
float alpha = .6;
string uniform = "diffuseColor";
active = false;
if(!hasTech){
vector<int> techParents = Game::getSingleton()->getTechnology(techId).parents;
@@ -66,6 +69,7 @@ namespace battleship{
}
if(hasTechParents){
active = true;
overlay->setVisible(false);
vector<Unit*> labs = getUnits(unitId);
@@ -74,6 +78,7 @@ namespace battleship{
vector<int> researchQueue = ((ResearchStruct*)lab)->getQueue();
if(find(researchQueue.begin(), researchQueue.end(), techId) != researchQueue.end()){
active = false;
overlay->setVisible(true);
overlay->getMesh(0)->getMaterial()->setVec4Uniform(uniform, Vector4(0, 0, 1, alpha));
break;
+1
View File
@@ -12,6 +12,7 @@ namespace battleship{
void update();
private:
int techId;
bool active = false;
vb01::Node *overlay = nullptr;
};
}