Selecting Cities

Xyth

History Rewritten
Joined
Jul 14, 2004
Messages
4,106
Location
Aotearoa
Does anyone know how to select a city in Python (i.e can be retrieved by CyInterface().getHeadSelectedCity()) but NOT open the city screen like CyInterface.selectCity() does? Alternatively, is there a way of quickly closing the city screen straight after a CyInterface.selectCity() call?
 
I'm making a custom Domestic Advisor for my mod and I'm having problems with tooltips. Because we can't pass CyCity instances as widget data, in getWidgetHelp() I make extensive use of CyInterface().getHeadSelectedCity() to obtain the selected city, freeing up data1 and data2 for more useful information. I also want to be able to select a city in a table, have the camera zoom to its location and have the bottom UI pane show the city's production options (much like when selecting nameplates and cycling between cities using the arrows above the player flag banner).
 
1) You cannot pass CyCity directly as widget data but there are always ways to do it.
Just pass the player ID and city ID or simply use pCity.getX() * 1000 + pCiy.getY() and you have saved the city with just one data.

2) Anyway, isnt the BTS domestic advisor already doing it? When you click on a city, you can choose the production directly as though the city screen is opened.
 
simply use pCity.getX() * 1000 + pCiy.getY()

Clever!

2) Anyway, isnt the BTS domestic advisor already doing it? When you click on a city, you can choose the production directly as though the city screen is opened.

Hmm so it is, and it seems to be doing it via CyInterface().selectCity too (in handleInput()):

Code:
		if ( inputClass.getNotifyCode() == NotifyCode.NOTIFY_LISTBOX_ITEM_SELECTED ):
			if (inputClass.getMouseX() == 0):
				screen = CyGInterfaceScreen( "DomesticAdvisor", CvScreenEnums.DOMESTIC_ADVISOR )
				screen.hideScreen()
				
				CyInterface().selectCity(gc.getPlayer(inputClass.getData1()).getCity(inputClass.getData2()), true);
				
				popupInfo = CyPopupInfo()
				popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
				popupInfo.setText(u"showDomesticAdvisor")
				popupInfo.addPopup(inputClass.getData1())		
			else:
				self.updateAppropriateCitySelection()
				self.updateSpecialists()

I can't figure this code out though, when I copy it exactly into my advisor, clicking on a city in the table closes the advisor and opens the city screen. What am I missing here?

Also, why does updating the selection and specialists occur separately to selecting a city? Shouldn't they happen at the same time?
 
I can't figure this code out though, when I copy it exactly into my advisor, clicking on a city in the table closes the advisor and opens the city screen. What am I missing here?

Also, why does updating the selection and specialists occur separately to selecting a city? Shouldn't they happen at the same time?

1) No idea, since your domestic advisor will probably be heavily modified by BUG

2) Isn't it occuring together in the above codes.
 
1) No idea, since your domestic advisor will probably be heavily modified by BUG

It's actually built from yours, no BUG code in it at all yet. The section I posted above seems to be identical to both the BTS and Platy UI versions.

2) Isn't it occuring together in the above codes.

No because the selectCity() happens in the 'if' section, while the updateCitySelection() and updateSpecialist happens after the 'else'. I don't understand why these aren't all together since presumably they're all meant to trigger when a table row is selected.
 
The if statement checks if the clicked stuff is actually the first column which is Enter City button.
Thus, it does what it is supposed to do.
Close the DA and open the city screen.

Any other columns, will just update and not close the screen.
 
The if statement checks if the clicked stuff is actually the first column which is Enter City button.
Thus, it does what it is supposed to do.
Close the DA and open the city screen.

Any other columns, will just update and not close the screen.

Ahhh that makes sense now. So the code to 'select' the city and bring up it's production options must be elsewhere.
 
All fixed. The needed function was CyGInterfaceScreen().updateAppropriateCitySelection().
 
Back
Top Bottom