Rearranging the order that appears in the city queue

You need to convert from the BuildingClassTypes to the civ's actual building for one thing:

Code:
civInfo = gc.getCivilzationInfo(gc.getPlayer(gc.getGame().getActivePlayer()).getCivilizationType())
for i in range(gc.getNumBuildingClassInfos()):
    eBuilding = civInfo.getCivilizationBuildings(i) # or whatever this is
    info = gc.getBuildingInfo(eBuilding)
    # add (info.getDescription(), eBuilding) to list

This way your list is sorted by the actual building's name (Mint) rather than the generic building's name (Forge).
 
Hmm, well now I get a new exception about this line:

Code:
g_buildings.append(info.getDescription(), eBuilding)

It says that I am giving it 2 arguments, when it only takes 1.
 
You need to append a single tuple instead of two values:

Code:
g_buildings.append([B][COLOR="Red"]([/COLOR][/B]info.getDescription(), eBuilding[B][COLOR="Red"])[/COLOR][/B])
 
You need to append a single tuple instead of two values:

Code:
g_buildings.append([B][COLOR=Red]([/COLOR][/B]info.getDescription(), eBuilding[B][COLOR=Red])[/COLOR][/B])

Great, now I get a cascading failure. How do I convert the tuple back to the eBuilding value I want?
Spoiler :

ERR: Python function forceScreenRedraw failed, module CvScreensInterface
Traceback (most recent call last):

File "CvScreensInterface", line 983, in forceScreenRedraw

File "CvMainInterface", line 3279, in redraw

File "CvMainInterface", line 4474, in updateSelectionButtons

ArgumentError: Python argument types in
CvPythonExtensions.isLimitedWonderClass(tuple)
did not match C++ signature:
isLimitedWonderClass(int)
ERR: Python function forceScreenRedraw failed, module CvScreensInterface
Traceback (most recent call last):

File "CvScreensInterface", line 983, in forceScreenRedraw

File "CvMainInterface", line 3279, in redraw

File "CvMainInterface", line 4474, in updateSelectionButtons

ArgumentError: Python argument types in
CvPythonExtensions.isLimitedWonderClass(tuple)
did not match C++ signature:
isLimitedWonderClass(int)
ERR: Python function forceScreenRedraw failed, module CvScreensInterface
Traceback (most recent call last):

File "CvScreensInterface", line 983, in forceScreenRedraw

File "CvMainInterface", line 3279, in redraw

File "CvMainInterface", line 4474, in updateSelectionButtons

ArgumentError: Python argument types in
CvPythonExtensions.isLimitedWonderClass(tuple)
did not match C++ signature:
isLimitedWonderClass(int)
ERR: Python function forceScreenRedraw failed, module CvScreensInterface
Traceback (most recent call last):

File "CvScreensInterface", line 983, in forceScreenRedraw

File "CvMainInterface", line 3279, in redraw

File "CvMainInterface", line 4474, in updateSelectionButtons

ArgumentError: Python argument types in
CvPythonExtensions.isLimitedWonderClass(tuple)
did not match C++ signature:
isLimitedWonderClass(int)
ERR: Python function forceScreenRedraw failed, module CvScreensInterface
Traceback (most recent call last):

File "CvScreensInterface", line 983, in forceScreenRedraw

File "CvMainInterface", line 3279, in redraw

File "CvMainInterface", line 4474, in updateSelectionButtons

ArgumentError: Python argument types in
CvPythonExtensions.isLimitedWonderClass(tuple)
did not match C++ signature:
isLimitedWonderClass(int)
ERR: Python function forceScreenRedraw failed, module CvScreensInterface
Traceback (most recent call last):

File "CvScreensInterface", line 983, in forceScreenRedraw

File "CvMainInterface", line 3279, in redraw

File "CvMainInterface", line 4474, in updateSelectionButtons

ArgumentError: Python argument types in
CvPythonExtensions.isLimitedWonderClass(tuple)
did not match C++ signature:
isLimitedWonderClass(int)
ERR: Python function forceScreenRedraw failed, module CvScreensInterface
Traceback (most recent call last):

File "CvScreensInterface", line 983, in forceScreenRedraw

File "CvMainInterface", line 3279, in redraw

File "CvMainInterface", line 4474, in updateSelectionButtons

ArgumentError: Python argument types in
CvPythonExtensions.isLimitedWonderClass(tuple)
did not match C++ signature:
isLimitedWonderClass(int)
ERR: Python function forceScreenRedraw failed, module CvScreensInterface
Traceback (most recent call last):

File "CvScreensInterface", line 983, in forceScreenRedraw

File "CvMainInterface", line 3279, in redraw

File "CvMainInterface", line 4474, in updateSelectionButtons

ArgumentError: Python argument types in
CvPythonExtensions.isLimitedWonderClass(tuple)
did not match C++ signature:
isLimitedWonderClass(int)
ERR: Python function forceScreenRedraw failed, module CvScreensInterface
Traceback (most recent call last):

File "CvScreensInterface", line 983, in forceScreenRedraw

File "CvMainInterface", line 3279, in redraw

File "CvMainInterface", line 4474, in updateSelectionButtons

ArgumentError: Python argument types in
CvPythonExtensions.isLimitedWonderClass(tuple)
did not match C++ signature:
isLimitedWonderClass(int)
ERR: Python function forceScreenRedraw failed, module CvScreensInterface
 
I guess, you try isLimitedWonderClass(g_buildings), right?
Change it to isLimitedWonderClass(g_buildings[1]).


