refactor: empty positions

This commit is contained in:
pavanvo 2022-08-30 14:25:06 +04:00
parent a0c8383be0
commit 1c1dd0a393
No known key found for this signature in database
GPG Key ID: 34C1C36681B4AD84
1 changed files with 10 additions and 11 deletions

View File

@ -939,6 +939,7 @@ void Gui::computeDisplay(){
//printf("selection.isComandable()\n");
if(selectingBuilding == false){
vector<int> emptyPosIndexes = {};
//cancel button
const Unit *u= selection.getFrontUnit();
@ -974,9 +975,7 @@ void Gui::computeDisplay(){
int displayPos= i;
const CommandType *ct= ut->getCommandTypeSorted(i);
if(ct == NULL) {
display.setDownImage(displayPos, ut->getCancelImage());
display.setCommandType(displayPos, ct);
display.setDownLighted(displayPos,false);
emptyPosIndexes.push_back(displayPos);
continue;
}
if(ct->getClass() == ccMorph) {
@ -1030,11 +1029,8 @@ void Gui::computeDisplay(){
int basicPos = CommandHelper::getRowPos(crBasics);
// First row is always empty
for (int i = 0; i < 5; i++) {
display.setDownImage(i, ut->getCancelImage());
display.setCommandType(i, NULL);
display.setDownLighted(i,false);
}
for (int i = 0; i < 5; i++)
emptyPosIndexes.push_back(i);
// only basics can be shared
for(auto &&cc : CommandHelper::getBasicsCC()){
@ -1058,12 +1054,15 @@ void Gui::computeDisplay(){
}
display.setCommandClass(basicPos + ccPos, cc);
} else {
display.setDownImage(basicPos+ccPos, ut->getCancelImage());
display.setCommandType(basicPos+ccPos, NULL);
display.setDownLighted(basicPos+ccPos,false);
emptyPosIndexes.push_back(basicPos+ccPos);
}
}
}
for (int i : emptyPosIndexes ) {
display.setDownImage(i, ut->getCancelImage());
display.setCommandType(i, NULL);
display.setDownLighted(i,false);
}
}
else if (activeCommandType != NULL && activeCommandType->getClass() == ccBuild) {
const Unit *u = selection.getFrontUnit();