def update(self, fDelta):
screen = CyGInterfaceScreen( "MainInterface", CvScreenEnums.MAIN_INTERFACE )
pHeadSelectedUnit = CyInterface().getHeadSelectedUnit()
bComplete = False
global g_ActionInfoIsUp
# This code is for mouseover info on the custom buttons
if (pHeadSelectedUnit and not CyEngine().isGlobeviewUp() and CyInterface().getShowInterface() != InterfaceVisibility.INTERFACE_HIDE_ALL and CyInterface().getShowInterface() != InterfaceVisibility.INTERFACE_MINIMAP_ONLY):
global g_ActionListOverflow
# Find out our resolution
xResolution = screen.getXResolution()
yResolution = screen.getYResolution()
mouseX = CyInterface().getMousePos().x
mouseY = CyInterface().getMousePos().y
# This is the area the big box the selection boxes can be in is
if ((yResolution - 160 - (57 * g_ActionListOverflow)) < mouseY < yResolution) and (296 < mouseX < (xResolution - 296)):
# Don't check the default buttons
numDefaults = len(CyInterface().getActionsToShow())
defaultPositions = []
bContinue = True
if numDefaults > 18:
return
while bContinue:
for Y in range(2):
for X in range (9):
if len(defaultPositions) < numDefaults:
defaultPositions.append((X, Y))
else:
bContinue = False
# Getting the button spacing/sizing
### THIS SIZING IS SPECIFIC TO MY INTERFACE ###
realWidth = xResolution - 592 - ((xResolution - 592)/11.5)
buttonSpacing = int(realWidth/8.7)
buttonSize = int(realWidth/9) - 4
notDefaults = []
addedButtons = ActionButtons.getButtons(pHeadSelectedUnit)
numAddedButtons = len(addedButtons)
iCount = 0
for iY in range(3):
for iX in range (9):
if (iCount < numAddedButtons) and ((iX, iY) not in defaultPositions):
buttonXmin = (296 + (xResolution - 592)/33 + (iX * buttonSpacing))
if (buttonXmin) <= mouseX <= (buttonXmin + buttonSize):
buttonYmin = yResolution - 107 + (57 * (iY - g_ActionListOverflow - 1)) + (48 - buttonSize)/2 # Dunno why there it is g_ActionListOverflow - 1. Too tired to work it out. It works though
if (buttonYmin) <= mouseY <= (buttonYmin + buttonSize):
if g_ActionInfoIsUp == iCount:
return
bComplete = True
szHelpText = "<font=2>"
szHelpText += "<color=100,225,255>"
szHelpText += u"%s" %addedButtons[iCount].getType()
szHelpText += "</color>"
szHelpText += u"\n"
szHelpText += u"%s" %addedButtons[iCount].getText()
szHelpText += "</font>"
# calculate panel heigth by examining the to be dispalyed text
# seperate the text into the chapters : everything between the line feeds
lChapters = szHelpText.split("\n")
nLines = 0
for iLoop in range(len(lChapters)):
# one line for each "\n"
nLines += 1
# another line for each n characters per chapter
nLines += int(CyInterface().determineWidth( lChapters[iLoop] )/259)
# transform the lines into pixels
yOffset = int(nLines*18)
szTextBlack = szHelpText
while szTextBlack.find("<color=") != -1:
iStartPos = szTextBlack.find("<color=")
iEndPos = szTextBlack.find(">", iStartPos)
szTextBlack = szTextBlack[:iStartPos]+szTextBlack[iEndPos+1:]
# replace color end sequence
szTextBlack = szTextBlack.replace("</color>", "")
szTextBlack = localText.changeTextColor(szTextBlack, gc.getInfoTypeForString("COLOR_BLACK"))
screen.addPanel( "MouseoverTextPanel", u"", u"", True, False, \
7, yResolution - 182 - yOffset, 269, yOffset + 10, \
PanelStyles.PANEL_STYLE_HUD_HELP )
screen.addMultilineText( "MouseoverTextShadow", szTextBlack, \
7 + 1 + 1, yResolution - 178 + 1 - yOffset, \
269 - 10, yOffset + 4, \
WidgetTypes.WIDGET_HELP_SELECTED, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
screen.addMultilineText( "MouseoverText", szHelpText, \
7 + 1, yResolution - 178 - yOffset, \
269 - 10, yOffset +4, \
WidgetTypes.WIDGET_HELP_SELECTED, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
screen.show( "MouseoverTextPanel" )
screen.show( "MouseoverTextShadow" )
screen.show( "MouseoverText" )
g_ActionInfoIsUp = iCount
#CyInterface().addImmediateMessage("Mouse is over custom button", "")
iCount += 1
if not (bComplete):
screen.hide("MouseoverTextPanel")
screen.hide( "MouseoverTextShadow" )
screen.hide("MouseoverText")
g_ActionInfoIsUp = -1
#CyInterface().addImmediateMessage("Mouse is NOT over custom button", "")
return