Advertisement
Civilization Fanatics' Center  

Welcome to Civilization Fanatics' Center.

You are currently viewing our site as a guest which gives you limited access to our site features. By joining our free community, you will be able to participate in the discussions, search the forum, send private messages, vote in polls, upload your own screenshots to the gallery, and access many other special features. Registration is fast, simple and absolutely free, so sign up today! If you have any problems with the registration process or your account login, please contact support.

Go Back   Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization > Civ4 - SDK/Python

Notices

Reply
 
Thread Tools
Old Jul 12, 2010, 04:04 PM   #1
Asaf
Sleep Deprived
 
Asaf's Avatar
 
Join Date: Mar 2010
Posts: 1,309
attachControlToTableCell and a new widget

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):

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:
  1. When entering the city screen, in most cases (but not all), the loading of those specific buildings rows in the table was VERY SLOW.
  2. 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.
  3. 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.
Asaf is offline   Reply With Quote
Old Jul 18, 2010, 03:17 PM   #2
Asaf
Sleep Deprived
 
Asaf's Avatar
 
Join Date: Mar 2010
Posts: 1,309
So I understand 'attachControlToTableCell' is a tough cookie...
I've given it up. I now use textual cells with a new widget to modify its behavior.

I'll expand my 2nd question with what I've learned so far, maybe it'll give an idea to someone:

It appears that when giving a new widget to a text cell in the buildings table, whether or not this widget works (tooltip + click) depends on the position of this widget in the widgets Enum!

I tried a few places, but placing it before WIDGET_PYTHON or at the end of the list (before NUM_WIDGET_TYPES) will cause it not to work.

My current position (right after WIDGET_HELP_PROMOTION) works just fine.

I'm afraid that there's a problem I'm not aware of (another place which holds this list?), which might cause other widgets to stop working because of the one that I added.

And just in case you were wondering, I added it to the python widget types enum in CyEnumsPythonInterface().

Any ideas?
Asaf is offline   Reply With Quote
Old Jul 18, 2010, 06:52 PM   #3
The_J
Say No 2 Net Validations

 
The_J's Avatar
 
Join Date: Oct 2008
Location: Germany / Netherlands
Posts: 24,853
Images: 51
Some background of your idea might help. What exactly do you want to achieve?
__________________
Civ4-BtS-Mod "Mars, Now!"


Steam eats the souls of little gamers!!!
The_J is offline   Reply With Quote
Old Jul 18, 2010, 07:02 PM   #4
Sephi
Deity
 
Join Date: Jan 2009
Posts: 2,871
Quote:
Originally Posted by Asaf View Post
So I understand 'attachControlToTableCell' is a tough cookie...
I've given it up. I now use textual cells with a new widget to modify its behavior.

I'll expand my 2nd question with what I've learned so far, maybe it'll give an idea to someone:

It appears that when giving a new widget to a text cell in the buildings table, whether or not this widget works (tooltip + click) depends on the position of this widget in the widgets Enum!

I tried a few places, but placing it before WIDGET_PYTHON or at the end of the list (before NUM_WIDGET_TYPES) will cause it not to work.

My current position (right after WIDGET_HELP_PROMOTION) works just fine.

I'm afraid that there's a problem I'm not aware of (another place which holds this list?), which might cause other widgets to stop working because of the one that I added.

And just in case you were wondering, I added it to the python widget types enum in CyEnumsPythonInterface().

Any ideas?
I had a similar problem which I could fix by disabling Popups for the current active screen.
__________________

Master of Mana

Turn based Strategy in a fantasy world setting
Sephi is offline   Reply With Quote
Old Jul 19, 2010, 01:15 AM   #5
Asaf
Sleep Deprived
 
Asaf's Avatar
 
Join Date: Mar 2010
Posts: 1,309
Thank you for your help

Quote:
Originally Posted by The_J View Post
Some background of your idea might help. What exactly do you want to achieve?
I wanted to keep it as a surprise
Oh well:
I work on BTS 3.19 (no BUG or anything). My mod lets some buildings accumulate experience when they build units of specific categories, and then gain specific promotions in these buildings for units of these categories which are built in this city (a complicated sentence ).

To do that I need to be able to change the display of buildings which have an available promotion in the buildings table in the city screen, and I need to be able to click on them to open the relevant popups.

The basic functionality works, including the UI (I created a new widget in the SDK and new popups, also in the SDK), but with the problem I mentioned (whether it works or not depends on its position in the enum).

Quote:
Originally Posted by Sephi View Post
I had a similar problem which I could fix by disabling Popups for the current active screen.
I'm not sure how to do that, and if I understand it correctly then I don't want to do that since I want to open popups as a result of clicking this widget.

Why would that make a difference? Is there another way to fix/bypass this?

I've come across a few other problems which might be related:
- In the civilopedia, the Exit button does not work.
- In the civics screen, the Revolution button does not work. It just closes the screen, but does not revolt.

I think that I somehow caused these widgets to stop functioning, the same way I prevent my widget from functioning when I place it in the wrong place in the enum. I'll debug it soon (hadn't had a chance yet) to see if I actually get to the relevant functions in the SDK.

It looks like the list of widgets is duplicated somewhere else (in the exe itself?) and changing it in the SDK (and in its exports to python) is sometimes just not enough...
Asaf is offline   Reply With Quote
Old Jul 19, 2010, 09:57 AM   #6
Sephi
Deity
 
