Literal Links (The Blue Text in the Civilopedia)

Afforess

The White Wizard
Joined
Jul 31, 2007
Messages
12,239
Location
Austin, Texas
I have two questions about Literal Links...

1.) Can I make a literal link jump to an advisor screen instead of the civilopedia article?

2.) Literal Links seem to be tied to an object's description and not it's XML name. For instance, I have two placeholder civics with different XML entries, but the same description "NONE" (They are placeholders), but all literal links to NONE entries head to the first one and not the second one, regardless of which one I choose. Is there any way to correct this?
 
I highly doubt there is a way to link to an advisor screen. Have you seen this done in any mod?

As you point out, the literal links are tied to the description. The civilopedia is heavily based on this. In fact, it has caused me several problems when I had a tech and a civic with the same name. Since you are seeing this problem on placeholders, can you just change the descriptions to "NONE1" and "NONE2"?
 
Is the code for generating the links somewhere in the SDK?
 
Not AFAIK. There are a bunch of formatting codes which are used in the xml files for text, such as , [space], etc. I assume there is a formatting engine which interprets this, and I assume it is in the exe so it can't be modded. That is what interprets the literal syntax to give hyperlinks. However, if somebody knows better and corrects me, that will be interesting.
 
I would expect the code that jumps to a link is in CvScreensInterface. That's where the next and previous mouse buttons are handled as well. There's a function to jump to each type of object, for example:

Code:
def pediaJumpToBuilding(argsList):
	pediaMainScreen.pediaJump(PEDIA_BUILDING, argsList[0], True)

A quick search in the SDK lead to this:

Code:
void CvDLLWidgetData::doPediaBuildingJump(CvWidgetDataStruct &widgetDataStruct)
{
	CyArgsList argsList;
	argsList.add(widgetDataStruct.m_iData1);
	gDLL->getPythonIFace()->callFunction(PYScreensModule, "pediaJumpToBuilding", argsList.makeFunctionArgs());
}

Sadly this is called from only three places in execute(Alt)Action(). I do not know if those hyperlinks come through that code with a CvWidgetDataStruct or not. Oh wait, I thought I remembered seeing "link" somewhere. In CvScreensInterface is another function:

Code:
def linkToPedia(argsList):
	pediaMainScreen.link(argsList[0])

This looks more promising. I'd bet that is the string being passed in. Looking at SevoPediaMain.link() confirms this. There are links to the generic pages and then it loops over all types of items looking for the match:

Code:
def link(def link(self, szLink):
	if (szLink == "PEDIA_MAIN_TECH"):
		return self.pediaJump(SevoScreenEnums.PEDIA_MAIN, SevoScreenEnums.PEDIA_TECHS, True, True)
	...
	for i in range(gc.getNumTechInfos()):
		if (gc.getTechInfo(i).isMatchForLink(szLink, False)):
			return self.pediaJump(SevoScreenEnums.PEDIA_TECHS, i, True, True)

So you can definitely hook into linkToPedia(), but I don't know if you can create your own links. You could always create a fake building/unit/whatever I suppose and intercept it. You can see how links are inserted in some C++ code as well as in the CIV4GameText XML files. If you figure out a way to do this, please share.
 
Top Bottom