Beispiel #1
0
def writeModDataToDisk(self, newdata, fromIngame=0):
    newdata = flashObject2Dict(newdata)
    #print "received ModData from flash:"
    #print newdata
    #ModSettingsAPI.mods = newdata #DICKES TODO: UNION statt replacement
    for key in ModSettingsAPI.mods:
        #print 'saving mod '+key
        ModSettingsAPI.mods[key] = newdata[key]
    #print '[ModsSettings] saving all configs to disk'#, newdata
    
    if not os.path.exists(ModSettingsAPI.MODSETTINGSPATH):
        os.makedirs(ModSettingsAPI.MODSETTINGSPATH)
    for modname in newdata:
        #print '[ModsSettings] saving mod',modname
        with open(ModSettingsAPI.MODSETTINGSPATH+modname+'.cfg', 'w') as outfile:
            # Settings are stored in [modname][2]
            json.dump(flashObject2Dict(newdata[modname]['modsettings']), outfile, sort_keys=True, indent=4, separators=(',', ': '),ensure_ascii=True)
        if(fromIngame==1):
            try:
                #print "Callback", ModSettingsAPI.mods[modname]
                if("callback" in flashObject2Dict(ModSettingsAPI.mods[modname]['layout'])):
                    callbackFunction = flashObject2Dict(ModSettingsAPI.mods[modname]['layout'])["callback"]
                    self.callRegisteredFunction(callbackFunction, None, flashObject2Dict(newdata[modname]['modsettings']))
            except Exception, err:
                print "Error on callback for",modname,":", err
def writeModDataToDisk(self, newdata, fromIngame=0):
    newdata = flashObject2Dict(newdata)
    #print "received ModData from flash:"
    #print newdata
    #ModSettingsAPI.mods = newdata #DICKES TODO: UNION statt replacement
    for key in ModSettingsAPI.mods:
        #print 'saving mod '+key
        ModSettingsAPI.mods[key] = newdata[key]
    #print '[ModsSettings] saving all configs to disk'#, newdata

    if not os.path.exists(ModSettingsAPI.MODSETTINGSPATH):
        os.makedirs(ModSettingsAPI.MODSETTINGSPATH)
    for modname in newdata:
        #print '[ModsSettings] saving mod',modname
        with open(ModSettingsAPI.MODSETTINGSPATH + modname + '.cfg',
                  'w') as outfile:
            # Settings are stored in [modname][2]
            json.dump(flashObject2Dict(newdata[modname]['modsettings']),
                      outfile,
                      sort_keys=True,
                      indent=4,
                      separators=(',', ': '),
                      ensure_ascii=True)
        if (fromIngame == 1):
            try:
                #print "Callback", ModSettingsAPI.mods[modname]
                if ("callback" in flashObject2Dict(
                        ModSettingsAPI.mods[modname]['layout'])):
                    callbackFunction = flashObject2Dict(
                        ModSettingsAPI.mods[modname]['layout'])["callback"]
                    self.callRegisteredFunction(
                        callbackFunction, None,
                        flashObject2Dict(newdata[modname]['modsettings']))
            except Exception, err:
                print "Error on callback for", modname, ":", err
Beispiel #3
0
    def sell(self, vehicleCD, shells, eqs, optDevs, inventory, isDismissCrew):
        """
        Make server request to sell given @vehicle. Called from flash.
        
        @param vehicle: <dict> vehicle packed data to sell
        @param shells: <list> list of shells items to sell
        @param eqs: <list> list of equipment items to sell
        @param optDevs: <list> list of optional devices to sell
        @param inventory: <list> list of inventory items to sell
        @param isDismissCrew: <bool> is dismiss crew
        """
        def getItem(data):
            return self.itemsCache.items.getItemByCD(int(data['intCD']))

        def getShellItem(data):
            return Shell(int(data['intCD']),
                         int(data['count']),
                         proxy=self.itemsCache.items)

        try:
            vehicle = self.itemsCache.items.getItemByCD(int(vehicleCD))
            shells = [
                getShellItem(flashObject2Dict(shell)) for shell in shells
            ]
            eqs = [getItem(flashObject2Dict(eq)) for eq in eqs]
            optDevs = [getItem(flashObject2Dict(dev)) for dev in optDevs]
            inventory = [
                getItem(flashObject2Dict(module)) for module in inventory
            ]
            self.__doSellVehicle(vehicle, shells, eqs, optDevs, inventory,
                                 isDismissCrew)
        except Exception:
            LOG_ERROR('There is error while selling vehicle')
            LOG_CURRENT_EXCEPTION()