Join Date: Jan 2009
Posts: 2,871
Quote:
Originally Posted by Asaf View Post
Why would that make a difference? Is there another way to fix/bypass this?
there is a way to bypass this but you need to test first if this is the problem. Just to prevent any misunderstandings, the python function I am talking about is
Code:
		screen.showScreen(PopupStates.POPUPSTATE_IMMEDIATE, False)
__________________

Master of Mana

Turn based Strategy in a fantasy world setting
Sephi is offline   Reply With Quote
Old Jul 20, 2010, 04:47 AM   #7
Asaf
Sleep Deprived
 
Asaf's Avatar
 
Join Date: Mar 2010
Posts: 1,309
I actually use the popups in the SDK, so I use

Code:
gDLL->getInterfaceIFace()->addPopup()
and
Code:
gDLL->getInterfaceIFace()->popupLaunch()
Asaf is offline   Reply With Quote
Old Jul 20, 2010, 09:45 AM   #8
Asaf
Sleep Deprived
 
Asaf's Avatar
 
Join Date: Mar 2010
Posts: 1,309
Moving the widget to the end of the enum (before NUM_WIDGET_TYPES) now works (must have done something wrong earlier), and it solves the civics 'revolution' button and the pedia exit button.

Interesting point: If I place my widget in the enum between these two (WIDGET_REVOLUTION and WIDGET_CLOSE_SCREEN), then only the earlier one (revolution) works.

I guess there is another copy of the enums compiled into the exe. Another hint for this is the fact that there's the _USRDLL definition, implying that this file might also compile when this is not defined...

Oh well. I hope there are no other hidden problems. Thank you for your time.
Asaf is offline   Reply With Quote
Old Jul 20, 2010, 11:46 PM   #9
EmperorFool
Deity
 
EmperorFool's Avatar
 
Join Date: Mar 2007
Location: Mountain View, California
Posts: 9,624
Likely you needed to fully recompile as some .cpp files were not seeing the changed enum values. Whenever you modify a header (.h) file, do a clean and build.
__________________
Monkeys killing monkeys killing monkeys over pieces of the ground.
Silly monkeys, give them thumbs they make a club and beat their brother down.


BUG Mod - BTS Unaltered Gameplay
[ Forum | Download | FAQ | Known Issues | Troubleshooting | Modding Tutorial ]

BAT 3.0.1 QuickFix™ released Oct 24th
EmperorFool is offline   Reply With Quote
Old Jul 21, 2010, 01:36 AM   #10
Asaf
Sleep Deprived
 
Asaf's Avatar
 
Join Date: Mar 2010
Posts: 1,309
Quote:
Originally Posted by EmperorFool View Post
Likely you needed to fully recompile as some .cpp files were not seeing the changed enum values. Whenever you modify a header (.h) file, do a clean and build.
Thanks, but that is definitely not the problem.
Asaf is offline   Reply With Quote
Old Jul 21, 2010, 07:50 PM   #11
EmperorFool
Deity
 
EmperorFool's Avatar
 
Join Date: Mar 2007
Location: Mountain View, California
Posts: 9,624
As long as you don't change the values of any existing enums you should be okay. The EXE is compiled against CvEnum.h as well, and it isn't recompiled when you change it obviously.
__________________
Monkeys killing monkeys killing monkeys over pieces of the ground.
Silly monkeys, give them thumbs they make a club and beat their brother down.


BUG Mod - BTS Unaltered Gameplay
[ Forum | Download | FAQ | Known Issues | Troubleshooting | Modding Tutorial ]

BAT 3.0.1 QuickFix™ released Oct 24th
EmperorFool is offline   Reply With Quote
Old Jul 22, 2010, 12:59 AM   #12
Asaf
Sleep Deprived
 
Asaf's Avatar
 
Join Date: Mar 2010
Posts: 1,309
Quote:
Originally Posted by EmperorFool View Post
As long as you don't change the values of any existing enums you should be okay. The EXE is compiled against CvEnum.h as well, and it isn't recompiled when you change it obviously.
That's what I figured, so I moved all my new Enum values to the end of each enum.
I wish Firaxis would add a comment about it in the code.
Actually I wish Firaxis would comment their code in general

Thanks.
Asaf is offline   Reply With Quote
Reply

Bookmarks

Go Back Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization > Civ4 - SDK/Python > attachControlToTableCell and a new widget

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Widget Issue Opera Civ4 - SDK/Python 5 Jan 22, 2010 03:12 AM
connection from xml help to widget help? davidlallen Civ4 - SDK/Python 6 Oct 28, 2009 07:59 AM
[SDK] Widget Help johnny_cash Civ4 - SDK/Python 22 Sep 14, 2009 07:23 AM
help with new widget evertebrate Civ4 - SDK/Python 4 Jul 26, 2009 02:11 AM
1.52 - Promotion info shown in tech widget The Great Apple Civ4 - Bug Reports 0 Jan 10, 2006 04:44 PM


Advertisement

All times are GMT -6. The time now is 11:19 AM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
This site is copyright © Civilization Fanatics' Center.
Support CFC: Amazon.com | Amazon UK | Amazon DE | Amazon CA | Amazon FR