Advertisement
Civilization Fanatics' Center

Go Back   Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization > Civ4 - Project & Mod Development > Civ4 - BTS Unaltered Gameplay (BUG, BAT and BULL)

Notices

Civ4 - BTS Unaltered Gameplay (BUG, BAT and BULL) (Public) Forum for Civ4 BTS Unaltered Gameplay Project.

Reply
 
Thread Tools
Old Feb 29, 2012, 01:08 AM   #1
modifieda4
Chief Time Waster
 
Join Date: Sep 2006
Location: Gold Coast
Posts: 384
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>
how would i get the corporation's name into a mouse over?
__________________
My mods: 23+ mod comps for BTS as of 1/22/2014
modifieda4 is offline   Reply With Quote
Old Feb 29, 2012, 07:20 PM   #2
modifieda4
Chief Time Waster
 
Join Date: Sep 2006
Location: Gold Coast
Posts: 384
i think ill just try to hijack iData2 since it doesnt seem to be used...
__________________
My mods: 23+ mod comps for BTS as of 1/22/2014
modifieda4 is offline   Reply With Quote
Old Mar 01, 2012, 01:44 AM   #3
EmperorFool
Deity
 
EmperorFool's Avatar
 
Join Date: Mar 2007
Location: Mountain View, California
Posts: 9,625
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())
Next you'll need to hook up this handler to the getWidgetHelp game utils callback. Follow the tutorial for that. Try it out and post again with how far you got.
__________________
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 Mar 01, 2012, 08:58 AM   #4
modifieda4
Chief Time Waster
 
Join Date: Sep 2006
Location: Gold Coast
Posts: 384
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: 23+ mod comps for BTS as of 1/22/2014
modifieda4 is offline   Reply With Quote
Old Mar 01, 2012, 08:58 PM   #5
EmperorFool
Deity
 
EmperorFool's Avatar
 
Join Date: Mar 2007
Location: Mountain View, California
Posts: 9,625
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"/>
And for simple ones that display a static help text hover from an XML file, use

Code:
<widget name="WIDGET_BUG_OPTION_SCREEN" xml="TXT_KEY_BUG_OPTIONS_SCREEN_HOVER"/>
When placing custom widgets, just reference them as you would any other widget type:

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 ]

BAT 3.0.1 QuickFix™ released Oct 24th
EmperorFool is offline   Reply With Quote
Old Mar 01, 2012, 09:04 PM   #6
modifieda4
Chief Time Waster
 
Join Date: Sep 2006
Location: Gold Coast
Posts: 384
Quote:
Originally Posted by EmperorFool View Post
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"/>
And for simple ones that display a static help text hover from an XML file, use

Code:
<widget name="WIDGET_BUG_OPTION_SCREEN" xml="TXT_KEY_BUG_OPTIONS_SCREEN_HOVER"/>
When placing custom widgets, just reference them as you would any other widget type:

Code:
WidgetType.WIDGET_GP_PROGRESS_BAR
yah i just got the "register widget error"
which bug xml file contains the registrations?

oops i found it in WidgetUtil.py...
__________________
My mods: 23+ mod comps for BTS as of 1/22/2014

Last edited by modifieda4; Mar 01, 2012 at 09:19 PM.
modifieda4 is offline   Reply With Quote
Old Mar 02, 2012, 08:47 AM   #7
modifieda4
Chief Time Waster
 
Join Date: Sep 2006
Location: Gold Coast
Posts: 384
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: 23+ mod comps for BTS as of 1/22/2014
modifieda4 is offline   Reply With Quote
Old Mar 03, 2012, 08:27 PM   #8
EmperorFool
Deity
 
EmperorFool's Avatar
 
Join Date: Mar 2007
Location: Mountain View, California
Posts: 9,625
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 ]

BAT 3.0.1 QuickFix™ released Oct 24th
EmperorFool is offline   Reply With Quote
Old Mar 06, 2012, 09:38 PM   #9
modifieda4
Chief Time Waster
 
Join Date: Sep 2006
Location: Gold Coast
Posts: 384
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"/>
in CvMainInterface.py:
Code:
screen.appendMultiListButton( "BottomButtonContainer", ArtFileMgr.getInterfaceArtInfo("INTERFACE_CORPORATE_RELOCATION").getPath(), 0, WidgetTypes.WIDGET_CORPORATE, iCity, iUnit, False)
i guess its not understanding the 4 parameters being passed into argsList?
__________________
My mods: 23+ mod comps for BTS as of 1/22/2014
modifieda4 is offline   Reply With Quote
Old Mar 07, 2012, 10:24 PM   #10
modifieda4
Chief Time Waster
 
Join Date: Sep 2006
Location: Gold Coast
Posts: 384
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 page
http://sourceforge.net/apps/mediawik...&search=widget
__________________
My mods: 23+ mod comps for BTS as of 1/22/2014
modifieda4 is offline   Reply With Quote
Old Mar 09, 2012, 09:05 PM   #11
EmperorFool
Deity
 
EmperorFool's Avatar
 
