[TUTORIAL] How to fix Wonder Movie Popup CTD

Isabelxxx

Prince
Joined
Sep 26, 2010
Messages
399
Since COL has no wonders there are no movies for any building in game. That provokes a bug when opening the Wonder Movie Popup (ctrl + shift + W) because of 2 reasons:

  • You can not close the popup without performing an action (Cancel).
  • The list of available movies is NULL so there is a NULL default selection and that provokes an inmediate CTD when trying to play a NULL movie.

Here is a modification of that popup to solve both:
Now there is a cancel button (do nothing except close the popup).
Default selection is NONE which will not play anything if there are no movies available.


This works for COL and BTS (designed for mods which disabled wonder movies).





Both files contained in *\Assets\Python

Text in green are the additions, the rest is Vanilla code. No other changes done, only added.

In CvDebugTools.py:

Code:
	def wonderMovie( self ):
		'ShowWonder Movie'
		popup = CyPopup(CvUtil.EventShowWonder, EventContextTypes.EVENTCONTEXT_ALL, True)
		popup.setHeaderString( "Wonder Movie", CvUtil.FONT_CENTER_JUSTIFY )
		popup.createPullDown(0)
[COLOR="green"]		#DOANE Wonder Movie Fix: Check for no selection to avoid crashes if movie list is None
		popup.addPullDownString( "NONE", -1, 0 ) #Add no Movie as default selection (ID = -1)
		#END DOANE[/COLOR]
		for i in range(gc.getNumBuildingInfos()):
			szMovieFile = gc.getBuildingInfo(i).getMovie()
			if (szMovieFile != None and len(szMovieFile) > 0):
				popup.addPullDownString( gc.getBuildingInfo(i).getDescription(), i, 0 )
[COLOR="green"]		#DOANE Wonder Movie Fix
		popup.addSeparator()
		popup.addButton("Cancel")
		popup.addSeparator()
		#END DOANE[/COLOR]
		
		popup.launch(true, PopupStates.POPUPSTATE_IMMEDIATE)

In CvEventManager.py:

Code:
	def __eventShowWonderApply(self, playerID, netUserData, popupReturn):
		'Wonder Movie Apply'
		[COLOR="green"]#DOANE Wonder Movie Fix: Check for no selection to avoid crashes if movie list is NULL
		autoIdx = popupReturn.getButtonClicked()
		wonderID = popupReturn.getSelectedPullDownValue( 0 )
		if (autoIdx == 0): #Cancel button
			return
		if (wonderID == -1): #If no Movie is selected (ID = -1), exit
			return
		#END DOANE[/COLOR]
		if (getChtLvl() > 0):
			CvDebugTools.CvDebugTools().applyWonderMovie( (popupReturn) )
 
lol.. I thought this was something already well known.

It would be nice to make a popup screen noting the progress between Eras ("You have entered the Age of Exploration", etc) like in regular Civ4.
That is already done in DOANE, but I think it was implemented via DLL but not sure right now...

Anyway if you want to do it in python it should be even more simple! The popup only needs an image and that's just 1 line of code, because the "ok" button is always added by default!
 
lol.. I thought this was something already well known.
Really ? :eek:
I often open the World Builder and the python Console but thats quite it ... (Edit: Are there other hidden popups, Isabelxxx?)

I didn't know it was possible to launch popups either :cool: It would be nice to make a popup screen noting the progress between Eras ("You have entered the Age of Exploration", etc) like in regular Civ4.
Yes, it would be nice... (Edit: This could be considered as an achievement)

That is already done in DOANE, but I think it was implemented via DLL but not sure right now...

Anyway if you want to do it in python it should be even more simple! The popup only needs an image and that's just 1 line of code, because the "ok" button is always added by default!
You're right! In BtS, it's a python screen:
Spoiler :
Code:
## Sid Meier's Civilization 4
## Copyright Firaxis Games 2005
from CvPythonExtensions import *
import PyHelpers
import CvUtil
import ScreenInput
import CvScreenEnums
import string

PyPlayer = PyHelpers.PyPlayer
PyInfo = PyHelpers.PyInfo

# globals
gc = CyGlobalContext()
ArtFileMgr = CyArtFileMgr()
localText = CyTranslator()

class CvEraMovieScreen:
	"Wonder Movie Screen"
	def interfaceScreen (self, iEra):
		
		self.X_SCREEN = 100
		self.Y_SCREEN = 40
		self.W_SCREEN = 775
		self.H_SCREEN = 660
		self.Y_TITLE = self.Y_SCREEN + 20
		
		self.X_EXIT = self.X_SCREEN + self.W_SCREEN/2 - 50
		self.Y_EXIT = self.Y_SCREEN + self.H_SCREEN - 50
		self.W_EXIT = 120
		self.H_EXIT = 30
		
		if (CyInterface().noTechSplash()):
			return 0
				
		player = PyPlayer(CyGame().getActivePlayer())
			
		screen = CyGInterfaceScreen( "EraMovieScreen" + str(iEra), CvScreenEnums.ERA_MOVIE_SCREEN)
		screen.addPanel("EraMoviePanel", "", "", true, true,
			self.X_SCREEN, self.Y_SCREEN, self.W_SCREEN, self.H_SCREEN, PanelStyles.PANEL_STYLE_MAIN)
		
		screen.showWindowBackground(True)
		screen.setRenderInterfaceOnly(False);
		screen.setSound("AS2D_NEW_ERA")
		screen.showScreen(PopupStates.POPUPSTATE_MINIMIZED, False)
                		
		# Header...
		szHeader = localText.getText("TXT_KEY_ERA_SPLASH_SCREEN", (gc.getEraInfo(iEra).getTextKey(), ))
		szHeaderId = "EraTitleHeader" + str(iEra)
		screen.setText(szHeaderId, "Background", szHeader, CvUtil.FONT_CENTER_JUSTIFY,
			       self.X_SCREEN + self.W_SCREEN / 2, self.Y_TITLE, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
		
		screen.setButtonGFC("EraExit" + str(iEra), localText.getText("TXT_KEY_MAIN_MENU_OK", ()), "", self.X_EXIT, self.Y_EXIT, self.W_EXIT, self.H_EXIT, WidgetTypes.WIDGET_CLOSE_SCREEN, -1, -1, ButtonStyles.BUTTON_STYLE_STANDARD )
		
		# Play the movie
		if iEra == 1:
			szMovie = "Art/Movies/Era/Era01-Classical.dds"
		elif iEra == 2:
			szMovie = "Art/Movies/Era/Era02-Medeival.dds"
		elif iEra == 3:
			szMovie = "Art/Movies/Era/Era03-Renaissance.dds"
		elif iEra == 4:
			szMovie = "Art/Movies/Era/Era04-Industrial.dds"
		else:
			szMovie = "Art/Movies/Era/Era05-Modern.dds"

		screen.addDDSGFC("EraMovieMovie" + str(iEra), szMovie, self.X_SCREEN + 27, self.Y_SCREEN + 50, 720, 540, WidgetTypes.WIDGET_GENERAL, -1, -1 )
				
		return 0
		
	# Will handle the input for this screen...
	def handleInput (self, inputClass):
		return 0

	def update(self, fDelta):
		return
 
Top Bottom