def calltext(): if g_appLoader.getDefBattleApp() is not None: if textCallBackId is not None: BigWorld.cancelCallback(textCallBackId) Battle.Battle._Battle__callEx(g_appLoader.getDefBattleApp(), 'timerBig.setTimer', [BigWorld.player().arena.UTtext]) removeCallBackId = BigWorld.callback(delay, removetext) return
def _injectAPButton(self, event): # TODO - Save custom hit height per vehicle if g_appLoader.getDefBattleApp(): # adjust the hull hit height up if event.key == self.toggleDrawDebugRender and event.isKeyDown(): eAP.hitHullHeight = float(eAP.hitHullHeight) + 0.25 hullHeightMsg = "MeltyElement AP Hull Height Multi + 0.05 to " + str( eAP.hitHullHeight) ctrl = g_appLoader.getDefBattleApp() if ctrl is not None: battle_page = ctrl.containerManager.getContainer( ViewTypes.VIEW).getView() battle_page.components[ 'battlePlayerMessages'].as_showGreenMessageS( None, hullHeightMsg) # adjust the hull hit height down if event.key == self.hitDown and event.isKeyDown(): eAP.hitHullHeight = float(eAP.hitHullHeight) - 0.25 hullHeightMsg = "MeltyElement AP Hull Height Multi - 0.05 to " + str( eAP.hitHullHeight) ctrl = g_appLoader.getDefBattleApp() if ctrl is not None: battle_page = ctrl.containerManager.getContainer( ViewTypes.VIEW).getView() battle_page.components[ 'battlePlayerMessages'].as_showGreenMessageS( None, hullHeightMsg) # reset the hull hit height to default/config value if event.key == self.hitDefault and event.isKeyDown(): eAP.hitHullHeight = config.get('armorPanel/eAP/hitHullHeight', 0.7) hullHeightMsg = "MeltyElement AP Hull Height Multi reset to " + str( eAP.hitHullHeight) ctrl = g_appLoader.getDefBattleApp() if ctrl is not None: battle_page = ctrl.containerManager.getContainer( ViewTypes.VIEW).getView() battle_page.components[ 'battlePlayerMessages'].as_showGreenMessageS( None, hullHeightMsg) # Toggle the debugRender on/off if event.key == self.toggleDrawDebugRender and event.isKeyDown(): self.drawDebugRender = not self.drawDebugRender self.modelFakeHitVisible = not self.modelFakeHitVisible self.modelFakeShotVisible = not self.modelFakeShotVisible message = "MeltyElement AP Debug Render - On" if self.drawDebugRender else "MeltyElement AP Debug Render - OFF" ctrl = g_appLoader.getDefBattleApp() if ctrl is not None: battle_page = ctrl.containerManager.getContainer( ViewTypes.VIEW).getView() if self.drawDebugRender: battle_page.components[ 'battlePlayerMessages'].as_showGreenMessageS( None, message) self._setVisible() else: battle_page.components[ 'battlePlayerMessages'].as_showRedMessageS( None, message) self._hideVisible()
def onBattleLoaded(statistic): global CONFIG_FILENAME, LOG_FILENAME, SHOW_INFO, SHOW_ITEMS, KEYS_SHOWHIDEALL, KEYS_TANKSLIST, \ PRINT_LOG, PRINT_ITEMS, GUI_TEXT, NEW_BATTLE CONFIG_FILENAME = getConfigFileName() if CONFIG_FILENAME is not None: #Config ------------------------------------------ config = json.loads( re.compile('(/\*(.|\n)*?\*/)|((#|//).*?$)', re.I | re.M).sub( '', codecs.open(CONFIG_FILENAME, 'r', 'utf-8-sig').read())) TeamChances = config['System']['TeamChances'] SHOW_INFO = TeamChances['GUIStatistics']['Show'] SHOW_ITEMS = TeamChances['GUIStatistics']['ShowItems'] KEYS_SHOWHIDEALL = TeamChances['Hotkeys']['ShowHideAll'] KEYS_SHOWHIDEALL['Key'] = getattr(Keys, KEYS_SHOWHIDEALL['Key']) KEYS_TANKSLIST = TeamChances['Hotkeys']['TanksList'] KEYS_TANKSLIST['Key'] = getattr(Keys, KEYS_TANKSLIST['Key']) GUIFormat = TeamChances['GUIFormat'] GUI_TEXT['Font'] = GUIFormat['Font']['Name'] GUI_TEXT['Size'] = GUIFormat['Font']['Size'] GUI_TEXT['Color'] = GUIFormat['Font']['Color'].replace('$', '#') GUI_TEXT['Bold'] = GUIFormat['Font']['Bold'] GUI_TEXT['Alpha'] = GUIFormat['Font']['Alpha'] GUI_TEXT['Shadow'] = GUIFormat['Font']['Shadow'] GUI_TEXT['Pos'] = (GUIFormat['Position'][0], GUIFormat['Position'][1]) GUI_TEXT['Align'] = (GUIFormat['Align'][0].lower(), GUIFormat['Align'][1].lower()) GUI_TEXT['LastChangeColor'] = ( GUIFormat['LastChangeColor']['AllyTeam'].replace('$', '#'), GUIFormat['LastChangeColor']['EnemyTeam'].replace('$', '#')) GUI_TEXT['CompareValuesColor'] = ( GUIFormat['CompareValuesColor']['BestValue'].replace('$', '#'), GUIFormat['CompareValuesColor']['WorstValue'].replace('$', '#'), GUIFormat['Font']['Color'].replace('$', '#')) PRINT_LOG = TeamChances['PrintLog'] PRINT_ITEMS = TeamChances['LogFormat']['PrintItems'] LOG_FILENAME = getLogFileName(TeamChances['LogFormat']['Dir'], TeamChances['LogFormat']['Prefix']) #Flash ------------------------------------------- g_appLoader.getDefBattleApp( ).VictoryChancesGUI = VictoryChancesGUI = FlashTextLabel(GUI_TEXT) VictoryChancesGUI.Visible(KEYS_SHOWHIDEALL['ShowDefault']) #Keys -------------------------------------------- if SHOW_INFO: InputHandler.g_instance.onKeyDown += onKeyDown if SHOW_ITEMS['TanksList'] and KEYS_TANKSLIST['ShowKeyDownOnly']: SHOW_ITEMS['TanksList'] = False InputHandler.g_instance.onKeyDown += onShowHideTanksList InputHandler.g_instance.onKeyUp += onShowHideTanksList #Statistic --------------------------------------- g_StatisticEvents.OnVehiclesChanged += onVehiclesChanged showStat(statistic) printStrings( ('------------------------- %s -------------------------\n' % datetime.now().strftime('%d.%m.%y %H:%M:%S'), '\nReason: BattleLoading\n\n')) printStat(statistic, True)
def setNewTarget(newTarget): global gExpertTarget #print 'newTarget {0} oldTarget {1}'.format(newTarget, gExpertTarget) if newTarget is not gExpertTarget and (newTarget is None or newTarget.isAlive()): gExpertTarget = newTarget BigWorld.player().cell.monitorVehicleDamagedDevices( gExpertTarget.id if gExpertTarget is not None else 0 ) #print 'setNewTarget monitor {0}'.format(gExpertTarget.id if gExpertTarget is not None else 0) #FLUSH_LOG() if g_appLoader.getDefBattleApp(): g_appLoader.getDefBattleApp().pMsgsPanel._FadingMessages__showMessage(random.choice(string.ascii_letters), 'Expert: {0}'.format(g_sessionProvider.getCtx().getFullPlayerName(vID=gExpertTarget.id)) if gExpertTarget is not None else 'Expert: OFF', 'default')
def setNewTarget(newTarget): global gExpertTarget #print 'newTarget {0} oldTarget {1}'.format(newTarget, gExpertTarget) if newTarget is not gExpertTarget and (newTarget is None or newTarget.isAlive()): gExpertTarget = newTarget BigWorld.player().cell.monitorVehicleDamagedDevices( gExpertTarget.id if gExpertTarget is not None else 0 ) #print 'setNewTarget monitor {0}'.format(gExpertTarget.id if gExpertTarget is not None else 0) #FLUSH_LOG() if g_appLoader.getDefBattleApp(): panel = g_appLoader.getDefBattleApp().containerManager.getContainer(ViewTypes.VIEW).getView().components[BATTLE_VIEW_ALIASES.PLAYER_MESSAGES] panel.as_showRedMessageS(None, 'Expert: {0}'.format(BigWorld.player().guiSessionProvider.getCtx().getPlayerFullNameParts(vID=gExpertTarget.id)[0]) if gExpertTarget is not None else 'Expert: OFF')
def onKeyDown(event): global KEYS_SHOWHIDEALL if event.isKeyDown() and BigWorld.isKeyDown(KEYS_SHOWHIDEALL['Key']): KEYS_SHOWHIDEALL['ShowDefault'] = not KEYS_SHOWHIDEALL['ShowDefault'] if hasattr(g_appLoader.getDefBattleApp(), 'VictoryChancesGUI'): g_appLoader.getDefBattleApp().VictoryChancesGUI.Visible( KEYS_SHOWHIDEALL['ShowDefault']) if CONFIG_FILENAME: s = re.sub( '"ShowDefault"\s*:\s*(true|false)', '"ShowDefault": ' + str(KEYS_SHOWHIDEALL['ShowDefault']).lower(), codecs.open(CONFIG_FILENAME, 'r', 'utf-8-sig').read()) with codecs.open(CONFIG_FILENAME, 'w', 'utf-8-sig') as f: f.write(s)
def handleKeyEvent(self, event): cursorDetached = self.__detachCount < 0 import game isDown, key, mods, isRepeat = game.convertKeyEvent(event) if isRepeat: return False if self.__isStarted and cursorDetached: return BigWorld.player().handleKey(isDown, key, mods) if not self.__isStarted or cursorDetached: return False if isDown and BigWorld.isKeyDown(Keys.KEY_CAPSLOCK): if self.__alwaysShowAimKey is not None and key == self.__alwaysShowAimKey: self.__alwaysShowAim = not self.__alwaysShowAim getAim = getattr(self.__curCtrl, 'getAim') if getAim is not None: aim = getAim() if aim is not None: aim.setVisible(self.__alwaysShowAim or BigWorld.player().isGuiVisible) return True if self.__showMarkersKey is not None and key == self.__showMarkersKey and not BigWorld.player().isGuiVisible: battle = g_appLoader.getDefBattleApp() if battle: markersManager = battle.markersManager markersManager.active(not markersManager.isActive) return True if key == Keys.KEY_F5 and constants.IS_DEVELOPMENT: self.__vertScreenshotCamera.enable(not self.__vertScreenshotCamera.isEnabled) return True if self.__curCtrl.handleKeyEvent(isDown, key, mods, event): return True return BigWorld.player().handleKey(isDown, key, mods)
def minimapPulse(vehicleID): battle = g_appLoader.getDefBattleApp() if battle: minimap = battle.minimap if minimap: minimap.showActionMarker(vehicleID, SpotExtended.myConf['minimapEffect'])
def message(): app = g_appLoader.getDefBattleApp() if _config.data['only_HeavyTank']: app.call('battle.PlayerMessagesPanel.ShowMessage', ['%s%s' % (_config.i18n['UI_in_battle_activate_message_only_HeavyTank'], random.choice(string.ascii_letters)), _config.i18n['UI_in_battle_activate_message_only_HeavyTank'].decode('utf-8-sig'), 'gold']) else: app.call('battle.PlayerMessagesPanel.ShowMessage', ['%s%s' % (_config.i18n['UI_in_battle_activate_message'], random.choice(string.ascii_letters)), _config.i18n['UI_in_battle_activate_message'].decode('utf-8-sig'), 'gold'])
def showConfirmDialog(confirmDialog, callback, customMessage='', ns='common'): """ Show confirmation dialog (2 buttons - Submit, Close) and wait when player closes this dialog. @param confirmDialog: dialog name. Title, button labels, message builds as #dialogs:' + dialog + '/title'. @param callback: method is invoked when closing the dialog with argument - True if player confirmed actions, otherwise - False. @param customMessage: external message if #dialogs:' + dialog + '/message' does not fit. @param ns: 'common' or 'battle'. """ from gui.app_loader import g_appLoader def onConfirmResponse(confirm): battle = g_appLoader.getDefBattleApp() if battle: battle.removeExternalCallbacks('confirmDialog.onConfirm', 'confirmDialog.onClose') callback(confirm) battle = g_appLoader.getDefBattleApp() if battle: battle.addExternalCallbacks({ 'confirmDialog.onConfirm': lambda callBackId: onConfirmResponse(True), 'confirmDialog.onClose': lambda callBackId: onConfirmResponse(False) }) battle.call('{0:>s}.showConfirmDialog'.format(ns), [ confirmDialog, customMessage, 'confirmDialog.onConfirm', 'confirmDialog.onClose' ])
def showConfirmDialog(confirmDialog, callback, customMessage = '', ns = 'common'): """ Show confirmation dialog (2 buttons - Submit, Close) and wait when player closes this dialog. @param confirmDialog: dialog name. Title, button labels, message builds as #dialogs:' + dialog + '/title'. @param callback: method is invoked when closing the dialog with argument - True if player confirmed actions, otherwise - False. @param customMessage: external message if #dialogs:' + dialog + '/message' does not fit. @param ns: 'common' or 'battle'. """ from gui.app_loader import g_appLoader def onConfirmResponse(confirm): battle = g_appLoader.getDefBattleApp() if battle: battle.removeExternalCallbacks('confirmDialog.onConfirm', 'confirmDialog.onClose') callback(confirm) battle = g_appLoader.getDefBattleApp() if battle: battle.addExternalCallbacks({'confirmDialog.onConfirm': lambda callBackId: onConfirmResponse(True), 'confirmDialog.onClose': lambda callBackId: onConfirmResponse(False)}) battle.call('{0:>s}.showConfirmDialog'.format(ns), [confirmDialog, customMessage, 'confirmDialog.onConfirm', 'confirmDialog.onClose'])
def injectButton(self, isDown, key): if config.data['enabled'] and self.player is not None: if g_appLoader.getDefBattleApp(): if CommandMapping.g_instance.isFired( CommandMapping.CMD_CM_LOCK_TARGET, key) and isDown: return self.catch() return
def handleKeyEvent(self, event): cursorDetached = self.__detachCount < 0 import game isDown, key, mods, isRepeat = game.convertKeyEvent(event) if isRepeat: return False if self.__isStarted and cursorDetached: return BigWorld.player().handleKey(isDown, key, mods) if not self.__isStarted or cursorDetached: return False if isDown and BigWorld.isKeyDown(Keys.KEY_CAPSLOCK): if self.__alwaysShowAimKey is not None and key == self.__alwaysShowAimKey: self.__alwaysShowAim = not self.__alwaysShowAim getAim = getattr(self.__curCtrl, 'getAim') if getAim is not None: aim = getAim() if aim is not None: aim.setVisible(self.__alwaysShowAim or BigWorld.player().isGuiVisible) return True if self.__showMarkersKey is not None and key == self.__showMarkersKey and not BigWorld.player( ).isGuiVisible: battle = g_appLoader.getDefBattleApp() if battle: markersManager = battle.markersManager markersManager.active(not markersManager.isActive) return True if key == Keys.KEY_F5 and constants.IS_DEVELOPMENT: self.__vertScreenshotCamera.enable( not self.__vertScreenshotCamera.isEnabled) return True if self.__curCtrl.handleKeyEvent(isDown, key, mods, event): return True return BigWorld.player().handleKey(isDown, key, mods)
def callTextInit(newText, targetID, attackerID, squadManID): arena = BigWorld.player().arena LOG_NOTE('text init:', newText, targetID, attackerID, squadManID) isPlayer = { 'attacker': attackerID == BigWorld.player().playerVehicleID, 'target': targetID == BigWorld.player().playerVehicleID } isAlly = { 'attacker': arena.vehicles[attackerID]['team'] == BigWorld.player().team, 'target': arena.vehicles[targetID]['team'] == BigWorld.player().team } isSquadMan = { 'attacker': attackerID in arena.UT['squadMan'], 'target': targetID in arena.UT['squadMan'] } try: names = { 'attacker': arena.vehicles[attackerID]['name'], 'target': arena.vehicles[targetID]['name'], 'squadMan': arena.vehicles[squadManID]['name'] if squadManID else '' } except StandardError: names = {} traceback.print_exc() text = _config.formatText(newText, isPlayer, isAlly, isSquadMan, names) battle = g_appLoader.getDefBattleApp() if battle is not None and _gui_flash is not None: _gui_flash.addText(text)
def showInformationDialog(infDialog, callback, customMessage='', ns='common'): """ Show information dialog (1 button - Close) and wait when player closes this dialog. @param infDialog: dialog name. Title, button labels, message builds as #dialogs:' + dialog + '/title'. @param callback: method is invoked when closing the dialog, without arguments. @param customMessage: external message if #dialogs:' + dialog + '/message' does not fit. @param ns: 'common' or 'battle'. """ from gui.app_loader import g_appLoader def onInformationDialogClosed(_): battle = g_appLoader.getDefBattleApp() if battle: battle.removeExternalCallbacks('informationDialog.onClose') callback() battle = g_appLoader.getDefBattleApp() if battle: battle.addExternalCallbacks( {'informationDialog.onClose': onInformationDialogClosed}) battle.call('{0:>s}.showInformationDialog'.format(ns), [infDialog, customMessage, 'informationDialog.onClose'])
def setNewTarget(newTarget): global gExpertTarget #print 'newTarget {0} oldTarget {1}'.format(newTarget, gExpertTarget) if newTarget is not gExpertTarget and (newTarget is None or newTarget.isAlive()): gExpertTarget = newTarget BigWorld.player().cell.monitorVehicleDamagedDevices( gExpertTarget.id if gExpertTarget is not None else 0) #print 'setNewTarget monitor {0}'.format(gExpertTarget.id if gExpertTarget is not None else 0) #FLUSH_LOG() if g_appLoader.getDefBattleApp(): g_appLoader.getDefBattleApp( ).pMsgsPanel._FadingMessages__showMessage( random.choice(string.ascii_letters), 'Expert: {0}'.format( g_sessionProvider.getCtx().getFullPlayerName( vID=gExpertTarget.id)) if gExpertTarget is not None else 'Expert: OFF', 'default')
def getMinimapCellName(cellIdx): from gui.app_loader import g_appLoader battle = g_appLoader.getDefBattleApp() if battle: cellName = battle.minimap.getCellName(cellIdx) else: cellName = 'N/A' return cellName
def flush(self): panel = SpotExtended.myConf['panel'] color = SpotExtended.myConf['color'] index = 0 battle = g_appLoader.getDefBattleApp() if battle and panel in ('VehicleErrorsPanel', 'VehicleMessagesPanel', 'PlayerMessagesPanel'): battle.call('battle.' + panel + '.ShowMessage', [index, self.message, color]) self.clean()
def inj_hkKeyEvent(event): BattleApp = g_appLoader.getDefBattleApp() try: if BattleApp and mod_playersHP.data['enabled']: mod_playersHP.battleKeyControl(event) except StandardError: print mod_playersHP.ID + ': ERROR at inj_hkKeyEvent' traceback.print_exc()
def message(): app = g_appLoader.getDefBattleApp() if config.data['config'].get('only_HeavyTank'): app.call('battle.PlayerMessagesPanel.ShowMessage', [config.language['activate_message_only_HeavyTank'] + random.choice(string.ascii_letters), config.language['activate_message_only_HeavyTank'].decode('utf-8-sig'), 'gold']) else: app.call('battle.PlayerMessagesPanel.ShowMessage', [config.language['activate_message'] + random.choice(string.ascii_letters), config.language['activate_message'].decode('utf-8-sig'), 'gold'])
def getGuiRoot(self): try: root = g_appLoader.getDefBattleApp() except AttributeError: LOG_CURRENT_EXCEPTION() root = None return root
def injectButton(self, event): if g_appLoader.getDefBattleApp(): if g_gui.get_key( config.data['buttonChassis']) and event.isKeyDown(): self.repairChassis() if g_gui.get_key( config.data['buttonRepair']) and event.isKeyDown(): self.repairAll()
def __disableSidePanelContextMenu(self): self.__disableSidePanelContextMenuCb = None app = g_appLoader.getDefBattleApp() if app and hasattr(app.movie, 'leftPanel'): app.movie.leftPanel.onMouseDown = None app.movie.rightPanel.onMouseDown = None else: self.__disableSidePanelContextMenuCb = BigWorld.callback(0.1, self.__disableSidePanelContextMenu)
def show(self): matrixProve = Math.Matrix() matrixProve.translation = self.position + (0, SpotExtended.myConf['markerHeight'], 0) battle = g_appLoader.getDefBattleApp() if battle: markersManager = battle.markersManager vehiclePoint = markersManager._MarkersManager__ownUI.addMarker(matrixProve, 'StaticObjectMarker') markersManager._MarkersManager__ownUI.markerInvoke(vehiclePoint, ('init', [SpotExtended.myConf['markerType'], 40, 40 + 1, self.distance])) self.handle = vehiclePoint
def new__destroyGUI(self): InputHandler.g_instance.onKeyDown -= onKeyDown InputHandler.g_instance.onKeyDown -= onShowHideTanksList InputHandler.g_instance.onKeyUp -= onShowHideTanksList if CONFIG_FILENAME is not None: battle = g_appLoader.getDefBattleApp() battle.VictoryChancesGUI.Visible(False) battle.VictoryChancesGUI.__del__() del battle.VictoryChancesGUI
def __init__(self): Flash.__init__(self, SWF_FILE_NAME, self.__FLASH_CLASS, self.__FLASH_ARGS, self.__FLASH_PATH) self.component.wg_inputKeyMode = 2 self.component.drawWithRestrictedViewPort = False self.movie.backgroundAlpha = 0 self.__parentUI = weakref.proxy(g_appLoader.getDefBattleApp()) self.__parentUIcomp = self.__parentUI.component self.__ownUI = None return
def __disableSidePanelContextMenu(self): self.__disableSidePanelContextMenuCb = None app = g_appLoader.getDefBattleApp() if app and hasattr(app.movie, 'leftPanel'): app.movie.leftPanel.onMouseDown = None app.movie.rightPanel.onMouseDown = None else: self.__disableSidePanelContextMenuCb = BigWorld.callback( 0.1, self.__disableSidePanelContextMenu)
def __closeModalWindow(cls): app = g_appLoader.getDefBattleApp() if app is not None: topWindowContainer = app.containerManager.getContainer(TOP_WINDOW) if topWindowContainer is not None: pyView = topWindowContainer.getView({POP_UP_CRITERIA.VIEW_ALIAS: 'simpleDialog'}) if pyView is not None: topWindowContainer.remove(pyView) return
def inject_handle_key_event(self, event): if g_appLoader.getDefBattleApp(): if config.data['enabled']: if g_gui.get_key(config.data['button_chassis_repair']) and event.isKeyDown(): self.repair_chassis() if g_gui.get_key(config.data['button_fast_repair_all']) and event.isKeyDown(): self.fires() self.heal() self.repair()
def post_message(self, assist_type, vehicles_ids): if assist_type in config.language['messages']: self.format_recreate() for i in vehicles_ids: if i >> 32 & 4294967295L > 0: i = i >> 32 & 4294967295L else: i &= 4294967295L icon = '<img src="img://%s" width="%s" height="%s" />' % ( g_sessionProvider.getArenaDP().getVehicleInfo(i).vehicleType.iconPath.replace('..', 'gui'), config.data['config'].get('icon_size')[0], config.data['config'].get('icon_size')[1]) target_info = g_sessionProvider.getCtx().getFullPlayerNameWithParts(vID=i) if self.check_macros('{icons}'): self.format_str['icons'] += icon if self.check_macros('{names}'): self.format_str['names'] += '[%s]' % target_info[1] if target_info[1] else icon if self.check_macros('{vehicles}'): self.format_str['vehicles'] += '[%s]' % target_info[4] if target_info[4] else icon if self.check_macros('{icons_names}'): self.format_str['icons_names'] += '%s[%s]' % (icon, target_info[1]) if target_info[1] else icon if self.check_macros('{icons_vehicles}'): self.format_str['icons_vehicles'] += '%s[%s]' % (icon, target_info[4]) if target_info[4] else icon if self.check_macros('{full}'): full = g_sessionProvider.getCtx().getFullPlayerName(vID=i) self.format_str['full'] += '%s[%s]' % (icon, full) if full else icon msg = config.language['messages'][assist_type].format(**self.format_str) g_appLoader.getDefBattleApp().call('battle.PlayerMessagesPanel.ShowMessage', [msg + random.choice(string.ascii_letters), '%s' % msg.decode('utf-8-sig'), 'gold'])
def _injectAPButton(self, event): # TODO - Save custom hit height per vehicle if g_appLoader.getDefBattleApp(): # adjust the hull hit height up if event.key == self.toggleDrawDebugRender and event.isKeyDown(): eAP.hitHullHeight = float(eAP.hitHullHeight) + 0.25 hullHeightMsg = "MeltyElement AP Hull Height Multi + 0.05 to " + str(eAP.hitHullHeight) ctrl = g_appLoader.getDefBattleApp() if ctrl is not None: battle_page = ctrl.containerManager.getContainer(ViewTypes.VIEW).getView() battle_page.components['battlePlayerMessages'].as_showGreenMessageS(None, hullHeightMsg) # adjust the hull hit height down if event.key == self.hitDown and event.isKeyDown(): eAP.hitHullHeight = float(eAP.hitHullHeight) - 0.25 hullHeightMsg = "MeltyElement AP Hull Height Multi - 0.05 to " + str(eAP.hitHullHeight) ctrl = g_appLoader.getDefBattleApp() if ctrl is not None: battle_page = ctrl.containerManager.getContainer(ViewTypes.VIEW).getView() battle_page.components['battlePlayerMessages'].as_showGreenMessageS(None, hullHeightMsg) # reset the hull hit height to default/config value if event.key == self.hitDefault and event.isKeyDown(): eAP.hitHullHeight = config.get('armorPanel/eAP/hitHullHeight', 0.7) hullHeightMsg = "MeltyElement AP Hull Height Multi reset to " + str(eAP.hitHullHeight) ctrl = g_appLoader.getDefBattleApp() if ctrl is not None: battle_page = ctrl.containerManager.getContainer(ViewTypes.VIEW).getView() battle_page.components['battlePlayerMessages'].as_showGreenMessageS(None, hullHeightMsg) # Toggle the debugRender on/off if event.key == self.toggleDrawDebugRender and event.isKeyDown(): self.drawDebugRender = not self.drawDebugRender self.modelFakeHitVisible = not self.modelFakeHitVisible self.modelFakeShotVisible = not self.modelFakeShotVisible message = "MeltyElement AP Debug Render - On" if self.drawDebugRender else "MeltyElement AP Debug Render - OFF" ctrl = g_appLoader.getDefBattleApp() if ctrl is not None: battle_page = ctrl.containerManager.getContainer(ViewTypes.VIEW).getView() if self.drawDebugRender: battle_page.components['battlePlayerMessages'].as_showGreenMessageS(None, message) self._setVisible() else: battle_page.components['battlePlayerMessages'].as_showRedMessageS(None, message) self._hideVisible()
def calltextinit(newtext, targetID, attackerID, buddyID): if logging == 'true': LOG_NOTE('textinit:', newtext, targetID, attackerID, buddyID) BigWorld.player().arena.UTtemplate = Template(newtext) if buddyID is not None: try: BigWorld.player().arena.UTtext = BigWorld.player().arena.UTtemplate.safe_substitute(attacker=BigWorld.player().arena.vehicles.get(attackerID)['name'], target=BigWorld.player().arena.vehicles.get(targetID)['name'], buddy=BigWorld.player().arena.vehicles.get(buddyID)['name']) except: BigWorld.player().arena.UTtext = 'Welcome back!' else: try: BigWorld.player().arena.UTtext = BigWorld.player().arena.UTtemplate.safe_substitute(attacker=BigWorld.player().arena.vehicles.get(attackerID)['name'], target=BigWorld.player().arena.vehicles.get(targetID)['name'], buddy='') except: BigWorld.player().arena.UTtext = 'Welcome back!' if g_appLoader.getDefBattleApp() is not None: Battle.Battle._Battle__callEx(g_appLoader.getDefBattleApp(), 'timerBig.setTimer', [BigWorld.player().arena.UTtext]) textCallBackId = BigWorld.callback(0.3, calltext) return
def PlayerAvatar_showOtherVehicleDamagedDevices(self, vehicleID, damagedExtras, destroyedExtras): #print 'PlayerAvatar_showOtherVehicleDamagedDevices' global gExpertTarget if gExpertTarget is not None: target = gExpertTarget if not isinstance(target, Vehicle.Vehicle): if self._PlayerAvatar__maySeeOtherVehicleDamagedDevices and vehicleID != 0: self.cell.monitorVehicleDamagedDevices(0) #print 'PlayerAvatar_showOtherVehicleDamagedDevices monitor {0}'.format(0) #FLUSH_LOG() elif target.id == vehicleID: g_appLoader.getDefBattleApp().damageInfoPanel.show(vehicleID, damagedExtras, destroyedExtras) else: if self._PlayerAvatar__maySeeOtherVehicleDamagedDevices: self.cell.monitorVehicleDamagedDevices(target.id) #print 'PlayerAvatar_showOtherVehicleDamagedDevices monitor {0}'.format(target.id) #FLUSH_LOG() g_appLoader.getDefBattleApp().damageInfoPanel.hide() else: old_PlayerAvatar_showOtherVehicleDamagedDevices(self, vehicleID, damagedExtras, destroyedExtras)
def battleMessage(self, text='', colour='Green', panel='Player'): """ panel = 'Player', 'Vehicle', 'VehicleError' colour = 'Red', 'Purple', 'Green', 'Gold', 'Yellow', 'Self' """ battle = g_appLoader.getDefBattleApp() battle_page = battle.containerManager.getContainer(ViewTypes.VIEW).getView() if battle and battle_page is not None: getattr(battle_page.components['battle%sMessages' % panel], 'as_show%sMessageS' % colour, None)(None, text) else: BigWorld.callback(0.5, partial(battleMessage, text, colour, panel))
def inject_handle_key_event(self, event): if g_appLoader.getDefBattleApp(): if config.data['enabled']: if g_gui.get_key(config.data['button_chassis_repair'] ) and event.isKeyDown(): self.repair_chassis() if g_gui.get_key(config.data['button_fast_repair_all'] ) and event.isKeyDown(): self.fires() self.heal() self.repair()
def _resolveGuiRoot(self): proxy = None try: app = g_appLoader.getDefBattleApp() if not app: return self._guiRef = weakref.ref(app) proxy = weakref.proxy(app) except AttributeError: LOG_CURRENT_EXCEPTION() return proxy
def onMessage(func, self, message, channel): _message = str(message.text) if _message[0:-3] == 'Внимание на квадрат ' and _message[-1] == '!' and len(_message) == 40: app = g_appLoader.getDefBattleApp() minimap = app.containerManager.getContainer(ViewTypes.VIEW).getView().getComponent(BATTLE_VIEW_ALIASES.MINIMAP) cells_plg = minimap.getPlugin('cells') x = _message[-2] if x == '0': x = '10' cells_plg._doAttention(Y_POINT.index(_message[-3]) + (int(x) - 1) * 10, 1) func(self, message, channel)
def message(status=None): app = g_appLoader.getDefBattleApp() if status: app.call('battle.PlayerMessagesPanel.ShowMessage', [ config.language[status] + random.choice(string.ascii_letters), config.language[status].decode('utf-8-sig'), 'gold' ]) else: app.call('battle.PlayerMessagesPanel.ShowMessage', [ config.language['activate_message'] + random.choice(string.ascii_letters), config.language['activate_message'].decode('utf-8-sig'), 'gold' ])
def injectButton(self, event): if not config.data['enabled']: return if g_appLoader.getDefBattleApp(): if g_gui.get_key(config.data['button']) and event.isKeyDown(): status = not self.settingsCore.options.getSetting( settings_constants.GAME.DISABLE_BATTLE_CHAT).get() self.settingsCore.applySetting( settings_constants.GAME.DISABLE_BATTLE_CHAT, status) self.settingsCore.confirmChanges( self.settingsCore.applyStorages(restartApproved=False)) inject.message( config.i18n['UI_message_chatOn'] if status else config.i18n['UI_message_chatOff'], '#FFA500' if status else '#84DE40')
def inject_handle_key_event(event): is_down, key, mods, is_repeat = game.convertKeyEvent(event) is_in_battle = g_appLoader.getDefBattleApp() try: if is_in_battle: if _config.data['enabled']: if BigWorld.isKeyDown(_config.data['button_chassis_repair']) and is_down and mods == _config.data['button_chassis_repair_mod']: _repair.repair_chassis() if BigWorld.isKeyDown(_config.data['button_fast_repair_all']) and is_down and mods == _config.data['button_fast_repair_all_mod']: _repair.fires() _repair.heal() _repair.repair() except Exception as e: print('%s inject_handle_key_event' % _config.ids, e)
def sendMessage(text='', colour='Green', panel='Player'): from gui.Scaleform.framework import ViewTypes from gui.app_loader import g_appLoader """ panel = 'Player', 'Vehicle', 'VehicleError' colour = 'Red', 'Purple', 'Green', 'Gold', 'Yellow', 'Self' """ battle_page = g_appLoader.getDefBattleApp().containerManager.getContainer( ViewTypes.VIEW).getView() if battle_page is not None: getattr(battle_page.components['battle%sMessages' % panel], 'as_show%sMessageS' % colour, None)(None, text) else: BigWorld.callback(0.5, partial(sendMessage, text, colour, panel))
def showMessage(text, color='green'): app = g_appLoader.getDefBattleApp() if app is not None: battle_page = app.containerManager.getContainer(ViewTypes.VIEW).getView() if color == 'green': battle_page.components['battleVehicleMessages'].as_showGreenMessageS(None, text) elif color == 'red': battle_page.components['battleVehicleMessages'].as_showRedMessageS(None, text) else: battle_page.components['battleVehicleMessages'].as_showPurpleMessageS(None, text) # as_showGoldMessageS, as_showSelfMessageS elif isinstance(BigWorld.player(), PlayerAccount): SystemMessages.pushMessage(text, type = SystemMessages.SM_TYPE.Warning) else: print text
def show(self): matrixProve = Math.Matrix() matrixProve.translation = self.position + ( 0, SpotExtended.myConf['markerHeight'], 0) battle = g_appLoader.getDefBattleApp() if battle: markersManager = battle.markersManager vehiclePoint = markersManager._MarkersManager__ownUI.addMarker( matrixProve, 'StaticObjectMarker') markersManager._MarkersManager__ownUI.markerInvoke( vehiclePoint, ('init', [ SpotExtended.myConf['markerType'], 40, 40 + 1, self.distance ])) self.handle = vehiclePoint
def _resolveGuiRoot(self): proxy = None try: app = g_appLoader.getDefBattleApp() if not app: return proxy = weakref.proxy(app) self._guiRef = weakref.ref(app) dispatcher = self.getDispatcher() if dispatcher is not None and proxy is not None: dispatcher.populateUI(proxy) except AttributeError: LOG_CURRENT_EXCEPTION() return proxy
def minimapResetCamera(cam): #import pydevd; pydevd.settrace(); minimap = g_appLoader.getDefBattleApp().containerManager.getContainer(ViewTypes.VIEW).getView().components[BATTLE_VIEW_ALIASES.MINIMAP] personal = minimap.getPlugin('personal') if spgAim.enabled: # matrix = cam._StrategicCamera__aimingSystem._matrix matrix = matrix_factory.makeArcadeCameraMatrix() matrix.translationSrc = cam._StrategicCamera__aimingSystem._matrix # FIXME: find a way to scale the square with the zoom level else: matrix = matrix_factory.makeStrategicCameraMatrix() cameraID = personal._PersonalEntriesPlugin__cameraIDs[_S_NAME.STRATEGIC_CAMERA] personal._setMatrix(cameraID, matrix)
def addStats(): app = g_appLoader.getDefBattleApp() if app is None: return if config('playersPanel/enable'): playersPanel = app.containerManager.getContainer(ViewTypes.VIEW).getView().components['playersPanel'] playersPanel.flashObject.panelSwitch.visible = config('playersPanel/switcherVisible') playersPanel.flashObject.listLeft.y = config('playersPanel/y') playersPanel.flashObject.listRight.y = config('playersPanel/y') for i in range(playersPanel.flashObject.listLeft.getItemsLength()): item = playersPanel.flashObject.listLeft.getItemByIndex(i) accountDBID = item.accountDBID playerInfo = stats.playersInfo.get(str(int(accountDBID)), None) if config('playersPanel/playerNameFull/width'): item.listItem.playerNameFullTF.width = config('playersPanel/playerNameFull/width') if config('playersPanel/playerNameCut/width'): item.listItem.playerNameCutTF.width = config('playersPanel/playerNameCut/width') if config('playersPanel/vehicleName/width'): item.listItem.vehicleTF.width = config('playersPanel/vehicleName/width') if playerInfo is not None: item.listItem.playerNameFullTF.htmlText = config('playersPanel/playerNameFull/left').format(**playerInfo) item.listItem.playerNameCutTF.htmlText = config('playersPanel/playerNameCut/left').format(**playerInfo) item.listItem.vehicleTF.htmlText = config('playersPanel/vehicleName/left').format(**playerInfo) item.listItem.updatePositions() for i in range(playersPanel.flashObject.listRight.getItemsLength()): item = playersPanel.flashObject.listRight.getItemByIndex(i) accountDBID = item.accountDBID playerInfo = stats.playersInfo.get(str(int(accountDBID)),None) if config('playersPanel/playerNameFull/width'): item.listItem.playerNameFullTF.width = config('playersPanel/playerNameFull/width') if config('playersPanel/playerNameCut/width'): item.listItem.playerNameCutTF.width = config('playersPanel/playerNameCut/width') if config('playersPanel/vehicleName/width'): item.listItem.vehicleTF.width = config('playersPanel/vehicleName/width') if playerInfo is not None: item.listItem.playerNameFullTF.htmlText = config('playersPanel/playerNameFull/right').format(**playerInfo) item.listItem.playerNameCutTF.htmlText = config('playersPanel/playerNameCut/right').format(**playerInfo) item.listItem.vehicleTF.htmlText = config('playersPanel/vehicleName/right').format(**playerInfo) item.listItem.updatePositions() if config('tab/enable'): fullStats = app.containerManager.getContainer(ViewTypes.VIEW).getView().components['fullStats'] for i,value in BigWorld.player().arena.vehicles.items(): itemHolder = fullStats.flashObject.getHolderByVehicleID(i) playerNameTF = itemHolder.getStatsItem.playerNameTF vehicleNameTF = itemHolder.getStatsItem.vehicleNameTF if config('tab/playerName/width'): playerNameTF.width = config('tab/playerName/width') if config('tab/vehicleName/width'): vehicleNameTF.width = config('tab/vehicleName/width') accountDBID = str(value['accountDBID']) playerInfo = stats.playersInfo.get(accountDBID, None) if playerInfo is not None: team = 'left' if value['team'] == BigWorld.player().team else 'right' playerNameTF.htmlText = config('tab/playerName/' + team).format(**playerInfo) vehicleNameTF.htmlText = config('tab/vehicleName/' + team).format(**playerInfo)
def minimapResetCamera(cam): minimap = g_appLoader.getDefBattleApp().minimap if minimap is None: return if minimap._Minimap__cameraHandle is not None: minimap._Minimap__ownUI.delEntry(minimap._Minimap__cameraHandle) if spgAim.enabled: m = cam._StrategicCamera__aimingSystem._matrix else: m = Math.WGStrategicAreaViewMP() m.source = BigWorld.camera().invViewMatrix m.baseScale = (1.0, 1.0) minimap._Minimap__cameraHandle = minimap._Minimap__ownUI.addEntry(m, minimap.zIndexManager.getIndexByName(Minimap.CAMERA_STRATEGIC)) minimap._Minimap__ownUI.entryInvoke(minimap._Minimap__cameraHandle, ('gotoAndStop', [Minimap.CURSOR_STRATEGIC])) minimap._Minimap__parentUI.call('minimap.entryInited', [])
def showMarker(enemyID, config): if enemyID is None or MarkersStorage.hasMarker(enemyID): return battle = g_appLoader.getDefBattleApp() if battle is None: return minimap = battle.minimap enemyVehicle = BigWorld.entities.get(enemyID) if enemyVehicle is None: return if not enemyVehicle.isAlive(): return indicator = DirectionIndicator(config) if indicator is None: return indicatorCtrl = DirectionIndicatorCtrl(indicator, config, enemyVehicle) VehicleMarker = VehicleMarkers(enemyID, minimap, 5, indicatorCtrl) if VehicleMarker is not None: MarkersStorage.addMarker(enemyID, VehicleMarker, config)
def keypressed(self): if self.__enableRenderModel: if g_appLoader.getDefBattleApp() is not None: g_appLoader.getDefBattleApp().call('battle.PlayerMessagesPanel.ShowMessage', ['0', 'Ally Outlines OFF', 'gold']) self.__enableRenderModel = False for v in BigWorld.entities.values(): if type(v) is Vehicle: BigWorld.wgDelEdgeDetectEntity(v) elif g_appLoader.getDefBattleApp() is not None: self.__enableRenderModel = True g_appLoader.getDefBattleApp().call('battle.PlayerMessagesPanel.ShowMessage', ['0', 'Ally Outlines ON', 'gold']) BigWorld.Silouhette.ally_silouhette() return
def showInformationDialog(infDialog, callback, customMessage = '', ns = 'common'): """ Show information dialog (1 button - Close) and wait when player closes this dialog. @param infDialog: dialog name. Title, button labels, message builds as #dialogs:' + dialog + '/title'. @param callback: method is invoked when closing the dialog, without arguments. @param customMessage: external message if #dialogs:' + dialog + '/message' does not fit. @param ns: 'common' or 'battle'. """ from gui.app_loader import g_appLoader def onInformationDialogClosed(_): battle = g_appLoader.getDefBattleApp() if battle: battle.removeExternalCallbacks('informationDialog.onClose') callback() battle = g_appLoader.getDefBattleApp() if battle: battle.addExternalCallbacks({'informationDialog.onClose': onInformationDialogClosed}) battle.call('{0:>s}.showInformationDialog'.format(ns), [infDialog, customMessage, 'informationDialog.onClose'])
def onInformationDialogClosed(_): battle = g_appLoader.getDefBattleApp() if battle: battle.removeExternalCallbacks('informationDialog.onClose') callback()
def onConfirmResponse(confirm): battle = g_appLoader.getDefBattleApp() if battle: battle.removeExternalCallbacks('confirmDialog.onConfirm', 'confirmDialog.onClose') callback(confirm)