示例#1
0
def init():
    """Performs the one-time initialization of the BUG core and all mods."""
    global g_initDone
    if g_initDone:
        BugUtil.debug("BugInit - init() already complete")
        return
    if not CyGame().isFinalInitialized():
        BugUtil.debug("BugInit - game not fully initialized")
        return
    global g_initRunning
    if g_initRunning:
        BugUtil.warn("BugInit - init() already running")
        return
    g_initRunning = True

    BugUtil.debug("BugInit - initializing...")
    timer = BugUtil.Timer("BUG init")

    BugPath.init()
    timer.log("init paths").start()

    loadMod("init")
    BugCore.initDone()
    timer.log("read configs").start()

    callInits()
    timer.log("call inits/events")

    timer.logTotal()

    g_initDone = True
    g_initRunning = False
    return True
def _getRemoteRevision(url):
	"""
	Parses and returns the revision number from a remote SVN repository.
	
	The URL must be correctly escaped (+ for space, etc).
	A BugError exception is raised if the URL can't be connected to or it doesn't
	have the expected format.
	
	This function looks specifically for the string 'Revision: ####' anywhere
	in the first MAX_READ_LINES
	"""
	try:
		timer = BugUtil.Timer("SvnUtil.getRevision")
		try:
			BugUtil.debug("SvnUtil.getRevision - opening '%s'", url)
			web = urllib.urlopen(urllib.quote(url, "/:"))
			count = 0
			try:
				for line in web:
					result = REVISION_PATTERN.search(line)
					if result:
						BugUtil.debug("SvnUtil.getRevision - found '%s'", result.group())
						try:
							return int(result.group(1))
						except ValueError:
							raise BugUtil.BugError("invalid SVN revision format '%s'" 
									% result.group(1))
					count += 1
					if count > MAX_READ_LINES:
						return None
			finally:
				web.close()
		except IOError, e:
			raise BugUtil.BugError("failed to access SVN repository: %s" % str(e))
		return None
示例#3
0
def loadMod(name):
    """Load the given mod from its XML file using a custom parser."""
    path = BugPath.findAssetFile(name + ".xml", "Config")
    if path:
        BugUtil.debug("BugInit - loading mod %s...", name)
        parser = BugConfig.ConfigParser()
        timer = BugUtil.Timer("load mod")
        try:
            parser.parse(path)
        finally:
            timer.log(name)
    else:
        BugUtil.error("BugInit - cannot find XML file for mod %s", name)
