- bugfix for cancel icon displaying when unit has only the 'stop' command active

This commit is contained in:
Mark Vejvoda 2010-10-28 18:31:12 +00:00
parent df3f56a451
commit 5cf0313c5a
5 changed files with 51 additions and 20 deletions

View File

@ -672,7 +672,9 @@ void Gui::computeInfoString(int posDisplay){
} }
} }
void Gui::computeDisplay(){ void Gui::computeDisplay() {
//printf("Start ===> computeDisplay()\n");
//init //init
display.clear(); display.clear();
@ -693,35 +695,49 @@ void Gui::computeDisplay(){
// ================ PART 2 ================ // ================ PART 2 ================
if(selectingPos || selectingMeetingPoint){ if(selectingPos || selectingMeetingPoint) {
//printf("selectingPos || selectingMeetingPoint\n");
display.setDownSelectedPos(activePos); display.setDownSelectedPos(activePos);
} }
if(selection.isComandable()){ if(selection.isComandable()) {
if(!selectingBuilding){ //printf("selection.isComandable()\n");
if(selectingBuilding == false) {
//cancel button //cancel button
const Unit *u= selection.getFrontUnit(); const Unit *u= selection.getFrontUnit();
const UnitType *ut= u->getType(); const UnitType *ut= u->getType();
if(selection.isCancelable()){ if(selection.isCancelable()) {
//printf("selection.isCancelable() commandcount = %d\n",selection.getUnit(0)->getCommandSize());
if(selection.getUnit(0)->getCommandSize() > 0) {
//printf("Current Command [%s]\n",selection.getUnit(0)->getCurrCommand()->toString().c_str());
}
display.setDownImage(cancelPos, ut->getCancelImage()); display.setDownImage(cancelPos, ut->getCancelImage());
display.setDownLighted(cancelPos, true); display.setDownLighted(cancelPos, true);
} }
//meeting point //meeting point
if(selection.isMeetable()){ if(selection.isMeetable()) {
//printf("selection.isMeetable()\n");
display.setDownImage(meetingPointPos, ut->getMeetingPointImage()); display.setDownImage(meetingPointPos, ut->getMeetingPointImage());
display.setDownLighted(meetingPointPos, true); display.setDownLighted(meetingPointPos, true);
} }
if(selection.isUniform()){ if(selection.isUniform()) {
//printf("selection.isUniform()\n");
//uniform selection //uniform selection
if(u->isBuilt()){ if(u->isBuilt()) {
//printf("u->isBuilt()\n");
int morphPos= 8; int morphPos= 8;
for(int i=0; i<ut->getCommandTypeCount(); ++i){ for(int i=0; i<ut->getCommandTypeCount(); ++i) {
int displayPos= i; int displayPos= i;
const CommandType *ct= ut->getCommandType(i); const CommandType *ct= ut->getCommandType(i);
if(ct->getClass()==ccMorph){ if(ct->getClass()==ccMorph) {
displayPos= morphPos++; displayPos= morphPos++;
} }
display.setDownImage(displayPos, ct->getImage()); display.setDownImage(displayPos, ct->getImage());
@ -730,13 +746,14 @@ void Gui::computeDisplay(){
} }
} }
} }
else {
//printf("selection.isUniform() == FALSE\n");
else{
//non uniform selection //non uniform selection
int lastCommand= 0; int lastCommand= 0;
for(int i=0; i<ccCount; ++i){ for(int i=0; i<ccCount; ++i) {
CommandClass cc= static_cast<CommandClass>(i); CommandClass cc= static_cast<CommandClass>(i);
if(isSharedCommandClass(cc) && cc!=ccBuild){ if(isSharedCommandClass(cc) && cc!=ccBuild) {
display.setDownLighted(lastCommand, true); display.setDownLighted(lastCommand, true);
display.setDownImage(lastCommand, ut->getFirstCtOfClass(cc)->getImage()); display.setDownImage(lastCommand, ut->getFirstCtOfClass(cc)->getImage());
display.setCommandClass(lastCommand, cc); display.setCommandClass(lastCommand, cc);
@ -745,7 +762,7 @@ void Gui::computeDisplay(){
} }
} }
} }
else{ else {
//selecting building //selecting building
const Unit *unit= selection.getFrontUnit(); const Unit *unit= selection.getFrontUnit();

View File

@ -141,8 +141,8 @@ bool Selection::isComandable() const{
bool Selection::isCancelable() const{ bool Selection::isCancelable() const{
return return
selectedUnits.size()>1 || selectedUnits.size() > 1 ||
(selectedUnits.size()==1 && selectedUnits[0]->anyCommand()); (selectedUnits.size() == 1 && selectedUnits[0]->anyCommand(true));
} }
bool Selection::isMeetable() const{ bool Selection::isMeetable() const{

View File

@ -103,7 +103,7 @@ std::string Command::toString() const {
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__, __LINE__); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__, __LINE__);
result = ", stateType = " + intToStr(stateType) + ", stateValue = " + intToStr(stateValue); result += ", stateType = " + intToStr(stateType) + ", stateValue = " + intToStr(stateValue);
return result; return result;
} }

View File

@ -673,8 +673,22 @@ Vec3f Unit::getCurrVectorFlat() const{
// =================== Command list related =================== // =================== Command list related ===================
//any command //any command
bool Unit::anyCommand() const{ bool Unit::anyCommand(bool validateCommandtype) const {
return !commands.empty(); bool result = false;
if(validateCommandtype == false) {
result = (commands.empty() == false);
}
else {
for(Commands::const_iterator it= commands.begin(); it != commands.end(); ++it) {
const CommandType *ct = (*it)->getCommandType();
if(ct != NULL && ct->getClass() != ccStop) {
result = true;
break;
}
}
}
return result;
} }
//return current command, assert that there is always one command //return current command, assert that there is always one command

View File

@ -392,7 +392,7 @@ public:
Vec3f getCurrVectorFlat() const; Vec3f getCurrVectorFlat() const;
//command related //command related
bool anyCommand() const; bool anyCommand(bool validateCommandtype=false) const;
Command *getCurrCommand() const; Command *getCurrCommand() const;
void replaceCurrCommand(Command *cmd); void replaceCurrCommand(Command *cmd);
int getCountOfProducedUnits(const UnitType *ut) const; int getCountOfProducedUnits(const UnitType *ut) const;