Still no dice, dispite that change. It tells me that it is invalid syntax on that line:
Code:
                global g_buildings
                if g_buildings is None:
                    g_buildings = []
                    civInfo = gc.getCivilizationInfo(pHeadSelectedCity.getCivilizationType())
                    for i in range(gc.getNumBuildingClassInfos()):
                        eBuilding = civInfo.getCivilizationBuildings(i)
                        info = gc.getBuildingInfo(eBuilding)
                        g_buildings.append((info.getDescription(), eBuilding))
                    g_buildings.sort()
                for i in g_buildings:
                    if (not isLimitedWonderClass(g_buildings[i][1]):
                        eLoopBuilding = gc.getCivilizationInfo(pHeadSelectedCity.getCivilizationType()).getCivilizationBuildings(g_buildings[i][1])

                        if (pHeadSelectedCity.canConstruct(eLoopBuilding, False, True, False)):
                            screen.appendMultiListButton( "BottomButtonContainer", gc.getBuildingInfo(eLoopBuilding).getButton(), iRow, WidgetTypes.WIDGET_CONSTRUCT, g_buildings[i][1], -1, False )
                            screen.show( "BottomButtonContainer" )
                            
                            if ( not pHeadSelectedCity.canConstruct(eLoopBuilding, False, False, False) ):
                                screen.disableMultiListButton( "BottomButtonContainer", iRow, iCount, gc.getBuildingInfo(eLoopBuilding).getButton() )

                            iCount = iCount + 1
                            bFound = True

                iCount = 0
                if (bFound):
                    iRow = iRow + 1
                bFound = False
 
Ups, isLimitedWonderClass needs a buildingsclasstype (if i see that right), not a building.
Try:
isLimitedWonderClass(gc.getBuildingInfo(g_buildings[1]).getBuildingClassType())


Hmm that worked, sort of. I get no more python exceptions, but my city interface is gone. The rest of the UI is fine. I have no idea what's causing it.
 
Well, we're back to the original problem. The interface magically started working again (I reloaded the game and it was there, when I had not edited the python one bit), but there are no buildings in the city queue. A check of the logs show that 0 buildings got put in the list, so g_buildings was empty. I thought we stopped this with the None setting... grr.
 
Don't convert to the civilization's building in the second loop as you've already done that in the first loop. Instead, eLoopBuilding is i.
 
Don't convert to the civilization's building in the second loop as you've already done that in the first loop. Instead, eLoopBuilding is i.

Sure, but that shouldn't affect anything, it's just a waste of CPU.
 
I can't tell what your code looks like now, so let me be clear:

Code:
for [B][COLOR="Red"]_, eLoopBuilding[/COLOR][/B] in g_buildings:
    if (not isLimitedWonderClass([B][COLOR="Red"]gc.getBuildingType(eLoopBuilding).getBuildingClassType()[/COLOR][/B])):
        [s][COLOR="Red"]eLoopBuilding = gc.getCivilizationInfo(pHeadSelectedCity.getCivilizationType()).getCivilizationBuildings(g_buildings[i][1])[/COLOR][/s]
 
I can't tell what your code looks like now, so let me be clear:

Code:
for [B][COLOR=Red]_, eLoopBuilding[/COLOR][/B] in g_buildings:
    if (not isLimitedWonderClass([B][COLOR=Red]gc.getBuildingType(eLoopBuilding).getBuildingClassType()[/COLOR][/B])):
        [s][COLOR=Red]eLoopBuilding = gc.getCivilizationInfo(pHeadSelectedCity.getCivilizationType()).getCivilizationBuildings(g_buildings[i][1])[/COLOR][/s]

My code:
Code:
                global g_buildings
                if g_buildings is None:
                    g_buildings = []
                    civInfo = gc.getCivilizationInfo(pHeadSelectedCity.getCivilizationType())
                    for i in range(gc.getNumBuildingClassInfos()):
                        eBuilding = civInfo.getCivilizationBuildings(i)
                        info = gc.getBuildingInfo(eBuilding)
                        g_buildings.append((info.getDescription(), eBuilding))
                    g_buildings.sort()
                for i, eLoopBuilding in g_buildings:
                    if (not isLimitedWonderClass(gc.getBuildingType(eLoopBuilding).getBuildingClassType())):
                        if (pHeadSelectedCity.canConstruct(eLoopBuilding, False, True, False)):
                            screen.appendMultiListButton( "BottomButtonContainer", gc.getBuildingInfo(eLoopBuilding).getButton(), iRow, WidgetTypes.WIDGET_CONSTRUCT, eLoopBuilding, -1, False )
                            screen.show( "BottomButtonContainer" )
                            
                            if ( not pHeadSelectedCity.canConstruct(eLoopBuilding, False, False, False) ):
                                screen.disableMultiListButton( "BottomButtonContainer", iRow, iCount, gc.getBuildingInfo(eLoopBuilding).getButton() )

                            iCount = iCount + 1
                            bFound = True

                iCount = 0
                if (bFound):
                    iRow = iRow + 1
                bFound = False

I followed your instructions to the T. I don't get any python exceptions. But no buildings.
 
My advice is always going to be the same in these situations: add debugging output to see what's happening. There's no point staring at code for more than a couple minutes hoping the solution will jump out at you. You'll go nuts. Instead, add some pyPrint() calls in the first loop, after sorting, while adding buttons, anywhere you don't know what's going on.
 
Top Bottom