def _updateServersList(self): result = [] simpleHostList = g_preDefinedHosts.getSimpleHostsList(g_preDefinedHosts.hostsWithRoaming()) if len(simpleHostList): for idx, (hostName, name, csisStatus, peripheryID) in enumerate(simpleHostList): result.append({'label': self.__wrapServerName(name), 'data': hostName, 'id': peripheryID, 'csisStatus': csisStatus}) if connectionManager.peripheryID == 0: result.insert(0, {'label': self.__wrapServerName(connectionManager.serverUserName), 'id': 0, 'csisStatus': HOST_AVAILABILITY.IGNORED, 'data': connectionManager.url}) if not self.__isListSelected: self.__isListSelected = True index = 0 if connectionManager.peripheryID != 0: for idx, (hostName, name, csisStatus, peripheryID) in enumerate(simpleHostList): if hostName == connectionManager.url: index = idx break self.as_setSelectedServerIndexS(index) self._serversDP.rebuildList(result)
def getPrimeTimesForDay(self, selectedTime, groupIdentical=False): hostsList = g_preDefinedHosts.getSimpleHostsList(g_preDefinedHosts.hostsWithRoaming(), withShortName=True) if self.connectionMgr.peripheryID == 0: hostsList.insert(0, (self.connectionMgr.url, self.connectionMgr.serverUserName, self.connectionMgr.serverUserNameShort, HOST_AVAILABILITY.IGNORED, 0)) primeTimes = self.getPrimeTimes() dayStart, dayEnd = time_utils.getDayTimeBoundsForLocal(selectedTime) dayEnd += 1 serversPeriodsMapping = {} for _, _, serverShortName, _, peripheryID in hostsList: if peripheryID not in primeTimes: continue dayPeriods = primeTimes[peripheryID].getPeriodsBetween(dayStart, dayEnd) if groupIdentical and dayPeriods in serversPeriodsMapping.values(): for name, period in serversPeriodsMapping.iteritems(): serverInMapping = name if period == dayPeriods else None if serverInMapping: newName = '{0}, {1}'.format(serverInMapping, serverShortName) serversPeriodsMapping[newName] = serversPeriodsMapping.pop(serverInMapping) break serversPeriodsMapping[serverShortName] = dayPeriods return serversPeriodsMapping
def __makePeripheryData(self): fort = self.fortCtrl.getFort() optionsList = g_preDefinedHosts.getSimpleHostsList(g_preDefinedHosts.hostsWithRoaming()) servername = None for key, name, csisStatus, peripheryID in optionsList: if fort.peripheryID == peripheryID: servername = name if servername is None: servername = connectionManager.serverUserName _, inCooldown = fort.getPeripheryProcessing() timestamp, _, _ = fort.events.get(FORT_EVENT_TYPE.PERIPHERY_COOLDOWN, (0, 0, 0)) buttonEnabled = not inCooldown buttonToolTip = self.__makePeripheryBtnToolTip( buttonEnabled, time_utils.getTimeDeltaFromNow(time_utils.makeLocalServerTime(timestamp)) ) descriptionTooltip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_PERIPHERYDESCRIPTION if self._isFortFrozen(): peripheryName = text_styles.standard(str(servername)) else: peripheryName = text_styles.neutral(str(servername)) return { "peripheryTitle": text_styles.main(i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_PEREPHERYTITLE)), "peripheryName": peripheryName, "buttonEnabled": buttonEnabled, "buttonToolTip": buttonToolTip, "descriptionTooltip": descriptionTooltip, }
def _updateServersList(self): self.__serversList = [] hostsList = g_preDefinedHosts.getSimpleHostsList( g_preDefinedHosts.hostsWithRoaming()) for key, name, csisStatus, peripheryID in hostsList: self.__serversList.append({ 'label': self.__wrapServerName(name), 'id': peripheryID, 'csisStatus': csisStatus, 'selected': connectionManager.peripheryID == peripheryID }) if connectionManager.peripheryID == 0: self.__serversList.insert( 0, { 'label': self.__wrapServerName(connectionManager.serverUserName), 'id': 0, 'csisStatus': HOST_AVAILABILITY.IGNORED, 'selected': True }) if not self.__isGuiUpdateSuppressed: self.as_setServersListS(self.__serversList)
def _updateServersList(self): hostsList = g_preDefinedHosts.getSimpleHostsList( g_preDefinedHosts.hostsWithRoaming()) serversList = [] for key, name, csisStatus, peripheryID in hostsList: if peripheryID not in self.__ctx.getForbiddenPeripherieIDs(): serversList.append({ 'label': name if not constants.IS_CHINA else makeHtmlString( 'html_templates:lobby/serverStats', 'serverName', {'name': name}), 'id': peripheryID, 'csisStatus': csisStatus, 'selected': True }) label = _ms(self.__ctx.getSelectServerLabel()) if len(serversList) == 1: label = _ms(self.__ctx.getApplySwitchLabel(), server=text_styles.stats(serversList[0]['label'])) self.as_setDataS({ 'label': label, 'peripheries': serversList, 'isServerDropdownMenuVisibility': len(serversList) > 1, 'selectedIndex': 0 })
def __getHostList(self): hostsList = g_preDefinedHosts.getSimpleHostsList(g_preDefinedHosts.hostsWithRoaming(), withShortName=True) if self.connectionMgr.isStandalone(): hostsList.insert(0, (self.connectionMgr.url, self.connectionMgr.serverUserName, self.connectionMgr.serverUserNameShort, HOST_AVAILABILITY.IGNORED, 0)) return hostsList
def __getPeripheryList(): result = [] optionsList = g_preDefinedHosts.getSimpleHostsList( g_preDefinedHosts.hostsWithRoaming()) for _, name, _, peripheryID in optionsList: result.append({'id': peripheryID, 'label': name}) if connectionManager.peripheryID == 0: result.append({'id': 0, 'label': connectionManager.serverUserName}) return result
def __getServersList(self): result = [] optionsList = g_preDefinedHosts.getSimpleHostsList( g_preDefinedHosts.hostsWithRoaming()) for _, name, _, peripheryID in optionsList: result.append({'id': peripheryID, 'label': name}) if connectionManager.peripheryID == 0: result.append({'id': 0, 'label': connectionManager.serverUserName}) return result
def __isFrontlineAvailableOnDifferentPeriphery(self): hostsList = g_preDefinedHosts.getSimpleHostsList( g_preDefinedHosts.hostsWithRoaming()) for _, _, _, peripheryID in hostsList: if peripheryID == self.__connectionMgr.peripheryID: continue primeTimeStatus, _, primeTimeNow = self.__epicController.getPrimeTimeStatus( peripheryID) if primeTimeStatus != PrimeTimeStatus.NOT_SET and primeTimeNow: return True return False
def __buildServersList(self): hostsList = g_preDefinedHosts.getSimpleHostsList( g_preDefinedHosts.hostsWithRoaming(), withShortName=True) if self._connectionMgr.isStandalone(): hostsList.insert( 0, (self._connectionMgr.url, self._connectionMgr.serverUserName, self._connectionMgr.serverUserNameShort, HOST_AVAILABILITY.IGNORED, 0)) for idx, serverData in enumerate(hostsList): serverPresenter = self._serverPresenterClass(idx, *serverData) self._allServers[ serverPresenter.getPeripheryID()] = serverPresenter
def hasAvailablePrimeTimeServers(self): hostsList = g_preDefinedHosts.getSimpleHostsList( g_preDefinedHosts.hostsWithRoaming(), withShortName=True) if self.connectionMgr.isStandalone(): hostsList.insert( 0, (self.connectionMgr.url, self.connectionMgr.serverUserName, self.connectionMgr.serverUserNameShort, HOST_AVAILABILITY.IGNORED, 0)) for _, _, _, _, peripheryID in hostsList: primeTimeStatus, _, _ = self.getPrimeTimeStatus(peripheryID) if primeTimeStatus in (PRIME_TIME_STATUS.AVAILABLE, PRIME_TIME_STATUS.NOT_AVAILABLE): return True return False
def _updateServersList(self): hostsList = g_preDefinedHosts.getSimpleHostsList(g_preDefinedHosts.hostsWithRoaming()) serversList = [] for hostName, name, csisStatus, peripheryID in hostsList: if peripheryID not in self.__ctx.getForbiddenPeripherieIDs(): serversList.append({'label': name, 'id': peripheryID, 'csisStatus': csisStatus, 'data': hostName}) label = _ms(self.__ctx.getSelectServerLabel()) if len(serversList) == 1: label = _ms(self.__ctx.getApplySwitchLabel(), server=text_styles.stats(serversList[0]['label'])) self._serversDP.rebuildList(serversList) self.as_setServerParamsS(label, len(serversList) > 1) self.as_setSelectedIndexS(0)
def _updateServersList(self): self.__serversList = [] hostsList = g_preDefinedHosts.getSimpleHostsList(g_preDefinedHosts.hostsWithRoaming()) for key, name, csisStatus, peripheryID in hostsList: self.__serversList.append({'label': self.__wrapServerName(name), 'id': peripheryID, 'csisStatus': csisStatus, 'selected': connectionManager.peripheryID == peripheryID}) if connectionManager.peripheryID == 0: self.__serversList.insert(0, {'label': self.__wrapServerName(connectionManager.serverUserName), 'id': 0, 'csisStatus': HOST_AVAILABILITY.IGNORED, 'selected': True}) if not self.__isGuiUpdateSuppressed: self.as_setServersListS(self.__serversList)
def _updateServersList(self): hostsList = g_preDefinedHosts.getSimpleHostsList(g_preDefinedHosts.hostsWithRoaming()) serversList = [] for key, name, csisStatus, peripheryID in hostsList: if peripheryID not in self.__ctx.getForbiddenPeripherieIDs(): serversList.append({'label': name if not constants.IS_CHINA else makeHtmlString('html_templates:lobby/serverStats', 'serverName', {'name': name}), 'id': peripheryID, 'csisStatus': csisStatus, 'selected': True}) label = _ms(self.__ctx.getSelectServerLabel()) if len(serversList) == 1: label = _ms(self.__ctx.getApplySwitchLabel(), server=text_styles.stats(serversList[0]['label'])) self.as_setDataS({'label': label, 'peripheries': serversList, 'isServerDropdownMenuVisibility': len(serversList) > 1, 'selectedIndex': 0})
def __makePeripheryData(self): fort = self.fortCtrl.getFort() optionsList = g_preDefinedHosts.getSimpleHostsList(g_preDefinedHosts.hostsWithRoaming()) servername = None for key, name, csisStatus, peripheryID in optionsList: if fort.peripheryID == peripheryID: servername = name if servername is None: servername = connectionManager.serverUserName _, inCooldown = fort.getPeripheryProcessing() timestamp, _, _ = fort.events.get(FORT_EVENT_TYPE.PERIPHERY_COOLDOWN, (0, 0, 0)) buttonEnabled = not inCooldown buttonToolTip = self.__makePeripheryBtnToolTip(buttonEnabled, time_utils.getTimeDeltaFromNow(time_utils.makeLocalServerTime(timestamp))) descriptionTooltip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_PERIPHERYDESCRIPTION return {'peripheryTitle': self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_PEREPHERYTITLE)), 'peripheryName': self.app.utilsManager.textManager.getText(TextType.NEUTRAL_TEXT, str(servername)), 'buttonEnabled': buttonEnabled, 'buttonToolTip': buttonToolTip, 'descriptionTooltip': descriptionTooltip}
def __updateList(self): hostsList = g_preDefinedHosts.getSimpleHostsList( g_preDefinedHosts.hostsWithRoaming(), withShortName=True) if self.connectionMgr.isStandalone(): hostsList.insert( 0, (self.connectionMgr.url, self.connectionMgr.serverUserName, self.connectionMgr.serverUserNameShort, HOST_AVAILABILITY.IGNORED, 0)) serversList = [] availableServersList = [] for hostName, name, shortName, csisStatus, peripheryID in hostsList: primeTimeStatus, timeLeft, _ = self._getController( ).getPrimeTimeStatus(peripheryID) pingValue, _ = g_preDefinedHosts.getHostPingData(hostName) pingValue = min(pingValue, _PING_MAX_VALUE) if primeTimeStatus in (PRIME_TIME_STATUS.AVAILABLE, PRIME_TIME_STATUS.NOT_AVAILABLE): isAvailable = primeTimeStatus == PRIME_TIME_STATUS.AVAILABLE periphery = { 'label': name, 'id': peripheryID, 'csisStatus': csisStatus, 'data': hostName, 'enabled': isAvailable, 'timeLeft': timeLeft, 'shortname': shortName, 'pingValue': pingValue } serversList.append(periphery) if isAvailable: availableServersList.append(periphery) self.__allServersList = serversList if availableServersList: self._isEnabled = True serversList = availableServersList else: self._isEnabled = False self.__serversList = serversList self.__serversDP.rebuildList(serversList) self.__updateServer()
def getDisplayableData(self): from ConnectionManager import connectionManager serverName = '' if connectionManager.peripheryID == 0: serverName = connectionManager.serverUserName else: hostsList = g_preDefinedHosts.getSimpleHostsList(g_preDefinedHosts.hostsWithRoaming()) for key, name, csisStatus, peripheryID in hostsList: if connectionManager.peripheryID == peripheryID: serverName = name break serversStats = None if constants.IS_SHOW_SERVER_STATS: serversStats, _ = game_control.g_instance.serverStats.getFormattedStats() return {'name': i18n.makeString(TOOLTIPS.HEADER_MENU_HEADER), 'description': i18n.makeString(TOOLTIPS.HEADER_MENU_DESCRIPTION), 'serverHeader': i18n.makeString(TOOLTIPS.HEADER_MENU_SERVER), 'serverName': serverName, 'playersOnServer': i18n.makeString(TOOLTIPS.HEADER_MENU_PLAYERSONSERVER), 'serversStats': serversStats}
def getDisplayableData(self, peripheryID): hostsList = g_preDefinedHosts.getSimpleHostsList(g_preDefinedHosts.hostsWithRoaming(), withShortName=True) serverName = '' for _, serverData in enumerate(hostsList): _, serverName, _, _, pID = serverData if pID == peripheryID: break timeLeftStr = '-' isNow = False primeTime = self.__rankedController.getPrimeTimes().get(peripheryID) if primeTime: currentCycleEnd = self.__rankedController.getCurrentSeason().getCycleEndDate() isNow, timeLeft = primeTime.getAvailability(time_utils.getCurrentLocalServerTimestamp(), currentCycleEnd) timeLeftStr = backport.getTillTimeStringByRClass(timeLeft, R.strings.ranked_battles.status.timeLeft) formatedTime = text_styles.neutral(timeLeftStr) if isNow: descriptionID = R.strings.ranked_battles.primeTime.tooltip.server.available.untill() else: descriptionID = R.strings.ranked_battles.primeTime.tooltip.server.unavailable.inTime() sName = backport.text(R.strings.ranked_battles.primeTime.tooltip.server.onServer(), server=serverName) description = backport.text(descriptionID, time=formatedTime) return {'body': '{}\n{}'.format(sName, description)}
def __makePeripheryData(self): fort = self.fortCtrl.getFort() optionsList = g_preDefinedHosts.getSimpleHostsList( g_preDefinedHosts.hostsWithRoaming()) servername = None for key, name, csisStatus, peripheryID in optionsList: if fort.peripheryID == peripheryID: servername = name if servername is None: servername = connectionManager.serverUserName _, inCooldown = fort.getPeripheryProcessing() timestamp, _, _ = fort.events.get(FORT_EVENT_TYPE.PERIPHERY_COOLDOWN, (0, 0, 0)) buttonEnabled = not inCooldown buttonToolTip = self.__makePeripheryBtnToolTip( buttonEnabled, time_utils.getTimeDeltaFromNow( time_utils.makeLocalServerTime(timestamp))) descriptionTooltip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_PERIPHERYDESCRIPTION if self._isFortFrozen(): peripheryName = text_styles.standard(str(servername)) else: peripheryName = text_styles.neutral(str(servername)) return { 'peripheryTitle': text_styles.main( i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_PEREPHERYTITLE)), 'peripheryName': peripheryName, 'buttonEnabled': buttonEnabled, 'buttonToolTip': buttonToolTip, 'descriptionTooltip': descriptionTooltip }