Esempio n. 1
0
class ClanEmblemsHelper(_EmblemsHelper):
    __default = {
        16: _readEmblem(clan_settings.getDefaultEmblem16x16()),
        32: _readEmblem(clan_settings.getDefaultEmblem32x32()),
        64: None,
        128: _readEmblem(clan_settings.getDefaultEmblem128x128()),
        256: _readEmblem(clan_settings.getDefaultEmblem256x256())
    }

    def requestClanEmblem16x16(self, clanDbID):
        self.__makeRequest(clanDbID, 16, self.onClanEmblem16x16Received)

    def requestClanEmblem32x32(self, clanDbID):
        self.__makeRequest(clanDbID, 32, self.onClanEmblem32x32Received)

    def requestClanEmblem64x64(self, clanDbID):
        self.__makeRequest(clanDbID, 64, self.onClanEmblem64x64Received)

    def requestClanEmblem128x128(self, clanDbID):
        self.__makeRequest(clanDbID, 128, self.onClanEmblem128x128Received)

    def requestClanEmblem256x256(self, clanDbID):
        self.__makeRequest(clanDbID, 256, self.onClanEmblem256x256Received)

    def onClanEmblem16x16Received(self, clanDbID, emblem):
        pass

    def onClanEmblem32x32Received(self, clanDbID, emblem):
        pass

    def onClanEmblem64x64Received(self, clanDbID, emblem):
        pass

    def onClanEmblem128x128Received(self, clanDbID, emblem):
        pass

    def onClanEmblem256x256Received(self, clanDbID, emblem):
        pass

    def getDefaultClanEmblem(self, size):
        width, _ = size
        return self.__default.get(width, None)

    def _requestClanEmblem(self, clanDbID, url, size, handler):
        cb = partial(handler, clanDbID)
        self.requestEmblemByUrl(url, (size, size), cb,
                                self.getDefaultClanEmblem)

    def __makeRequest(self, clanDbID, size, requestHandler):
        svrSettings = g_lobbyContext.getServerSettings()
        url = svrSettings.fileServer.getClanEmblemBySize(
            clanDbID, size) if svrSettings is not None else None
        self._requestClanEmblem(clanDbID, url, size, requestHandler)
        return
Esempio n. 2
0
class ClanEmblemsHelper(ImageHelper):
    __default = {
        EmblemSize.SIZE_16: clan_settings.getDefaultEmblem16x16(),
        EmblemSize.SIZE_32: clan_settings.getDefaultEmblem32x32(),
        EmblemSize.SIZE_64: None,
        EmblemSize.SIZE_128: clan_settings.getDefaultEmblem128x128(),
        EmblemSize.SIZE_256: clan_settings.getDefaultEmblem256x256()
    }

    def requestClanEmblem16x16(self, clanDbID):
        self.__makeRequest(clanDbID, EmblemSize.SIZE_16,
                           self.onClanEmblem16x16Received)

    def requestClanEmblem32x32(self, clanDbID):
        self.__makeRequest(clanDbID, EmblemSize.SIZE_32,
                           self.onClanEmblem32x32Received)

    def requestClanEmblem64x64(self, clanDbID):
        self.__makeRequest(clanDbID, EmblemSize.SIZE_64,
                           self.onClanEmblem64x64Received)

    def requestClanEmblem128x128(self, clanDbID):
        self.__makeRequest(clanDbID, EmblemSize.SIZE_128,
                           self.onClanEmblem128x128Received)

    def requestClanEmblem256x256(self, clanDbID):
        self.__makeRequest(clanDbID, EmblemSize.SIZE_256,
                           self.onClanEmblem256x256Received)

    def onClanEmblem16x16Received(self, clanDbID, emblem):
        pass

    def onClanEmblem32x32Received(self, clanDbID, emblem):
        pass

    def onClanEmblem64x64Received(self, clanDbID, emblem):
        pass

    def onClanEmblem128x128Received(self, clanDbID, emblem):
        pass

    def onClanEmblem256x256Received(self, clanDbID, emblem):
        pass

    def getDefaultClanEmblem(self, size):
        width, _ = size
        return readLocalImage(self.__default.get(width, None))

    def __makeRequest(self, clanDbID, size, handler):
        url = getClanEmblemURL(clanDbID, size)
        cb = partial(handler, clanDbID)
        self.requestImageByUrl(url, cb, (size, size),
                               self.getDefaultClanEmblem)
Esempio n. 3
0
class ClanEmblemsHelper(ImageHelper):
    __default = {
        16: clan_settings.getDefaultEmblem16x16(),
        32: clan_settings.getDefaultEmblem32x32(),
        64: None,
        128: clan_settings.getDefaultEmblem128x128(),
        256: clan_settings.getDefaultEmblem256x256()
    }
    lobbyContext = dependency.descriptor(ILobbyContext)

    def requestClanEmblem16x16(self, clanDbID):
        self.__makeRequest(clanDbID, 16, self.onClanEmblem16x16Received)

    def requestClanEmblem32x32(self, clanDbID):
        self.__makeRequest(clanDbID, 32, self.onClanEmblem32x32Received)

    def requestClanEmblem64x64(self, clanDbID):
        self.__makeRequest(clanDbID, 64, self.onClanEmblem64x64Received)

    def requestClanEmblem128x128(self, clanDbID):
        self.__makeRequest(clanDbID, 128, self.onClanEmblem128x128Received)

    def requestClanEmblem256x256(self, clanDbID):
        self.__makeRequest(clanDbID, 256, self.onClanEmblem256x256Received)

    def onClanEmblem16x16Received(self, clanDbID, emblem):
        pass

    def onClanEmblem32x32Received(self, clanDbID, emblem):
        pass

    def onClanEmblem64x64Received(self, clanDbID, emblem):
        pass

    def onClanEmblem128x128Received(self, clanDbID, emblem):
        pass

    def onClanEmblem256x256Received(self, clanDbID, emblem):
        pass

    def getDefaultClanEmblem(self, size):
        width, _ = size
        return readLocalImage(self.__default.get(width, None))

    def __makeRequest(self, clanDbID, size, handler):
        svrSettings = self.lobbyContext.getServerSettings()
        url = svrSettings.fileServer.getClanEmblemBySize(
            clanDbID, size) if svrSettings is not None else None
        cb = partial(handler, clanDbID)
        self.requestImageByUrl(url, (size, size), cb,
                               self.getDefaultClanEmblem)
        return