本文整理汇总了Python中BugDll类的典型用法代码示例。如果您正苦于以下问题:Python BugDll类的具体用法?Python BugDll怎么用?Python BugDll使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BugDll类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawContents
def drawContents(self):
self.deleteAllWidgets()
# Create a new screen, called FinanceAdvisor, using the file FinanceAdvisor.py for input
screen = self.getScreen()
player = gc.getPlayer(self.iActiveLeader)
numCities = player.getNumCities()
totalUnitCost = player.calculateUnitCost()
totalUnitSupply = player.calculateUnitSupply()
totalMaintenance = player.getTotalMaintenance()
totalCivicUpkeep = player.getCivicUpkeep([], False)
totalPreInflatedCosts = player.calculatePreInflatedCosts()
totalInflatedCosts = player.calculateInflatedCosts()
goldCommerce = player.getCommerceRate(CommerceTypes.COMMERCE_GOLD)
if not player.isCommerceFlexible(CommerceTypes.COMMERCE_RESEARCH):
goldCommerce += player.calculateBaseNetResearch()
gold = player.getGold()
goldFromCivs = player.getGoldPerTurn()
goldPerTurn = player.calculateGoldRate()
szTreasuryPanel = self.getNextWidgetName()
screen.addPanel(
szTreasuryPanel,
u"",
"",
True,
True,
self.X_SLIDERS,
self.Y_TREASURY,
self.X_EXPENSES + self.PANE_WIDTH - self.X_SLIDERS,
self.H_TREASURY,
PanelStyles.PANEL_STYLE_MAIN,
)
szText = localText.getText("TXT_KEY_FINANCIAL_ADVISOR_TREASURY", (gold,)).upper()
if gold < 0:
if goldPerTurn != 0:
if gold + goldPerTurn >= 0:
szText += BugUtil.getText("TXT_KEY_MISC_POS_GOLD_PER_TURN", goldPerTurn)
elif goldPerTurn >= 0:
szText += BugUtil.getText("TXT_KEY_MISC_POS_WARNING_GOLD_PER_TURN", goldPerTurn)
else:
szText += BugUtil.getText("TXT_KEY_MISC_NEG_GOLD_PER_TURN", goldPerTurn)
else:
if goldPerTurn != 0:
if goldPerTurn >= 0:
szText += BugUtil.getText("TXT_KEY_MISC_POS_GOLD_PER_TURN", goldPerTurn)
elif gold + goldPerTurn >= 0:
szText += BugUtil.getText("TXT_KEY_MISC_NEG_WARNING_GOLD_PER_TURN", goldPerTurn)
else:
szText += BugUtil.getText("TXT_KEY_MISC_NEG_GOLD_PER_TURN", goldPerTurn)
screen.setLabel(
self.getNextWidgetName(),
szTreasuryPanel,
u"<font=4>" + szText + u"</font>",
CvUtil.FONT_CENTER_JUSTIFY,
(self.X_SLIDERS + self.PANE_WIDTH + self.X_EXPENSES) / 2,
self.Y_TREASURY + self.H_TREASURY / 2 - self.Y_SPACING / 2,
self.Z_CONTROLS,
FontTypes.TITLE_FONT,
WidgetTypes.WIDGET_HELP_FINANCE_GOLD_RESERVE,
-1,
-1,
)
szCommercePanel = self.getNextWidgetName()
screen.addPanel(
szCommercePanel,
u"",
"",
True,
True,
self.X_SLIDERS,
self.Y_LOCATION,
self.PANE_WIDTH,
self.PANE_HEIGHT,
PanelStyles.PANEL_STYLE_MAIN,
)
screen.setLabel(
self.getNextWidgetName(),
"Background",
u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_COMMERCE", ()).upper() + u"</font>",
CvUtil.FONT_CENTER_JUSTIFY,
self.X_SLIDERS + self.PANE_WIDTH / 2,
self.Y_LOCATION + self.TEXT_MARGIN,
self.Z_CONTROLS + self.DZ,
FontTypes.GAME_FONT,
WidgetTypes.WIDGET_GENERAL,
-1,
-1,
)
szIncomePanel = self.getNextWidgetName()
screen.addPanel(
szIncomePanel,
u"",
"",
#.........这里部分代码省略.........
示例2: translate
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
示例3: __init__
def __init__(self, mod, id, andId=None, dll=None):
self.mod = mod
self.id = id
self.andId = andId
self.andOption = None
self.dll = BugDll.decode(dll)
if self.dll is not None and self.dll <= 0:
BugUtil.warn("BugOptions - %s has invalid dll value %r, ignoring", id, dll)
self.dll = None
self.enabled = True
if self.dll > 0:
if not BugDll.isVersion(self.dll):
self.enabled = False
示例4: isCancelable
def isCancelable(self, eByPlayer, bIgnoreWaitingPeriod=False):
if BugDll.isPresent():
return self.deal.isCancelable(eByPlayer, bIgnoreWaitingPeriod)
else:
if self.isUncancelableVassalDeal(eByPlayer):
return False
return self.turnsToCancel(eByPlayer) <= 0
示例5: isWillingToTalk
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
示例6: handleInput
def handleInput (self, inputClass):
if (inputClass.getNotifyCode() == NotifyCode.NOTIFY_CLICKED):
if (inputClass.getFunctionName() == self.UNIT_LOC_TAB_ID):
self.iScreen = UNIT_LOCATION_SCREEN
self.showUnitLocation()
return 1
elif (inputClass.getFunctionName() == self.SIT_REP_TAB_ID):
self.iScreen = SITUATION_REPORT_SCREEN
self.showSituationReport()
return 1
elif (inputClass.getFunctionName() == self.STRAT_ADV_TAB_ID):
self.iScreen = STRATEGIC_ADVANTAGES_SCREEN
self.showStrategicAdvantages()
return 1
elif (inputClass.getFunctionName() == self.UNIT_BUTTON_ID):
self.bUnitDetails = not self.bUnitDetails
self.UL_refreshUnitSelection(True, True)
return 1
# RJG Start - following line added as per RJG (http://forums.civfanatics.com/showpost.php?p=6997192&postcount=16)
elif (inputClass.getButtonType() == WidgetTypes.WIDGET_LEADERHEAD or BugDll.isWidgetVersion(2, inputClass.getButtonType(), "WIDGET_LEADERHEAD_RELATIONS")):
if (inputClass.getFlags() & MouseFlags.MOUSE_RBUTTONUP):
if (self.iActivePlayer != inputClass.getData1()):
self.getScreen().hideScreen()
return 1
# RJG End
elif (inputClass.getNotifyCode() == NotifyCode.NOTIFY_CHARACTER):
if (inputClass.getData() == int(InputTypes.KB_LSHIFT)
or inputClass.getData() == int(InputTypes.KB_RSHIFT)):
self.iShiftKeyDown = inputClass.getID()
return 1
elif ( inputClass.getNotifyCode() == NotifyCode.NOTIFY_LISTBOX_ITEM_SELECTED ):
if self.iScreen == UNIT_LOCATION_SCREEN:
iSelected = inputClass.getData()
control = inputClass.getFunctionName() + str(inputClass.getID())
BugUtil.debug("Selected item %d from list %s" % (iSelected, control))
if control in self.groupDropDowns:
iGroup = self.groupDropDowns.index(control)
key = self.grouper[iSelected].key
self.groupingKeys[iGroup] = key
self.selectedGroups.clear()
BugUtil.debug("Switched grouping %d to %s" % (iGroup, key))
self.UL_refresh(False, True)
return 1
elif (inputClass.getButtonType() == WidgetTypes.WIDGET_LEADERHEAD):
if (self.iActivePlayer != inputClass.getData1()):
self.getScreen().hideScreen()
return 1
if self.iconGrid:
return self.iconGrid.handleInput(inputClass)
return 0
示例7: Grid_WorstEnemy
def Grid_WorstEnemy(self, iRow, iLeader):
pWorstEnemy = PlayerUtil.getWorstEnemy(iLeader, self.iActivePlayer)
if pWorstEnemy:
self.iconGrid.addIcon(iRow, self.Col_WEnemy,
gc.getLeaderHeadInfo(pWorstEnemy.getLeaderType()).getButton(), 45,
*BugDll.widgetVersion(2, "WIDGET_LEADERHEAD_RELATIONS", iLeader, pWorstEnemy.getID(),
WidgetTypes.WIDGET_LEADERHEAD, iLeader, pWorstEnemy.getID()))
else:
pass
示例8: repl
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 ""
示例9: resolveDll
def resolveDll(self, element, dll):
dll = BugDll.decode(dll)
inherited = element.getState("dll")
if dll is None:
return inherited
if inherited is None:
return dll
if inherited > dll:
BugUtil.warn("BugConfig - element <%s>.dll attribute %s overrides newer inherited dll attribute %s" % (element.tag, dll, inherited))
return dll
示例10: handle
def handle(self, element, module, function, immediate, dll):
immediate = self.isTrue(immediate)
dll = BugDll.decode(dll)
if self.isDllOkay(element, dll):
func = BugUtil.getFunction(module, function, True, *element.args, **element.kwargs)
if immediate:
func()
else:
BugInit.addInit(module, func)
else:
BugUtil.info("BugConfig - ignoring <%s> %s.%s, requires dll version %s", element.tag, module, function, self.resolveDll(element, dll))
示例11: handle
def handle(self, element, module, clazz, dll):
dll = BugDll.decode(dll)
if self.isDllOkay(element, dll):
BugUtil.callFunction(module, clazz, CvEventInterface.getEventManager(), *element.args, **element.kwargs)
else:
BugUtil.info(
"BugConfig - ignoring <%s> from %s.%s, requires dll version %s",
element.tag,
module,
clazz,
self.resolveDll(element, dll),
)
示例12: handle
def handle(self, element, id, name, fromKey, offset, dll):
dll = BugDll.decode(dll)
if self.isDllOkay(element, dll):
if not fromKey:
if not self.lastSymbol:
raise BugUtil.ConfigError("<%s> %s requires an offset symbol" % (element.tag, id))
fromKey = self.lastSymbol
if offset is None:
offset = 1
else:
offset = int(offset)
self.lastSymbol = addOffsetSymbol(id, fromKey, offset, name)
else:
BugUtil.info("FontUtil - ignoring <%s> %s, requires dll version %s", element.tag, id, self.resolveDll(element, dll))
示例13: handle
def handle(self, element, name, type, default, module, handler, listener, log, dll):
dll = BugDll.decode(dll)
if self.isDllOkay(element, dll):
utils = element.getState("gameutils")
if utils:
func = BugUtil.bindFunction(utils, handler)
if listener:
listenerFunc = BugUtil.bindFunction(utils, listener)
elif not module:
raise BugUtil.ConfigError("Element <%s> requires attribute module or be enclosed in <gameutils> that defines a class", element.tag)
else:
func = BugUtil.lookupFunction(module, handler)
if listener:
listenerFunc = BugUtil.lookupFunction(module, listener)
createCallback(name, func, self.createValue(type, default), log)
if listener:
addNamedListener(name, listenerFunc, log)
else:
BugUtil.info("BugGameUtils - ignoring <%s> %s, requires dll version %s", element.tag, name, self.resolveDll(element, dll))
示例14: showSituationReport
def showSituationReport(self):
self.timer.start()
self.deleteAllWidgets()
screen = self.getScreen()
# get Player arrays
pVassals = [[]] * gc.getMAX_PLAYERS()
pDefPacts = [[]] * gc.getMAX_PLAYERS()
bVassals = False
bDefPacts = False
for iLoopPlayer in range(gc.getMAX_PLAYERS()):
pPlayer = gc.getPlayer(iLoopPlayer)
if (pPlayer.isAlive()
and (gc.getTeam(pPlayer.getTeam()).isHasMet(gc.getPlayer(self.iActivePlayer).getTeam())
or gc.getGame().isDebugMode())
and iLoopPlayer != self.iActivePlayer
and not pPlayer.isBarbarian()
and not pPlayer.isMinorCiv()):
pVassals[iLoopPlayer] = PlayerUtil.getVassals(iLoopPlayer, self.iActivePlayer)
pDefPacts[iLoopPlayer] = PlayerUtil.getDefensivePacts(iLoopPlayer, self.iActivePlayer)
if len(pVassals[iLoopPlayer]) > 0:
bVassals = True
if len(pDefPacts[iLoopPlayer]) > 0:
bDefPacts = True
bVassals = True
bDefPacts = True
self.initIconGrid(screen, bVassals, bDefPacts)
self.initPower()
activePlayer = gc.getPlayer(self.iActivePlayer)
# Assemble the panel
iPANEL_X = 5
iPANEL_Y = 60
iPANEL_WIDTH = self.W_SCREEN - 20
iPANEL_HEIGHT = self.H_SCREEN - 120
self.tradePanel = self.getNextWidgetName()
screen.addPanel(self.tradePanel, "", "", True, True, iPANEL_X, iPANEL_Y, iPANEL_WIDTH, iPANEL_HEIGHT, PanelStyles.PANEL_STYLE_MAIN )
self.iconGrid.createGrid()
self.iconGrid.clearData()
iRow = 0
for iLoopPlayer in range(gc.getMAX_PLAYERS()):
pPlayer = gc.getPlayer(iLoopPlayer)
if (pPlayer.isAlive()
and (gc.getTeam(pPlayer.getTeam()).isHasMet(gc.getPlayer(self.iActivePlayer).getTeam())
or gc.getGame().isDebugMode())
and iLoopPlayer != self.iActivePlayer
and not pPlayer.isBarbarian()
and not pPlayer.isMinorCiv()):
# szPlayerName = pPlayer.getName() + "/" + pPlayer.getCivilizationShortDescription(0)
# BugUtil.debug("Grid_ThreatIndex - Start %i %s" % (iLoopPlayer, szPlayerName))
# BugUtil.debug("Grid_ThreatIndex - Start %i" % (iLoopPlayer))
self.iconGrid.appendRow(pPlayer.getCivilizationShortDescription(0), "", 3)
# add leaderhead icon
self.iconGrid.addIcon(iRow, self.Col_Leader,
gc.getLeaderHeadInfo(pPlayer.getLeaderType()).getButton(), 64,
WidgetTypes.WIDGET_LEADERHEAD, iLoopPlayer, self.iActivePlayer)
# add worst enemy
self.Grid_WorstEnemy(iRow, iLoopPlayer)
# add current war opponents
pActiveWars = PlayerUtil.getActiveWars(iLoopPlayer, self.iActivePlayer)
bCurrentWar = len(pActiveWars) > 0
for pLoopPlayer in pActiveWars:
self.iconGrid.addIcon(iRow, self.Col_Curr_Wars,
gc.getLeaderHeadInfo (pLoopPlayer.getLeaderType()).getButton(), 32,
*BugDll.widgetVersion(2, "WIDGET_LEADERHEAD_RELATIONS", iLoopPlayer, pLoopPlayer.getID(),
WidgetTypes.WIDGET_LEADERHEAD, iLoopPlayer, pLoopPlayer.getID()))
# show vassals
if bVassals:
for pLoopPlayer in pVassals[iLoopPlayer]:
self.iconGrid.addIcon(iRow, self.Col_Vassals,
gc.getLeaderHeadInfo (pLoopPlayer.getLeaderType()).getButton(), 32,
*BugDll.widgetVersion(2, "WIDGET_LEADERHEAD_RELATIONS", iLoopPlayer, pLoopPlayer.getID(),
WidgetTypes.WIDGET_LEADERHEAD, iLoopPlayer, pLoopPlayer.getID()))
# show defensive pacts
if bDefPacts:
for pLoopPlayer in pDefPacts[iLoopPlayer]:
self.iconGrid.addIcon(iRow, self.Col_DefPacts,
gc.getLeaderHeadInfo (pLoopPlayer.getLeaderType()).getButton(), 32,
*BugDll.widgetVersion(2, "WIDGET_LEADERHEAD_RELATIONS", iLoopPlayer, pLoopPlayer.getID(),
WidgetTypes.WIDGET_LEADERHEAD, iLoopPlayer, pLoopPlayer.getID()))
# show players that the current player will declare on
#.........这里部分代码省略.........
示例15: handle
def handle(self, element, keys, module, function, dll):
dll = BugDll.decode(dll)
if self.isDllOkay(element, dll):
CvEventInterface.getEventManager().addShortcutHandler(keys, BugUtil.getFunction(module, function, *element.args, **element.kwargs))
else:
BugUtil.info("InputUtil - ignoring <%s> %s, requires dll version %s", element.tag, keys, self.resolveDll(element, dll))