Пример #1
0
    def __setVehicleLayouts(self, vehicle, shellsLayout = list(), eqsLayout = list()):
        LOG_DEBUG('setVehicleLayouts', shellsLayout, eqsLayout)
        result = yield VehicleLayoutProcessor(vehicle, shellsLayout, eqsLayout).request()
        if result and result.auxData:
            for m in result.auxData:
                SystemMessages.g_instance.pushI18nMessage(m.userMsg, type=m.sysMsgType)

        if result and len(result.userMsg):
            SystemMessages.g_instance.pushI18nMessage(result.userMsg, type=result.sysMsgType)
        self.destroy()
Пример #2
0
 def doAction(self):
     if self._battleBooster is not None:
         boosterLayout = (self._battleBooster.intCD, 1) if self._battleBooster else (0, 0)
         eqsLayout = EquipmentLayoutHelper(self._vehicle, self._eqsLayout, boosterLayout)
         result = yield VehicleBattleBoosterLayoutProcessor(self._vehicle, self._battleBooster, eqsLayout, self.skipConfirm).request()
     else:
         shellsHelper = ShellLayoutHelper(self._vehicle, self._shellsLayout)
         eqsHelper = EquipmentLayoutHelper(self._vehicle, self._eqsLayout)
         result = yield VehicleLayoutProcessor(self._vehicle, shellsHelper, eqsHelper, self.skipConfirm).request()
     self._showResult(result)
     return
Пример #3
0
def checkAmmoLevel(callback):
    """
    Check ammo for current vehicle, if it is lower then 20% shows message dialog
    Example:
            isAmmoOk = yield checkAmmoLevel()
            if isAmmoOk:
                    do something...
    
    @return: True if ammo level is ok or user confirm, False otherwise
    """
    showAmmoWarning = False
    from CurrentVehicle import g_currentVehicle
    if g_currentVehicle.isReadyToFight():
        vehicle = g_currentVehicle.item
        if not g_currentVehicle.isAutoLoadFull(
        ) or not g_currentVehicle.isAutoEquipFull():
            from gui import SystemMessages
            from gui.shared.gui_items.processors.vehicle import VehicleLayoutProcessor
            shellsLayout = []
            eqsLayout = []
            for shell in vehicle.shells:
                shellsLayout.append(shell.intCD if not shell.isBoughtForCredits
                                    else -shell.intCD)
                shellsLayout.append(shell.defaultCount)

            for eq in vehicle.eqsLayout:
                if eq is not None:
                    eqsLayout.append(
                        eq.intCD if not eq.isBoughtForCredits else -eq.intCD)
                    eqsLayout.append(1)
                else:
                    eqsLayout.append(0)
                    eqsLayout.append(0)

            LOG_DEBUG('setVehicleLayouts', shellsLayout, eqsLayout)
            result = yield VehicleLayoutProcessor(vehicle, shellsLayout,
                                                  eqsLayout).request()
            if result and result.auxData:
                for m in result.auxData:
                    SystemMessages.g_instance.pushI18nMessage(
                        m.userMsg, type=m.sysMsgType)

            if result and len(result.userMsg):
                SystemMessages.g_instance.pushI18nMessage(
                    result.userMsg, type=result.sysMsgType)
        showAmmoWarning = not g_currentVehicle.item.isAmmoFull
    if showAmmoWarning:
        from gui import DialogsInterface
        success = yield DialogsInterface.showI18nConfirmDialog('lowAmmo')
        callback(success)
    else:
        yield lambda callback: callback(None)
        callback(True)
    return