City Screen Help

Dom Pedro II

Modder For Life
Joined
Apr 3, 2002
Messages
6,811
Location
Exit 16, New Jersey
I'm all thumbs when it comes to python, so I was wondering how I would go about doing this. I would like to add a button that will activate/deactivate a building. I know what to do on the C++ side, so that's not really an issue. What I want though is to have the button appear alongside the building in the building list.

If this can't be done, I'll just have to have a button that when pressed will bring up a popup, but I'd rather not do this. Thanks in advance.
 
Actually this might be able to be done completely in the DLL. I am pretty sure there is already a Widget defined for buildings in city view (if you can hold the mouse over them to get further information, then there is a widget for it already). If that is the case, then you just have to make the widget react to clicking on it. If that is NOT the case, you need to define and attach a widget, which gets slightly more complicated.
 
Anyway, you want to work in Python/Screens/CvMainInterface to modify the city screen.

Buildings are displayed as a part of "BuildingListTable" which has 3 columns defined. if you want to add a button specifically for your action you'll want to modify this to have a 4th column most likely to hold your button in, or just expand the very tiny 3rd column. Then you could follow everything which comes after declaration of the ListTable to add your button with only python. However, there IS a widget defined.

WidgetTypes.WIDGET_HELP_BUILDING

So you can accomplish this with just DLL work.

Go to CvDLLWidgetData and you'll see that WIDGET_HELP_BUILDING only shows up in parseHelp. You want to add it to executeAction and make it perform what you want to do with clicking on the building.

What you would still want to do in Python though is ensure that the deactivated building will show up in the list as normal by modification of the list construction to still list the deactivated buildings (if part of deactivating it actually removes it from the list of buildings in the city and places it in a new list to track presence and block reconstruction), and to place a big red X over it or something to indicate that it is deactivated.
 
Anyway, you want to work in Python/Screens/CvMainInterface to modify the city screen.

Buildings are displayed as a part of "BuildingListTable" which has 3 columns defined. if you want to add a button specifically for your action you'll want to modify this to have a 4th column most likely to hold your button in, or just expand the very tiny 3rd column. Then you could follow everything which comes after declaration of the ListTable to add your button with only python. However, there IS a widget defined.

WidgetTypes.WIDGET_HELP_BUILDING

So you can accomplish this with just DLL work.

Go to CvDLLWidgetData and you'll see that WIDGET_HELP_BUILDING only shows up in parseHelp. You want to add it to executeAction and make it perform what you want to do with clicking on the building.

What you would still want to do in Python though is ensure that the deactivated building will show up in the list as normal by modification of the list construction to still list the deactivated buildings (if part of deactivating it actually removes it from the list of buildings in the city and places it in a new list to track presence and block reconstruction), and to place a big red X over it or something to indicate that it is deactivated.

Hmm.. that's an interesting idea. I actually hadn't thought of just modifying the widget type. But you're right. There's really no need for a specific button when clicking on the building should suffice. Actually, this is a very interesting solution because if I wanted to make several possible actions, I could create a new popup that would appear whenever you click on a building... Thanks!
 
Damn... it worked kind of. I guess you can't have a popup appear over the city screen? If I clicked on the building and then got out of the city screen, it popped up. Otherwise no. I wonder if it's possible to override this....
 
Instead of a popup, create a new screen. Should work then.

Right... screen... in python... *runs away*

Personally, I don't like using python. I don't get it, so if I'm going to do a python screen, I want to have a darn good reason for it. So I'll hold off.
 
Top Bottom