Example #1
0
    def turnChecker(self, iTurnNum):

        # Check to see if this is a turn when the screen should pop up (every 50 turns)
        if (not CyGame().isNetworkMultiPlayer()
                and CyGame().getActivePlayer() >= 0):
            if (iTurnNum % 50 == 0 and iTurnNum > 0
                    and gc.getPlayer(CyGame().getActivePlayer()).isAlive()):
                self.showScreen()
Example #2
0
class RootTable(Table):
	def __init__(self):
		from CvPythonExtensions import CyGame
		super(RootTable, self).__init__("root", dict())
		self.game = CyGame()
	def load(self):
		script = self.game.getScriptData()
		if script:
			self.data = pickle.loads(script)
	def _save(self):
		self.game.setScriptData(pickle.dumps(self.data))
Example #3
0
class RootTable(Table):
	def __init__(self):
		super(RootTable, self).__init__("root", dict())
		self.game = CyGame()
	def load(self):
		BugUtil.debug("BugData - loading %s", self)
		script = self.game.getScriptData()
		if script:
			self.data = pickle.loads(script)
			BugUtil.debug("BugData - loaded %r", self.data)
	def _save(self):
		self.game.setScriptData(pickle.dumps(self.data))
Example #4
0
File: BugData.py Project: AP-ML/DTM
class RootTable(Table):
	def __init__(self):
		super(RootTable, self).__init__("root", dict())
		self.game = CyGame()
	def load(self):
		BugUtil.debug("BugData - loading %s", self)
		script = self.game.getScriptData()
		if script:
			self.data = pickle.loads(script)
			BugUtil.debug("BugData - loaded %r", self.data)
	def _save(self):
		self.game.setScriptData(pickle.dumps(self.data))
Example #5
0
 def handleInput (self, inputClass):
     if inputClass.getNotifyCode() == NotifyCode.NOTIFY_CLICKED:
       if inputClass.getButtonType() == WidgetTypes.WIDGET_GENERAL and inputClass.getData2() != -1:
         pPlayer = gc.getPlayer(CyGame().getActivePlayer())
         pUnit = pPlayer.getUnit(inputClass.getData2())
         if inputClass.getData1() == 1:
           CyCamera().JustLookAtPlot(pUnit.plot())
           CyInterface().selectUnit(pUnit, True, True, True)
           self.hideScreen()
         elif inputClass.getData1() == 748:
           CyMessageControl().sendModNetMessage(748, -1, -1, CyGame().getActivePlayer(), inputClass.getData2())
           CyCamera().JustLookAtPlot(pUnit.plot())
           CyInterface().selectUnit(pUnit, True, True, True)
           self.hideScreen()
     return 0
 def __init__(self, iThisPlayer, iTargetPlayer):
     pActiveTeam = gc.getTeam(gc.getActivePlayer().getTeam())
     iThisTeam = gc.getPlayer(iThisPlayer).getTeam()
     pThisTeam = gc.getTeam(iThisTeam)
     iTargetTeam = gc.getPlayer(iTargetPlayer).getTeam()
     self.iThisPlayer = iThisPlayer
     self.iTargetPlayer = iTargetPlayer
     self.iAttitudeSum = 0
     self.iAttitudeModifiers = {}
     self.bHasActiveMetBoth = CyGame().isDebugMode() or (pActiveTeam.isHasMet(iThisTeam) and pActiveTeam.isHasMet(iTargetTeam))
     self.eAttitudeType = AttitudeTypes.NO_ATTITUDE
     # This might be better off being something descriptive such as
     # "players have not met" or "players are the same"
     self.sAttitudeString = ""
     # keldath fix attitude call on selfs - already checked
     if iThisPlayer != iTargetPlayer and pThisTeam.isHasMet(iTargetTeam):
         self.eAttitudeType = gc.getPlayer(iThisPlayer).AI_getAttitude(iTargetPlayer)
         self.sAttitudeString = CyGameTextMgr().getAttitudeString(iThisPlayer, iTargetPlayer)
         for sLine in self.sAttitudeString.split("\n"):
             #BugUtil.debug(u"LINE: %s" % (sLine))
             pMatch = re.match("^.*>([-\+]\d+)\s?:\s+(\".+\")<.*$", sLine, re.UNICODE)
             if (pMatch):
                 #BugUtil.debug(u"MATCH: (%s) (%s)" %(pMatch.group(1), pMatch.group(2)))
                 iValue = int(pMatch.group(1))
                 sString = unicode(pMatch.group(2))
                 self.iAttitudeSum += iValue
                 if sString in MODIFIER_STRING_TO_KEY:
                     self.iAttitudeModifiers[MODIFIER_STRING_TO_KEY[sString]] = iValue
                     #BugUtil.debug(u"Attitude::init() - Added to dict: %s" % (sString))
                 else:
                     BugUtil.debug(u"Attitude::init() - Attitude string contains unknown modifier text: %s" % (sString))
     #BugUtil.debug(u"Attitude::init() complete.")
     BugUtil.debug(u"%s" % (self))
