Hi all,
I've done a lot of SDK modding (I'm far more comfortable with C++ than I am with application-level python code). I've recently made an SDK change that seems to work, but the interface buttons don't seem to have gotten the message.
I'm trying to modify the way corporation interact with the Mercantilism Civc (specifically, the part that sets the player so CvPlayer::isNoForeignCorporations() returns True). I'd like it so that players running Mercantilism can still have corporations spread to them by teammates (but still prohibit foreign corporations. I've modified CvPlayer::isActiveCorporation to make that work.
Original code:
To change the behavior, I first set a define in GlobalDefines.xml, FOUND_CORPORATION_CITY_TEAM, which controls it (set to 1 for the new behavior and to 0 for the original behavior). The new function uses CvTeam::hasHeadquarters() instead of CvPlayer::hasHeadquearters():
This works, partly. Team corporations no longer get disabled when you switch to Mercantilism, while Foreign corporations still do. If your team has an AI on it, it can spread corporations that it has the headquarters for to you. And your executives will spread team corporations if you set them on automatic spread. And on the city screen, it disables any benefit from true foreign corporations (hammers/food/culture) as well as disabling the ability to build their executives, while allowing team corporations to work normally.
My problem is the button for the executive is still being enabled/disabled based on the old logic, and I haven't the slightest idea where that is. If you hover over the button, you no longer get the message that you can't spread in the other civ's lands, but it remains dimmed out and unclickable.
Commenting out these lines in CvInterfaceManager.py causes the button to stop dimming out, which lead me to look into canHandleAction(), but I can't make heads or tails of how it works.
Can anyone out there who has a better understanding of how the Python and SDK code are intertwined help me out, or at least give me a suggestion as to where to look? I've been stuck on this for a couple of days. I can usually modify the standalone Python but this seens messy.
I've done a lot of SDK modding (I'm far more comfortable with C++ than I am with application-level python code). I've recently made an SDK change that seems to work, but the interface buttons don't seem to have gotten the message.
I'm trying to modify the way corporation interact with the Mercantilism Civc (specifically, the part that sets the player so CvPlayer::isNoForeignCorporations() returns True). I'd like it so that players running Mercantilism can still have corporations spread to them by teammates (but still prohibit foreign corporations. I've modified CvPlayer::isActiveCorporation to make that work.
Original code:
Code:
bool CvPlayer::isActiveCorporation(CorporationTypes eIndex) const
{
if (isNoCorporations())
{
return false;
}
if (isNoForeignCorporations() && !hasHeadquarters(eIndex))
{
return false;
}
return true;
}
To change the behavior, I first set a define in GlobalDefines.xml, FOUND_CORPORATION_CITY_TEAM, which controls it (set to 1 for the new behavior and to 0 for the original behavior). The new function uses CvTeam::hasHeadquarters() instead of CvPlayer::hasHeadquearters():
Code:
bool CvPlayer::isActiveCorporation(CorporationTypes eIndex) const
{
if (isNoCorporations())
{
return false;
}
if (isNoForeignCorporations())
{
if (GC.getDefineINT("FOUND_CORPORATION_CITY_TEAM") > 0)
{
if (!GET_TEAM(getTeam()).hasHeadquarters(eIndex))
{
return false;
}
}
else
{
if (!hasHeadquarters(eIndex))
{
return false;
}
}
}
return true;
}
This works, partly. Team corporations no longer get disabled when you switch to Mercantilism, while Foreign corporations still do. If your team has an AI on it, it can spread corporations that it has the headquarters for to you. And your executives will spread team corporations if you set them on automatic spread. And on the city screen, it disables any benefit from true foreign corporations (hammers/food/culture) as well as disabling the ability to build their executives, while allowing team corporations to work normally.
My problem is the button for the executive is still being enabled/disabled based on the old logic, and I haven't the slightest idea where that is. If you hover over the button, you no longer get the message that you can't spread in the other civ's lands, but it remains dimmed out and unclickable.
Commenting out these lines in CvInterfaceManager.py causes the button to stop dimming out, which lead me to look into canHandleAction(), but I can't make heads or tails of how it works.
Code:
if ( not CyInterface().canHandleAction(i, False) ):
screen.disableMultiListButton( "BottomButtonContainer", 0, iCount, gc.getActionInfo(i).getButton() )
Can anyone out there who has a better understanding of how the Python and SDK code are intertwined help me out, or at least give me a suggestion as to where to look? I've been stuck on this for a couple of days. I can usually modify the standalone Python but this seens messy.