Quick Modding Questions Thread

The file Assets\python\pyHelper\Popup.py has a function setsize. I suggest to try to modify that.

Thanks I tried altering the values, but unfortunately it messed the in game interface entirely so that all the boxes in the bottom of the screen in the main interface was not visible anymore. I am
total noob to python so bear with me :) i should just add values to:

def setSize(self, iXS, iYS):
"sets the popups size"
self.popup.setSize(iXS, iYS)

Did you have any success Nexus?
 
As far as I can tell changing the values in the popup.py didn't do much on its own other than make the main interface not work. This mod I am using has BUG implemented, not sure whether that is a factor. It seems like the popup
is the same format as the main menu and other popups that do not have specific screens that are modified via their own python-files.
 
Could you paste the python code? It may just be a missing indentation which then causes a Python exception which then in turn causes the rest of the script execution to be aborted.

To set yourself up for success :) with respect to Python modding, observe the following tips:

- Ensure that your code editor is set up to use either tabs or spaces, depending on what the py
file does
- Keep an eye on the Python exception logs ( Logs\PythonErr2.log )
- Turn on (i.e. "unhide) python exception popups in the ini file:
Code:
; Set to 1 for no python exception popups
HidePythonExceptions = 0
 
Last edited:
Not strictly a modding question but one I need answered to upload my work. When I upload a file to google drive people can't download it unless I manually give them permission through an email that the drive sends me. This is obviously not practical so can anyone tell me how the hell I can turn it off and make it so that everyone can just download it freely?

I tried searching the internet but did not find any solutions that do not refer to menu options that no longer exist.
 
Could you paste the python code? It may just be a missing indentation which then causes a Python exception which then in turn causes the rest of the script execution to be aborted.

To set yourself up for success :) with respect to Python modding, observe the following tips:

- Ensure that your code editor is set up to use either tabs or spaces, depending on what the py
file does
- Keep an eye on the Python exception logs ( Logs\PythonErr2.log )
- Turn on (i.e. "unhide) python exception popups in the ini file:
Code:
; Set to 1 for no python exception popups
HidePythonExceptions = 0

Code editor? Why I use notepad strictly :D I just changed the values suggested by Sephi:

## Sid Meier's Civilization 4
## Copyright Firaxis Games 2005
import CvUtil
from CvPythonExtensions import *

class PyPopup:
############## S E T U P F U N C T I O N S ###################
def __init__(self, popupID=-1, contextType=EventContextTypes.NO_EVENTCONTEXT, bDynamic = True):
self.ID = popupID
self.popup = CyPopup(popupID, contextType, bDynamic)

# Misc!

def isNone(self):
"verifies valid instance"
return self.popup.isNone()

def launch(self, bCreateOkButton = True, eState = PopupStates.POPUPSTATE_IMMEDIATE):
"sets attributes to the popup launch"
self.popup.launch(bCreateOkButton, eState)

def setUserData(self, userData):
"sets userData that is passed to OnOkClicked"
self.popup.setUserData(userData)

def setPosition(self, iX, iY):
"set the location of the popup"
self.popup.setPosition(iX, iY)

def setSize(self, 512, 512):
"sets the popups size"
self.popup.setSize(iXS, iYS)


It resulted in a "blank" interface, I realise that other values probably have to be adapted:

upload_2022-2-5_22-5-4.png

I am thinking maybe the position would have to be adapted, it seems like if I enlarge event picture as I did, it created a scroll bar vertically, but the popup was "locked" horizontally
which is interesting.

Edit: I didn't register a python error in the logs as far as I can tell
 
Not strictly a modding question but one I need answered to upload my work. When I upload a file to google drive people can't download it unless I manually give them permission through an email that the drive sends me. This is obviously not practical so can anyone tell me how the hell I can turn it off and make it so that everyone can just download it freely?

I tried searching the internet but did not find any solutions that do not refer to menu options that no longer exist.
Google drive ssss... something not so good.
I suggest you try mega.nz or dropbox. Both are great, simple and free (with a limit of course).
 
Google drive ssss... something not so good.
I suggest you try mega.nz or dropbox. Both are great, simple and free (with a limit of course).
I know it's ***ptastic but I really can't be bothered to register for yet another website if I can help it. :)
 
I know it's ***ptastic but I really can't be bothered to register for yet another website if I can help it. :)
Oh, I know that feeling. :lol: You have to register to use something but registering pretty complicated: You cannot pick the name of your choice and your password...
Spoiler :

 
Thanks I tried altering the values, but unfortunately it messed the in game interface entirely so that all the boxes in the bottom of the screen in the main interface was not visible anymore. I am
total noob to python so bear with me :) i should just add values to:

