示例#1
0
def getCountsText():
    return u"%s %d, %s %d" % (
        BugUtil.getPlainText("TXT_KEY_MAPFINDER_TOTAL_MAPS"),
        iRegenCount,
        BugUtil.getPlainText("TXT_KEY_MAPFINDER_TOTAL_SAVES"),
        iSavedCount,
    )
示例#2
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
示例#3
0
 def __eventUnitRenameBegin(self, argsList):
     header = localText.getText(
         "TXT_KEY_UNIT_NAME_EM_HEADER_1",
         ())  #BugUtil.getPlainText("TXT_KEY_REMINDER_HEADER")
     #~ header = "Unit Name Testing (cancel to quit)"  #BugUtil.getPlainText("TXT_KEY_REMINDER_HEADER")
     prompt = self.Prompt  #"Enter a rename convention"   #BugUtil.getPlainText("TXT_KEY_REMINDER_PROMPT")
     ok = BugUtil.getPlainText("TXT_KEY_MAIN_MENU_OK")
     cancel = BugUtil.getPlainText("TXT_KEY_POPUP_CANCEL")
     popup = PyPopup.PyPopup(RENAME_EVENT_ID,
                             EventContextTypes.EVENTCONTEXT_SELF)
     popup.setHeaderString(header)
     popup.setBodyString(prompt)
     popup.createPythonEditBox(
         self.UnitNameConv,
         "Enter the unit name convention that you want to test.", 0)
     #		popup.createPythonCheckBoxes(1, 0)
     #		popup.setPythonCheckBoxText(0, "Check to increment counters", "Note: if checked, units named in-game commence from counter used in testing.", 0)
     popup.addButton(
         localText.getText("TXT_KEY_UNIT_NAME_EM_DONT_INCREMENT_COUNTER",
                           ()))
     popup.addButton(
         localText.getText("TXT_KEY_UNIT_NAME_EM_INCREMENT_COUNTER", ()))
     #~ popup.addButton("Ok, don't increment counter")
     #~ popup.addButton("Ok, increment counter")
     popup.addButton(cancel)
     popup.launch(False, PopupStates.POPUPSTATE_IMMEDIATE)
