Weird python error with the flag/TeamAI.h

It looks like you need to add an entry for your new control to an XML file. If there's a CvControlInfo, there must be a matching XML item for it. You may also need a shortcut for it? And Action? I dunno.
 
It looks like you need to add an entry for your new control to an XML file. If there's a CvControlInfo, there must be a matching XML item for it. You may also need a shortcut for it? And Action? I dunno.

I can't find any xml to it. It's not mentioned in CvXMLLoadUtilitySet.cpp, here's all from CvInfos.cpp
Spoiler :
Code:
//======================================================================================================
//					CvControlInfo
//======================================================================================================

//------------------------------------------------------------------------------------------------------
//
//  FUNCTION:   CvControlInfo()
//
//  PURPOSE :   Default constructor
//
//------------------------------------------------------------------------------------------------------
CvControlInfo::CvControlInfo()
{
}

//------------------------------------------------------------------------------------------------------
//
//  FUNCTION:   ~CvControlInfo()
//
//  PURPOSE :   Default destructor
//
//------------------------------------------------------------------------------------------------------
CvControlInfo::~CvControlInfo()
{
}

bool CvControlInfo::read(CvXMLLoadUtility* pXML)
{
	if (!CvHotkeyInfo::read(pXML))
	{
		return false;
	}

	return true;
}
What do you mean with shortcut and action?
 
Looks like CvControlInfo is the shortcut (hotkey), and action is for units so forget that. All I know is that you added a new control and suddenly it's crashing while looking for a CvControlInfo that doesn't exist. That to me sounds like you need to add a control.

Add this to the bottom of XML/Units/CIV4ControlInfos.xml (yes, Units :crazyeye:) so it is in the same relative position as your new constant:

Code:
		<ControlInfo>
			<Type>CONTROL_IDEOLOGY_SCREEN</Type>
			<Description>TXT_KEY_IDEOLOGY_ADVISOR_TITLE</Description>
			<Help/>
			<HotKey>KB_F7</HotKey>
			<bAltDown>0</bAltDown>
			<bShiftDown>0</bShiftDown>
			<bCtrlDown>1</bCtrlDown>
			<iHotKeyPriority>0</iHotKeyPriority>
			<HotKeyAlt/>
			<bAltDownAlt>0</bAltDownAlt>
			<bShiftDownAlt>0</bShiftDownAlt>
			<bCtrlDownAlt>0</bCtrlDownAlt>
			<iHotKeyPriorityAlt>0</iHotKeyPriorityAlt>
		</ControlInfo>