Beispiel #4
0
    def sell(self, vehicleCD, shells, eqs, optDevicesToSell, inventory,
             customizationItems, isDismissCrew):
        def getItem(data):
            return self.itemsCache.items.getItemByCD(int(data['intCD']))

        def getShellItem(data):
            return Shell(int(data['intCD']),
                         int(data['count']),
                         proxy=self.itemsCache.items)

        try:
            vehicle = self.itemsCache.items.getItemByCD(int(vehicleCD))
            shells = [
                getShellItem(flashObject2Dict(shell)) for shell in shells
            ]
            eqs = [getItem(flashObject2Dict(eq)) for eq in eqs]
            optDevicesToSell = [
                getItem(flashObject2Dict(dev)) for dev in optDevicesToSell
            ]
            inventory = [
                getItem(flashObject2Dict(module)) for module in inventory
            ]
            self.__doSellVehicle(vehicle, shells, eqs, optDevicesToSell,
                                 inventory, isDismissCrew)
        except Exception:
            LOG_ERROR('There is error while selling vehicle')
            LOG_CURRENT_EXCEPTION()
Beispiel #5
0
 def __init__(self, ctx=None):
     super(PackItemsPopover, self).__init__(ctx)
     self.__data = flashObject2Dict(ctx.get('data'))
     self.__rawItems = []
     for item in self.__data.get('items'):
         item = flashObject2Dict(item)
         self.__rawItems.append(ItemPackEntry(type=item.get('type'), id=int(item.get('id')), count=item.get('rawCount') or 0, groupID=item.get('groupID'), title=item.get('title'), description=item.get('description')))
Beispiel #6
0
 def requestTableData(self, nation, actionsSelected, tabType, f):
     Waiting.show('updateShop')
     f = flashObject2Dict(f)
     itemCD = AccountSettings.getFilter('scroll_to_item')
     AccountSettings.setFilter('shop_current',
                               (nation, tabType, actionsSelected))
     AccountSettings.setFilter('shop_' + tabType, flashObject2Dict(f))
     AccountSettings.setFilter('scroll_to_item', None)
     self._setTableData(f, nation, tabType, actionsSelected, itemCD)
     Waiting.hide('updateShop')
     return
    def _populate(self):
        super(PackItemsPopover, self)._populate()
        pack = flashObject2Dict(self.__rawData)
        title = '{}\n{}'.format(text_styles.highTitle(pack.get('title', TOOLTIPS.VEHICLEPREVIEW_SHOPPACK_TITLE)), text_styles.main(makeString(pack.get('desc', TOOLTIPS.VEHICLEPREVIEW_SHOPPACK_DESC), count=pack.get('count'))))
        items = []
        for item in pack.get('items'):
            item = flashObject2Dict(item)
            items.append({'value': item.get('count'),
             'icon': item.get('icon'),
             'description': item.get('desc'),
             'hasCompensation': item.get('hasCompensation', False)})

        self.as_setItemsS(title, items)
Beispiel #8
0
 def requestTableData(self, nation, type, filter):
     """
     Request table data for selected tab
     :param type: <str> tab ID
     :param nation: <int> gui nation
     :param filter: <obj> filter data
     """
     Waiting.show('updateShop')
     AccountSettings.setFilter('shop_current', (nation, type))
     filter = flashObject2Dict(filter)
     AccountSettings.setFilter('shop_' + type, flashObject2Dict(filter))
     self._setTableData(filter, nation, type)
     Waiting.hide('updateShop')
Beispiel #9
0
 def requestTableData(self, nation, type, filter):
     """
     Request table data for selected tab
     :param type: <str> tab ID
     :param nation: <int> gui nation
     :param filter: <obj> filter data
     """
     Waiting.show("updateShop")
     AccountSettings.setFilter("shop_current", (nation, type))
     filter = flashObject2Dict(filter)
     AccountSettings.setFilter("shop_" + type, flashObject2Dict(filter))
     self._setTableData(filter, nation, type)
     Waiting.hide("updateShop")
