EmperorFool
Deity
Yes, I found the same thing. And restarting Civ doesn't get rid of the ghost icons for you? It did for me. I'll see if I can fix this before we do the whole PLE rewrite thing.
Revision 1867 - updated UnitPlotListUtil.py with more stuff. While it only contains the promoframe at the moment, I think it is time to start folding this into the maininterface.I've started the coding for the UnitPlotList enhancements. I've committed the UnitPlotListUtil.py file (revision 1866).
Revision 1867 - updated UnitPlotListUtil.py with more stuff. While it only contains the promoframe at the moment, I think it is time to start folding this into the maininterface.
Would CIV still read/recognize the python files if they were compiled into .pyc files?
I was just going to ruin my local copy. But I would value your 2c if you have time to take a quick look at what I have committed.As per our other discussion, definitely do not fold this into BUG at this time--way too risky and also incomplete. Feel free to create a branch in SVN for this work, however, and go to town.
localText = CyTranslator()
iLeaderPromo = gc.getInfoTypeForString('PROMOTION_LEADER')
sFileNamePromo = ArtFileMgr.getInterfaceArtInfo("OVERLAY_PROMOTION_FRAME").getPath()
screen = CyGInterfaceScreen( "MainInterface", CvScreenEnums.MAIN_INTERFACE )
# constants
sUpdateShow = "SHOW"
sUpdateShowIf = "SHOWIF"
sUpdateHide = "HIDE"
sUpdateNothing = "NOTHING"
(
sUpdateShow,
sUpdateShowIf,
sUpdateHide,
sUpdateNothing,
) = range(4)
def updatePLEOptions():
# Capture these for looping over the plot's units
self.bShowWoundedIndicator = PleOpt.isShowWoundedIndicator()
...
bShowWoundedIndicator = False
...
def updatePLEOptions():
global bShowWoundedIndicator, ...
bShowWoundedIndicator = PleOpt.isShowWoundedIndicator()
...
NUM_PLE_OPTIONS = 7
(
WOUNDED_DOT,
HEALTH_BAR,
MOVE_BAR,
GG_INDICATOR,
PROMO_INDICATOR,
UPGRADE_INDICATOR,
MISSION_TAG,
) = range(NUM_PLE_OPTIONS)
PLE_OPTION_MAP = {
WOUNDED_DOT: PleOpt.isShowWoundedIndicator, # note no () after function
HEALTH_BAR: PleOpt.isShowHealthBar,
...
}
pleOptions = [False] * NUM_PLE_OPTIONS
def updatePLEOptions():
for element, option in PLE_OPTION_MAP.iteritems():
pleOptions[element] = option()
## - the vanilla BtS unit plot list has a panel for each row of icons and the units are arranged from the bottom left
## - the PLE unit plot list has no panel (drawn straight onto the screen) and counts from the top left (when in standard format)
## - the BUG unit plot list has one big panel and counts from the bottom left
## - this means that the max'th row fills up first, then the max'th-1, etc.
class UnitList:
def __init__(self, vScreen, vCols, vRows, yRes):
screen = vScreen
iCols = vCols
iRows = vRows
...
self.screen= vScreen
self.iCols = vCols
...
self.iCols = iCols
iCols = iCols
_x = 315 - 3
_y = yRes - 169 - 3 + (1 - vRows) * 34
_w = vCols * 34 + 3
_h = vRows * 34 + 3
class UnitPlot:
def __init__(self, vBupPanel, iIndex, x, y):
sBupString = sBupStringBase + str(iIndex)
xPixel = _getxPixel(x)
[B]yPixel = _getyPixel(x)[/B]
# add promo frame
screen.addDDSGFCAt(sBupString + "PromoFrame", vBupPanel, sFileNamePromo, xPixel + 2, yPixel + 2, 32, 32, WidgetTypes.WIDGET_PLOT_LIST, iIndex, -1, False )
screen.hide(sBupString + "PromoFrame")
def _getxPixel(self, x):
return x * 34 + 3
_updatePromo(sBupString + "PromoFrame", pCurrUnit, pPrevUnit, sUpdateHide)
_updatePromo(sBupString + "PromoFrame", pCurrUnit, pPrevUnit, sUpdateNothing)
_updatePromo(sBupString + "PromoFrame", pCurrUnit, pPrevUnit, sUpdateShowIf)
_updatePromo(sBupString + "PromoFrame", pCurrUnit, pPrevUnit, sUpdateShow)
if not pCurrUnit:
if not pPrevUnit:
# both have no unit, nothing to do
else:
# empty -> full
_drawPromo()
else:
if not pPrevUnit:
# full -> empty
_hidePromo()
else:
# both full
_updatePromo() # this function doesn't do anything, but e.g. mission tag updates the image
def _getPromoString():
return self.sBupString + "PromoFrame"
def _drawPromo():
if self.pCurrUnit.bPromo:
self._showPromo()
def _updatePromo():
if self.pCurrUnit.bPromo and not self.pPrevUnit.bPromo:
self._showPromo()
elif not self.pCurrUnit.bPromo and self.pCurrUnit.bPromo:
self._hidePromo()
def _hidePromo():
if self.pPrevUnit.bPromo:
self.screen.hide(_getPromoString())
def _showPromo():
self.screen.show(_getPromoString())
self.bMoved = pUnit...
self.bInjured = pUnit...
if pPrevUnit:
if pCurrUnit:
# both full
for element in elements:
element.update(pPrevUnit, pCurrUnit)
else:
# full -> empty
for element in elements:
element.hide(pPrevUnit)
else:
if pCurrUnit:
# empty -> full
for element in elements:
element.draw(pPrevUnit)
else:
# both empty
# do nothing
Code:## - the vanilla BtS unit plot list has a panel for each row of icons and the units are arranged from the bottom left ## - the PLE unit plot list has no panel (drawn straight onto the screen) and counts from the top left (when in standard format) ## - the BUG unit plot list has one big panel and counts from the bottom left ## - this means that the max'th row fills up first, then the max'th-1, etc.
I would consider normalizing the use of y to be the same for all, with 0 at the bottom and increasing toward the top of the screen (or vice versa) to make the code much easier. You'll be writing all the code essentially from scratch by pulling pieces from CvMI and modifying it, so you may as well make that easier and reuse as much as possible.
I totally agree with your comments and have noted them down. However, I am 100% sure that I have no idea how to even approach this. My thinking was to get promo frame up and running and then to see if I can extract that do a create() function. I guess I am putting off what I have no idea how to do while I work on something that I have a 25% idea about.Code:# add promo frame screen.addDDSGFCAt(sBupString + "PromoFrame", vBupPanel, sFileNamePromo, xPixel + 2, yPixel + 2, 32, 32, WidgetTypes.WIDGET_PLOT_LIST, iIndex, -1, False ) screen.hide(sBupString + "PromoFrame")
This should be extracted to a create() function. I think here is where you have a great opportunity for abstraction and generalization that will save you a lot of coding. Create a separate object for each element. I'll write more about this tomorrow as it will get pretty complex.
Part of me agrees, but the PLE action is to actually show the 'top' unit at the top left, while the vanilla BtS action is to show the 'top' unit at the bottom right.
My thinking was to get promo frame up and running and then to see if I can extract that do a create() function.
This looks like the bug that we saw the other day. I've got a solution for this that I will fold into the SVN version of BUG.the "stuck" icons were pretty much just like normal unit icons.. but they weren't tied to a unit, and are always on screen. when you select a stack they get mixed into that stack, and when no stack is selected they are still on screen. selecting them puts a yellow border around them, but they dont do anything beyond that.
dont think i had any filters on at the time.
try it. turn off PLE mid-game and you'll start seeing some units always on the interface.
I was working on this a little over the week end. I think some of the above is redundant so I put it in as follows:Code:def _drawPromo(): if self.pCurrUnit.bPromo: self._showPromo() def _updatePromo(): if self.pCurrUnit.bPromo and not self.pPrevUnit.bPromo: self._showPromo() elif not self.pCurrUnit.bPromo and self.pCurrUnit.bPromo: self._hidePromo() def _hidePromo(): if self.pPrevUnit.bPromo: self.screen.hide(_getPromoString()) def _showPromo(): self.screen.show(_getPromoString())
def _updatePromo():
if not self.pPrevUnit.bPromo:
self._showPromo()
elif not self.pCurrUnit.bPromo:
self._hidePromo()
def _hidePromo():
if self.pPrevUnit.bPromo:
self.screen.hide(_getPromoString())
def _showPromo():
if self.pCurrUnit.bPromo:
self.screen.show(_getPromoString())
ok, fair enough. However ... Q: Should 'update' show or hide or should it draw or erase?
if not pCurrUnit:
if not pPrevUnit:
# both have no unit, nothing to do
else:
# empty -> full
draw(pCurrUnit)
else:
if not pPrevUnit:
# full -> empty
hide(pPrevUnit)
else:
# both full
update(pPrevUnit, pCurrUnit)