Python Performance and Interface Overhaul (PPIO)

I think I'm getting a crash using this when someone vassalizes another nation. I have to test more to make sure, though.
 
I would like to inspect your PythonErr.log file when such a crash occur, it should be in the logs folder which can be found within the C2C root folder.
Keep in mind that the log content is deleted every time you launch the game, so upload the log right after the crash without starting the game again.
 
@Toffer90
Is it possible to add right click functionality to unit/building/resource lists where applicable, so rightclicking them would open pedia on them?

For example I right click Forge/Settler/Iron on left/bottom/right side of city screen and it opens respective pedia entry.
On right and left there are lists and on bottom there are buildings/units, that are buildable (or not too, if you enabled showing buildings/units, that aren't buildable).

---
Resources are already rightclickable.
So only bottom and left sides can be made interactable
 
Last edited:
I'm not sure about the build queue, but I know I can make it so for the built buildings lists by redesigning the list completely on a technical level.
Doing so would also make the lists faster to create and draw on screen, so this is something I'm planning to do when I get my inspiration back.
 
I'm not sure about the build queue, but I know I can make it so for the built buildings lists by redesigning the list completely on a technical level.
Doing so would also make the lists faster to create and draw on screen, so this is something I'm planning to do when I get my inspiration back.
What about building/unit buttons, that adds buildings/units to build queue?
Is it possible to link those to pedia too, so rightclicking them would open appropriate pedia entry?

By the way is it possible to separate buildable/unbuildable buildings and units, so they wouldn't be mixed with each other?
 
What about building/unit buttons, that adds buildings/units to build queue?
Is it possible to link those to pedia too, so rightclicking them would open appropriate pedia entry?
Isn't that already the case?
By the way is it possible to separate buildable/unbuildable buildings and units, so they wouldn't be mixed with each other?
Sure.
 
I'm gonna start looking into optimizing the build screens stuff we talked about earlier, @Toffer90 . Is it okay if i build off of your minimod? You seem to have already done a lot of work on the MainScreen file already.

Also, is there any Type information on the 'screen' object in python? I'd like to know what parameters i can pass to functions and such.
 
Last edited:
I'm gonna start looking into optimizing the build screens stuff we talked about earlier, @Toffer90 . Is it okay if i build off of your minimod? You seem to have already done a lot of work on the MainScreen file already.
I'm somewhat ambivalent to there being a modmodmod to my modmod, there is a significant risk that we may step on each other toes, but on the other hand, all contributions are good for C2C.

I would like you to keep me informed through PM about what specific code sections you intend to work on.
I'm guessing you want to start within the updateSelectionButtons() function or perhaps work on the BuildListScreen.py file first.
Also, is there any Type information on the 'screen' object in python? I'd like to know what parameters i can pass to functions and such.
Do you mean information like what can be found in this LINK under the category "CyGInterfaceScreen" (search for it on page).
 
so, this thing is still in limbo in regards of making this part of the core? :(
 
I usually just set up relevant "print XYZ" commands around the code.
It then gets written to the pythonDbg.log file.
There are other ways too: e.g. so that the debug is written in the message panel within the game, but I don't remember the function for it off hand.
 
Last edited:
@Toffer90 hmm, i'm feeling a bit stuck. I've switched my BottomButtonContainer to a regular panel now. I'm looping through available units, and I have it like so:

eLoopUnit = pHeadSelectedCity.getUnitListType(iGroup, iPos)
screen.attachPanelAt("BottomButtonContainer", "unit_panel_" + str(iCount), "", "", False, False, PanelStyles.PANEL_STYLE_STANDARD, 0 + (60 * iCount), 0, 60, 60, WidgetTypes.WIDGET_GENERAL, GC.getUnitInfo(eLoopUnit).getUnitClassType(), -1)
screen.attachImageButton("unit_panel_" + str(iCount),"unit" + str(iCount),GC.getUnitInfo(eLoopUnit).getButton(),GenericButtonSizes.BUTTON_SIZE_CUSTOM,WidgetTypes.WIDGET_TRAIN,GC.getUnitInfo(eLoopUnit).getUnitClassType(),-1,False)
But none of the image buttons show up. Using regular attachPanel instead, they show up by in wrong size. Am I using attachPanelAt wrong? Does the X and Y parameters refer to X and Y of the parent panel? I'll keep working on it, but I would appreciate any help :)

Edit: Some more trials. I tried this code below:

screen.attachPanel("BottomButtonContainer", "unit_panel_" + str(iCount), "", "", False, False, PanelStyles.PANEL_STYLE_STANDARD)
screen.setPanelSize("unit_panel_" + str(iCount),0 + (60 * iCount),0,60,60)
screen.attachImageButton("unit_panel_" + str(iCount),"unit" + str(iCount),GC.getUnitInfo(eLoopUnit).getButton(),GenericButtonSizes.BUTTON_SIZE_46,WidgetTypes.WIDGET_TRAIN,GC.getUnitInfo(eLoopUnit).getUnitClassType(),-1,False)
And it almost works. It lays out the panels in correct size for a single frame, but then the panels expand to 1 panel per row, with a small height like < 10pixels.

Edit 2: Oops, had bVerticalLayout on parent panel. That fixes some of it. Still getting panels stretching to fill parent, even though size set to 60x60

Edit 3: Still can't get it to layout correctly, but i can definitely say that performance is vastly improved! clicks are instant now.

Edit 4: Stopping for the night. Tried using a table as parent instead. Didn't work out, as the cells don't seem to want to accept a panel as a child, only button I think?

Using Panel as parent, if VerticalLayout = true, any child panels don't seem to respect their widths, and just push out as far as they can, even when Scroll = true.
 
Last edited:
@Toffer90 hmm, i'm feeling a bit stuck. I've switched my BottomButtonContainer to a regular panel now. I'm looping through available units, and I have it like so:

eLoopUnit = pHeadSelectedCity.getUnitListType(iGroup, iPos)
screen.attachPanelAt("BottomButtonContainer", "unit_panel_" + str(iCount), "", "", False, False, PanelStyles.PANEL_STYLE_STANDARD, 0 + (60 * iCount), 0, 60, 60, WidgetTypes.WIDGET_GENERAL, GC.getUnitInfo(eLoopUnit).getUnitClassType(), -1)
screen.attachImageButton("unit_panel_" + str(iCount),"unit" + str(iCount),GC.getUnitInfo(eLoopUnit).getButton(),GenericButtonSizes.BUTTON_SIZE_CUSTOM,WidgetTypes.WIDGET_TRAIN,GC.getUnitInfo(eLoopUnit).getUnitClassType(),-1,False)
But none of the image buttons show up. Using regular attachPanel instead, they show up by in wrong size. Am I using attachPanelAt wrong? Does the X and Y parameters refer to X and Y of the parent panel? I'll keep working on it, but I would appreciate any help :)
Yeah, there's an issue with attaching something to an attachment panel, been there done that, it drove me crazy for an hour or two. ^^
The problem lies in the exe algorithm for automatically screen placement and size scaling of child UI object. If a child has automatic placement, then there will in many cases be issues if the child of the child also have automatic placement.
Panels attached to panels attached to panels work just fine, but there are combinations that the exe coding is not written for and it will simply not work the way we modders sometimes envision.
Use setImageButtonAt instead and increment the x and y manually for each button. Top left corner of parent UI object define the coordinate origin for the "setAt".

I usually avoid all the basic "attach" functions, "setAt" and "attachAt" are always more reliable as there is less "smart" code involved.
 
Last edited:
What about building/unit buttons, that adds buildings/units to build queue?
Is it possible to link those to pedia too, so rightclicking them would open appropriate pedia entry?
Isn't that already the case?
Checked in game, and right-clicking on the buttons in the city screen that add units and buildings to the build queue does open the pedia as it should.
Perhaps you mistyped something or were too unspecific for me to understand what you meant.
 
Back
Top Bottom