Beispiel #10
0
    def _populate(self):
        super(PackItemsPopover, self)._populate()
        pack = flashObject2Dict(self.__rawData)
        title = text_styles.highTitle(pack.get('title', backport.text(_R_SHOP_PACK.title())))
        items = []
        for item in pack.get('items'):
            item = flashObject2Dict(item)
            count = item.get('count') or 0
            items.append({'value': backport.text(_R_SHOP_PACK.count()).format(count=count) if count > 1 else None,
             'icon': item.get('icon'),
             'overlayType': item.get('overlay'),
             'description': item.get('desc'),
             'hasCompensation': item.get('hasCompensation', False)})

        self.as_setItemsS(title, items)
        return
Beispiel #11
0
    def _packBlocks(self, *args, **kwargs):
        items = super(AdditionalAwardTooltipData, self)._packBlocks()
        items.append(
            formatters.packTextBlockData(text_styles.middleTitle(
                TOOLTIPS.QUESTS_AWARDS_ADDITIONAL_HEADER),
                                         padding=formatters.packPadding(
                                             top=8, bottom=8)))
        for bonus in args:
            bonusDict = flashObject2Dict(bonus)
            bonusName = bonusDict.get('name', '')
            imgSource = bonusDict.get('imgSource', '')
            label = bonusDict.get('label', '')
            items.append(
                formatters.packRendererTextBlockData(
                    rendererType='AwardItemExUI',
                    dataType='net.wg.gui.data.AwardItemVO',
                    title=text_styles.main(bonusName),
                    rendererData={
                        'imgSource': imgSource,
                        'label': label
                    },
                    padding=formatters.packPadding(top=-10, bottom=-10),
                    txtPadding=formatters.packPadding(top=15, left=10),
                    titleAtMiddle=True))
            if len(items) > _MAX_AWARDS_PER_TOOLTIP:
                count = len(args) - len(items) + 1
                if count > 0:
                    items.append(
                        formatters.packTextBlockData(
                            text_styles.main(
                                _ms(TOOLTIPS.QUESTS_AWARDS_ADDITIONAL_BOTTOM,
                                    count=count))))
                break

        return items
Beispiel #12
0
    def _packBlocks(self, *args, **kwargs):
        items = super(AdditionalAwardTooltipData, self)._packBlocks()
        items.append(formatters.packTextBlockData(text_styles.middleTitle(TOOLTIPS.QUESTS_AWARDS_ADDITIONAL_HEADER), padding=formatters.packPadding(top=8, bottom=8)))
        for bonus in args:
            bonusDict = flashObject2Dict(bonus)
            bonusName = bonusDict.get('name', '')
            imgSource = bonusDict.get('imgSource', '')
            label = bonusDict.get('label', '')
            highlight = bonusDict.get('highlightIcon', '')
            overlay = bonusDict.get('overlayIcon', '')
            rendererData = {'imgSource': imgSource,
             'label': label,
             'highlight': highlight,
             'overlay': overlay}
            if overlay:
                rendererType = 'EquipmentAwardItemExUI'
                padding = formatters.packPadding(top=-35, bottom=-30)
            else:
                rendererType = 'AwardItemExUI'
                padding = formatters.packPadding(top=-7, bottom=-12)
            items.append(formatters.packRendererTextBlockData(rendererType=rendererType, dataType='net.wg.gui.data.AwardItemVO', title=text_styles.main(bonusName), rendererData=rendererData, padding=padding, txtPadding=formatters.packPadding(top=15, left=15), titleAtMiddle=True))
            if len(items) > _MAX_AWARDS_PER_TOOLTIP:
                count = len(args) - len(items) + 1
                if count > 0:
                    items.append(formatters.packTextBlockData(text_styles.main(backport.text(R.strings.tooltips.quests.awards.additional.bottom(), count=count))))
                break

        return items
Beispiel #13
0
 def requestTableData(self, nation, actionsSelected, type, filter):
     """
     Request table data for selected tab
     :param type: <str> tab ID
     :param nation: <int> gui nation
     :param actionsSelected: <bool> discount's checkbox value
     :param filter: <obj> filter data
     """
     Waiting.show('updateShop')
     filter = flashObject2Dict(filter)
     itemCD = AccountSettings.getFilter('scroll_to_item')
     AccountSettings.setFilter('shop_current',
                               (nation, type, actionsSelected))
     AccountSettings.setFilter('shop_' + type, flashObject2Dict(filter))
     AccountSettings.setFilter('scroll_to_item', None)
     self._setTableData(filter, nation, type, actionsSelected, itemCD)
     Waiting.hide('updateShop')
     return
 def onCountersVisited(self, counters):
     for counterGfxData in counters:
         counterData = flashObject2Dict(counterGfxData)
         valToSearch = (counterData['componentId'],
                        counterData['selectedIdx'])
         prefName = _COUNTERS_MAP.keys()[_COUNTERS_MAP.values().index(
             valToSearch)]
         self.__setCountersData(prefName, counter=0)
         self.__setVisited(prefName)
