| General | Hosted Sites | Civ5 | CivRev | Civ4Col | Civ4 | Civ3 | Civ2 | Civ1 | Misc | Marketplace |
![]() |
|
|
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. |
|
|||||||
![]() |
|
|
Thread Tools |
|
|
#1 |
|
Chief Time Waster
|
how to pass more args to getWidgetHelp?
the default args list is:
eWidgetType, iData1, iData2, bOption i want to use a text string as the hover which includes a string variable here would an example text xml: Code:
<TEXT> <Tag>TXT_KEY_CORPORATE_RELOCATION_MOUSE_OVER</Tag> <English>Relocate %s1 headquarters to this city</English> <French></French> <German></German> <Italian></Italian> <Spanish></Spanish> </TEXT>
__________________
My mods: 20+ mod comps for BTS |
|
|
|
|
|
#2 |
|
Chief Time Waster
|
i think ill just try to hijack iData2 since it doesnt seem to be used...
__________________
My mods: 20+ mod comps for BTS |
|
|
|
|
|
#3 |
|
Deity
Join Date: Mar 2007
Location: Mountain View, California
Posts: 9,624
|
When you place a widget on the screen, you give it the widget ID (eWidgetType) and two numeric identifiers, iData1, and iData2. That's all you get. To put substitute the name of a city into your text you need to find a way to determine the city's name from those two numbers. Luckily for you, that's pretty easy: iData1 holds the player ID and iData2 holds the city ID.
It's been a long time since I did this, so I'll have to resort to English text rather than code. If you put this into code I can help from there. You can get help with some of it from the BUG tutorial. Nevermind, let's try some code: Code:
MY_CUSTOM_WIDGET = 12345
def getWidgetHelp(argsList):
eWidgetType, iPlayer, iCity = argsList
if eWidgetType is MY_CUSTOM_WIDGET:
pPlayer = gc.getPlayer(iPlayer)
pCity = pPlayer.getCity(iCity)
return BugUtil.getText("TXT_KEY_CORPORATE_RELOCATION_MOUSE_OVER", pCity.getName())
__________________
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 ] |
|
|
|
|
|
#4 |
|
Chief Time Waster
|
EmporerFool, thanks! Ill try those suggestions out.
BTW the brute force way of hijacking iData2 seems to be working. The problem with that is there is a cost calculation in my mod that I had to put into the maininterface.py. So every time the action button is rendered, the calculation would run. If I can get your method to work, I can put the cost calculation into the getWidgetHelp of my BUG event so the calculation would only run on mouse over. It seems more efficient that way. I'll let you know how it goes.
__________________
My mods: 20+ mod comps for BTS |
|
|
|
|
|
#5 |
|
Deity
Join Date: Mar 2007
Location: Mountain View, California
Posts: 9,624
|
I don't know if it was clear, but BUG can define new widget types for you very easily that you can then use in Python. For ones that need to have a function called in Python use
Code:
<widget name="WIDGET_GP_PROGRESS_BAR" module="GPUtil" function="getHoverText"/> Code:
<widget name="WIDGET_BUG_OPTION_SCREEN" xml="TXT_KEY_BUG_OPTIONS_SCREEN_HOVER"/> Code:
WidgetType.WIDGET_GP_PROGRESS_BAR
__________________
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 ] |
|
|
|
|
|
#6 | |
|
Chief Time Waster
|
Quote:
![]() which bug xml file contains the registrations? oops i found it in WidgetUtil.py...
__________________
My mods: 20+ mod comps for BTS Last edited by modifieda4; Mar 01, 2012 at 08:19 PM. |
|
|
|
|
|
|
#7 |
|
Chief Time Waster
|
EmperorFool:
I understand all the logic to creating a BUG help widget now EXCEPT in what file to call the widgetutils and to register the wiget. does this go in my mod's gameutils? the widget needs to be visible to the maininterface.py and i know load order matters.
__________________
My mods: 20+ mod comps for BTS |
|
|
|
|
|
#8 |
|
Deity
Join Date: Mar 2007
Location: Mountain View, California
Posts: 9,624
|
Adding <widget .../> to your mod's config XML file makes the constant available on the WidgetType class. You don't need to use create a gameutils callback or use WidgetUtils (BUG does both). All you need to do is place an object (button, text, whatever) on the screen that references the new WidgetType you declared.
I don't recall "register widget error". Did this appear in the logs? If so, can you paste the full message including some surrounding context? Code helps a ton in understanding what's going wrong. Your XML config file and the Python where you place the widget would be most helpful.
__________________
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 ] |
|
|
|
|
|
#9 |
|
Chief Time Waster
|
some progress, though i've hit another snag:
python exception: type error: getWidgetHelp() takes exactly 1 argument (4 given) in Basic Corporate Relocation.xml: Code:
<widget name="WIDGET_CORPORATE" module="BasicCorporateRelocation" function="getWidgetHelp"/> Code:
screen.appendMultiListButton( "BottomButtonContainer", ArtFileMgr.getInterfaceArtInfo("INTERFACE_CORPORATE_RELOCATION").getPath(), 0, WidgetTypes.WIDGET_CORPORATE, iCity, iUnit, False)
__________________
My mods: 20+ mod comps for BTS |
|
|
|
|
|
#10 |
|
Chief Time Waster
|
more issues...
how do i launch the button? I know how to do it the old way. not the new way ![]() in: def handleInput (self, inputClass): the old way: if (inputClass.getNotifyCode() == 11 and inputClass.getData() == 667): and inputClass.getData2() == 667): this would be a whole lot easier with a nice write up like (the old way): http://forums.civfanatics.com/showthread.php?t=331001 i can't find any bug examples...ROM AND doesnt use this nor does the BUG sourceforge pagehttp://sourceforge.net/apps/mediawik...&search=widget
__________________
My mods: 20+ mod comps for BTS |
|
|
|
|
|
#11 |
|
Deity
Join Date: Mar 2007
Location: Mountain View, California
Posts: 9,624
|
BUG extracts the four parameters from the argsList array and passes them directly to your function. You can see an example in Python/BUG/GPUtil.py:
Code:
def getHoverText(eWidgetType, iData1, iData2, bOption): Code:
# create the button
sBUGOptionsScreenButton = ArtFileMgr.getInterfaceArtInfo("BUG_OPTIONS_SCREEN_BUTTON").getPath()
screen.setImageButton("BUGOptionsScreenWidget", sBUGOptionsScreenButton, iBtnX + 30, iBtnY - 2, iBtnWidth, iBtnWidth, WidgetTypes.WIDGET_BUG_OPTION_SCREEN, -1, -1)
# in handleInput():
if inputClass.getNotifyCode() == NotifyCode.NOTIFY_CLICKED:
if inputClass.getFunctionName() == "BUGOptionsScreenWidget":
BugOptionsScreen.showOptionsScreen()
__________________
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 ] |
|
|
|
|
|
#12 |
|
Deity
Join Date: Mar 2007
Location: Mountain View, California
Posts: 9,624
|
I do agree that more BUG tutorials are needed.
__________________
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 ] |
|
|
|
![]() |
| Bookmarks |
|
| Thread Tools | |
|
|