[TUTORIAL] How to fix Cheat Menu cancel button Bug

Discussion in 'Civ4Col - Creation & Customization' started by Isabelxxx, Sep 10, 2012.

  1. Isabelxxx

    Isabelxxx DoaNE Explorer

    Joined:
    Sep 26, 2010
    Messages:
    381
    I think most mods use the Cheat Popup, and while my version is heavily modified I will show how to fix a wrong behavior in the Dale's version of the Cheat Popup. This one is pretty obvious if you understood the previous fix.

    If you add something to the AI Autoplay input in the popup, when you press "cancel" the game will do the AI Autoplay instead of just closing the popup. So the cancel button is not really avoiding any action.

    In CvEventManager.py:
    Code:
    	def AoDCheatMenuApply(self, playerID, userData, popupReturn):
    		autoIdx = popupReturn.getButtonClicked()
    		iPlayer = gc.getPlayer(playerID)
    		iAutoplay = 0
    		iAutoplay = popupReturn.getSpinnerWidgetValue(int(0))
    [COLOR="blue"]		//Cancel buttons[/COLOR]
    [COLOR="SeaGreen"]		if (autoIdx == 0):
    			return[/COLOR]
    		//AI Input
    		if (iAutoplay > 0):
    			CyGame().setAIAutoPlay(iAutoplay)
    [COLOR="Red"]		if (autoIdx == 0):
    			return[/COLOR]
    		[COLOR="blue"]//AI buttons[/COLOR]
    		if (autoIdx == 1):
    			CyGame().setAIAutoPlay(10)
    		if (autoIdx == 2):
    			CyGame().setAIAutoPlay(50)
    		[COLOR="blue"]//Gold Input[/COLOR]
    		iMoneyTree = 0
    		iMoneyTree = popupReturn.getSpinnerWidgetValue(int(1))
    		if (iMoneyTree > 0): 
    			iPlayer.changeGold(iMoneyTree)
    		[COLOR="blue"]//Gold buttons[/COLOR]
    		if (autoIdx == 3):
    			iPlayer.changeGold(1000)
    		if (autoIdx == 4):
    			iPlayer.changeGold(5000)
    		return

    Red is removed, green added. The rest are comments.
    Just move that if block to the bottom.

    That part is the cancel button, so it should be the first. (you can also move it before iPlayer declaration, so it does not run unnecessary code)

    Note the relation between input checks and button checks: pressing a button in a popup do close the popup and call the _apply function, but input (spin box) values have to be checked manually before buttons clicked! AI input is checked before AI buttons, the same for Gold Input and gold buttons.

    In fact, if you take that into consideration you can set AI autoplay and gold cheat at the same time due to the way the code are checked.
     
  2. Sanotra

    Sanotra Wannabe Modder

    Joined:
    May 16, 2007
    Messages:
    668
    Location:
    Wa - USA
    How do I even open the cheat menu? I've never done it.
     
  3. Isabelxxx

    Isabelxxx DoaNE Explorer

    Joined:
    Sep 26, 2010
    Messages:
    381
    ctrl+shift+z (for Tac, RaR, Doane & AoD)
     

Share This Page