Beispiel #15
0
 def requestTableData(self, nation, type, filter):
     """
     Request table data for selected tab
     :param type: <str> tab ID
     :param nation: <int> gui nation
     :param filter: <obj> filter data
     """
     Waiting.show('updateInventory')
     AccountSettings.setFilter('inventory_current', (nation, type))
     filter = flashObject2Dict(filter)
     AccountSettings.setFilter('inventory_' + type, filter)
     self._setTableData(filter, nation, type)
     Waiting.hide('updateInventory')
 def sell(self, vehicleCD, shells, eqs, optDevs, inventory, isDismissCrew):
     """
     Make server request to sell given @vehicle. Called from flash.
     
     @param vehicle: <dict> vehicle packed data to sell
     @param shells: <list> list of shells items to sell
     @param eqs: <list> list of equipment items to sell
     @param optDevs: <list> list of optional devices to sell
     @param inventory: <list> list of inventory items to sell
     @param isDismissCrew: <bool> is dismiss crew
     """
     getItem = lambda data: g_itemsCache.items.getItemByCD(int(data['intCD']))
     getShellItem = lambda data: Shell(int(data['intCD']), int(data['count']), proxy=g_itemsCache.items)
     try:
         vehicle = g_itemsCache.items.getItemByCD(int(vehicleCD))
         shells = [ getShellItem(flashObject2Dict(shell)) for shell in shells ]
         eqs = [ getItem(flashObject2Dict(eq)) for eq in eqs ]
         optDevs = [ getItem(flashObject2Dict(dev)) for dev in optDevs ]
         inventory = [ getItem(flashObject2Dict(module)) for module in inventory ]
         self.__doSellVehicle(vehicle, shells, eqs, optDevs, inventory, isDismissCrew)
     except Exception:
         LOG_ERROR('There is error while selling vehicle')
         LOG_CURRENT_EXCEPTION()
Beispiel #17
0
 def onApply(self, diff):
     diff = flashObject2Dict(diff)
     AccountSettings.setSettings(COLOR_SETTINGS_TAB_IDX, self.__selectedTabIdx)
     if self.__selectedTabIdx == TABS.CUSTOM:
         if self.__hasChangesInSettings(settings_constants.GRAPHICS.getCustomColorSettings(), diff):
             diff.update({settings_constants.GRAPHICS.COLOR_GRADING_TECHNIQUE: COLOR_GRADING_TECHNIQUE_DEFAULT})
         diff[COLOR_SETTINGS.COLOR_GRADING_TECHNIQUE] = 0
         diff[COLOR_SETTINGS.COLOR_FILTER_INTENSITY] = 25
     self.settingsCore.applySettings(diff)
     lastAppliedSettings = AccountSettings.getSettings(APPLIED_COLOR_SETTINGS)
     lastAppliedSettings[self.__selectedTabIdx] = diff
     AccountSettings.setSettings(APPLIED_COLOR_SETTINGS, lastAppliedSettings)
     BigWorld.commitPendingGraphicsSettings()
     self.destroy()
    def applySettings(self, settings, isCloseWnd):
        settings = flashObject2Dict(settings)
        applyMethod = self.params.getApplyMethod(settings)

        def confirmHandler(isOk):
            self.__commitSettings(settings, isOk)
            if isOk and isCloseWnd:
                self.closeWindow()

        if applyMethod == APPLY_METHOD.RESTART:
            DialogsInterface.showI18nConfirmDialog('graphicsPresetRestartConfirmation', confirmHandler)
        elif applyMethod == APPLY_METHOD.DELAYED:
            DialogsInterface.showI18nConfirmDialog('graphicsPresetDelayedConfirmation', confirmHandler)
        else:
            confirmHandler(True)
