1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. Photobucket has changed its policy concerning hotlinking images and now requires an account with a $399.00 annual fee to allow hotlink. More information is available at: this link.
    Dismiss Notice
  3. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  4. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  5. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  6. Dismiss Notice
  7. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

Merging BUG with other Mods

Discussion in 'Civ4 - BTS Unaltered Gameplay (BUG, BAT and BULL)' started by EmperorFool, Oct 17, 2008.

  1. The Number Pi

    The Number Pi Irrational Number

    Joined:
    Jan 29, 2010
    Messages:
    332
    Location:
    Between 3 and 4
    No, I do not touch the fonts. I probabily merged it incorrectly and accidently changed something that controls the icons.

    EDIT: After starting over, and merging again, I got the smilies to disappear. It works correctly now! :woohoo:

    I do not know where the problem came from, but it stopped, and BUG works! I even got it to work with BULL!

    Thank you very much for your help with this; without it I would probably have either given up or endured the smily apocalypse. :goodjob: :thanx: :hatsoff:
     
  2. EmperorFool

    EmperorFool Chieftain

    Joined:
    Mar 2, 2007
    Messages:
    9,633
    Location:
    Mountain View, California
    You're welcome. One can take only so much happiness in one sitting! :D
     
  3. stolenrays

    stolenrays Chieftain

    Joined:
    Aug 2, 2009
    Messages:
    2,061
    I'd like to use only the great general bar, but merging didn't work and created python exceptions. I am using a CustomEventManager and not BUG's Event manager. I figure the EventInterfacefiles should be merged and I'm not sure what else. Any tips please?:confused:
     
  4. EmperorFool

    EmperorFool Chieftain

    Joined:
    Mar 2, 2007
    Messages:
    9,633
    Location:
    Mountain View, California
    There are probably problems around BUG trying to access its options which won't exist since you're not using the full BUG stack. The GG bar doesn't require any special events, so you don't need anything from BUG's CvEventInterface.py. I think everything you need should be in CvMainInterface.py and GGUtil.py.

    Anywhere you see it accessing an option such as MainOpt.isShowGGProgressBar() replace that with True.

    GGUtil uses some functions from BugUtil and FontUtil that you'll need to merge somehow. I suggest just copying the functions to GGUtil and repeating as necessary.

    BUG was designed to make it easy to add mods to it--not extract small pieces. :assimilate:
     
  5. stolenrays

    stolenrays Chieftain

    Joined:
    Aug 2, 2009
    Messages:
    2,061
    Thanks for the information. I orignally wanted to rebuild my mod from the ground up by merging all my files with BUG or RevDCM, but could never get it to work since interface icons were always missing.

    BTW, did Al Pacino sell you that property? <---from Glengarry Glen Ross
     
  6. stolenrays

    stolenrays Chieftain

    Joined:
    Aug 2, 2009
    Messages:
    2,061
    Is this everything I need from Fontutil/BugUtil merged into GGUtil?

    Spoiler :
    Code:
    ## GGUtil
    ##
    ## Utilities for dealing with Great Generals.
    ##
    ## Notes
    ##   - Must be initialized externally by calling init()
    ##
    ## Copyright (c) 2008 The BUG Mod.
    ##
    ## Author: EmperorFool
    
    from CvPythonExtensions import *
    
    gc = CyGlobalContext()
    
    g_ePromo = -1
    g_promoButton = ""
    g_cGreatGeneral = ""
    
    def init():
    	global g_ePromo
    	g_ePromo = gc.getInfoTypeForString("PROMOTION_LEADER")
    	global g_promoButton
    	g_promoButton = gc.getPromotionInfo(g_ePromo).getButton()
    	global g_cGreatGeneral
    	g_cGreatGeneral = FontUtil.getChar(FontSymbols.GREAT_GENERAL_CHAR)
    
    def getPromotionId():
    	return g_ePromo
    
    def getPromotion():
    	return gc.getPromotionInfo(g_ePromo)
    
    def getGreatGeneralText(iNeededExp):
    	return BugUtil.getText("INTERFACE_NEXT_GREAT_GENERAL_XP", 
    			(g_cGreatGeneral, iNeededExp))
    			
    def getText(key, values=(), default=None, replaceFontTags=True):
    	"""
    	Looks up a translated message in XML with a tuple of replacement parameters.
    	It is safe to pass in a single value instead of tuple/list.
    	If the key isn't found, the default is returned.
    	"""
    	if values is None:
    		values = ()
    	elif not isinstance(values, (tuple, list)):
    		values = (values,)
    	if isinstance(key, unicode):
    		warn("getText - received Unicode key %s", key)
    		key = str(key)
    	text = localText.getText(key, values)
    	if (text and text != key):
    		if replaceFontTags:
    			import FontUtil
    			text = FontUtil.replaceSymbols(text)
    		return text
    	else:
    		if default is not None:
    			return default
    		else:
    			debug("BugUtil.getText - XML key %s not found", key)
    			return "XML key %s not found" % key
    
    def replaceSymbols(text, unknownReplacement=""):
    	def replace(match):
    		try:
    			return getChar(match.group(1))
    		except BugUtil.ConfigError:
    			return unknownReplacement
    	return SYMBOL_REGEXP.sub(replace, text)
    			
    def getChar(symbolOrKey):
    	try:
    		return symbolChars[getSymbol(symbolOrKey)]
    	except KeyError:
    		raise BugUtil.ConfigError("unknown font symbol or key '%s'" % str(symbolOrKey))
    		
    def getSymbol(symbolOrKey):
    	if isinstance(symbolOrKey, FontSymbols):
    		return symbolOrKey
    	try:
    		return keySymbols[symbolOrKey]
    	except KeyError:
    		try:
    			return keySymbols[symbolOrKey.upper() + "_CHAR"]
    		except KeyError:
    			raise BugUtil.ConfigError("unknown font symbol or key '%s'" % str(symbolOrKey))


    I thiink I am supposed to replace BugUtil or FontUtil with something, but I do not know what.
     
  7. EmperorFool

    EmperorFool Chieftain

    Joined:
    Mar 2, 2007
    Messages:
    9,633
    Location:
    Mountain View, California
    You'll need to look in FontUtil and BugUtil for how getChar() and getText() work. They are very simple functions that you could copy directly into GGUtil and then simply remove the package references in front of the function calls. In other words "FontUtil.getChar" becomes "getChar", etc.
     
  8. stolenrays

    stolenrays Chieftain

    Joined:
    Aug 2, 2009
    Messages:
    2,061
  9. Spellbinder

    Spellbinder Chieftain

    Joined:
    Oct 3, 2011
    Messages:
    14
    I try to make some modifications to revolutiondcm that uses bug.

    Here is my xml file:

    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!--
    Amducias Mods
    by Amducias

    Copyright (c) 2011 Amducias.
    -->
    <mod id="Amdu"
    module="Amdu"
    name="Amducias Mod"
    author="Amducias"
    version="1.0"
    date="09/11/2011"
    url="http://forums.civfanatics.com/">

    <event type="combatResult" function="onCombatResult"/>
    <event type="BeginPlayerTurn" function="onBeginPlayerTurn"/>
    </mod>


    Here is my py file:

    ## Amdu

    from CvPythonExtensions import *
    import BugUtil
    import PlayerUtil
    import BugData
    import Popup as PyPopup

    gc = CyGlobalContext()

    def onCombatResult(self, argsList):
    pWinner,pLoser = argsList
    popup = PyPopup.PyPopup()
    popup.setBodyString( 'Combat Trigger' )
    popup.launch()

    def onBeginPlayerTurn(argsList):
    iGameTurn, iPlayer = argsList


    The popup is just there to test if the function is called. But after combat I get a eventhandler error message. can someone tell me what I am doing wrong?
     
  10. EmperorFool

    EmperorFool Chieftain

    Joined:
    Mar 2, 2007
    Messages:
    9,633
    Location:
    Mountain View, California
    Remove the first argument (self) from both functions. You only use the self argument if the functions are defined inside a class. Yes, I know it's not super obvious, but it's just how Python works.

    If that doesn't solve the problem, make sure to follow the steps in the Troubleshooting page linked in my sig so you can post the full error message and stack trace.
     
  11. Spellbinder

    Spellbinder Chieftain

    Joined:
    Oct 3, 2011
    Messages:
    14
    Thanks EmperorFool,

    That helped a lot. I think I have have my basics right, now.

    Many Thanks,

    Spellbinder
     
  12. Spellbinder

    Spellbinder Chieftain

    Joined:
    Oct 3, 2011
    Messages:
    14
    Hi,

    is there a tutorial on how to make a Bug option screen for your mod?

    Regards,

    Spellbinder
     
  13. 33CI00FA

    33CI00FA Chieftain

    Joined:
    Jan 29, 2011
    Messages:
    80
    Gender:
    Male
    Location:
    Helsinki
    I tried out that BUFFY MOD. Incredible stuff there.
    Quite well done. All those information bars were very useful.

    I have a question:
    Can I alter BUFFY for my mod?
    I just change some unit speeds in that XML file.
     
  14. ruff_hi

    ruff_hi Live 4ever! Or die trying

    Joined:
    Oct 24, 2005
    Messages:
    8,868
    Location:
    an Aussie in Boston
    yes. You will not be able to submit HOF games using the modified BUFFY mod.
     
  15. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,674
    I'm having trouble getting my project to compile the CvBugOptions files. Both the .h and the .ccp files are listed as part of the project, but when I compile, it just skips right over them. What do I need to change to have these files compile correctly?
     
  16. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,674
    Turns out that something was wrong with my makefile. I ended up using Asaf's version from his tutorial.
     
  17. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,674
    Where are the files that control the popups for selecting techs and city builds? Specifically, I'm having issue with both windows showing techs and builds that shouldnt be available to the player, so I need to add in some Prereq checks somewhere but I cant figure out where.
     
  18. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,674
    Is there an easy and/or simple way I can set some of the BUG options as disabled? I want them to still be shown on the BUG options screen, but I want them to be grayed out and un-clickable.


    Also, I'm still looking for some help on my previous question regarding the tech and city build popups.
     
  19. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,674
    I find all of these tutorials very confusing as they never explain where to put this strange XML tag. <gameutils module="MyMod" class="MyGameUtils" override="True"/>

    All I want to do is to not have BUG overriding the function results from CvGameUtils. Can someone please explain how to do that?
     
  20. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,674
    Turns out I could bypass the whole BugGameUtils function rerouting by removing the CvGameInterfaceFile.py entirely. And in turn that fixed my problem with players being allowed to research and build things they shouldnt (the missing checks were in python and the BUG version wasn't calling the standard python functions for some reason).
     

Share This Page