def handleInput(self, inputClass): 'Handles input for this screen' if inputClass.getNotifyCode() == NotifyCode.NOTIFY_LISTBOX_ITEM_SELECTED: screen = self.getScreen() iIndex = screen.getSelectedPullDownID("DebugMenu") self.setActivePlayer(screen.getPullDownData("DebugMenu", iIndex)) self.placeContents() self.updateCivicCosts() self.updateRevolution() return 1 elif inputClass.getFunctionName().startswith("CivicButton") or inputClass.getFunctionName().startswith("CivicName"): if inputClass.getNotifyCode() == NotifyCode.NOTIFY_CLICKED: if inputClass.getFlags() & MouseFlags.MOUSE_RBUTTONUP: CvScreensInterface.pediaJumpToCivic((inputClass.getID(), )) else: # Select civic self.selectCivic(inputClass.getID()) self.showCivic(gc.getCivicInfo(inputClass.getID()).getCivicOptionType()) self.updateCivicCosts() self.updateRevolution() elif inputClass.getNotifyCode() == NotifyCode.NOTIFY_CURSOR_MOVE_ON: self.colorCivicTexts(inputClass.getID(), True) if self.hoverCivic(inputClass.getID(), True): # Highlight button self.showCivic(gc.getCivicInfo(inputClass.getID()).getCivicOptionType()) self.updateCivicCosts() self.updateRevolution() elif inputClass.getNotifyCode() == NotifyCode.NOTIFY_CURSOR_MOVE_OFF: self.colorCivicTexts(inputClass.getID(), False) if self.hoverCivic(inputClass.getID(), False): # Unhighlight button self.showCivic(gc.getCivicInfo(inputClass.getID()).getCivicOptionType()) self.updateCivicCosts() self.updateRevolution() return 1 elif inputClass.getFunctionName().startswith("CivicIcon"): if inputClass.getNotifyCode() == NotifyCode.NOTIFY_CLICKED: CvScreensInterface.pediaJumpToCivic((inputClass.getData1(), )) elif inputClass.getFunctionName() == "RevolutionButton": self.doRevolution() return 1 elif inputClass.getFunctionName() == "CancelButton": for i in xrange(gc.getNumCivicOptionInfos()): self.SelectedCivics[i] = self.PlayerCivics[i] self.DisplayedCivics[i] = self.PlayerCivics[i] self.placeContents() self.updateCivicCosts() self.updateRevolution() return 1 return 0
def handleInput(self, inputClass): 'Handles input for this screen' if inputClass.getNotifyCode() == NotifyCode.NOTIFY_LISTBOX_ITEM_SELECTED: screen = self.getScreen() iIndex = screen.getSelectedPullDownID("DebugMenu") self.setActivePlayer(screen.getPullDownData("DebugMenu", iIndex)) self.placeContents() self.updateCivicCosts() self.updateRevolution() return 1 elif inputClass.getFunctionName().startswith("CivicButton") or inputClass.getFunctionName().startswith("CivicName"): if inputClass.getNotifyCode() == NotifyCode.NOTIFY_CLICKED: if inputClass.getFlags() & MouseFlags.MOUSE_RBUTTONUP: CvScreensInterface.pediaJumpToCivic((inputClass.getID(), )) else: # Select civic self.selectCivic(inputClass.getID()) self.showCivic(gc.getCivicInfo(inputClass.getID()).getCivicOptionType()) self.updateCivicCosts() self.updateRevolution() elif inputClass.getNotifyCode() == NotifyCode.NOTIFY_CURSOR_MOVE_ON: self.colorCivicTexts(inputClass.getID(), True) if self.hoverCivic(inputClass.getID(), True): # Highlight button self.showCivic(gc.getCivicInfo(inputClass.getID()).getCivicOptionType()) self.updateCivicCosts() self.updateRevolution() elif inputClass.getNotifyCode() == NotifyCode.NOTIFY_CURSOR_MOVE_OFF: self.colorCivicTexts(inputClass.getID(), False) if self.hoverCivic(inputClass.getID(), False): # Unhighlight button self.showCivic(gc.getCivicInfo(inputClass.getID()).getCivicOptionType()) self.updateCivicCosts() self.updateRevolution() return 1 elif inputClass.getFunctionName().startswith("CivicIcon"): if inputClass.getNotifyCode() == NotifyCode.NOTIFY_CLICKED: CvScreensInterface.pediaJumpToCivic((inputClass.getData1(), )) elif inputClass.getFunctionName() == "RevolutionButton": self.doRevolution() return 1 elif inputClass.getFunctionName() == "CancelButton": for i in xrange(gc.getNumCivicOptionInfos()): self.SelectedCivics[i] = self.PlayerCivics[i] self.DisplayedCivics[i] = self.PlayerCivics[i] self.placeContents() self.updateCivicCosts() self.updateRevolution() return 1 return 0
def CivicsButton(self, inputClass): if (inputClass.getNotifyCode() == NotifyCode.NOTIFY_CLICKED) : if (inputClass.getFlags() & MouseFlags.MOUSE_RBUTTONUP): CvScreensInterface.pediaJumpToCivic((inputClass.getID(), )) else: # Select button self.select(inputClass.getID()) self.drawHelpText(gc.getCivicInfo(inputClass.getID()).getCivicOptionType()) self.updateAnarchy() elif (inputClass.getNotifyCode() == NotifyCode.NOTIFY_CURSOR_MOVE_ON) : # Highlight this button if self.highlight(inputClass.getID()): self.drawHelpText(gc.getCivicInfo(inputClass.getID()).getCivicOptionType()) self.updateAnarchy() elif (inputClass.getNotifyCode() == NotifyCode.NOTIFY_CURSOR_MOVE_OFF) : if self.unHighlight(inputClass.getID()): self.drawHelpText(gc.getCivicInfo(inputClass.getID()).getCivicOptionType()) self.updateAnarchy() return 0
def handleInput(self, inputClass): screen = self.getScreen() if not screen.isActive(): return HandleInputUtil.debugInput(inputClass) xMouse, yMouse = self.InputData.getMousePosition() bAlt, bCtrl, bShift = self.InputData.getModifierKeys() iCode = inputClass.eNotifyCode iData = inputClass.iData ID = inputClass.iItemID NAME = inputClass.szFunctionName iBtn = inputClass.iButtonType iData1 = inputClass.iData1 iData2 = inputClass.iData2 szFlag = HandleInputUtil.MOUSE_FLAGS.get(inputClass.uiFlags, "UNKNOWN") szSplit = NAME.split("|") BASE = szSplit[0] if szSplit[1:]: TYPE = szSplit[1] else: TYPE = "" if szSplit[2:]: CASE = szSplit[2:] else: CASE = [0] # Remove potential Help Text screen.hide("Tooltip") if iCode == NotifyCode.NOTIFY_CURSOR_MOVE_ON: if BASE == "WID": if TYPE == "CIVIC": if CASE[0] == "TEXT": if ID != self.iCivicDisplayed: self.setCivicText(screen, ID) else: self.updateTooltip(screen, GTM.parseCivicInfo( ID, False, True, False), uFont=self.aFontList[4]) elif NAME == "CivicDisplay": self.updateTooltip(screen, "Toggle Display Type") elif iCode == NotifyCode.NOTIFY_CURSOR_MOVE_OFF: if BASE == "WID": if TYPE == "CIVIC": if CASE[0] == "TEXT": if ID != self.iCivicDisplayed: if self.iCivicDisplayed > -1: self.setCivicText(screen, self.iCivicDisplayed) else: screen.hide("CivicText") elif iCode == NotifyCode.NOTIFY_CLICKED: if BASE == "Civic_Tab": if CASE[0] != "Col": screen.hide("Civic_Tab|Col" + str(self.iTab)) screen.show("Civic_Tab" + str(self.iTab)) self.iTab = ID self.drawContents(screen) elif NAME == "CivicCancel": self.iCivicDisplayed = -1 if self.iType: screen.hide("CivicText") for iCivic in self.originalCivics: if iCivic not in self.currentCivics: self.selectCivic(screen, iCivic) self.updateStatus(screen) elif NAME == "CivicRevolution": # If we want to be able to change civics of another player in debug mode then a custom modnetmessage function must be created for MP compatibility. # CyMessageControl().sendModNetMessage(MsgID, iPlayer, -1, -1, -1) # The function would have to be able to reference this class instance and ask for reference.currentCivics. CyMessageControl().sendUpdateCivics(self.currentCivics) screen.hideScreen() elif szFlag == "MOUSE_RBUTTONUP": if BASE == "WID": if TYPE == "CIVIC": UP.pediaJumpToCivic([ID]) else: if BASE == "WID": if TYPE == "CIVIC": self.iCivicDisplayed = ID if ID in self.currentCivics or not self.CyPlayer.canDoCivics( ID): return self.selectCivic(screen, ID) self.updateStatus(screen) elif NAME == "CivicDisplay": self.iType = (self.iType + 1) % 2 self.drawContents(screen) elif iCode == NotifyCode.NOTIFY_LISTBOX_ITEM_SELECTED: if NAME == "Civic_DebugDD": iIndex = screen.getSelectedPullDownID(NAME) self.iPlayer = iPlayer = screen.getPullDownData(NAME, iIndex) self.setActivePlayer(iPlayer) self.drawContents(screen)
def handleInput (self, inputClass): screen = self.getScreen() if not screen.isActive(): return HandleInputUtil.debugInput(inputClass) bAlt, bCtrl, bShift = self.InputData.getModifierKeys() iCode = inputClass.eNotifyCode iData = inputClass.iData ID = inputClass.iItemID NAME = inputClass.szFunctionName iBtn = inputClass.iButtonType iData1 = inputClass.iData1 iData2 = inputClass.iData2 szFlag = HandleInputUtil.MOUSE_FLAGS.get(inputClass.uiFlags, "UNKNOWN") szSplit = NAME.split("|") BASE = szSplit[0] if szSplit[1:]: TYPE = szSplit[1] else: TYPE = "" if szSplit[2:]: CASE = szSplit[2:] else: CASE = [0] # Remove potential Help Text self.bTooltip = False screen.hide("Tooltip") if iCode == NotifyCode.NOTIFY_CURSOR_MOVE_ON: if BASE == "WID": if TYPE == "RELATION": aMap = [ "<color=255,0,0>", "<color=0,255,255>", "", "<color=0,255,0>", "<color=255,255,0>" ] iPlayerY, iPlayerX = self.aRelationList[ID] iSum, szTxt = self.sumAttitude(iPlayerY, iPlayerX) szTxt += "\n---> " + aMap[GC.getPlayer(iPlayerY).AI_getAttitude(iPlayerX)] + str(iSum) self.updateTooltip(screen, szTxt) elif TYPE == "LEADER": CyPlayer = GC.getPlayer(ID) szLeader = GC.getLeaderHeadInfo(CyPlayer.getLeaderType()).getDescription() if CyPlayer.isHuman(): szTxt = CyPlayer.getName() if szTxt == szLeader: szTxt = TRNSLTR.getText("TXT_KEY_PITBOSS_HUMAN", ()) else: szTxt = TRNSLTR.getText("TXT_KEY_MAIN_MENU_AI", ()) szTxt += "\n%s %s\n" %(CyPlayer.getCivilizationAdjective(0), szLeader) szTxt += "%s - %s" %(CyPlayer.getCivilizationShortDescription(0), CyPlayer.getCivilizationDescription(0)) self.updateTooltip(screen, szTxt) elif TYPE == "BONUS": if CASE[0] == "DEAL": iBonus, CyDeal = self.aDealMap[ID] szTxt = GTM.getDealString(CyDeal, self.iPlayer) + "\n" if CyDeal.isCancelable(self.iPlayer, False): szTxt += TRNSLTR.getText("TXT_KEY_MISC_CLICK_TO_CANCEL", ()) + "\n" szTxt += "\n" else: szTxt = "" iBonus = ID szTxt += GTM.getBonusHelp(iBonus, False) self.updateTooltip(screen, szTxt) elif TYPE == "CIVIC": self.updateTooltip(screen, GTM.parseCivicInfo(ID, False, True, False)) elif TYPE == "RELIGION": self.updateTooltip(screen, GTM.parseReligionInfo(ID, False)) elif TYPE == "TECH": self.updateTooltip(screen, GTM.getTechHelp(ID, False, True, False, True, -1)) elif BASE == "GPT": szTxt = "" if TYPE == "WILL": szTxt = TRNSLTR.getText("TXT_KEY_FOREIGN_ADVISOR_GOLD_PER_TURN_FOR_TRADE", (ID,)) elif TYPE == "POS": szTxt = "<color=27,255,71>" + TRNSLTR.getText("TXT_KEY_FINANCIAL_ADVISOR_NET_INCOME", (ID,)) + " " + self.charGold elif TYPE == "NEG": szTxt = "<color=255,27,27>" + TRNSLTR.getText("TXT_KEY_FINANCIAL_ADVISOR_NET_INCOME", (-ID,)) + " " + self.charGold if szTxt: self.updateTooltip(screen, szTxt) elif BASE == "GOLD": if TYPE == "ALL": CyPlayerX = GC.getPlayer(ID) iGold = CyPlayerX.getGold() iGrGold = CyPlayerX.getGreaterGold() szTxt = "" if iGrGold: szTxt += str(iGrGold) szTxt += str(iGold) + self.charGold self.updateTooltip(screen, szTxt) elif TYPE == "WILL": iGold = GC.getPlayer(ID).AI_maxGoldTrade(self.iPlayer) iGrGold = iGold / 1000000 szTxt = "" if iGrGold: iGold - iGrGold*1000000 szTxt += str(iGrGold) szTxt += str(iGold) + self.charGold self.updateTooltip(screen, szTxt) elif iCode == NotifyCode.NOTIFY_CLICKED: if BASE == "FA_Tab": if CASE[0] != "Col": screen.hide("FA_Tab|Col" + str(self.iTab)) screen.show("FA_Tab" + str(self.iTab)) self.iTab = ID self.drawContents(screen) elif NAME == "BonusList": self.iBonusList = ID self.drawContents(screen) elif BASE == "KD": screen.deleteWidget("KD|Pnl") screen.deleteWidget("KD|Nay0") screen.deleteWidget("KD|Nay1") screen.deleteWidget("KD|Yay1") if TYPE == "Yay": CyMessageControl().sendModNetMessage(666, self.iPlayer, iData1, 0, 0) GAME.getDeal(iData1).kill() self.drawContents(screen) elif szFlag == "MOUSE_RBUTTONUP": if iBtn == WidgetTypes.WIDGET_LEADERHEAD and self.iTab == 0: if bShift: UP.pediaJumpToLeader([GC.getPlayer(iData1).getLeaderType()]) elif iData1 != self.iPlayer: screen.hideScreen() elif iBtn == WidgetTypes.WIDGET_LEADERHEAD: if iData1 != self.iPlayer: screen.hideScreen() elif BASE == "WID": if TYPE == "LEADER": UP.pediaJumpToLeader([GC.getPlayer(ID).getLeaderType()]) elif TYPE == "BONUS": if CASE[0] == "DEAL": iBonus = self.aDealMap[ID][0] else: iBonus = ID UP.pediaJumpToBonus([iBonus]) elif TYPE == "CIVIC": UP.pediaJumpToCivic([ID]) elif TYPE == "RELIGION": UP.pediaJumpToReligion([ID]) elif TYPE == "TECH": UP.pediaJumpToTech([ID]) else: if iBtn == WidgetTypes.WIDGET_LEADERHEAD and self.iTab == 0: aList = self.selectedLeaders if bShift: if iData1 in aList: aList.remove(iData1) else: aList.append(iData1) else: if aList and len(aList) == 1 and iData1 == aList[0]: aList = [] else: aList = [iData1] self.selectedLeaders = aList self.drawContents(screen) elif BASE == "WID": if TYPE == "LEADER": if ID != self.iPlayer: self.CyPlayer.contact(ID) screen.hideScreen() elif TYPE == "BONUS": if CASE[0] == "DEAL": iBonus, CyDeal = self.aDealMap[ID] if CyDeal.isCancelable(self.iPlayer, False): eWidGen = WidgetTypes.WIDGET_GENERAL ePnlMain = PanelStyles.PANEL_STYLE_MAIN eBtnStd = ButtonStyles.BUTTON_STYLE_STANDARD xRes = self.xRes yRes = self.yRes xMid = xRes/2 yMid = yRes/2 screen.setImageButton("KD|Nay0", "", 0, 0, xRes, yRes, eWidGen, 1, 1) screen.addPanel("KD|Pnl", "", "", True, True, xMid-180, yMid-60, 360, 120, ePnlMain) szTxt = "<font=3b>" + TRNSLTR.getText("TXT_KEY_ANNUL", ()) screen.setLabelAt("", "KD|Pnl", szTxt, 1<<2, 180, 20, 0, FontTypes.GAME_FONT, eWidGen, 1, 1) szTxt = TRNSLTR.getText("TXT_KEY_POPUP_NO", ()) screen.setButtonGFC("KD|Nay1", szTxt, "", xMid - 160, yMid, 150, 40, eWidGen, 1, 1, eBtnStd) szTxt = TRNSLTR.getText("TXT_KEY_POPUP_YES", ()) screen.setButtonGFC("KD|Yay1", szTxt, "", xMid + 10, yMid, 150, 40, eWidGen, CyDeal.getID(), 1, eBtnStd) elif iCode == NotifyCode.NOTIFY_LISTBOX_ITEM_SELECTED: if NAME == "FA_DebugDD": iIndex = screen.getSelectedPullDownID(NAME) self.iPlayer = iPlayer = screen.getPullDownData(NAME, iIndex) self.CyPlayer = CyPlayer = GC.getPlayer(iPlayer) self.iTeam = iTeam = CyPlayer.getTeam() self.CyTeam = GC.getTeam(iTeam) self.calcPlayerRelative() self.drawContents(screen)