small bugfix for handling morph commands in the UI (was not properly handling commandclass). Added validation to tell modders that we have a max if 6 morphs that can display in the UI

This commit is contained in:
Mark Vejvoda 2011-10-21 16:04:21 +00:00
parent af2e2a8930
commit c6d4e898a0
3 changed files with 53 additions and 20 deletions

View File

@ -766,6 +766,8 @@ void Gui::computeDisplay(){
display.setDownSelectedPos(activePos);
}
//printf("computeDisplay selection.isCommandable() = %d\n",selection.isCommandable());
if(selection.isCommandable()) {
//printf("selection.isComandable()\n");
@ -792,6 +794,9 @@ void Gui::computeDisplay(){
display.setDownLighted(meetingPointPos, true);
}
//printf("computeDisplay selection.isUniform() = %d\n",selection.isUniform());
if(selection.isUniform()) {
//printf("selection.isUniform()\n");
@ -806,8 +811,12 @@ void Gui::computeDisplay(){
if(ct->getClass() == ccMorph) {
displayPos= morphPos++;
}
//printf("computeDisplay i = %d displayPos = %d morphPos = %d ct->getClass() = %d [%s]\n",i,displayPos,morphPos,ct->getClass(),ct->getName().c_str());
display.setDownImage(displayPos, ct->getImage());
display.setCommandType(displayPos, ct);
display.setCommandClass(displayPos, ct->getClass());
display.setDownLighted(displayPos, u->getFaction()->reqsOk(ct));
}
}
@ -819,6 +828,9 @@ void Gui::computeDisplay(){
int lastCommand= 0;
for(int i= 0; i < ccCount; ++i){
CommandClass cc= static_cast<CommandClass> (i);
//printf("computeDisplay i = %d cc = %d isshared = %d lastCommand = %d\n",i,cc,isSharedCommandClass(cc),lastCommand);
if(isSharedCommandClass(cc) && cc != ccBuild){
display.setDownLighted(lastCommand, true);
display.setDownImage(lastCommand, ut->getFirstCtOfClass(cc)->getImage());
@ -857,16 +869,20 @@ void Gui::computeDisplay(){
int Gui::computePosDisplay(int x, int y){
int posDisplay= display.computeDownIndex(x, y);
//printf("computePosDisplay x = %d y = %d posDisplay = %d Display::downCellCount = %d cc = %d ct = %p\n",x,y,posDisplay,Display::downCellCount,display.getCommandClass(posDisplay),display.getCommandType(posDisplay));
if(posDisplay < 0 || posDisplay >= Display::downCellCount) {
posDisplay= invalidPos;
//printf("In [%s:%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
}
else if(selection.isCommandable()) {
if(posDisplay != cancelPos) {
if(posDisplay != meetingPointPos) {
if(!selectingBuilding){
if(selectingBuilding == false) {
//standard selection
if(display.getCommandClass(posDisplay) == ccNull && display.getCommandType(posDisplay) == NULL) {
posDisplay= invalidPos;
//printf("In [%s:%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
}
}
else {
@ -875,6 +891,7 @@ int Gui::computePosDisplay(int x, int y){
const BuildCommandType *bct= static_cast<const BuildCommandType*>(activeCommandType);
if(posDisplay >= bct->getBuildingCount()) {
posDisplay= invalidPos;
//printf("In [%s:%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
}
}
}
@ -883,20 +900,25 @@ int Gui::computePosDisplay(int x, int y){
//check meeting point
if(!selection.isMeetable()) {
posDisplay= invalidPos;
//printf("In [%s:%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
}
}
}
else {
//check cancel button
if(!selection.isCancelable()){
if(selection.isCancelable() == false) {
posDisplay= invalidPos;
//printf("In [%s:%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
}
}
}
else {
posDisplay= invalidPos;
//printf("In [%s:%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
}
//printf("computePosDisplay returning = %d\n",posDisplay);
return posDisplay;
}

View File

@ -97,9 +97,11 @@ class Gui : public ObjectStateInterface {
public:
static const int maxSelBuff= 128*5;
static const int upgradeDisplayIndex= 8;
static const int cancelPos= 15;
static const int meetingPointPos= 14;
static const int cancelPos= 15;
static const int imageCount= 16;
static const int invalidPos= -1;
static const int doubleClickSelectionRadius= 20;

View File

@ -266,6 +266,7 @@ std::vector<std::string> FactionType::validateFactionType() {
}
}
int morphCommandCount = 0;
for(int j = 0; j < unitType.getCommandTypeCount(); ++j) {
const CommandType *cmdType = unitType.getCommandType(j);
if(cmdType != NULL) {
@ -362,6 +363,7 @@ std::vector<std::string> FactionType::validateFactionType() {
if(cmdType->getClass() == ccMorph) {
const MorphCommandType *morph = dynamic_cast<const MorphCommandType *>(cmdType);
if(morph != NULL) {
morphCommandCount++;
const UnitType *morphUnit = morph->getMorphUnit();
// Now lets find the unit that we should be able to morph
@ -385,6 +387,13 @@ std::vector<std::string> FactionType::validateFactionType() {
}
}
const int maxMorphsAllowed = 6;
if(morphCommandCount > maxMorphsAllowed) {
char szBuf[4096]="";
sprintf(szBuf,"The Unit [%s] in Faction [%s] has more than %d morph commands which is too many to display in the UI!",unitType.getName().c_str(),this->getName().c_str(),maxMorphsAllowed);
results.push_back(szBuf);
}
// Check every unit's unit requirements to validate that for every unit-requirements
// we have the units required in the faction.
for(int j = 0; j < unitType.getUnitReqCount(); ++j) {