Example #7
0
    def interfaceScreen (self):

        self.iTargetPlayer = -1
        self.iActiveCityID = -1
        self.iSelectedMission = -1
        self.iActivePlayer = CyGame().getActivePlayer()

        screen = self.getScreen()
        if screen.isActive():
            return
        screen.setRenderInterfaceOnly(True)
        screen.showScreen( PopupStates.POPUPSTATE_IMMEDIATE, False)

        # Set the background and exit button, and show the screen
        screen.setDimensions(screen.centerX(0), screen.centerY(0), self.W_SCREEN, self.H_SCREEN)

        screen.addDDSGFC(self.BACKGROUND_ID, ArtFileMgr.getInterfaceArtInfo("SCREEN_BG_OPAQUE").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.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.WIDGET_HEADER, "Background", u"<font=4b>" + localText.getText("TXT_KEY_TRADE_ROUTE2_ADVISOR_SCREEN", ()).upper() + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, self.X_SCREEN, self.Y_TITLE, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

        # draw the contents
        self.drawContents()

        self.refreshScreen()
def addGoldNearbyRiverTiles():
	"""Increase extra gold value of plot if zero.
	Well, this algorithm is not correct for all cases...
	"""
	iMapW = gc.getMap().getGridWidth()
	iMapH = gc.getMap().getGridHeight()
	global RIVER_TERRAINS
	RIVER_TERRAINS = [
		gc.getInfoTypeForString("TERRAIN_RIVER"),
		gc.getInfoTypeForString("TERRAIN_RIVER_FORD")]
	neighbours_indizies = [
		(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)]
	goldYield = 2
	for x in xrange(iMapW):
		for y in xrange(iMapH):
			loopPlot = gc.getMap().plot(x, y)
			if(loopPlot.isRiver() or
			   loopPlot.getPlotType() is not PlotTypes.PLOT_LAND):
				continue
			neighbours = [gc.getMap().plot(x + n[0], y + n[1])
						  for n in neighbours_indizies]
			for nPlot in neighbours:
				if nPlot is None:
					continue
				if nPlot.getTerrainType() in RIVER_TERRAINS:
					iYield = loopPlot.getYield(YieldTypes(goldYield))
					iImprovement = loopPlot.getImprovementType()
					if iImprovement > -1:
						iYield -= loopPlot.calculateImprovementYieldChange(iImprovement, YieldTypes(goldYield), loopPlot.getOwner(), False)
					if iYield == 0:
						# Achtung, Methode wirkt eher wie eine Change-Routine?!
						CyGame().setPlotExtraYield(loopPlot.getX(), loopPlot.getY(), goldYield, iYield + 1)
						break
    def interfaceScreen(self):

        screen = self.getScreen()
        if screen.isActive():
            return
        screen.setRenderInterfaceOnly(True)
        screen.showScreen(PopupStates.POPUPSTATE_IMMEDIATE, False)

        # Set the background and exit button, and show the screen
        screen.setDimensions(screen.centerX(0), screen.centerY(0),
                             self.W_SCREEN, self.H_SCREEN)
        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.setText(
            self.CANCEL_NAME, "Background",
            u"<font=4>" + localText.getText("TXT_KEY_SCREEN_CANCEL",
                                            ()).upper() + u"</font>",
            CvUtil.FONT_CENTER_JUSTIFY, self.X_CANCEL, self.Y_CANCEL,
            self.Z_TEXT, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, 1,
            0)

        # Header...
        screen.setText(
            self.TITLE_NAME, "Background",
            u"<font=4b>" + localText.getText("TXT_KEY_CIVICS_SCREEN_TITLE",
                                             ()).upper() + u"</font>",
            CvUtil.FONT_CENTER_JUSTIFY, self.X_SCREEN, self.Y_TITLE,
            self.Z_TEXT, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1,
            -1)

        self.setActivePlayer(gc.getGame().getActivePlayer())

        if CyGame().isDebugMode():
            self.szDropdownName = self.DEBUG_DROPDOWN_ID
            screen.addDropDownBoxGFC(self.szDropdownName, 22, 12, 300,
                                     WidgetTypes.WIDGET_GENERAL, -1, -1,
                                     FontTypes.GAME_FONT)
            for j in xrange(gc.getMAX_PLAYERS()):
                if (gc.getPlayer(j).isAlive()):
                    screen.addPullDownString(self.szDropdownName,
                                             gc.getPlayer(j).getName(), j, j,
                                             False)

        screen.addPanel("CivicsBottomLine", "", "", True, True,
                        self.HEADINGS_SPACING, self.BOTTOM_LINE_TOP,
                        self.BOTTOM_LINE_WIDTH, self.BOTTOM_LINE_HEIGHT,
                        PanelStyles.PANEL_STYLE_MAIN)

        # Draw Contents
        self.drawContents()

        return 0
    def highlightMoveArea(self, pUnit):
        # init some variables
        self.pUnit              = pUnit
        self.pFromPlot          = pUnit.plot()
        self.dPlotList          = {}
        self.iMovesLeft         = self.pUnit.movesLeft()
        pUnitTypeInfo           = gc.getUnitInfo(self.pUnit.getUnitType())
        self.eDomain            = pUnitTypeInfo.getDomainType()
        self.iActivePlayer      = CyGame().getActivePlayer()
        pActivePlayer           = gc.getPlayer(self.iActivePlayer)
        self.iActivePlayerTeam  = pActivePlayer.getTeam()

        # add from plot to OK list
        self.dPlotList[self.getPlotXY(self.pFromPlot)] = 0

        # creates the infromation of the moveable area
        self.AS.generateArea(self.pUnit, self.pFromPlot)
        self.lArea = self.AS.getArea()

        # analyze data and set plot colors
        for i in xrange(len(self.lArea)):
            tItem = self.lArea[i]
            self.setPlotColor(tItem[0][0], tItem[0][1], tItem[1])

        # highlight the area
        self.highlightMoves()
        return 1
def preGameStart():
    import CvScreensInterface

    if not CyGame().isPitbossHost():
        NiTextOut("Initializing font icons")
        # Load dynamic font icons into the icon map
        CvUtil.initDynamicFontIcons()

    if not CyGame().isPitbossHost():
        # Preload the tech chooser..., only do this release builds, in debug build we may not be raising the tech chooser
        if (not gc.isDebugBuild()):
            NiTextOut("Preloading tech chooser")
            CvScreensInterface.showTechChooser()
            CvScreensInterface.techChooser.hideScreen()

    NiTextOut("Loading main interface...")
    CvScreensInterface.showMainInterface()
Example #12
0
    def printList(self, szType):

        # Print out the list
        for iRankLoop in xrange(8):

            if (iRankLoop > len(self.aiTopCivsValues) - 1):
                return

            iPlayer = self.aiTopCivsValues[iRankLoop][1]
            #             iValue = self.aiTopCivsValues[iRankLoop][0]

            szPlayerName = gc.getPlayer(iPlayer).getNameKey()

            if (szPlayerName != ""):

                pActivePlayerTeam = gc.getTeam(
                    gc.getPlayer(CyGame().getActivePlayer()).getTeam())
                iPlayerTeam = gc.getPlayer(iPlayer).getTeam()
                szCivText = ""

                # Does the Active player know this player exists?
                if (iPlayer == CyGame().getActivePlayer()
                        or pActivePlayerTeam.isHasMet(iPlayerTeam)):
                    szCivText = localText.getText(
                        "TXT_KEY_TOPCIVS_TEXT3",
                        (szPlayerName, self.RankList[iRankLoop]))

                else:
                    szCivText = localText.getText("TXT_KEY_TOPCIVS_UNKNOWN",
                                                  ())

                szWidgetName = "Text" + str(iRankLoop)
                szWidgetDesc = "%d) %s" % (iRankLoop + 1, szCivText)
                iXLoc = self.X_RANK_TEXT
                iYLoc = self.Y_RANK_TEXT + (iRankLoop * self.H_RANK_TEXT)
                #self.screen.setText(szWidgetName, "Background", szWidgetDesc, CvUtil.FONT_LEFT_JUSTIFY, iXLoc, iYLoc, TEXT_Z, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
                self.screen.addMultilineText(szWidgetName,
                                             unicode(szWidgetDesc), iXLoc,
                                             iYLoc, self.W_RANK_TEXT,
                                             self.H_RANK_TEXT,
                                             WidgetTypes.WIDGET_GENERAL, -1,
                                             -1, CvUtil.FONT_LEFT_JUSTIFY)
Example #13
0
    def interfaceScreen (self):

        self.iTargetPlayer = -1
        self.iActiveCityID = -1
        self.iSelectedMission = -1
        self.iActivePlayer = CyGame().getActivePlayer()

        screen = self.getScreen()
        if screen.isActive():
            return
        screen.setRenderInterfaceOnly(True);
        screen.showScreen( PopupStates.POPUPSTATE_IMMEDIATE, False)

        # Set the background and exit button, and show the screen
        screen.setDimensions(screen.centerX(0), screen.centerY(0), self.W_SCREEN, self.H_SCREEN)

        screen.addDDSGFC(self.BACKGROUND_ID, ArtFileMgr.getInterfaceArtInfo("SCREEN_BG_OPAQUE").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.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.WIDGET_HEADER, "Background", u"<font=4b>" + localText.getText("TXT_KEY_ESPIONAGE_SCREEN", ()).upper() + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, self.X_SCREEN, self.Y_TITLE, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

        if CyGame().isDebugMode():
            self.iDebugDropdownID = 554
            self.szDropdownName = self.DEBUG_DROPDOWN_ID
            screen.addDropDownBoxGFC(self.szDropdownName, 22, 12, 300, WidgetTypes.WIDGET_GENERAL, self.iDebugDropdownID, -1, FontTypes.GAME_FONT)
            for j in xrange(gc.getMAX_PLAYERS()):
                if (gc.getPlayer(j).isAlive()):
                    screen.addPullDownString(self.szDropdownName, gc.getPlayer(j).getName(), j, j, False )

        # draw the contents
        self.drawContents()

        self.refreshScreen()
Example #14
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
Example #15
0
def launch(argsList=None):
    """
    Opens the mod's help file or web page externally if it can be found or displays an error alert.

    On Windows this opens the compiled HTML help file (CHM).
    On Mac this opens a browser window to the online help file.
    """
    if BugPath.isMac():
        sLang = ["ENG", "ENG", "DEU", "ITA", "ENG"]
        url = "http://civ4bug.sourceforge.net/BUGModHelp/%s/index.htm" % sLang[
            CyGame().getCurrentLanguage()]
        try:
            import webbrowser
            showLaunchMessage()
            webbrowser.open(url, new=1, autoraise=1)
            return True
        except:
            showErrorAlert(
                BugUtil.getPlainText(
                    "TXT_KEY_BUG_HELP_CANNOT_OPEN_BROWSER_TITLE"),
                BugUtil.getText("TXT_KEY_BUG_HELP_CANNOT_OPEN_BROWSER_BODY",
                                (url, )))
    else:
        sLang = ["ENG", "FRA", "DEU", "ITA", "ESP"]
        name = "BUG Mod Help-%s.chm" % (sLang[CyGame().getCurrentLanguage()])
        file = BugPath.findInfoFile(name)
        if file:
            import os
            message = BugUtil.getPlainText("TXT_KEY_BUG_HELP_OPENING")
            CyInterface().addImmediateMessage(message, "")
            os.startfile(file)
            return True
        else:
            showErrorAlert(
                BugUtil.getPlainText("TXT_KEY_BUG_HELP_MISSING_TITLE"),
                BugUtil.getText("TXT_KEY_BUG_HELP_MISSING_BODY", (name, )))
    return False
    def getText(self, bNumber, bSmily, bWorstEnemy, bWarPeace):
        """ Returns a string describing the attitude this player has toward target. """
        if self.bHasActiveMetBoth:
            nAttitude = self.getCount()

            if bNumber:
                szText = str(nAttitude)
                if nAttitude > 0:
                    szText = "+" + szText
                if bSmily:
                    szText = "[" + szText + "] "
                else:
                    szText = "<font=3>   " + szText + "</font> "
            else:
                szText = ""

            iColor = self.getColor()
            szText = BugUtil.colorText(szText, iColor)
            if bSmily:
                szText = self.getIcon() + " " + szText

            pThisPlayer = gc.getPlayer(self.iThisPlayer)
            pTargetPlayer = gc.getPlayer(self.iTargetPlayer)
            if bWorstEnemy and isWorstEnemy(pThisPlayer, pTargetPlayer):
                szText += u"%c" % (CyGame().getSymbolID(FontSymbols.ANGRY_POP_CHAR))

            if bWarPeace:
                iThisTeam = pThisPlayer.getTeam()
                pThisTeam = gc.getTeam(iThisTeam)
                iTargetTeam = pTargetPlayer.getTeam()
                pTargetTeam = gc.getTeam(iTargetTeam)
                if pThisTeam.isAtWar(iTargetTeam):
                    szText += u"%c" % (gc.getCommerceInfo(CommerceTypes.COMMERCE_GOLD).getChar() + 25)
                elif gc.getGame().getActiveTeam() in (iThisTeam, iTargetTeam):
                    bPeace = False
                    if pThisTeam.isForcePeace(iTargetTeam):
                        bPeace = True
                    elif pTargetTeam.isAVassal():
                        for iOwnerTeam in xrange(gc.getMAX_TEAMS()):
                            if pTargetTeam.isVassal(iOwnerTeam) and pThisTeam.isForcePeace(iOwnerTeam):
                                bPeace = True
                                break
                    if bPeace:
                        szText += u"%c" % (gc.getCommerceInfo(CommerceTypes.COMMERCE_GOLD).getChar() + 26)

            return szText
        return ""
    def update(self, fDelta):
        if (CyInterface().isDirty(
                InterfaceDirtyBits.Domestic_Advisor_DIRTY_BIT) == True):
            CyInterface().setDirty(
                InterfaceDirtyBits.Domestic_Advisor_DIRTY_BIT, False)

            # screen = CyGInterfaceScreen( "DomesticAdvisor", CvScreenEnums.DOMESTIC_ADVISOR )
            player = gc.getPlayer(CyGame().getActivePlayer())

            i = 0
            (loopCity, iter) = player.firstCity(False)
            while loopCity:
                #if not loopCity.isNone() and loopCity.getOwner() == player.getID(): #only valid cities
                self.updateTable(loopCity, i)
                i += 1
                (loopCity, iter) = player.nextCity(iter, False)

            self.updateSpecialists()

        return
 def doReInit(self):
     iPlayer = PyPlayer(CyGame().getActivePlayer())
     unitList = iPlayer.getUnitList()
     # Loop for all players cities
     for ii in xrange(len(unitList)):
         pLoopUnit = unitList[ii]
         # get the group the unit belongs to.
         pGroup = pLoopUnit.getGroup()
         # check if unit is doing air patrol
         if (pGroup.getActivityType() == ActivityTypes.ACTIVITY_INTERCEPT):
             # remove mission (this one shold be obsolete, but who knows ;)
             pGroup.popMission()
             pPlot = pGroup.plot()
             # add new mission -> fortify
             pGroup.pushMission(MissionTypes.MISSION_FORTIFY, 0, 0, 0,
                                False, False, MissionAITypes.NO_MISSIONAI,
                                pPlot, pLoopUnit)
             # add new mission -> air patrol
             pGroup.pushMission(MissionTypes.MISSION_AIRPATROL, 0, 0, 0,
                                False, False, MissionAITypes.NO_MISSIONAI,
                                pPlot, pLoopUnit)
Example #19
0
def initModFolder():
    """
    Checks if BUG is running as a mod and sets the folder and name if so.
    """
    global _modFolderInitDone
    if _modFolderInitDone:
        return
    if not CyGame().isFinalInitialized():
        BugUtil.debug("BugInit - game not fully initialized")
        return
    BugUtil.debug("BugPath - initializing mod folder")
    global _modDir, _modFolder
    try:
        replay = CyReplayInfo()
        replay.createInfo(0)
        modDir = replay.getModName().replace('\\', r'/')
    except:
        BugUtil.trace("replay not ready")
    else:
        if modDir and len(modDir) > 2:
            if not setModDir(abspath(modDir)):
                BugUtil.error("Replay provided invalid mod directory")
    if not _modDir:
        BugUtil.debug("BugPath - checking CvModFolder")
        try:
            import CvModFolder
            modFolder = CvModFolder.modFolder
        except ImportError:
            BugUtil.debug("BugPath - CvModFolder module not present")
        except AttributeError:
            BugUtil.error("CvModFolder.py module has no modFolder setting")
        else:
            if not setModDir(join(getRootDir(), MODS_FOLDER, modFolder)):
                if not setModDir(join(getAppDir(), MODS_FOLDER, modFolder)):
                    BugUtil.error(
                        "Cannot find mod folder using '%s' from CvModFolder.py",
                        modFolder)
    if not _modFolder:
        BugUtil.debug("BugPath - no mod directory found")
    _modFolderInitDone = True
    def drawContents(self):

        # Get the screen and the player
        screen = CyGInterfaceScreen("DomesticAdvisor",
                                    CvScreenEnums.DOMESTIC_ADVISOR)
        player = gc.getPlayer(CyGame().getActivePlayer())

        screen.moveToFront("Background")

        # Build the table
        screen.addTableControlGFC("CityListBackground", 21, 18, 21,
                                  self.nTableWidth, self.nTableHeight, True,
                                  False, 24, 24,
                                  TableStyles.TABLE_STYLE_STANDARD)
        screen.enableSelect("CityListBackground", True)
        screen.enableSort("CityListBackground")
        screen.setStyle("CityListBackground", "Table_StandardCiv_Style")

        # Loop through the cities
        i = 0
        (loopCity, iter) = player.firstCity(False)
        while loopCity:
            screen.appendTableRow("CityListBackground")
            if (loopCity.getName() in self.listSelectedCities):
                screen.selectRow("CityListBackground", i, True)
            self.updateTable(loopCity, i)
            i += 1
            (loopCity, iter) = player.nextCity(iter, False)

        self.drawHeaders()

        self.drawSpecialists()

        screen.moveToBack("DomesticAdvisorBG")

        self.updateAppropriateCitySelection()

        CyInterface().setDirty(InterfaceDirtyBits.Domestic_Advisor_DIRTY_BIT,
                               True)
Example #21
0
def configure(logging=None, noLogEvents=None):
    # """Sets the global event manager's logging options."""
    # if g_eventManager:
    # g_eventManager.setLogging(logging)
    # g_eventManager.setNoLogEvents(noLogEvents)
    # else:
    # BugUtil.error("BugEventManager - BugEventManager not setup before configure()")
    # K-Mod. I've expanded the purpose of this function.
    """Sets the global event manager's logging options. And registers some BUG events handlers."""

    if not g_eventManager:
        BugUtil.error(
            "BugEventManager - BugEventManager not setup before configure()")
        return

    g_eventManager.setLogging(logging)
    g_eventManager.setNoLogEvents(noLogEvents)

    # K-Mod. Don't use register BUG events for PitBoss host.
    # (Note: actually, if this is a PitBoss host, this function won't even be called
    #  because the BUG core will not initialize any mod components in PitBoss mode.)
    if CyGame().isPitbossHost():
        BugUtil.debug(
            "BugEventManager - skipping event registration for PitBoss host")
        return
    # K-Mod end

    # --------- Better BTS AI (2/2) (moved by K-Mod) -------------
    # K-Mod, only enable these feature if the cheat mode is enabled.
    if getChtLvl():
        AIAutoPlay.AIAutoPlay(g_eventManager)
        ChangePlayer.ChangePlayer(g_eventManager)
        Tester.Tester(g_eventManager)

    # g_eventManager.addEventHandler("kbdEvent", g_eventManager.onKbdEvent)
    g_eventManager.addEventHandler("OnLoad", g_eventManager.resetActiveTurn)
    g_eventManager.addEventHandler("GameStart", g_eventManager.resetActiveTurn)
        def placeStats(self):

                screen = self.top.getScreen()

                panelName = self.top.getNextWidgetName()

                # PAE: Unit class
                iUnitClass = gc.getUnitInfo(self.iUnit).getUnitClassType()

                # Unit combat group
                iCombatType = gc.getUnitInfo(self.iUnit).getUnitCombatType()
                if (iCombatType != -1):
                        screen.setImageButton(self.top.getNextWidgetName(), gc.getUnitCombatInfo(iCombatType).getButton(), self.X_STATS_PANE + 7, self.Y_STATS_PANE - 36, 32, 32, WidgetTypes.WIDGET_PEDIA_JUMP_TO_UNIT_COMBAT, iCombatType, 0)
                        screen.setText(self.top.getNextWidgetName(), "", u"<font=4>" + gc.getUnitCombatInfo(iCombatType).getDescription() + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_STATS_PANE + 45, self.Y_STATS_PANE - 31, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_PEDIA_JUMP_TO_UNIT_COMBAT, iCombatType, 0)

                screen.addListBoxGFC(panelName, "", self.X_STATS_PANE, self.Y_STATS_PANE, self.W_STATS_PANE, self.H_STATS_PANE, TableStyles.TABLE_STYLE_EMPTY)
                screen.enableSelect(panelName, False)

                if (gc.getUnitInfo(self.iUnit).getAirCombat() > 0 and gc.getUnitInfo(self.iUnit).getCombat() == 0):
                        iStrength = gc.getUnitInfo(self.iUnit).getAirCombat()
                else:
                        iStrength = gc.getUnitInfo(self.iUnit).getCombat()

                # szName = self.top.getNextWidgetName()
                szStrength = localText.getText("TXT_KEY_PEDIA_STRENGTH", ( iStrength, ) )
                screen.appendListBoxStringNoUpdate(panelName, u"<font=3>" + szStrength.upper() + u"%c" % CyGame().getSymbolID(FontSymbols.STRENGTH_CHAR) + u"</font>", WidgetTypes.WIDGET_GENERAL, 0, 0, CvUtil.FONT_LEFT_JUSTIFY)

                # szName = self.top.getNextWidgetName()
                szMovement = localText.getText("TXT_KEY_PEDIA_MOVEMENT", ( gc.getUnitInfo(self.iUnit).getMoves(), ) )
                screen.appendListBoxStringNoUpdate(panelName, u"<font=3>" + szMovement.upper() + u"%c" % CyGame().getSymbolID(FontSymbols.MOVES_CHAR) + u"</font>", WidgetTypes.WIDGET_GENERAL, 0, 0, CvUtil.FONT_LEFT_JUSTIFY)

                # PAE: not buildable units
                if gc.getUnitInfo(self.iUnit).getProductionCost() == -1:
                        # szName = self.top.getNextWidgetName()
                        szText = localText.getText("TXT_KEY_PEDIA_NOCOST", ())
                        screen.appendListBoxStringNoUpdate(panelName, u"<font=3>" + szText + u"</font>", WidgetTypes.WIDGET_GENERAL, 0, 0, CvUtil.FONT_LEFT_JUSTIFY)
                elif (gc.getUnitInfo(self.iUnit).getProductionCost() >= 0 and not gc.getUnitInfo(self.iUnit).isFound()):
                        # szName = self.top.getNextWidgetName()
                        if self.top.iActivePlayer == -1:
                            iKosten = gc.getUnitInfo(self.iUnit).getProductionCost() * gc.getDefineINT("UNIT_PRODUCTION_PERCENT") / 100
                            #szCost = localText.getText("TXT_KEY_PEDIA_COST", ((gc.getUnitInfo(self.iUnit).getProductionCost() * gc.getDefineINT("UNIT_PRODUCTION_PERCENT"))/100,))
                        else:
                            iKosten = gc.getActivePlayer().getUnitProductionNeeded(self.iUnit)
                            #szCost = localText.getText("TXT_KEY_PEDIA_COST", ( gc.getActivePlayer().getUnitProductionNeeded(self.iUnit), ) )
                        szCost = localText.getText("TXT_KEY_PEDIA_COST", ( iKosten, ) )
                        szText = u"<font=3>" + szCost.upper() + u"%c" % gc.getYieldInfo(YieldTypes.YIELD_PRODUCTION).getChar()
                        if gc.getUnitInfo(self.iUnit).isMilitaryHappiness():
                            if self.iUnit == gc.getInfoTypeForString("UNIT_WARRIOR") or self.iUnit == gc.getInfoTypeForString("UNIT_HUNTER"): iKosten = 0
                            szText += u" %d%c" % (iKosten / 2, gc.getYieldInfo(YieldTypes.YIELD_FOOD).getChar())
                        szText += u"</font>"
                        screen.appendListBoxStringNoUpdate(panelName, szText, WidgetTypes.WIDGET_GENERAL, 0, 0, CvUtil.FONT_LEFT_JUSTIFY)

                if (gc.getUnitInfo(self.iUnit).getAirRange() > 0):
                        # szName = self.top.getNextWidgetName()
                        szRange = localText.getText("TXT_KEY_PEDIA_RANGE", ( gc.getUnitInfo(self.iUnit).getAirRange(), ) )
                        screen.appendListBoxStringNoUpdate(panelName, u"<font=3>" + szRange.upper() + u"</font>", WidgetTypes.WIDGET_GENERAL, 0, 0, CvUtil.FONT_LEFT_JUSTIFY)

                # PAE more infos
                if gc.getUnitClassInfo(iUnitClass).getMaxPlayerInstances() != -1:
                        # szName = self.top.getNextWidgetName()
                        szText = localText.getText("TXT_KEY_PEDIA_MAX_PLAYER", ( gc.getUnitClassInfo(iUnitClass).getMaxPlayerInstances(), ) )
                        screen.appendListBoxStringNoUpdate(panelName, u"<font=3>" + szText.upper() + u"</font>", WidgetTypes.WIDGET_GENERAL, 0, 0, CvUtil.FONT_LEFT_JUSTIFY)

                if gc.getUnitClassInfo(iUnitClass).getMaxGlobalInstances() != -1:
                        # szName = self.top.getNextWidgetName()
                        szText = localText.getText("TXT_KEY_PEDIA_MAX_GLOBAL", ( gc.getUnitClassInfo(iUnitClass).getMaxGlobalInstances(), ) )
                        screen.appendListBoxStringNoUpdate(panelName, u"<font=3>" + szText.upper() + u"</font>", WidgetTypes.WIDGET_GENERAL, 0, 0, CvUtil.FONT_LEFT_JUSTIFY)

                if (gc.getUnitInfo(self.iUnit).getExtraCost() > 0):
                        # szName = self.top.getNextWidgetName()
                        szText = localText.getText("TXT_KEY_UNIT_EXTRA_COST", ( gc.getUnitInfo(self.iUnit).getExtraCost(), ) )
                        screen.appendListBoxStringNoUpdate(panelName, u"<font=3>" + szText.upper() + u"</font>", WidgetTypes.WIDGET_GENERAL, 0, 0, CvUtil.FONT_LEFT_JUSTIFY)


                screen.updateListBox(panelName)
Example #23
0
 def __init__(self):
     super(RootTable, self).__init__("root", dict())
     self.game = CyGame()
Example #24
0
    def drawContents(self):

        screen = self.getScreen()
        self.deleteAllWidgets()

        BUTTON_SIZE = 48

        # +++ 1 +++ Units with trade routes
        lTradeUnitsLand = [
            gc.getInfoTypeForString("UNIT_TRADE_MERCHANT"),
            gc.getInfoTypeForString("UNIT_CARAVAN")
        ]
        lTradeUnitsSea = [
            gc.getInfoTypeForString("UNIT_TRADE_MERCHANTMAN"),
            gc.getInfoTypeForString("UNIT_GAULOS"),
            gc.getInfoTypeForString("UNIT_CARVEL_TRADE")
        ]

        list1 = []
        list2 = []

        pPlayer = gc.getPlayer(CyGame().getActivePlayer())
        (unit, pIter) = pPlayer.firstUnit(False)
        while unit:
            if unit.getUnitType() in lTradeUnitsLand:
                if int(CvUtil.getScriptData(unit, ["autA"], 0)):
                    list1.append(unit)
            elif unit.getUnitType() in lTradeUnitsSea:
                if int(CvUtil.getScriptData(unit, ["autA"], 0)):
                    list2.append(unit)

            (unit, pIter) = pPlayer.nextUnit(pIter, False)

        # Zeige zuerst Landeinheiten, danach Schiffe
        lHandelseinheiten = list1 + list2

        iY = 80
        i = 0

        iRange = len(lHandelseinheiten)
        if iRange == 0:
            szText = localText.getText("TXT_KEY_TRADE_ADVISOR_INFO2", ())
            screen.setLabel("Label1_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, 100, iY+20, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
        else:
            for j in xrange(iRange):
                pUnit = lHandelseinheiten[j]

                screen.addPanel( "PanelBG_"+str(i), u"", u"", True, False, 40, iY, 935, 51, PanelStyles.PANEL_STYLE_MAIN_BLACK25 )
                iY += 4

                # Button unit
                screen.setImageButton("L1_"+str(i), pUnit.getButton(), 50, iY, BUTTON_SIZE, BUTTON_SIZE, WidgetTypes.WIDGET_GENERAL, 1, pUnit.getID())

                # Unit name
                szText = pUnit.getName()
                screen.setLabel("L2_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, 100, iY+5, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

                # Unit load
                szText = localText.getText("TXT_UNIT_INFO_BAR_5", ()) + u" "
                iValue1 = CvUtil.getScriptData(pUnit, ["b"], -1)
                if iValue1 != -1:
                    sBonusDesc = gc.getBonusInfo(iValue1).getDescription()
                    iBonusChar = gc.getBonusInfo(iValue1).getChar()
                    szText += localText.getText("TXT_UNIT_INFO_BAR_4", (iBonusChar,sBonusDesc))
                else:
                    szText += localText.getText("TXT_KEY_NO_BONUS_STORED", ())

                screen.setLabel("L3_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, 100, iY+24, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

                # City 1
                iCityX = int(CvUtil.getScriptData(pUnit, ["autX1"], -1))
                iCityY = int(CvUtil.getScriptData(pUnit, ["autY1"], -1))
                tmpPlot = CyMap().plot(iCityX, iCityY)
                if tmpPlot and not tmpPlot.isNone() and tmpPlot.isCity():
                    szText = tmpPlot.getPlotCity().getName()
                    if tmpPlot.getOwner() == CyGame().getActivePlayer(): iTmpX = 470
                    else: iTmpX = 500
                    screen.setLabel("L4_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_RIGHT_JUSTIFY, iTmpX, iY+5, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
                if tmpPlot.getOwner() != -1:
                    iCiv = gc.getPlayer(tmpPlot.getOwner()).getCivilizationType()
                    # Flagge
                    if tmpPlot.getOwner() == CyGame().getActivePlayer():
                      screen.addFlagWidgetGFC("L5_"+str(i), 480, iY, 24, 54, tmpPlot.getOwner(), WidgetTypes.WIDGET_FLAG, tmpPlot.getOwner(), -1)
                    # Civ-Button
                    else:
                      screen.setImageButton("L5_"+str(i), gc.getCivilizationInfo(iCiv).getButton(), 476, iY+24, 24, 24, WidgetTypes.WIDGET_PEDIA_JUMP_TO_CIV, iCiv, -1)
                    szText = gc.getPlayer(tmpPlot.getOwner()).getCivilizationDescription(0)
                    screen.setLabel("L6_"+str(i), "Background", u"<font=2>" + szText + u"</font>", CvUtil.FONT_RIGHT_JUSTIFY, 470, iY+28, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_PEDIA_JUMP_TO_CIV, iCiv, -1 )

                # Button Bonus 1
                iBonus = CvUtil.getScriptData(pUnit, ["autB1"], -1)
                if iBonus != -1:
                    screen.setImageButton("L7_"+str(i), gc.getBonusInfo(iBonus).getButton(), 510, iY, BUTTON_SIZE, BUTTON_SIZE, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BONUS, iBonus, -1)

                # Buttons Arrow to left
                screen.setImageButton("L8_"+str(i), "Art/Interface/Buttons/arrow_left.tga", 580, iY+9, 32, 32, WidgetTypes.WIDGET_GENERAL, -1, -1)

                # Promotion Escort / Begleitschutz
                iPromo = gc.getInfoTypeForString("PROMOTION_SCHUTZ")
                if pUnit.isHasPromotion(iPromo):
                    screen.setImageButton("L14_"+str(i), gc.getPromotionInfo(iPromo).getButton(), 615, iY+9, 32, 32, WidgetTypes.WIDGET_PEDIA_JUMP_TO_PROMOTION, iPromo, -1)

                # Button Arrow to right
                screen.setImageButton("L9_"+str(i), "Art/Interface/Buttons/arrow_right.tga", 650, iY+9, 32, 32, WidgetTypes.WIDGET_GENERAL, -1, -1)

                # Button Bonus 2
                iBonus = CvUtil.getScriptData(pUnit, ["autB2"], -1)
                if iBonus != -1:
                    screen.setImageButton("L10_"+str(i), gc.getBonusInfo(iBonus).getButton(), 700, iY, BUTTON_SIZE, BUTTON_SIZE, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BONUS, iBonus, -1)

                # City 2
                iCityX = int(CvUtil.getScriptData(pUnit, ["autX2"], -1))
                iCityY = int(CvUtil.getScriptData(pUnit, ["autY2"], -1))
                tmpPlot = CyMap().plot(iCityX,iCityY)
                if tmpPlot and not tmpPlot.isNone() and tmpPlot.isCity():
                    szText = tmpPlot.getPlotCity().getName()
                    if tmpPlot.getOwner() == CyGame().getActivePlayer():
                        iTmpX = 790
                    else:
                        iTmpX = 760
                    screen.setLabel("L11_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, iTmpX, iY+5, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
                if tmpPlot.getOwner() != -1:
                    iCiv = gc.getPlayer(tmpPlot.getOwner()).getCivilizationType()
                    # Flagge
                    if tmpPlot.getOwner() == CyGame().getActivePlayer():
                      screen.addFlagWidgetGFC("L12_"+str(i), 756, iY, 24, 54, tmpPlot.getOwner(), WidgetTypes.WIDGET_FLAG, tmpPlot.getOwner(), -1)
                    # Civ-Button
                    else:
                      screen.setImageButton("L12_"+str(i), gc.getCivilizationInfo(iCiv).getButton(), 760, iY+24, 24, 24, WidgetTypes.WIDGET_PEDIA_JUMP_TO_CIV, iCiv, -1)
                    szText = gc.getPlayer(tmpPlot.getOwner()).getCivilizationDescription(0)
                    screen.setLabel("L13_"+str(i), "Background", u"<font=2>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, 790, iY+28, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_PEDIA_JUMP_TO_CIV, iCiv, -1 )

                # Cancel Button
                screen.setImageButton("L15_"+str(i), ArtFileMgr.getInterfaceArtInfo("INTERFACE_TRADE_AUTO_STOP").getPath(), 900, iY, BUTTON_SIZE, BUTTON_SIZE, WidgetTypes.WIDGET_GENERAL, 748, pUnit.getID())

                # ----
                i += 1
                iY += 60
Example #25
0
    def showScreen(self, bFromHallOfFame):

        # Create a new screen
        screen = self.getScreen()
        if screen.isActive():
            return
        self.calculateLayout()  # advc.106m
        screen.setRenderInterfaceOnly(True)
        screen.showScreen(PopupStates.POPUPSTATE_IMMEDIATE, False)

        self.EXIT_TEXT = u"<font=4>" + localText.getText(
            "TXT_KEY_PEDIA_SCREEN_EXIT", ()).upper() + u"</font>"
        self.PLAY_TEXT = u"<font=4>" + localText.getText(
            "TXT_KEY_REPLAY_SCREEN_PLAY", ()).upper() + u"</font>"
        self.FORWARD_TEXT = u"<font=4>" + localText.getText(
            "TXT_KEY_REPLAY_SCREEN_NEXT", ()).upper() + u"</font>"
        self.STOP_TEXT = u"<font=4>" + localText.getText(
            "TXT_KEY_REPLAY_SCREEN_STOP", ()).upper() + u"</font>"
        self.SPEED_TEXT = localText.getText("TXT_KEY_REPLAY_SCREEN_SPEED", ())

        self.bPlaying = False
        self.fLastUpdate = 0.
        self.iSpeed = 2
        self.iLastTurnShown = -1
        self.bFromHallOfFame = bFromHallOfFame
        self.bDone = False

        if not bFromHallOfFame:
            self.replayInfo = CyGame().getReplayInfo()
            if self.replayInfo.isNone():
                self.replayInfo = CyReplayInfo()
                self.replayInfo.createInfo(gc.getGame().getActivePlayer())

        self.iTurn = self.replayInfo.getInitialTurn()

        self.deleteAllWidgets()

        # Controls
        self.szForwardId = self.getNextWidgetName()
        self.szPlayId = self.getNextWidgetName()

        # Set the background widget and exit button
        # advc.106m: x, y were screen.centerX(0), screen.centerY(0)
        screen.setDimensions(self.X_SCREEN, self.Y_SCREEN, self.W_SCREEN,
                             self.H_SCREEN)
        screen.addDDSGFC(
            self.BACKGROUND_ID,
            ArtFileMgr.getInterfaceArtInfo("SCREEN_BG_OPAQUE").getPath(), 0, 0,
            self.W_SCREEN, self.H_SCREEN, WidgetTypes.WIDGET_GENERAL, -1, -1)
        screen.addPanel("TopPanel", u"", u"", True, False, 0, self.Y_TOP_PANEL,
                        self.W_SCREEN, self.H_PANELS,
                        PanelStyles.PANEL_STYLE_TOPBAR)
        screen.addPanel("BottomPanel", u"", u"", True, False, 0,
                        self.Y_BOTTOM_PANEL, self.W_SCREEN, self.H_PANELS,
                        PanelStyles.PANEL_STYLE_BOTTOMBAR)
        screen.showWindowBackground(False)
        screen.setText(self.EXIT_ID, "", self.EXIT_TEXT,
                       CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXIT, self.Y_EXIT, 0,
                       FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1,
                       -1)

        # Header...
        self.szHeader = self.getNextWidgetName()
        # advc.106m: X position was self.X_SCREEN; that doesn't work anymore.
        screen.setLabel(
            self.szHeader, "Background",
            u"<font=4b>" + localText.getText("TXT_KEY_REPLAY_SCREEN_TITLE",
                                             ()).upper() + u"</font>",
            CvUtil.FONT_CENTER_JUSTIFY, self.X_TITLE, self.Y_TITLE,
            self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL,
            -1, -1)

        # Minimap initialization
        self.H_MAP = (self.W_MAP * self.replayInfo.getMapHeight()
                      ) / self.replayInfo.getMapWidth()
        if (self.H_MAP > self.H_MAP_MAX):
            self.W_MAP = (self.H_MAP_MAX * self.replayInfo.getMapWidth()
                          ) / self.replayInfo.getMapHeight()
            self.H_MAP = self.H_MAP_MAX

        screen.setMinimapMap(self.replayInfo, self.X_MAP,
                             self.X_MAP + self.W_MAP, self.Y_MAP,
                             self.Y_MAP + self.H_MAP, self.Z_CONTROLS)
        screen.updateMinimapSection(True, False)
        screen.setMinimapMode(MinimapModeTypes.MINIMAPMODE_REPLAY)

        # add pane for text
        #mainPanelName = self.getNextWidgetName()
        #screen.addPanel(mainPanelName, "", "", True, True, self.X_TEXT, self.Y_TEXT, self.W_TEXT, self.H_TEXT, PanelStyles.PANEL_STYLE_IN)
        self.szAreaId = self.getNextWidgetName()
        screen.addListBoxGFC(self.szAreaId, "", self.X_TEXT, self.Y_TEXT,
                             self.W_TEXT, self.H_TEXT,
                             TableStyles.TABLE_STYLE_STANDARD)
        screen.enableSelect(self.szAreaId, False)

        self.Y_GRAPH = self.Y_MAP + self.H_MAP + self.H_MAP_GRAPH_GAP
        #self.H_GRAPH = 680 - self.Y_GRAPH
        # advc.106m:
        self.H_GRAPH = self.H_TEXT - self.H_MAP - self.H_MAP_GRAPH_GAP
        self.szGraph = self.getNextWidgetName()
        screen.addGraphWidget(
            self.szGraph, "Background",
            ArtFileMgr.getInterfaceArtInfo(
                "POPUPS_BACKGROUND_TRANSPARENT").getPath(), self.X_GRAPH,
            self.Y_GRAPH, self.Z_CONTROLS, self.W_GRAPH, self.H_GRAPH,
            WidgetTypes.WIDGET_GENERAL, -1, -1)

        self.initGraph()

        # Forward
        screen.setText(self.szForwardId, "Background", self.FORWARD_TEXT,
                       CvUtil.FONT_LEFT_JUSTIFY, self.X_FORWARD,
                       self.Y_FORWARD, self.Z_CONTROLS, FontTypes.TITLE_FONT,
                       WidgetTypes.WIDGET_GENERAL, -1, -1)

        # Play
        screen.setText(self.szPlayId, "Background", self.PLAY_TEXT,
                       CvUtil.FONT_LEFT_JUSTIFY, self.X_PLAY, self.Y_PLAY,
                       self.Z_CONTROLS, FontTypes.TITLE_FONT,
                       WidgetTypes.WIDGET_GENERAL, 1, -1)

        # Speed Slider
        self.szSliderTextId = self.getNextWidgetName()
        screen.setLabel(self.szSliderTextId, "Background", self.SPEED_TEXT,
                        CvUtil.FONT_CENTER_JUSTIFY, self.X_SPEED, self.Y_SPEED,
                        self.Z_CONTROLS, FontTypes.GAME_FONT,
                        WidgetTypes.WIDGET_GENERAL, -1, -1)

        self.szSliderId = self.getNextWidgetName()
        screen.addSlider(self.szSliderId, self.X_SLIDER, self.Y_SLIDER,
                         self.W_SLIDER, self.H_SLIDER, self.iSpeed - 1, 0,
                         self.NUM_SLIDER_STOPS - 1, WidgetTypes.WIDGET_GENERAL,
                         -1, -1, False)

        self.showEvents(self.iTurn, False)

        return
Example #26
0
    def placeStats(self):

        screen = self.top.getScreen()

        buildingInfo = gc.getBuildingInfo(self.iBuilding)

        panelName = self.top.getNextWidgetName()

        if buildingInfo.getGreatPeopleRateChange() != 0:
            y = self.Y_STATS_PANE - 30
        else:
            y = self.Y_STATS_PANE

        screen.addListBoxGFC(panelName, "", self.X_STATS_PANE, y,
                             self.W_STATS_PANE, self.H_STATS_PANE,
                             TableStyles.TABLE_STYLE_EMPTY)
        screen.enableSelect(panelName, False)

        if (isWorldWonderClass(
                gc.getBuildingInfo(self.iBuilding).getBuildingClassType())):
            iMaxInstances = gc.getBuildingClassInfo(
                gc.getBuildingInfo(self.iBuilding).getBuildingClassType()
            ).getMaxGlobalInstances()
            szBuildingType = localText.getText("TXT_KEY_PEDIA_WORLD_WONDER",
                                               ())
            if (iMaxInstances > 1):
                szBuildingType += " " + localText.getText(
                    "TXT_KEY_PEDIA_WONDER_INSTANCES", (iMaxInstances, ))
                screen.appendListBoxStringNoUpdate(
                    panelName,
                    u"<font=4>" + szBuildingType.upper() + u"</font>",
                    WidgetTypes.WIDGET_GENERAL, 0, 0, CvUtil.FONT_LEFT_JUSTIFY)

        if (isTeamWonderClass(
                gc.getBuildingInfo(self.iBuilding).getBuildingClassType())):
            iMaxInstances = gc.getBuildingClassInfo(
                gc.getBuildingInfo(self.iBuilding).getBuildingClassType()
            ).getMaxTeamInstances()
            szBuildingType = localText.getText("TXT_KEY_PEDIA_TEAM_WONDER", ())
            if (iMaxInstances > 1):
                szBuildingType += " " + localText.getText(
                    "TXT_KEY_PEDIA_WONDER_INSTANCES", (iMaxInstances, ))
                screen.appendListBoxStringNoUpdate(
                    panelName,
                    u"<font=4>" + szBuildingType.upper() + u"</font>",
                    WidgetTypes.WIDGET_GENERAL, 0, 0, CvUtil.FONT_LEFT_JUSTIFY)

        if (isNationalWonderClass(
                gc.getBuildingInfo(self.iBuilding).getBuildingClassType())):
            iMaxInstances = gc.getBuildingClassInfo(
                gc.getBuildingInfo(self.iBuilding).getBuildingClassType()
            ).getMaxPlayerInstances()
            szBuildingType = localText.getText("TXT_KEY_PEDIA_NATIONAL_WONDER",
                                               ())
            if (iMaxInstances > 1):
                szBuildingType += " " + localText.getText(
                    "TXT_KEY_PEDIA_WONDER_INSTANCES", (iMaxInstances, ))
                screen.appendListBoxStringNoUpdate(
                    panelName,
                    u"<font=4>" + szBuildingType.upper() + u"</font>",
                    WidgetTypes.WIDGET_GENERAL, 0, 0, CvUtil.FONT_LEFT_JUSTIFY)

        if (buildingInfo.getProductionCost() > 0):
            if self.top.iActivePlayer == -1:
                szCost = localText.getText(
                    "TXT_KEY_PEDIA_COST",
                    ((buildingInfo.getProductionCost() *
                      gc.getDefineINT("BUILDING_PRODUCTION_PERCENT")) / 100, ))
            else:
                szCost = localText.getText("TXT_KEY_PEDIA_COST", (gc.getPlayer(
                    self.top.iActivePlayer).getBuildingProductionNeeded(
                        self.iBuilding), ))
            screen.appendListBoxStringNoUpdate(
                panelName, u"<font=4>" + szCost.upper() +
                u"%c" % gc.getYieldInfo(YieldTypes.YIELD_PRODUCTION).getChar()
                + u"</font>", WidgetTypes.WIDGET_GENERAL, 0, 0,
                CvUtil.FONT_LEFT_JUSTIFY)

        for k in xrange(YieldTypes.NUM_YIELD_TYPES):
            if (buildingInfo.getYieldChange(k) != 0):
                if (buildingInfo.getYieldChange(k) > 0):
                    szSign = "+"
                else:
                    szSign = ""

                szYield = gc.getYieldInfo(k).getDescription() + ": "

                szText1 = szYield.upper() + szSign + str(
                    buildingInfo.getYieldChange(k))
                szText2 = szText1 + (u"%c" % (gc.getYieldInfo(k).getChar()))
                screen.appendListBoxStringNoUpdate(
                    panelName, u"<font=4>" + szText2 + u"</font>",
                    WidgetTypes.WIDGET_GENERAL, 0, 0, CvUtil.FONT_LEFT_JUSTIFY)

        for k in xrange(CommerceTypes.NUM_COMMERCE_TYPES):

            iTotalCommerce = buildingInfo.getObsoleteSafeCommerceChange(
                k) + buildingInfo.getCommerceChange(k)
            if (iTotalCommerce != 0):
                if (iTotalCommerce > 0):
                    szSign = "+"
                else:
                    szSign = ""

                szCommerce = gc.getCommerceInfo(k).getDescription() + ": "

                szText1 = szCommerce.upper() + szSign + str(iTotalCommerce)
                szText2 = szText1 + (u"%c" % (gc.getCommerceInfo(k).getChar()))
                screen.appendListBoxStringNoUpdate(
                    panelName, u"<font=4>" + szText2 + u"</font>",
                    WidgetTypes.WIDGET_GENERAL, 0, 0, CvUtil.FONT_LEFT_JUSTIFY)

        iHappiness = buildingInfo.getHappiness()
        if self.top.iActivePlayer != -1:
            if (self.iBuilding == gc.getCivilizationInfo(
                    gc.getPlayer(self.top.iActivePlayer).getCivilizationType()
            ).getCivilizationBuildings(buildingInfo.getBuildingClassType())):
                iHappiness += gc.getPlayer(
                    self.top.iActivePlayer).getExtraBuildingHappiness(
                        self.iBuilding)

        if (iHappiness > 0):
            szText = localText.getText("TXT_KEY_PEDIA_HAPPY",
                                       (iHappiness, )).upper()
            screen.appendListBoxStringNoUpdate(
                panelName, u"<font=4>" + szText +
                u"%c" % CyGame().getSymbolID(FontSymbols.HAPPY_CHAR) +
                u"</font>", WidgetTypes.WIDGET_GENERAL, 0, 0,
                CvUtil.FONT_LEFT_JUSTIFY)

        elif (iHappiness < 0):
            szText = localText.getText("TXT_KEY_PEDIA_UNHAPPY",
                                       (-iHappiness, )).upper()
            screen.appendListBoxStringNoUpdate(
                panelName, u"<font=4>" + szText +
                u"%c" % CyGame().getSymbolID(FontSymbols.UNHAPPY_CHAR) +
                u"</font>", WidgetTypes.WIDGET_GENERAL, 0, 0,
                CvUtil.FONT_LEFT_JUSTIFY)

        iHealth = buildingInfo.getHealth()
        if self.top.iActivePlayer != -1:
            if (self.iBuilding == gc.getCivilizationInfo(
                    gc.getPlayer(self.top.iActivePlayer).getCivilizationType()
            ).getCivilizationBuildings(buildingInfo.getBuildingClassType())):
                iHealth += gc.getPlayer(
                    self.top.iActivePlayer).getExtraBuildingHealth(
                        self.iBuilding)

        if (iHealth > 0):
            szText = localText.getText("TXT_KEY_PEDIA_HEALTHY",
                                       (iHealth, )).upper()
            screen.appendListBoxStringNoUpdate(
                panelName, u"<font=4>" + szText +
                u"%c" % CyGame().getSymbolID(FontSymbols.HEALTHY_CHAR) +
                u"</font>", WidgetTypes.WIDGET_GENERAL, 0, 0,
                CvUtil.FONT_LEFT_JUSTIFY)

        elif (iHealth < 0):
            szText = localText.getText("TXT_KEY_PEDIA_UNHEALTHY",
                                       (-iHealth, )).upper()
            screen.appendListBoxStringNoUpdate(
                panelName, u"<font=4>" + szText +
                u"%c" % CyGame().getSymbolID(FontSymbols.UNHEALTHY_CHAR) +
                u"</font>", WidgetTypes.WIDGET_GENERAL, 0, 0,
                CvUtil.FONT_LEFT_JUSTIFY)

        if (buildingInfo.getGreatPeopleRateChange() != 0):
            szText = localText.getText(
                "TXT_KEY_PEDIA_GREAT_PEOPLE",
                (buildingInfo.getGreatPeopleRateChange(), )).upper()
            screen.appendListBoxStringNoUpdate(
                panelName, u"<font=4>" + szText +
                u"%c" % CyGame().getSymbolID(FontSymbols.GREAT_PEOPLE_CHAR) +
                u"</font>", WidgetTypes.WIDGET_GENERAL, 0, 0,
                CvUtil.FONT_LEFT_JUSTIFY)

        # PAE: Conquest Probabilty
        szText = localText.getText(
            "TXT_KEY_PEDIA_CONQUER", ()).upper() + u": " + str(
                buildingInfo.getConquestProbability()) + u"%"
        screen.appendListBoxStringNoUpdate(panelName,
                                           u"<font=4>" + szText + u"</font>",
                                           WidgetTypes.WIDGET_GENERAL, 0, 0,
                                           CvUtil.FONT_LEFT_JUSTIFY)

        screen.updateListBox(panelName)
Example #27
0
    def handleInput (self, inputClass):
        'Calls function mapped in EspionageAdvisorInputMap'

        screen = self.getScreen()
        pActivePlayer = gc.getPlayer(self.iActivePlayer)

        ##### Debug Dropdown #####
        if CyGame().isDebugMode():
            if inputClass.getFunctionName() == self.DEBUG_DROPDOWN_ID:
                iIndex = screen.getSelectedPullDownID(self.DEBUG_DROPDOWN_ID)
                self.iActivePlayer = screen.getPullDownData(self.DEBUG_DROPDOWN_ID, iIndex)
                self.drawContents()
                CyInterface().setDirty(InterfaceDirtyBits.Espionage_Advisor_DIRTY_BIT, True)

        if self.iTargetPlayer != -1:

            ##### Player Images #####
            if (inputClass.getData1() == self.iLeaderImagesID):

                self.iTargetPlayer = inputClass.getData2()

                # Loop through all images
                for iPlayerID in self.aiKnownPlayers:
                    szName = "LeaderImage%d" %(iPlayerID)
                    if (self.iTargetPlayer == iPlayerID):
                        screen.setState(szName, True)
                    else:
                        screen.setState(szName, False)

                    self.iActiveCityID = -1

                CyInterface().setDirty(InterfaceDirtyBits.Espionage_Advisor_DIRTY_BIT, True)


            ##### City Listbox #####
            if "%s%d" %(inputClass.getFunctionName(), inputClass.getID()) == self.szCityListBox:
                iCityID = inputClass.getData1()
                self.iActiveCityID = iCityID#gc.getPlayer(self.iTargetPlayer).getCity(iCityID)
                CyInterface().setDirty(InterfaceDirtyBits.Espionage_Advisor_DIRTY_BIT, True)

            # Is there any other players which have been met?
            if self.iTargetPlayer != -1:

                ##### Increase Button #####
                if inputClass.getData1() == self.iIncreaseButtonID:

                    iPlayerID = inputClass.getData2()
                    iTargetTeam = gc.getPlayer(iPlayerID).getTeam()

                    #CyMessageControl().sendEspionageSpendingWeightChange(iTargetTeam, 1)
                    # K-Mod. Right click -> min/max
                    if inputClass.getFlags() & MouseFlags.MOUSE_RBUTTONUP:
                        CyMessageControl().sendEspionageSpendingWeightChange(iTargetTeam, 99)
                    else:
                        CyMessageControl().sendEspionageSpendingWeightChange(iTargetTeam, 1)
                    # K-Mod end

                    if (pActivePlayer.getEspionageSpending(iTargetTeam) > 0):
                        szText = u"<font=2><color=0,255,0,0>%s</color></font>" %(localText.getText("TXT_KEY_ESPIONAGE_NUM_EPS_PER_TURN", (pActivePlayer.getEspionageSpending(iTargetTeam),)))
                    else:
                        szText = u"<font=2><color=192,0,0,0>%s</color></font>" %(localText.getText("TXT_KEY_ESPIONAGE_NUM_EPS_PER_TURN", (pActivePlayer.getEspionageSpending(iTargetTeam),)))

                    screen.setLabelAt("AmountText%d" %(iPlayerID), "LeaderContainer%d" % (iPlayerID), szText, 0, 247, 15 - 1, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

                    if (pActivePlayer.getEspionageSpendingWeightAgainstTeam(iTargetTeam) > 0):
                        szText = u"<font=2>%c</font>" %(gc.getCommerceInfo(CommerceTypes.COMMERCE_ESPIONAGE).getChar())
                    else:
                        szText = u""
                    attach = "LeaderContainer%d" % (iPlayerID)
                    iY = 15
                    screen.setLabelAt("SpendingIcon%d" %(iPlayerID), attach, szText, 0, 25, iY - 1, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

                    CyInterface().setDirty(InterfaceDirtyBits.Espionage_Advisor_DIRTY_BIT, True)

                ##### Decrease Button #####
                elif inputClass.getData1() == self.iDecreaseButtonID:

                    iPlayerID = inputClass.getData2()
                    iTargetTeam = gc.getPlayer(iPlayerID).getTeam()

                    if pActivePlayer.getEspionageSpendingWeightAgainstTeam(iTargetTeam) > 0:  # Can't reduce weight below 0
                        #CyMessageControl().sendEspionageSpendingWeightChange(iTargetTeam, -1)
                        # K-Mod. Right click -> min/max
                        if inputClass.getFlags() & MouseFlags.MOUSE_RBUTTONUP:
                            CyMessageControl().sendEspionageSpendingWeightChange(iTargetTeam, -99)
                        else:
                            CyMessageControl().sendEspionageSpendingWeightChange(iTargetTeam, -1)
                        # K-Mod end

                        if pActivePlayer.getEspionageSpending(iTargetTeam) > 0:
                            szText = u"<font=2><color=0,255,0,0>%s</color></font>" %(localText.getText("TXT_KEY_ESPIONAGE_NUM_EPS_PER_TURN", (pActivePlayer.getEspionageSpending(iTargetTeam),)))
                        else:
                            szText = u"<font=2><color=192,0,0,0>%s</color></font>" %(localText.getText("TXT_KEY_ESPIONAGE_NUM_EPS_PER_TURN", (pActivePlayer.getEspionageSpending(iTargetTeam),)))

                        screen.setLabelAt("AmountText%d" %(iPlayerID), "LeaderContainer%d" % (iPlayerID), szText, 0, 247, 15 - 1, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

                        if pActivePlayer.getEspionageSpendingWeightAgainstTeam(iTargetTeam) > 0:
                            szText = u"<font=2>%c</font>" %(gc.getCommerceInfo(CommerceTypes.COMMERCE_ESPIONAGE).getChar())
                        else:
                            szText = u""
                        attach = "LeaderContainer%d" % (iPlayerID)
                        iY = 15
                        screen.setLabelAt("SpendingIcon%d" %(iPlayerID), attach, szText, 0, 25, iY - 1, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

                        CyInterface().setDirty(InterfaceDirtyBits.Espionage_Advisor_DIRTY_BIT, True)

        return 0
Example #28
0
File: BugData.py Project: AP-ML/DTM
	def __init__(self):
		super(RootTable, self).__init__("root", dict())
		self.game = CyGame()
Example #29
0
	def __init__(self):
		from CvPythonExtensions import CyGame
		super(RootTable, self).__init__("root", dict())
		self.game = CyGame()
    def drawContents(self):
        screen = self.getScreen()
        self.deleteAllWidgets()
        # addPanel: Vertical, scrollable, x ,y, width, height
        # +++ 1 +++ PANEL Requests: Trade Requests
        screen.addPanel( "PanelRequests", u"", u"", True, False, 35, 75, 945, 200, PanelStyles.PANEL_STYLE_DAWNTOP )
        BUTTON_SIZE = 48
        iY = 30
        # Cities with Special bonus order
        bMessageNoCities = True
        i = 0
        for iPlayer in xrange(gc.getMAX_PLAYERS()):
            loopPlayer = gc.getPlayer(iPlayer)
            if loopPlayer.isAlive() and not loopPlayer.isHuman() and not loopPlayer.isBarbarian():
                (pCity, pIter) = loopPlayer.firstCity(False)
                while pCity:
                    if not pCity.isNone() and pCity.getOwner() == loopPlayer.getID(): #only valid cities
                        iTurn = int(CvUtil.getScriptData(pCity, ["tst"], -1)) - gc.getGame().getGameTurn()
                        if iTurn != -1:
                            i += 1
                            pTeam = gc.getTeam(loopPlayer.getTeam())
                            if pTeam.isHasMet(gc.getPlayer(gc.getGame().getActivePlayer()).getTeam()):
                                iBonus = int(CvUtil.getScriptData(pCity, ["tsb"],-1))
                                if iBonus != -1:
                                    iCiv = loopPlayer.getCivilizationType()
                                    iLeader = loopPlayer.getLeaderType()
                                    iPop = pCity.getPopulation()
                                    bMessageNoCities = False
                                    iX = 50
                                    iY += 60
                                    # Button Bonus
                                    screen.setImageButton("Label_1_"+str(i), gc.getBonusInfo(iBonus).getButton(), iX, iY, BUTTON_SIZE, BUTTON_SIZE, WidgetTypes.WIDGET_PEDIA_JUMP_TO_BONUS, iBonus, -1)
                                    iX += 60
                                    # Text City name
                                    szText = pCity.getName()
                                    screen.setLabel("Label_2_"+str(i), "Background", u"<font=4>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, iX, iY + 2, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
                                    # Text CIV Name
                                    szText = loopPlayer.getCivilizationDescription(0)
                                    screen.setLabel("Label_CivName_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, iX, iY + 25, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
                                    iX += 325
                                    # Text City Population
                                    szText = localText.getText("POP:", ()) + u" %d" %(iPop)
                                    screen.setLabel("Label_3_"+str(i), "Background", u"<font=4>" + szText + u"</font>", CvUtil.FONT_RIGHT_JUSTIFY, iX, iY + 10, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
                                    iX += 10
                                    # Button Civ
                                    screen.setImageButton("Label_4_"+str(i), gc.getCivilizationInfo(iCiv).getButton(), iX, iY, BUTTON_SIZE, BUTTON_SIZE, WidgetTypes.WIDGET_PEDIA_JUMP_TO_CIV, iCiv, -1)
                                    iX += 60
                                    # Button Leader
                                    screen.setImageButton("Label_5_"+str(i), gc.getLeaderHeadInfo(iLeader).getButton(), iX, iY, BUTTON_SIZE, BUTTON_SIZE, WidgetTypes.WIDGET_PEDIA_JUMP_TO_LEADER, iLeader, iCiv)
                                    iX += 60
                                    # Text Open Borders
                                    szText = localText.getText("TXT_KEY_MISC_OPEN_BORDERS", ()) + u": "
                                    if pTeam.isOpenBorders(CyGame().getActiveTeam()):
                                        szText += localText.getText("TXT_KEY_COLOR_POSITIVE", ()) + localText.getText("TXT_KEY_POPUP_YES", ( )) + localText.getText("TXT_KEY_COLOR_REVERT", ())
                                    else:
                                        szText += localText.getText("TXT_KEY_COLOR_NEGATIVE", ()) + localText.getText("TXT_KEY_POPUP_NO", ( )) + localText.getText("TXT_KEY_COLOR_REVERT", ())
                                    screen.setLabel("Label_6_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, iX, iY+4, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

                                    # AI Attitudes - KI Haltung
                                    iAtt = loopPlayer.AI_getAttitude(gc.getGame().getActivePlayer())
                                    lAttText = ["TXT_KEY_ATTITUDE_FURIOUS","TXT_KEY_ATTITUDE_ANNOYED","TXT_KEY_ATTITUDE_CAUTIOUS","TXT_KEY_ATTITUDE_PLEASED","TXT_KEY_ATTITUDE_FRIENDLY"]
                                    # Text Attitude
                                    szText = localText.getText("TXT_KEY_ATTITUDE", ()) + u": %c" %(CyGame().getSymbolID(FontSymbols.POWER_CHAR) + 4 + iAtt) + localText.getText(lAttText[iAtt], ())
                                    screen.setLabel("Label_7_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, iX, iY+24, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
                                    iX += 200

                                    # Text Required Bonus
                                    szText = localText.getText("TXT_KEY_TRADE_ADVISOR_1",()) + u": " + gc.getBonusInfo(iBonus).getDescription()
                                    screen.setLabel("Label_8_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, iX, iY+4, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
                                    # Text Remaining Turns
                                    szText = localText.getText("TXT_KEY_TRADE_ADVISOR_2",()) + u": %d" %(iTurn)
                                    screen.setLabel("Label_9_"+str(i), "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, iX, iY+24, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
                    (pCity, pIter) = loopPlayer.nextCity(pIter, False)

        if bMessageNoCities:
            szText = localText.getText("TXT_KEY_TRADE_ADVISOR_INFO", ())
            screen.setLabel("Label1_0", "Background", u"<font=3>" + szText + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, 100, iY+80, 0.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

        # +++ 2 +++ PANEL 1-4: Goods (Bonus resources)
        screen.addPanel( "Panel1", u"", u"", True, False,  35, 280, 225, 50, PanelStyles.PANEL_STYLE_DAWNTOP )
        screen.addPanel( "Panel2", u"", u"", True, False, 275, 280, 225, 50, PanelStyles.PANEL_STYLE_DAWNTOP )
        screen.addPanel( "Panel3", u"", u"", True, False, 515, 280, 225, 50, PanelStyles.PANEL_STYLE_DAWNTOP )
        screen.addPanel( "Panel4", u"", u"", True, False, 755, 280, 225, 50, PanelStyles.PANEL_STYLE_DAWNTOP )

        szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_TITLE_PANEL1",()).upper() + u"</font>"
        screen.setLabel("TitelPanel1", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 45, 286, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
        szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_TITLE_PANEL2",()).upper() + u"</font>"
        screen.setLabel("TitelPanel2", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 285, 286, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
        szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_TITLE_PANEL3",()).upper() + u"</font>"
        screen.setLabel("TitelPanel3", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 525, 286, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
        szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_TITLE_PANEL4",()).upper() + u"</font>"
        screen.setLabel("TitelPanel4", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 765, 286, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

        szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_WERT_PANEL1",()) + u"</font>"
        screen.setLabel("WertPanel1", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 45, 304, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
        szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_WERT_PANEL2",()) + u"</font>"
        screen.setLabel("WertPanel2", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 285, 304, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
        szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_WERT_PANEL3",()) + u"</font>"
        screen.setLabel("WertPanel3", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 525, 304, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
        szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_WERT_PANEL4",()) + u"</font>"
        screen.setLabel("WertPanel4", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 765, 304, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

        # Tabellen
        screen.addTableControlGFC("Table1", 1,  40, 340, 215, 310, False, True, 24,24, TableStyles.TABLE_STYLE_STANDARD)
        screen.addTableControlGFC("Table2", 1, 280, 340, 215, 310, False, True, 24,24, TableStyles.TABLE_STYLE_STANDARD)
        screen.addTableControlGFC("Table3", 1, 520, 340, 215, 310, False, True, 24,24, TableStyles.TABLE_STYLE_STANDARD)
        screen.addTableControlGFC("Table4", 1, 760, 340, 215, 310, False, True, 24,24, TableStyles.TABLE_STYLE_STANDARD)

        # Add bonus to tables
        # pPlayer = gc.getPlayer(self.iActivePlayer)
        iCol1 = 0
        iCol2 = 0
        iCol3 = 0
        iCol4 = 0
        iNumBonus = gc.getNumBonusInfos()
        for iLoop in xrange(iNumBonus):
            szName   = gc.getBonusInfo(iLoop).getDescription()
            szButton = gc.getBonusInfo(iLoop).getButton()
            iBonusClassType = gc.getBonusInfo(iLoop).getBonusClassType()
            # iBonusTechReveal = gc.getBonusInfo(iLoop).getTechReveal()
            #bShow = False
            #if gc.getTeam(pPlayer.getTeam()).isHasTech(iBonusTechReveal):
            bShow = True
            # BonusclassTypes PAE:
            # 0: BONUSCLASS_GENERAL
            # 1: BONUSCLASS_GRAIN
            # 2: BONUSCLASS_LIVESTOCK
            # 3: BONUSCLASS_MERCENARY
            # 4: BONUSCLASS_LUXURY
            # 5: BONUSCLASS_WONDER
            # 6: BONUSCLASS_MISC
            # 7: BONUSCLASS_RARITY
            # 8: BONUSCLASS_PLANTATION
            if bShow:
                if iBonusClassType == 7:
                    screen.appendTableRow("Table1")
                    screen.setTableText("Table1", 0, iCol1, szName, szButton, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
                    iCol1 += 1
                elif iBonusClassType == 4:
                    screen.appendTableRow("Table2")
                    screen.setTableText("Table2", 0, iCol2, szName, szButton, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
                    iCol2 += 1
                elif iBonusClassType == 0 or iBonusClassType == 5:
                    screen.appendTableRow("Table3")
                    screen.setTableText("Table3", 0, iCol3, szName, szButton, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
                    iCol3 += 1
                elif iBonusClassType == 1 or iBonusClassType == 2 or iBonusClassType == 8:
                    screen.appendTableRow("Table4")
                    screen.setTableText("Table4", 0, iCol4, szName, szButton, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
                    iCol4 += 1


        # +++ 3 +++ PANEL Bottom: Formeln

        screen.addPanel( "PanelBottom", u"", u"", True, False, 40, self.H_SCREEN-110, 935, 50, PanelStyles.PANEL_STYLE_MAIN_BLACK25 )

        szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_BOTTOM1",()) + u"</font>"
        screen.setLabel("TextBottom1", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 50, self.H_SCREEN-103, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
        szText = u"<font=3>" + localText.getText("TXT_KEY_TRADE_ADVISOR_BOTTOM2",()) + u"</font>"
        screen.setLabel("TextBottom2", "Background", szText, CvUtil.FONT_LEFT_JUSTIFY, 50, self.H_SCREEN-83, -2.0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
Example #31
0
    def placeUnitTable(self):
        screen = self.top.getScreen()

        panelName = self.top.getNextWidgetName()
        screen.addPanel(panelName, "", "", True, True, self.X_UNITS,
                        self.Y_UNITS, self.W_UNITS, self.H_UNITS,
                        PanelStyles.PANEL_STYLE_BLUE50)

        iMargin = 40
        panelName2 = self.top.getNextWidgetName()
        screen.addPanel(panelName2, "", "", True, True, self.X_UNITS + iMargin,
                        self.Y_UNITS + iMargin, self.W_UNITS - (iMargin * 2),
                        self.H_UNITS - (iMargin * 2),
                        PanelStyles.PANEL_STYLE_BLUE50)
        szTable = self.top.getNextWidgetName()
        screen.addTableControlGFC(szTable, 4, self.X_UNITS + iMargin,
                                  self.Y_UNITS + iMargin + 5,
                                  self.W_UNITS - (iMargin * 2),
                                  self.H_UNITS - (iMargin * 2) - 10, True,
                                  False, 32, 32, TableStyles.TABLE_STYLE_EMPTY)
        screen.enableSort(szTable)

        #        screen.attachTableControlGFC( panelName, szTable, 4, False, True, 32, 32, TableStyles.TABLE_STYLE_EMPTY );

        iTableWidth = self.W_UNITS - (iMargin * 2)
        iColWidth = int(iTableWidth * (7 / 19.0))
        screen.setTableColumnHeader(szTable, 0, "", iColWidth)
        iColWidth = int(iTableWidth * (4 / 19.0))
        screen.setTableColumnHeader(
            szTable, 1,
            u"%c" % CyGame().getSymbolID(FontSymbols.STRENGTH_CHAR), iColWidth)
        screen.setTableColumnHeader(
            szTable, 2, u"%c" % CyGame().getSymbolID(FontSymbols.MOVES_CHAR),
            iColWidth)
        screen.setTableColumnHeader(
            szTable, 3,
            u"%c" % gc.getYieldInfo(YieldTypes.YIELD_PRODUCTION).getChar(),
            iColWidth)

        # count units in this group
        nUnits = 0
        for j in xrange(gc.getNumUnitInfos()):
            if (self.iGroup == gc.getUnitInfo(j).getUnitCombatType()
                    or self.iGroup == gc.getNumUnitCombatInfos()):
                nUnits += 1

#         dy = self.DY_UNITS
#         yTextMargin = self.Y_TEXT_MARGIN
#         if self.iGroup == gc.getNumUnitCombatInfos():
#             dy = self.DY_UNITS/2
#             yTextMargin = 0

# sort Units by strength
        i = 0
        unitsList = [(0, 0, 0, 0, 0)] * nUnits
        for j in xrange(gc.getNumUnitInfos()):
            if (self.iGroup == gc.getUnitInfo(j).getUnitCombatType()
                    or self.iGroup == gc.getNumUnitCombatInfos()):

                if (gc.getUnitInfo(j).getDomainType() == DomainTypes.DOMAIN_AIR
                    ):
                    iStrength = unicode(gc.getUnitInfo(j).getAirCombat())
                    iMovement = unicode(gc.getUnitInfo(j).getAirRange())
                else:
                    iStrength = unicode(gc.getUnitInfo(j).getCombat())
                    iMovement = unicode(gc.getUnitInfo(j).getMoves())

                if (gc.getUnitInfo(j).getProductionCost() < 0):
                    szCost = localText.getText("TXT_KEY_NON_APPLICABLE", ())
                else:
                    szCost = unicode(
                        gc.getUnitInfo(j).getProductionCost()
                    )  # + u"%c" % gc.getYieldInfo(YieldTypes.YIELD_PRODUCTION).getChar()

                unitsList[i] = (iStrength, iMovement, szCost,
                                gc.getUnitInfo(j).getDescription(), j)
                i += 1

        for i in xrange(nUnits):
            iRow = screen.appendTableRow(szTable)
            screen.setTableText(szTable, 0, iRow,
                                u"<font=3>" + unitsList[i][3] + u"</font>", "",
                                WidgetTypes.WIDGET_PEDIA_JUMP_TO_UNIT,
                                unitsList[i][4], 1, CvUtil.FONT_LEFT_JUSTIFY)
            screen.setTableInt(
                szTable, 1, iRow,
                u"<font=3>" + unicode(unitsList[i][0]) + u"</font>", "",
                WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
            screen.setTableInt(
                szTable, 2, iRow,
                u"<font=3>" + unicode(unitsList[i][1]) + u"</font>", "",
                WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
            screen.setTableInt(
                szTable, 3, iRow,
                u"<font=3>" + unicode(unitsList[i][2]) + u"</font>", "",
                WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
Example #32
0
    def __init__(self, sWidgetId, screen, iX, iY, iWidth, iHeight, columns,
                 bUseSmallIcons, bShowRowHeader, bShowRowBorder):
        self.WIDGET_ID = sWidgetId
        self.NEXT_WIDGET_ID = sWidgetId + "IG"
        self.widgetCount = 0
        self.screen = screen
        self.xStart = iX
        self.yStart = iY
        self.width = iWidth
        self.height = iHeight
        self.columns = columns
        self.useSmallIcons = bUseSmallIcons
        self.showRowHeader = bShowRowHeader
        self.showRowBorder = bShowRowBorder
        self.columnGroups = []
        self.header = []
        self.headerFont = []
        self.data = []
        self.scrollPosition = 0
        self.textColWidth = {}
        self.StackedBarColWidth = {}

        for i in xrange(len(self.columns)):
            self.header.append("")
            self.headerFont.append(3)

        self.groupTitleHeight = 24
        self.headerHeight = 24
        self.rowHeight = 68
        self.rowHeaderHeight = 17
        self.scrollArrowSize = 24
        self.rowBorderWidth = 3
        self.scrollSpace = 3

        iTemp = [0, 0, 35, 30, 0]
        self.iconColWidth = 55 + iTemp[CyGame().getCurrentLanguage()]

        self.groupBorder = 10
        self.groupLabelOffset = "  "
        self.minColSpace = 3
        self.minRowSpace = 0

        self.SCROLL_UP = 1
        self.SCROLL_DOWN = 2
        self.SCROLL_PAGE_UP = 3
        self.SCROLL_PAGE_DOWN = 4
        self.SCROLL_TOP = 5
        self.SCROLL_BOTTOM = 6

        self.inputFunctionMap = {
            self.SCROLL_UP: self.scrollUp,
            self.SCROLL_DOWN: self.scrollDown,
            self.SCROLL_PAGE_UP: self.scrollPageUp,
            self.SCROLL_PAGE_DOWN: self.scrollPageDown,
            self.SCROLL_TOP: self.scrollTop,
            self.SCROLL_BOTTOM: self.scrollBottom,
        }
        self.keyFunctionMap = {
            int(InputTypes.KB_UP): self.scrollUp,
            int(InputTypes.KB_DOWN): self.scrollDown,
            int(InputTypes.KB_PGUP): self.scrollPageUp,
            int(InputTypes.KB_PGDN): self.scrollPageDown,
            int(InputTypes.KB_HOME): self.scrollTop,
            int(InputTypes.KB_END): self.scrollBottom,
        }