This will assign CTRL + F7 to your Ideology Advisor. Make sure the type matches your constant (it doesn't have to but it should) and you add the <Text> entry for the description that is shown in the hover text I think.
 
The ideology advisor button appears to be bigger problem than I expected. I can't find a way to add an image to it. Does anyone know how to do it?
:bump:


Another question. I started making the ideology advisor, but why would this line cause error
Spoiler :
Code:
	def drawIdeologyInfo(self, iIdeology):

		screen = self.getScreen()
		if (iIdeology == gc.getNumIdeologyInfos()):
			iLinkIdeology = -1
		else:
			iLinkIdeology = iIdeology

		szArea = self.AREA_ID
		screen.addPanel(self.AREA_ID, "", "", True, True, self.X_INFO_AREA, self.Y_INFO_AREA, self.W_IDEOLOGY_AREA, self.H_INFO_AREA, PanelStyles.PANEL_STYLE_MAIN)

		[COLOR="Red"]szHelpText = CyGameTextMgr().parseIdeologyInfo(iIdeology, False)[/COLOR]

		szHelpAreaID = self.HELP_AREA_NAME
		screen.addMultilineText(szHelpAreaID, szHelpText, self.X_INFO_AREA, self.Y_INFO_AREA, self.W_IDEOLOGY_AREA, self.H_INFO_AREA, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
...
Here's the error
Spoiler :
Code:
ERR: Python function showIdeologyScreen failed, module CvScreensInterface
Traceback (most recent call last):
  File "CvScreensInterface", line 97, in showIdeologyScreen
  File "CvIdeologyScreen", line 108, in interfaceScreen
  File "CvIdeologyScreen", line 161, in drawIdeologyInfo
RuntimeError
: 
unidentifiable C++ exception
 
How to set the button's image depends on how you draw the button. If you are using setStyle like the other advisor buttons, you need to define a new style in your mod's theme (copy all of the Civ4 theme files first I think).

What's the code for that CvGameTextMgr function? I can't possibly know why it's failing otherwise. My guess is that you're passing in an invalid value for iIdeology.
 
How to set the button's image depends on how you draw the button. If you are using setStyle like the other advisor buttons, you need to define a new style in your mod's theme (copy all of the Civ4 theme files first I think).
Do you mean all files in Beyond the Sword/Resource/Themes/Civ4?

What's the code for that CvGameTextMgr function? I can't possibly know why it's failing otherwise. My guess is that you're passing in an invalid value for iIdeology.
I'll try that.
 
Yes I think so. I didn't play with modding the theme much at all, but I believe that to do so in a mod you have to copy the entire Theme folder. There's probably a tutorial on it here.
 
Could you take a look at my CvIdeologyScreen? I tried, but couldn't find anything. I think I know where it crashes, but i don't know why. It throws in python error when I hover on any ideology button in the advisor. I tested that my parseIdeologyInfo() works by passing in this line
Code:
		szHelpText = CyGameTextMgr().parseIdeologyInfo(iIdeology, False)
0 instead of iIdeology and it worked. It seems when calling the function, I pass something wrong.
All in it is pretty much copy/paste from religion and civic screen.
 
Start by trying other values for iIdeology such as 1 or 2. You should be able to pass in 0 to N - 1 where N is the number of ideologies.
 
Start by trying other values for iIdeology such as 1 or 2. You should be able to pass in 0 to N - 1 where N is the number of ideologies.

Well, actually I've got only one ideology. And that's the number 0, because NO_IDEOLOGY is -1. But I would like to know what am i passing to the function.

EDIT: Doesn't BUG have somekind of logging system? I'll take a look at it.
 
I think I found something interesting. How does this code work? It's from BugUtil.py Assets/Python/BUG.
Code:
def logToFile(message):
	"""
	Writes the message to the debug log with a time stamp if that option is enabled.
	"""
	if logTime:
		message = time.asctime()[11:20] + message
	if isinstance(message, unicode):
		message = message.encode("iso8859")
	sys.stdout.write(message + "\n")
I think it seems to do what I want, or did I misunderstand it?
 
Wait, I think I discovered what's the cause of the error. Because I just copy/pasted the parts from different files, I screwed it up. Taking part of civic screen and compiling it with religion advisor isn't good thing.
Code:
		self.iIdeologySelected = gc.getPlayer(self.iActivePlayer).getIdeology()
		[COLOR="Red"]if (self.iIdeologySelected == -1):
			self.iIdeologySelected = gc.getNumIdeologyInfos()[/COLOR]
		self.iIdeologyExamined = self.iIdeologySelected
		self.iIdeologyOriginal = self.iIdeologySelected
I copyed this from religion advisor. It defines what ideologies am I looking, the ideology currently etc. Then I passed it to draw ideologyInfo like it was in religion advisor. But the value was used in creating the city infos, and I used it to print the ideology's info. :mad: And if the player doesn't have ideology (like at the start), iIdeologySelected is defined as n (where n is the number of ideologies) and I was trying to call
Code:
CyGameTextMgr().parseIdeologyInfo(iIdeology, False)
with ideology that didn't exist. :wallbash:
 
Now when the ideology advisor is actually working, I'm trying to let you convert ideologies with it.
But I don't understand how Civ converts to religion. As far as I understand this part, from religion advisor, adds the convert button.
Code:
		# Convert Button....
		iLink = 0
		if (gc.getPlayer(self.iActivePlayer).canChangeReligion()):
			iLink = 1
				
		if (not self.canConvert(iLinkReligion) or iLinkReligion == self.iReligionOriginal):			
			screen.setText(self.CONVERT_NAME, "Background", self.EXIT_TEXT, CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXIT, self.Y_EXIT, self.Z_TEXT, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, 1, 0)
			screen.hide(self.CANCEL_NAME)
			szAnarchyTime = CyGameTextMgr().setConvertHelp(self.iActivePlayer, iLinkReligion)
		else:
			[COLOR="Red"]screen.setText(self.CONVERT_NAME, "Background", self.CONVERT_TEXT, CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXIT, self.Y_EXIT, self.Z_TEXT, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_CONVERT, iLinkReligion, 1)[/COLOR]
			screen.show(self.CANCEL_NAME)
			szAnarchyTime = localText.getText("TXT_KEY_ANARCHY_TURNS", (gc.getPlayer(self.iActivePlayer).getReligionAnarchyLength(), ))
But what next? Does the WidgetTypes.WIDGET_CONVERT do it? I followed it in the DLL, and seems that it only sends somekind of message. :confused:
 
Don't use logToFile() directly. Instead use one of these functions:

  • debug(msg, [args])
  • info(msg, [args])
  • warn(msg, [args])
  • error(msg, [args])
The reason to use these is that they will each call logToFile() and/or logToScreen() depending on your logging level settings on the options screen's System tab. This way you can hide debug messages when not coding without having to remove them from the code. The args are optional replacement parameters in the message.

Code:
BugUtil.debug("Player %d is looking at ideology %d", ePlayer, iIdeology)

To your latest question, the convert() function will convert the player to that ideology, but to allow this to work in multiplayer games you need to tell all of the computers to call the convert() function. To do this you must create a new network message. Don't worry, it's actually pretty easy.

Start by following the code path that the religion button takes to the file CvMessageData.cpp I think. In there you will see a class for each network message. Copy and paste the entire definition for the religion message, and do the same in the matching header file. Replace Religion in your pasted code with Ideology.

The class's Execute() function is what does the actual work when the message is received. It needs to look up the player (their ID is one of the data values in the message) and call convert(eIdeology) on it (the ideology ID is the other data value in the message).

Then you need to create a new widget type just like the religion convert widget. Again copy the religion conversion code and change Religion to Ideology.
 
The next subject would be founding ideologies. Should I create a new network message again? How would I let you found ideology if you're first to discover the prereq tech? Could it be through CvTeam.cpp setHasTech?
 
Top Bottom