def setSize(self, iXS, iYS):
"sets the popups size"
self.popup.setSize(iXS, iYS)

Did you have any success Nexus?

I don't think altering this function is going to actually do what you want. This function is a definition, and is only used when you are hand-creating a popup window. An example is the Change All Plots popup in WorldBuilder. If you look at CvWorldBuilderScreen.py, that popup calls a setsize function early on and then calls the launch function at the very end.

Code:
    def allPlotsCB(self):
       self.m_normalPlayerTabCtrl.enable(False)
       self.m_normalMapTabCtrl.enable(False)
       if (self.m_tabCtrlEdit != 0):
           self.m_tabCtrlEdit.enable(False)

       popup=PyPopup.PyPopup(CvUtil.EventWBAllPlotsPopup, EventContextTypes.EVENTCONTEXT_ALL)
       iPopupWidth = 200
       iPopupHeight = 50*PlotTypes.NUM_PLOT_TYPES
       popup.setSize(iPopupWidth, iPopupHeight)

       popup.setHeaderString(localText.getText("TXT_KEY_WB_CHANGE_ALL_PLOTS",()))

       for i in range (PlotTypes.NUM_PLOT_TYPES):
           if (i==0):
               popup.addButton(localText.getText("TXT_KEY_WB_ADD_MOUNTAIN",()))
           elif(i==1):
               popup.addButton(localText.getText("TXT_KEY_WB_ADD_HILL",()))
           elif(i==2):
               popup.addButton(localText.getText("TXT_KEY_WB_ADD_GRASS",()))
           elif(i==3):
               popup.addButton(localText.getText("TXT_KEY_WB_ADD_OCEAN",()))

       popup.addButton(localText.getText("TXT_KEY_SCREEN_CANCEL", ()))
       popup.launch(False)
       return 1

I tried looking into this because I thought it was interesting, but I can't seem to find anything that governs the width of that box. I am convinced that it's an overall popup box and not just for events, because I tried two different screen resolutions and the event pop-up box at one resolution and the convert religion box at a different resolution were both 400 pixels wide. The only places in the code that I can find a 400 that look relevent are TURN_LOG_MAX_WIDTH in GlobalDefines.xml and iGlobeLayerOptionsWidth in CvMainInterface.py, but fiddling with those didn't seem to do anything.
 
For what it's worth, this is apparently how BULL launches the random event popup (CvDLLButtonPopup.cpp):
Spoiler :
Code:
// BUG - Events with Images - start
if (getBugOptionBOOL("MainInterface__EventsWithImages", false, "BUG_EVENTS_WITH_IMAGES") == true)
{
   if (kTrigger.getEventArt())
   {   // (DLL interface of the EXE)
       gDLL->getInterfaceIFace()->popupAddDDS(pPopup, kTrigger.getEventArt());
   }
}
// BUG - Events with Images - end
CvDLLInterfaceIFaceBase:: popupAddDDS has some optional parameters:
Code:
int iWidth = 0, int iHeight = 0, CvWString szHelpText = ""
I suspect that those are only for scaling the image and that the popup figures out its own size, and that there are fixed dimensions or an upper limit in the EXE. But I haven't tested it and also haven't tested whether the EXE calls any PyPopup methods (pyHelper\Popup.py), i.e. setSize or addDDS.
def setSize(self, 512, 512):
"sets the popups size"
self.popup.setSize(iXS, iYS)
It resulted in a "blank" interface, [...]
I don't think that's syntactically correct, so it should have resulted in an exception in PythonErr.log provided that logging is enabled in CivilizationIV.ini (and in an error popup when un-hidden through the INI). When large parts of the HUD aren't displayed, an uncaught Python exception is usually the cause.

If anything, a change to the last line, e.g.
self.popup.setSize(512, 512)
or
self.popup.setSize(2 * iXS, 2 * iYS)
should have the desired effect. But I expect that, if you place a
print "setSize was called"
at the end (and have logging enabled in the INI), you won't find that string printed in PythonDebug.log, i.e. I doubt that setSize gets called at all.
An example is the Change All Plots popup in WorldBuilder. If you look at CvWorldBuilderScreen.py, that popup calls a setsize function early on and then calls the launch function at the very end.
If a width greater than 400 can be accomplished that way, then maybe one could launch the random event popups through Python rather than the DLL. Would have to reimplement a few dozen lines of BtS code (for setting up all the components of the popup) in Python though, and change the DLL so that it invokes the Python code.
 
