mirror of
https://github.com/glest/glest-source.git
synced 2025-08-14 20:34:01 +02:00
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:
@@ -766,6 +766,8 @@ void Gui::computeDisplay(){
|
|||||||
display.setDownSelectedPos(activePos);
|
display.setDownSelectedPos(activePos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//printf("computeDisplay selection.isCommandable() = %d\n",selection.isCommandable());
|
||||||
|
|
||||||
if(selection.isCommandable()) {
|
if(selection.isCommandable()) {
|
||||||
//printf("selection.isComandable()\n");
|
//printf("selection.isComandable()\n");
|
||||||
|
|
||||||
@@ -792,6 +794,9 @@ void Gui::computeDisplay(){
|
|||||||
display.setDownLighted(meetingPointPos, true);
|
display.setDownLighted(meetingPointPos, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//printf("computeDisplay selection.isUniform() = %d\n",selection.isUniform());
|
||||||
|
|
||||||
if(selection.isUniform()) {
|
if(selection.isUniform()) {
|
||||||
//printf("selection.isUniform()\n");
|
//printf("selection.isUniform()\n");
|
||||||
|
|
||||||
@@ -806,8 +811,12 @@ void Gui::computeDisplay(){
|
|||||||
if(ct->getClass() == ccMorph) {
|
if(ct->getClass() == ccMorph) {
|
||||||
displayPos= morphPos++;
|
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.setDownImage(displayPos, ct->getImage());
|
||||||
display.setCommandType(displayPos, ct);
|
display.setCommandType(displayPos, ct);
|
||||||
|
display.setCommandClass(displayPos, ct->getClass());
|
||||||
display.setDownLighted(displayPos, u->getFaction()->reqsOk(ct));
|
display.setDownLighted(displayPos, u->getFaction()->reqsOk(ct));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -819,6 +828,9 @@ void Gui::computeDisplay(){
|
|||||||
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);
|
||||||
|
|
||||||
|
//printf("computeDisplay i = %d cc = %d isshared = %d lastCommand = %d\n",i,cc,isSharedCommandClass(cc),lastCommand);
|
||||||
|
|
||||||
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());
|
||||||
@@ -857,16 +869,20 @@ void Gui::computeDisplay(){
|
|||||||
int Gui::computePosDisplay(int x, int y){
|
int Gui::computePosDisplay(int x, int y){
|
||||||
int posDisplay= display.computeDownIndex(x, 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) {
|
if(posDisplay < 0 || posDisplay >= Display::downCellCount) {
|
||||||
posDisplay= invalidPos;
|
posDisplay= invalidPos;
|
||||||
|
//printf("In [%s:%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
else if(selection.isCommandable()) {
|
else if(selection.isCommandable()) {
|
||||||
if(posDisplay != cancelPos) {
|
if(posDisplay != cancelPos) {
|
||||||
if(posDisplay != meetingPointPos) {
|
if(posDisplay != meetingPointPos) {
|
||||||
if(!selectingBuilding){
|
if(selectingBuilding == false) {
|
||||||
//standard selection
|
//standard selection
|
||||||
if(display.getCommandClass(posDisplay) == ccNull && display.getCommandType(posDisplay) == NULL) {
|
if(display.getCommandClass(posDisplay) == ccNull && display.getCommandType(posDisplay) == NULL) {
|
||||||
posDisplay= invalidPos;
|
posDisplay= invalidPos;
|
||||||
|
//printf("In [%s:%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -875,6 +891,7 @@ int Gui::computePosDisplay(int x, int y){
|
|||||||
const BuildCommandType *bct= static_cast<const BuildCommandType*>(activeCommandType);
|
const BuildCommandType *bct= static_cast<const BuildCommandType*>(activeCommandType);
|
||||||
if(posDisplay >= bct->getBuildingCount()) {
|
if(posDisplay >= bct->getBuildingCount()) {
|
||||||
posDisplay= invalidPos;
|
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
|
//check meeting point
|
||||||
if(!selection.isMeetable()) {
|
if(!selection.isMeetable()) {
|
||||||
posDisplay= invalidPos;
|
posDisplay= invalidPos;
|
||||||
|
//printf("In [%s:%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//check cancel button
|
//check cancel button
|
||||||
if(!selection.isCancelable()){
|
if(selection.isCancelable() == false) {
|
||||||
posDisplay= invalidPos;
|
posDisplay= invalidPos;
|
||||||
|
//printf("In [%s:%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
posDisplay= invalidPos;
|
posDisplay= invalidPos;
|
||||||
|
//printf("In [%s:%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//printf("computePosDisplay returning = %d\n",posDisplay);
|
||||||
|
|
||||||
return posDisplay;
|
return posDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -97,9 +97,11 @@ class Gui : public ObjectStateInterface {
|
|||||||
public:
|
public:
|
||||||
static const int maxSelBuff= 128*5;
|
static const int maxSelBuff= 128*5;
|
||||||
static const int upgradeDisplayIndex= 8;
|
static const int upgradeDisplayIndex= 8;
|
||||||
static const int cancelPos= 15;
|
|
||||||
static const int meetingPointPos= 14;
|
static const int meetingPointPos= 14;
|
||||||
|
static const int cancelPos= 15;
|
||||||
static const int imageCount= 16;
|
static const int imageCount= 16;
|
||||||
|
|
||||||
static const int invalidPos= -1;
|
static const int invalidPos= -1;
|
||||||
static const int doubleClickSelectionRadius= 20;
|
static const int doubleClickSelectionRadius= 20;
|
||||||
|
|
||||||
|
@@ -266,6 +266,7 @@ std::vector<std::string> FactionType::validateFactionType() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int morphCommandCount = 0;
|
||||||
for(int j = 0; j < unitType.getCommandTypeCount(); ++j) {
|
for(int j = 0; j < unitType.getCommandTypeCount(); ++j) {
|
||||||
const CommandType *cmdType = unitType.getCommandType(j);
|
const CommandType *cmdType = unitType.getCommandType(j);
|
||||||
if(cmdType != NULL) {
|
if(cmdType != NULL) {
|
||||||
@@ -362,6 +363,7 @@ std::vector<std::string> FactionType::validateFactionType() {
|
|||||||
if(cmdType->getClass() == ccMorph) {
|
if(cmdType->getClass() == ccMorph) {
|
||||||
const MorphCommandType *morph = dynamic_cast<const MorphCommandType *>(cmdType);
|
const MorphCommandType *morph = dynamic_cast<const MorphCommandType *>(cmdType);
|
||||||
if(morph != NULL) {
|
if(morph != NULL) {
|
||||||
|
morphCommandCount++;
|
||||||
const UnitType *morphUnit = morph->getMorphUnit();
|
const UnitType *morphUnit = morph->getMorphUnit();
|
||||||
|
|
||||||
// Now lets find the unit that we should be able to morph
|
// 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
|
// Check every unit's unit requirements to validate that for every unit-requirements
|
||||||
// we have the units required in the faction.
|
// we have the units required in the faction.
|
||||||
for(int j = 0; j < unitType.getUnitReqCount(); ++j) {
|
for(int j = 0; j < unitType.getUnitReqCount(); ++j) {
|
||||||
|
Reference in New Issue
Block a user