Jump to content
Korean Random

Контекстное меню


CyToTV

Recommended Posts

def _generateOptions(self, ctx = None):
        vehicle = g_itemsCache.items.getItemByCD(self._nodeCD)
        options = [self._makeItem(VEHICLE.INFO, MENU.CONTEXTMENU_VEHICLEINFOEX),
         self._makeItem(VEHICLE.STATS, MENU.CONTEXTMENU_SHOWVEHICLESTATISTICS, {'enabled': NODE_STATE.isWasInBattle(self._nodeState)}),
         self._makeSeparator(),
         self._makeItem(VEHICLE.UNLOCK, MENU.CONTEXTMENU_UNLOCK, {'enabled': NODE_STATE.isAvailable2Unlock(self._nodeState) and not NODE_STATE.isPremium(self._nodeState)})]
        if not vehicle.isPremiumIGR:
            options.extend([self._makeItem(VEHICLE.BUY, MENU.CONTEXTMENU_BUY, {'enabled': NODE_STATE.isAvailable2Buy(self._nodeState)}),
             self._makeItem(VEHICLE.SELL, MENU.CONTEXTMENU_VEHICLEREMOVE if vehicle.isRented else MENU.CONTEXTMENU_SELL, {'enabled': NODE_STATE.isAvailable2Sell(self._nodeState)}),
             self._makeSeparator(),
             self._makeItem(VEHICLE.SELECT, MENU.CONTEXTMENU_SELECTVEHICLEINHANGAR, {'enabled': (NODE_STATE.inInventory(self._nodeState) or NODE_STATE.isRentalOver(self._nodeState)) and NODE_STATE.isVehicleCanBeChanged(self._nodeState)})])
        return options

вот и я тоже так понял...

Link to comment
Short link
Share on other sites

Походу. Только, вот еще один пункт у меня создать не получается...

это смотри как в хвм сделано

# -*- coding: utf-8 -*-
from gui.Scaleform.locale.MENU import MENU
from gui.Scaleform.daapi.view.lobby.techtree.settings import NODE_STATE
from gui.Scaleform.daapi.view.lobby.hangar.hangar_cm_handlers import VEHICLE
from gui.Scaleform.daapi.view.lobby.techtree.research_cm_handlers import ResearchVehicleContextMenuHandler   
    
def new_generateOptions(self, ctx = None):
    options = old_generateOptions(self, ctx)
    options.append(self._makeItem(VEHICLE.STATS, u'Перейти к статистике танка', {'enabled': NODE_STATE.isWasInBattle(self._nodeState)}))
    return options
    
    
    
old_generateOptions = ResearchVehicleContextMenuHandler._generateOptions
ResearchVehicleContextMenuHandler._generateOptions = new_generateOptions

как то так

  • Upvote 1
Link to comment
Short link
Share on other sites

как свою функцию лепить я не допер :ok:

 

 

просто огромное спасибо))) все работает.. ща будем пытаться пилить функцию..)) ты второй раз сделал мой день  :heh:

Link to comment
Short link
Share on other sites

  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...