def UL_refreshUnitSelection(self, bReload, bRedraw): screen = self.getScreen() screen.minimapClearAllFlashingTiles() if (bRedraw): iBtn_X = self.X_TEXT + self.MAP_MARGIN iBtn_Y = self.Y_TEXT + self.MAP_MARGIN / 2 iTxt_X = iBtn_X + 22 iTxt_Y = iBtn_Y + 2 if (self.bUnitDetails): szText = localText.getText("TXT_KEY_MILITARY_ADVISOR_UNIT_TOGGLE_OFF", ()) screen.setButtonGFC(self.UNIT_BUTTON_ID, u"", "", iBtn_X, iBtn_Y, 20, 20, WidgetTypes.WIDGET_GENERAL, -1, -1, ButtonStyles.BUTTON_STYLE_CITY_MINUS ) screen.setLabel(self.UNIT_BUTTON_LABEL_ID, "", szText, CvUtil.FONT_LEFT_JUSTIFY, iTxt_X, iTxt_Y, 0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) else: szText = localText.getText("TXT_KEY_MILITARY_ADVISOR_UNIT_TOGGLE_ON", ()) screen.setButtonGFC(self.UNIT_BUTTON_ID, u"", "", iBtn_X, iBtn_Y, 20, 20, WidgetTypes.WIDGET_GENERAL, -1, -1, ButtonStyles.BUTTON_STYLE_CITY_PLUS ) screen.setLabel(self.UNIT_BUTTON_LABEL_ID, "", szText, CvUtil.FONT_LEFT_JUSTIFY, iTxt_X, iTxt_Y, 0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1) if bReload: self.timer.start() _, activePlayer, iActiveTeam, activeTeam = PlayerUtil.getActivePlayerAndTeamAndIDs() self.stats = UnitGrouper.GrouperStats(self.grouper) for player in PlayerUtil.players(alive=True): for unit in PlayerUtil.playerUnits(player): plot = unit.plot() if plot.isNone(): continue bVisible = plot.isVisible(iActiveTeam, False) and not unit.isInvisible(iActiveTeam, False) if not bVisible: continue if unit.getVisualOwner() in self.selectedLeaders: self.stats.processUnit(activePlayer, activeTeam, unit) self.timer.log("process units") iGroupID = 1 szText = localText.getText("TXT_KEY_PEDIA_ALL_UNITS", ()).upper() bAllSelected = iGroupID in self.selectedGroups if (bAllSelected): szText = localText.changeTextColor(u"<u>" + szText + u"</u>", gc.getInfoTypeForString("COLOR_YELLOW")) if (bRedraw): screen.addListBoxGFC(self.UNIT_LIST_ID, "", self.X_TEXT + self.MAP_MARGIN, self.Y_TEXT + self.MAP_MARGIN + 15, self.W_TEXT - 2 * self.MAP_MARGIN, self.H_TEXT - 2 * self.MAP_MARGIN - 15, TableStyles.TABLE_STYLE_STANDARD) screen.enableSelect(self.UNIT_LIST_ID, False) screen.setStyle(self.UNIT_LIST_ID, "Table_StandardCiv_Style") screen.appendListBoxString(self.UNIT_LIST_ID, szText, WidgetTypes.WIDGET_MINIMAP_HIGHLIGHT, 1, iGroupID, CvUtil.FONT_LEFT_JUSTIFY) else: screen.setListBoxStringGFC(self.UNIT_LIST_ID, 0, szText, WidgetTypes.WIDGET_MINIMAP_HIGHLIGHT, 1, iGroupID, CvUtil.FONT_LEFT_JUSTIFY) # for grouping in self.stats.itergroupings(): # for group in grouping.itergroups(): # BugUtil.debug("%s / %s : %d (%d)" % (grouping.grouping.title, group.group.title, group.size(), group.isEmpty())) eYellow = gc.getInfoTypeForString("COLOR_YELLOW") eRed = gc.getInfoTypeForString("COLOR_RED") eWhite = gc.getInfoTypeForString("COLOR_WHITE") grouping1 = self.stats.getGrouping(self.groupingKeys[0]) grouping2 = self.stats.getGrouping(self.groupingKeys[1]) BugUtil.debug("Grouping 1 is %s" % grouping1.grouping.title) BugUtil.debug("Grouping 2 is %s" % grouping2.grouping.title) self.timer.start() iItem = 1 for group1 in grouping1.itergroups(): if (group1.isEmpty()): continue units1 = group1.units iGroupID += 1 bGroup1Selected = iGroupID in self.selectedGroups szDescription = group1.group.title.upper() + u" (%d)" % len(units1) if (bGroup1Selected): szDescription = u" <u>" + szDescription + u"</u>" else: szDescription = u" " + szDescription if (bGroup1Selected or bAllSelected): szDescription = localText.changeTextColor(szDescription, eYellow) if (bRedraw): screen.appendListBoxString(self.UNIT_LIST_ID, szDescription, WidgetTypes.WIDGET_MINIMAP_HIGHLIGHT, 1, iGroupID, CvUtil.FONT_LEFT_JUSTIFY) else: screen.setListBoxStringGFC(self.UNIT_LIST_ID, iItem, szDescription, WidgetTypes.WIDGET_MINIMAP_HIGHLIGHT, 1, iGroupID, CvUtil.FONT_LEFT_JUSTIFY) iItem += 1 bGroup1Selected = bGroup1Selected or bAllSelected for group2 in grouping2.itergroups(): units2 = group2.units & units1 if (not units2): continue iGroupID += 1 bGroup2Selected = iGroupID in self.selectedGroups szDescription = group2.group.title + u" (%d)" % len(units2) if (bGroup2Selected): szDescription = u" <u>" + szDescription + u"</u>" else: szDescription = u" " + szDescription if (bGroup2Selected or bGroup1Selected): szDescription = localText.changeTextColor(szDescription, eYellow) if (bRedraw): screen.appendListBoxString(self.UNIT_LIST_ID, szDescription, WidgetTypes.WIDGET_MINIMAP_HIGHLIGHT, 1, iGroupID, CvUtil.FONT_LEFT_JUSTIFY) else: screen.setListBoxStringGFC(self.UNIT_LIST_ID, iItem, szDescription, WidgetTypes.WIDGET_MINIMAP_HIGHLIGHT, 1, iGroupID, CvUtil.FONT_LEFT_JUSTIFY) iItem += 1 bGroup2Selected = bGroup2Selected or bGroup1Selected for unit in units2: loopUnit = unit.unit bUnitSelected = self.isSelectedUnit(loopUnit.getOwner(), loopUnit.getID()) if (self.bUnitDetails): szDescription = CyGameTextMgr().getSpecificUnitHelp(loopUnit, true, false) listMatches = re.findall("<.*?color.*?>", szDescription) for szMatch in listMatches: szDescription = szDescription.replace(szMatch, u"") if (loopUnit.isWaiting()): szDescription = '*' + szDescription if (bUnitSelected): szDescription = u" <u>" + szDescription + u"</u>" else: szDescription = u" " + szDescription if (bUnitSelected or bGroup2Selected): szDescription = localText.changeTextColor(szDescription, eYellow) if (bRedraw): screen.appendListBoxString(self.UNIT_LIST_ID, szDescription, WidgetTypes.WIDGET_MINIMAP_HIGHLIGHT, -loopUnit.getOwner(), loopUnit.getID(), CvUtil.FONT_LEFT_JUSTIFY) else: screen.setListBoxStringGFC(self.UNIT_LIST_ID, iItem, szDescription, WidgetTypes.WIDGET_MINIMAP_HIGHLIGHT, -loopUnit.getOwner(), loopUnit.getID(), CvUtil.FONT_LEFT_JUSTIFY) iItem += 1 iPlayer = loopUnit.getVisualOwner() player = PyPlayer(iPlayer) iColor = gc.getPlayerColorInfo(gc.getPlayer(iPlayer).getPlayerColor()).getColorTypePrimary() screen.setMinimapColor(MinimapModeTypes.MINIMAPMODE_MILITARY, loopUnit.getX(), loopUnit.getY(), iColor, 0.6) if (bUnitSelected or bGroup2Selected) and iPlayer in self.selectedLeaders: if (player.getTeam().isAtWar(gc.getPlayer(self.iActivePlayer).getTeam())): iColor = eRed elif (gc.getPlayer(iPlayer).getTeam() != gc.getPlayer(self.iActivePlayer).getTeam()): iColor = eYellow else: iColor = eWhite screen.minimapFlashPlot(loopUnit.getX(), loopUnit.getY(), iColor, -1) self.timer.log("draw unit list")