Asaf
Sleep Deprived
- Joined
- Mar 22, 2010
- Messages
- 1,326
This involves both Python and SDK.
What I'm trying to do is to add a button next to some buildings in the city's building list, according to a condition which changes over time.
After a few attempts I did this:
I changed the "BuildingListTable" to have 4 (instead of 3) columns, where I added a new column to the left (previous 0 became 1 etc.). Total width remained the same.
In the loop which goes over the buildings, I checked the condition, and if it was true I used the following (i is the building type):
(I used different names, but I spare you these details).
It worked just fine (when I clicked on it it did what I wanted), except for a few problems, some are big, some are much bigger:
All these problems happened without clicking this button, so it has nothing to do with what happened after the click.
When I only changed the UI to not have attachControlToTableCell, problems 1 & 3 went away (nothing else changed in the code, including testing for the condition remained).
However, when instead of adding a column with a button I just changed the color of the text of the building name and changed its widget type, I couldn't even get the click to work, and the tool tip didn't work either.
I'd appreciate any help I can get on this.
What I'm trying to do is to add a button next to some buildings in the city's building list, according to a condition which changes over time.
After a few attempts I did this:
I changed the "BuildingListTable" to have 4 (instead of 3) columns, where I added a new column to the left (previous 0 became 1 etc.). Total width remained the same.
In the loop which goes over the buildings, I checked the condition, and if it was true I used the following (i is the building type):
Code:
buttonName = "_NewButton_" + str(i)
screen.setButtonGFC(buttonName, u"", "", 0, 0, 16, 16, WidgetTypes.WIDGET_NEW_WIDGET, i, -1, ButtonStyles.BUTTON_STYLE_CITY_PLUS )
screen.attachControlToTableCell(buttonName, "BuildingListTable", iNumBuildings, 0)
(I used different names, but I spare you these details).
It worked just fine (when I clicked on it it did what I wanted), except for a few problems, some are big, some are much bigger:
- When entering the city screen, in most cases (but not all), the loading of those specific buildings rows in the table was VERY SLOW.
- Tool tip didn't show for the button, although it did reach the code in CvDLLWidgetData:: parseHelp for the new widget, and the help string was constructed just fine.
- Crashes, crashes and more crashes, when entering the city screen. Some gave an error message, such as "Pure virtual function call", and some just threw an exception and died. Tracing their location did me no good since the entire call stack was in the executable.
All these problems happened without clicking this button, so it has nothing to do with what happened after the click.
When I only changed the UI to not have attachControlToTableCell, problems 1 & 3 went away (nothing else changed in the code, including testing for the condition remained).
However, when instead of adding a column with a button I just changed the color of the text of the building name and changed its widget type, I couldn't even get the click to work, and the tool tip didn't work either.
I'd appreciate any help I can get on this.