Example #1
0
    def _generateOptions(self, ctx=None):
        item = self.itemsCache.items.getItemByCD(self._intCD)
        buyPriceVO = getItemPricesVO(item.getBuyPrice())
        sellPriceVO = getItemPricesVO(item.getSellPrice())
        inventoryCount = self._c11nView.getItemInventoryCount(item)
        availableForSale = inventoryCount > 0 and item.getSellPrice(
        ) != ITEM_PRICE_EMPTY and not item.isRentable and not item.isHidden
        style = self._c11nView.getModifiedStyle()
        removeFromTankEnabled = style.intCD == item.intCD if style is not None else False
        for outfit in (self._c11nView.getModifiedOutfit(season)
                       for season in SeasonType.COMMON_SEASONS):
            if outfit.has(item):
                removeFromTankEnabled = True
                break

        accountMoney = self.itemsCache.items.stats.money
        availableForPurchase = not item.isHidden and not item.getBuyPrice(
        ) == ITEM_PRICE_EMPTY and item.getBuyPrice().price <= accountMoney
        showAlert = len(sellPriceVO[0]) > 1
        tooltipVO = None
        if showAlert:
            tooltipVO = packActionTooltipData(
                ACTION_TOOLTIPS_TYPE.ITEM, str(item.intCD), False,
                item.sellPrices.getSum().price,
                item.sellPrices.getSum().defPrice)
            price = sellPriceVO[0]['price']
            sellPriceVO[0] = {}
            sellPriceVO[0]['price'] = price
        return [
            self._makeItem(
                CustomizationOptions.BUY,
                MENU.cst_item_ctx_menu(CustomizationOptions.BUY), {
                    'data': {
                        'price': first(buyPriceVO)
                    } if availableForPurchase else None,
                    'enabled': availableForPurchase
                }, None, 'CurrencyContextMenuItem'),
            self._makeSeparator(),
            self._makeItem(
                CustomizationOptions.SELL,
                MENU.cst_item_ctx_menu(CustomizationOptions.SELL), {
                    'data': {
                        'price': first(sellPriceVO)
                    } if availableForSale else None,
                    'enabled': availableForSale,
                    'showAlert': showAlert,
                    'tooltipVO': tooltipVO
                }, None, 'CurrencyContextMenuItem'),
            self._makeSeparator(),
            self._makeItem(
                CustomizationOptions.REMOVE_FROM_TANK,
                MENU.cst_item_ctx_menu(CustomizationOptions.REMOVE_FROM_TANK),
                {'enabled': removeFromTankEnabled})
        ]
Example #2
0
 def _generateOptions(self, ctx=None):
     if self._selected:
         label = MENU.cst_item_ctx_menu('prohibitSale')
     else:
         label = MENU.cst_item_ctx_menu('allowSale')
     return [
         self._makeItem(_StorageOptions.INFORMATION,
                        MENU.cst_item_ctx_menu(
                            _StorageOptions.INFORMATION)),
         self._makeItem(_StorageOptions.SELL,
                        MENU.cst_item_ctx_menu(_StorageOptions.SELL)),
         self._makeItem(_StorageOptions.SALE_OPTION, label)
     ]
Example #3
0
    def _generateOptions(self, ctx=None):
        """ Generate a list of options for  the context menu.
        """
        item = self.itemsCache.items.getItemByCD(self._intCD)
        buyPriceVO = getItemPricesVO(item.getBuyPrice())
        sellPriceVO = getItemPricesVO(item.getSellPrice())
        inventoryCount = self._c11nView.getItemInventoryCount(item)
        availableForSale = inventoryCount > 0 and item.getSellPrice(
        ) != ITEM_PRICE_EMPTY and not item.isRentable and not item.isHidden
        style = self._c11nView.getModifiedStyle()
        removeFromTankEnabled = style.intCD == item.intCD if style is not None else False
        for outfit in (self._c11nView.getModifiedOutfit(season)
                       for season in SeasonType.COMMON_SEASONS):
            if outfit.has(item):
                removeFromTankEnabled = True
                break

        availableForPurchase = not item.isHidden and item.getBuyPrice(
        ) != ITEM_PRICE_EMPTY
        return [
            self._makeItem(
                CustomizationOptions.BUY,
                MENU.cst_item_ctx_menu(CustomizationOptions.BUY), {
                    'data': {
                        'price': first(buyPriceVO)
                    } if availableForPurchase else None,
                    'enabled': availableForPurchase
                }, None, 'CurrencyContextMenuItem'),
            self._makeSeparator(),
            self._makeItem(
                CustomizationOptions.SELL,
                MENU.cst_item_ctx_menu(CustomizationOptions.SELL), {
                    'data': {
                        'price': first(sellPriceVO)
                    } if availableForSale else None,
                    'enabled': availableForSale
                }, None, 'CurrencyContextMenuItem'),
            self._makeSeparator(),
            self._makeItem(
                CustomizationOptions.REMOVE_FROM_TANK,
                MENU.cst_item_ctx_menu(CustomizationOptions.REMOVE_FROM_TANK),
                {'enabled': removeFromTankEnabled})
        ]