Beispiel #19
0
    def applySettings(self, settings, isCloseWnd):
        settings = flashObject2Dict(settings)
        applyMethod = self.params.getApplyMethod(settings)

        def confirmHandler(isOk):
            self.__commitSettings(settings, isOk)
            if isOk and isCloseWnd:
                self.closeWindow()

        if applyMethod == APPLY_METHOD.RESTART:
            DialogsInterface.showI18nConfirmDialog(
                'graphicsPresetRestartConfirmation', confirmHandler)
        elif applyMethod == APPLY_METHOD.DELAYED:
            DialogsInterface.showI18nConfirmDialog(
                'graphicsPresetDelayedConfirmation', confirmHandler)
        else:
            confirmHandler(True)
Beispiel #20
0
    def _packBlocks(self, *args, **kwargs):
        items = super(RentVehicleAwardTooltipData, self)._packBlocks()
        blocks = list()
        blocks.append(formatters.packTextBlockData(text_styles.middleTitle(TOOLTIPS.QUESTS_AWARDS_VEHICLERENT_HEADER), padding=formatters.packPadding(top=8)))
        blocks.append(formatters.packTextParameterWithIconBlockData(name=text_styles.premiumVehicleName(TOOLTIPS.QUESTS_AWARDS_VEHICLERENT_EXPIRE), value='', icon=ICON_TEXT_FRAMES.RENTALS, padding=formatters.packPadding(left=-60), iconYOffset=3))
        items.append(formatters.packBuildUpBlockData(blocks, padding=formatters.packPadding(bottom=-19)))
        blocks = list()
        vehiclesCount = 0
        for rentVehicleData in args:
            rentVehicleData = flashObject2Dict(rentVehicleData)
            vehicleName = rentVehicleData.get('vehicleName', '')
            vehicleType = rentVehicleData.get('vehicleType', '')
            isPremiumVehicle = rentVehicleData.get('isPremium', True)
            rentLeftCount = 0
            rentTypeName = None
            for rentType in _RENT_TYPES:
                rentTypeValue = rentVehicleData.get(rentType, 0)
                if rentTypeValue > 0:
                    rentTypeName = rentType
                    rentLeftCount = rentTypeValue
                    break

            if isPremiumVehicle:
                imgPaddings = formatters.packPadding(right=2)
            else:
                imgPaddings = formatters.packPadding(left=5, right=5, top=4)
            blocks.append(formatters.packImageTextBlockData(title=text_styles.highlightText(vehicleName), img=getTypeSmallIconPath(vehicleType, isPremiumVehicle), imgPadding=imgPaddings, txtPadding=formatters.packPadding(left=2)))
            if rentTypeName is not None and rentLeftCount > 0:
                rentCountStr = text_styles.premiumVehicleName(rentLeftCount)
                rentLeftStr = _ms(TOOLTIPS.getRentLeftTypeLabel(rentTypeName), count=rentCountStr)
                blocks.append(formatters.packTextBlockData(text_styles.main(rentLeftStr), padding=formatters.packPadding(left=28, top=-8, bottom=5)))
            vehiclesCount += 1
            if vehiclesCount >= _MAX_AWARDS_PER_TOOLTIP:
                count = len(args) - vehiclesCount
                if count > 0:
                    blocks.append(formatters.packTextBlockData(text_styles.main(backport.text(R.strings.tooltips.quests.awards.additional.bottom(), count=count))))
                break

        items.append(formatters.packBuildUpBlockData(blocks, padding=formatters.packPadding(bottom=-12)))
        return items
Beispiel #21
0
 def applySettings(self, settings, isCloseWnd):
     self._applySettings(flashObject2Dict(settings), isCloseWnd)
Beispiel #22
0
 def onSettingsChange(self, settingName, settingValue):
     settingValue = flashObject2Dict(settingValue)
     self.params.preview(settingName, settingValue)
 def applySettings(self, settings, isCloseWnd):
     self._applySettings(flashObject2Dict(settings), isCloseWnd)
 def onSettingsChange(self, settingName, settingValue):
     settingValue = flashObject2Dict(settingValue)
     LOG_DEBUG('onSettingsChange', settingName, settingValue)
     self.params.preview(settingName, settingValue)
 def onSettingsChange(self, settingName, settingValue):
     settingValue = flashObject2Dict(settingValue)
     LOG_DEBUG('onSettingsChange', settingName, settingValue)
     self.settingsCore.previewSetting(settingName, settingValue)
     self.__tabsPreviewSettings[
         self.__selectedTabIdx][settingName] = settingValue