Thanks for all the help and investigative work on this, yes the eventimages-changes to the dll seem to use some "universal" popup-width that is used a lot by the game, and seems
to be very set in stone to 400 pixels, except for height. This is a strange design choice but probably made more sense for when the game was released originally.

If anything, a change to the last line, e.g.
self.popup.setSize(512, 512)
or
self.popup.setSize(2 * iXS, 2 * iYS)
should have the desired effect. But I expect that, if you place a
print "setSize was called"
at the end (and have logging enabled in the INI), you won't find that string printed in PythonDebug.log, i.e. I doubt that setSize gets called at all.
If a width greater than 400 can be accomplished that way, then maybe one could launch the random event popups through Python rather than the DLL. Would have to reimplement a few dozen lines of BtS code (for setting up all the components of the popup) in Python though, and change the DLL so that it invokes the Python code.

Yeah I did try several different variants, but nothing changed the width of the popup, it's a tough nut to crack!

But yes ideally having the popups through python would probably be the best option and "disconnect" that particular popup from the universal size-format, but I really like the neat feature of just putting a .dds file in the eventtriggers.xml. There are mods out there that seem to have done this (using python rather), someone pointed out FFH2 but I haven't tried that particular mod.
 
So it means, that we can still replace the 256x256 images with 400x400 ones, right?

Well sort of, but there is some space that have to be left in the margins and for the scroll bar, so more like 360x360 or something like that, but hey still an improvement over
256x256 :) I really like the random events for modding scenarios so I guess this is what we have to work with at the moment, I resized to 400x400 and the below result is what I got:

upload_2022-2-6_22-55-51.png
 
BTW, for a long time I've been thinking about replacing the current event images with bigger and nicer ones.
E.g. replace this:
Spoiler :
upload_2022-2-6_23-38-22.png

With this for example:
Spoiler :
upload_2022-2-6_23-41-26.png

Are you interested in starting such a project? :)
 
But yes ideally having the popups through python would probably be the best option and "disconnect" that particular popup from the universal size-format, but I really like the neat feature of just putting a .dds file in the eventtriggers.xml. There are mods out there that seem to have done this (using python rather), someone pointed out FFH2 but I haven't tried that particular mod.
Come to think of it, when re-implementing the popup in Python, one could also use a custom screen rather than a popup, akin to the tech splash screen. BAT, for example, has a GreatPersonScreen with dimensions
Code:
self.X_SCREEN = 255
self.Y_SCREEN = 40
self.W_SCREEN = 515
self.H_SCREEN = 570
for announcing Great Person births. But I'd agree that going down this road is a disproportionate effort. Although the 400x400 does look a little sad. Maybe landscape dimensions – like Nexus's example – would look better, if the scrollbar can be avoided that way.
 
Does anyone know what iNumCitiesAnarchyPercent does in Civ4WorldInfo?

That percentage multiplied with player's number of cities is the number of turns added to anarchy length when civic/religion change is made. (There are also other factors and modifiers in that whole calculation.)
 
If I am trying to make a unit "glow" like a Great General, what do I need to do other than inserting the nodes for the glow into the NIF? I have tried doing this and the unit model doesn't glow at all. I know the old Adventurer model in Rise of Mankind used to glow until I removed the glow nodes, and it doesn't use any of the Great Person KFM files at all, so I don't think it's that.
 
If I am trying to make a unit "glow" like a Great General, what do I need to do other than inserting the nodes for the glow into the NIF? I have tried doing this and the unit model doesn't glow at all. I know the old Adventurer model in Rise of Mankind used to glow until I removed the glow nodes, and it doesn't use any of the Great Person KFM files at all, so I don't think it's that.
As an example for copying the Warlord glow, additionally to copying the 'ATTACHABLE_HIGHLIGHT_WARLORD' node plus subnodes into the BIP structure of your unit, you will also need to copy the 'ATTACHABLES' node plus subnode to the 'MD NonAccum' node of your unit.

If you copy both nodes (plus subnodes) from the same original unit, all entries should already fit to each other. Otherwise, you will have to check their entries (for example, the entry of the 'NiStringExtraData' subnode of the 'ATTACHABLES' node). Further, if you want to have the glow appear or disappear for different animations, you will have to create entries in the respective kf file.

Hope this helps. :)
 
Top Bottom