示例#4
0
	def interfaceScreen(self):

		self.timer = BugUtil.Timer("MilAdv")
		
		# Create a new screen
		screen = self.getScreen()
		if screen.isActive():
			return

		# over-ride screen width, height
		self.W_SCREEN = screen.getXResolution() - 40
		self.X_SCREEN = (screen.getXResolution() - 24) / 2
		self.L_SCREEN = 20

		if self.W_SCREEN < 1024:
			self.W_SCREEN = 1024
			self.L_SCREEN = 0
		
		self.X_EXIT = self.W_SCREEN - 30
		#self.Y_EXIT = 726
		#self.H_SCREEN = screen.getYResolution()
			
		screen.setRenderInterfaceOnly(True);
		screen.showScreen(PopupStates.POPUPSTATE_IMMEDIATE, False)

		self.iActivePlayer = CyGame().getActivePlayer()
		if self.iScreen == -1:
			self.iScreen = UNIT_LOCATION_SCREEN

		# Set the background widget and exit button
		screen.addDDSGFC(self.BACKGROUND_ID, ArtFileMgr.getInterfaceArtInfo("MAINMENU_SLIDESHOW_LOAD").getPath(), 0, 0, self.W_SCREEN, self.H_SCREEN, WidgetTypes.WIDGET_GENERAL, -1, -1 )
		screen.addPanel( "TechTopPanel", u"", u"", True, False, 0, 0, self.W_SCREEN, 55, PanelStyles.PANEL_STYLE_TOPBAR )
		screen.addPanel( "TechBottomPanel", u"", u"", True, False, 0, 713, self.W_SCREEN, 55, PanelStyles.PANEL_STYLE_BOTTOMBAR )
		screen.showWindowBackground( False )
		#screen.setDimensions(screen.centerX(0), screen.centerY(0), self.W_SCREEN, self.H_SCREEN)
		screen.setDimensions(self.L_SCREEN, screen.centerY(0), self.W_SCREEN, self.H_SCREEN)
		screen.setText(self.EXIT_ID, "Background", u"<font=4>" + localText.getText("TXT_KEY_PEDIA_SCREEN_EXIT", ()).upper() + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXIT, self.Y_EXIT, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_CLOSE_SCREEN, -1, -1 )

		# Header...
		screen.setLabel(self.HEADER_ID, "Background", u"<font=4b>" + localText.getText("TXT_KEY_MILITARY_ADVISOR_TITLE", ()).upper() + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, self.X_SCREEN, self.Y_TITLE, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
		
		self.iconGrid = None
		self.unitLocationInitDone = False
		if self.iScreen == UNIT_LOCATION_SCREEN:
			self.showUnitLocation()
		elif self.iScreen == SITUATION_REPORT_SCREEN:
			self.showSituationReport()
		elif self.iScreen == STRATEGIC_ADVANTAGES_SCREEN:
			self.showStrategicAdvantages()
		self.timer.logSpan("total")
示例#5
0
def loadMod(name):
    """Load the given mod from its XML file using a custom parser."""
    path = BugPath.findAssetFile(name + ".xml", "Config")
    if path:
        BugUtil.debug("BugInit - loading module %s...", name)
        parser = BugConfig.ConfigParser()
        timer = BugUtil.Timer("load mod")
        try:
            parser.parse(path)
        # <advc.009b> Say which module failed
        except Exception, e:
            BugUtil.error("BugInit - failed to parse module %s", name)
            timer.log(name)
            raise e  # </advc.009b>
        timer.log(name)
示例#6
0
def init():
    """Performs the one-time initialization of the BUG core and all mods."""
    global g_initDone
    if g_initDone:
        BugUtil.debug("BugInit - init() already complete")
        return
    if not CyGame().isFinalInitialized():
        BugUtil.debug("BugInit - game not fully initialized")
        return
    # K-Mod. Don't use any BUG features if this is a PitBoss server.
    if CyGame().isPitbossHost():
        BugUtil.debug("BugInit - BUG disabled for PitBoss host")
        return
    # K-Mod end
    global g_initRunning
    if g_initRunning:
        BugUtil.warn("BugInit - init() already running")
        return
    g_initRunning = True

    BugUtil.debug("BugInit - initializing...")
    timer = BugUtil.Timer("BUG init")

    BugPath.init()
    timer.log("init paths").start()

    loadMod("init")
    BugCore.initDone()
    timer.log("read configs").start()

    callInits()
    timer.log("call inits/events")

    timer.logTotal()

    g_initDone = True
    g_initRunning = False
    return True
    def draw(self, screen):
        """Sorts and draws the scoreboard right-to-left, bottom-to-top."""
        timer = BugUtil.Timer("scores")
        self.hide(screen)
        self.assignRanks()
        self.gatherVassals()
        self.sort()
        interface = CyInterface()
        xResolution = screen.getXResolution()
        yResolution = screen.getYResolution()

        x = xResolution - 12  # start here and shift left with each column
        if (interface.getShowInterface() == InterfaceVisibility.INTERFACE_SHOW
                or interface.isInAdvancedStart()):
            y = yResolution - 206
        else:
            y = yResolution - 88
        totalWidth = 0
        height = ScoreOpt.getLineHeight()
        techIconSize = ScoreOpt.getResearchIconSize()

        defaultSpacing = ScoreOpt.getDefaultSpacing()
        spacing = defaultSpacing
        format = re.findall(
            '(-?[0-9]+|[^0-9])',
            ScoreOpt.getDisplayOrder().replace(' ', '').upper())
        format.reverse()
        for k in format:
            if k == '-':
                spacing = 0
                continue
            if k[0] in string.digits or k[0] == '-':
                spacing = int(k)
                continue
            if (not columnsByKey.has_key(k)):
                spacing = defaultSpacing
                continue
            column = columnsByKey[k]
            c = column.id
            if (not self._anyHas[c]):
                spacing = defaultSpacing
                continue
            type = column.type
            if (c == RESEARCH and not ScoreOpt.isShowResearchIcons()):
                # switch SPECIAL research icon to DYNAMIC name
                type = DYNAMIC

            if (type == SKIP):
                spacing = defaultSpacing
                continue

            elif (type == FIXED):
                width = column.width
                value = column.text
                x -= spacing
                for p, playerScore in enumerate(self._playerScores):
                    if (playerScore.has(c) and playerScore.value(c)):
                        name = "ScoreText%d-%d" % (p, c)
                        widget = playerScore.widget(c)
                        if widget is None:
                            if (playerScore.value(ALIVE)):
                                widget = (WidgetTypes.WIDGET_CONTACT_CIV,
                                          playerScore.getID(), -1)
                            else:
                                widget = (WidgetTypes.WIDGET_GENERAL, -1, -1)
                        screen.setText(name, "Background", value,
                                       CvUtil.FONT_RIGHT_JUSTIFY, x,
                                       y - p * height, Z_DEPTH,
                                       FontTypes.SMALL_FONT, *widget)
                        screen.show(name)
                x -= width
                totalWidth += width + spacing
                spacing = defaultSpacing

            elif (type == DYNAMIC):
                width = 0
                for playerScore in self._playerScores:
                    if (playerScore.has(c)):
                        value = playerScore.value(c)
                        if (c == NAME and playerScore.isVassal()
                                and ScoreOpt.isGroupVassals()):
                            if (ScoreOpt.isLeftAlignName()):
                                value = VASSAL_PREFIX + value
                            else:
                                value += VASSAL_POSTFIX
                        newWidth = interface.determineWidth(value)
                        if (newWidth > width):
                            width = newWidth
                if (width == 0):
                    spacing = defaultSpacing
                    continue
                x -= spacing
                for p, playerScore in enumerate(self._playerScores):
                    if (playerScore.has(c)):
                        name = "ScoreText%d-%d" % (p, c)
                        value = playerScore.value(c)
                        if (c == NAME and playerScore.isVassal()
                                and ScoreOpt.isGroupVassals()):
                            if (ScoreOpt.isLeftAlignName()):
                                value = VASSAL_PREFIX + value
                            else:
                                value += VASSAL_POSTFIX
                        align = CvUtil.FONT_RIGHT_JUSTIFY
                        adjustX = 0
                        if (c == NAME):
                            name = "ScoreText%d" % p
                            if (ScoreOpt.isLeftAlignName()):
                                align = CvUtil.FONT_LEFT_JUSTIFY
                                adjustX = width
                        widget = playerScore.widget(c)
                        if widget is None:
                            if (playerScore.value(ALIVE)):
                                widget = (WidgetTypes.WIDGET_CONTACT_CIV,
                                          playerScore.getID(), -1)
                            else:
                                widget = (WidgetTypes.WIDGET_GENERAL, -1, -1)
                        screen.setText(name, "Background", value, align,
                                       x - adjustX, y - p * height, Z_DEPTH,
                                       FontTypes.SMALL_FONT, *widget)
                        screen.show(name)
                x -= width
                totalWidth += width + spacing
                spacing = defaultSpacing

            else:  # SPECIAL
                if (c == RESEARCH):
                    x -= spacing
                    for p, playerScore in enumerate(self._playerScores):
                        if (playerScore.has(c)):
                            tech = playerScore.value(c)
                            name = "ScoreTech%d" % p
                            info = gc.getTechInfo(tech)
                            screen.addDDSGFC(
                                name, info.getButton(), x - techIconSize,
                                y - p * height - 1, techIconSize, techIconSize,
                                WidgetTypes.WIDGET_PEDIA_JUMP_TO_TECH, tech,
                                -1)
                    x -= techIconSize
                    totalWidth += techIconSize + spacing
                    spacing = defaultSpacing

        for playerScore in self._playerScores:
            interface.checkFlashReset(playerScore.getID())

        if (interface.getShowInterface() == InterfaceVisibility.INTERFACE_SHOW
                or interface.isInAdvancedStart()):
            y = yResolution - 186
        else:
            y = yResolution - 68
        screen.setPanelSize("ScoreBackground", xResolution - 21 - totalWidth,
                            y - (height * self.size()) - 4, totalWidth + 12,
                            (height * self.size()) + 8)
        screen.show("ScoreBackground")
        timer.log()
示例#8
0
    def draw(self, screen):
        """Sorts and draws the scoreboard right-to-left, bottom-to-top."""
        timer = BugUtil.Timer("scores")
        self.hide(screen)
        self.assignRanks()
        self.gatherVassals()
        self.sort()
        interface = CyInterface()
        xResolution = screen.getXResolution()
        yResolution = screen.getYResolution()
        # <advc.106d>
        # Was effectively 18 in BtS regardless of resolution
        iVOffset = 0
        if screen.getYResolution() > 1100:
            iVOffset = 6
        # </advc.106d>
        x = xResolution - 12  # start here and shift left with each column
        if (interface.getShowInterface() == InterfaceVisibility.INTERFACE_SHOW
                or interface.isInAdvancedStart()):
            y = yResolution - 188 - iVOffset  # advc.106d: was yResolution-206
        else:
            y = yResolution - 88
        totalWidth = 0
        height = ScoreOpt.getLineHeight()
        techIconSize = ScoreOpt.getResearchIconSize()

        defaultSpacing = ScoreOpt.getDefaultSpacing()
        spacing = defaultSpacing
        szDisplayOrder = ScoreOpt.getDisplayOrder()
        # <advc.085>
        bExpanded = False
        if gc.getPlayer(self._activePlayer).isScoreboardExpanded():
            bExpanded = True
        else:  # Take out the keys preceded by an underscore
            stringsToRemove = []
            for i, c in enumerate(szDisplayOrder):
                if i > 0 and szDisplayOrder[i - 1] == '_':
                    stringsToRemove.append('_' + c)
            for s in stringsToRemove:
                szDisplayOrder = szDisplayOrder.replace(s, '')
            # Remove any stray underscores as well
            szDisplayOrder = szDisplayOrder.replace('_', '')
            # A bit of a hack: Disable the option when there are no fly-out columns
            if len(stringsToRemove) <= 0 and ScoreOpt.isExpandOnHover():
                ScoreOpt.setExpandOnHover(False)
        # </advc.085>
        format = re.findall('(-?[0-9]+|[^0-9])',
                            szDisplayOrder.replace(' ', '').upper())
        format.reverse()
        for k in format:
            if k == '-':
                spacing = 0
                continue
            if k[0] in string.digits or k[0] == '-':
                spacing = int(k)
                continue
            if (not columnsByKey.has_key(k)):
                spacing = defaultSpacing
                continue
            column = columnsByKey[k]
            c = column.id
            if (not self._anyHas[c]):
                #spacing = defaultSpacing # disabled by K-Mod
                continue
            type = column.type
            if (c == RESEARCH and not ScoreOpt.isShowResearchIcons()):
                # switch SPECIAL research icon to DYNAMIC name
                type = DYNAMIC
            # advc.085: For filling gaps so that the scoreboard doesn't collapse. 4 spaces seem to fit almost exactly for columns with a single icon.
            szBlank = "    "
            if (type == SKIP):
                spacing = defaultSpacing
                continue
            elif (type == FIXED):
                width = column.width
                value = column.text
                x -= spacing
                for p, playerScore in enumerate(self._playerScores):
                    name = "ScoreText%d-%d" % (p, c)  # advc.085: Moved up
                    if (playerScore.has(c) and playerScore.value(c)):
                        widget = playerScore.widget(c)
                        if widget is None:
                            #if (playerScore.value(ALIVE)):
                            #	widget = (WidgetTypes.WIDGET_CONTACT_CIV, playerScore.getID(), 0)
                            #else:
                            #	widget = (WidgetTypes.WIDGET_GENERAL, -1, -1)
                            # <advc.085> Contact widget now set explicitly for Score and Name. Default widget: expand the scoreboard.
                            if bExpanded:
                                widget = (WidgetTypes.WIDGET_EXPAND_SCORES, -1,
                                          0)
                            else:  # </advc.085>
                                widget = (WidgetTypes.WIDGET_GENERAL, -1, -1)
                        screen.setText(name, "Background", value,
                                       CvUtil.FONT_RIGHT_JUSTIFY, x,
                                       y - p * height, Z_DEPTH,
                                       FontTypes.SMALL_FONT, *widget)
                        screen.show(name)
                    # <advc.085>
                    elif bExpanded:
                        screen.setText(name, "Background", szBlank,
                                       CvUtil.FONT_RIGHT_JUSTIFY, x,
                                       y - p * height, Z_DEPTH,
                                       FontTypes.SMALL_FONT,
                                       WidgetTypes.WIDGET_EXPAND_SCORES, -1, 0)
                        screen.show(name)  # </advc.085>
                x -= width
                totalWidth += width + spacing
                spacing = defaultSpacing

            elif (type == DYNAMIC):
                width = 0
                for playerScore in self._playerScores:
                    if (playerScore.has(c)):
                        value = playerScore.value(c)
                        if (c == NAME and playerScore.isVassal()
                                and ScoreOpt.isGroupVassals()):
                            if (ScoreOpt.isLeftAlignName()):
                                value = VASSAL_PREFIX + value
                            else:
                                value += VASSAL_POSTFIX
                        newWidth = interface.determineWidth(value)
                        if (newWidth > width):
                            width = newWidth
                if (width == 0):
                    spacing = defaultSpacing
                    continue
                x -= spacing
                for p, playerScore in enumerate(self._playerScores):
                    name = "ScoreText%d-%d" % (p, c)  # advc.085: Moved up
                    if (playerScore.has(c)):
                        value = playerScore.value(c)
                        if (c == NAME and playerScore.isVassal()
                                and ScoreOpt.isGroupVassals()):
                            if (ScoreOpt.isLeftAlignName()):
                                value = VASSAL_PREFIX + value
                            else:
                                value += VASSAL_POSTFIX
                        align = CvUtil.FONT_RIGHT_JUSTIFY
                        adjustX = 0
                        if (c == NAME):
                            name = "ScoreText%d" % p
                            if (ScoreOpt.isLeftAlignName()):
                                align = CvUtil.FONT_LEFT_JUSTIFY
                                adjustX = width
                        widget = playerScore.widget(c)
                        if widget is None:
                            #if (playerScore.value(ALIVE)):
                            #	widget = (WidgetTypes.WIDGET_CONTACT_CIV, playerScore.getID(), 0)
                            #else:
                            #	widget = (WidgetTypes.WIDGET_GENERAL, -1, -1)
                            # <advc.085> See under FIXED above
                            if bExpanded:
                                widget = (WidgetTypes.WIDGET_EXPAND_SCORES, -1,
                                          0)
                            else:  # </advc.085>
                                widget = (WidgetTypes.WIDGET_GENERAL, -1, -1)
                        screen.setText(name, "Background", value, align,
                                       x - adjustX, y - p * height, Z_DEPTH,
                                       FontTypes.SMALL_FONT, *widget)
                        screen.show(name)
                    # <advc.085>
                    elif bExpanded and c != NAME:
                        szBlankLoop = szBlank
                        if c == POWER:  # Power ratio takes up extra space
                            # Mustn't add too much space though: when the power ratio is in the leftmost column, too many spaces will prevent the scoreboard from collapsing when the mouse is moved away to the left.
                            szBlankLoop += szBlank + szBlank
                        screen.setText(name, "Background", szBlankLoop,
                                       CvUtil.FONT_RIGHT_JUSTIFY, x,
                                       y - p * height, Z_DEPTH,
                                       FontTypes.SMALL_FONT,
                                       WidgetTypes.WIDGET_EXPAND_SCORES, -1, 0)
                        screen.show(name)  # </advc.085>
                x -= width
                totalWidth += width + spacing
                spacing = defaultSpacing

            else:  # SPECIAL
                if (c == RESEARCH):
                    x -= spacing
                    for p, playerScore in enumerate(self._playerScores):
                        if (playerScore.has(c)):
                            tech = playerScore.value(c)
                            name = "ScoreTech%d" % p
                            info = gc.getTechInfo(tech)
                            iData2 = 0  # advc.085: was -1
                            screen.addDDSGFC(
                                name, info.getButton(), x - techIconSize,
                                y - p * height - 1, techIconSize, techIconSize,
                                WidgetTypes.WIDGET_PEDIA_JUMP_TO_TECH, tech,
                                iData2)
                    x -= techIconSize
                    totalWidth += techIconSize + spacing
                    spacing = defaultSpacing
                # <kekm.30>
                elif c == LEADER_BUTTON:
                    x -= spacing
                    for p, playerScore in enumerate(self._playerScores):
                        if (playerScore.has(c)):
                            leader = playerScore.value(c)
                            name = "ScoreLeader%d" % p
                            info = gc.getLeaderHeadInfo(leader)
                            screen.addDDSGFC(
                                name, info.getButton(), x - techIconSize,
                                y - p * height - 1, techIconSize, techIconSize,
                                WidgetTypes.WIDGET_PEDIA_JUMP_TO_LEADER,
                                leader, 1)
                    x -= techIconSize
                    totalWidth += techIconSize + spacing
                    spacing = defaultSpacing
                elif c == CIV_BUTTON:
                    x -= spacing
                    for p, playerScore in enumerate(self._playerScores):
                        if (playerScore.has(c)):
                            civ = playerScore.value(c)
                            name = "ScoreCiv%d" % p
                            info = gc.getCivilizationInfo(civ)
                            screen.addDDSGFC(
                                name, info.getButton(), x - techIconSize,
                                y - p * height - 1, techIconSize, techIconSize,
                                WidgetTypes.WIDGET_PEDIA_JUMP_TO_CIV, civ, -1)
                    x -= techIconSize
                    totalWidth += techIconSize + spacing
                    spacing = defaultSpacing
                # </kekm.30>

        for playerScore in self._playerScores:
            interface.checkFlashReset(playerScore.getID())

        if (interface.getShowInterface() == InterfaceVisibility.INTERFACE_SHOW
                or interface.isInAdvancedStart()):
            y = yResolution - 168 - iVOffset  # advc.106d: was yResolution-186
        else:
            y = yResolution - 68
        screen.setPanelSize("ScoreBackground", xResolution - 21 - totalWidth,
                            y - (height * self.size()) - 4, totalWidth + 12,
                            (height * self.size()) + 8)
        screen.show("ScoreBackground")
        timer.log()
示例#9
0
	def draw(self, screen):
		"""Sorts and draws the scoreboard right-to-left, bottom-to-top."""
		timer = BugUtil.Timer("scores")
		self.hide(screen)
		self.assignRanks()
		self.gatherVassals()
		self.sort()
		# <advc.092> "Default" choices added
		bScaleHUD = BugCore.game.MainInterface.isEnlargeHUD()
		if ScoreOpt.isRowHeightDefault():
			if bScaleHUD:
				height = LayoutDict.VLEN(21, 0.5)
			else:
				height = 20
		else:
			# Convert choice index to choice value by adding the
			# lowest possible value
			height = ScoreOpt.getRowHeight() - 1 + 10
		if ScoreOpt.isTechButtonSizeDefault():
			techIconSize = height + 2
		else:
			techIconSize = ScoreOpt.getTechButtonSize() - 1 + 12
		if ScoreOpt.isColumnSpacingDefault():
			if bScaleHUD:
				defaultSpacing = LayoutDict.HSPACE(2, 2)
			else:
				defaultSpacing = 0
		else:
			defaultSpacing = ScoreOpt.getColumnSpacing() - 1 + 0
		x = LayoutDict.gPoint("ScoreTextLowerRight").x() 
		y = LayoutDict.gPoint("ScoreTextLowerRight").y()
		y -= height
		# </advc.092>
		# start at x and shift left with each column
		totalWidth = 0
		spacing = defaultSpacing
		szDisplayOrder = ScoreOpt.getDisplayOrder()
		# <advc.085>
		bExpanded = False
		if gc.getPlayer(self._activePlayer).isScoreboardExpanded():
			bExpanded = True
		else: # Take out the keys preceded by an underscore
			stringsToRemove = []
			for i, c in enumerate(szDisplayOrder):
				if i > 0 and szDisplayOrder[i - 1] == '_':
					stringsToRemove.append('_' + c)
			for s in stringsToRemove:
				szDisplayOrder = szDisplayOrder.replace(s, '')
			# Remove any stray underscores as well
			szDisplayOrder = szDisplayOrder.replace('_', '')
			# A bit of a hack: Disable the option when there are no fly-out columns
			if len(stringsToRemove) <= 0 and ScoreOpt.isExpandOnHover():
				ScoreOpt.setExpandOnHover(False)
		# </advc.085>
		format = re.findall('(-?[0-9]+|[^0-9])', szDisplayOrder.replace(' ', '').upper())
		format.reverse()
		for k in format:
			if k == '-':
				spacing = 0
				continue
			if k[0] in string.digits or k[0] == '-':
				spacing = int(k)
				continue
			if (not columnsByKey.has_key(k)):
				spacing = defaultSpacing
				continue
			column = columnsByKey[k]
			c = column.id
			if (not self._anyHas[c]):
				#spacing = defaultSpacing # disabled by K-Mod
				continue
			type = column.type
			if (c == RESEARCH and not ScoreOpt.isShowResearchIcons()):
				# switch SPECIAL research icon to DYNAMIC name
				type = DYNAMIC
			# <advc.002b>
			if c in gameTextColumns:
				iYTextOffset = 3
			else:
				iYTextOffset = 0
			iYIconOffset = -1 # (as in BUG)
			# </advc.002b>
			# advc.085: For filling gaps so that the scoreboard doesn't collapse. 4 spaces seem to fit almost exactly for columns with a single icon.
			szBlank = "    "
			if (type == SKIP):
				spacing = defaultSpacing
				continue
			elif (type == FIXED):
				width = column.width
				value = column.text
				x -= spacing
				for p, playerScore in enumerate(self._playerScores):
					name = "ScoreText%d-%d" %( p, c ) # advc.085: Moved up
					if (playerScore.has(c) and playerScore.value(c)):
						widget = playerScore.widget(c)
						if widget is None:
							#if (playerScore.value(ALIVE)):
							#	widget = (WidgetTypes.WIDGET_CONTACT_CIV, playerScore.getID(), 0)
							#else:
							#	widget = (WidgetTypes.WIDGET_GENERAL, -1, -1)
							# <advc.085> Contact widget now set explicitly for Score and Name. Default widget: expand the scoreboard.
							if bExpanded:
								widget = (WidgetTypes.WIDGET_EXPAND_SCORES, -1, 0)
							else: # </advc.085>
								widget = (WidgetTypes.WIDGET_GENERAL, -1, -1)
						screen.setText(name, "Background", value,
								CvUtil.FONT_RIGHT_JUSTIFY,
								# advc.002b: text offset
								x, y - p * height + iYTextOffset, Z_DEPTH,
								FontTypes.SMALL_FONT,
								*widget)
						screen.show(name)
					# <advc.085>
					elif bExpanded:
						screen.setText(name, "Background", szBlank,
								CvUtil.FONT_RIGHT_JUSTIFY,
								x, y - p * height, Z_DEPTH,
								FontTypes.SMALL_FONT,
								WidgetTypes.WIDGET_EXPAND_SCORES, -1, 0)
						screen.show(name) # </advc.085>
				x -= width
				totalWidth += width + spacing
				spacing = defaultSpacing
			
			elif (type == DYNAMIC):
				width = 0
				for playerScore in self._playerScores:
					if (playerScore.has(c)):
						value = playerScore.value(c)
						if (c == NAME and playerScore.isVassal() and ScoreOpt.isGroupVassals()):
							if (ScoreOpt.isLeftAlignName()):
								value = VASSAL_PREFIX + value
							else:
								value += VASSAL_POSTFIX
						newWidth = CyInterface().determineWidth( value )
						if (newWidth > width):
							width = newWidth
				if (width == 0):
					spacing = defaultSpacing
					continue
				x -= spacing
				for p, playerScore in enumerate(self._playerScores):
					name = "ScoreText%d-%d" %( p, c ) # advc.085: Moved up
					if (playerScore.has(c)):
						value = playerScore.value(c)
						if (c == NAME and playerScore.isVassal() and ScoreOpt.isGroupVassals()):
							if (ScoreOpt.isLeftAlignName()):
								value = VASSAL_PREFIX + value
							else:
								value += VASSAL_POSTFIX
						align = CvUtil.FONT_RIGHT_JUSTIFY
						adjustX = 0
						if (c == NAME):
							name = "ScoreText%d" % p
							if (ScoreOpt.isLeftAlignName()):
								align = CvUtil.FONT_LEFT_JUSTIFY
								adjustX = width
						widget = playerScore.widget(c)
						if widget is None:
							#if (playerScore.value(ALIVE)):
							#	widget = (WidgetTypes.WIDGET_CONTACT_CIV, playerScore.getID(), 0)
							#else:
							#	widget = (WidgetTypes.WIDGET_GENERAL, -1, -1)
							# <advc.085> See under FIXED above
							if bExpanded:
								widget = (WidgetTypes.WIDGET_EXPAND_SCORES, -1, 0)
							else: # </advc.085>
								widget = (WidgetTypes.WIDGET_GENERAL, -1, -1)
						screen.setText(name, "Background", value,
								align,
								# advc.002b: text offset
								x - adjustX, y - p * height + iYTextOffset, Z_DEPTH, 
								FontTypes.SMALL_FONT,
								*widget)
						screen.show(name)
					# <advc.085>
					elif bExpanded and c != NAME:
						szBlankLoop = szBlank
						if c == POWER: # Power ratio takes up extra space
							# Mustn't add too much space though: when the power ratio is in the leftmost column, too many spaces will prevent the scoreboard from collapsing when the mouse is moved away to the left.
							szBlankLoop += szBlank + szBlank
						screen.setText(name, "Background", szBlankLoop,
								CvUtil.FONT_RIGHT_JUSTIFY,
								x, y - p * height, Z_DEPTH,
								FontTypes.SMALL_FONT,
								WidgetTypes.WIDGET_EXPAND_SCORES, -1, 0)
						screen.show(name) # </advc.085>
				x -= width
				totalWidth += width + spacing
				spacing = defaultSpacing
			
			else: # SPECIAL
				if (c == RESEARCH):
					x -= spacing
					for p, playerScore in enumerate(self._playerScores):
						if (playerScore.has(c)):
							tech = playerScore.value(c)
							name = "ScoreTech%d" % p
							info = gc.getTechInfo(tech)
							iData2 = 0 # advc.085: was -1
							screen.addDDSGFC(name, info.getButton(),
									x - techIconSize, y - p * height + iYIconOffset,
									techIconSize, techIconSize,
									WidgetTypes.WIDGET_PEDIA_JUMP_TO_TECH, tech, iData2 )
					x -= techIconSize
					totalWidth += techIconSize + spacing
					spacing = defaultSpacing
				# <kekm.30>
				elif c == LEADER_BUTTON:
					x -= spacing
					for p, playerScore in enumerate(self._playerScores):
						if (playerScore.has(c)):
							leader = playerScore.value(c)
							name = "ScoreLeader%d" % p
							info = gc.getLeaderHeadInfo(leader)
							screen.addDDSGFC(name, info.getButton(),
									x - techIconSize, y - p * height + iYIconOffset,
									techIconSize, techIconSize,
									WidgetTypes.WIDGET_PEDIA_JUMP_TO_LEADER, leader, 1 )
					x -= techIconSize
					totalWidth += techIconSize + spacing
					spacing = defaultSpacing
				elif c == CIV_BUTTON:
					x -= spacing
					for p, playerScore in enumerate(self._playerScores):
						if (playerScore.has(c)):
							civ = playerScore.value(c)
							name = "ScoreCiv%d" % p
							info = gc.getCivilizationInfo(civ)
							screen.addDDSGFC(name, info.getButton(),
									x - techIconSize, y - p * height + iYIconOffset,
									techIconSize, techIconSize,
									WidgetTypes.WIDGET_PEDIA_JUMP_TO_CIV, civ, -1 )
					x -= techIconSize
					totalWidth += techIconSize + spacing
					spacing = defaultSpacing
				# </kekm.30>
		
		for playerScore in self._playerScores:
			CyInterface().checkFlashReset( playerScore.getID() )
		# advc.092:
		CvScreensInterface.mainInterface.updateScoreBackgrSize(totalWidth, height * self.size())

		#screen.show( "ScoreBackground" ) # advc.004z: Handled by caller now
		timer.log()