示例#4
0
	def _getGameYear(self):
		zturn = gc.getGame().getGameTurn() + 1
		zyear = gc.getGame().getTurnYear(zturn)
		if (zyear < 0):
			return str(-zyear) + BugUtil.getPlainText("TXT_KEY_AUTOLOG_BC")
		else:
			return str(zyear) + BugUtil.getPlainText("TXT_KEY_AUTOLOG_AD")
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
示例#6
0
    def fillTable(self, screen, table, eYield, eTileType):
        """Fills the given GFC table control with the chosen yield values."""
        self.iRow = 0
        # Tiles
        iTotal = self.getYield(eYield, eTileType)
        self.appendTable(screen, table, False, BugUtil.getText(
            LABEL_KEYS[eTileType], (self.tileCounts[eTileType],)), eYield, iTotal)

        # Trade
        for eType in (DOMESTIC_TRADE, FOREIGN_TRADE):
            iValue = self.getYield(eYield, eType)
            if iValue != 0:
                self.appendTable(screen, table, False, BugUtil.getPlainText(
                    LABEL_KEYS[eType]), eYield, iValue, TradeUtil.isFractionalTrade())
        iValue = self.getYield(eYield, DOMESTIC_TRADE) + self.getYield(eYield, FOREIGN_TRADE)
        if TradeUtil.isFractionalTrade():
            iValue //= 100
        iTotal += iValue

        # Buildings, Corporations, Specialists
        for eType in (BUILDINGS, CORPORATIONS, SPECIALISTS):
            iValue = self.getYield(eYield, eType)
            if iValue != 0:
                iTotal += iValue
                self.appendTable(screen, table, False, BugUtil.getPlainText(LABEL_KEYS[eType]), eYield, iValue)

        # Subtotal and Base Modifiers
        iModifier = self.getYield(eYield, BASE_MODIFIER)
        if iModifier != 0:
            # Subtotal
            self.appendTableTotal(screen, table, eYield, iTotal)
            #self.appendTable(screen, table, True, BugUtil.getPlainText("TXT_KEY_CONCEPT_SUBTOTAL"), eYield, iTotal)
            # Modifier
            iValue = (iTotal * (iModifier + 100) // 100) - iTotal
            iSubtotal = iTotal + iValue
            self.appendTable(screen, table, False, BugUtil.getText(
                "TXT_KEY_CONCEPT_BASE_MODIFIER", (iModifier,)), eYield, iValue)
        else:
            iSubtotal = iTotal

        # Subtotal and Production Modifiers
        if eYield == YieldTypes.YIELD_PRODUCTION and self.iProductionModifier != 0:
            # Subtotal
            self.appendTableTotal(screen, table, eYield, iSubtotal)
            #self.appendTable(screen, table, True, BugUtil.getPlainText("TXT_KEY_CONCEPT_SUBTOTAL"), eYield, iSubtotal)
            # Total
            iTotal = iTotal * (iModifier + self.iProductionModifier + 100) // 100
            # Modifier
            iValue = iTotal - iSubtotal
            self.appendTable(screen, table, False, BugUtil.getText("TXT_KEY_CONCEPT_PRODUCTION_MODIFIER",
                             (self.sModifierDetail, self.iProductionModifier)), eYield, iValue)
        else:
            iTotal = iSubtotal

        # Total
        self.appendTableTotal(screen, table, eYield, iTotal)
	def addButton (self, screen, panel, name, callback, title=None, tooltip=None):
		key = "TXT_KEY_BUG_OPTBUTTON_" + name.upper()
		title = BugUtil.getPlainText(key, title)
		tooltip = BugUtil.getPlainText(key + "_HOVER", tooltip)
		if (title):
			button = name + "_Button"
			screen.attachButton(panel, button, title, self.callbackIFace, callback, button)
			if (tooltip):
				screen.setToolTip(button, tooltip)
			return button
		return None
示例#8
0
文件: BugOptions.py 项目: AP-ML/DTM
	def translate(self):
		if self.isStringList():
			if self.valuesXmlKey:
				list = BugUtil.getPlainText(self.valuesXmlKey + "_LIST")
			else:
				list = BugUtil.getPlainText(self.xmlKey + "_LIST")
			if list:
				self.displayValues = list.split("|")
			else:
				self.displayValues = self.values
		super(BaseListOption, self).translate()
示例#9
0
	def translate(self):
		if self.isStringList():
			if self.valuesXmlKey:
				list = BugUtil.getPlainText(self.valuesXmlKey + "_LIST")
			else:
				list = BugUtil.getPlainText(self.xmlKey + "_LIST")
			if list:
				self.displayValues = list.split("|")
			else:
				self.displayValues = self.values
		super(BaseListOption, self).translate()
 def addButton (self, screen, panel, name, callback, title=None, tooltip=None):
     key = "TXT_KEY_BUG_OPTBUTTON_" + name.upper()
     title = BugUtil.getPlainText(key, title)
     tooltip = BugUtil.getPlainText(key + "_HOVER", tooltip)
     if (title):
         button = name + "_Button"
         screen.attachButton(panel, button, title, self.callbackIFace, callback, button)
         if (tooltip):
             screen.setToolTip(button, tooltip)
         return button
     return None
示例#11
0
文件: RawYields.py 项目: AP-ML/DTM
	def fillTable(self, screen, table, eYield, eTileType):
		"""Fills the given GFC table control with the chosen yield values."""
		self.iRow = 0
		# Tiles
		iTotal = self.getYield(eYield, eTileType)
		self.appendTable(screen, table, False, BugUtil.getText(LABEL_KEYS[eTileType], (self.tileCounts[eTileType],)), eYield, iTotal)
		
		# Trade
		for eType in (DOMESTIC_TRADE, FOREIGN_TRADE):
			iValue = self.getYield(eYield, eType)
			if iValue != 0:
				self.appendTable(screen, table, False, BugUtil.getPlainText(LABEL_KEYS[eType]), eYield, iValue, TradeUtil.isFractionalTrade())
		iValue = self.getYield(eYield, DOMESTIC_TRADE) + self.getYield(eYield, FOREIGN_TRADE)
		if TradeUtil.isFractionalTrade():
			iValue //= 100
		iTotal += iValue
		
		# Buildings, Corporations, Specialists
		for eType in (BUILDINGS, CORPORATIONS, SPECIALISTS):
			iValue = self.getYield(eYield, eType)
			if iValue != 0:
				iTotal += iValue
				self.appendTable(screen, table, False, BugUtil.getPlainText(LABEL_KEYS[eType]), eYield, iValue)
		
		# Subtotal and Base Modifiers
		iModifier = self.getYield(eYield, BASE_MODIFIER)
		if iModifier != 0:
			# Subtotal
			self.appendTableTotal(screen, table, eYield, iTotal)
			#self.appendTable(screen, table, True, BugUtil.getPlainText("TXT_KEY_CONCEPT_SUBTOTAL"), eYield, iTotal)
			# Modifier
			iValue = (iTotal * (iModifier + 100) // 100) - iTotal
			iSubtotal = iTotal + iValue
			self.appendTable(screen, table, False, BugUtil.getText("TXT_KEY_CONCEPT_BASE_MODIFIER", (iModifier,)), eYield, iValue)
		else:
			iSubtotal = iTotal
		
		# Subtotal and Production Modifiers
		if eYield == YieldTypes.YIELD_PRODUCTION and self.iProductionModifier != 0:
			# Subtotal
			self.appendTableTotal(screen, table, eYield, iSubtotal)
			#self.appendTable(screen, table, True, BugUtil.getPlainText("TXT_KEY_CONCEPT_SUBTOTAL"), eYield, iSubtotal)
			# Total
			iTotal = iTotal * (iModifier + self.iProductionModifier + 100) // 100
			# Modifier
			iValue = iTotal - iSubtotal
			self.appendTable(screen, table, False, BugUtil.getText("TXT_KEY_CONCEPT_PRODUCTION_MODIFIER", (self.sModifierDetail, self.iProductionModifier)), eYield, iValue)
		else:
			iTotal = iSubtotal
		
		# Total
		self.appendTableTotal(screen, table, eYield, iTotal)
	def __eventReminderStoreBegin(self, argsList):
		header = BugUtil.getPlainText("TXT_KEY_REMINDER_HEADER")
		prompt = BugUtil.getPlainText("TXT_KEY_REMINDER_PROMPT")
		ok = BugUtil.getPlainText("TXT_KEY_MAIN_MENU_OK")
		cancel = BugUtil.getPlainText("TXT_KEY_POPUP_CANCEL")
		popup = PyPopup.PyPopup(STORE_EVENT_ID, EventContextTypes.EVENTCONTEXT_SELF)
		popup.setHeaderString(header)
		popup.setBodyString(prompt)
		popup.createSpinBox(0, "", 1, 1, 1500, 0)
		popup.createEditBox("", 1)
		popup.addButton(ok)
		popup.addButton(cancel)
		popup.launch(False, PopupStates.POPUPSTATE_IMMEDIATE)
示例#13
0
 def __eventReminderStoreBegin(self, argsList):
     header = BugUtil.getPlainText("TXT_KEY_REMINDER_HEADER")
     prompt = BugUtil.getPlainText("TXT_KEY_REMINDER_PROMPT")
     ok = BugUtil.getPlainText("TXT_KEY_MAIN_MENU_OK")
     cancel = BugUtil.getPlainText("TXT_KEY_POPUP_CANCEL")
     popup = PyPopup.PyPopup(STORE_EVENT_ID,
                             EventContextTypes.EVENTCONTEXT_SELF)
     popup.setHeaderString(header)
     popup.setBodyString(prompt)
     popup.createSpinBox(0, "", 1, 1, 1500, 0)
     popup.createEditBox("", 1)
     popup.addButton(ok)
     popup.addButton(cancel)
     popup.launch(False, PopupStates.POPUPSTATE_IMMEDIATE)
	def __eventUnitRenameBegin(self, argsList):
		header = "Unit Name Testing (cancel to quit)"  #BugUtil.getPlainText("TXT_KEY_REMINDER_HEADER")
		prompt = self.Prompt   #"Enter a rename convention"   #BugUtil.getPlainText("TXT_KEY_REMINDER_PROMPT")
		ok = BugUtil.getPlainText("TXT_KEY_MAIN_MENU_OK")
		cancel = BugUtil.getPlainText("TXT_KEY_POPUP_CANCEL")
		popup = PyPopup.PyPopup(RENAME_EVENT_ID, EventContextTypes.EVENTCONTEXT_SELF)
		popup.setHeaderString(header)
		popup.setBodyString(prompt)
		popup.createPythonEditBox(self.UnitNameConv, "Enter the unit name convention that you want to test.", 0)
#		popup.createPythonCheckBoxes(1, 0)
#		popup.setPythonCheckBoxText(0, "Check to increment counters", "Note: if checked, units named in-game commence from counter used in testing.", 0)
		popup.addButton("Ok, don't increment counter")
		popup.addButton("Ok, increment counter")
		popup.addButton(cancel)
		popup.launch(False, PopupStates.POPUPSTATE_IMMEDIATE)
示例#15
0
def showChooseEventPopup(argsList):
    if getEventManager().bAllowCheats:
        ePlayer = PlayerUtil.getActivePlayerID()
        popupInfo = CyPopupInfo()
        popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
        popupInfo.setText(BugUtil.getPlainText("TXT_KEY_POPUP_SELECT_EVENT"))
        popupInfo.setData1(ePlayer)
        popupInfo.setOnClickedPythonCallback("triggerRandomEvent")
        for i in range(gc.getNumEventTriggerInfos()):
            info = gc.getEventTriggerInfo(i)
            name = info.getType().replace("EVENTTRIGGER_",
                                          "").replace("_", " ").title()
            popupInfo.addPythonButton(name, "")
        popupInfo.addPythonButton(BugUtil.getPlainText("TXT_KEY_POPUP_CANCEL"),
                                  "")
        popupInfo.addPopup(ePlayer)
示例#16
0
def regenerate():
    if canRegenerate():
        if CyInterface().getShowInterface() != InterfaceVisibility.INTERFACE_SHOW:
            CyInterface().setShowInterface(InterfaceVisibility.INTERFACE_SHOW)
        BugUtil.alert(BugUtil.getPlainText("TXT_KEY_MAPFINDER_REGNERATING"))
        # must defer to allow alert to appear
        BugUtil.deferCall(regenerateForReal)
示例#17
0
def getHoverText(eWidgetType, iData1, iData2, bOption):
    city, iTurns = getDisplayCity()
    if not city:
        # no rate or progress in any city and no city selected
        return BugUtil.getText(
            "TXT_KEY_MISC_GREAT_PERSON",
            (0, PlayerUtil.getActivePlayer().greatPeopleThreshold(False)))
    iThreshold = gc.getPlayer(city.getOwner()).greatPeopleThreshold(False)
    iProgress = city.getGreatPeopleProgress()
    iRate = city.getGreatPeopleRate()
    szText = BugUtil.colorText(city.getName(), "COLOR_HIGHLIGHT_TEXT")
    szText += u"\n"
    szText += BugUtil.getText("TXT_KEY_MISC_GREAT_PERSON",
                              (iProgress, iThreshold))
    if iRate > 0:
        szText += u"\n%d%s%s " % (iRate, g_gpIcon,
                                  BugUtil.getPlainText("TXT_KEY_PER_TURN"))
        szText += BugUtil.getText("INTERFACE_CITY_TURNS", (iTurns, ))

    percents = calcPercentages(city)
    if percents:
        percents.sort()
        percents.reverse()
        szText += u"\n"
        for iPercent, iUnit in percents:
            #           iUnit = getUnitType(gpType)
            szText += u"\n%s%s - %d%%" % (getUnitIcon(
                iUnit), gc.getUnitInfo(iUnit).getDescription(), iPercent)
    return szText
示例#18
0
def isWillingToTalk(playerOrID, toPlayerOrID):
	"""
	Returns True if <player> is willing to talk to <toPlayer>.
	
	- Every player is willing to talk to themselves
	- All human players are willing to talk
	- Uses BUG DLL if present, otherwise scans attitude hover text
	  for "Refuses to Talk!!!" in the current language
	
	Note: This function does not check if the two players can make contact.
	"""
	playerID, player = PlayerUtil.getPlayerAndID(playerOrID)
	toPlayerID = PlayerUtil.getPlayerID(toPlayerOrID)
	if playerID == toPlayerID or player.isHuman():
		# all players talk to themselves, and all humans talk
		return True
	if BugDll.isPresent():
		return player.AI_isWillingToTalk(toPlayerID)
	else:
		hover = AttitudeUtil.getAttitudeString(playerID, toPlayerID)
		if hover:
			return (hover.find(BugUtil.getPlainText("TXT_KEY_MISC_REFUSES_TO_TALK")) == -1)
		else:
			# haven't met yet
			return False
示例#19
0
def isWillingToTalk(playerOrID, toPlayerOrID):
	"""
	Returns True if <player> is willing to talk to <toPlayer>.
	
	- Every player is willing to talk to themselves
	- All human players are willing to talk
	- Uses BUG DLL if present, otherwise scans attitude hover text
	  for "Refuses to Talk!!!" in the current language
	
	Note: This function does not check if the two players can make contact.
	"""
	playerID, player = PlayerUtil.getPlayerAndID(playerOrID)
	toPlayerID = PlayerUtil.getPlayerID(toPlayerOrID)
	if playerID == toPlayerID or player.isHuman():
		# all players talk to themselves, and all humans talk
		return True
	if BugDll.isPresent():
		return player.AI_isWillingToTalk(toPlayerID)
	else:
		hover = AttitudeUtil.getAttitudeString(playerID, toPlayerID)
		if hover:
			return (hover.find(BugUtil.getPlainText("TXT_KEY_MISC_REFUSES_TO_TALK")) == -1)
		else:
			# haven't met yet
			return False
示例#20
0
 def __init__(self, grouping, key, title):
     self.grouping = grouping
     self.key = key
     if title.startswith("TXT_KEY_"):
         self.title = BugUtil.getPlainText(title)
     else:
         self.title = title
示例#21
0
	def __init__(self, grouping, key, title):
		self.grouping = grouping
		self.key = key
		if title.startswith("TXT_KEY_"):
			self.title = BugUtil.getPlainText(title)
		else:
			self.title = title
示例#22
0
def finderSave():
    MapFinderStatusScreen.setStatus(BugUtil.getPlainText("TXT_KEY_MAPFINDER_SAVING"))
    # must delay long enough to allow unrevealed tiles to disappear before taking the screenshot
    delay = options.getSaveDelay()
    if delay < MINIMUM_SAVE_DELAY:
        delay = MINIMUM_SAVE_DELAY
    BugUtil.deferCall(save, delay)
示例#23
0
def getHoverText(eWidgetType, iData1, iData2, bOption):
    city, iTurns = getDisplayCity()
    if (not city):
        # no rate or progress in any city and no city selected
        return BugUtil.getText(
            "TXT_KEY_MISC_GREAT_PERSON",
            (0, PlayerUtil.getActivePlayer().greatPeopleThreshold(False)))
    iThreshold = gc.getPlayer(city.getOwner()).greatPeopleThreshold(False)
    iProgress = city.getGreatPeopleProgress()
    iRate = city.getGreatPeopleRate()
    #szText = BugUtil.colorText(city.getName(), "COLOR_HIGHLIGHT_TEXT")
    # advc.004: Don't color the city (I don't think this matches the overall color scheme of the game)
    szText = city.getName()
    szText += u"\n"
    szText += BugUtil.getText("TXT_KEY_MISC_GREAT_PERSON",
                              (iProgress, iThreshold))
    if (iRate > 0):
        szText += u"\n%d%s%s " % (iRate, g_gpIcon,
                                  BugUtil.getPlainText("TXT_KEY_PER_TURN"))
        szText += BugUtil.getText("INTERFACE_CITY_TURNS", (iTurns, ))

    percents = calcPercentages(city)
    if (len(percents) > 0):
        percents.sort()
        percents.reverse()
        #szText += u"\n" advc.004: No empty line between total rate and percentages
        for iPercent, iUnit in percents:
            #			iUnit = getUnitType(gpType)
            szText += u"\n%s%s - %d%%" % (getUnitIcon(
                iUnit), gc.getUnitInfo(iUnit).getDescription(), iPercent)
    return szText
示例#24
0
def stop():
    global bActive
    bActive = False
    MapFinderStatusScreen.hide()
    restoreInterface()
    BugUtil.alert(
        BugUtil.getPlainText("TXT_KEY_MAPFINDER_STOPPED") + " - " +
        getCountsText())
示例#25
0
def finderSave():
    MapFinderStatusScreen.setStatus(
        BugUtil.getPlainText("TXT_KEY_MAPFINDER_SAVING"))
    # must delay long enough to allow unrevealed tiles to disappear before taking the screenshot
    delay = options.getSaveDelay()
    if delay < MINIMUM_SAVE_DELAY:
        delay = MINIMUM_SAVE_DELAY
    BugUtil.deferCall(save, delay)
示例#26
0
def regenerate():
    if canRegenerate():
        if CyInterface().getShowInterface(
        ) != InterfaceVisibility.INTERFACE_SHOW:
            CyInterface().setShowInterface(InterfaceVisibility.INTERFACE_SHOW)
        BugUtil.alert(BugUtil.getPlainText("TXT_KEY_MAPFINDER_REGNERATING"))
        # must defer to allow alert to appear
        BugUtil.deferCall(regenerateForReal)
示例#27
0
def doStop(argsList=None):
    try:
        if bActive:
            stop()
        else:
            BugUtil.alert(BugUtil.getPlainText("TXT_KEY_MAPFINDER_NOT_RUNNING"))
    except MapFinderError, e:
        e.display()
示例#28
0
 def showReminders(self, endOfTurn):
     global g_turnReminderTexts
     # <advc.127> Don't show reminder during Auto Play
     if gc.getPlayer(PlayerUtil.getActivePlayerID()).isHumanDisabled():
         return  # </advc.127>
     thisTurn = gc.getGame().getGameTurn()
     if (endOfTurn):
         prompt = BugUtil.getPlainText("TXT_KEY_REMIND_NEXT_TURN_PROMPT")
         eventId = RECALL_AGAIN_EVENT_ID
     else:
         g_turnReminderTexts = ""
         prompt = BugUtil.getPlainText("TXT_KEY_REMIND_END_TURN_PROMPT")
         eventId = RECALL_EVENT_ID
     yes = BugUtil.getPlainText("TXT_KEY_POPUP_YES")
     no = BugUtil.getPlainText("TXT_KEY_POPUP_NO")
     queue = self.reminders.get(PlayerUtil.getActivePlayerID())
     while (not queue.isEmpty()):
         nextTurn = queue.nextTurn()
         if (nextTurn > thisTurn):
             break
         elif (nextTurn < thisTurn):
             # invalid (lost) reminder
             reminder = queue.pop()
             BugUtil.warn("Reminder - skipped turn %d: %s", reminder.turn,
                          reminder.message)
         else:
             self.reminder = queue.pop()
             if (g_autolog.isLogging() and ReminderOpt.isAutolog()):
                 g_autolog.writeLog("Reminder: %s" % self.reminder.message)
             if (not endOfTurn):
                 if (g_turnReminderTexts):
                     g_turnReminderTexts += ", "
                 g_turnReminderTexts += self.reminder.message
             if (ReminderOpt.isShowMessage()):
                 CyInterface().addMessage(PlayerUtil.getActivePlayerID(),
                                          True, 10, self.reminder.message,
                                          None, 0, None, ColorTypes(8), 0,
                                          0, False, False)
             if (ReminderOpt.isShowPopup()):
                 popup = PyPopup.PyPopup(
                     eventId, EventContextTypes.EVENTCONTEXT_SELF)
                 popup.setHeaderString(self.reminder.message)
                 popup.setBodyString(prompt)
                 popup.addButton(yes)
                 popup.addButton(no)
                 popup.launch(False)
    def createMainPanel(self, screen):
        "Creates and returns the options tab panel with Exit and Help buttons"
        # VBox with two blocks: scrolling control panel and Exit button with separator
        vbox = self.name + "VBox"
        screen.attachVBox(self.tab, vbox)

        # scrollpane
        scrollpane = self.name + "Scroll"
        screen.attachScrollPanel(vbox, scrollpane)
        screen.setLayoutFlag(scrollpane, "LAYOUT_SIZE_HEXPANDING")
        screen.setLayoutFlag(scrollpane, "LAYOUT_SIZE_VEXPANDING")

        # panel for option controls
        panel = self.name + "Panel"
        screen.attachPanel(scrollpane, panel)
        screen.setStyle(panel, "Panel_Tan15_Style")
        screen.setLayoutFlag(panel, "LAYOUT_SIZE_HPREFERREDEXPANDING")
        screen.setLayoutFlag(panel, "LAYOUT_SIZE_VPREFERREDEXPANDING")

        # panel for Help and Exit buttons
        screen.attachHSeparator(vbox, "RM_ExitSeparator")
        exitPanel = self.name + "ExitBox"
        screen.attachHBox(vbox, exitPanel)
        screen.setLayoutFlag(exitPanel, "LAYOUT_HCENTER")

        # Help button
        title = BugUtil.getPlainText("TXT_KEY_BUG_OPTBUTTON_HELP", "Help")
        hover = BugUtil.getPlainText(
            "TXT_KEY_BUG_OPTBUTTON_HELP_HOVER",
            "Opens the help file. You can hit Shift-F1 from the main interface."
        )
        helpButton = self.name + "Help"
        self.addButton(screen, exitPanel, helpButton,
                       "handleBugHelpButtonInput", title, hover)

        self.addSpacer(screen, exitPanel, exitPanel)

        # Exit button
        title = BugUtil.getPlainText("TXT_KEY_PEDIA_SCREEN_EXIT", "Exit")
        hover = BugUtil.getPlainText("TXT_KEY_BUG_OPTBUTTON_EXIT_HOVER",
                                     "Exits the BUG Options screen.")
        exitButton = self.name + "Exit"
        self.addButton(screen, exitPanel, exitButton,
                       "handleBugExitButtonInput", title, hover)

        return panel
示例#30
0
	def __init__(self, key, title):
		self.index = None
		self.key = key
		if title.startswith("TXT_KEY_"):
			self.title = BugUtil.getPlainText(title)
		else:
			self.title = title
		self.groups = {}
示例#31
0
 def __init__(self, key, title):
     self.index = None
     self.key = key
     if title.startswith("TXT_KEY_"):
         self.title = BugUtil.getPlainText(title)
     else:
         self.title = title
     self.groups = {}
示例#32
0
	def fillComments(self):
		self.config.clearInitialComment()
		self.config.addInitialComment(self.id)
		self.config.addInitialComment("")
		self.config.addInitialComment(BugUtil.getPlainText("TXT_KEY_BUG_CREATED_BY_HEADER"))
		self.config.addInitialComment()
		defaultHeader = BugUtil.getPlainText("TXT_KEY_BUG_DEFAULT") + ": "
		for option in self.options:
			if not option.isParameterized():
				section = self.getSection(option.getSection())
				key = option.getKey()
				section.clearKeyComments(key)
				section.addKeyComment(key)
				for line in option.getTooltip().splitlines():
					section.addKeyComment(key, line)
				section.addKeyComment(key, defaultHeader + str(option.getDefault()))
				section.addKeyComment(key)
		self.config.addFinalComment()
示例#33
0
 def interfaceScreen(self):
     "Initial creation of the screen"
     title = BugUtil.getPlainText("TXT_KEY_BUG_OPT_TITLE", "C2C Options")
     self.pTabControl = CyGTabCtrl(title, False, False)
     self.pTabControl.setModal(1)
     self.pTabControl.setSize(950, 715)
     self.pTabControl.setControlsExpanding(False)
     self.pTabControl.setColumnLength(self.iScreenHeight)
     self.createTabs()
示例#34
0
def doStop(argsList=None):
    try:
        if bActive:
            stop()
        else:
            BugUtil.alert(
                BugUtil.getPlainText("TXT_KEY_MAPFINDER_NOT_RUNNING"))
    except MapFinderError, e:
        e.display()
示例#35
0
def launch():
	"Opens the mod's help file externally if it can be found or displays an error alert"
	sLang = ["ENG", "FRA", "DEU", "ITA", "ESP"]
	name = "BUG Mod Help-%s.chm" % (sLang[CyGame().getCurrentLanguage()])
	file = findIniFile(name)
	if file:
		message = BugUtil.getPlainText("TXT_KEY_BUG_HELP_OPENING")
		CyInterface().addImmediateMessage(message, "")
		os.startfile(file)
		return True
	else:
		title = BugUtil.getPlainText("TXT_KEY_BUG_HELP_MISSING_TITLE")
		body = BugUtil.getText("TXT_KEY_BUG_HELP_MISSING_BODY", (name,))
		popup = PyPopup.PyPopup()
		popup.setHeaderString(title)
		popup.setBodyString(body)
		popup.launch()
		return False
示例#36
0
def doStart(argsList=None):
    try:
        if not bActive:
            start()
        else:
            BugUtil.alert(BugUtil.getPlainText("TXT_KEY_MAPFINDER_ALREADY_RUNNING"))
    except MapFinderError, e:
        MapFinderStatusScreen.hide()
        e.display()
示例#37
0
def finderCanRegenerate():
    if bActive:
        try:
            if canRegenerate():
                MapFinderStatusScreen.setStatus(BugUtil.getPlainText("TXT_KEY_MAPFINDER_REGNERATING"))
                # must defer to allow screen to update
                BugUtil.deferCall(finderRegenerate)
        except MapFinderError, e:
            e.display()
            stop()
示例#38
0
文件: BugOptions.py 项目: AP-ML/DTM
	def fillComments(self):
		print dir(self.config)
		self.config.clearInitialComment()
		self.config.addInitialComment(self.id)
		self.config.addInitialComment("")
		self.config.addInitialComment(BugUtil.getPlainText("TXT_KEY_BUG_CREATED_BY_HEADER"))
		self.config.addInitialComment()
		defaultHeader = BugUtil.getPlainText("TXT_KEY_BUG_DEFAULT") + ": "
		for option in self.options:
			if not option.isParameterized():
				section = self.getSection(option.getSection())
				key = option.getKey()
				section.clearKeyComments(key)
				section.addKeyComment(key)
				for line in option.getTooltip().splitlines():
					section.addKeyComment(key, line)
				section.addKeyComment(key, defaultHeader + str(option.getDefault()))
				section.addKeyComment(key)
		self.config.addFinalComment()
示例#39
0
	def start(self):
		self.writeMsg("")
		self.writeMsg("Logging by " + CvModName.getDisplayNameAndVersion() + " (" + CvModName.getCivNameAndVersion() + ")")
		self.writeMsg("------------------------------------------------")
		zcurrturn = gc.getGame().getElapsedGameTurns() + AutologOpt.get4000BCTurn()
		zmaxturn = gc.getGame().getMaxTurns()
		zyear = gc.getGame().getGameTurnYear()
		if (zyear < 0):
			zyear = str(-zyear) + BugUtil.getPlainText("TXT_KEY_AUTOLOG_BC")
		else:
			zyear = str(zyear) + BugUtil.getPlainText("TXT_KEY_AUTOLOG_AD")
		zCurrDateTime = time.strftime("%d-%b-%Y %H:%M:%S")
		if (zmaxturn == 0):
			zsTurn = "%i" % (zcurrturn)
		else:
			zsTurn = "%i/%i" % (zcurrturn, zmaxturn)
		message = BugUtil.getText("TXT_KEY_AUTOLOG_TURN", (zsTurn, zyear, zCurrDateTime))
		self.writeMsg(message, vBold=True, vUnderline=True)
		self.bStarted = True
示例#40
0
def doStart(argsList=None):
    try:
        if not bActive:
            start()
        else:
            BugUtil.alert(
                BugUtil.getPlainText("TXT_KEY_MAPFINDER_ALREADY_RUNNING"))
    except MapFinderError, e:
        MapFinderStatusScreen.hide()
        e.display()
示例#41
0
def initModifiers (argsList=None):
	""" Creates the dictionary that maps strings to modifier keys. """
	global MODIFIER_STRING_TO_KEY
	MODIFIER_STRING_TO_KEY = {}
	for sKey in ATTITUDE_MODIFIERS:
		sStr = BugUtil.getPlainText(sKey, "NONE")
		if (sStr != "NONE"):
			# These modifier strings should contain the '%d: ' prefix
			# so we need to extract just the portion in quotes.
			pMatch = re.match(u"^.*(\".+\")", sStr, re.UNICODE)
			if (pMatch):
				MODIFIER_STRING_TO_KEY[unicode(pMatch.group(1))] = sKey
	for iMemType in range(MemoryTypes.NUM_MEMORY_TYPES):
		sKey = str(gc.getMemoryInfo(iMemType).getTextKey())
		sStr = BugUtil.getPlainText(sKey, "NONE")
		if (sStr != "NONE"):
			# These modifier strings have no extra text and so
			# we can use them directly
			MODIFIER_STRING_TO_KEY[unicode(sStr)] = sKey
def initModifiers(argsList=None):
    """ Creates the dictionary that maps strings to modifier keys. """
    global MODIFIER_STRING_TO_KEY
    MODIFIER_STRING_TO_KEY = {}
    for sKey in ATTITUDE_MODIFIERS:
        sStr = BugUtil.getPlainText(sKey, "NONE")
        if (sStr != "NONE"):
            # These modifier strings should contain the '%d: ' prefix
            # so we need to extract just the portion in quotes.
            pMatch = re.match(u"^.*(\".+\")", sStr, re.UNICODE)
            if (pMatch):
                MODIFIER_STRING_TO_KEY[unicode(pMatch.group(1))] = sKey
    for iMemType in xrange(MemoryTypes.NUM_MEMORY_TYPES):
        sKey = str(gc.getMemoryInfo(iMemType).getTextKey())
        sStr = BugUtil.getPlainText(sKey, "NONE")
        if (sStr != "NONE"):
            # These modifier strings have no extra text and so
            # we can use them directly
            MODIFIER_STRING_TO_KEY[unicode(sStr)] = sKey
示例#43
0
def finderCanRegenerate():
    if bActive:
        try:
            if canRegenerate():
                MapFinderStatusScreen.setStatus(
                    BugUtil.getPlainText("TXT_KEY_MAPFINDER_REGNERATING"))
                # must defer to allow screen to update
                BugUtil.deferCall(finderRegenerate)
        except MapFinderError, e:
            e.display()
            stop()
示例#44
0
	def addLabel (self, screen, panel, name, title=None, tooltip=None):
		key = "TXT_KEY_BUG_OPTLABEL_" + name.upper()
		title = BugUtil.getPlainText(key, title)
		#tooltip = BugUtil.getPlainText(key + "_HOVER", tooltip)
		if (title):
			label = name + "_Label"
			screen.attachLabel(panel, label, title)
			screen.setControlFlag(label, "CF_LABEL_DEFAULTSIZE")
			#if (tooltip):
			#	screen.setToolTip(label, tooltip)
			return label
		return None
	def createMainPanel (self, screen):
		"Creates and returns the options tab panel with Exit and Help buttons"
		# VBox with two blocks: scrolling control panel and Exit button with separator
		vbox = self.name + "VBox"
		screen.attachVBox(self.tab, vbox)		
		
		# scrollpane
		scrollpane = self.name + "Scroll"
		screen.attachScrollPanel(vbox, scrollpane)
		screen.setLayoutFlag(scrollpane, "LAYOUT_SIZE_HEXPANDING")
		screen.setLayoutFlag(scrollpane, "LAYOUT_SIZE_VEXPANDING")
		
		# panel for option controls
		panel = self.name + "Panel"
		screen.attachPanel(scrollpane, panel)
		screen.setStyle(panel, "Panel_Tan15_Style")
		screen.setLayoutFlag(panel, "LAYOUT_SIZE_HPREFERREDEXPANDING")
		screen.setLayoutFlag(panel, "LAYOUT_SIZE_VPREFERREDEXPANDING")
		
		# panel for Help and Exit buttons
		screen.attachHSeparator(vbox, "RM_ExitSeparator")
		exitPanel = self.name + "ExitBox"
		screen.attachHBox(vbox, exitPanel)
		screen.setLayoutFlag(exitPanel, "LAYOUT_HCENTER")
		
		# Help button
		title = BugUtil.getPlainText("TXT_KEY_BUG_OPTBUTTON_HELP", "Help")
		hover = BugUtil.getPlainText("TXT_KEY_BUG_OPTBUTTON_HELP_HOVER", "Opens the help file. You can hit Shift-F1 from the main interface.")
		helpButton = self.name + "Help"
		self.addButton(screen, exitPanel, helpButton, "handleBugHelpButtonInput", title, hover)
		
		self.addSpacer(screen, exitPanel, exitPanel)
		
		# Exit button
		title = BugUtil.getPlainText("TXT_KEY_PEDIA_SCREEN_EXIT", "Exit")
		hover = BugUtil.getPlainText("TXT_KEY_BUG_OPTBUTTON_EXIT_HOVER", "Exits the BUG Options screen.")
		exitButton = self.name + "Exit"
		self.addButton(screen, exitPanel, exitButton, "handleBugExitButtonInput", title, hover)
		
		return panel
示例#46
0
文件: BugOptions.py 项目: AP-ML/DTM
	def translate(self):
		self.title = BugUtil.getPlainText(self.xmlKey + "_TEXT", self.title)
		self.tooltip = BugUtil.getPlainText(self.xmlKey + "_HOVER", self.tooltip)
		if self.isDll():
			if BugDll.isVersion(self.dll):
				self.tooltip = RE_DLL_ALL_TAGS.sub("", self.tooltip)
			else:
				if not BugDll.isPresent():
					dllText = BugUtil.getPlainText("TXT_KEY_BULL_REQUIRED")
				else:
					dllText = BugUtil.getPlainText("TXT_KEY_BULL_REQUIRED_NEWER")
				if self.tooltip.find("[DLL") >= 0:
					self.tooltip = RE_DLL_START_END_TAGS.sub("", self.tooltip)
					self.tooltip = RE_DLL_MSG_TAG.sub(dllText, self.tooltip)
				else:
					self.tooltip += "\n" + dllText
		elif self.tooltip.find("[DLL") >= 0:
			if not BugDll.isPresent():
				# no DLL, ignore all minimum versions and use standard error message
				self.tooltip = RE_DLL_START_END_TAGS.sub("", self.tooltip)
				self.tooltip = RE_DLL_MSG_TAG.sub(BugUtil.getPlainText("TXT_KEY_BULL_REQUIRED"), self.tooltip)
			else:
				dllText = BugUtil.getPlainText("TXT_KEY_BULL_REQUIRED_NEWER")
				def repl(matchobj):
					try:
						if BugDll.isVersion(int(matchobj.group(1))):
							return ""
						else:
							return RE_DLL_MSG_TAG.sub(dllText, matchobj.group(2))
					except:
						# invalid version
						return ""
				self.tooltip = RE_DLL_CAPTURE_VERSION_MESSAGE.sub(repl, self.tooltip)
		self.translated = True
	def showReminders(self, endOfTurn):
		global g_turnReminderTexts
		thisTurn = gc.getGame().getGameTurn()
		if (endOfTurn):
			prompt = BugUtil.getPlainText("TXT_KEY_REMIND_NEXT_TURN_PROMPT")
			eventId = RECALL_AGAIN_EVENT_ID
		else:
			g_turnReminderTexts = ""
			prompt = BugUtil.getPlainText("TXT_KEY_REMIND_END_TURN_PROMPT")
			eventId = RECALL_EVENT_ID
		yes = BugUtil.getPlainText("TXT_KEY_POPUP_YES")
		no = BugUtil.getPlainText("TXT_KEY_POPUP_NO")
		queue = self.reminders.get(PlayerUtil.getActivePlayerID())
		while (not queue.isEmpty()):
			nextTurn = queue.nextTurn()
			if (nextTurn > thisTurn):
				break
			elif (nextTurn < thisTurn):
				# invalid (lost) reminder
				reminder = queue.pop()
				BugUtil.warn("Reminder - skipped turn %d: %s", reminder.turn, reminder.message)
			else:
				self.reminder = queue.pop()
				if (g_autolog.isLogging() and ReminderOpt.isAutolog()):
					g_autolog.writeLog("Reminder: %s" % self.reminder.message)
				if (not endOfTurn):
					if (g_turnReminderTexts):
						g_turnReminderTexts += ", "
					g_turnReminderTexts += self.reminder.message
				if (ReminderOpt.isShowMessage()):
					CyInterface().addMessage(PlayerUtil.getActivePlayerID(), True, 10, self.reminder.message, 
											 None, 0, None, ColorTypes(8), 0, 0, False, False)
				if (ReminderOpt.isShowPopup()):
					popup = PyPopup.PyPopup(eventId, EventContextTypes.EVENTCONTEXT_SELF)
					popup.setHeaderString(self.reminder.message)
					popup.setBodyString(prompt)
					popup.addButton(yes)
					popup.addButton(no)
					popup.launch(False)
示例#48
0
 def start(self):
     self.writeMsg("")
     self.writeMsg("Logging by " + CvModName.getDisplayNameAndVersion() +
                   " (" + CvModName.getCivNameAndVersion() + ")")
     self.writeMsg("------------------------------------------------")
     zcurrturn = gc.getGame().getElapsedGameTurns(
     ) + AutologOpt.get4000BCTurn()
     zmaxturn = gc.getGame().getMaxTurns()
     zyear = gc.getGame().getGameTurnYear()
     if (zyear < 0):
         zyear = str(-zyear) + BugUtil.getPlainText("TXT_KEY_AUTOLOG_BC")
     else:
         zyear = str(zyear) + BugUtil.getPlainText("TXT_KEY_AUTOLOG_AD")
     zCurrDateTime = time.strftime("%d-%b-%Y %H:%M:%S")
     if (zmaxturn == 0):
         zsTurn = "%i" % (zcurrturn)
     else:
         zsTurn = "%i/%i" % (zcurrturn, zmaxturn)
     message = BugUtil.getText("TXT_KEY_AUTOLOG_TURN",
                               (zsTurn, zyear, zCurrDateTime))
     self.writeMsg(message, vBold=True, vUnderline=True)
     self.bStarted = True
示例#49
0
	def interfaceScreen(self):
		"Initial creation of the screen"
		title = BugUtil.getPlainText("TXT_KEY_BUG_OPT_TITLE", "BUG Mod Options")
		self.pTabControl = CyGTabCtrl(title, False, False)
		self.pTabControl.setModal(1)
		self.pTabControl.setSize(950, 715)
		self.pTabControl.setControlsExpanding(False)
		self.pTabControl.setColumnLength(self.iScreenHeight)
		
		if self.options.isLoaded():
			self.createTabs()
		else:
			BugErrorOptionsTab.BugErrorOptionsTab(self).create(self.pTabControl)
示例#50
0
	def interfaceScreen(self):
		"Initial creation of the screen"
		title = BugUtil.getPlainText("TXT_KEY_BUG_OPT_TITLE", "BUG Mod Options")
		self.pTabControl = CyGTabCtrl(title, False, False)
		self.pTabControl.setModal(1)
		self.pTabControl.setSize(900, 705)
		self.pTabControl.setControlsExpanding(False)
		self.pTabControl.setColumnLength(self.iScreenHeight)
		
		if self.options.isLoaded():
			self.createTabs()
		else:
			BugErrorOptionsTab.BugErrorOptionsTab(self).create(self.pTabControl)
示例#51
0
	def drawPanel(self, screen):
		screen.addPanel(self.MAIN_PANEL_ID, u"", u"", True, False, 
					self.MAIN_PANEL_X, self.MAIN_PANEL_Y, self.MAIN_PANEL_W, self.MAIN_PANEL_H, PanelStyles.PANEL_STYLE_HUD_HELP)
		
		x = self.MAIN_PANEL_X + self.MARGIN_X
		y = self.MAIN_PANEL_Y + self.MARGIN_Y
		z = -0.3
		screen.setLabel("TitleLabel", self.MAIN_PANEL_ID, BugUtil.getPlainText("TXT_KEY_MAPFINDER_SCREEN_TITLE"), CvUtil.FONT_CENTER_JUSTIFY,
					self.MAIN_PANEL_X + self.MAIN_PANEL_W / 2, y, z, FontTypes.SMALL_FONT, 
					WidgetTypes.WIDGET_GENERAL, -1, -1)
		y += self.LINE_HEIGHT + self.MARGIN_Y
		
		screen.setLabel("RegenLabel", self.MAIN_PANEL_ID, BugUtil.getPlainText("TXT_KEY_MAPFINDER_TOTAL_MAPS"), CvUtil.FONT_LEFT_JUSTIFY,
					x, y, z, FontTypes.SMALL_FONT, 
					WidgetTypes.WIDGET_GENERAL, -1, -1)
		y += self.LINE_HEIGHT
		screen.setLabel("SaveLabel", self.MAIN_PANEL_ID, BugUtil.getPlainText("TXT_KEY_MAPFINDER_TOTAL_SAVES"), CvUtil.FONT_LEFT_JUSTIFY,
					x, y, z, FontTypes.SMALL_FONT, 
					WidgetTypes.WIDGET_GENERAL, -1, -1)
		
		y = self.MAIN_PANEL_Y + self.MAIN_PANEL_H - self.MARGIN_Y - self.LINE_HEIGHT
		screen.setLabel("StopMsgLabel", self.MAIN_PANEL_ID, BugUtil.getPlainText("TXT_KEY_MAPFINDER_STOP_SHORTCUT"), CvUtil.FONT_CENTER_JUSTIFY,
					self.MAIN_PANEL_X + self.MAIN_PANEL_W / 2, y, z, FontTypes.SMALL_FONT, 
					WidgetTypes.WIDGET_GENERAL, -1, -1)
示例#52
0
文件: ColorUtil.py 项目: AP-ML/DTM
def createColors(argsList=None):
	for key in COLOR_KEYS:
		type = gc.getInfoTypeForString(key)
		if (type >= 0):
			info = gc.getColorInfo(type)
			if (info):
				name = BugUtil.getPlainText("TXT_KEY_" + key, "")
				if (not name):
					name = key.replace("COLOR_", "").replace("_", " ").title()
				COLOR_TYPES.append(type)
				COLOR_DISPLAY_NAMES.append(name)
				color = (len(COLORS), type, key, name)
				COLORS.append(color)
				COLORS_BY_TYPE[type] = color
				COLORS_BY_KEY[key] = color
				TYPES_BY_KEY[key] = type
示例#53
0
def createColors(argsList=None):
	for key in COLOR_KEYS:
		type = gc.getInfoTypeForString(key)
		if (type >= 0):
			info = gc.getColorInfo(type)
			if (info):
				name = BugUtil.getPlainText("TXT_KEY_" + key, "")
				if (not name):
					name = key.replace("COLOR_", "").replace("_", " ").title()
				COLOR_TYPES.append(type)
				COLOR_DISPLAY_NAMES.append(name)
				color = (len(COLORS), type, key, name)
				COLORS.append(color)
				COLORS_BY_TYPE[type] = color
				COLORS_BY_KEY[key] = color
				TYPES_BY_KEY[key] = type
 def addLabel (self, screen, panel, name, title=None, tooltip=None, spacer=False):
     key = "TXT_KEY_BUG_OPTLABEL_" + name.upper()
     title = BugUtil.getPlainText(key, title)
     #tooltip = BugUtil.getPlainText(key + "_HOVER", tooltip)
     if spacer:
         hbox = name + "HBox"
         screen.attachHBox(panel, hbox)
         #screen.setLayoutFlag(box, "LAYOUT_SIZE_HPREFERREDEXPANDING")
         self.addSpacer(screen, hbox, hbox, CHECKBOX_INDENT)
         panel = hbox
     if title:
         label = name + "_Label"
         screen.attachLabel(panel, label, title)
         screen.setControlFlag(label, "CF_LABEL_DEFAULTSIZE")
         #if (tooltip):
         #   screen.setToolTip(label, tooltip)
         return label
     return None
	def addLabel (self, screen, panel, name, title=None, tooltip=None, spacer=False):
		key = "TXT_KEY_BUG_OPTLABEL_" + name.upper()
		title = BugUtil.getPlainText(key, title)
		#tooltip = BugUtil.getPlainText(key + "_HOVER", tooltip)
		if spacer:
			hbox = name + "HBox"
			screen.attachHBox(panel, hbox)
			#screen.setLayoutFlag(box, "LAYOUT_SIZE_HPREFERREDEXPANDING")
			self.addSpacer(screen, hbox, hbox, CHECKBOX_INDENT)
			panel = hbox
		if (title):
			label = name + "_Label"
			screen.attachLabel(panel, label, title)
			screen.setControlFlag(label, "CF_LABEL_DEFAULTSIZE")
			#if (tooltip):
			#	screen.setToolTip(label, tooltip)
			return label
		return None
示例#56
0
    def interfaceScreen(self):
        "Initial creation of the screen"
        title = BugUtil.getPlainText("TXT_KEY_BUG_OPT_TITLE",
                                     "BUG Mod Options")
        self.pTabControl = CyGTabCtrl(title, False, False)
        self.pTabControl.setModal(1)
        screen = CyGInterfaceScreen("MainInterface",
                                    CvScreenEnums.MAIN_INTERFACE)
        resolutionWidth = screen.getXResolution()
        # resolutionHeigth = screen.getYResolution()
        self.pTabControl.setSize(resolutionWidth - 60, 750)
        # self.pTabControl.setSize(1000, 750)
        self.pTabControl.setControlsExpanding(False)
        self.pTabControl.setColumnLength(self.iScreenHeight)

        if self.options.isLoaded():
            self.createTabs()
        else:
            BugErrorOptionsTab.BugErrorOptionsTab(self).create(
                self.pTabControl)
示例#57
0
文件: GPUtil.py 项目: AP-ML/DTM
def getHoverText(eWidgetType, iData1, iData2, bOption):
	city, iTurns = getDisplayCity()
	if (not city):
		# no rate or progress in any city and no city selected
		return BugUtil.getText("TXT_KEY_MISC_GREAT_PERSON", (0, PlayerUtil.getActivePlayer().greatPeopleThreshold(False)))
	iThreshold = gc.getPlayer(city.getOwner()).greatPeopleThreshold(False)
	iProgress = city.getGreatPeopleProgress()
	iRate = city.getGreatPeopleRate()
	szText = BugUtil.colorText(city.getName(), "COLOR_HIGHLIGHT_TEXT")
	szText += u"\n"
	szText += BugUtil.getText("TXT_KEY_MISC_GREAT_PERSON", (iProgress, iThreshold))
	if (iRate > 0):
		szText += u"\n%d%s%s " % (iRate, g_gpIcon, BugUtil.getPlainText("TXT_KEY_PER_TURN"))
		szText += BugUtil.getText("INTERFACE_CITY_TURNS", (iTurns,))
	
	percents = calcPercentages(city)
	if (len(percents) > 0):
		percents.sort()
		percents.reverse()
		szText += u"\n"
		for iPercent, iUnit in percents:
#			iUnit = getUnitType(gpType)
			szText += u"\n%s%s - %d%%" % (getUnitIcon(iUnit), gc.getUnitInfo(iUnit).getDescription(), iPercent)
	return szText
示例#58
0
def setWidgetHelpXml(widget, key):
	"""
	Assigns the XML <key> to be used to lookup the translated hover text for <widget>.
	"""
	_setWidgetHelp(widget, "XML", lambda *ignored: BugUtil.getPlainText(key))