Join Date: Mar 2007
Location: Mountain View, California
Posts: 9,625
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):
To use the button should be no different from before; inputClass.getFunctionName() returns the name of the button. Here's an example for the BUG Options Screen button:

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 ]

BAT 3.0.1 QuickFix™ released Oct 24th
EmperorFool is offline   Reply With Quote
Old Mar 09, 2012, 09:06 PM   #12
EmperorFool
Deity
 
EmperorFool's Avatar
 
Join Date: Mar 2007
Location: Mountain View, California
Posts: 9,625
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 ]

BAT 3.0.1 QuickFix™ released Oct 24th
EmperorFool is offline   Reply With Quote
Old Aug 08, 2013, 05:06 AM   #13
Bataknese
Horas Bah..
 
Bataknese's Avatar
 
Join Date: Jun 2009
Location: Indonesia
Posts: 51
Quote:
Originally Posted by EmperorFool View Post
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"/>
And for simple ones that display a static help text hover from an XML file, use

Code:
<widget name="WIDGET_BUG_OPTION_SCREEN" xml="TXT_KEY_BUG_OPTIONS_SCREEN_HOVER"/>
When placing custom widgets, just reference them as you would any other widget type:

Code:
WidgetType.WIDGET_GP_PROGRESS_BAR
in what file that's should be put?? do we need create new XML file?

i have codes like this in CvGameUtil.py, which should be display text when a button hovered:

Code:
	def getWidgetHelp(self, argsList):
		eWidgetType, iData1, iData2, bOption = argsList
	
          if eWidgetType == WidgetTypes.WIDGET_GENERAL:
			GameSpeedInfo = gc.getGameSpeedInfo(CyGame().getGameSpeedType())
			if iData1 == 800:
				return CyTranslator().getText("TXT_KEY_PLATY_GENERAL_MISSION1",())
that's not working since i'm using BUG mod
I have read the "WidgetUtil.py" but still don't get it
__________________
We just dont like you enough

Last edited by Bataknese; Aug 09, 2013 at 03:28 AM.
Bataknese is offline   Reply With Quote
Old Sep 01, 2013, 11:00 PM   #14
Lemon Merchant
Mod Grrl
 
Lemon Merchant's Avatar
 
Join Date: Jun 2008
Location: Red Sector A
Posts: 3,735
Gender: Female
If you're adding hover widgets, you'll need to edit both the XML and Python. The *.py file that you put your code into depends on what you're trying to accomplish.
Lemon Merchant is offline   Reply With Quote
Old Oct 21, 2013, 09:36 AM   #15
Yxklyx
King
 
Yxklyx's Avatar
 
Join Date: May 2008
Posts: 869
Hello, having some issues getting hover text to work:

Assets\Config\VassalWar.xml:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
VassalWar
-->
<mod id="VassalWar" module="VassalWar">
<gameutils module="VassalWar" handlers="getWidgetHelp" override="True"/>
<widget name="WIDGET_VASSAL_WAR" xml="TXT_KEY_DECLARE_WAR"/>
</mod>

Asstes\Python\VassalWar.py:

# VassalWar

from CvPythonExtensions import *
import BugCore
import BugUtil

gc = CyGlobalContext()

def getWidgetHelp(argsList):
eWidgetType, iData1, iData2, bOption = argsList
## War on Vassal ##
if eWidgetType == WidgetTypes.WIDGET_VASSAL_WAR:
if iData1 == 3434:
return CyTranslator().getText("TXT_KEY_DECLARE_WAR",())
## War on Vassal ##
return u""

Assets\Python\Screens\CvForeignAdvisor.py:

iLoopTeam = player.getTeam()
iActiveTeam = playerActive.getTeam()
if iLoopTeam != iActiveTeam and not gc.getTeam(iLoopTeam).isForcePeace(iActiveTeam) and not gc.getTeam(iActiveTeam).isAVassal() and not gc.getTeam(iLoopTeam).isAtWar(iActiveTeam):
screen.setImageButton("DeclareWar" + str(iPlayer), ",Art/Interface/Buttons/Promotions/Blitz.dds,Art/Interface/Buttons/Promotions_Atlas.dds,8,1", fX - 24, fY+ iLeaderHeight, 24, 24, WidgetTypes.WIDGET_VASSAL_WAR, 3434, iLoopTeam)

If I just use WIDGET_GENERAL, the mod works but there's no hover text.

Also, I copied in a python file: Assets\Python\CvEventManager.py - Can this file coexist with BUG? It works for my mod but will it break BUG in other places?
Yxklyx is offline   Reply With Quote
Old Oct 21, 2013, 01:03 PM   #16
Yxklyx
King
 
Yxklyx's Avatar
 
Join Date: May 2008
Posts: 869
Never mind - was missing the load in init.xml.

I still have this question about Assets\Python\CvEventManager.py - do the functions in this file exist elsewhere in BUG or can I safely copy it in?
Yxklyx is offline   Reply With Quote
Reply

Bookmarks

Go Back Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization > Civ4 - Project & Mod Development > Civ4 - BTS Unaltered Gameplay (BUG, BAT and BULL) > how to pass more args to getWidgetHelp?

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



Advertisement

All times are GMT -6. The time now is 01:16 AM.


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