def __onServerSettingsChanged(self, diff): if TRADE_IN_CONFIG_NAME in diff: with self._eventBus.getTransaction(): self.__fillConfig() self.__fillCache() self.__resetSelectedVehiclesIfNeeded() self._eventBus.call(VehicleBuyEvent(VehicleBuyEvent.VEHICLE_SELECTED))
def __onSync(self, updateReason, diff): if updateReason == CACHE_SYNC_REASON.CLIENT_UPDATE: if diff is not None and GUI_ITEM_TYPE.VEHICLE in diff: with self._eventBus.getTransaction(): self.__fillConfig() self.__fillCache() self.__resetSelectedVehiclesIfNeeded() self._eventBus.call(VehicleBuyEvent(VehicleBuyEvent.VEHICLE_SELECTED)) return
def setActiveTradeOffVehicleCD(self, value): intCD = int(value) oldCD = self.__activeTradeOffCD if self.__canSetActiveTradeOffVehicle(intCD): self.__activeTradeOffCD = intCD if self.__activeTradeOffCD != oldCD: g_eventBus.handleEvent(VehicleBuyEvent(VehicleBuyEvent.VEHICLE_SELECTED)) else: _logger.error('%s, can not be set as active trade-off vehicle compact descriptor', intCD)
def _onTokensUpdated(self, diff): if not self.isEnabled(): return modifiedTokens = set(diff.iterkeys()) accessTokens = self.getConfig().allAccessTokenSet if accessTokens & modifiedTokens: with self._eventBus.getTransaction(): self.__fillConfig() self.__fillCache() self.__resetSelectedVehiclesIfNeeded() self._eventBus.call(VehicleBuyEvent(VehicleBuyEvent.VEHICLE_SELECTED))
def selectVehicleToBuy(self, vehCD): intCD = int(vehCD) oldCD = self._vehicleToBuyInfo.vehicleCD if not self.__canSetVehicleToBuy(intCD): _logger.error('%s, can not be set as active trade-in buy vehicle compact descriptor', intCD) return possibleVehiclesToSell = set() if intCD in self.getVehiclesToBuy(False): buyToSellConversionCache = self.__cache.get('buyToSellConversionCache', {}) for _, vehToSell in buyToSellConversionCache.get(intCD, []): possibleVehiclesToSell.add(vehToSell.intCD) self._vehicleToBuyInfo = _TradeInVehicleToBuy(intCD, possibleVehiclesToSell) if intCD != oldCD: self._eventBus.call(VehicleBuyEvent(VehicleBuyEvent.VEHICLE_SELECTED))
def selectVehicleToSell(self, vehCD): intCD = int(vehCD) oldCD = self._vehicleToSellInfo.vehicleCD if not self.__canSetVehicleToSell(intCD): _logger.error('%s, can not be set as active trade-off vehicle compact descriptor', intCD) return else: possibleVehiclesToBuyCDs = set() conversionRule = None if intCD in self.getVehiclesToSell(False): sellToBuyConversionCache = self.__cache.get('sellToBuyConversionCache', {}) conversionRule, possibleVehiclesToBuy = sellToBuyConversionCache.get(intCD, (None, [])) possibleVehiclesToBuyCDs = {v.intCD for v in possibleVehiclesToBuy} self._vehicleToSellInfo = _TradeInVehicleToSell(intCD, possibleVehiclesToBuyCDs, conversionRule) if intCD != oldCD: self._eventBus.call(VehicleBuyEvent(VehicleBuyEvent.VEHICLE_SELECTED)) return
def onSelectVehicle(self, vehicle): self.fireEvent( VehicleBuyEvent(VehicleBuyEvent.VEHICLE_SELECTED, vehicle)) self.onWindowClose()