コード例 #1
0
ファイル: lobbyserverstats.py プロジェクト: Difrex/wotsdk
    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)
コード例 #2
0
ファイル: serverstats.py プロジェクト: webiumsk/WOT-0.9.15-CT
    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
コード例 #4
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
        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,
        }
コード例 #5
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)
コード例 #6
0
    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
        })
コード例 #7
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
コード例 #8
0
    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
コード例 #9
0
    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
コード例 #10
0
    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
コード例 #11
0
 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
コード例 #12
0
    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
コード例 #13
0
    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)
コード例 #14
0
    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)
コード例 #15
0
ファイル: serverstats.py プロジェクト: webiumsk/WOT-0.9.12-CT
    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)
コード例 #16
0
    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})
コード例 #17
0
ファイル: fortsettingswindow.py プロジェクト: webiumsk/WoT
    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}
コード例 #18
0
    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()
コード例 #19
0
ファイル: common.py プロジェクト: webiumsk/WoT
    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}
コード例 #20
0
    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)}
コード例 #21
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
        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
        }