def _readDefaultColors(cache, xmlCtx, section, sectionName): for tag, iSection in section.items(): if tag != sectionName: continue nation = ix.readString(xmlCtx, iSection, 'nation') color = iv._readColor(xmlCtx, iSection, 'color') cache.defaultColors[nations.INDICES[nation]] = color
def _readDefaultColors(cache, xmlCtx, section, sectionName): for tag, iSection in section.items(): if tag != sectionName: continue nation = ix.readString(xmlCtx, iSection, 'nation') colors = [] scolors = iSection['colors'] for idx, (ctag, csection) in enumerate(scolors.items()): colors.append( iv._readColor((xmlCtx, 'color {}'.format(idx)), scolors, ctag)) cache.defaultColors[nations.INDICES[nation]] = tuple(colors)
def _readFromXml(self, target, xmlCtx, section): super(PaintXmlReader, self)._readFromXml(target, xmlCtx, section) if section.has_key('color'): target.color = iv._readColor(xmlCtx, section, 'color') if section.has_key('gloss'): target.gloss = ix.readFloat(xmlCtx, section, 'gloss', 0.0) if section.has_key('metallic'): target.metallic = ix.readFloat(xmlCtx, section, 'metallic', 0.0) if section.has_key('usages'): xmlSubCtx = (xmlCtx, 'usages') for name, sub in ix.getChildren(xmlCtx, section, 'usages'): ctype, cost = self._readUsage(xmlSubCtx, sub) for i in ApplyArea.RANGE: if ctype & i: target.usageCosts[i] = cost
def _readDefault(cache, xmlCtx, section, sectionName): for tag, iSection in section.items(): if tag != sectionName: continue nation = ix.readString(xmlCtx, iSection, 'nation') colors = [] scolors = iSection['colors'] for idx, (ctag, csection) in enumerate(scolors.items()): colors.append( iv._readColor((xmlCtx, 'color {}'.format(idx)), scolors, ctag)) cache.defaultColors[nations.INDICES[nation]] = tuple(colors) itemId = ix.readInt(xmlCtx, iSection, 'insignia_id') cache.defaultInsignias[nations.INDICES[nation]] = itemId if iSection.has_key('top_vehicle'): topVehicle = ix.readString(xmlCtx, iSection, 'top_vehicle') cache.topVehiclesByNation[nation] = topVehicle
def _readFromXml(self, target, xmlCtx, section, cache=None): super(CamouflageXmlReader, self)._readFromXml(target, xmlCtx, section) target.compatibleParts = readFlagEnum(xmlCtx, section, 'compatibleParts', ApplyArea, target.compatibleParts) target.componentsCovering = readFlagEnum(xmlCtx, section, 'componentsCovering', ApplyArea, target.componentsCovering) target.invisibilityFactor = section.readFloat('invisibilityFactor', 1.0) target.glossMetallicSettings = { 'glossMetallicMap': section.readString('glossMetallicMap', ''), 'gloss': section.readVector4('gloss', Math.Vector4(DEFAULT_GLOSS)), 'metallic': section.readVector4('metallic', Math.Vector4(DEFAULT_METALLIC)) } if IS_EDITOR: target.editorData.glossMetallicSettingsType = 0 if target.glossMetallicSettings['glossMetallicMap'] != '': target.editorData.glossMetallicSettingsType = 1 editorOnlySection = c11n.getEditorOnlySection(section) if editorOnlySection is not None: target.editorData.paletteIndex = editorOnlySection.readInt( 'paletteIndex', 0) if section.has_key('palettes'): palettes = [] spalettes = section['palettes'] for pname, psection in spalettes.items(): res = [] pctx = (xmlCtx, 'palettes') for j, (cname, csection) in enumerate(psection.items()): res.append( iv._readColor((pctx, 'palette %s' % (j, )), psection, cname)) palettes.append(res) target.palettes = tuple(palettes) return
def _readFromXml(self, target, xmlCtx, section): super(LegacyCamouflageReader, self)._readFromXml(target, xmlCtx, section) if section.has_key('colors'): palette = [] for c_name in section['colors'].keys(): palette.append( iv._readColor((xmlCtx, 'colors'), section['colors'], c_name)) target.palettes = (palette, ) if g_config.data['fullAlpha']: for paletteNum in xrange(len(target.palettes)): for idx, color in enumerate(target.palettes[paletteNum]): rgba = [] for _ in xrange(3): rgba.append(color - (color >> 8 << 8)) color = color >> 8 rgba.append(255) target.palettes[paletteNum][idx] = rgba[0] + ( rgba[1] << 8) + (rgba[2] << 16) + (rgba[3] << 24)
def _readFromXml(self, target, xmlCtx, section): super(CamouflageXmlReader, self)._readFromXml(target, xmlCtx, section) target.compatibleParts = readFlagEnum(xmlCtx, section, 'compatibleParts', ApplyArea, target.compatibleParts) target.componentsCovering = readFlagEnum(xmlCtx, section, 'componentsCovering', ApplyArea, target.componentsCovering) target.invisibilityFactor = section.readFloat('invisibilityFactor', 1.0) if section.has_key('palettes'): palettes = [] spalettes = section['palettes'] for pname, psection in spalettes.items(): res = [] pctx = (xmlCtx, 'palettes') for j, (cname, csection) in enumerate(psection.items()): res.append( iv._readColor((pctx, 'palette %s' % (j, )), psection, cname)) palettes.append(res) target.palettes = tuple(palettes)