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.tooltip.reset(screen) if iCode == NotifyCode.NOTIFY_CURSOR_MOVE_ON: if BASE == "WID": if 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", ()) elif CyPlayer.isNPC(): szTxt = "NPC" 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.tooltip.handle(screen, szTxt) elif iCode == NotifyCode.NOTIFY_CLICKED: if szFlag == "MOUSE_RBUTTONUP": if BASE == "WID": if TYPE == "LEADER": UP.pediaJumpToLeader([GC.getPlayer(ID).getLeaderType()]) else: if BASE == "WID": if TYPE == "LEADER": aList = self.selectedCivs bChange = True if bShift: if ID in aList: if len(aList) == 1: bChange = False else: aList.remove(ID) screen.hide("WID|LEADER|HiLi" + str(ID)) else: aList.append(ID) screen.show("WID|LEADER|HiLi" + str(ID)) else: if len(aList) == 1 and ID in aList: bChange = False else: if ID not in aList: screen.show("WID|LEADER|HiLi" + str(ID)) for iPlayerX in aList: if iPlayerX != ID: screen.hide("WID|LEADER|HiLi" + str(iPlayerX)) aList = [ID] if bChange: self.selectedCivs = aList self.UL_refreshUnitSelection(True, True) elif NAME == "MA_UnitButton": self.bUnitDetails = not self.bUnitDetails self.UL_refreshUnitSelection(True, True) elif iCode == NotifyCode.NOTIFY_LISTBOX_ITEM_SELECTED: if NAME == "MA_DDBox": key = self.grouper[iData].key self.groupingKeys[ID] = key self.selectedGroups.clear() self.UL_refresh(screen, False)
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)